Move the secure-random code into this project due to build issues with the module, which is no longer maintained

This commit is contained in:
Paul Frazee 2022-06-15 22:08:28 -05:00
parent 2c73703d7d
commit a56cae626a
12 changed files with 110 additions and 18 deletions

View file

@ -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)