Skip to content

Commit cf654f8

Browse files
authored
fix: Use Web Crypto compatible function for nonce generation (#817)
1 parent 7fa4e0b commit cf654f8

File tree

2 files changed

+153
-187
lines changed

2 files changed

+153
-187
lines changed

src/steps/csp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ function shouldApplyNonce(metaCSPText, headersCSPText) {
5959
* @returns {string}
6060
*/
6161
function createNonce() {
62-
return cryptoImpl.randomBytes(18).toString('base64');
62+
const array = new Uint8Array(18);
63+
cryptoImpl.getRandomValues(array);
64+
return btoa(String.fromCharCode(...array));
6365
}
6466

6567
/**

0 commit comments

Comments
 (0)