diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-06-15 22:08:28 -0500 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-06-15 22:08:28 -0500 |
commit | a56cae626abf6c553cd9756db875c8ab5f903879 (patch) | |
tree | 4c2c8ef9f00006a573959db84c8e3b037105a0bd /src | |
parent | 2c73703d7d59bdd9a3e4b10c41e5099b8f92db1c (diff) | |
download | voidsky-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')
-rw-r--r-- | src/platform/polyfills.native.ts | 12 |
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) |