diff options
Diffstat (limited to 'src/platform/polyfills.native.ts')
-rw-r--r-- | src/platform/polyfills.native.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/platform/polyfills.native.ts b/src/platform/polyfills.native.ts new file mode 100644 index 000000000..b4d38f04f --- /dev/null +++ b/src/platform/polyfills.native.ts @@ -0,0 +1,21 @@ +import {generateSecureRandom} from 'react-native-securerandom' +import crypto from 'msrcrypto' +import '@zxing/text-encoding' // TextEncoder / TextDecoder + +export const whenWebCrypto = new Promise(async (resolve, reject) => { + try { + const bytes = await generateSecureRandom(48) + crypto.initPrng(Array.from(bytes)) + + // @ts-ignore global.window exists -prf + if (!global.window.crypto) { + // @ts-ignore global.window exists -prf + global.window.crypto = crypto + } + resolve(true) + } catch (e: any) { + reject(e) + } +}) + +export const webcrypto = crypto |