File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,15 +16,19 @@ import { Buffer } from './buffer.js'
1616
1717import * as exports from './crypto.js'
1818
19- let getRandomValuesFallback = null
19+ /**
20+ * WebCrypto API
21+ * @see {https://developer.mozilla.org/en-US/docs/Web/API/Crypto}
22+ */
23+ export let webcrypto = globalThis . crypto ?. webcrypto ?? globalThis . crypto
2024
2125const pending = [ ]
2226
2327if ( globalThis ?. process ?. versions ?. node ) {
2428 pending . push (
2529 import ( 'node:crypto' )
2630 . then ( ( module ) => {
27- getRandomValuesFallback = module . getRandomValues
31+ webcrypto = module . webcrypto
2832 } )
2933 )
3034}
@@ -54,12 +58,6 @@ export const ready = Promise.all(pending)
5458 */
5559export { sodium }
5660
57- /**
58- * WebCrypto API
59- * @see {https://developer.mozilla.org/en-US/docs/Web/API/Crypto}
60- */
61- export const webcrypto = globalThis . crypto ?. webcrypto ?? globalThis . crypto
62-
6361/**
6462 * Generate cryptographically strong random values into the `buffer`
6563 * @param {TypedArray } buffer
@@ -76,8 +74,6 @@ export function getRandomValues (buffer, ...args) {
7674 const output = toBuffer ( buffer )
7775 input . copy ( output )
7876 return buffer
79- } else if ( typeof getRandomValuesFallback === 'function' ) {
80- return getRandomValuesFallback ( buffer , ...args )
8177 }
8278
8379 console . warn ( 'Missing implementation for globalThis.crypto.getRandomValues()' )
You can’t perform that action at this time.
0 commit comments