dop-wallet-v6 1.2.14 → 1.2.16
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/README.md +14 -1
- package/dist/services/dop/core/react-native-init.d.ts +18 -0
- package/dist/services/dop/core/react-native-init.js +30 -24
- package/dist/services/dop/core/react-native-init.js.map +1 -1
- package/dist/services/dop/crypto/react-native-crypto-provider.d.ts +41 -0
- package/dist/services/dop/crypto/react-native-crypto-provider.js +146 -0
- package/dist/services/dop/crypto/react-native-crypto-provider.js.map +1 -0
- package/dist/services/dop/crypto/react-native-rapidsnark-prover.d.ts +49 -0
- package/dist/services/dop/crypto/react-native-rapidsnark-prover.js +202 -0
- package/dist/services/dop/crypto/react-native-rapidsnark-prover.js.map +1 -0
- package/dist/services/dop/util/runtime.d.ts +1 -0
- package/dist/services/dop/util/runtime.js +34 -2
- package/dist/services/dop/util/runtime.js.map +1 -1
- package/dist/services/dop/wallets/wallets.js +47 -46
- package/dist/services/dop/wallets/wallets.js.map +1 -1
- package/metro.config.react-native.example.js +10 -8
- package/node-polyfills/fs-polyfill.js +54 -0
- package/node-polyfills/path-polyfill.js +36 -0
- package/node-polyfills/process-polyfill.js +61 -0
- package/node-polyfills/url-polyfill.js +32 -0
- package/node-polyfills/util-polyfill.js +76 -0
- package/package.json +16 -4
- package/react-native-shims.js +27 -10
- package/react-native.js +12 -0
- package/DOP_WALLET_V6_REACT_NATIVE_INTEGRATION_GUIDE.md +0 -2174
- package/SELECTIVE_TRANSPARENCY.md +0 -207
- package/WEB_WORKER_TROUBLESHOOTING.md +0 -180
- package/issuev3.md +0 -78
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Util module polyfill for React Native
|
|
3
|
+
*
|
|
4
|
+
* This provides Node.js util functionality for React Native.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Use the util package which should work in React Native
|
|
8
|
+
const util = require('util');
|
|
9
|
+
|
|
10
|
+
console.warn('util polyfill: Using util package for React Native.');
|
|
11
|
+
|
|
12
|
+
// Ensure promisify is available - this is critical for crypto operations
|
|
13
|
+
const promisify = util.promisify || ((fn) => {
|
|
14
|
+
return function promisified(...args) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
fn.call(this, ...args, (err, result) => {
|
|
17
|
+
if (err) reject(err);
|
|
18
|
+
else resolve(result);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Export util functionality with React Native enhancements
|
|
25
|
+
module.exports = {
|
|
26
|
+
...util,
|
|
27
|
+
|
|
28
|
+
// Ensure promisify is always available
|
|
29
|
+
promisify,
|
|
30
|
+
|
|
31
|
+
// Add React Native safe implementations
|
|
32
|
+
inspect: (obj, options = {}) => {
|
|
33
|
+
// In React Native, we might not have full util.inspect capabilities
|
|
34
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(obj, null, options.depth || 2);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return '[Object object]';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return String(obj);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// Provide format function
|
|
45
|
+
format: util.format || ((f, ...args) => {
|
|
46
|
+
let index = 0;
|
|
47
|
+
return f.replace(/%[sdj%]/g, (match) => {
|
|
48
|
+
if (index >= args.length) return match;
|
|
49
|
+
switch (match) {
|
|
50
|
+
case '%s': return String(args[index++]);
|
|
51
|
+
case '%d': return Number(args[index++]);
|
|
52
|
+
case '%j':
|
|
53
|
+
try {
|
|
54
|
+
return JSON.stringify(args[index++]);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return '[Circular]';
|
|
57
|
+
}
|
|
58
|
+
case '%%': return '%';
|
|
59
|
+
default:
|
|
60
|
+
return match;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}),
|
|
64
|
+
|
|
65
|
+
// Provide deprecate function
|
|
66
|
+
deprecate: util.deprecate || ((fn, msg) => {
|
|
67
|
+
let warned = false;
|
|
68
|
+
return function deprecated(...args) {
|
|
69
|
+
if (!warned) {
|
|
70
|
+
console.warn(msg);
|
|
71
|
+
warned = true;
|
|
72
|
+
}
|
|
73
|
+
return fn.apply(this, args);
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dop-wallet-v6",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"description": "DOP Wallet SDK, compatible with mobile, browser and nodejs environments.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/**/*",
|
|
9
9
|
"*.js",
|
|
10
|
-
"
|
|
10
|
+
"README.md",
|
|
11
11
|
"node-polyfills/**/*",
|
|
12
12
|
"metro.config.react-native.example.js",
|
|
13
13
|
"package-rn-integration.json"
|
|
14
14
|
],
|
|
15
15
|
"exports": {
|
|
16
16
|
".": "./dist/index.js",
|
|
17
|
+
"./react-native": "./react-native.js",
|
|
17
18
|
"./react-native-shims": "./react-native-shims.js"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
@@ -29,7 +30,8 @@
|
|
|
29
30
|
"eslint": "eslint src/**/* --ext .ts,.tsx --ignore-pattern **/*.graphql --fix",
|
|
30
31
|
"lint": "npm run check-circular-deps && npm run eslint && npm run tsc && npm run tsc-test",
|
|
31
32
|
"prepare": "npm run build",
|
|
32
|
-
"postinstall": "node postinstall.js"
|
|
33
|
+
"postinstall": "patch-package && node postinstall.js",
|
|
34
|
+
"verify-rn-compatibility": "node verify-react-native-compatibility.cjs"
|
|
33
35
|
},
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
@@ -44,6 +46,7 @@
|
|
|
44
46
|
"@noble/ed25519": "^1.7.1",
|
|
45
47
|
"@react-native-async-storage/async-storage": "^1.24.0",
|
|
46
48
|
"@whatwg-node/fetch": "^0.8.4",
|
|
49
|
+
"@zk-kit/eddsa-poseidon": "^1.1.0",
|
|
47
50
|
"assert": "2.0.0",
|
|
48
51
|
"axios": "1.7.2",
|
|
49
52
|
"brotli": "^1.3.3",
|
|
@@ -57,6 +60,8 @@
|
|
|
57
60
|
"events": "3.3.0",
|
|
58
61
|
"graphql": "^16.6.0",
|
|
59
62
|
"memdown": "^6.1.1",
|
|
63
|
+
"patch-package": "^8.0.1",
|
|
64
|
+
"poseidon-lite": "^0.3.0",
|
|
60
65
|
"stream-browserify": "3.0.0"
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
@@ -87,16 +92,23 @@
|
|
|
87
92
|
"typescript": "^4.9.4"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
95
|
+
"@iden3/react-native-rapidsnark": "^0.0.1-beta.1",
|
|
90
96
|
"@react-native-async-storage/async-storage": "^1.24.0"
|
|
91
97
|
},
|
|
92
98
|
"peerDependenciesMeta": {
|
|
93
99
|
"@react-native-async-storage/async-storage": {
|
|
94
100
|
"optional": false
|
|
101
|
+
},
|
|
102
|
+
"@iden3/react-native-rapidsnark": {
|
|
103
|
+
"optional": true
|
|
95
104
|
}
|
|
96
105
|
},
|
|
97
106
|
"react-native": {
|
|
98
107
|
"crypto": false,
|
|
99
|
-
"util": false
|
|
108
|
+
"util": false,
|
|
109
|
+
"fs": false,
|
|
110
|
+
"path": false,
|
|
111
|
+
"os": false
|
|
100
112
|
},
|
|
101
113
|
"resolutions": {
|
|
102
114
|
"ethers": "6.13.1"
|
package/react-native-shims.js
CHANGED
|
@@ -29,10 +29,12 @@ global.crypto.subtle.digest ??= (algorithm, data) => {
|
|
|
29
29
|
return cryptoBrowserify.createHash(algo).update(data).digest();
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
// CRITICAL FIX: Force
|
|
32
|
+
// CRITICAL FIX: Force optimal crypto libraries for React Native
|
|
33
33
|
// This prevents hanging during wallet creation due to Web Worker incompatibility
|
|
34
34
|
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
35
|
-
|
|
35
|
+
console.log('🔧 Applying React Native crypto optimizations...');
|
|
36
|
+
|
|
37
|
+
// Disable Web Workers and WebAssembly for circomlibjs fallback
|
|
36
38
|
global.Worker = undefined;
|
|
37
39
|
global.WebAssembly = undefined;
|
|
38
40
|
|
|
@@ -65,18 +67,33 @@ if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
|
65
67
|
}
|
|
66
68
|
return originalSetTimeout.apply(this, arguments);
|
|
67
69
|
};
|
|
70
|
+
|
|
71
|
+
console.log('✅ React Native crypto optimizations applied');
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
/**
|
|
75
|
+
* React Native Compatibility Information:
|
|
76
|
+
*
|
|
77
|
+
* This SDK now uses lightweight crypto alternatives for React Native:
|
|
78
|
+
* - poseidon-lite: Lightweight poseidon hash (replaces circomlibjs poseidon)
|
|
79
|
+
* - @zk-kit/eddsa-poseidon: EdDSA operations (replaces circomlibjs eddsa)
|
|
80
|
+
* - @iden3/react-native-rapidsnark: Fast proof generation (optional, recommended)
|
|
81
|
+
*
|
|
82
|
+
* Benefits:
|
|
83
|
+
* - Faster initialization and smaller bundle size
|
|
84
|
+
* - No Web Worker dependencies
|
|
85
|
+
* - Better mobile performance
|
|
86
|
+
* - Native iOS/Android compilation support via rapidsnark
|
|
87
|
+
*
|
|
88
|
+
* Installation for React Native projects:
|
|
89
|
+
* npm install @react-native-async-storage/async-storage react-native-get-random-values
|
|
90
|
+
* npm install @iden3/react-native-rapidsnark # Optional but recommended
|
|
91
|
+
*
|
|
71
92
|
* Other package.json dependencies and why we need them:
|
|
72
|
-
* - assert:
|
|
73
|
-
*
|
|
74
|
-
* -
|
|
75
|
-
* -
|
|
76
|
-
* - engine uses levelup which uses EventEmitter
|
|
77
|
-
* - stream-browserify:
|
|
78
|
-
* - engine uses AES encryption, which we shim with browserify-aes, which
|
|
79
|
-
* needs cipher-base, which needs stream
|
|
93
|
+
* - assert: engine uses circomlibjs which uses assert (now uses lightweight alternatives)
|
|
94
|
+
* - events: engine uses EventEmitter; engine uses levelup which uses EventEmitter
|
|
95
|
+
* - stream-browserify: engine uses AES encryption, which we shim with browserify-aes,
|
|
96
|
+
* which needs cipher-base, which needs stream
|
|
80
97
|
*
|
|
81
98
|
* AsyncStorage Compatibility Note:
|
|
82
99
|
* - This wallet SDK is compatible with React Native 0.60+ which moved AsyncStorage
|
package/react-native.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native specific entry point for DOP Wallet SDK
|
|
3
|
+
*
|
|
4
|
+
* This file provides React Native-specific initialization and polyfill setup.
|
|
5
|
+
* Import this before importing the main SDK to ensure proper React Native compatibility.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Apply React Native shims first
|
|
9
|
+
require('./react-native-shims');
|
|
10
|
+
|
|
11
|
+
// Re-export the main SDK
|
|
12
|
+
module.exports = require('./dist/index.js');
|