@gurge/sdk 0.3.27 → 0.3.28

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 (140) hide show
  1. package/common/src/crypto/BabyJubRN.cjs +1 -0
  2. package/common/src/crypto/BabyJubRN.d.ts +2 -0
  3. package/common/src/crypto/BabyJubRN.mjs +66 -0
  4. package/common/src/crypto/EddsaRN.cjs +1 -0
  5. package/common/src/crypto/EddsaRN.mjs +41 -0
  6. package/common/src/crypto/babyJub.cjs +1 -1
  7. package/common/src/crypto/babyJub.mjs +6 -12
  8. package/common/src/crypto/eddsa.cjs +1 -1
  9. package/common/src/crypto/eddsa.mjs +6 -12
  10. package/common/src/crypto/poseidon.cjs +1 -1
  11. package/common/src/crypto/poseidon.mjs +6 -12
  12. package/common/src/crypto/preProcessing.cjs +1 -1
  13. package/common/src/crypto/preProcessing.mjs +13 -23
  14. package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
  15. package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +9 -9
  16. package/common/src/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
  17. package/common/src/data-structures/Hinkal/hinkalClaimUtxo.mjs +6 -6
  18. package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  19. package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +1 -1
  20. package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
  21. package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +18 -18
  22. package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  23. package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +17 -17
  24. package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  25. package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +13 -13
  26. package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
  27. package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +11 -11
  28. package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
  29. package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +14 -14
  30. package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  31. package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +51 -51
  32. package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  33. package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +51 -51
  34. package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
  35. package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +20 -20
  36. package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
  37. package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +19 -19
  38. package/common/src/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  39. package/common/src/data-structures/Hinkal/hinkalSwap.mjs +1 -1
  40. package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  41. package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +9 -9
  42. package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  43. package/common/src/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
  44. package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +35 -46
  45. package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  46. package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +33 -33
  47. package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.cjs +1 -1
  48. package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.mjs +1 -1
  49. package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
  50. package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +26 -42
  51. package/common/src/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  52. package/common/src/data-structures/crypto-keys/decodeUTXO.mjs +7 -7
  53. package/common/src/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  54. package/common/src/data-structures/crypto-keys/encryptDecryptUtxo.mjs +1 -1
  55. package/common/src/data-structures/utxo/Utxo.cjs +1 -1
  56. package/common/src/data-structures/utxo/Utxo.d.ts +0 -1
  57. package/common/src/data-structures/utxo/Utxo.mjs +6 -19
  58. package/common/src/functions/index.cjs +1 -1
  59. package/common/src/functions/index.mjs +4 -3
  60. package/common/src/functions/pre-transaction/buildCommitmentValidationData.cjs +1 -1
  61. package/common/src/functions/pre-transaction/buildCommitmentValidationData.mjs +43 -86
  62. package/common/src/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  63. package/common/src/functions/pre-transaction/outputUtxoProcessing.d.ts +2 -2
  64. package/common/src/functions/pre-transaction/outputUtxoProcessing.mjs +22 -28
  65. package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
  66. package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +14 -14
  67. package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
  68. package/common/src/functions/snarkjs/common.snarkjs.mjs +7 -7
  69. package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  70. package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +60 -67
  71. package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  72. package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +60 -60
  73. package/common/src/functions/snarkjs/verifyCommitmentValidationData.cjs +1 -1
  74. package/common/src/functions/snarkjs/verifyCommitmentValidationData.mjs +1 -1
  75. package/common/src/functions/utils/bigint-math.utils.cjs +1 -1
  76. package/common/src/functions/utils/bigint-math.utils.d.ts +2 -0
  77. package/common/src/functions/utils/bigint-math.utils.mjs +18 -1
  78. package/common/src/functions/utils/buildClaimableDepositPlan.cjs +1 -1
  79. package/common/src/functions/utils/buildClaimableDepositPlan.mjs +1 -1
  80. package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
  81. package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +1 -1
  82. package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
  83. package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +4 -4
  84. package/common/src/functions/utils/index.cjs +1 -1
  85. package/common/src/functions/utils/index.mjs +3 -3
  86. package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  87. package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +71 -122
  88. package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
  89. package/common/src/functions/web3/events/getShieldedBalance.mjs +64 -64
  90. package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  91. package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +42 -42
  92. package/common/src/types/index.cjs +1 -1
  93. package/common/src/types/index.mjs +1 -1
  94. package/common/src/webworker/logError-D8yBaP96.js +2 -0
  95. package/common/src/webworker/package.json +1 -1
  96. package/common/src/webworker/performTaskWithWorker.cjs +1 -1
  97. package/common/src/webworker/performTaskWithWorker.mjs +17 -18
  98. package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
  99. package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
  100. package/common/src/webworker/utxoWorkerNode.cjs +1 -1
  101. package/common/src/webworker/viteWorkerURL.constant.cjs +3 -4
  102. package/common/src/webworker/viteWorkerURL.constant.d.ts +0 -1
  103. package/common/src/webworker/viteWorkerURL.constant.mjs +3 -4
  104. package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
  105. package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
  106. package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
  107. package/package.json +1 -1
  108. package/react-native/HinkalWebViewWorker.cjs +4 -76
  109. package/react-native/HinkalWebViewWorker.mjs +49 -152
  110. package/react-native/bridge/HinkalRNWorker.cjs +1 -1
  111. package/react-native/bridge/HinkalRNWorker.d.ts +0 -1
  112. package/react-native/bridge/HinkalRNWorker.mjs +11 -16
  113. package/react-native/shims/circomlibjs-hinkal-fork.js +2 -2
  114. package/react-native/shims/circomlibjs.js +2 -2
  115. package/react-native/workerCDNUrls.cjs +1 -1
  116. package/react-native/workerCDNUrls.d.ts +0 -1
  117. package/react-native/workerCDNUrls.mjs +2 -2
  118. package/sdk/package.json.cjs +1 -1
  119. package/sdk/package.json.mjs +1 -1
  120. package/common/src/crypto/rnCryptoBridge.cjs +0 -1
  121. package/common/src/crypto/rnCryptoBridge.d.ts +0 -8
  122. package/common/src/crypto/rnCryptoBridge.mjs +0 -10
  123. package/common/src/crypto/rnUtxoCrypto.cjs +0 -1
  124. package/common/src/crypto/rnUtxoCrypto.d.ts +0 -25
  125. package/common/src/crypto/rnUtxoCrypto.mjs +0 -74
  126. package/common/src/functions/utils/hinkalTiming.utils.cjs +0 -1
  127. package/common/src/functions/utils/hinkalTiming.utils.d.ts +0 -11
  128. package/common/src/functions/utils/hinkalTiming.utils.mjs +0 -21
  129. package/common/src/functions/utils/utxoPadding.utils.cjs +0 -1
  130. package/common/src/functions/utils/utxoPadding.utils.d.ts +0 -2
  131. package/common/src/functions/utils/utxoPadding.utils.mjs +0 -14
  132. package/common/src/webworker/cryptoWorker/cryptoWorker.types.cjs +0 -1
  133. package/common/src/webworker/cryptoWorker/cryptoWorker.types.d.ts +0 -51
  134. package/common/src/webworker/cryptoWorker/cryptoWorker.types.mjs +0 -6
  135. package/common/src/webworker/cryptoWorker/cryptoWorkerLauncher.d.ts +0 -1
  136. package/common/src/webworker/cryptoWorker/cryptoWorkerLogic.d.ts +0 -2
  137. package/common/src/webworker/logError-Dy_GXEF5.js +0 -2
  138. package/react-native/bridge/RnWebViewCryptoBridge.cjs +0 -1
  139. package/react-native/bridge/RnWebViewCryptoBridge.d.ts +0 -7
  140. package/react-native/bridge/RnWebViewCryptoBridge.mjs +0 -49
@@ -1,74 +0,0 @@
1
- import { isReactNative as e } from "../constants/vite.constants.mjs";
2
- import { getRnCryptoBridge as t } from "./rnCryptoBridge.mjs";
3
- import { randomBigInt as n } from "../functions/web3/etherFunctions.mjs";
4
- import { CryptoWorkerOp as r } from "../webworker/cryptoWorker/cryptoWorker.types.mjs";
5
- import { calcStealthAddressStructure as i } from "../functions/snarkjs/common.snarkjs.mjs";
6
- //#region libs/shared/common/src/crypto/rnUtxoCrypto.ts
7
- var a = () => n(31).toString(), o = async (e) => {
8
- let { pubSpendingBJJPoint: t } = await s(e);
9
- return t;
10
- }, s = async (n) => {
11
- if (!e) return n.getSpendingKeyPair();
12
- let i = t();
13
- await i.init();
14
- let a = await i.call(r.GET_SPENDING_KEY_PAIR, { signature: n.getSignature() });
15
- return {
16
- privSpendingKey: a.privSpendingKey,
17
- pubSpendingBJJPoint: [BigInt(a.pubSpendingBJJPoint[0]), BigInt(a.pubSpendingBJJPoint[1])]
18
- };
19
- }, c = async (n, i) => {
20
- if (!e) return n.signEddsa(i);
21
- let a = t();
22
- await a.init();
23
- let o = await a.call(r.SIGN_EDDSA, {
24
- signature: n.getSignature(),
25
- message: i.toString()
26
- });
27
- return {
28
- R8: [BigInt(o.R8[0]), BigInt(o.R8[1])],
29
- S: BigInt(o.S)
30
- };
31
- }, l = async (n, a, o) => {
32
- if (!e) return i(n, a, o);
33
- let s = t();
34
- await s.init();
35
- let c = await s.call(r.CALC_STEALTH_ADDRESS_STRUCTURE, {
36
- extraRandomization: n.toString(),
37
- nullifyingPrivateKey: a,
38
- spendingPublicKey: o.map((e) => e.toString())
39
- });
40
- return {
41
- extraRandomization: BigInt(c.extraRandomization),
42
- H0: BigInt(c.H0),
43
- H1: BigInt(c.H1),
44
- stealthAddress: BigInt(c.stealthAddress)
45
- };
46
- }, u = async (n, i) => {
47
- if (!e) throw Error("prepareNewStyleUtxoFields is only for React Native crypto bridge");
48
- let o = t();
49
- await o.init();
50
- let s = await o.call(r.PREPARE_NEW_STYLE_UTXO_FIELDS, {
51
- initialRandomization: a(),
52
- nullifyingKey: n,
53
- spendingPublicKey: i?.map((e) => e.toString())
54
- });
55
- return {
56
- randomization: BigInt(s.randomization),
57
- H0: [BigInt(s.H0[0]), BigInt(s.H0[1])],
58
- stealthAddress: s.stealthAddress
59
- };
60
- }, d = async (n) => {
61
- if (!e) throw Error("prepareNewStyleUtxoFieldsBatch is only for React Native crypto bridge");
62
- let i = t();
63
- return await i.init(), (await i.call(r.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH, { items: n.map((e) => ({
64
- initialRandomization: a(),
65
- nullifyingKey: e.nullifyingKey,
66
- spendingPublicKey: e.spendingPublicKey?.map((e) => e.toString())
67
- })) })).map((e) => ({
68
- randomization: BigInt(e.randomization),
69
- H0: [BigInt(e.H0[0]), BigInt(e.H0[1])],
70
- stealthAddress: e.stealthAddress
71
- }));
72
- }, f = (t) => e && !!t.isNewStyle && !!t.nullifyingKey && t.H0 === void 0 && t.randomization === void 0;
73
- //#endregion
74
- export { l as calcStealthAddressStructureForRn, s as getSpendingKeyPairForRn, o as getSpendingPublicKeyForRn, f as needsRnNewStyleCrypto, u as prepareNewStyleUtxoFields, d as prepareNewStyleUtxoFieldsBatch, c as signEddsaForRn };
@@ -1 +0,0 @@
1
- var e=`[HinkalRnDelta]`,t=e=>`at=${e}`,n=(n,r,i,a)=>{let o=Date.now(),s=o-i.last,c=o-i.start;i.last=o;let l=a?` ${JSON.stringify(a)}`:``;console.log(`${e} ${t(o)} [${n}] ${r} +${s}ms (total ${c}ms)${l}`)},r=e=>{let t={start:Date.now(),last:Date.now()};return{marks:t,log:(r,i)=>n(e,r,t,i)}},i=(n,r,i)=>{let a=Date.now(),o=i?` ${JSON.stringify(i)}`:``;console.log(`${e} ${t(a)} [${n}] ${r}${o}`)};exports.createRnDeltaTiming=r,exports.logRnDeltaEvent=i;
@@ -1,11 +0,0 @@
1
- export type HinkalTimingMarks = {
2
- start: number;
3
- last: number;
4
- };
5
- export declare const logRnDelta: (scope: string, phase: string, marks: HinkalTimingMarks, extra?: Record<string, unknown>) => void;
6
- export declare const createRnDeltaTiming: (scope: string) => {
7
- marks: HinkalTimingMarks;
8
- log: (phase: string, extra?: Record<string, unknown>) => void;
9
- };
10
- /** One-off event (e.g. WebView sub-phase with its own clock). */
11
- export declare const logRnDeltaEvent: (scope: string, phase: string, extra?: Record<string, unknown>) => void;
@@ -1,21 +0,0 @@
1
- //#region libs/shared/common/src/functions/utils/hinkalTiming.utils.ts
2
- var e = "[HinkalRnDelta]", t = (e) => `at=${e}`, n = (n, r, i, a) => {
3
- let o = Date.now(), s = o - i.last, c = o - i.start;
4
- i.last = o;
5
- let l = a ? ` ${JSON.stringify(a)}` : "";
6
- console.log(`${e} ${t(o)} [${n}] ${r} +${s}ms (total ${c}ms)${l}`);
7
- }, r = (e) => {
8
- let t = {
9
- start: Date.now(),
10
- last: Date.now()
11
- };
12
- return {
13
- marks: t,
14
- log: (r, i) => n(e, r, t, i)
15
- };
16
- }, i = (n, r, i) => {
17
- let a = Date.now(), o = i ? ` ${JSON.stringify(i)}` : "";
18
- console.log(`${e} ${t(a)} [${n}] ${r}${o}`);
19
- };
20
- //#endregion
21
- export { r as createRnDeltaTiming, i as logRnDeltaEvent };
@@ -1 +0,0 @@
1
- const e=require(`../../crypto/rnUtxoCrypto.cjs`),t=require(`../../data-structures/utxo/Utxo.cjs`);var n=async(n,r)=>n<=0?[]:e.needsRnNewStyleCrypto(r)?(await e.prepareNewStyleUtxoFieldsBatch(Array.from({length:n},()=>({nullifyingKey:r.nullifyingKey,spendingPublicKey:r.spendingPublicKey})))).map(e=>new t.Utxo({...r,randomization:e.randomization,H0:e.H0,stealthAddress:e.stealthAddress})):Array.from({length:n},()=>new t.Utxo(r));exports.createPaddingUtxos=n;
@@ -1,2 +0,0 @@
1
- import { Utxo, IUtxoConstructor } from '../../data-structures/utxo/Utxo';
2
- export declare const createPaddingUtxos: (count: number, baseParams: IUtxoConstructor) => Promise<Utxo[]>;
@@ -1,14 +0,0 @@
1
- import { needsRnNewStyleCrypto as e, prepareNewStyleUtxoFieldsBatch as t } from "../../crypto/rnUtxoCrypto.mjs";
2
- import { Utxo as n } from "../../data-structures/utxo/Utxo.mjs";
3
- //#region libs/shared/common/src/functions/utils/utxoPadding.utils.ts
4
- var r = async (r, i) => r <= 0 ? [] : e(i) ? (await t(Array.from({ length: r }, () => ({
5
- nullifyingKey: i.nullifyingKey,
6
- spendingPublicKey: i.spendingPublicKey
7
- })))).map((e) => new n({
8
- ...i,
9
- randomization: e.randomization,
10
- H0: e.H0,
11
- stealthAddress: e.stealthAddress
12
- })) : Array.from({ length: r }, () => new n(i));
13
- //#endregion
14
- export { r as createPaddingUtxos };
@@ -1 +0,0 @@
1
- var e=function(e){return e.INIT=`init`,e.PREPARE_NEW_STYLE_UTXO_FIELDS=`prepareNewStyleUtxoFields`,e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH=`prepareNewStyleUtxoFieldsBatch`,e.BATCH_STEALTH_VALIDATION=`batchStealthValidation`,e.POSEIDON_HASH=`poseidonHash`,e.GET_SPENDING_KEY_PAIR=`getSpendingKeyPair`,e.SIGN_EDDSA=`signEddsa`,e.CALC_STEALTH_ADDRESS_STRUCTURE=`calcStealthAddressStructure`,e}({});exports.CryptoWorkerOp=e;
@@ -1,51 +0,0 @@
1
- export type CryptoWorkerPrepareNewStyleUtxoPayload = {
2
- initialRandomization: string;
3
- nullifyingKey: string;
4
- spendingPublicKey?: [string, string];
5
- };
6
- export type CryptoWorkerPrepareNewStyleUtxoResult = {
7
- randomization: string;
8
- H0: [string, string];
9
- stealthAddress: string;
10
- };
11
- export type CryptoWorkerStealthCheck = {
12
- utxoStealthAddress: string;
13
- isNewStyle: boolean;
14
- randomization?: string;
15
- H0?: [string, string];
16
- spendingPublicKey?: [string, string];
17
- };
18
- export type CryptoWorkerStealthCheckResult = {
19
- derivedStealthAddress: string;
20
- matches: boolean;
21
- };
22
- export type CryptoWorkerSpendingKeyPairResult = {
23
- privSpendingKey: string;
24
- pubSpendingBJJPoint: [string, string];
25
- };
26
- export declare enum CryptoWorkerOp {
27
- INIT = "init",
28
- PREPARE_NEW_STYLE_UTXO_FIELDS = "prepareNewStyleUtxoFields",
29
- PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH = "prepareNewStyleUtxoFieldsBatch",
30
- BATCH_STEALTH_VALIDATION = "batchStealthValidation",
31
- POSEIDON_HASH = "poseidonHash",
32
- GET_SPENDING_KEY_PAIR = "getSpendingKeyPair",
33
- SIGN_EDDSA = "signEddsa",
34
- CALC_STEALTH_ADDRESS_STRUCTURE = "calcStealthAddressStructure"
35
- }
36
- export type CryptoWorkerRequest = {
37
- requestId?: string;
38
- op: CryptoWorkerOp | string;
39
- payload?: unknown;
40
- };
41
- export type CryptoWorkerResponse = {
42
- type: 'ready';
43
- } | {
44
- requestId: string;
45
- type: 'result';
46
- data: unknown;
47
- } | {
48
- requestId: string;
49
- type: 'error';
50
- error: string;
51
- };
@@ -1,6 +0,0 @@
1
- //#region libs/shared/common/src/webworker/cryptoWorker/cryptoWorker.types.ts
2
- var e = /* @__PURE__ */ function(e) {
3
- return e.INIT = "init", e.PREPARE_NEW_STYLE_UTXO_FIELDS = "prepareNewStyleUtxoFields", e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH = "prepareNewStyleUtxoFieldsBatch", e.BATCH_STEALTH_VALIDATION = "batchStealthValidation", e.POSEIDON_HASH = "poseidonHash", e.GET_SPENDING_KEY_PAIR = "getSpendingKeyPair", e.SIGN_EDDSA = "signEddsa", e.CALC_STEALTH_ADDRESS_STRUCTURE = "calcStealthAddressStructure", e;
4
- }({});
5
- //#endregion
6
- export { e as CryptoWorkerOp };
@@ -1,2 +0,0 @@
1
- import { CryptoWorkerRequest } from './cryptoWorker.types';
2
- export declare const onCryptoWorkerMessage: (data: CryptoWorkerRequest) => Promise<void>;
@@ -1,2 +0,0 @@
1
- const e=require(`./workerProxy-DPeuP2Mg.js`);let t=require(`buffer`),n=require(`process`);n=e.u(n);let r=require(`ethers`),i=require(`poseidon-lite`);i=e.u(i);let a=require(`libsodium-wrappers`);a=e.u(a);let o=require(`@solana/web3.js`),s=require(`bs58`);s=e.u(s);let c=require(`tweetnacl`);c=e.u(c);let l=require(`tronweb`);var u=class{static bridge=null},d=()=>{let e=u.bridge;if(!e)throw Error(`RN crypto bridge is not registered. Mount HinkalWebViewWorker in your app.`);return e},f=new class{babyjub=void 0;async init(){if(this.babyjub)return;if(e.o){await d().init();return}let{buildBabyjub:t}=await import(`circomlibjs-hinkal-fork`);this.babyjub=await t()}getJub(){if(e.o)throw Error(`babyJubInstance is unavailable on React Native main thread. Use WebView crypto bridge.`);return this.babyjub}},p=()=>f.getJub(),m=new class{eddsa=void 0;async init(){if(this.eddsa)return;if(e.o){await d().init();return}let{buildEddsa:t}=await import(`circomlibjs-hinkal-fork`);this.eddsa=await t()}getEddsa(){if(e.o)throw Error(`eddsaInstance is unavailable on React Native main thread. Use WebView crypto bridge.`);return this.eddsa}},h=()=>m.getEddsa();function g(e){return typeof e==`object`&&`toBigInt`in e?e.toBigInt():BigInt(e)}var _=()=>{let e=e=>{let t=i[`poseidon${e.length}`];if(!t)throw Error(`Poseidon: arity ${e.length} not supported (1..16)`);return t(e.map(e=>BigInt(e)))};return e.F={toString:e=>BigInt(e).toString()},e},v=new class{poseidon=void 0;async init(){if(this.poseidon)return;if(e.o){await d().init(),this.poseidon=_();return}let{buildPoseidon:t}=await import(`circomlibjs-hinkal-fork`);this.poseidon=await t()}getPoseidon(){return this.poseidon}};function y(...e){let t=v.getPoseidon();return g(t.F.toString(t(e)))}var b=(...e)=>{let t=v.getPoseidon();return r.ethers.toBeHex(t.F.toString(t([...e])))},ee=async(r=!1)=>{if((typeof window<`u`||typeof self<`u`)&&(typeof window<`u`&&(window.global=window),globalThis.Buffer=t.Buffer,globalThis.process=n.default),e.o&&!r){await Promise.all([a.default.ready,d().init(),v.init()]);return}await Promise.all([a.default.ready,v.init(),f.init(),...r?[]:[m.init()]])};`${`00`.repeat(20)}`;var x=21888242871839275222246405745257275088548364400416034343698204186575808495617n,S=x/2n,C=200n;`${`00`.repeat(32)}`;var w=class{inMemoryCache=new Map;constructor(e){e&&this.mergeWithSerialized(e)}getInMemory(e){return this.inMemoryCache.get(e)??void 0}setInMemory(e,t){this.inMemoryCache.set(e,t)}mergeWithSerialized(t){Object.entries(t).forEach(([t,n])=>{this.set(t,e.c(n))})}},T=class extends w{isAttached=!1;get(e){return this.getInMemory(e)}set(e,t){this.setInMemory(e,t)}serialize(){return Object.fromEntries([...this.inMemoryCache].map(([t,n])=>[t,e.l(n)]))}attach(t){if(this.isAttached)throw Error(`can't reattach cache device`);return this.isAttached=!0,(...n)=>{let r=e.l(n),i=this.get(r);if(i!==void 0)return i;let a=t(...n);return this.set(r,a),a}}},E=e=>{if(e<0n||e>=21888242871839275222246405745257275088548364400416034343698204186575808495617n)throw RangeError();return e>S},D=e=>E(e)?1n:0n,O=new T,k=new T,A=new T,j=class{signature;nullifyingKey;PREFIX_FOR_SPENDING_PAIR=`1`;PREFIX_FOR_NULLIFYING_PAIR=`2`;constructor(e,t){this.signature=e,this.nullifyingKey=t}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error(`No signature provided`)}requireKeyMaterial(){if(!this.signature&&!this.nullifyingKey)throw Error(`No signature or private key provided`)}verifyTronMessage(e,t){return this.requireSignature(),t===l.Trx.verifyMessageV2(e,this.signature)}getShieldedPrivateKey=()=>(this.requireKeyMaterial(),this.nullifyingKey||=r.ethers.keccak256(this.signature),this.nullifyingKey);getShieldedPublicKey=()=>(this.requireKeyMaterial(),b(this.getShieldedPrivateKey()));getSpendingKeyPair=()=>{this.requireSignature();let e=h(),t=p(),n=b(this.PREFIX_FOR_SPENDING_PAIR,this.getSignature()),i=Buffer.from(r.ethers.getBytes(n)),a=e.prv2pub(i);return{privSpendingKey:n,pubSpendingBJJPoint:[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))]}};signEddsa=e=>{this.requireSignature();let t=p(),n=h(),i=Buffer.from(r.ethers.getBytes(this.getSpendingKeyPair().privSpendingKey)),a=t.F.e(e),o=n.signPoseidon(i,a);return{R8:[BigInt(t.F.toString(o.R8[0])),BigInt(t.F.toString(o.R8[1]))],S:BigInt(o.S)}};getShieldedPrivateKeyFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(`hinkal-offchain-shielded-key:${t}`))};getClaimableSignatureFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(`hinkal-claimable-utxo-signature:${t}`))};getDerivedEthereumAddress=()=>(this.requireKeyMaterial(),new r.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireKeyMaterial(),o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());getNearIntentsAccountId=()=>{this.requireKeyMaterial();let e=o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey()));return r.ethers.hexlify(e.publicKey.toBytes()).slice(2)};getNearIntentsKeyPairString=()=>{this.requireKeyMaterial();let e=o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey()));return`ed25519:${s.default.encode(e.secretKey)}`};getSignerPrivateKeyFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(t))};getSignerSolanaPrivateKeyFromNonce=e=>{let t=this.getSignerPrivateKeyFromNonce(e),n=r.ethers.getBytes(t),i=o.Keypair.fromSeed(n);return s.default.encode(i.secretKey)};verifyMessage(e){return this.requireSignature(),r.ethers.verifyMessage(e,this.signature)}verifySolanaMessage(e,t){this.requireSignature();let n=new TextEncoder().encode(e),i=r.ethers.getBytes(this.signature),a=new o.PublicKey(t).toBytes();return c.default.sign.detached.verify(n,i,a)}static getRandomizedStealthPairOld=k.attach((e,t)=>{let n=p(),r=e*(BigInt(t)%x)%x,i=n.mulPointEscalar(n.Base8,e),a=n.mulPointEscalar(n.Base8,r);return{H0:[BigInt(n.F.toString(i[0])),BigInt(n.F.toString(i[1]))],H1:[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]}});static getRandomizedStealthPair=O.attach((e,t)=>{let n=p(),r=BigInt(t)%x,i=n.mulPointEscalar(n.Base8,e),a=n.mulPointEscalar(i,r);return{H0:[BigInt(n.F.toString(i[0])),BigInt(n.F.toString(i[1]))],H1:[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]}});static getStealthAddressCompressedPoints=(e,t)=>{let{H0:n,H1:r}=this.getRandomizedStealthPairOld(e,t),[i,a]=[n,r].map(e=>BigInt(e[1])+2n**255n*D(e[0]));return{h0:i,h1:a}};static checkSignature=(e,t,n,r)=>{let{h0:i,h1:a}=this.getStealthAddressCompressedPoints(e,r);return t===i&&n===a};static getStealthAddress=A.attach((e,t)=>{let{H0:n,H1:r}=this.getRandomizedStealthPairOld(e,t);return b(2n*D(n[0])+D(r[0]),n[1],r[1])});static getH1FromH0=(e,t)=>{let n=p(),r=BigInt(t)%x,i=[n.F.e(e[0]),n.F.e(e[1])],a=n.mulPointEscalar(i,r);return[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]};static verifyStealthPair=(e,t,n,r=!0)=>{let i=this.getH1FromH0(e,n);return r?i[1]===t[1]:i===t};static getStealthAddressNewStyle=(e,t,n)=>{if(n?.length!==2)throw Error(`Spending public key must be an array of 2 elements`);let r=this.getH1FromH0(e,t);return b(2n*D(e[0])+D(r[0]),e[1],r[1],n[0],n[1],t)};static findCorrectRandomization(e,t){if(!t)throw Error(`No Private Shielded Key Provided`);let n=BigInt(t)%x,r,i,a=0n;do r=e*10n**a%x,i=r*n%x,a+=1n;while(i>=2n**253n||r>=2n**253n);return r}static getH0FromRandomization=e=>{let t=p(),n=t.mulPointEscalar(t.Base8,e);return[BigInt(t.F.toString(n[0])),BigInt(t.F.toString(n[1]))]};static findH0(e,t){if(!t)return;let{H0:n}=this.getRandomizedStealthPair(e,t);return n}static getEncryptionKeyPair=e=>{let t=a.default.crypto_box_seed_keypair(r.ethers.getBytes(e));return{privateKey:r.ethers.hexlify(t.privateKey),publicKey:r.ethers.hexlify(t.publicKey)}};getAccessKey=()=>(this.requireKeyMaterial(),b(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getBackendToken=()=>(this.requireKeyMaterial(),b(this.getAccessKey(),this.getShieldedPublicKey()))},M={CANNOT_CERTIFY_FOR_PAST_WEEK:`Certification for the past week is not available`,CYCLICAL_REFERRALS_FORBIDDEN:`Cyclical referrals are forbidden`,USER_IS_UNRANKED:`Please certify transactions to see rank`},N={WC_NO_MATCHING_KEY:`creating the transaction failed
2
- version`,CONNECTION_PROBLEM:`Failed to connect wallet. Please try again.`,REQUEST_PENDING:`request of type 'wallet_requestpermissions' already pending for origin`},P={INSUFFICIENT_FUNDS:`Insufficient funds`,INSUFFICIENT_FUNDS_WITHDRAW:`Not enough funds to withdraw`,INSUFFICIENT_FUNDS_TRANSFER:`Not enough funds to transfer`,INSUFFICIENT_FUNDS_TO_TRANSACT:`Not enough funds to transact`,INSUFFICIENT_FUNDS_GAS:`Insufficient funds for gas * price`,INSUFFICIENT_TRON_BALANCE_FOR_FEE:`Insufficient TRX balance to cover transfer amount and transaction fee reserve`,INSUFFICIENT_SOL_BALANCE:`Insufficient SOL balance`},F={GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT:`Skipped shielding due to gas fee exceeding your limit.`,AUTO_SHIELD_INSUFFICIENT_GAS:`Auto-Shield skipped due to insufficient gas.`};({...M,...N,...P,...F});var I=e=>BigInt(r.ethers.hexlify(r.ethers.randomBytes(e))),L=function(e){return e.INIT=`init`,e.PREPARE_NEW_STYLE_UTXO_FIELDS=`prepareNewStyleUtxoFields`,e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH=`prepareNewStyleUtxoFieldsBatch`,e.BATCH_STEALTH_VALIDATION=`batchStealthValidation`,e.POSEIDON_HASH=`poseidonHash`,e.GET_SPENDING_KEY_PAIR=`getSpendingKeyPair`,e.SIGN_EDDSA=`signEddsa`,e.CALC_STEALTH_ADDRESS_STRUCTURE=`calcStealthAddressStructure`,e}({}),R=()=>a.default.crypto_box_SEALBYTES+a.default.crypto_secretbox_KEYBYTES,z=e=>{let t=a.default.crypto_secretbox_NONCEBYTES,n=R(),r=0,i=e[r];r+=1;let o=e.slice(r,r+t);r+=t;let s=[];for(let t=0;t<i;t+=1)s.push(e.slice(r,r+n)),r+=n;return{nonce:o,sealedKeys:s,ciphertext:e.slice(r)}},B=(e,t,n,i)=>{let{nonce:o,sealedKeys:s,ciphertext:c}=z(e),l=a.default.crypto_box_seal_open(s[i],r.ethers.getBytes(n),r.ethers.getBytes(t)),u=a.default.crypto_secretbox_open_easy(c,o,l);return Buffer.from(u)},V=(e,t,n)=>{let i=a.default.crypto_box_seal_open(e,r.ethers.getBytes(n),r.ethers.getBytes(t));return Buffer.from(i)},H=54912,U=2,W=e=>e[0]*256+e[1],G=(e,t)=>{let{privateKey:n,publicKey:r}=j.getEncryptionKeyPair(t.getShieldedPrivateKey()),i=W(e)===H?B(e.slice(U),n,r,0):V(e,n,r),a=Buffer.from(i).toString(`utf-8`).split(`0x`).filter(e=>e.length!==0),s=e=>BigInt(`0x${e}`),c=e=>`0x${e}`,l=a.length>=8,u=l&&s(a[5])===1n,d=l?8:6,f=a[d]?c(a[d]):void 0,p=f?new o.PublicKey(Buffer.from(f.slice(2),`hex`)).toString():void 0;return{amount:s(a[0]),erc20TokenAddress:c(a[1]),randomization:s(a[2]),stealthAddress:c(a[3]),nullifyingKey:t.getShieldedPrivateKey(),timeStamp:s(a[4]).toString(),isNewStyle:u,...u?{H0:[s(a[6]),s(a[7])]}:{},mintAddress:p}},K=(e,t)=>new $(G(e,t));Object.values({preHookContract:`0x0000000000000000000000000000000000000000`,hookContract:`0x0000000000000000000000000000000000000000`,preHookMetadata:`0x00`,postHookMetadata:`0x00`});var q=e=>e&2n**255n-1n,J=e=>e>>255n&1n;Array.from({length:25},()=>`0`);var Y=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){n.push([]);for(let i=0;i<e[r].length;i+=1)n[r][i]=t.getSiblingHashesForVerification(BigInt(e[r][i].getCommitment())).map(e=>e.toString())}let r=[];for(let n=0;n<e.length;n+=1){r.push([]);for(let i=0;i<e[n].length;i+=1)r[n][i]=t.getSiblingSides(BigInt(e[n][i].getCommitment())).map(e=>e.toString())}return{inCommitmentSiblings:n,inCommitmentSiblingSides:r}},X=()=>I(31).toString(),Z=async(t,n)=>{if(!e.o)throw Error(`prepareNewStyleUtxoFields is only for React Native crypto bridge`);let r=d();await r.init();let i=await r.call(L.PREPARE_NEW_STYLE_UTXO_FIELDS,{initialRandomization:X(),nullifyingKey:t,spendingPublicKey:n?.map(e=>e.toString())});return{randomization:BigInt(i.randomization),H0:[BigInt(i.H0[0]),BigInt(i.H0[1])],stealthAddress:i.stealthAddress}},Q=t=>e.o&&!!t.isNewStyle&&!!t.nullifyingKey&&t.H0===void 0&&t.randomization===void 0,te=()=>Math.floor(Date.now()/1e3),$=class t{amount;erc20TokenAddress;mintAddress;timeStamp;nullifyingKey;spendingPublicKey;randomization;H0;stealthAddress;encryptionKey;commitment;nullifier;isBlocked;isNewStyle;constructor({amount:e,erc20TokenAddress:t,mintAddress:n,timeStamp:r,nullifyingKey:i,spendingPublicKey:a,randomization:o,H0:s,stealthAddress:c,encryptionKey:l,commitment:u=void 0,nullifier:d=void 0,isBlocked:f=!1,isNewStyle:p=!1}){this.amount=e,this.erc20TokenAddress=t,this.mintAddress=n,this.timeStamp=r??te().toString(),this.nullifyingKey=i,this.spendingPublicKey=a,this.randomization=o??(i?j.findCorrectRandomization(I(31),i):void 0),this.H0=s??(p&&this.randomization?j.findH0(this.randomization,i):void 0),this.stealthAddress=c,this.encryptionKey=l,this.commitment=u,this.nullifier=d,this.isBlocked=f,this.isNewStyle=p}static async createAsync(e){if(Q(e)){let n=await Z(e.nullifyingKey,e.spendingPublicKey);return new t({...e,randomization:n.randomization,H0:n.H0,stealthAddress:n.stealthAddress})}return new t(e)}static createFrom(e,n){return new t({...e.getConstructableParams(),nullifier:void 0,commitment:void 0,...n})}getConstructableParams(){return{amount:this.amount,erc20TokenAddress:this.erc20TokenAddress,mintAddress:this.mintAddress,timeStamp:this.timeStamp,nullifyingKey:this.nullifyingKey,spendingPublicKey:this.spendingPublicKey,randomization:this.randomization,H0:this.H0,stealthAddress:this.stealthAddress,encryptionKey:this.encryptionKey,commitment:this.commitment,nullifier:this.nullifier,isBlocked:this.isBlocked,isNewStyle:this.isNewStyle}}getBasicUtxoParams(){return{amount:this.amount,erc20TokenAddress:this.erc20TokenAddress,mintAddress:this.mintAddress,timeStamp:this.timeStamp,randomization:this.randomization,H0:this.H0,stealthAddress:this.stealthAddress,commitment:this.commitment,nullifier:this.nullifier,isBlocked:this.isBlocked,isNewStyle:this.isNewStyle}}getCommitment(){if(!this.commitment){let e=[this.amount,this.erc20TokenAddress,BigInt(this.getStealthAddress()),this.timeStamp];this.commitment=b(...e)}return this.commitment}getNullifier(){if(!this.nullifier){if(!this.nullifyingKey)throw Error(`No Nullifiers if private key is not provided`);let e=this.getCommitment(),t=b(this.nullifyingKey,e);this.nullifier=b(e,t)}return this.nullifier}getStealthAddress(){if(!this.stealthAddress){if(!this.nullifyingKey)throw Error(`No stealth address in UTXO if private key is not provided`);if(this.isNewStyle){if(!this.H0)throw Error(`No H0 point provided`);this.stealthAddress=j.getStealthAddressNewStyle(this.H0,this.nullifyingKey,this.spendingPublicKey)}else{if(!this.randomization)throw Error(`No randomization provided`);this.stealthAddress=j.getStealthAddress(this.randomization,this.nullifyingKey)}}return this.stealthAddress}getTokenAddress(t){let n=e.r(t)?this.mintAddress:this.erc20TokenAddress;if(!n)throw Error(`No token address provided`);return n}getEncryptionKey(){if(!this.nullifyingKey){if(!this.encryptionKey)throw Error(`No encryption key provided in UTXO`);return this.encryptionKey}return j.getEncryptionKeyPair(this.nullifyingKey).publicKey}},ne=(...t)=>{e.a&&console.log(...t)};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return O}});
@@ -1 +0,0 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../common/src/functions/utils/hinkalTiming.utils.cjs`),t=require(`./serialization.utils.cjs`);let n=require(`react-native`);var r=class{initPromise=null;ready=!1;init(){return this.ready?Promise.resolve():(this.initPromise||=new Promise((r,i)=>{let a=t.nextRequestId(),o=setTimeout(()=>{s.remove(),i(Error(`RN crypto engine init timed out`))},12e4),s=n.DeviceEventEmitter.addListener(`FROM_WEBVIEW_CRYPTO`,t=>{if(t?.type===`CRYPTO_READY`){clearTimeout(o),s.remove(),this.ready=!0,e.logRnDeltaEvent(`rnBridge.crypto`,`ready`,{requestId:a}),r();return}t?.requestId===a&&t?.type===`ERROR`&&(clearTimeout(o),s.remove(),i(Error(t.error??`RN crypto engine init failed`)))});e.logRnDeltaEvent(`rnBridge.crypto`,`init-sent`,{requestId:a}),n.DeviceEventEmitter.emit(`TO_WEBVIEW_CRYPTO`,{type:`INIT`,requestId:a})}),this.initPromise)}call(r,i){return new Promise((a,o)=>{let s=t.nextRequestId(),c=Date.now(),l=n.DeviceEventEmitter.addListener(`FROM_WEBVIEW_CRYPTO`,t=>{if(!(!t||t.requestId!==s)){if(l.remove(),t.type===`RESULT`){e.logRnDeltaEvent(`rnBridge.crypto`,r,{requestId:s,ms:Date.now()-c}),a(t.data);return}o(Error(t.error??`RN crypto call failed: ${r}`))}});n.DeviceEventEmitter.emit(`TO_WEBVIEW_CRYPTO`,{type:`CALL`,requestId:s,op:r,payload:i})})}};exports.RnWebViewCryptoBridge=r;
@@ -1,7 +0,0 @@
1
- import { IRnCryptoBridge } from '../../common/src/crypto/rnCryptoBridge';
2
- export declare class RnWebViewCryptoBridge implements IRnCryptoBridge {
3
- private initPromise;
4
- private ready;
5
- init(): Promise<void>;
6
- call<T>(op: string, payload?: unknown): Promise<T>;
7
- }
@@ -1,49 +0,0 @@
1
- import { logRnDeltaEvent as e } from "../../common/src/functions/utils/hinkalTiming.utils.mjs";
2
- import { nextRequestId as t } from "./serialization.utils.mjs";
3
- import { DeviceEventEmitter as n } from "react-native";
4
- //#region libs/shared/sdk/src/react-native/bridge/RnWebViewCryptoBridge.ts
5
- var r = class {
6
- initPromise = null;
7
- ready = !1;
8
- init() {
9
- return this.ready ? Promise.resolve() : (this.initPromise ||= new Promise((r, i) => {
10
- let a = t(), o = setTimeout(() => {
11
- s.remove(), i(/* @__PURE__ */ Error("RN crypto engine init timed out"));
12
- }, 12e4), s = n.addListener("FROM_WEBVIEW_CRYPTO", (t) => {
13
- if (t?.type === "CRYPTO_READY") {
14
- clearTimeout(o), s.remove(), this.ready = !0, e("rnBridge.crypto", "ready", { requestId: a }), r();
15
- return;
16
- }
17
- t?.requestId === a && t?.type === "ERROR" && (clearTimeout(o), s.remove(), i(Error(t.error ?? "RN crypto engine init failed")));
18
- });
19
- e("rnBridge.crypto", "init-sent", { requestId: a }), n.emit("TO_WEBVIEW_CRYPTO", {
20
- type: "INIT",
21
- requestId: a
22
- });
23
- }), this.initPromise);
24
- }
25
- call(r, i) {
26
- return new Promise((a, o) => {
27
- let s = t(), c = Date.now(), l = n.addListener("FROM_WEBVIEW_CRYPTO", (t) => {
28
- if (!(!t || t.requestId !== s)) {
29
- if (l.remove(), t.type === "RESULT") {
30
- e("rnBridge.crypto", r, {
31
- requestId: s,
32
- ms: Date.now() - c
33
- }), a(t.data);
34
- return;
35
- }
36
- o(Error(t.error ?? `RN crypto call failed: ${r}`));
37
- }
38
- });
39
- n.emit("TO_WEBVIEW_CRYPTO", {
40
- type: "CALL",
41
- requestId: s,
42
- op: r,
43
- payload: i
44
- });
45
- });
46
- }
47
- };
48
- //#endregion
49
- export { r as RnWebViewCryptoBridge };