@cloak.dev/sdk 0.2.12 → 0.2.14
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/CHANGELOG.md +57 -0
- package/README.md +43 -4
- package/dist/index.cjs +287 -68
- package/dist/index.d.cts +65 -12
- package/dist/index.d.ts +65 -12
- package/dist/index.js +294 -73
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -648,6 +648,7 @@ __export(index_exports, {
|
|
|
648
648
|
VARIABLE_FEE_NUMERATOR: () => VARIABLE_FEE_NUMERATOR,
|
|
649
649
|
VARIABLE_FEE_RATE: () => VARIABLE_FEE_RATE,
|
|
650
650
|
VERSION: () => VERSION,
|
|
651
|
+
WALLET_ADDED_PROGRAMS: () => WALLET_ADDED_PROGRAMS,
|
|
651
652
|
WITHDRAW_FEE_BPS: () => WITHDRAW_FEE_BPS,
|
|
652
653
|
WITHDRAW_FIXED_FEE: () => WITHDRAW_FIXED_FEE,
|
|
653
654
|
accountMeta: () => accountMeta,
|
|
@@ -924,6 +925,7 @@ __export(index_exports, {
|
|
|
924
925
|
verifyQuoteSignature: () => verifyQuoteSignature,
|
|
925
926
|
verifyUtxos: () => verifyUtxos,
|
|
926
927
|
waitForRoot: () => waitForRoot,
|
|
928
|
+
walletAuthTransactionMessageBinds: () => walletAuthTransactionMessageBinds,
|
|
927
929
|
withShieldRetries: () => withShieldRetries,
|
|
928
930
|
withTiming: () => withTiming,
|
|
929
931
|
withdrawFeeFor: () => withdrawFeeFor
|
|
@@ -1522,7 +1524,7 @@ function messageSignerFromCallback(address2, signMessage) {
|
|
|
1522
1524
|
}
|
|
1523
1525
|
|
|
1524
1526
|
// src/scanning/compliance-keys.ts
|
|
1525
|
-
var
|
|
1527
|
+
var import_tweetnacl3 = __toESM(require("tweetnacl"), 1);
|
|
1526
1528
|
var import_blake32 = require("@noble/hashes/blake3");
|
|
1527
1529
|
var import_sha22 = require("@noble/hashes/sha2");
|
|
1528
1530
|
init_inputs();
|
|
@@ -1795,6 +1797,8 @@ var import_sha2 = require("@noble/hashes/sha2");
|
|
|
1795
1797
|
var import_utils = require("@noble/hashes/utils");
|
|
1796
1798
|
var import_kit5 = require("@solana/kit");
|
|
1797
1799
|
var import_system2 = require("@solana-program/system");
|
|
1800
|
+
var import_tweetnacl2 = __toESM(require("tweetnacl"), 1);
|
|
1801
|
+
init_address();
|
|
1798
1802
|
|
|
1799
1803
|
// src/solana/transaction.ts
|
|
1800
1804
|
var import_kit4 = require("@solana/kit");
|
|
@@ -2242,6 +2246,61 @@ function buildAuthTransactionMessage(sender, digest) {
|
|
|
2242
2246
|
function serializeAuthTransactionMessage(sender, digest) {
|
|
2243
2247
|
return new Uint8Array(compileUnsigned(buildAuthTransactionMessage(sender, digest)).messageBytes);
|
|
2244
2248
|
}
|
|
2249
|
+
var MAX_AUTH_TX_MESSAGE_BYTES = 1232;
|
|
2250
|
+
var TRANSFER_ZERO_LAMPORTS = Uint8Array.from([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
2251
|
+
var SYSTEM_PROGRAM_ADDRESS2 = "11111111111111111111111111111111";
|
|
2252
|
+
function sameBytes(a, b) {
|
|
2253
|
+
return a.length === b.length && a.every((byte, i) => byte === b[i]);
|
|
2254
|
+
}
|
|
2255
|
+
function walletAuthTransactionMessageBinds(sender, payload, bytes) {
|
|
2256
|
+
if (bytes.length > MAX_AUTH_TX_MESSAGE_BYTES) return false;
|
|
2257
|
+
let compiled;
|
|
2258
|
+
try {
|
|
2259
|
+
compiled = (0, import_kit5.getCompiledTransactionMessageDecoder)().decode(bytes);
|
|
2260
|
+
if (compiled.version !== "legacy" && compiled.version !== 0) return false;
|
|
2261
|
+
if (!sameBytes(new Uint8Array((0, import_kit5.getCompiledTransactionMessageEncoder)().encode(compiled)), bytes)) return false;
|
|
2262
|
+
} catch {
|
|
2263
|
+
return false;
|
|
2264
|
+
}
|
|
2265
|
+
if (!sanitizes(compiled)) return false;
|
|
2266
|
+
const accounts = compiled.staticAccounts;
|
|
2267
|
+
if (compiled.header.numSignerAccounts !== 1 || accounts[0] !== sender) return false;
|
|
2268
|
+
const lifetimeToken = compiled.lifetimeToken;
|
|
2269
|
+
if (lifetimeToken !== (0, import_kit5.getBase58Decoder)().decode((0, import_sha2.sha256)(payload))) return false;
|
|
2270
|
+
let ours = false;
|
|
2271
|
+
for (const instruction of compiled.instructions) {
|
|
2272
|
+
const program = accounts[instruction.programAddressIndex];
|
|
2273
|
+
if (program === SYSTEM_PROGRAM_ADDRESS2 && instruction.accountIndices?.length === 2 && instruction.accountIndices[0] === 0 && instruction.accountIndices[1] === 0 && sameBytes(new Uint8Array(instruction.data ?? []), TRANSFER_ZERO_LAMPORTS)) {
|
|
2274
|
+
ours = true;
|
|
2275
|
+
} else if (!WALLET_ADDED_PROGRAMS.includes(program)) {
|
|
2276
|
+
return false;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
return ours;
|
|
2280
|
+
}
|
|
2281
|
+
var WALLET_ADDED_PROGRAMS = [
|
|
2282
|
+
"ComputeBudget111111111111111111111111111111",
|
|
2283
|
+
"L2TExMFKdjpN9kozasaurPirfHy9P8sbXoAN1qA3S95"
|
|
2284
|
+
];
|
|
2285
|
+
function sanitizes(compiled) {
|
|
2286
|
+
const { header, staticAccounts, instructions } = compiled;
|
|
2287
|
+
const lookups = compiled.addressTableLookups ?? [];
|
|
2288
|
+
if (header.numReadonlySignerAccounts >= header.numSignerAccounts) return false;
|
|
2289
|
+
if (header.numSignerAccounts + header.numReadonlyNonSignerAccounts > staticAccounts.length) return false;
|
|
2290
|
+
let total = staticAccounts.length;
|
|
2291
|
+
for (const lookup of lookups) {
|
|
2292
|
+
const loaded = lookup.writableIndexes.length + lookup.readonlyIndexes.length;
|
|
2293
|
+
if (loaded === 0) return false;
|
|
2294
|
+
total += loaded;
|
|
2295
|
+
}
|
|
2296
|
+
if (total > 256) return false;
|
|
2297
|
+
return instructions.every(
|
|
2298
|
+
(instruction) => (
|
|
2299
|
+
// Programs come from static keys only and are never the fee payer.
|
|
2300
|
+
instruction.programAddressIndex > 0 && instruction.programAddressIndex < staticAccounts.length && (instruction.accountIndices ?? []).every((index) => index < total)
|
|
2301
|
+
)
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2245
2304
|
async function signRelayAuthPayload(signer, payload) {
|
|
2246
2305
|
if (isMessageSigner(signer)) {
|
|
2247
2306
|
const signature = await signMessageBytes(signer, payload);
|
|
@@ -2265,7 +2324,21 @@ async function signRelayAuthPayload(signer, payload) {
|
|
|
2265
2324
|
}
|
|
2266
2325
|
const signature = new Uint8Array(own);
|
|
2267
2326
|
assertDetachedSignature(signature, "signTransaction");
|
|
2268
|
-
|
|
2327
|
+
const signedMessage = new Uint8Array(signed.messageBytes);
|
|
2328
|
+
if (!import_tweetnacl2.default.sign.detached.verify(signedMessage, signature, addressBytes(signer.address))) {
|
|
2329
|
+
throw new Error(
|
|
2330
|
+
"The wallet's signature does not match the Cloak auth transaction it returned. Nothing was submitted."
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2333
|
+
if (sameBytes(signedMessage, new Uint8Array(compileUnsigned(message).messageBytes))) {
|
|
2334
|
+
return { signature, mode: "transaction" };
|
|
2335
|
+
}
|
|
2336
|
+
if (!walletAuthTransactionMessageBinds(signer.address, payload, signedMessage)) {
|
|
2337
|
+
throw new Error(
|
|
2338
|
+
"The wallet changed the Cloak auth transaction into one that no longer authorizes this request (another fee payer or signer, another blockhash, or no 0 SOL self-transfer). Nothing was submitted."
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
return { signature, mode: "transaction", txMessage: signedMessage };
|
|
2269
2342
|
}
|
|
2270
2343
|
throw new Error("Relay auth signer can neither sign messages nor transactions.");
|
|
2271
2344
|
}
|
|
@@ -2327,14 +2400,15 @@ async function buildRelayAuthFields(endpoint, programId, body, signers, fields =
|
|
|
2327
2400
|
fields
|
|
2328
2401
|
);
|
|
2329
2402
|
const approvalStartedMs = Date.now();
|
|
2330
|
-
const { signature, mode } = await signRelayAuthPayload(wallet, preimage.message);
|
|
2403
|
+
const { signature, mode, txMessage } = await signRelayAuthPayload(wallet, preimage.message);
|
|
2331
2404
|
assertApprovalWithinFreshnessWindow(Date.now() - approvalStartedMs);
|
|
2332
2405
|
return {
|
|
2333
2406
|
sender: preimage.sender,
|
|
2334
2407
|
auth_issued_at: preimage.auth_issued_at,
|
|
2335
2408
|
auth_nonce: preimage.auth_nonce,
|
|
2336
2409
|
auth_signature: Buffer.from(signature).toString("base64"),
|
|
2337
|
-
...mode === "transaction" ? { auth_mode: mode } : {}
|
|
2410
|
+
...mode === "transaction" ? { auth_mode: mode } : {},
|
|
2411
|
+
...txMessage ? { auth_tx_message: Buffer.from(txMessage).toString("base64") } : {}
|
|
2338
2412
|
};
|
|
2339
2413
|
}
|
|
2340
2414
|
var REQUEST_AUTH_BATCH_DOMAIN = "CLOAK_RELAY_BATCH_AUTH_V1";
|
|
@@ -2385,7 +2459,7 @@ function deriveViewingKeyFromNk(nk) {
|
|
|
2385
2459
|
preimage.set(nk, CHAIN_NOTE_VK_DOMAIN.length);
|
|
2386
2460
|
const derived = (0, import_blake32.blake3)(preimage);
|
|
2387
2461
|
const privateKey = clampX25519Secret(derived);
|
|
2388
|
-
const publicKey =
|
|
2462
|
+
const publicKey = import_tweetnacl3.default.scalarMult.base(privateKey);
|
|
2389
2463
|
return { privateKey, publicKey };
|
|
2390
2464
|
}
|
|
2391
2465
|
function deriveDiversifier(nk, commitmentHex, outputIndex) {
|
|
@@ -2420,7 +2494,7 @@ function deriveDiversifiedViewingKey(nk, diversifier) {
|
|
|
2420
2494
|
preimage.set(diversifier, SK_D_DOMAIN.length + nk.length);
|
|
2421
2495
|
const derived = (0, import_blake32.blake3)(preimage);
|
|
2422
2496
|
const privateKey = clampX25519Secret(derived);
|
|
2423
|
-
const publicKey =
|
|
2497
|
+
const publicKey = import_tweetnacl3.default.scalarMult.base(privateKey);
|
|
2424
2498
|
return { privateKey, publicKey };
|
|
2425
2499
|
}
|
|
2426
2500
|
function deriveViewingKeyFromSpendKey(skSpend) {
|
|
@@ -2483,7 +2557,7 @@ async function deriveUserCompliancePublicKey(masterCompliancePublicKey, userPubl
|
|
|
2483
2557
|
masterCompliancePublicKey,
|
|
2484
2558
|
userPublicKey
|
|
2485
2559
|
);
|
|
2486
|
-
return
|
|
2560
|
+
return import_tweetnacl3.default.scalarMult(factor, masterCompliancePublicKey);
|
|
2487
2561
|
}
|
|
2488
2562
|
function bytesToHex3(bytes) {
|
|
2489
2563
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
@@ -2530,7 +2604,8 @@ async function registerViewingKey(relayUrl, userPubkey, nk, signMessage) {
|
|
|
2530
2604
|
nonce: challenge.nonce,
|
|
2531
2605
|
identifier: keyId,
|
|
2532
2606
|
signature,
|
|
2533
|
-
...signed.mode === "transaction" ? { auth_mode: signed.mode } : {}
|
|
2607
|
+
...signed.mode === "transaction" ? { auth_mode: signed.mode } : {},
|
|
2608
|
+
...signed.txMessage ? { tx_message: Buffer.from(signed.txMessage).toString("base64") } : {}
|
|
2534
2609
|
})
|
|
2535
2610
|
});
|
|
2536
2611
|
if (!response.ok) {
|
|
@@ -2539,7 +2614,7 @@ async function registerViewingKey(relayUrl, userPubkey, nk, signMessage) {
|
|
|
2539
2614
|
}
|
|
2540
2615
|
|
|
2541
2616
|
// src/scanning/metadata-encryption.ts
|
|
2542
|
-
var
|
|
2617
|
+
var import_tweetnacl4 = __toESM(require("tweetnacl"), 1);
|
|
2543
2618
|
init_inputs();
|
|
2544
2619
|
var AES_GCM_NONCE_LENGTH = 12;
|
|
2545
2620
|
var AES_GCM_TAG_LENGTH = 16;
|
|
@@ -2637,8 +2712,8 @@ async function aesGcmDecrypt(ciphertext, keyBytes, nonce) {
|
|
|
2637
2712
|
}
|
|
2638
2713
|
async function encryptForRecipient(plaintext, recipientPublicKey) {
|
|
2639
2714
|
assert32Bytes2(recipientPublicKey, "recipientPublicKey");
|
|
2640
|
-
const ephemeral =
|
|
2641
|
-
const sharedSecret =
|
|
2715
|
+
const ephemeral = import_tweetnacl4.default.box.keyPair();
|
|
2716
|
+
const sharedSecret = import_tweetnacl4.default.scalarMult(ephemeral.secretKey, recipientPublicKey);
|
|
2642
2717
|
const nonce = randomBytes(AES_GCM_NONCE_LENGTH);
|
|
2643
2718
|
const ciphertext = await aesGcmEncrypt(plaintext, sharedSecret, nonce);
|
|
2644
2719
|
return {
|
|
@@ -2697,7 +2772,7 @@ async function encryptTransactionMetadataBundle(metadata, viewingKeyPrivate, use
|
|
|
2697
2772
|
const plaintext = new TextEncoder().encode(JSON.stringify(metadata));
|
|
2698
2773
|
const basePoint = new Uint8Array(32);
|
|
2699
2774
|
basePoint[0] = 9;
|
|
2700
|
-
const viewingKeyPublic =
|
|
2775
|
+
const viewingKeyPublic = import_tweetnacl4.default.scalarMult(viewingKeyPrivate, basePoint);
|
|
2701
2776
|
const [userPayload, compliancePayload] = await Promise.all([
|
|
2702
2777
|
encryptForRecipient(plaintext, viewingKeyPublic),
|
|
2703
2778
|
encryptForRecipient(plaintext, viewingKeyPublic)
|
|
@@ -2716,7 +2791,7 @@ async function decryptTransactionMetadata(encrypted, viewKeySecret) {
|
|
|
2716
2791
|
const payload = decodePayload(encrypted);
|
|
2717
2792
|
const ephemeralPk = hexToBytes(payload.ephemeral_pk);
|
|
2718
2793
|
assert32Bytes2(ephemeralPk, "ephemeral public key");
|
|
2719
|
-
const sharedSecret =
|
|
2794
|
+
const sharedSecret = import_tweetnacl4.default.scalarMult(viewKeySecret, ephemeralPk);
|
|
2720
2795
|
return decryptWithSharedSecret(payload, sharedSecret);
|
|
2721
2796
|
}
|
|
2722
2797
|
async function decryptComplianceMetadataWithMasterKey(encrypted, masterCompliancePrivateKey, masterCompliancePublicKey, userPublicKey) {
|
|
@@ -2729,8 +2804,8 @@ async function decryptComplianceMetadataWithMasterKey(encrypted, masterComplianc
|
|
|
2729
2804
|
masterCompliancePublicKey,
|
|
2730
2805
|
userPublicKey
|
|
2731
2806
|
);
|
|
2732
|
-
const scaledEphemeral =
|
|
2733
|
-
const sharedSecret =
|
|
2807
|
+
const scaledEphemeral = import_tweetnacl4.default.scalarMult(userFactor, ephemeralPk);
|
|
2808
|
+
const sharedSecret = import_tweetnacl4.default.scalarMult(masterCompliancePrivateKey, scaledEphemeral);
|
|
2734
2809
|
return decryptWithSharedSecret(payload, sharedSecret);
|
|
2735
2810
|
}
|
|
2736
2811
|
|
|
@@ -4390,7 +4465,8 @@ var RelayService = class {
|
|
|
4390
4465
|
nonce: challenge.nonce,
|
|
4391
4466
|
identifier,
|
|
4392
4467
|
signature,
|
|
4393
|
-
...signed.mode === "transaction" ? { auth_mode: signed.mode } : {}
|
|
4468
|
+
...signed.mode === "transaction" ? { auth_mode: signed.mode } : {},
|
|
4469
|
+
...signed.txMessage ? { tx_message: this.bytesToBase64(signed.txMessage) } : {}
|
|
4394
4470
|
})
|
|
4395
4471
|
});
|
|
4396
4472
|
if (!response.ok) {
|
|
@@ -5807,7 +5883,7 @@ function chainNoteFromBase64(base64) {
|
|
|
5807
5883
|
}
|
|
5808
5884
|
|
|
5809
5885
|
// src/notes/delivery-note.ts
|
|
5810
|
-
var
|
|
5886
|
+
var import_tweetnacl5 = __toESM(require("tweetnacl"), 1);
|
|
5811
5887
|
var RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN = 32;
|
|
5812
5888
|
var RECIPIENT_DELIVERY_NONCE_LEN = 24;
|
|
5813
5889
|
var RECIPIENT_DELIVERY_PLAINTEXT_LEN = 40;
|
|
@@ -5858,10 +5934,10 @@ function encodeRecipientDeliveryNote(note, recipientViewingPublicKey) {
|
|
|
5858
5934
|
const plaintext = new Uint8Array(RECIPIENT_DELIVERY_PLAINTEXT_LEN);
|
|
5859
5935
|
writeU64LE2(plaintext, 0, note.amount);
|
|
5860
5936
|
writeU256BE2(plaintext, 8, note.blinding);
|
|
5861
|
-
const ephemeral =
|
|
5862
|
-
const shared =
|
|
5863
|
-
const nonce =
|
|
5864
|
-
const ciphertext =
|
|
5937
|
+
const ephemeral = import_tweetnacl5.default.box.keyPair();
|
|
5938
|
+
const shared = import_tweetnacl5.default.box.before(recipientViewingPublicKey, ephemeral.secretKey);
|
|
5939
|
+
const nonce = import_tweetnacl5.default.randomBytes(import_tweetnacl5.default.secretbox.nonceLength);
|
|
5940
|
+
const ciphertext = import_tweetnacl5.default.secretbox(plaintext, nonce, shared);
|
|
5865
5941
|
if (ciphertext.length !== RECIPIENT_DELIVERY_CIPHERTEXT_LEN) {
|
|
5866
5942
|
throw new Error(
|
|
5867
5943
|
`delivery ciphertext must be ${RECIPIENT_DELIVERY_CIPHERTEXT_LEN} bytes, got ${ciphertext.length}`
|
|
@@ -5887,8 +5963,8 @@ function openRecipientDeliveryNote(envelope, viewingSecretKey) {
|
|
|
5887
5963
|
const ciphertext = envelope.slice(
|
|
5888
5964
|
RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN + RECIPIENT_DELIVERY_NONCE_LEN
|
|
5889
5965
|
);
|
|
5890
|
-
const shared =
|
|
5891
|
-
const plaintext =
|
|
5966
|
+
const shared = import_tweetnacl5.default.box.before(ephemeralPk, viewingSecretKey);
|
|
5967
|
+
const plaintext = import_tweetnacl5.default.secretbox.open(ciphertext, nonce, shared);
|
|
5892
5968
|
if (!plaintext || plaintext.length !== RECIPIENT_DELIVERY_PLAINTEXT_LEN) return null;
|
|
5893
5969
|
return { amount: readU64LE2(plaintext, 0), blinding: readU256BE2(plaintext, 8) };
|
|
5894
5970
|
} catch {
|
|
@@ -5924,7 +6000,7 @@ async function createRecipientDeliveryOpener(viewingSecretKey) {
|
|
|
5924
6000
|
}
|
|
5925
6001
|
const slow = async (envelope) => openRecipientDeliveryNote(envelope, viewingSecretKey);
|
|
5926
6002
|
const subtle = globalThis.crypto?.subtle;
|
|
5927
|
-
const hsalsa =
|
|
6003
|
+
const hsalsa = import_tweetnacl5.default.lowlevel?.crypto_core_hsalsa20;
|
|
5928
6004
|
if (!subtle || typeof hsalsa !== "function") return slow;
|
|
5929
6005
|
let privateKey;
|
|
5930
6006
|
const sharedKey = async (ephemeralPk) => {
|
|
@@ -5941,9 +6017,9 @@ async function createRecipientDeliveryOpener(viewingSecretKey) {
|
|
|
5941
6017
|
pkcs8.set(X25519_PKCS8_PREFIX);
|
|
5942
6018
|
pkcs8.set(viewingSecretKey, X25519_PKCS8_PREFIX.length);
|
|
5943
6019
|
privateKey = await subtle.importKey("pkcs8", pkcs8, { name: "X25519" }, false, ["deriveBits"]);
|
|
5944
|
-
const probe =
|
|
6020
|
+
const probe = import_tweetnacl5.default.box.keyPair().publicKey;
|
|
5945
6021
|
const fast = await sharedKey(probe);
|
|
5946
|
-
const reference =
|
|
6022
|
+
const reference = import_tweetnacl5.default.box.before(probe, viewingSecretKey);
|
|
5947
6023
|
if (fast.length !== reference.length || fast.some((b, i) => b !== reference[i])) return slow;
|
|
5948
6024
|
} catch {
|
|
5949
6025
|
return slow;
|
|
@@ -5963,7 +6039,7 @@ async function createRecipientDeliveryOpener(viewingSecretKey) {
|
|
|
5963
6039
|
return openRecipientDeliveryNote(envelope, viewingSecretKey);
|
|
5964
6040
|
}
|
|
5965
6041
|
try {
|
|
5966
|
-
return decodeOpened(
|
|
6042
|
+
return decodeOpened(import_tweetnacl5.default.secretbox.open(ciphertext, nonce, key));
|
|
5967
6043
|
} catch {
|
|
5968
6044
|
return null;
|
|
5969
6045
|
}
|
|
@@ -6565,7 +6641,7 @@ async function matchChangeNote(params) {
|
|
|
6565
6641
|
|
|
6566
6642
|
// src/flows/transact.ts
|
|
6567
6643
|
var import_circomlibjs4 = require("circomlibjs");
|
|
6568
|
-
var
|
|
6644
|
+
var import_tweetnacl6 = __toESM(require("tweetnacl"), 1);
|
|
6569
6645
|
|
|
6570
6646
|
// src/relay/chain-note-time.ts
|
|
6571
6647
|
async function relayChainNoteTimestampMs(relayUrl) {
|
|
@@ -6669,13 +6745,75 @@ async function circuitArtifactFetch(url, init) {
|
|
|
6669
6745
|
var IS_REACT_NATIVE = isReactNative();
|
|
6670
6746
|
var IS_BROWSER = IS_REACT_NATIVE || typeof window !== "undefined" || typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
|
|
6671
6747
|
var DEFAULT_CIRCUITS_URL = TRANSACTION_CIRCUITS_BASE_URL;
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6748
|
+
var ARTIFACT_DOWNLOAD_IDLE_TIMEOUT_MS = 2e4;
|
|
6749
|
+
var ARTIFACT_DOWNLOAD_ATTEMPTS = 3;
|
|
6750
|
+
var ARTIFACT_DOWNLOAD_BACKOFF_MS = 1e3;
|
|
6751
|
+
var RETRYABLE_ARTIFACT_STATUSES = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
6752
|
+
async function fetchFileAsBuffer(url, onBytes) {
|
|
6753
|
+
let lastError;
|
|
6754
|
+
for (let attempt = 1; attempt <= ARTIFACT_DOWNLOAD_ATTEMPTS; attempt++) {
|
|
6755
|
+
try {
|
|
6756
|
+
return await fetchFileAttempt(url, onBytes);
|
|
6757
|
+
} catch (err) {
|
|
6758
|
+
lastError = err;
|
|
6759
|
+
if (err.retryable === false) throw err;
|
|
6760
|
+
if (attempt < ARTIFACT_DOWNLOAD_ATTEMPTS) {
|
|
6761
|
+
await new Promise((resolve) => setTimeout(resolve, ARTIFACT_DOWNLOAD_BACKOFF_MS * attempt));
|
|
6762
|
+
}
|
|
6763
|
+
}
|
|
6764
|
+
}
|
|
6765
|
+
throw new Error(
|
|
6766
|
+
`Failed to download ${url} after ${ARTIFACT_DOWNLOAD_ATTEMPTS} attempts: ` + String(lastError?.message ?? lastError)
|
|
6767
|
+
);
|
|
6768
|
+
}
|
|
6769
|
+
async function fetchFileAttempt(url, onBytes) {
|
|
6770
|
+
const controller = new AbortController();
|
|
6771
|
+
let idleTimer;
|
|
6772
|
+
const armIdle = () => {
|
|
6773
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
6774
|
+
idleTimer = setTimeout(() => controller.abort(), ARTIFACT_DOWNLOAD_IDLE_TIMEOUT_MS);
|
|
6775
|
+
};
|
|
6776
|
+
armIdle();
|
|
6777
|
+
try {
|
|
6778
|
+
const response = await circuitArtifactFetch(url, { signal: controller.signal });
|
|
6779
|
+
if (!response.ok) {
|
|
6780
|
+
const error = new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
6781
|
+
error.retryable = RETRYABLE_ARTIFACT_STATUSES.has(response.status);
|
|
6782
|
+
throw error;
|
|
6783
|
+
}
|
|
6784
|
+
const lengthHeader = Number(response.headers?.get?.("content-length"));
|
|
6785
|
+
const total = Number.isFinite(lengthHeader) && lengthHeader > 0 ? lengthHeader : null;
|
|
6786
|
+
const reader = response.body?.getReader?.();
|
|
6787
|
+
if (!reader) {
|
|
6788
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
6789
|
+
onBytes?.(arrayBuffer.byteLength, total);
|
|
6790
|
+
return new CapturedUint8Array(arrayBuffer);
|
|
6791
|
+
}
|
|
6792
|
+
const chunks = [];
|
|
6793
|
+
let received = 0;
|
|
6794
|
+
for (; ; ) {
|
|
6795
|
+
const { done, value } = await reader.read();
|
|
6796
|
+
if (done) break;
|
|
6797
|
+
armIdle();
|
|
6798
|
+
chunks.push(value);
|
|
6799
|
+
received += value.byteLength;
|
|
6800
|
+
onBytes?.(received, total);
|
|
6801
|
+
}
|
|
6802
|
+
const out = new CapturedUint8Array(received);
|
|
6803
|
+
let offset = 0;
|
|
6804
|
+
for (const chunk of chunks) {
|
|
6805
|
+
out.set(chunk, offset);
|
|
6806
|
+
offset += chunk.byteLength;
|
|
6807
|
+
}
|
|
6808
|
+
return out;
|
|
6809
|
+
} catch (err) {
|
|
6810
|
+
if (controller.signal.aborted) {
|
|
6811
|
+
throw new Error(`Download of ${url} stalled: no data for ${ARTIFACT_DOWNLOAD_IDLE_TIMEOUT_MS / 1e3}s`);
|
|
6812
|
+
}
|
|
6813
|
+
throw err;
|
|
6814
|
+
} finally {
|
|
6815
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
6676
6816
|
}
|
|
6677
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
6678
|
-
return new CapturedUint8Array(arrayBuffer);
|
|
6679
6817
|
}
|
|
6680
6818
|
var CapturedUint8Array = Uint8Array;
|
|
6681
6819
|
var capturedTypedArraySet = Uint8Array.prototype.set;
|
|
@@ -6725,9 +6863,9 @@ async function getNodeFs() {
|
|
|
6725
6863
|
_nodeFs = await loadNodeModule("fs");
|
|
6726
6864
|
return _nodeFs;
|
|
6727
6865
|
}
|
|
6728
|
-
async function loadCircuitArtifact(path) {
|
|
6866
|
+
async function loadCircuitArtifact(path, onBytes) {
|
|
6729
6867
|
if (isCircuitArtifactUrl(path)) {
|
|
6730
|
-
return fetchFileAsBuffer(path);
|
|
6868
|
+
return fetchFileAsBuffer(path, onBytes);
|
|
6731
6869
|
}
|
|
6732
6870
|
if (IS_BROWSER) {
|
|
6733
6871
|
throw new Error(
|
|
@@ -6768,10 +6906,24 @@ function resolveVerificationBase(circuitsPath2) {
|
|
|
6768
6906
|
return assertAllowedCircuitsBase(circuitsPath2);
|
|
6769
6907
|
}
|
|
6770
6908
|
var _verifiedArtifacts = /* @__PURE__ */ new Map();
|
|
6771
|
-
async function loadArtifactPair(base) {
|
|
6909
|
+
async function loadArtifactPair(base, onDownload) {
|
|
6910
|
+
const progress = { wasm: 0, zkey: 0, wasmTotal: null, zkeyTotal: null };
|
|
6911
|
+
const report = () => {
|
|
6912
|
+
if (!onDownload) return;
|
|
6913
|
+
const total = progress.wasmTotal !== null && progress.zkeyTotal !== null ? progress.wasmTotal + progress.zkeyTotal : null;
|
|
6914
|
+
onDownload(progress.wasm + progress.zkey, total);
|
|
6915
|
+
};
|
|
6772
6916
|
const [wasm, zkey] = await Promise.all([
|
|
6773
|
-
loadCircuitArtifact(`${base}/transaction_js/transaction.wasm
|
|
6774
|
-
|
|
6917
|
+
loadCircuitArtifact(`${base}/transaction_js/transaction.wasm`, (r, t) => {
|
|
6918
|
+
progress.wasm = r;
|
|
6919
|
+
progress.wasmTotal = t;
|
|
6920
|
+
report();
|
|
6921
|
+
}),
|
|
6922
|
+
loadCircuitArtifact(`${base}/transaction_final.zkey`, (r, t) => {
|
|
6923
|
+
progress.zkey = r;
|
|
6924
|
+
progress.zkeyTotal = t;
|
|
6925
|
+
report();
|
|
6926
|
+
})
|
|
6775
6927
|
]);
|
|
6776
6928
|
return { wasm, zkey };
|
|
6777
6929
|
}
|
|
@@ -6791,11 +6943,11 @@ function copyAndVerify(base, canonical) {
|
|
|
6791
6943
|
}
|
|
6792
6944
|
return Object.freeze({ wasm, zkey, digests: Object.freeze(digests) });
|
|
6793
6945
|
}
|
|
6794
|
-
async function loadVerifiedCircuitArtifacts(circuitsPath2) {
|
|
6946
|
+
async function loadVerifiedCircuitArtifacts(circuitsPath2, onDownload) {
|
|
6795
6947
|
const base = resolveVerificationBase(circuitsPath2);
|
|
6796
6948
|
const cached = _verifiedArtifacts.get(base);
|
|
6797
6949
|
if (cached) return copyAndVerify(base, cached);
|
|
6798
|
-
const loaded = await loadArtifactPair(base);
|
|
6950
|
+
const loaded = await loadArtifactPair(base, onDownload);
|
|
6799
6951
|
const artifacts = copyAndVerify(base, loaded);
|
|
6800
6952
|
_verifiedArtifacts.set(base, loaded);
|
|
6801
6953
|
return artifacts;
|
|
@@ -6851,8 +7003,8 @@ function canRebuildMerkleTreeFromChain() {
|
|
|
6851
7003
|
}
|
|
6852
7004
|
var DEFAULT_TRANSACTION_CIRCUITS_URL = TRANSACTION_CIRCUITS_BASE_URL;
|
|
6853
7005
|
var circuitsPath = DEFAULT_TRANSACTION_CIRCUITS_URL;
|
|
6854
|
-
async function resolveTransactionCircuitFiles() {
|
|
6855
|
-
const { wasm, zkey } = await loadVerifiedCircuitArtifacts(circuitsPath);
|
|
7006
|
+
async function resolveTransactionCircuitFiles(onDownload) {
|
|
7007
|
+
const { wasm, zkey } = await loadVerifiedCircuitArtifacts(circuitsPath, onDownload);
|
|
6856
7008
|
return { wasmPath: wasm, zkeyPath: zkey };
|
|
6857
7009
|
}
|
|
6858
7010
|
var _transactPaddingSaltCounter = 0;
|
|
@@ -7362,6 +7514,7 @@ async function registerViewingKeyOnce(relayUrl, userPubkey, viewingKeyHex, cache
|
|
|
7362
7514
|
);
|
|
7363
7515
|
let signatureBase64;
|
|
7364
7516
|
let authMode = "message";
|
|
7517
|
+
let txMessageBase64;
|
|
7365
7518
|
const messageBytes = new TextEncoder().encode(challenge.message);
|
|
7366
7519
|
if (options.signMessage) {
|
|
7367
7520
|
const sig = await options.signMessage(messageBytes);
|
|
@@ -7379,6 +7532,7 @@ async function registerViewingKeyOnce(relayUrl, userPubkey, viewingKeyHex, cache
|
|
|
7379
7532
|
const signed = await signRelayAuthPayload(options.signer, messageBytes);
|
|
7380
7533
|
signatureBase64 = Buffer.from(signed.signature).toString("base64");
|
|
7381
7534
|
authMode = signed.mode;
|
|
7535
|
+
if (signed.txMessage) txMessageBase64 = Buffer.from(signed.txMessage).toString("base64");
|
|
7382
7536
|
} else {
|
|
7383
7537
|
throw new Error(
|
|
7384
7538
|
"Viewing key registration is mandatory: signMessage or signer (wallet) or depositorKeypair is required."
|
|
@@ -7393,7 +7547,8 @@ async function registerViewingKeyOnce(relayUrl, userPubkey, viewingKeyHex, cache
|
|
|
7393
7547
|
viewing_key: viewingKeyHex,
|
|
7394
7548
|
nonce: challenge.nonce,
|
|
7395
7549
|
signature: signatureBase64,
|
|
7396
|
-
...authMode === "transaction" ? { auth_mode: authMode } : {}
|
|
7550
|
+
...authMode === "transaction" ? { auth_mode: authMode } : {},
|
|
7551
|
+
...txMessageBase64 ? { tx_message: txMessageBase64 } : {}
|
|
7397
7552
|
})
|
|
7398
7553
|
});
|
|
7399
7554
|
if (!response.ok) {
|
|
@@ -7402,27 +7557,52 @@ async function registerViewingKeyOnce(relayUrl, userPubkey, viewingKeyHex, cache
|
|
|
7402
7557
|
}
|
|
7403
7558
|
_registeredViewingKeys.add(cacheKey);
|
|
7404
7559
|
}
|
|
7405
|
-
async function generateTransactionProof(inputs, onProgress) {
|
|
7560
|
+
async function generateTransactionProof(inputs, onProgress, onStatus) {
|
|
7406
7561
|
onProgress?.(10);
|
|
7407
7562
|
onProgress?.(30);
|
|
7408
|
-
|
|
7563
|
+
let lastReportedMb = -1;
|
|
7564
|
+
const { wasmPath: wasmInput, zkeyPath: zkeyInput } = await resolveTransactionCircuitFiles(
|
|
7565
|
+
onStatus ? (received, total) => {
|
|
7566
|
+
const mb = Math.floor(received / 1e6);
|
|
7567
|
+
if (mb === lastReportedMb) return;
|
|
7568
|
+
lastReportedMb = mb;
|
|
7569
|
+
onStatus(
|
|
7570
|
+
total ? `Downloading circuit files (${mb} of ${Math.ceil(total / 1e6)} MB)...` : `Downloading circuit files (${mb} MB)...`
|
|
7571
|
+
);
|
|
7572
|
+
} : void 0
|
|
7573
|
+
);
|
|
7574
|
+
if (lastReportedMb >= 0) onStatus?.("Generating zero-knowledge proof...");
|
|
7575
|
+
const threaded = (run) => withProveWatchdog(run(), PROVE_WATCHDOG_MS);
|
|
7576
|
+
const singleThread = async () => {
|
|
7577
|
+
await terminateThreadedCurve();
|
|
7578
|
+
return snarkjs.groth16.fullProve(inputs, wasmInput, zkeyInput, void 0, void 0, {
|
|
7579
|
+
singleThread: true
|
|
7580
|
+
});
|
|
7581
|
+
};
|
|
7582
|
+
const workers = await defaultProverWorkers();
|
|
7409
7583
|
let result;
|
|
7410
7584
|
try {
|
|
7411
|
-
result = await
|
|
7585
|
+
result = await threaded(
|
|
7586
|
+
() => withReportedCores(workers, () => snarkjs.groth16.fullProve(inputs, wasmInput, zkeyInput))
|
|
7587
|
+
);
|
|
7412
7588
|
} catch (err) {
|
|
7413
|
-
if (
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
() => snarkjs.groth16.fullProve(inputs, wasmInput, zkeyInput)
|
|
7419
|
-
);
|
|
7420
|
-
} catch (retryErr) {
|
|
7421
|
-
if (!isProverOutOfMemory(retryErr)) throw retryErr;
|
|
7589
|
+
if (err instanceof ProveWatchdogTimeout) {
|
|
7590
|
+
onStatus?.("Proof is taking longer than expected, retrying on a single thread...");
|
|
7591
|
+
result = await singleThread();
|
|
7592
|
+
} else {
|
|
7593
|
+
if (!isProverOutOfMemory(err)) throw err;
|
|
7422
7594
|
await terminateThreadedCurve();
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7595
|
+
try {
|
|
7596
|
+
result = await threaded(
|
|
7597
|
+
() => withReportedCores(
|
|
7598
|
+
REDUCED_PROVER_WORKERS,
|
|
7599
|
+
() => snarkjs.groth16.fullProve(inputs, wasmInput, zkeyInput)
|
|
7600
|
+
)
|
|
7601
|
+
);
|
|
7602
|
+
} catch (retryErr) {
|
|
7603
|
+
if (!isProverOutOfMemory(retryErr) && !(retryErr instanceof ProveWatchdogTimeout)) throw retryErr;
|
|
7604
|
+
result = await singleThread();
|
|
7605
|
+
}
|
|
7426
7606
|
}
|
|
7427
7607
|
}
|
|
7428
7608
|
onProgress?.(100);
|
|
@@ -7436,6 +7616,40 @@ function isProverOutOfMemory(err) {
|
|
|
7436
7616
|
return name === "RangeError" && /(allocat|array buffer|memory)/i.test(message);
|
|
7437
7617
|
}
|
|
7438
7618
|
var REDUCED_PROVER_WORKERS = 4;
|
|
7619
|
+
var MAX_PROVER_WORKERS = 8;
|
|
7620
|
+
var MAX_PROVER_WORKERS_32BIT = 2;
|
|
7621
|
+
async function is32BitBrowser() {
|
|
7622
|
+
const nav = globalThis.navigator;
|
|
7623
|
+
if (!nav) return false;
|
|
7624
|
+
try {
|
|
7625
|
+
const hints = await nav.userAgentData?.getHighEntropyValues?.(["bitness", "wow64"]);
|
|
7626
|
+
if (hints) return hints.bitness === "32" || hints.wow64 === true;
|
|
7627
|
+
} catch {
|
|
7628
|
+
}
|
|
7629
|
+
return /\bWOW64\b/.test(nav.userAgent ?? "");
|
|
7630
|
+
}
|
|
7631
|
+
async function defaultProverWorkers() {
|
|
7632
|
+
return await is32BitBrowser() ? MAX_PROVER_WORKERS_32BIT : MAX_PROVER_WORKERS;
|
|
7633
|
+
}
|
|
7634
|
+
var PROVE_WATCHDOG_MS = 6e4;
|
|
7635
|
+
var ProveWatchdogTimeout = class extends Error {
|
|
7636
|
+
constructor(ms) {
|
|
7637
|
+
super(`Threaded proof did not finish within ${Math.round(ms / 1e3)}s`);
|
|
7638
|
+
this.name = "ProveWatchdogTimeout";
|
|
7639
|
+
}
|
|
7640
|
+
};
|
|
7641
|
+
function withProveWatchdog(work, ms) {
|
|
7642
|
+
work.catch(() => {
|
|
7643
|
+
});
|
|
7644
|
+
let timer;
|
|
7645
|
+
const timeout = new Promise((_, reject) => {
|
|
7646
|
+
timer = setTimeout(() => reject(new ProveWatchdogTimeout(ms)), ms);
|
|
7647
|
+
timer.unref?.();
|
|
7648
|
+
});
|
|
7649
|
+
return Promise.race([work, timeout]).finally(() => {
|
|
7650
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
7651
|
+
});
|
|
7652
|
+
}
|
|
7439
7653
|
async function withReportedCores(cores, fn) {
|
|
7440
7654
|
const nav = globalThis.navigator;
|
|
7441
7655
|
const reported = nav?.hardwareConcurrency;
|
|
@@ -8599,7 +8813,7 @@ async function fetchRiskQuote(riskQuoteUrl, wallet, options) {
|
|
|
8599
8813
|
`Invalid risk quote response: invalid lengths (sig=${signatureBuf.length}, msg=${messageArr.length}, pk=${publicKeyBytes.length}; expected msg 33/41/50/82/146)`
|
|
8600
8814
|
);
|
|
8601
8815
|
}
|
|
8602
|
-
if (!
|
|
8816
|
+
if (!import_tweetnacl6.default.sign.detached.verify(messageArr, new Uint8Array(signatureBuf), publicKeyBytes)) {
|
|
8603
8817
|
throw new Error(
|
|
8604
8818
|
"Invalid risk quote response: signature does not verify under signer_pubkey"
|
|
8605
8819
|
);
|
|
@@ -9549,7 +9763,7 @@ async function transact(params, rawOptions) {
|
|
|
9549
9763
|
let publicSignals;
|
|
9550
9764
|
const releaseProofSlot = options.relayAuthBatch ? await options.relayAuthBatch.proofSlot() : void 0;
|
|
9551
9765
|
try {
|
|
9552
|
-
const result = await generateTransactionProof(circuitInputs, onProofProgress);
|
|
9766
|
+
const result = await generateTransactionProof(circuitInputs, onProofProgress, onProgress);
|
|
9553
9767
|
proof = result.proof;
|
|
9554
9768
|
publicSignals = result.publicSignals;
|
|
9555
9769
|
releaseProofSlot?.();
|
|
@@ -10851,7 +11065,7 @@ async function swapUtxo(params, rawOptions) {
|
|
|
10851
11065
|
let proof;
|
|
10852
11066
|
let publicSignals;
|
|
10853
11067
|
try {
|
|
10854
|
-
const result = await generateTransactionProof(circuitInputs, onProofProgress);
|
|
11068
|
+
const result = await generateTransactionProof(circuitInputs, onProofProgress, onProgress);
|
|
10855
11069
|
proof = result.proof;
|
|
10856
11070
|
publicSignals = result.publicSignals;
|
|
10857
11071
|
} catch (proofError) {
|
|
@@ -11529,7 +11743,7 @@ var RelayBatchAuthCoordinator = class {
|
|
|
11529
11743
|
);
|
|
11530
11744
|
}
|
|
11531
11745
|
const approvalStartedMs = Date.now();
|
|
11532
|
-
const { signature, mode } = await signRelayAuthPayload(this.signer, message);
|
|
11746
|
+
const { signature, mode, txMessage } = await signRelayAuthPayload(this.signer, message);
|
|
11533
11747
|
if (!(0, import_kit9.isKeyPairSigner)(this.signer)) {
|
|
11534
11748
|
assertApprovalWithinFreshnessWindow(
|
|
11535
11749
|
Date.now() - approvalStartedMs,
|
|
@@ -11547,6 +11761,9 @@ var RelayBatchAuthCoordinator = class {
|
|
|
11547
11761
|
auth_nonce: preimage.auth_nonce,
|
|
11548
11762
|
auth_signature: signatureB64,
|
|
11549
11763
|
...mode === "transaction" ? { auth_mode: mode } : {},
|
|
11764
|
+
// The wallet's own message when it changed the envelope; one approval, so the same
|
|
11765
|
+
// message for every item, exactly like the signature.
|
|
11766
|
+
...txMessage ? { auth_tx_message: Buffer.from(txMessage).toString("base64") } : {},
|
|
11550
11767
|
// A fresh array per item: `Object.assign` puts this on the wire body, and the body is
|
|
11551
11768
|
// serialized again on every network retry.
|
|
11552
11769
|
auth_batch: { digests: [...digests] }
|
|
@@ -13390,7 +13607,7 @@ async function fetchNoteIndexPage(relayUrl, epoch, page, options = {}) {
|
|
|
13390
13607
|
|
|
13391
13608
|
// src/notes/request-keys.ts
|
|
13392
13609
|
var import_blake37 = require("@noble/hashes/blake3");
|
|
13393
|
-
var
|
|
13610
|
+
var import_tweetnacl7 = __toESM(require("tweetnacl"), 1);
|
|
13394
13611
|
init_utxo();
|
|
13395
13612
|
var BN254_ORDER = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
13396
13613
|
var ROOT_SEED_DOMAIN = new TextEncoder().encode("cloak_request_root_v1");
|
|
@@ -13441,7 +13658,7 @@ async function deriveRequestKeys(root, counter) {
|
|
|
13441
13658
|
return {
|
|
13442
13659
|
counter,
|
|
13443
13660
|
utxoKeypair: { privateKey, publicKey },
|
|
13444
|
-
viewingKeypair: { privateKey: vk, publicKey:
|
|
13661
|
+
viewingKeypair: { privateKey: vk, publicKey: import_tweetnacl7.default.scalarMult.base(vk) }
|
|
13445
13662
|
};
|
|
13446
13663
|
}
|
|
13447
13664
|
async function deriveRequestKeyRange(root, from, count) {
|
|
@@ -14947,7 +15164,7 @@ async function loadWeb3() {
|
|
|
14947
15164
|
}
|
|
14948
15165
|
|
|
14949
15166
|
// src/bridge/rail-verify.ts
|
|
14950
|
-
var
|
|
15167
|
+
var import_tweetnacl8 = __toESM(require("tweetnacl"), 1);
|
|
14951
15168
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
14952
15169
|
var ONECLICK_PUBKEY_B58 = "reYaWhvwu8Jzo3WUM3zhn6VrhuMEF4eADL17qtRVifc";
|
|
14953
15170
|
var b58 = /* @__PURE__ */ (() => {
|
|
@@ -15058,7 +15275,7 @@ function verifyQuoteSignature(resp) {
|
|
|
15058
15275
|
const message = new TextEncoder().encode(b58.encode(new Uint8Array(digest)));
|
|
15059
15276
|
const sig = resp.signature.replace(/^ed25519:/, "");
|
|
15060
15277
|
try {
|
|
15061
|
-
return { valid:
|
|
15278
|
+
return { valid: import_tweetnacl8.default.sign.detached.verify(message, b58.decode(sig), b58.decode(ONECLICK_PUBKEY_B58)) };
|
|
15062
15279
|
} catch (e) {
|
|
15063
15280
|
return { valid: false, reason: e instanceof Error ? e.message : String(e) };
|
|
15064
15281
|
}
|
|
@@ -15819,7 +16036,7 @@ async function withShieldRetries(attempt, hooks = {}) {
|
|
|
15819
16036
|
}
|
|
15820
16037
|
|
|
15821
16038
|
// src/index.ts
|
|
15822
|
-
var VERSION = "0.2.
|
|
16039
|
+
var VERSION = "0.2.14";
|
|
15823
16040
|
var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
15824
16041
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15825
16042
|
0 && (module.exports = {
|
|
@@ -15896,6 +16113,7 @@ var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
|
15896
16113
|
VARIABLE_FEE_NUMERATOR,
|
|
15897
16114
|
VARIABLE_FEE_RATE,
|
|
15898
16115
|
VERSION,
|
|
16116
|
+
WALLET_ADDED_PROGRAMS,
|
|
15899
16117
|
WITHDRAW_FEE_BPS,
|
|
15900
16118
|
WITHDRAW_FIXED_FEE,
|
|
15901
16119
|
accountMeta,
|
|
@@ -16172,6 +16390,7 @@ var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
|
16172
16390
|
verifyQuoteSignature,
|
|
16173
16391
|
verifyUtxos,
|
|
16174
16392
|
waitForRoot,
|
|
16393
|
+
walletAuthTransactionMessageBinds,
|
|
16175
16394
|
withShieldRetries,
|
|
16176
16395
|
withTiming,
|
|
16177
16396
|
withdrawFeeFor
|