Import apps/android/src/polyfills.ts

This commit is contained in:
QQ 2026-11-14 14:11:46 +08:00
parent 7523ef7ba8
commit 2122747fde
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import * as ExpoCrypto from 'expo-crypto'
// Noble's browser builds resolve the Web Crypto random source while their
// modules are being evaluated. Install the native Expo implementation before
// importing App (and therefore before importing @dsh-remote/crypto).
const currentCrypto = globalThis.crypto
if (currentCrypto?.getRandomValues === undefined) {
Object.defineProperty(globalThis, 'crypto', {
value: {
...currentCrypto,
getRandomValues: ExpoCrypto.getRandomValues,
randomUUID: ExpoCrypto.randomUUID,
},
configurable: true,
})
}