@gurge/sdk-react-native 0.3.94 → 0.3.105
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.cjs +1 -1
- package/bootstrap.mjs +1 -10
- package/common/src/crypto/preProcessing.cjs +2 -1
- package/common/src/crypto/preProcessing.mjs +2 -1
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/package.json +3 -2
- package/scripts/patch-libsodium-for-rn.js +62 -0
- package/shims/libsodium-wrappers.cjs +2 -3
package/bootstrap.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./_virtual/_rolldown/runtime.cjs`);require(`react-native-get-random-values`);let t=require(`buffer`),n=require(`react-native`);
|
|
1
|
+
const e=require(`./_virtual/_rolldown/runtime.cjs`);require(`react-native-get-random-values`);let t=require(`buffer`),n=require(`react-native`);n=e.__toESM(n),globalThis.process?.versions?.node&&delete globalThis.process.versions.node,global.Buffer=t.Buffer,globalThis.indexedDB===void 0&&(globalThis.indexedDB={}),global.require===void 0&&(global.require=e=>{if(e===`react-native`)return n;throw Error(`global.require shim: unsupported module "${e}"`)});
|
package/bootstrap.mjs
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import "react-native-get-random-values";
|
|
2
2
|
import { Buffer as e } from "buffer";
|
|
3
3
|
import * as t from "react-native";
|
|
4
|
-
|
|
5
|
-
if (globalThis.WebAssembly === void 0) {
|
|
6
|
-
class e extends Error {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
super(e), this.name = "RuntimeError";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
globalThis.WebAssembly = { RuntimeError: e };
|
|
12
|
-
}
|
|
13
|
-
global.Buffer = e, globalThis.indexedDB === void 0 && (globalThis.indexedDB = {}), global.require === void 0 && (global.require = (e) => {
|
|
4
|
+
globalThis.process?.versions?.node && delete globalThis.process.versions.node, global.Buffer = e, globalThis.indexedDB === void 0 && (globalThis.indexedDB = {}), global.require === void 0 && (global.require = (e) => {
|
|
14
5
|
if (e === "react-native") return t;
|
|
15
6
|
throw Error(`global.require shim: unsupported module "${e}"`);
|
|
16
7
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
require("../../../bootstrap.cjs");
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require(`./poseidon.cjs`),n=require(`../../../shims/libsodium-wrappers.cjs`),r=require(`./babyJub.cjs`),i=require(`./eddsa.cjs`);let a=require(`buffer`),o=require(`process`);o=e.__toESM(o);var s=e.__toESM(n.default),c=async(e=!1)=>{(typeof window<`u`||typeof self<`u`)&&(typeof window<`u`&&(window.global=window),globalThis.Buffer=a.Buffer,globalThis.process=o.default,delete globalThis.process?.versions?.node),await Promise.all([s.default.ready,t.poseidonHolder.init(),r.jubHolder.init(),...e?[]:[i.eddsaHolder.init()]])};exports.preProcessing=c;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../../bootstrap.mjs";
|
|
1
2
|
import { __toESM as e } from "../../../_virtual/_rolldown/runtime.mjs";
|
|
2
3
|
import { poseidonHolder as t } from "./poseidon.mjs";
|
|
3
4
|
import { require_libsodium_wrappers as n } from "../../../shims/libsodium-wrappers.mjs";
|
|
@@ -7,7 +8,7 @@ import { Buffer as a } from "buffer";
|
|
|
7
8
|
import o from "process";
|
|
8
9
|
//#region common/src/crypto/preProcessing.ts
|
|
9
10
|
var s = /* @__PURE__ */ e(n()), c = async (e = !1) => {
|
|
10
|
-
(typeof window < "u" || typeof self < "u") && (typeof window < "u" && (window.global = window), globalThis.Buffer = a, globalThis.process
|
|
11
|
+
(typeof window < "u" || typeof self < "u") && (typeof window < "u" && (window.global = window), globalThis.Buffer = a, globalThis.process=o,delete globalThis.process?.versions?.node), await Promise.all([
|
|
11
12
|
s.default.ready,
|
|
12
13
|
t.init(),
|
|
13
14
|
r.init(),
|
|
@@ -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.105/' + 'zkProofWorkerLauncher.js',
|
|
6
|
+
SnarkJS: domain + '/0.3.105/' + 'snarkjsWorkerLauncher.js',
|
|
7
|
+
UTXO: domain + '/0.3.105/' + '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.
|
|
3
|
+
"version": "0.3.105",
|
|
4
4
|
"description": "Prebundled Hinkal SDK for React Native — no Metro config required.",
|
|
5
5
|
"homepage": "hinkal.io",
|
|
6
6
|
"author": {
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "nx build sdk-react-native"
|
|
50
|
+
"build": "nx build sdk-react-native",
|
|
51
|
+
"postinstall": "node ./scripts/patch-libsodium-for-rn.js"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
54
|
"buffer": "6.0.3",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const PATCH_MARKER = '/* @hinkal/sdk-react-native: node:fs patched */';
|
|
9
|
+
const LIBSODIUM_FILE = path.join('libsodium', 'dist', 'modules', 'libsodium.js');
|
|
10
|
+
|
|
11
|
+
const patchFile = (filePath) => {
|
|
12
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
13
|
+
if (content.includes(PATCH_MARKER)) return false;
|
|
14
|
+
if (!/require\(["']node:fs["']\)/.test(content)) return false;
|
|
15
|
+
|
|
16
|
+
content = `${PATCH_MARKER}\n${content.replace(/require\(["']node:fs["']\)/g, '({})')}`;
|
|
17
|
+
fs.writeFileSync(filePath, content);
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const collectLibsodiumPaths = (startDir) => {
|
|
22
|
+
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);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const parent = path.dirname(dir);
|
|
39
|
+
if (parent === dir) break;
|
|
40
|
+
dir = parent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return [...found];
|
|
44
|
+
};
|
|
45
|
+
|
|
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
|
+
let patched = 0;
|
|
53
|
+
for (const filePath of targets) {
|
|
54
|
+
if (patchFile(filePath)) {
|
|
55
|
+
patched += 1;
|
|
56
|
+
console.log(`[@hinkal/sdk] patched libsodium for React Native: ${filePath}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (patched === 0 && targets.length === 0) {
|
|
61
|
+
console.warn('[@hinkal/sdk] libsodium not found — RN postinstall patch skipped (install libsodium-wrappers first)');
|
|
62
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
);
|
|
1
|
+
// Static CJS subpath bypasses package "import" (ESM) exports. postinstall patches libsodium's node:fs require.
|
|
2
|
+
module.exports = require("libsodium-wrappers/dist/modules/libsodium-wrappers.js");
|