@getpara/react-native-wallet 2.0.0-alpha.61 → 2.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shim.d.ts +1 -130
- package/dist/shim.js +10 -187
- package/package.json +5 -5
package/dist/shim.d.ts
CHANGED
|
@@ -1,130 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
baseCrypto: webcrypto.Crypto | {
|
|
3
|
-
getCiphers: () => string[];
|
|
4
|
-
getHashes: () => string[];
|
|
5
|
-
webcrypto: {
|
|
6
|
-
subtle: import("react-native-quick-crypto/lib/typescript/src/subtle").Subtle;
|
|
7
|
-
SubtleCrypto: typeof import("react-native-quick-crypto/lib/typescript/src/subtle").Subtle;
|
|
8
|
-
CryptoKey: typeof import("react-native-quick-crypto/lib/typescript/src/keys").CryptoKey;
|
|
9
|
-
};
|
|
10
|
-
randomFill<T extends import("react-native-quick-crypto/lib/typescript/src/Utils").ABV>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
|
|
11
|
-
randomFill<T extends import("react-native-quick-crypto/lib/typescript/src/Utils").ABV>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
|
|
12
|
-
randomFill<T extends import("react-native-quick-crypto/lib/typescript/src/Utils").ABV>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
|
|
13
|
-
randomFillSync<T extends import("react-native-quick-crypto/lib/typescript/src/Utils").ABV>(buffer: T, offset?: number, size?: number): T;
|
|
14
|
-
randomBytes(size: number): Buffer;
|
|
15
|
-
randomBytes(size: number, callback: (err: Error | null, buf?: Buffer) => void): void;
|
|
16
|
-
randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
|
|
17
|
-
randomInt(max: number): number;
|
|
18
|
-
randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
|
|
19
|
-
randomInt(min: number, max: number): number;
|
|
20
|
-
getRandomValues(data: import("react-native-quick-crypto/lib/typescript/src/random").RandomTypedArrays): import("react-native-quick-crypto/lib/typescript/src/random").RandomTypedArrays;
|
|
21
|
-
randomUUID(): string;
|
|
22
|
-
rng: typeof import("react-native-quick-crypto/lib/typescript/src/random").randomBytes;
|
|
23
|
-
pseudoRandomBytes: typeof import("react-native-quick-crypto/lib/typescript/src/random").randomBytes;
|
|
24
|
-
prng: typeof import("react-native-quick-crypto/lib/typescript/src/random").randomBytes;
|
|
25
|
-
pbkdf2(password: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, salt: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey?: Buffer) => void): void;
|
|
26
|
-
pbkdf2Sync(password: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, salt: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, iterations: number, keylen: number, digest?: string): ArrayBuffer;
|
|
27
|
-
pbkdf2DeriveBits(algorithm: import("react-native-quick-crypto/lib/typescript/src/keys").SubtleAlgorithm, baseKey: import("react-native-quick-crypto/lib/typescript/src/keys").CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
28
|
-
createHmac: typeof import("react-native-quick-crypto/lib/typescript/src/Hmac").createHmac;
|
|
29
|
-
Hmac: typeof import("react-native-quick-crypto/lib/typescript/src/Hmac").createHmac;
|
|
30
|
-
Hash: typeof import("react-native-quick-crypto/lib/typescript/src/Hash").createHash;
|
|
31
|
-
createHash: typeof import("react-native-quick-crypto/lib/typescript/src/Hash").createHash;
|
|
32
|
-
createCipher: typeof import("react-native-quick-crypto/lib/typescript/src/Cipher").createCipher;
|
|
33
|
-
createCipheriv: typeof import("react-native-quick-crypto/lib/typescript/src/Cipher").createCipheriv;
|
|
34
|
-
createDecipher: typeof import("react-native-quick-crypto/lib/typescript/src/Cipher").createDecipher;
|
|
35
|
-
createDecipheriv: typeof import("react-native-quick-crypto/lib/typescript/src/Cipher").createDecipheriv;
|
|
36
|
-
createPublicKey: typeof import("react-native-quick-crypto/lib/typescript/src/keys").createPublicKey;
|
|
37
|
-
createPrivateKey: (key: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike | import("react-native-quick-crypto/lib/typescript/src/keys").EncodingOptions) => import("react-native-quick-crypto/lib/typescript/src/keys").PrivateKeyObject;
|
|
38
|
-
createSecretKey: typeof import("react-native-quick-crypto/lib/typescript/src/keys").createSecretKey;
|
|
39
|
-
publicEncrypt: (options: import("react-native-quick-crypto/lib/typescript/src/keys").EncodingOptions | import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, buffer: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike) => Buffer;
|
|
40
|
-
publicDecrypt: (options: import("react-native-quick-crypto/lib/typescript/src/keys").EncodingOptions | import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, buffer: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike) => Buffer;
|
|
41
|
-
privateDecrypt: (options: import("react-native-quick-crypto/lib/typescript/src/keys").EncodingOptions | import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike, buffer: import("react-native-quick-crypto/lib/typescript/src/Utils").BinaryLike) => Buffer;
|
|
42
|
-
generateKey: (type: import("react-native-quick-crypto/lib/typescript/src/keys").SecretKeyType, options: import("react-native-quick-crypto/lib/typescript/src/keys").AesKeyGenParams, callback: import("react-native-quick-crypto/lib/typescript/src/keygen").KeyGenCallback) => void;
|
|
43
|
-
generateKeyPair: (type: import("react-native-quick-crypto/lib/typescript/src/keys").KeyPairType, options: import("react-native-quick-crypto/lib/typescript/src/Cipher").GenerateKeyPairOptions, callback: import("react-native-quick-crypto/lib/typescript/src/Cipher").GenerateKeyPairCallback) => void;
|
|
44
|
-
generateKeyPairSync: typeof import("react-native-quick-crypto/lib/typescript/src/Cipher").generateKeyPairSync;
|
|
45
|
-
generateKeySync: (type: import("react-native-quick-crypto/lib/typescript/src/keys").SecretKeyType, options: import("react-native-quick-crypto/lib/typescript/src/keys").AesKeyGenParams) => import("react-native-quick-crypto/lib/typescript/src/keys").SecretKeyObject;
|
|
46
|
-
createSign: typeof import("react-native-quick-crypto/lib/typescript/src/sig").createSign;
|
|
47
|
-
createVerify: typeof import("react-native-quick-crypto/lib/typescript/src/sig").createVerify;
|
|
48
|
-
subtle: import("react-native-quick-crypto/lib/typescript/src/subtle").Subtle;
|
|
49
|
-
constants: {
|
|
50
|
-
OPENSSL_VERSION_NUMBER: number;
|
|
51
|
-
SSL_OP_ALL: number;
|
|
52
|
-
SSL_OP_ALLOW_NO_DHE_KEX: number;
|
|
53
|
-
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
|
54
|
-
SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
|
55
|
-
SSL_OP_CISCO_ANYCONNECT: number;
|
|
56
|
-
SSL_OP_COOKIE_EXCHANGE: number;
|
|
57
|
-
SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
|
58
|
-
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
|
59
|
-
SSL_OP_EPHEMERAL_RSA: number;
|
|
60
|
-
SSL_OP_LEGACY_SERVER_CONNECT: number;
|
|
61
|
-
SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
|
|
62
|
-
SSL_OP_MICROSOFT_SESS_ID_BUG: number;
|
|
63
|
-
SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
|
|
64
|
-
SSL_OP_NETSCAPE_CA_DN_BUG: number;
|
|
65
|
-
SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
|
|
66
|
-
SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
|
|
67
|
-
SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
|
|
68
|
-
SSL_OP_NO_COMPRESSION: number;
|
|
69
|
-
SSL_OP_NO_ENCRYPT_THEN_MAC: number;
|
|
70
|
-
SSL_OP_NO_QUERY_MTU: number;
|
|
71
|
-
SSL_OP_NO_RENEGOTIATION: number;
|
|
72
|
-
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
|
73
|
-
SSL_OP_NO_SSLv2: number;
|
|
74
|
-
SSL_OP_NO_SSLv3: number;
|
|
75
|
-
SSL_OP_NO_TICKET: number;
|
|
76
|
-
SSL_OP_NO_TLSv1: number;
|
|
77
|
-
SSL_OP_NO_TLSv1_1: number;
|
|
78
|
-
SSL_OP_NO_TLSv1_2: number;
|
|
79
|
-
SSL_OP_NO_TLSv1_3: number;
|
|
80
|
-
SSL_OP_PKCS1_CHECK_1: number;
|
|
81
|
-
SSL_OP_PKCS1_CHECK_2: number;
|
|
82
|
-
SSL_OP_PRIORITIZE_CHACHA: number;
|
|
83
|
-
SSL_OP_SINGLE_DH_USE: number;
|
|
84
|
-
SSL_OP_SINGLE_ECDH_USE: number;
|
|
85
|
-
SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
|
|
86
|
-
SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
|
|
87
|
-
SSL_OP_TLS_BLOCK_PADDING_BUG: number;
|
|
88
|
-
SSL_OP_TLS_D5_BUG: number;
|
|
89
|
-
SSL_OP_TLS_ROLLBACK_BUG: number;
|
|
90
|
-
ENGINE_METHOD_RSA: number;
|
|
91
|
-
ENGINE_METHOD_DSA: number;
|
|
92
|
-
ENGINE_METHOD_DH: number;
|
|
93
|
-
ENGINE_METHOD_RAND: number;
|
|
94
|
-
ENGINE_METHOD_EC: number;
|
|
95
|
-
ENGINE_METHOD_CIPHERS: number;
|
|
96
|
-
ENGINE_METHOD_DIGESTS: number;
|
|
97
|
-
ENGINE_METHOD_PKEY_METHS: number;
|
|
98
|
-
ENGINE_METHOD_PKEY_ASN1_METHS: number;
|
|
99
|
-
ENGINE_METHOD_ALL: number;
|
|
100
|
-
ENGINE_METHOD_NONE: number;
|
|
101
|
-
DH_CHECK_P_NOT_SAFE_PRIME: number;
|
|
102
|
-
DH_CHECK_P_NOT_PRIME: number;
|
|
103
|
-
DH_UNABLE_TO_CHECK_GENERATOR: number;
|
|
104
|
-
DH_NOT_SUITABLE_GENERATOR: number;
|
|
105
|
-
ALPN_ENABLED: number;
|
|
106
|
-
RSA_PKCS1_PADDING: number;
|
|
107
|
-
RSA_SSLV23_PADDING: number;
|
|
108
|
-
RSA_NO_PADDING: number;
|
|
109
|
-
RSA_PKCS1_OAEP_PADDING: number;
|
|
110
|
-
RSA_X931_PADDING: number;
|
|
111
|
-
RSA_PKCS1_PSS_PADDING: number;
|
|
112
|
-
RSA_PSS_SALTLEN_DIGEST: number;
|
|
113
|
-
RSA_PSS_SALTLEN_MAX_SIGN: number;
|
|
114
|
-
RSA_PSS_SALTLEN_AUTO: number;
|
|
115
|
-
defaultCoreCipherList: string;
|
|
116
|
-
TLS1_VERSION: number;
|
|
117
|
-
TLS1_1_VERSION: number;
|
|
118
|
-
TLS1_2_VERSION: number;
|
|
119
|
-
TLS1_3_VERSION: number;
|
|
120
|
-
POINT_CONVERSION_COMPRESSED: number;
|
|
121
|
-
POINT_CONVERSION_UNCOMPRESSED: number;
|
|
122
|
-
POINT_CONVERSION_HYBRID: number;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
peculiarCrypto: PeculiarCrypto;
|
|
126
|
-
};
|
|
127
|
-
export function ensureCreateECDH(): any;
|
|
128
|
-
import { webcrypto } from 'crypto';
|
|
129
|
-
import { Buffer } from '@craftzdog/react-native-buffer';
|
|
130
|
-
import { Crypto as PeculiarCrypto } from '@peculiar/webcrypto';
|
|
1
|
+
export {};
|
package/dist/shim.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import crypto from 'react-native-quick-crypto';
|
|
2
2
|
import { webcrypto } from 'crypto';
|
|
3
|
-
import { Crypto
|
|
4
|
-
import { ec as EllipticEC } from 'elliptic';
|
|
3
|
+
import { Crypto } from '@peculiar/webcrypto';
|
|
5
4
|
import Forge from 'node-forge';
|
|
6
5
|
import modPow from 'react-native-modpow';
|
|
7
6
|
import { atob, btoa } from 'react-native-quick-base64';
|
|
@@ -34,191 +33,16 @@ const setupBase64Polyfills = () => {
|
|
|
34
33
|
throw new Error('Base64 polyfills failed to initialize');
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
|
-
const curveAliases = {
|
|
38
|
-
'P-256': 'p256',
|
|
39
|
-
'p-256': 'p256',
|
|
40
|
-
'prime256v1': 'p256',
|
|
41
|
-
'secp256r1': 'p256',
|
|
42
|
-
'secp256k1': 'secp256k1',
|
|
43
|
-
};
|
|
44
|
-
const getBufferImpl = () => {
|
|
45
|
-
const BufferImpl = globalThis.Buffer;
|
|
46
|
-
if (!BufferImpl) {
|
|
47
|
-
// prettier-ignore
|
|
48
|
-
throw new Error("[Para React Native shim] Buffer global missing. Please import '@getpara/react-native-wallet/shim' before using cryptography helpers.");
|
|
49
|
-
}
|
|
50
|
-
return BufferImpl;
|
|
51
|
-
};
|
|
52
|
-
const bufferFrom = (data, encoding = 'binary') => {
|
|
53
|
-
const BufferImpl = getBufferImpl();
|
|
54
|
-
if (BufferImpl.isBuffer && BufferImpl.isBuffer(data)) {
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
if (typeof data === 'string') {
|
|
58
|
-
switch (encoding) {
|
|
59
|
-
case 'hex':
|
|
60
|
-
return BufferImpl.from(data, 'hex');
|
|
61
|
-
case 'base64':
|
|
62
|
-
return BufferImpl.from(data, 'base64');
|
|
63
|
-
default:
|
|
64
|
-
return BufferImpl.from(data, 'binary');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return BufferImpl.from(data);
|
|
68
|
-
};
|
|
69
|
-
const bufferTo = (buf, encoding = 'binary') => {
|
|
70
|
-
const BufferImpl = getBufferImpl();
|
|
71
|
-
switch (encoding) {
|
|
72
|
-
case 'hex':
|
|
73
|
-
return BufferImpl.from(buf).toString('hex');
|
|
74
|
-
case 'base64':
|
|
75
|
-
return BufferImpl.from(buf).toString('base64');
|
|
76
|
-
case 'binary':
|
|
77
|
-
default:
|
|
78
|
-
return BufferImpl.from(buf);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
let cachedCreateECDH = null;
|
|
82
|
-
const ensureCreateECDH = () => {
|
|
83
|
-
if (!cachedCreateECDH) {
|
|
84
|
-
cachedCreateECDH = curveName => {
|
|
85
|
-
const BufferImpl = getBufferImpl();
|
|
86
|
-
const normalizedCurve = curveAliases[curveName] || curveName;
|
|
87
|
-
if (!normalizedCurve && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
88
|
-
console.warn('[Para React Native shim] Unknown curve alias', curveName);
|
|
89
|
-
}
|
|
90
|
-
const ec = new EllipticEC(normalizedCurve);
|
|
91
|
-
const secretByteLength = (() => {
|
|
92
|
-
const order = (ec && ec.curve && ec.curve.n) || (ec && ec.n);
|
|
93
|
-
if (!order) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
if (typeof order.byteLength === 'function') {
|
|
97
|
-
return order.byteLength();
|
|
98
|
-
}
|
|
99
|
-
if (typeof order.bitLength === 'function') {
|
|
100
|
-
return Math.ceil(order.bitLength() / 8);
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
})();
|
|
104
|
-
let keyPair = ec.genKeyPair();
|
|
105
|
-
return {
|
|
106
|
-
generateKeys: (encoding = 'binary', format = 'uncompressed') => {
|
|
107
|
-
keyPair = ec.genKeyPair();
|
|
108
|
-
const compressed = format === 'compressed' || format === 'comp';
|
|
109
|
-
const publicKey = keyPair.getPublic(compressed, 'array');
|
|
110
|
-
return bufferTo(BufferImpl.from(publicKey), encoding || 'binary');
|
|
111
|
-
},
|
|
112
|
-
computeSecret: (publicKey, inputEncoding = 'binary', outputEncoding = 'binary') => {
|
|
113
|
-
const publicKeyBuf = bufferFrom(publicKey, inputEncoding || 'binary');
|
|
114
|
-
const derived = keyPair.derive(ec.keyFromPublic(publicKeyBuf).getPublic());
|
|
115
|
-
const padded = secretByteLength ? derived.toArray('be', secretByteLength) : derived.toArray('be');
|
|
116
|
-
// Match Node's ECDH API: shared secret is always curve-size bytes.
|
|
117
|
-
const secret = BufferImpl.from(padded);
|
|
118
|
-
return bufferTo(secret, outputEncoding || 'binary');
|
|
119
|
-
},
|
|
120
|
-
getPrivateKey: (encoding = 'binary') => {
|
|
121
|
-
return bufferTo(keyPair.getPrivate().toArrayLike(BufferImpl, 'be', 32), encoding || 'binary');
|
|
122
|
-
},
|
|
123
|
-
getPublicKey: (encoding = 'binary', format = 'uncompressed') => {
|
|
124
|
-
const compressed = format === 'compressed' || format === 'comp';
|
|
125
|
-
const publicKey = keyPair.getPublic(compressed, 'array');
|
|
126
|
-
return bufferTo(BufferImpl.from(publicKey), encoding || 'binary');
|
|
127
|
-
},
|
|
128
|
-
setPrivateKey: (privateKey, encoding = 'binary') => {
|
|
129
|
-
keyPair = ec.keyFromPrivate(bufferFrom(privateKey, encoding));
|
|
130
|
-
},
|
|
131
|
-
setPublicKey: (publicKey, encoding = 'binary') => {
|
|
132
|
-
keyPair = ec.keyFromPublic(bufferFrom(publicKey, encoding));
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const possibleTargets = [];
|
|
138
|
-
const globalCrypto = globalThis.crypto;
|
|
139
|
-
if (globalCrypto) {
|
|
140
|
-
possibleTargets.push(globalCrypto, globalCrypto.default);
|
|
141
|
-
}
|
|
142
|
-
possibleTargets.push(quickCrypto, quickCrypto && quickCrypto.default);
|
|
143
|
-
try {
|
|
144
|
-
const nodeCrypto = require('crypto');
|
|
145
|
-
possibleTargets.push(nodeCrypto, nodeCrypto && nodeCrypto.default);
|
|
146
|
-
// eslint-disable-next-line no-unused-vars
|
|
147
|
-
}
|
|
148
|
-
catch (_err) {
|
|
149
|
-
// The Node crypto module is not available in React Native; ignore failures.
|
|
150
|
-
}
|
|
151
|
-
const patchedTargets = new Set(possibleTargets.filter(Boolean));
|
|
152
|
-
let patched = false;
|
|
153
|
-
patchedTargets.forEach(target => {
|
|
154
|
-
if (target && typeof target === 'object' && target.createECDH !== cachedCreateECDH) {
|
|
155
|
-
try {
|
|
156
|
-
target.createECDH = cachedCreateECDH;
|
|
157
|
-
patched = true;
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
161
|
-
console.warn('[Para React Native shim] Failed to patch createECDH', err);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
if (patched && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
167
|
-
console.info('[Para React Native shim] createECDH patched function');
|
|
168
|
-
}
|
|
169
|
-
return cachedCreateECDH;
|
|
170
|
-
};
|
|
171
|
-
const syncWindowLikeGlobals = cryptoObj => {
|
|
172
|
-
const maybeWindow = globalThis.window;
|
|
173
|
-
if (maybeWindow && typeof maybeWindow === 'object' && maybeWindow.crypto !== cryptoObj) {
|
|
174
|
-
maybeWindow.crypto = cryptoObj;
|
|
175
|
-
}
|
|
176
|
-
const maybeSelf = globalThis.self;
|
|
177
|
-
if (maybeSelf && typeof maybeSelf === 'object' && maybeSelf.crypto !== cryptoObj) {
|
|
178
|
-
maybeSelf.crypto = cryptoObj;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const ensureParaCrypto = () => {
|
|
182
|
-
getBufferImpl();
|
|
183
|
-
const baseCrypto = (typeof globalThis.crypto === 'object' && globalThis.crypto) || quickCrypto;
|
|
184
|
-
if (!baseCrypto || typeof baseCrypto !== 'object') {
|
|
185
|
-
throw new Error('[Para React Native shim] No crypto object found to polyfill');
|
|
186
|
-
}
|
|
187
|
-
if (typeof baseCrypto.default === 'undefined') {
|
|
188
|
-
baseCrypto.default = baseCrypto;
|
|
189
|
-
}
|
|
190
|
-
const peculiarCrypto = new PeculiarCrypto();
|
|
191
|
-
baseCrypto.subtle = peculiarCrypto.subtle;
|
|
192
|
-
baseCrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
|
|
193
|
-
if (baseCrypto.default && baseCrypto.default !== baseCrypto) {
|
|
194
|
-
baseCrypto.default.subtle = baseCrypto.subtle;
|
|
195
|
-
baseCrypto.default.getRandomValues = baseCrypto.getRandomValues;
|
|
196
|
-
}
|
|
197
|
-
globalThis.crypto = baseCrypto;
|
|
198
|
-
syncWindowLikeGlobals(baseCrypto);
|
|
199
|
-
try {
|
|
200
|
-
const brorand = require('brorand');
|
|
201
|
-
if (brorand && brorand.Rand) {
|
|
202
|
-
brorand.Rand.prototype._rand = function _rand(n) {
|
|
203
|
-
const arr = new Uint8Array(n);
|
|
204
|
-
baseCrypto.getRandomValues(arr);
|
|
205
|
-
return arr;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
catch (err) {
|
|
210
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
211
|
-
console.warn('[Para React Native shim] Failed to patch brorand RNG', err);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
ensureCreateECDH();
|
|
215
|
-
return { baseCrypto, peculiarCrypto };
|
|
216
|
-
};
|
|
217
36
|
const setupCryptoPolyfills = () => {
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
|
|
37
|
+
const peculiarCrypto = new Crypto();
|
|
38
|
+
if (typeof globalThis.crypto === 'undefined') {
|
|
39
|
+
globalThis.crypto = crypto;
|
|
40
|
+
}
|
|
41
|
+
if (!globalThis.crypto.subtle) {
|
|
42
|
+
globalThis.crypto.subtle = peculiarCrypto.subtle;
|
|
43
|
+
globalThis.crypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
|
|
221
44
|
}
|
|
45
|
+
webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
|
|
222
46
|
if (typeof Forge === 'undefined') {
|
|
223
47
|
throw new Error('node-forge not loaded');
|
|
224
48
|
}
|
|
@@ -249,4 +73,3 @@ setupBase64Polyfills();
|
|
|
249
73
|
setupCryptoPolyfills();
|
|
250
74
|
setupTextEncodingPolyfills();
|
|
251
75
|
setupStructuredClonePolyfill();
|
|
252
|
-
export { ensureParaCrypto, ensureCreateECDH };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-native-wallet",
|
|
3
3
|
"description": "Para Wallet for React Native",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.63",
|
|
5
5
|
"author": "Para Team <hello@getpara.com> (https://getpara.com)",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@getpara/core-sdk": "2.0.0-alpha.
|
|
8
|
-
"@getpara/user-management-client": "2.0.0-alpha.
|
|
9
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
7
|
+
"@getpara/core-sdk": "2.0.0-alpha.63",
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.63",
|
|
9
|
+
"@getpara/web-sdk": "2.0.0-alpha.63",
|
|
10
10
|
"@peculiar/webcrypto": "^1.5.0",
|
|
11
11
|
"@ungap/structured-clone": "1.3.0",
|
|
12
12
|
"node-forge": "1.3.1",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
]
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "440300efa66a6bc808504e2771b21e92bdee4c9b"
|
|
97
97
|
}
|