@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.114/' + 'zkProofWorkerLauncher.js',
6
- SnarkJS: domain + '/0.3.114/' + 'snarkjsWorkerLauncher.js',
7
- UTXO: domain + '/0.3.114/' + 'utxoWorkerLauncher.js',
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@gurge/sdk-react-native",
3
- "version": "0.3.115",
3
+ "version": "0.3.120",
4
4
  "description": "Prebundled Hinkal SDK for React Native — no Metro config required.",
5
5
  "homepage": "hinkal.io",
6
6
  "author": {
@@ -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 — no Metro config needed.
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 LIBSODIUM_FILE = path.join('libsodium', 'dist', 'modules', 'libsodium.js');
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
- content = `${PATCH_MARKER}\n${content.replace(/require\(["']node:fs["']\)/g, '({})')}`;
17
- fs.writeFileSync(filePath, content);
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 collectLibsodiumPaths = (startDir) => {
24
+ const findLibsodiumFiles = () => {
25
+ const searchPaths = [process.cwd(), __dirname, path.join(__dirname, '..')];
22
26
  const found = new Set();
23
- let dir = startDir;
24
-
25
- for (let depth = 0; depth < 8 && dir; depth += 1) {
26
- const nodeModules = path.join(dir, 'node_modules');
27
- if (fs.existsSync(nodeModules)) {
28
- const direct = path.join(nodeModules, LIBSODIUM_FILE);
29
- if (fs.existsSync(direct)) found.add(direct);
30
-
31
- for (const entry of fs.readdirSync(nodeModules, { withFileTypes: true })) {
32
- if (!entry.isDirectory() || entry.name.startsWith('.')) continue;
33
- const nested = path.join(nodeModules, entry.name, 'node_modules', LIBSODIUM_FILE);
34
- if (fs.existsSync(nested)) found.add(nested);
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 targets) {
49
+ for (const filePath of findLibsodiumFiles()) {
54
50
  if (patchFile(filePath)) {
55
51
  patched += 1;
56
- console.log(`[@hinkal/sdk] patched libsodium for React Native: ${filePath}`);
52
+ console.log(`[@gurge/sdk-react-native] patched libsodium: ${filePath}`);
57
53
  }
58
54
  }
59
55
 
60
- if (patched === 0 && targets.length === 0) {
61
- console.warn('[@hinkal/sdk] libsodium not found — RN postinstall patch skipped (install libsodium-wrappers first)');
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
  }