From 2381414196b7b001c9e6e7e8fc0046ffe320967f Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 2 Mar 2026 16:06:18 +0330 Subject: randomBytes polyfill --- client/public/crypto.ts | 4 ++-- 1 file 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 = {} -- cgit v1.2.3