From a56cae626abf6c553cd9756db875c8ab5f903879 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 15 Jun 2022 22:08:28 -0500 Subject: Move the secure-random code into this project due to build issues with the module, which is no longer maintained --- src/platform/polyfills.native.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/platform/polyfills.native.ts') diff --git a/src/platform/polyfills.native.ts b/src/platform/polyfills.native.ts index b4d38f04f..0c9f30582 100644 --- a/src/platform/polyfills.native.ts +++ b/src/platform/polyfills.native.ts @@ -1,7 +1,17 @@ -import {generateSecureRandom} from 'react-native-securerandom' +// import {generateSecureRandom} from 'react-native-securerandom' +import {NativeModules} from 'react-native' +const {AppSecureRandomModule} = NativeModules +import {toByteArray} from 'base64-js' import crypto from 'msrcrypto' import '@zxing/text-encoding' // TextEncoder / TextDecoder +async function generateSecureRandom(bytes: number) { + console.log('a') + return toByteArray( + await AppSecureRandomModule.generateSecureRandomAsBase64(bytes), + ) +} + export const whenWebCrypto = new Promise(async (resolve, reject) => { try { const bytes = await generateSecureRandom(48) -- cgit 1.4.1