shinjuku-shielded 0.3.41 → 0.3.42

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/manifest.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schema": "carbon-shielded-wallet/bundle-manifest/v1",
3
3
  "file": "shinjuku-wallet.mjs",
4
- "sha256": "387938b415cfece575952e875ecafc7149e29279e202a4e862433f66f664a803",
5
- "bytes": 11230018,
6
- "sourceCommit": "60acd91587cd5576b91001c7dcdabbb1c0f723aa",
4
+ "sha256": "f55f1fb8f1b63bf4caf94b552f06f6c3126ed8fd598d6d8fe8fc9abd7377b509",
5
+ "bytes": 11232354,
6
+ "sourceCommit": "602ba18e9b8035f26155973016e9d4df9beaa718",
7
7
  "sourceDirty": false,
8
8
  "installRecordMatchesLockfile": true,
9
9
  "releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shielded",
3
- "version": "0.3.41",
3
+ "version": "0.3.42",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
5
5
  "description": "Shinjuku Shielded, the private x402 facilitator on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
6
- "shinjukuRelease": "387938b4",
7
- "shinjukuSha256": "387938b415cfece575952e875ecafc7149e29279e202a4e862433f66f664a803",
6
+ "shinjukuRelease": "f55f1fb8",
7
+ "shinjukuSha256": "f55f1fb8f1b63bf4caf94b552f06f6c3126ed8fd598d6d8fe8fc9abd7377b509",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
@@ -60149,6 +60149,7 @@ var init_sealedCache = __esm({
60149
60149
  });
60150
60150
 
60151
60151
  // wallet/src/recovery/recoveryCache.mjs
60152
+ import { performance as performance2 } from "node:perf_hooks";
60152
60153
  function contextBinding(context) {
60153
60154
  return [
60154
60155
  context.transitionKind,
@@ -60200,7 +60201,28 @@ function decodeOutput(value) {
60200
60201
  VERIFIED_OPENINGS.add(opening);
60201
60202
  return { ...output2, leafIndex: decimal3(value.leafIndex) };
60202
60203
  }
60203
- function openRecoveryCache(store, { programId, pool: pool2 }) {
60204
+ function openRecoveryCache(store, ids) {
60205
+ const run5 = openRecoveryCacheSteps(store, ids);
60206
+ let step = run5.next();
60207
+ while (!step.done) step = run5.next();
60208
+ return step.value;
60209
+ }
60210
+ async function openRecoveryCacheSliced(store, ids) {
60211
+ const run5 = openRecoveryCacheSteps(store, ids);
60212
+ let started = performance2.now();
60213
+ let step = run5.next();
60214
+ while (!step.done) {
60215
+ if (performance2.now() - started >= 25) {
60216
+ await new Promise((resolve38) => {
60217
+ setImmediate(resolve38);
60218
+ });
60219
+ started = performance2.now();
60220
+ }
60221
+ step = run5.next();
60222
+ }
60223
+ return step.value;
60224
+ }
60225
+ function* openRecoveryCacheSteps(store, { programId, pool: pool2 }) {
60204
60226
  const file = sealedCacheFile(store, { file: RECOVERY_CACHE_FILE, schema: RECOVERY_CACHE_SCHEMA, keyLabel: KEY_LABEL });
60205
60227
  if (!file) return void 0;
60206
60228
  const read = file.read();
@@ -60217,6 +60239,7 @@ function openRecoveryCache(store, { programId, pool: pool2 }) {
60217
60239
  entryKey(memo2.digest, memo2.binding),
60218
60240
  { digest: memo2.digest, binding: memo2.binding, outputs: memo2.outputs.map(decodeOutput) }
60219
60241
  );
60242
+ yield;
60220
60243
  }
60221
60244
  } catch {
60222
60245
  entries.clear();
@@ -60282,14 +60305,14 @@ var init_recoveryCache = __esm({
60282
60305
 
60283
60306
  // wallet/src/recovery/memoDecryptPool.mjs
60284
60307
  import { availableParallelism } from "node:os";
60285
- import { performance as performance2 } from "node:perf_hooks";
60308
+ import { performance as performance3 } from "node:perf_hooks";
60286
60309
  import { Worker as Worker2 } from "node:worker_threads";
60287
60310
  function sliceClock() {
60288
- let started = performance2.now();
60311
+ let started = performance3.now();
60289
60312
  return async () => {
60290
- if (performance2.now() - started < SLICE_MS) return;
60313
+ if (performance3.now() - started < SLICE_MS) return;
60291
60314
  await yieldTurn();
60292
- started = performance2.now();
60315
+ started = performance3.now();
60293
60316
  };
60294
60317
  }
60295
60318
  async function sharedXOnMainThread(xs, eta) {
@@ -60618,7 +60641,7 @@ var init_successorHistories = __esm({
60618
60641
  // wallet/src/recovery/recover.mjs
60619
60642
  import { createHash as createHash15 } from "node:crypto";
60620
60643
  import { join as join10, resolve as resolve10 } from "node:path";
60621
- import { performance as performance3 } from "node:perf_hooks";
60644
+ import { performance as performance4 } from "node:perf_hooks";
60622
60645
  import { fileURLToPath as fileURLToPath5 } from "node:url";
60623
60646
  function pinnedGenerator2(profileVector) {
60624
60647
  if (profileVector?.payerKeys?.generator) return profileVector.payerKeys.generator;
@@ -60689,18 +60712,18 @@ function walMemoBundles(store) {
60689
60712
  }
60690
60713
  async function walMemoBundlesSliced(store) {
60691
60714
  const bundles = /* @__PURE__ */ new Map();
60692
- let started = performance3.now();
60715
+ let started = performance4.now();
60693
60716
  for (const name of store.listWal()) {
60694
60717
  const record = store.readWal(name);
60695
60718
  if (record?.memoBundleHex) {
60696
60719
  const bytes2 = Uint8Array.from(Buffer.from(hexOf2(record.memoBundleHex), "hex"));
60697
60720
  bundles.set(hexOf2(record.memoDigest ?? bundleDigest2(bytes2)), bytes2);
60698
60721
  }
60699
- if (performance3.now() - started >= 25) {
60722
+ if (performance4.now() - started >= 25) {
60700
60723
  await new Promise((resolve38) => {
60701
60724
  setImmediate(resolve38);
60702
60725
  });
60703
- started = performance3.now();
60726
+ started = performance4.now();
60704
60727
  }
60705
60728
  }
60706
60729
  return bundles;
@@ -60779,7 +60802,7 @@ async function legacyOutputs({ store, digests, serviceUrl: serviceUrl2, fresh, d
60779
60802
  return { entries, bundlesExamined: bundles.length };
60780
60803
  }
60781
60804
  async function syncedOutputs({ store, finalizedHistory: finalizedHistory2, digests, serviceUrl: serviceUrl2, fresh, deps, chainProgramId, pool: pool2, eta, decrypt }) {
60782
- const cache = deps.recoveryCache !== void 0 ? deps.recoveryCache : openRecoveryCache(store, { programId: chainProgramId.toBase58(), pool: pool2.toBase58() });
60805
+ const cache = deps.recoveryCache !== void 0 ? deps.recoveryCache : await openRecoveryCacheSliced(store, { programId: chainProgramId.toBase58(), pool: pool2.toBase58() });
60783
60806
  const contexts = finalizedHistory2.contexts;
60784
60807
  const found = /* @__PURE__ */ new Map();
60785
60808
  const pending = [];
@@ -60816,13 +60839,13 @@ async function syncedOutputs({ store, finalizedHistory: finalizedHistory2, diges
60816
60839
  }
60817
60840
  }
60818
60841
  const items = [];
60819
- let sliceStart = performance3.now();
60842
+ let sliceStart = performance4.now();
60820
60843
  for (const context of chunk) {
60821
- if (performance3.now() - sliceStart >= 25) {
60844
+ if (performance4.now() - sliceStart >= 25) {
60822
60845
  await new Promise((resolve38) => {
60823
60846
  setImmediate(resolve38);
60824
60847
  });
60825
- sliceStart = performance3.now();
60848
+ sliceStart = performance4.now();
60826
60849
  }
60827
60850
  const digest2 = hexOf2(context.memoDigest);
60828
60851
  const fromService = served.get(digest2);
@@ -60977,8 +61000,15 @@ async function runRecover({ store, connection, programId, digests, serviceUrl: s
60977
61000
  }
60978
61001
  markPhase("recover-memos");
60979
61002
  const recovered = [];
61003
+ let replayStarted = performance4.now();
60980
61004
  for (const { digest: digest2, context, outputs } of read.entries) {
60981
61005
  for (const output2 of outputs) {
61006
+ if (performance4.now() - replayStarted >= 25) {
61007
+ await new Promise((resolve38) => {
61008
+ setImmediate(resolve38);
61009
+ });
61010
+ replayStarted = performance4.now();
61011
+ }
60982
61012
  const replayValue = replayValueOf(
60983
61013
  output2.kind,
60984
61014
  context.poolDomain,
@@ -72513,8 +72543,15 @@ function respendNoteSubset({ accounts, notes, outputIndex, amountAtomic, refused
72513
72543
  return void 0;
72514
72544
  }
72515
72545
  function exitReservedNoteCommitments(store) {
72546
+ const run5 = exitReservedNoteCommitmentSteps(store);
72547
+ let step = run5.next();
72548
+ while (!step.done) step = run5.next();
72549
+ return step.value;
72550
+ }
72551
+ function* exitReservedNoteCommitmentSteps(store) {
72516
72552
  const reserved = /* @__PURE__ */ new Set();
72517
72553
  for (const name of typeof store?.listWal === "function" ? store.listWal() : []) {
72554
+ yield;
72518
72555
  const selfPay2 = name.startsWith("self-pay-");
72519
72556
  if (!selfPay2 && !name.startsWith("note-exit-")) continue;
72520
72557
  if (name.startsWith("self-pay-merge-")) continue;
@@ -72568,7 +72605,7 @@ function startFinalizedChainTime(connection) {
72568
72605
  return time + Math.floor(age / 1e3);
72569
72606
  };
72570
72607
  }
72571
- async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, deps = {} }) {
72608
+ async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, amountAtomic, deps = {} }) {
72572
72609
  if (typeof deps.walkHistory !== "function") fail15("walk_history_required");
72573
72610
  const viewing = deriveWalletViewingAuthority2({ seedBytes: seedBytes5(store.state), generator: pinnedGenerator4() });
72574
72611
  const history = assertAuthenticatedFinalizedP03History(await withRecentWalletHistory(() => deps.walkHistory()));
@@ -72579,14 +72616,31 @@ async function everyAccountHeld({ store, connection, programId, serviceUrl: serv
72579
72616
  serviceUrl: serviceUrl2,
72580
72617
  deps: { fetchImpl: deps.fetchImpl, finalizedHistory: history, transitionContextFor: history.transitionContextFor }
72581
72618
  });
72582
- return recovery.recovered.filter((entry) => entry.kind === "account" && entry.spendStatus === "unspent").every((entry) => {
72619
+ const poolDomain = history.contexts[0]?.poolDomain;
72620
+ const held = (entry) => {
72583
72621
  if (entry.leafIndex === void 0 || entry.leafIndex === null) return true;
72584
72622
  try {
72585
- return reservedReplayValues.has(accountNullifier(entry.commitment, viewing.eta, entry.leafIndex).toString());
72623
+ const value = entry.kind === "account" ? accountNullifier(entry.commitment, viewing.eta, entry.leafIndex) : noteNullifier2(poolDomain, entry.commitment, viewing.eta, entry.leafIndex);
72624
+ return reservedReplayValues.has(value.toString());
72586
72625
  } catch {
72587
72626
  return true;
72588
72627
  }
72589
- });
72628
+ };
72629
+ const unspent = (kind) => recovery.recovered.filter((entry) => entry.kind === kind && entry.spendStatus === "unspent");
72630
+ const unspentAccounts = unspent("account");
72631
+ const unheldAccounts = unspentAccounts.filter((entry) => !held(entry));
72632
+ if (unheldAccounts.length === 0) return true;
72633
+ if (amountAtomic === void 0) return false;
72634
+ const unspentNotes = unspent("note");
72635
+ const unheldNotes = unspentNotes.filter((entry) => !held(entry));
72636
+ const anyHeld = unheldAccounts.length !== unspentAccounts.length || unheldNotes.length !== unspentNotes.length && (() => {
72637
+ const exitReserved = exitReservedNoteCommitments(store);
72638
+ return unspentNotes.some((entry) => held(entry) && !exitReserved.has(BigInt(entry.commitment).toString()));
72639
+ })();
72640
+ if (!anyHeld) return false;
72641
+ const largestAccount = unheldAccounts.reduce((max, entry) => BigInt(entry.account.b) > max ? BigInt(entry.account.b) : max, 0n);
72642
+ const notesValue = unheldNotes.reduce((sum2, entry) => sum2 + BigInt(entry.note.b), 0n);
72643
+ return largestAccount + notesValue < BigInt(amountAtomic);
72590
72644
  }
72591
72645
  async function prepareRecoveredPayment({
72592
72646
  store,
@@ -93185,6 +93239,7 @@ async function payResourceOnce({
93185
93239
  programId,
93186
93240
  serviceUrl: serviceUrl2,
93187
93241
  reservedReplayValues: held,
93242
+ amountAtomic: maximumAtomic,
93188
93243
  deps: { fetchImpl: deps.fetchImpl, walkHistory: finality.walkHistory }
93189
93244
  }));
93190
93245
  } catch {