about summary refs log tree commit diff
path: root/src/platform/polyfills.native.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-06-15 22:08:28 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-06-15 22:08:28 -0500
commita56cae626abf6c553cd9756db875c8ab5f903879 (patch)
tree4c2c8ef9f00006a573959db84c8e3b037105a0bd /src/platform/polyfills.native.ts
parent2c73703d7d59bdd9a3e4b10c41e5099b8f92db1c (diff)
downloadvoidsky-a56cae626abf6c553cd9756db875c8ab5f903879.tar.zst
Move the secure-random code into this project due to build issues with the module, which is no longer maintained
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)