@gurge/sdk-react-native 0.3.115 → 0.3.120
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/bootstrap.d.ts
ADDED
|
File without changes
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
const domain = 'https://storage.googleapis.com/hinkal-workers-staging';
|
|
3
3
|
|
|
4
4
|
const WORKER_CDN_URLS = {
|
|
5
|
-
ZKProof: domain + '/0.3.
|
|
6
|
-
SnarkJS: domain + '/0.3.
|
|
7
|
-
UTXO: domain + '/0.3.
|
|
5
|
+
ZKProof: domain + '/0.3.119/' + 'zkProofWorkerLauncher.js',
|
|
6
|
+
SnarkJS: domain + '/0.3.119/' + 'snarkjsWorkerLauncher.js',
|
|
7
|
+
UTXO: domain + '/0.3.119/' + 'utxoWorkerLauncher.js',
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// Returns a blob:// URL which points
|
package/package.json
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Patches libsodium's Emscripten glue so Metro can bundle it on React Native.
|
|
3
|
-
* Replaces the static require("node:fs") (dead on Hermes) with a no-op
|
|
3
|
+
* Replaces the static require("node:fs") (dead on Hermes) with a no-op.
|
|
4
4
|
*/
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const { createRequire } = require('module');
|
|
7
8
|
|
|
8
9
|
const PATCH_MARKER = '/* @hinkal/sdk-react-native: node:fs patched */';
|
|
9
|
-
const
|
|
10
|
+
const LIBSODIUM_REL = path.join('libsodium', 'dist', 'modules', 'libsodium.js');
|
|
10
11
|
|
|
11
12
|
const patchFile = (filePath) => {
|
|
12
13
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
13
14
|
if (content.includes(PATCH_MARKER)) return false;
|
|
14
15
|
if (!/require\(["']node:fs["']\)/.test(content)) return false;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
fs.writeFileSync(
|
|
18
|
+
filePath,
|
|
19
|
+
`${PATCH_MARKER}\n${content.replace(/require\(["']node:fs["']\)/g, '({})')}`,
|
|
20
|
+
);
|
|
18
21
|
return true;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
const
|
|
24
|
+
const findLibsodiumFiles = () => {
|
|
25
|
+
const searchPaths = [process.cwd(), __dirname, path.join(__dirname, '..')];
|
|
22
26
|
const found = new Set();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (fs.existsSync(
|
|
27
|
+
|
|
28
|
+
for (const searchPath of searchPaths) {
|
|
29
|
+
try {
|
|
30
|
+
const req = createRequire(path.join(searchPath, 'package.json'));
|
|
31
|
+
const wrappersPkg = req.resolve('libsodium-wrappers/package.json');
|
|
32
|
+
const wrappersDir = path.dirname(wrappersPkg);
|
|
33
|
+
const candidates = [
|
|
34
|
+
path.join(wrappersDir, 'node_modules', LIBSODIUM_REL),
|
|
35
|
+
path.join(path.dirname(wrappersDir), 'libsodium', 'dist', 'modules', 'libsodium.js'),
|
|
36
|
+
];
|
|
37
|
+
for (const candidate of candidates) {
|
|
38
|
+
if (fs.existsSync(candidate)) found.add(candidate);
|
|
35
39
|
}
|
|
40
|
+
} catch {
|
|
41
|
+
// libsodium-wrappers not installed from this search root
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
const parent = path.dirname(dir);
|
|
39
|
-
if (parent === dir) break;
|
|
40
|
-
dir = parent;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
return [...found];
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
const roots = new Set([__dirname, path.join(__dirname, '..'), process.cwd()]);
|
|
47
|
-
const targets = new Set();
|
|
48
|
-
for (const root of roots) {
|
|
49
|
-
for (const filePath of collectLibsodiumPaths(root)) targets.add(filePath);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
48
|
let patched = 0;
|
|
53
|
-
for (const filePath of
|
|
49
|
+
for (const filePath of findLibsodiumFiles()) {
|
|
54
50
|
if (patchFile(filePath)) {
|
|
55
51
|
patched += 1;
|
|
56
|
-
console.log(`[@
|
|
52
|
+
console.log(`[@gurge/sdk-react-native] patched libsodium: ${filePath}`);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
if (patched === 0
|
|
61
|
-
console.warn(
|
|
56
|
+
if (patched === 0) {
|
|
57
|
+
console.warn(
|
|
58
|
+
'[@gurge/sdk-react-native] libsodium not found — postinstall patch skipped (install libsodium-wrappers first)',
|
|
59
|
+
);
|
|
62
60
|
}
|