From e2cfa136f9a357550277e2b0b343e9cdf2fd970c Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sun, 22 Feb 2026 19:37:19 +0300 Subject: [PATCH] fix: alias crypto-browserify to native Web Crypto shim (inherits error) --- web/src/polyfills/crypto-shim.ts | 11 +++++++++++ web/vite.config.ts | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 web/src/polyfills/crypto-shim.ts diff --git a/web/src/polyfills/crypto-shim.ts b/web/src/polyfills/crypto-shim.ts new file mode 100644 index 00000000..6b7a4b7c --- /dev/null +++ b/web/src/polyfills/crypto-shim.ts @@ -0,0 +1,11 @@ +// Minimal crypto shim that delegates to the browser's native Web Crypto API +// Prevents crypto-browserify (and its inherits dependency) from being bundled +export default globalThis.crypto; +export const webcrypto = globalThis.crypto; +export const randomBytes = (size: number): Uint8Array => { + const bytes = new Uint8Array(size); + globalThis.crypto.getRandomValues(bytes); + return bytes; +}; +export const createHash = undefined; +export const createHmac = undefined; diff --git a/web/vite.config.ts b/web/vite.config.ts index 1531a835..0c04a372 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -75,6 +75,8 @@ export default defineConfig(() => ({ 'vite-plugin-node-polyfills/shims/buffer': path.resolve(__dirname, './src/polyfills/buffer-shim.ts'), 'vite-plugin-node-polyfills/shims/global': path.resolve(__dirname, './src/polyfills/global-shim.ts'), 'vite-plugin-node-polyfills/shims/process': path.resolve(__dirname, './src/polyfills/process-shim.ts'), + // Prevent crypto-browserify chain (inherits error) - use native Web Crypto API + 'crypto-browserify': path.resolve(__dirname, './src/polyfills/crypto-shim.ts'), }, dedupe: ['react', 'lucide-react', 'sonner', '@pezkuwi/util-crypto', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring'], },