@cloak.dev/sdk 0.2.6 → 0.2.8

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/dist/index.js CHANGED
@@ -4643,6 +4643,19 @@ async function preflightCheck(relayUrl, rootHex) {
4643
4643
  };
4644
4644
  }
4645
4645
 
4646
+ // src/relay/affiliate.ts
4647
+ var AFFILIATE_CODE_PATTERN = /^[a-z0-9_]{3,24}$/;
4648
+ var RELAY_CLIENT_HEADER_NAME = "X-Cloak-Client";
4649
+ var RELAY_CLIENT_HEADER_PATTERN = /^cloak-mobile\/(ios|android)\/\d+\.\d+\.\d+$/;
4650
+ function normalizeAffiliateCode(raw) {
4651
+ if (typeof raw !== "string") return null;
4652
+ const code = raw.trim().toLowerCase();
4653
+ return AFFILIATE_CODE_PATTERN.test(code) ? code : null;
4654
+ }
4655
+ function isValidRelayClientId(value) {
4656
+ return typeof value === "string" && RELAY_CLIENT_HEADER_PATTERN.test(value);
4657
+ }
4658
+
4646
4659
  // src/flows/transact.ts
4647
4660
  import { createNoopSigner as createNoopSigner2, isKeyPairSigner, isSignerRole } from "@solana/kit";
4648
4661
  import {
@@ -6301,7 +6314,41 @@ function assertInputMints(inputUtxos, expectedMint) {
6301
6314
  }
6302
6315
  }
6303
6316
  function affiliateCodeOrUndefined(code) {
6304
- return typeof code === "string" && code.length > 0 ? code : void 0;
6317
+ return normalizeAffiliateCode(code) ?? void 0;
6318
+ }
6319
+ function prepareAffiliateAndClient(options) {
6320
+ let next = options;
6321
+ const raw = options.affiliateCode;
6322
+ if (raw !== void 0 && raw !== null) {
6323
+ const normalized = normalizeAffiliateCode(raw);
6324
+ if (normalized === null) {
6325
+ if (typeof raw === "string" && raw.trim() !== "") {
6326
+ options.onWarning?.(
6327
+ `affiliateCode ${JSON.stringify(raw)} is not a valid partner code (3-24 characters of a-z, 0-9 or _, after trimming and lower-casing); it was left out of the request.`
6328
+ );
6329
+ }
6330
+ next = { ...next, affiliateCode: void 0 };
6331
+ } else if (normalized !== raw) {
6332
+ next = { ...next, affiliateCode: normalized };
6333
+ }
6334
+ }
6335
+ const clientId = options.relayClientId;
6336
+ if (clientId !== void 0 && clientId !== null && !isValidRelayClientId(clientId)) {
6337
+ if (typeof clientId !== "string" || clientId.trim() !== "") {
6338
+ options.onWarning?.(
6339
+ `relayClientId ${JSON.stringify(clientId)} does not match cloak-mobile/(ios|android)/MAJOR.MINOR.PATCH; no X-Cloak-Client header was sent.`
6340
+ );
6341
+ }
6342
+ next = { ...next, relayClientId: void 0 };
6343
+ } else if (isValidRelayClientId(clientId)) {
6344
+ const headers = {};
6345
+ for (const [name, value] of Object.entries(options.relayHeaders ?? {})) {
6346
+ if (name.toLowerCase() !== RELAY_CLIENT_HEADER_NAME.toLowerCase()) headers[name] = value;
6347
+ }
6348
+ headers[RELAY_CLIENT_HEADER_NAME] = clientId;
6349
+ next = { ...next, relayHeaders: headers };
6350
+ }
6351
+ return next;
6305
6352
  }
6306
6353
  function parseNkInput(input) {
6307
6354
  if (typeof input !== "string") {
@@ -7956,7 +8003,8 @@ async function submitTransactToRelay(args) {
7956
8003
  new Error(`Relay submission exhausted ${maxNetworkRetries + 1} attempts without an outcome`)
7957
8004
  );
7958
8005
  }
7959
- async function transact(params, options) {
8006
+ async function transact(params, rawOptions) {
8007
+ const options = prepareAffiliateAndClient(rawOptions);
7960
8008
  const {
7961
8009
  connection,
7962
8010
  programId,
@@ -9077,7 +9125,8 @@ async function transact(params, options) {
9077
9125
  addressLookupTableAccounts: resultAddressLookupTableAccounts
9078
9126
  };
9079
9127
  }
9080
- async function transfer(inputUtxos, recipientPubkey, amount, options) {
9128
+ async function transfer(inputUtxos, recipientPubkey, amount, rawOptions) {
9129
+ const options = prepareAffiliateAndClient(rawOptions);
9081
9130
  const owner = await requireOwnerUtxoKeypair(options, "transfer");
9082
9131
  const transferNk = await requireWalletNk(options, "transfer");
9083
9132
  const inputSum = sumUtxoAmounts(inputUtxos);
@@ -9103,20 +9152,10 @@ async function transfer(inputUtxos, recipientPubkey, amount, options) {
9103
9152
  );
9104
9153
  }
9105
9154
  options.onProgress?.("Moving notes under the wallet key before the transfer...");
9106
- const migrationSalt = randomChangeNoteSalt();
9107
- const migrated = (await createRecoverableChangeUtxo(inputSum, owner, transferNk, mint, migrationSalt, 0)).utxo;
9108
- const { recipientViewingPublicKey: _recipientViewingPublicKey, ...migrationOptions } = options;
9109
- void _recipientViewingPublicKey;
9110
- const migration = await transact(
9111
- { inputUtxos: spendInputs, outputUtxos: [migrated], externalAmount: BigInt(0) },
9112
- { ...migrationOptions, chainNoteSalt: migrationSalt }
9113
- );
9114
- const migratedNote = migration.outputUtxos?.[0] ?? migrated;
9115
- if (migration.commitmentIndices?.[0] >= 0) {
9116
- migratedNote.index = migration.commitmentIndices[0];
9117
- }
9155
+ const migration = await sweepToWalletKey(spendInputs, options);
9156
+ const migratedNote = migration.note;
9118
9157
  spendInputs = [migratedNote];
9119
- spendOptions = { ...options, cachedMerkleTree: migration.merkleTree };
9158
+ spendOptions = { ...options, cachedMerkleTree: migration.result.merkleTree };
9120
9159
  }
9121
9160
  const changeNoteSalt = randomChangeNoteSalt();
9122
9161
  const isSendToSelf = recipientPubkey === owner.publicKey || inputUtxos.some((u) => u.keypair.publicKey === recipientPubkey);
@@ -9148,7 +9187,29 @@ async function transfer(inputUtxos, recipientPubkey, amount, options) {
9148
9187
  { ...spendOptions, chainNoteSalt: changeNoteSalt }
9149
9188
  );
9150
9189
  }
9151
- async function partialWithdraw(inputUtxos, recipient, withdrawAmount, options) {
9190
+ async function sweepToWalletKey(inputUtxos, rawOptions) {
9191
+ if (inputUtxos.length === 0 || inputUtxos.length > 2) {
9192
+ throw new Error("sweepToWalletKey: one transaction moves 1 or 2 notes");
9193
+ }
9194
+ assertInputMints(inputUtxos, rawOptions.expectedMint);
9195
+ const options = prepareAffiliateAndClient(rawOptions);
9196
+ const owner = await requireOwnerUtxoKeypair(options, "sweepToWalletKey");
9197
+ const walletNk = await requireWalletNk(options, "sweepToWalletKey");
9198
+ const mint = inputUtxos[0].mintAddress;
9199
+ const salt = randomChangeNoteSalt();
9200
+ const migrated = (await createRecoverableChangeUtxo(sumUtxoAmounts(inputUtxos), owner, walletNk, mint, salt, 0)).utxo;
9201
+ const { recipientViewingPublicKey: _recipientViewingPublicKey, ...sweepOptions } = options;
9202
+ void _recipientViewingPublicKey;
9203
+ const result = await transact(
9204
+ { inputUtxos, outputUtxos: [migrated], externalAmount: BigInt(0) },
9205
+ { ...sweepOptions, chainNoteSalt: salt }
9206
+ );
9207
+ const note = result.outputUtxos?.[0] ?? migrated;
9208
+ if (result.commitmentIndices?.[0] >= 0) note.index = result.commitmentIndices[0];
9209
+ return { note, result };
9210
+ }
9211
+ async function partialWithdraw(inputUtxos, recipient, withdrawAmount, rawOptions) {
9212
+ const options = prepareAffiliateAndClient(rawOptions);
9152
9213
  const owner = await requireOwnerUtxoKeypair(options, "partialWithdraw");
9153
9214
  const walletNk = await requireWalletNk(options, "partialWithdraw");
9154
9215
  const inputSum = sumUtxoAmounts(inputUtxos);
@@ -9290,7 +9351,8 @@ async function waitForSwapCompletion(relayUrl, requestId, onProgress, maxAttempt
9290
9351
  }
9291
9352
  return null;
9292
9353
  }
9293
- async function swapUtxo(params, options) {
9354
+ async function swapUtxo(params, rawOptions) {
9355
+ const options = prepareAffiliateAndClient(rawOptions);
9294
9356
  const {
9295
9357
  inputUtxos,
9296
9358
  changeUtxo,
@@ -10173,7 +10235,8 @@ async function swapUtxo(params, options) {
10173
10235
  }
10174
10236
  };
10175
10237
  }
10176
- async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount, options, recipientWallet) {
10238
+ async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount, rawOptions, recipientWallet) {
10239
+ const options = prepareAffiliateAndClient(rawOptions);
10177
10240
  const owner = await requireOwnerUtxoKeypair(options, "swapWithChange");
10178
10241
  const totalInput = sumUtxoAmounts(inputUtxos);
10179
10242
  const change = totalInput - swapAmount;
@@ -10578,7 +10641,8 @@ function createRelayBatchAuthCoordinator(options) {
10578
10641
  }
10579
10642
 
10580
10643
  // src/flows/transact-batch.ts
10581
- async function transactBatch(items, options) {
10644
+ async function transactBatch(items, rawOptions) {
10645
+ const options = prepareAffiliateAndClient(rawOptions);
10582
10646
  if (items.length === 0) {
10583
10647
  return { results: [], approvals: 0 };
10584
10648
  }
@@ -10650,6 +10714,7 @@ var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
10650
10714
  var SOL_MINT = "So11111111111111111111111111111111111111112";
10651
10715
  var USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
10652
10716
  var USDT_MINT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
10717
+ var BRS_MINT = "BRSxQRUaGswjLs7ewcH7uXj3r7SgmfKSSLLXyCKHZtUo";
10653
10718
  var PUBLIC_AMOUNT_OFFSET = 32;
10654
10719
  var EXT_DATA_HASH_OFFSET = 40;
10655
10720
  var OUTPUT_COMMITMENT_0_OFFSET = 168;
@@ -10706,6 +10771,7 @@ function symbolForMint(mint) {
10706
10771
  if (mint === SOL_MINT) return "SOL";
10707
10772
  if (mint === USDC_MINT) return "USDC";
10708
10773
  if (mint === USDT_MINT) return "USDT";
10774
+ if (mint === BRS_MINT) return "BRS";
10709
10775
  if (!mint || mint.length < 8) return "TOKEN";
10710
10776
  return `${mint.slice(0, 4)}...${mint.slice(-4)}`;
10711
10777
  }
@@ -12376,6 +12442,68 @@ async function fetchNoteIndexPage(relayUrl, epoch, page, options = {}) {
12376
12442
  });
12377
12443
  }
12378
12444
 
12445
+ // src/notes/request-keys.ts
12446
+ import { blake3 as blake36 } from "@noble/hashes/blake3";
12447
+ import nacl6 from "tweetnacl";
12448
+ var BN254_ORDER = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
12449
+ var ROOT_SEED_DOMAIN = new TextEncoder().encode("cloak_request_root_v1");
12450
+ var ROOT_NK_DOMAIN = new TextEncoder().encode("cloak_request_root_nk_v1");
12451
+ var UTXO_DOMAIN = new TextEncoder().encode("cloak_request_utxo_v1");
12452
+ var VIEWING_DOMAIN = new TextEncoder().encode("cloak_request_vk_v1");
12453
+ var REQUEST_KEY_ROOT_SOURCE = "nk";
12454
+ var REQUEST_KEY_GAP_LIMIT = 20;
12455
+ var MAX_REQUEST_KEYS = 64;
12456
+ function check32(value, label) {
12457
+ if (!(value instanceof Uint8Array) || value.length !== 32) throw new Error(`${label} must be 32 bytes`);
12458
+ return value;
12459
+ }
12460
+ function counterBytes(counter) {
12461
+ if (!Number.isInteger(counter) || counter < 0 || counter > 4294967295) throw new Error("request counter must be a u32");
12462
+ const out = new Uint8Array(4);
12463
+ new DataView(out.buffer).setUint32(0, counter, false);
12464
+ return out;
12465
+ }
12466
+ function hashWith(domain, root, counter) {
12467
+ const c = counterBytes(counter);
12468
+ const pre = new Uint8Array(domain.length + root.length + c.length);
12469
+ pre.set(domain, 0);
12470
+ pre.set(root, domain.length);
12471
+ pre.set(c, domain.length + root.length);
12472
+ return blake36(pre);
12473
+ }
12474
+ function deriveRequestKeyRoot(input, source = REQUEST_KEY_ROOT_SOURCE) {
12475
+ const secret = source === "seed" ? check32(input.skSpend, "skSpend") : check32(input.nk, "nk");
12476
+ const domain = source === "seed" ? ROOT_SEED_DOMAIN : ROOT_NK_DOMAIN;
12477
+ const pre = new Uint8Array(domain.length + 32);
12478
+ pre.set(domain, 0);
12479
+ pre.set(secret, domain.length);
12480
+ return blake36(pre);
12481
+ }
12482
+ async function deriveRequestKeys(root, counter) {
12483
+ check32(root, "request root");
12484
+ const h = hashWith(UTXO_DOMAIN, root, counter);
12485
+ let value = 0n;
12486
+ for (let i = 0; i < 32; i++) value = value << 8n | BigInt(h[i]);
12487
+ const privateKey = value % (BN254_ORDER >> 4n);
12488
+ if (privateKey === 0n) throw new Error("request key derivation produced a zero key");
12489
+ const publicKey = await derivePublicKey(privateKey);
12490
+ const vk = hashWith(VIEWING_DOMAIN, root, counter);
12491
+ vk[0] &= 248;
12492
+ vk[31] &= 127;
12493
+ vk[31] |= 64;
12494
+ return {
12495
+ counter,
12496
+ utxoKeypair: { privateKey, publicKey },
12497
+ viewingKeypair: { privateKey: vk, publicKey: nacl6.scalarMult.base(vk) }
12498
+ };
12499
+ }
12500
+ async function deriveRequestKeyRange(root, from, count) {
12501
+ if (!Number.isInteger(count) || count < 0 || count > MAX_REQUEST_KEYS) throw new Error(`count must be in 0..${MAX_REQUEST_KEYS}`);
12502
+ const out = [];
12503
+ for (let i = 0; i < count; i++) out.push(await deriveRequestKeys(root, from + i));
12504
+ return out;
12505
+ }
12506
+
12379
12507
  // src/scanning/note-index.ts
12380
12508
  import _bs584 from "bs58";
12381
12509
  import { sha256 as sha2566 } from "@noble/hashes/sha2";
@@ -12485,6 +12613,7 @@ var LeafBuffer = class {
12485
12613
  async function trialItem(item, trials) {
12486
12614
  for (const trial of trials) {
12487
12615
  if (trial.legacy && item.kind === 2) continue;
12616
+ if (trial.requestIndex !== void 0 && item.kind !== 2) continue;
12488
12617
  const opened = await trialItemWith(item, trial);
12489
12618
  if (opened) return { ...opened, trial };
12490
12619
  }
@@ -12564,7 +12693,7 @@ async function matchOwnItems(own, owner, onReject, onSkip) {
12564
12693
  const nullifier = hex32(
12565
12694
  await computeNullifier({ amount: c.amount, keypair: c.keypair, blinding: c.blinding, mintAddress: c.mint, index: c.leaf, commitment: c.commitment })
12566
12695
  );
12567
- const full = { ...c, atRisk: c.atRisk || o.trial.legacy, signature: o.item.signature, page: o.page, seq: o.seq, nullifier };
12696
+ const full = { ...c, requestIndex: o.trial.requestIndex, atRisk: c.atRisk || o.trial.legacy, signature: o.item.signature, page: o.page, seq: o.seq, nullifier };
12568
12697
  candidates.push(full);
12569
12698
  if (!byNullifier.has(nullifier)) {
12570
12699
  byNullifier.set(nullifier, full);
@@ -12642,9 +12771,10 @@ async function matchOwnItems(own, owner, onReject, onSkip) {
12642
12771
  onReject(o);
12643
12772
  return;
12644
12773
  }
12774
+ const deliveryOwner = o.trial.requestIndex !== void 0 ? o.trial.owner : owner;
12645
12775
  const commitment = await computeCommitment({
12646
12776
  amount: o.delivery.amount,
12647
- keypair: { privateKey: 0n, publicKey: owner.publicKey },
12777
+ keypair: { privateKey: 0n, publicKey: deliveryOwner.publicKey },
12648
12778
  blinding: o.delivery.blinding,
12649
12779
  mintAddress: mint
12650
12780
  });
@@ -12657,7 +12787,7 @@ async function matchOwnItems(own, owner, onReject, onSkip) {
12657
12787
  atRisk: false,
12658
12788
  amount: o.delivery.amount,
12659
12789
  blinding: o.delivery.blinding,
12660
- keypair: owner,
12790
+ keypair: deliveryOwner,
12661
12791
  mint,
12662
12792
  commitment,
12663
12793
  leaf: Number(item.leaf)
@@ -13011,6 +13141,24 @@ async function recoverNotesFromIndex(params) {
13011
13141
  seenNks.add(key);
13012
13142
  trials.push(await makeTrial(Uint8Array.from(nk), true));
13013
13143
  }
13144
+ const requestKeys = params.requestKeys ?? [];
13145
+ if (!Array.isArray(requestKeys)) throw new Error("requestKeys must be an array");
13146
+ if (requestKeys.length > MAX_REQUEST_KEYS) throw new Error(`requestKeys takes at most ${MAX_REQUEST_KEYS} keys`);
13147
+ const seenRequestIdx = /* @__PURE__ */ new Set();
13148
+ for (const rk of requestKeys) {
13149
+ if (!Number.isInteger(rk.index) || rk.index < 0 || seenRequestIdx.has(rk.index)) throw new Error("requestKeys entries need distinct non-negative integer indexes");
13150
+ seenRequestIdx.add(rk.index);
13151
+ if (!(rk.viewingSecretKey instanceof Uint8Array) || rk.viewingSecretKey.length !== 32) throw new Error("requestKeys viewingSecretKey must be 32 bytes");
13152
+ const ownerKp = await assertOwnerUtxoKeypair(rk.ownerKeypair, "requestKeys.ownerKeypair");
13153
+ trials.push({
13154
+ nk: new Uint8Array(32),
13155
+ legacy: false,
13156
+ owner: ownerKp,
13157
+ requestIndex: rk.index,
13158
+ decrypt: async () => null,
13159
+ open: await createRecipientDeliveryOpener(rk.viewingSecretKey)
13160
+ });
13161
+ }
13014
13162
  const poolMints = Array.from(new Set(params.poolMints));
13015
13163
  const warnings = [];
13016
13164
  const head = await fetchNoteIndexHead(relayUrl, { signal: params.signal });
@@ -13047,6 +13195,7 @@ async function recoverNotesFromIndex(params) {
13047
13195
  }
13048
13196
  async function runOnce(ctx, cursor) {
13049
13197
  const { params, head, trials, owner, stats, poolMints } = ctx;
13198
+ const requestOwners = new Set(trials.filter((t) => t.requestIndex !== void 0).map((t) => t.owner.publicKey));
13050
13199
  const { relayUrl, onProgress } = params;
13051
13200
  const poolSet = new Set(poolMints);
13052
13201
  const startPage = cursor?.raw.page ?? 0;
@@ -13334,7 +13483,8 @@ async function runOnce(ctx, cursor) {
13334
13483
  for (const c of byLeaf.values()) {
13335
13484
  const pubOk = keyChecked.get(c.keypair.privateKey) ?? (c.keypair.privateKey !== 0n && await derivePublicKey(c.keypair.privateKey) === c.keypair.publicKey);
13336
13485
  keyChecked.set(c.keypair.privateKey, pubOk);
13337
- if (!pubOk || !c.atRisk && c.keypair.publicKey !== owner.publicKey) {
13486
+ const ownerOk = c.requestIndex !== void 0 ? requestOwners.has(c.keypair.publicKey) : c.keypair.publicKey === owner.publicKey;
13487
+ if (!pubOk || !c.atRisk && !ownerOk) {
13338
13488
  stats.dropped++;
13339
13489
  tally(c, "rejected");
13340
13490
  continue;
@@ -13343,7 +13493,7 @@ async function runOnce(ctx, cursor) {
13343
13493
  verifiedOut.add(verifiedKey(c.mint, c.leaf, c.commitment));
13344
13494
  const utxo = {
13345
13495
  amount: c.amount,
13346
- keypair: c.atRisk ? { ...c.keypair } : owner,
13496
+ keypair: c.atRisk ? { ...c.keypair } : c.requestIndex !== void 0 ? c.keypair : owner,
13347
13497
  blinding: c.blinding,
13348
13498
  mintAddress: c.mint,
13349
13499
  index: c.leaf,
@@ -13358,7 +13508,8 @@ async function runOnce(ctx, cursor) {
13358
13508
  kind: c.kind,
13359
13509
  utxo,
13360
13510
  signature: bs584.encode(c.signature),
13361
- legacyExposed: c.atRisk
13511
+ legacyExposed: c.atRisk,
13512
+ ...c.requestIndex !== void 0 ? { requestIndex: c.requestIndex } : {}
13362
13513
  };
13363
13514
  (c.atRisk ? atRisk : notes).push(note);
13364
13515
  }
@@ -13800,7 +13951,7 @@ async function loadWeb3() {
13800
13951
  }
13801
13952
 
13802
13953
  // src/bridge/rail-verify.ts
13803
- import nacl6 from "tweetnacl";
13954
+ import nacl7 from "tweetnacl";
13804
13955
  import { sha256 as sha2567 } from "@noble/hashes/sha256";
13805
13956
  var ONECLICK_PUBKEY_B58 = "reYaWhvwu8Jzo3WUM3zhn6VrhuMEF4eADL17qtRVifc";
13806
13957
  var b58 = /* @__PURE__ */ (() => {
@@ -13911,7 +14062,7 @@ function verifyQuoteSignature(resp) {
13911
14062
  const message = new TextEncoder().encode(b58.encode(new Uint8Array(digest)));
13912
14063
  const sig = resp.signature.replace(/^ed25519:/, "");
13913
14064
  try {
13914
- return { valid: nacl6.sign.detached.verify(message, b58.decode(sig), b58.decode(ONECLICK_PUBKEY_B58)) };
14065
+ return { valid: nacl7.sign.detached.verify(message, b58.decode(sig), b58.decode(ONECLICK_PUBKEY_B58)) };
13915
14066
  } catch (e) {
13916
14067
  return { valid: false, reason: e instanceof Error ? e.message : String(e) };
13917
14068
  }
@@ -14139,7 +14290,7 @@ async function fundReceiverViaPaymaster(relayUrl, receiver, grantLamports) {
14139
14290
  // src/bridge/derive.ts
14140
14291
  import { hmac } from "@noble/hashes/hmac";
14141
14292
  import { sha512 } from "@noble/hashes/sha512";
14142
- import { blake3 as blake36 } from "@noble/hashes/blake3";
14293
+ import { blake3 as blake37 } from "@noble/hashes/blake3";
14143
14294
  var BRIDGE_ESCROW_LABEL = "cloak_bridge_escrow";
14144
14295
  var BRIDGE_ESCROW_LABEL_V2 = "cloak_bridge_escrow_v2";
14145
14296
  var BRIDGE_RECEIVER_KEY_DOMAIN = new TextEncoder().encode("cloak_bridge_receiver_key_v2");
@@ -14166,7 +14317,7 @@ async function deriveBridgeReceiver(ownerUtxoKeypair, index) {
14166
14317
  const preimage = new Uint8Array(BRIDGE_RECEIVER_KEY_DOMAIN.length + priv.length);
14167
14318
  preimage.set(BRIDGE_RECEIVER_KEY_DOMAIN, 0);
14168
14319
  preimage.set(priv, BRIDGE_RECEIVER_KEY_DOMAIN.length);
14169
- const key = blake36(preimage);
14320
+ const key = blake37(preimage);
14170
14321
  const h = hmac(sha512, key, new TextEncoder().encode(`${BRIDGE_ESCROW_LABEL_V2}:${index}`));
14171
14322
  return signerFromSecretKey(h.slice(0, 32));
14172
14323
  }
@@ -14677,7 +14828,7 @@ async function withShieldRetries(attempt, hooks = {}) {
14677
14828
  }
14678
14829
 
14679
14830
  // src/index.ts
14680
- var VERSION = "0.2.6";
14831
+ var VERSION = "0.2.8";
14681
14832
  var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
14682
14833
  export {
14683
14834
  AccountRole,
@@ -14705,6 +14856,7 @@ export {
14705
14856
  MAINNET_RENT_0,
14706
14857
  MAINNET_RENT_1,
14707
14858
  MAX_RECEIVER_INDEX,
14859
+ MAX_REQUEST_KEYS,
14708
14860
  MERKLE_TREE_HEIGHT2 as MERKLE_TREE_HEIGHT,
14709
14861
  MIN_DEPOSIT_LAMPORTS,
14710
14862
  MIN_DEPOSIT_SPL_BASE_UNITS,
@@ -14728,6 +14880,8 @@ export {
14728
14880
  REQUEST_AUTH_BATCH_MAX_AGE_SECONDS,
14729
14881
  REQUEST_AUTH_MAX_AGE_SECONDS,
14730
14882
  REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS,
14883
+ REQUEST_KEY_GAP_LIMIT,
14884
+ REQUEST_KEY_ROOT_SOURCE,
14731
14885
  RelayBatchAuthCoordinator,
14732
14886
  RelayInternalError,
14733
14887
  RelayService,
@@ -14825,6 +14979,9 @@ export {
14825
14979
  deriveLegacyDepositNoteSecrets,
14826
14980
  deriveLegacySwapRefundAuthorization,
14827
14981
  derivePublicKey,
14982
+ deriveRequestKeyRange,
14983
+ deriveRequestKeyRoot,
14984
+ deriveRequestKeys,
14828
14985
  deriveSpendKey,
14829
14986
  deriveSwapRefundAuthorization,
14830
14987
  deriveSwapRefundBlinding,
@@ -14913,6 +15070,7 @@ export {
14913
15070
  isTerminalFailure,
14914
15071
  isTransactionSigner,
14915
15072
  isValidHex,
15073
+ isValidRelayClientId,
14916
15074
  isValidRpcUrl,
14917
15075
  isValidSolanaAddress,
14918
15076
  isWithdrawAmountSufficient,
@@ -14926,6 +15084,7 @@ export {
14926
15084
  matchSwapRefundLeaf,
14927
15085
  mayRetry,
14928
15086
  messageSignerFromCallback,
15087
+ normalizeAffiliateCode,
14929
15088
  openRecipientDeliveryNote,
14930
15089
  parseAmount,
14931
15090
  parseDeliveryCarrierMemo,
@@ -14989,6 +15148,7 @@ export {
14989
15148
  sumUtxoAmounts,
14990
15149
  swapUtxo,
14991
15150
  swapWithChange,
15151
+ sweepToWalletKey,
14992
15152
  toAddress,
14993
15153
  toComplianceReport,
14994
15154
  transact,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloak.dev/sdk",
3
3
  "description": "Shield, send, and swap on Solana privately — TypeScript SDK with UTXO-based zero-knowledge transactions",
4
- "version": "0.2.6",
4
+ "version": "0.2.8",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -117,7 +117,7 @@
117
117
  "access": "public"
118
118
  },
119
119
  "engines": {
120
- "node": ">=18.0.0"
120
+ "node": ">=22.0.0"
121
121
  },
122
122
  "overrides": {
123
123
  "glob": "^10.5.0",