shinjuku-shielded 0.3.32 → 0.3.34

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": "3ec79a8335ea99f87cf8f2c34ea8723c70a30bd6f30fc5c0fb177edfa1816714",
5
- "bytes": 11184498,
6
- "sourceCommit": "8bd35a850efa3fb8dac143ea02a6d02a3f4008c6",
4
+ "sha256": "b22ae0f772097b698eba694cfec8b31061921a38948c11702df3653881361e9f",
5
+ "bytes": 11185132,
6
+ "sourceCommit": "164420d7b29522db79b23d11ae14bc10ec26ce8f",
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.32",
3
+ "version": "0.3.34",
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": "3ec79a83",
7
- "shinjukuSha256": "3ec79a8335ea99f87cf8f2c34ea8723c70a30bd6f30fc5c0fb177edfa1816714",
6
+ "shinjukuRelease": "b22ae0f7",
7
+ "shinjukuSha256": "b22ae0f772097b698eba694cfec8b31061921a38948c11702df3653881361e9f",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
@@ -46392,6 +46392,28 @@ var init_ohttp = __esm({
46392
46392
  }
46393
46393
  });
46394
46394
 
46395
+ // wallet/src/pay/phaseTiming.mjs
46396
+ import { AsyncLocalStorage } from "node:async_hooks";
46397
+ function withPhaseScope(mark, prefix, fn) {
46398
+ if (typeof mark !== "function") return fn();
46399
+ const outer = scope.getStore();
46400
+ const write = (phase) => mark(`${prefix}:${phase}`);
46401
+ return scope.run(outer ? (phase) => outer(`${prefix}:${phase}`) : write, fn);
46402
+ }
46403
+ function markPhase(phase) {
46404
+ try {
46405
+ scope.getStore()?.(phase);
46406
+ } catch {
46407
+ }
46408
+ }
46409
+ var scope;
46410
+ var init_phaseTiming = __esm({
46411
+ "wallet/src/pay/phaseTiming.mjs"() {
46412
+ "use strict";
46413
+ scope = new AsyncLocalStorage();
46414
+ }
46415
+ });
46416
+
46395
46417
  // wallet/src/net/proxy.mjs
46396
46418
  import { spawn } from "node:child_process";
46397
46419
  import { randomBytes as randomBytes5 } from "node:crypto";
@@ -46575,7 +46597,15 @@ function describeRpcPost(input, body) {
46575
46597
  const calls = Array.isArray(parsed) ? parsed : [parsed];
46576
46598
  const resendable = calls.length > 0 && calls.every((call3) => typeof call3?.method === "string" && RESENDABLE_METHOD.test(call3.method));
46577
46599
  const method = Array.isArray(parsed) ? "batch" : parsed?.method;
46578
- return { key: `${new URL(input instanceof Request ? input.url : String(input)).origin} ${method ?? ""}`, resendable };
46600
+ return {
46601
+ key: `${new URL(input instanceof Request ? input.url : String(input)).origin} ${method ?? ""}`,
46602
+ resendable,
46603
+ // The method in a timing mark: a JSON-RPC method name only, else "other".
46604
+ mark: typeof method === "string" && /^[A-Za-z]{1,40}$/.test(method) ? method : "other"
46605
+ };
46606
+ }
46607
+ function markRefusal(response, post) {
46608
+ if (response.status === 429 || response.status === 503) markPhase(`rpc-${response.status}-${post?.mark ?? "other"}`);
46579
46609
  }
46580
46610
  function noteAnswer(response) {
46581
46611
  if (!response.ok) return;
@@ -46607,6 +46637,7 @@ async function rpcFetch(input, init) {
46607
46637
  if (!post?.resendable) {
46608
46638
  const response = await fetch(input, init);
46609
46639
  noteAnswer(response);
46640
+ markRefusal(response, post);
46610
46641
  return response;
46611
46642
  }
46612
46643
  let strikes = 0;
@@ -46617,9 +46648,11 @@ async function rpcFetch(input, init) {
46617
46648
  if (stop2) throw new Error(`rpc_rate_limited: ${stop2}`);
46618
46649
  waited = true;
46619
46650
  }
46651
+ if (waited) markPhase(`rpc-paced-${post.mark}`);
46620
46652
  const circuit = torRotations;
46621
46653
  const response = await fetch(input, init);
46622
46654
  noteAnswer(response);
46655
+ markRefusal(response, post);
46623
46656
  if (response.status !== 429) return response;
46624
46657
  await response.body?.cancel().catch(() => {
46625
46658
  });
@@ -46709,6 +46742,7 @@ var init_proxy = __esm({
46709
46742
  "use strict";
46710
46743
  init_facilitatorOnion();
46711
46744
  init_ohttp();
46745
+ init_phaseTiming();
46712
46746
  TOR_HTTP_TUNNEL = "http://127.0.0.1:9080";
46713
46747
  TOR_CHECK = "https://check.torproject.org/api/ip";
46714
46748
  PROOF_TIMEOUT_MS = 2e4;
@@ -49625,28 +49659,6 @@ var init_serviceUrl = __esm({
49625
49659
  }
49626
49660
  });
49627
49661
 
49628
- // wallet/src/pay/phaseTiming.mjs
49629
- import { AsyncLocalStorage } from "node:async_hooks";
49630
- function withPhaseScope(mark, prefix, fn) {
49631
- if (typeof mark !== "function") return fn();
49632
- const outer = scope.getStore();
49633
- const write = (phase) => mark(`${prefix}:${phase}`);
49634
- return scope.run(outer ? (phase) => outer(`${prefix}:${phase}`) : write, fn);
49635
- }
49636
- function markPhase(phase) {
49637
- try {
49638
- scope.getStore()?.(phase);
49639
- } catch {
49640
- }
49641
- }
49642
- var scope;
49643
- var init_phaseTiming = __esm({
49644
- "wallet/src/pay/phaseTiming.mjs"() {
49645
- "use strict";
49646
- scope = new AsyncLocalStorage();
49647
- }
49648
- });
49649
-
49650
49662
  // wallet/src/anchorClock.mjs
49651
49663
  function observePoolAnchors(state, nowMs = Date.now()) {
49652
49664
  try {
@@ -56310,7 +56322,6 @@ async function loadWalletP03History(args) {
56310
56322
  }
56311
56323
  if (runKey !== void 0 && recentScope.getStore() === true && strictScope.getStore() !== true && args.forceRead !== true) {
56312
56324
  const recent = recentLoads.get(runKey);
56313
- recentLoads.delete(runKey);
56314
56325
  if (recent !== void 0 && Date.now() - recent.startedAt <= HISTORY_PREWARM_JOIN_MS) {
56315
56326
  PREWARMED_REPORTS.add(recent.report);
56316
56327
  markPhase("walk-recent");
@@ -56522,7 +56533,7 @@ function reportHistoryRpc(split5, source, result, crossChecked) {
56522
56533
  writeStderr(`history: ${who} answered ${list(split5.history)}; your own RPC answered ${list(split5.own)} (the pool account the history must match, and the cross-check)${window2}${integrity}
56523
56534
  `);
56524
56535
  }
56525
- var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
56536
+ var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
56526
56537
  var init_walletHistory = __esm({
56527
56538
  "wallet/src/history/walletHistory.mjs"() {
56528
56539
  "use strict";
@@ -56539,6 +56550,9 @@ var init_walletHistory = __esm({
56539
56550
  recentScope = new AsyncLocalStorage2();
56540
56551
  withRecentWalletHistory = (fn) => recentScope.run(true, fn);
56541
56552
  recentLoads = /* @__PURE__ */ new Map();
56553
+ forgetRecentWalletHistory = () => {
56554
+ recentLoads.clear();
56555
+ };
56542
56556
  historyCacheKey = (store) => createHmac5("sha256", Buffer.from(store.state.seedHex, "hex")).update("carbon-shielded-wallet/history-cache-key/v1").digest("hex");
56543
56557
  HISTORY_PREWARM_JOIN_MS = 1e4;
56544
56558
  prewarmedWalks = /* @__PURE__ */ new Map();
@@ -72022,6 +72036,7 @@ async function prepareRecoveredPayment({
72022
72036
  quoteCommitment: witnessQuote.quoteCommitment,
72023
72037
  amountAtomic: witnessQuote.amountAtomic
72024
72038
  });
72039
+ forgetRecentWalletHistory();
72025
72040
  return {
72026
72041
  replayed: false,
72027
72042
  walName: walName2,
@@ -72211,6 +72226,7 @@ async function prepareRecoveredPayment({
72211
72226
  if (persisted !== void 0 && persisted.requestHash !== requestHash2) {
72212
72227
  fail15("wal_request_binding_mismatch");
72213
72228
  }
72229
+ forgetRecentWalletHistory();
72214
72230
  const proved = await (deps.provePayment ?? proveRecoveredP03Payment)({ request, tools: proofTools });
72215
72231
  const binding = {
72216
72232
  poolDomain: request.poolDomain,
@@ -126143,7 +126159,7 @@ function createWalletTools({
126143
126159
  return;
126144
126160
  }
126145
126161
  if (!stale || refreshFailedAt && Date.now() - refreshFailedAt < REFRESH_RETRY_MS) return;
126146
- if (refreshRun && refreshInBackground) return;
126162
+ if (finalityWait || refreshRun && refreshInBackground) return;
126147
126163
  await refreshShared().catch(() => {
126148
126164
  });
126149
126165
  }