about summary refs log tree commit diff
path: root/src/platform/polyfills.native.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/polyfills.native.ts')
-rw-r--r--src/platform/polyfills.native.ts12
1 files changed, 11 insertions, 1 deletions
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)