@getpara/react-native-wallet 2.18.0 → 2.18.1

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.
@@ -13,7 +13,6 @@ import { Passkey, } from 'react-native-passkey';
13
13
  import { AuthMethodStatus } from '@getpara/user-management-client';
14
14
  import { setEnv } from '../config.js';
15
15
  import base64url from 'base64url';
16
- import { webcrypto } from 'crypto';
17
16
  const ES256_ALGORITHM = -7;
18
17
  const RS256_ALGORITHM = -257;
19
18
  /**
@@ -120,11 +119,11 @@ export class ParaMobile extends ParaCore {
120
119
  }
121
120
  const userId = this.assertUserId();
122
121
  const authInfo = this.assertIsAuthSet();
123
- if (!webcrypto || !webcrypto.getRandomValues) {
122
+ if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
124
123
  throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
125
124
  }
126
125
  const userHandle = new Uint8Array(32);
127
- webcrypto.getRandomValues(userHandle);
126
+ globalThis.crypto.getRandomValues(userHandle);
128
127
  const userHandleEncoded = base64url.encode(userHandle);
129
128
  const requestJson = {
130
129
  authenticatorSelection: {
package/dist/shim.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export function ensureParaCrypto(): {
2
- baseCrypto: webcrypto.Crypto | {
2
+ baseCrypto: import("crypto").webcrypto.Crypto | {
3
3
  getCiphers: () => string[];
4
4
  getHashes: () => string[];
5
5
  webcrypto: {
@@ -125,6 +125,5 @@ export function ensureParaCrypto(): {
125
125
  peculiarCrypto: PeculiarCrypto;
126
126
  };
127
127
  export function ensureCreateECDH(): any;
128
- import { webcrypto } from 'crypto';
129
128
  import { Buffer } from '@craftzdog/react-native-buffer';
130
129
  import { Crypto as PeculiarCrypto } from '@peculiar/webcrypto';
package/dist/shim.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import quickCrypto from 'react-native-quick-crypto';
2
- import { webcrypto } from 'crypto';
3
2
  import { Crypto as PeculiarCrypto } from '@peculiar/webcrypto';
4
3
  import { ec as EllipticEC } from 'elliptic';
5
4
  import Forge from 'node-forge';
@@ -246,8 +245,26 @@ const ensureParaCrypto = () => {
246
245
  };
247
246
  const setupCryptoPolyfills = () => {
248
247
  const { peculiarCrypto } = ensureParaCrypto();
249
- if (webcrypto && typeof webcrypto === 'object') {
250
- webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
248
+ // Ensure `import { webcrypto } from 'crypto'` works regardless of quick-crypto version.
249
+ // quick-crypto 1.x (Nitro) removed the webcrypto export that 0.7.x had.
250
+ try {
251
+ const cryptoModule = require('crypto');
252
+ if (!cryptoModule.webcrypto || typeof cryptoModule.webcrypto !== 'object') {
253
+ Object.defineProperty(cryptoModule, 'webcrypto', {
254
+ get() {
255
+ return globalThis.crypto;
256
+ },
257
+ configurable: true,
258
+ enumerable: true,
259
+ });
260
+ }
261
+ if (cryptoModule.webcrypto && typeof cryptoModule.webcrypto === 'object') {
262
+ cryptoModule.webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
263
+ }
264
+ // eslint-disable-next-line no-unused-vars
265
+ }
266
+ catch (_err) {
267
+ // crypto module not available
251
268
  }
252
269
  if (typeof Forge === 'undefined') {
253
270
  throw new Error('node-forge not loaded');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@getpara/react-native-wallet",
3
3
  "description": "Para Wallet for React Native",
4
- "version": "2.18.0",
4
+ "version": "2.18.1",
5
5
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
6
6
  "dependencies": {
7
7
  "@getpara/core-sdk": "2.18.0",
@@ -10,6 +10,7 @@
10
10
  "@getpara/web-sdk": "2.18.0",
11
11
  "@peculiar/webcrypto": "^1.5.0",
12
12
  "@ungap/structured-clone": "1.3.0",
13
+ "readable-stream": "^4.5.2",
13
14
  "react-native-url-polyfill": "2.0.0",
14
15
  "text-encoding": "0.7.0"
15
16
  },
@@ -24,7 +25,8 @@
24
25
  "react-native-modpow": "^1.1.0",
25
26
  "react-native-passkey": "^3.1.0",
26
27
  "react-native-quick-base64": "^2.2.0",
27
- "react-native-quick-crypto": "^0.7.14",
28
+ "react-native-nitro-modules": "^0.29.1",
29
+ "react-native-quick-crypto": "^1.0.0",
28
30
  "typescript": "^5.8.3"
29
31
  },
30
32
  "exports": {
@@ -58,10 +60,10 @@
58
60
  "react-native": ">=0.70.0",
59
61
  "react-native-keychain": ">=8.0.0",
60
62
  "react-native-modpow": ">=1.0.0",
63
+ "react-native-nitro-modules": ">=0.29.1",
61
64
  "react-native-passkey": ">=3.0.0",
62
65
  "react-native-quick-base64": ">=2.0.0",
63
- "react-native-quick-crypto": ">=0.7.0",
64
- "readable-stream": ">=4.0.0"
66
+ "react-native-quick-crypto": ">=1.0.0"
65
67
  },
66
68
  "publishConfig": {
67
69
  "access": "public"
@@ -92,6 +94,5 @@
92
94
  "./dist/index.d.ts"
93
95
  ]
94
96
  }
95
- },
96
- "gitHead": "4481f6f4e108e682d14c74d4433696141c47fc58"
97
+ }
97
98
  }
@@ -26,7 +26,6 @@ import {
26
26
  import { CurrentWalletIds, AuthMethodStatus, TWalletScheme } from '@getpara/user-management-client';
27
27
  import { setEnv } from '../config.js';
28
28
  import base64url from 'base64url';
29
- import { webcrypto } from 'crypto';
30
29
 
31
30
  const ES256_ALGORITHM = -7;
32
31
  const RS256_ALGORITHM = -257;
@@ -159,11 +158,11 @@ export class ParaMobile extends ParaCore {
159
158
  const userId = this.assertUserId();
160
159
  const authInfo = this.assertIsAuthSet();
161
160
 
162
- if (!webcrypto || !webcrypto.getRandomValues) {
161
+ if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
163
162
  throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
164
163
  }
165
164
  const userHandle = new Uint8Array(32);
166
- webcrypto.getRandomValues(userHandle);
165
+ globalThis.crypto.getRandomValues(userHandle);
167
166
  const userHandleEncoded = base64url.encode(userHandle as any);
168
167
 
169
168
  const requestJson: PasskeyCreateRequest = {
package/src/shim.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import quickCrypto from 'react-native-quick-crypto';
2
- import { webcrypto } from 'crypto';
3
2
  import { Crypto as PeculiarCrypto } from '@peculiar/webcrypto';
4
3
  import { ec as EllipticEC } from 'elliptic';
5
4
  import Forge from 'node-forge';
@@ -281,8 +280,25 @@ const ensureParaCrypto = () => {
281
280
  const setupCryptoPolyfills = () => {
282
281
  const { peculiarCrypto } = ensureParaCrypto();
283
282
 
284
- if (webcrypto && typeof webcrypto === 'object') {
285
- webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
283
+ // Ensure `import { webcrypto } from 'crypto'` works regardless of quick-crypto version.
284
+ // quick-crypto 1.x (Nitro) removed the webcrypto export that 0.7.x had.
285
+ try {
286
+ const cryptoModule = require('crypto');
287
+ if (!cryptoModule.webcrypto || typeof cryptoModule.webcrypto !== 'object') {
288
+ Object.defineProperty(cryptoModule, 'webcrypto', {
289
+ get() {
290
+ return globalThis.crypto;
291
+ },
292
+ configurable: true,
293
+ enumerable: true,
294
+ });
295
+ }
296
+ if (cryptoModule.webcrypto && typeof cryptoModule.webcrypto === 'object') {
297
+ cryptoModule.webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
298
+ }
299
+ // eslint-disable-next-line no-unused-vars
300
+ } catch (_err) {
301
+ // crypto module not available
286
302
  }
287
303
 
288
304
  if (typeof Forge === 'undefined') {