@gurge/sdk-react-native 0.3.69 → 0.3.74

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.
Files changed (83) hide show
  1. package/_virtual/_rolldown/runtime.mjs +11 -2
  2. package/common/src/constants/vite.constants.cjs +1 -1
  3. package/common/src/constants/vite.constants.mjs +1 -1
  4. package/common/src/crypto/babyJub.cjs +1 -1
  5. package/common/src/crypto/babyJub.mjs +7 -6
  6. package/common/src/crypto/eddsa.cjs +1 -1
  7. package/common/src/crypto/eddsa.mjs +7 -6
  8. package/common/src/crypto/poseidon.cjs +1 -1
  9. package/common/src/crypto/poseidon.mjs +13 -13
  10. package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
  11. package/common/src/data-structures/IndexedDB/activity-db.mjs +38 -38
  12. package/common/src/data-structures/IndexedDB/balances-db.cjs +1 -1
  13. package/common/src/data-structures/IndexedDB/balances-db.mjs +18 -16
  14. package/common/src/data-structures/IndexedDB/contact-db.cjs +1 -1
  15. package/common/src/data-structures/IndexedDB/contact-db.mjs +16 -14
  16. package/common/src/data-structures/IndexedDB/key-val-store.cjs +1 -1
  17. package/common/src/data-structures/IndexedDB/key-val-store.mjs +12 -12
  18. package/common/src/data-structures/IndexedDB/pay-activity-db.cjs +1 -1
  19. package/common/src/data-structures/IndexedDB/pay-activity-db.mjs +10 -8
  20. package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
  21. package/common/src/data-structures/IndexedDB/signatures-db.mjs +23 -21
  22. package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
  23. package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +32 -31
  24. package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
  25. package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +25 -25
  26. package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
  27. package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +47 -46
  28. package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
  29. package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +20 -20
  30. package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -1
  31. package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +19 -19
  32. package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -1
  33. package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +19 -19
  34. package/common/src/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
  35. package/common/src/data-structures/TokenDBs/token-visibility-db.mjs +45 -44
  36. package/common/src/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
  37. package/common/src/data-structures/cacheDevices/FileCacheDevice.mjs +1 -1
  38. package/common/src/functions/snarkjs/verifyCommitmentValidationData.cjs +1 -1
  39. package/common/src/functions/snarkjs/verifyCommitmentValidationData.mjs +4 -1
  40. package/common/src/functions/utils/cacheDevice.utils.cjs +1 -1
  41. package/common/src/functions/utils/cacheDevice.utils.mjs +1 -1
  42. package/common/src/functions/utils/cacheFunctions.cjs +1 -1
  43. package/common/src/functions/utils/cacheFunctions.mjs +13 -13
  44. package/common/src/functions/utils/ipfs.cjs +1 -1
  45. package/common/src/functions/utils/ipfs.mjs +3 -1
  46. package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
  47. package/common/src/webworker/workerFactory.cjs +1 -1
  48. package/common/src/webworker/workerFactory.mjs +3 -3
  49. package/package.json +1 -1
  50. package/shims/circomlibjs-hinkal-fork.cjs +14 -0
  51. package/shims/circomlibjs-hinkal-fork.mjs +3 -0
  52. package/shims/circomlibjs.cjs +15 -0
  53. package/shims/circomlibjs.mjs +3 -0
  54. package/shims/constants.cjs +7 -0
  55. package/shims/constants.mjs +3 -0
  56. package/shims/crypto.cjs +102 -0
  57. package/shims/crypto.mjs +3 -0
  58. package/shims/dotenv.cjs +3 -0
  59. package/shims/dotenv.mjs +3 -0
  60. package/shims/ffjavascript.cjs +5 -0
  61. package/shims/ffjavascript.mjs +3 -0
  62. package/shims/fs.cjs +5 -0
  63. package/shims/fs.mjs +3 -0
  64. package/shims/globals.cjs +15 -0
  65. package/shims/globals.mjs +3 -0
  66. package/shims/idb-keyval.cjs +75 -0
  67. package/shims/idb-keyval.mjs +3 -0
  68. package/shims/multiformats.cjs +1 -0
  69. package/shims/multiformats.mjs +3 -0
  70. package/shims/os.cjs +7 -0
  71. package/shims/os.mjs +3 -0
  72. package/shims/path.cjs +11 -0
  73. package/shims/path.mjs +3 -0
  74. package/shims/readline.cjs +6 -0
  75. package/shims/readline.mjs +3 -0
  76. package/shims/snarkjs.cjs +21 -0
  77. package/shims/snarkjs.mjs +3 -0
  78. package/shims/url.cjs +5 -0
  79. package/shims/url.mjs +3 -0
  80. package/shims/web-worker.cjs +7 -0
  81. package/shims/web-worker.mjs +3 -0
  82. package/shims/worker_threads.cjs +6 -0
  83. package/shims/worker_threads.mjs +3 -0
@@ -0,0 +1,102 @@
1
+ // Node `crypto` shim for React Native.
2
+
3
+ const { sha256, sha512, keccak256 } = require('ethers');
4
+ const { Buffer } = require('buffer');
5
+
6
+ function ensureRng() {
7
+ if (!global.crypto || typeof global.crypto.getRandomValues !== 'function') {
8
+ throw new Error(
9
+ '[hinkal-rn] global.crypto.getRandomValues is not available. ' +
10
+ 'Import @hinkal/sdk-react-native (HinkalProvider) before other SDK code.',
11
+ );
12
+ }
13
+ }
14
+
15
+ function randomBytes(size) {
16
+ ensureRng();
17
+ const arr = new Uint8Array(size);
18
+ global.crypto.getRandomValues(arr);
19
+ return Buffer.from(arr);
20
+ }
21
+
22
+ function randomFillSync(buf, offset, size) {
23
+ ensureRng();
24
+ const start = offset ?? 0;
25
+ const end = size != null ? start + size : buf.length;
26
+ const view = new Uint8Array(buf.buffer || buf, buf.byteOffset || 0, buf.length);
27
+ const tmp = new Uint8Array(end - start);
28
+ global.crypto.getRandomValues(tmp);
29
+ view.set(tmp, start);
30
+ return buf;
31
+ }
32
+
33
+ function randomUUID() {
34
+ // RFC 4122 v4 UUID via crypto-secure bytes.
35
+ const b = randomBytes(16);
36
+ b[6] = (b[6] & 0x0f) | 0x40;
37
+ b[8] = (b[8] & 0x3f) | 0x80;
38
+ const hex = b.toString('hex');
39
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
40
+ }
41
+
42
+ function toBytesLike(input) {
43
+ if (input == null) return new Uint8Array(0);
44
+ if (typeof input === 'string') return Buffer.from(input, 'utf8');
45
+ if (input instanceof Uint8Array) return input;
46
+ if (Buffer.isBuffer(input)) return input;
47
+ if (input.buffer) return new Uint8Array(input.buffer, input.byteOffset || 0, input.byteLength || input.length);
48
+ return Buffer.from(input);
49
+ }
50
+
51
+ function hexToBuffer(hex) {
52
+ return Buffer.from(hex.replace(/^0x/, ''), 'hex');
53
+ }
54
+
55
+ function createHash(algorithm) {
56
+ const alg = String(algorithm).toLowerCase().replace('-', '');
57
+ const chunks = [];
58
+ return {
59
+ update(chunk) {
60
+ chunks.push(toBytesLike(chunk));
61
+ return this;
62
+ },
63
+ digest(encoding) {
64
+ const total = chunks.reduce((acc, c) => acc + c.length, 0);
65
+ const merged = new Uint8Array(total);
66
+ let off = 0;
67
+ for (const c of chunks) {
68
+ merged.set(c, off);
69
+ off += c.length;
70
+ }
71
+ let hex;
72
+ if (alg === 'sha256') hex = sha256(merged);
73
+ else if (alg === 'sha512') hex = sha512(merged);
74
+ else if (alg === 'keccak256') hex = keccak256(merged);
75
+ else throw new Error(`[hinkal-rn] unsupported hash algorithm: ${algorithm}`);
76
+ const buf = hexToBuffer(hex);
77
+ if (!encoding) return buf;
78
+ if (encoding === 'hex') return buf.toString('hex');
79
+ if (encoding === 'base64') return buf.toString('base64');
80
+ return buf.toString(encoding);
81
+ },
82
+ };
83
+ }
84
+
85
+ function createHmac() {
86
+ throw new Error('[hinkal-rn] crypto.createHmac is not implemented in the RN shim. Use a JS implementation.');
87
+ }
88
+
89
+ module.exports = {
90
+ randomBytes,
91
+ randomFillSync,
92
+ randomUUID,
93
+ createHash,
94
+ createHmac,
95
+ webcrypto: typeof global.crypto !== 'undefined' ? global.crypto : undefined,
96
+ getRandomValues: (arr) => {
97
+ ensureRng();
98
+ global.crypto.getRandomValues(arr);
99
+ return arr;
100
+ },
101
+ };
102
+ module.exports.default = module.exports;
@@ -0,0 +1,3 @@
1
+ import mod from "./crypto.cjs";
2
+ export function require_crypto() { return mod; }
3
+ export default mod;
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ config: () => ({ parsed: {} }),
3
+ };
@@ -0,0 +1,3 @@
1
+ import mod from "./dotenv.cjs";
2
+ export function require_dotenv() { return mod; }
3
+ export default mod;
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ Scalar: {},
3
+ F1Field: class {},
4
+ getCurveFromName: () => { throw new Error("not supported") },
5
+ }
@@ -0,0 +1,3 @@
1
+ import mod from "./ffjavascript.cjs";
2
+ export function require_ffjavascript() { return mod; }
3
+ export default mod;
package/shims/fs.cjs ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ existsSync: () => false,
3
+ readFileSync: () => '',
4
+ writeFileSync: () => {},
5
+ };
package/shims/fs.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import mod from "./fs.cjs";
2
+ export function require_fs() { return mod; }
3
+ export default mod;
@@ -0,0 +1,15 @@
1
+ import { Buffer } from "buffer";
2
+ import * as ReactNative from "react-native";
3
+ global.Buffer = Buffer;
4
+
5
+ // key-val-store probes indexedDB; without it the SDK falls back to FileKeyValStore (process.cwd).
6
+ if (typeof globalThis.indexedDB === "undefined") {
7
+ globalThis.indexedDB = {};
8
+ }
9
+
10
+ if (typeof global.require === "undefined") {
11
+ global.require = (m) => {
12
+ if (m === "react-native") return ReactNative;
13
+ throw new Error(`global.require shim: unsupported module "${m}"`);
14
+ };
15
+ }
@@ -0,0 +1,3 @@
1
+ import mod from "./globals.cjs";
2
+ export function require_globals() { return mod; }
3
+ export default mod;
@@ -0,0 +1,75 @@
1
+ // idb-keyval shim for React Native
2
+ const AsyncStorage =
3
+ require("@react-native-async-storage/async-storage").default;
4
+
5
+ const PREFIX = "@hinkal/idb-keyval:";
6
+ const key = (k) => `${PREFIX}${typeof k === "string" ? k : JSON.stringify(k)}`;
7
+
8
+ async function get(k) {
9
+ const raw = await AsyncStorage.getItem(key(k));
10
+ if (raw == null) return undefined;
11
+ try {
12
+ return JSON.parse(raw);
13
+ } catch {
14
+ return undefined;
15
+ }
16
+ }
17
+
18
+ async function set(k, value) {
19
+ if (value === undefined) {
20
+ await AsyncStorage.removeItem(key(k));
21
+ return;
22
+ }
23
+ await AsyncStorage.setItem(key(k), JSON.stringify(value));
24
+ }
25
+
26
+ async function update(k, updater) {
27
+ const current = await get(k);
28
+ const next = updater(current);
29
+ await set(k, next);
30
+ return next;
31
+ }
32
+
33
+ async function del(k) {
34
+ await AsyncStorage.removeItem(key(k));
35
+ }
36
+
37
+ async function clear() {
38
+ const all = await AsyncStorage.getAllKeys();
39
+ const ours = all.filter((x) => x.startsWith(PREFIX));
40
+ if (ours.length) await AsyncStorage.multiRemove(ours);
41
+ }
42
+
43
+ async function keys() {
44
+ const all = await AsyncStorage.getAllKeys();
45
+ return all.filter((x) => x.startsWith(PREFIX)).map((x) => x.slice(PREFIX.length));
46
+ }
47
+
48
+ async function values() {
49
+ const ks = await keys();
50
+ return Promise.all(ks.map(get));
51
+ }
52
+
53
+ async function entries() {
54
+ const ks = await keys();
55
+ const vs = await Promise.all(ks.map(get));
56
+ return ks.map((k, i) => [k, vs[i]]);
57
+ }
58
+
59
+ function createStore() {
60
+ // idb-keyval lets callers create a store with a custom DB name; we ignore it
61
+ return undefined;
62
+ }
63
+
64
+ module.exports = {
65
+ get,
66
+ set,
67
+ update,
68
+ del,
69
+ clear,
70
+ keys,
71
+ values,
72
+ entries,
73
+ createStore,
74
+ };
75
+ module.exports.default = module.exports;
@@ -0,0 +1,3 @@
1
+ import mod from "./idb-keyval.cjs";
2
+ export function require_idb_keyval() { return mod; }
3
+ export default mod;
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -0,0 +1,3 @@
1
+ import mod from "./multiformats.cjs";
2
+ export function require_multiformats() { return mod; }
3
+ export default mod;
package/shims/os.cjs ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ hostname: () => 'localhost',
3
+ platform: () => 'linux',
4
+ arch: () => 'arm64',
5
+ EOL: '\n',
6
+ tmpdir: () => '/tmp',
7
+ };
package/shims/os.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import mod from "./os.cjs";
2
+ export function require_os() { return mod; }
3
+ export default mod;
package/shims/path.cjs ADDED
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ join: (...args) => args.join("/"),
3
+ resolve: (...args) => args.join("/"),
4
+ dirname: (p) => p.split("/").slice(0, -1).join("/"),
5
+ basename: (p) => p.split("/").pop(),
6
+ extname: (p) => {
7
+ const base = p.split("/").pop();
8
+ const idx = base.lastIndexOf(".");
9
+ return idx < 0 ? "" : base.slice(idx);
10
+ },
11
+ };
package/shims/path.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import mod from "./path.cjs";
2
+ export function require_path() { return mod; }
3
+ export default mod;
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ createInterface: () => ({
3
+ on: () => {},
4
+ close: () => {},
5
+ }),
6
+ };
@@ -0,0 +1,3 @@
1
+ import mod from "./readline.cjs";
2
+ export function require_readline() { return mod; }
3
+ export default mod;
@@ -0,0 +1,21 @@
1
+ function notSupported(name) {
2
+ return () => {
3
+ throw new Error(
4
+ `[hinkal-rn] snarkjs.${name} is not available on the React Native JS thread. ` +
5
+ "All proof generation must go through the SnarkJS WebView bridge.",
6
+ );
7
+ };
8
+ }
9
+
10
+ module.exports = {
11
+ groth16: {
12
+ fullProve: notSupported("groth16.fullProve"),
13
+ prove: notSupported("groth16.prove"),
14
+ verify: notSupported("groth16.verify"),
15
+ exportSolidityCallData: notSupported("groth16.exportSolidityCallData"),
16
+ },
17
+ zKey: {
18
+ exportVerificationKey: notSupported("zKey.exportVerificationKey"),
19
+ },
20
+ };
21
+ module.exports.default = module.exports;
@@ -0,0 +1,3 @@
1
+ import mod from "./snarkjs.cjs";
2
+ export function require_snarkjs() { return mod; }
3
+ export default mod;
package/shims/url.cjs ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ pathToFileURL: (p) => ({ href: p }),
3
+ fileURLToPath: (u) => u,
4
+ URL: typeof URL !== "undefined" ? URL : null,
5
+ };
package/shims/url.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import mod from "./url.cjs";
2
+ export function require_url() { return mod; }
3
+ export default mod;
@@ -0,0 +1,7 @@
1
+ module.exports = class Worker {
2
+ constructor() {}
3
+ postMessage() {}
4
+ terminate() {}
5
+ addEventListener() {}
6
+ removeEventListener() {}
7
+ };
@@ -0,0 +1,3 @@
1
+ import mod from "./web-worker.cjs";
2
+ export function require_web_worker() { return mod; }
3
+ export default mod;
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ Worker: class {},
3
+ workerData: {},
4
+ parentPort: null,
5
+ isMainThread: true,
6
+ };
@@ -0,0 +1,3 @@
1
+ import mod from "./worker_threads.cjs";
2
+ export function require_worker_threads() { return mod; }
3
+ export default mod;