Skip to content

Commit c9f1ed6

Browse files
committed
utils.randomBytes: ensure same return type Uint8Array in old nodejs
1 parent cb4b7ff commit c9f1ed6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/webcrypto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function randomBytes(bytesLength = 32): Uint8Array {
2222
}
2323
// Legacy Node.js compatibility
2424
if (crypto && typeof crypto.randomBytes === 'function') {
25-
return crypto.randomBytes(bytesLength);
25+
return Uint8Array.from(crypto.randomBytes(bytesLength));
2626
}
2727
throw new Error('crypto.getRandomValues must be defined');
2828
}

0 commit comments

Comments
 (0)