aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Moon Flower <mforoud86@gmail.com> 2026-03-02 16:06:18 +0330
committerGravatar Moon Flower <mforoud86@gmail.com> 2026-03-02 16:06:18 +0330
commit2381414196b7b001c9e6e7e8fc0046ffe320967f (patch)
tree5b4a258593d2a19f2f64ee476888a62472696ee1
parentblob changes, times, polling, etc (diff)
randomBytes polyfill
-rw-r--r--client/public/crypto.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/client/public/crypto.ts b/client/public/crypto.ts
index ab83517..476d713 100644
--- a/client/public/crypto.ts
+++ b/client/public/crypto.ts
@@ -3,7 +3,6 @@ import { hkdf } from '@noble/hashes/hkdf.js'
import { pbkdf2 } from '@noble/hashes/pbkdf2.js'
import { sha256 } from '@noble/hashes/sha2.js'
import { gcm } from '@noble/ciphers/aes.js'
-import { randomBytes as nodeRandomBytes } from 'node:crypto'
const B64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
@@ -77,7 +76,8 @@ function randomBytes(n: number): Uint8Array {
(_g['crypto'] as Crypto).getRandomValues(buf)
return buf
}
- return new Uint8Array(nodeRandomBytes(n))
+ // what can i do.
+ return new Uint8Array(new Array(n).fill(0).map(e => Math.floor(Math.random() * 256)))
}
const _wc: Record<string, boolean | undefined> = {}