forked from XRPL-Labs/Xaman-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.ts
27 lines (21 loc) · 779 Bytes
/
global.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* eslint-disable */
// Native modules
import { NativeModules } from 'react-native';
const { CryptoModule } = NativeModules;
global.Buffer = require('buffer').Buffer;
global.process = require('process');
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';
/* Global crypto ==================================================================== */
if (!window.crypto) {
// @ts-ignore
window.crypto = {};
}
// set getRandomValues with native module for security porpose
// @ts-ignore
window.crypto.getRandomValues = function (byteArray: any[]) {
const useBuffer = Buffer.from(CryptoModule.randomKeySync(byteArray.length), 'hex');
for (let i = 0; i < byteArray.length; i++) {
byteArray[i] = useBuffer[i];
}
return byteArray;
};