Remove webcrypto polyfill, as it's no longer needed
This commit is contained in:
parent
4eb8bc1249
commit
810fcf9910
11 changed files with 11 additions and 10364 deletions
|
@ -5,7 +5,6 @@ import {RootSiblingParent} from 'react-native-root-siblings'
|
|||
import {GestureHandlerRootView} from 'react-native-gesture-handler'
|
||||
import SplashScreen from 'react-native-splash-screen'
|
||||
import {SafeAreaProvider} from 'react-native-safe-area-context'
|
||||
import {whenWebCrypto} from './platform/polyfills.native'
|
||||
import * as view from './view/index'
|
||||
import {RootStoreModel, setupState, RootStoreProvider} from './state'
|
||||
import {MobileShell} from './view/shell/mobile'
|
||||
|
@ -17,23 +16,19 @@ function App() {
|
|||
|
||||
// init
|
||||
useEffect(() => {
|
||||
whenWebCrypto
|
||||
.then(() => {
|
||||
view.setup()
|
||||
return setupState()
|
||||
})
|
||||
.then(store => {
|
||||
setRootStore(store)
|
||||
SplashScreen.hide()
|
||||
Linking.getInitialURL().then((url: string | null) => {
|
||||
if (url) {
|
||||
store.nav.handleLink(url)
|
||||
}
|
||||
})
|
||||
Linking.addEventListener('url', ({url}) => {
|
||||
view.setup()
|
||||
setupState().then(store => {
|
||||
setRootStore(store)
|
||||
SplashScreen.hide()
|
||||
Linking.getInitialURL().then((url: string | null) => {
|
||||
if (url) {
|
||||
store.nav.handleLink(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
Linking.addEventListener('url', ({url}) => {
|
||||
store.nav.handleLink(url)
|
||||
})
|
||||
})
|
||||
}, [])
|
||||
|
||||
// show nothing prior to init
|
||||
|
|
|
@ -1,30 +1 @@
|
|||
import {NativeModules} from 'react-native'
|
||||
const {AppSecureRandomModule} = NativeModules
|
||||
import {toByteArray} from 'base64-js'
|
||||
// @ts-ignore we dont have types for this -prf
|
||||
import crypto from '../third-party/msrcrypto'
|
||||
import '@zxing/text-encoding' // TextEncoder / TextDecoder
|
||||
|
||||
async function generateSecureRandom(bytes: number) {
|
||||
return toByteArray(
|
||||
await AppSecureRandomModule.generateSecureRandomAsBase64(bytes),
|
||||
)
|
||||
}
|
||||
|
||||
export const whenWebCrypto = new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const bytes = await generateSecureRandom(48)
|
||||
crypto.initPrng(Array.from(bytes))
|
||||
|
||||
// @ts-ignore global.window exists -prf
|
||||
if (!global.window.crypto) {
|
||||
// @ts-ignore global.window exists -prf
|
||||
global.window.crypto = crypto
|
||||
}
|
||||
resolve(true)
|
||||
} catch (e: any) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
|
||||
export const webcrypto = crypto
|
||||
|
|
10144
src/third-party/msrcrypto.js
vendored
10144
src/third-party/msrcrypto.js
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue