shinjuku-shield 0.3.143 → 0.3.145

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/README.md CHANGED
@@ -6,19 +6,19 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
6
6
  command runs a local MCP server (stdio) for your agent. Your keys never
7
7
  leave your machine.
8
8
 
9
- This is version 0.3.143. The npm packages `shinjuku-shield` and
9
+ This is version 0.3.145. The npm packages `shinjuku-shield` and
10
10
  `shinjuku-shielded` hold the same files. The command is `shinjuku`.
11
11
 
12
12
  ## Set up
13
13
 
14
14
  ```sh
15
- npm install -g shinjuku@0.3.143
15
+ npm install -g shinjuku@0.3.145
16
16
  shinjuku setup
17
17
  ```
18
18
 
19
19
  Type the two lines as they are. `npx install shinjuku` does not work: npx
20
20
  reads `install` as the name of another npm package. To set up without
21
- installing, type `npx shinjuku@0.3.143 setup`.
21
+ installing, type `npx shinjuku@0.3.145 setup`.
22
22
 
23
23
  Setup makes the wallet on this machine, a private passphrase file, and the
24
24
  checked proof tools (about 191 MB), and writes `config.json`. It also writes
@@ -36,13 +36,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
36
36
  Claude Code:
37
37
 
38
38
  ```sh
39
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.143 mcp
39
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.145 mcp
40
40
  ```
41
41
 
42
42
  Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
43
43
 
44
44
  ```json
45
- { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.143", "mcp"] } } }
45
+ { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.145", "mcp"] } } }
46
46
  ```
47
47
 
48
48
  On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
@@ -55,7 +55,7 @@ Codex (the Codex app and Codex CLI read the same file, `~/.codex/config.toml`):
55
55
  ```toml
56
56
  [mcp_servers.shinjuku]
57
57
  command = "npx"
58
- args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.143", "mcp"]
58
+ args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.145", "mcp"]
59
59
  startup_timeout_sec = 120
60
60
  tool_timeout_sec = 300
61
61
  ```
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": "d1d7233b86e252e58009678280970cb3aaa264c8569bd29f790e5a592a948138",
5
- "bytes": 8974175,
6
- "sourceCommit": "d25e1296d250570e9a2a5c427ea98730b75a1cee",
4
+ "sha256": "a104f1f4855717492e6a01550a0e2fc02f50651f70a1812173ef94d2bcc963f7",
5
+ "bytes": 8976086,
6
+ "sourceCommit": "e8e4f61d53684f115b44ed99272b87318c254c15",
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",
@@ -1038,5 +1038,5 @@
1038
1038
  "version": "1.8.0"
1039
1039
  }
1040
1040
  ],
1041
- "publishedAt": "2026-11-01T09:22:38.910Z"
1041
+ "publishedAt": "2026-11-01T11:08:50.757Z"
1042
1042
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.143",
3
+ "version": "0.3.145",
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": "d1d7233b",
7
- "shinjukuSha256": "d1d7233b86e252e58009678280970cb3aaa264c8569bd29f790e5a592a948138",
6
+ "shinjukuRelease": "a104f1f4",
7
+ "shinjukuSha256": "a104f1f4855717492e6a01550a0e2fc02f50651f70a1812173ef94d2bcc963f7",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -82261,14 +82261,33 @@ function createAnchorReader({ connection, profile }) {
82261
82261
  const ringSlotServes = !current && requireCapacity && state.anchorMode === 2 && state.anchorRing !== null && newest !== void 0 && newest.anchorIndex === BigInt(state.currentIndex) && p03RingAnchorHasQuoteMargin(BigInt(newest.epoch), chainTimestamp);
82262
82262
  if (requireCapacity && !current && !ringSlotServes) fail17("anchor_not_ready");
82263
82263
  const selected = current ?? newest;
82264
- return {
82264
+ const read = {
82265
82265
  ...selected,
82266
82266
  chainTimestamp,
82267
82267
  finalizedSlot: slot3,
82268
82268
  retainedAnchors: anchors.filter((a) => a !== selected)
82269
82269
  };
82270
+ if (state.anchorMode === 2 && state.anchorRing !== null) ringModeReads.add(read);
82271
+ return read;
82270
82272
  };
82271
82273
  }
82274
+ function ringSlotServesPayment(read, quoteAnchor) {
82275
+ return quoteAnchor !== void 0 && ringModeReads.has(read) && p03RingAnchorServesQuote(quoteAnchor, {
82276
+ chainTimestamp: read.chainTimestamp,
82277
+ finalizedSlot: read.finalizedSlot,
82278
+ anchors: [read, ...read.retainedAnchors].map((a) => ({ epoch: BigInt(a.epoch), anchorIndex: BigInt(a.anchorIndex), anchorRoot: BigInt(a.anchorRoot) }))
82279
+ });
82280
+ }
82281
+ function quoteAnchorOfOffer(offer) {
82282
+ try {
82283
+ const extra = JSON.parse(offer.outboundJson).paymentRequirements.extra;
82284
+ const field4 = (value2) => typeof value2 === "string" && /^(0|[1-9][0-9]*)$/.test(value2) ? BigInt(value2) : void 0;
82285
+ const anchor = { epoch: field4(extra.epoch), anchorIndex: field4(extra.anchorIndex), anchorRoot: field4(extra.anchorRoot) };
82286
+ return Object.values(anchor).includes(void 0) ? void 0 : anchor;
82287
+ } catch {
82288
+ return void 0;
82289
+ }
82290
+ }
82272
82291
  function reusableBeforeSettle(offer, chain, elapsedMs) {
82273
82292
  if (!chain || !Number.isFinite(elapsedMs) || elapsedMs < 0 || elapsedMs > PRE_SETTLE_REUSE_MAX_AGE_MS) return false;
82274
82293
  const expiresAt = JSON.parse(offer.outboundJson).sellerAcceptance?.expiresAt;
@@ -82413,14 +82432,14 @@ async function createSellerAdapter({
82413
82432
  anchorPoll = void 0;
82414
82433
  });
82415
82434
  };
82416
- const readCurrentAnchor = async (first) => {
82417
- const isCurrent = (chain2) => chain2.epoch === chain2.chainTimestamp / 300n;
82435
+ const readCurrentAnchor = async (first, quoteAnchor) => {
82436
+ const usable = (chain2) => chain2.epoch === chain2.chainTimestamp / 300n || ringSlotServesPayment(chain2, quoteAnchor);
82418
82437
  const chain = first ?? await readAnchor();
82419
- if (isCurrent(chain)) return chain;
82438
+ if (usable(chain)) return chain;
82420
82439
  await requestFacilitatorAnchor();
82421
82440
  for (let attempt = 1; ; attempt += 1) {
82422
82441
  const next = await readAnchor();
82423
- if (isCurrent(next)) return next;
82442
+ if (usable(next)) return next;
82424
82443
  if (attempt >= ANCHOR_POLL_ATTEMPTS) fail17("anchor_not_ready");
82425
82444
  await sleep4(ANCHOR_POLL_MS);
82426
82445
  }
@@ -82966,7 +82985,7 @@ async function createSellerAdapter({
82966
82985
  }
82967
82986
  const firstIntake = intakeChain !== void 0 && !offer.settleAttempted;
82968
82987
  if (firstIntake) {
82969
- await readCurrentAnchor(intakeChain);
82988
+ await readCurrentAnchor(intakeChain, quoteAnchorOfOffer(offer));
82970
82989
  offer = { ...offer, phase: "settlement_pending", settleAttempted: true };
82971
82990
  await put(nonce, offer);
82972
82991
  mark("first-intake-settle");
@@ -82985,7 +83004,7 @@ async function createSellerAdapter({
82985
83004
  const renewed = await renewPreSettlementAcceptance(nonce, offer, chain);
82986
83005
  if (!renewed) return { status: 202, code: PAYMENT_REFUSED };
82987
83006
  offer = renewed;
82988
- await readCurrentAnchor(chain);
83007
+ await readCurrentAnchor(chain, quoteAnchorOfOffer(offer));
82989
83008
  const verified = await facilitator("verify", offer.outboundJson);
82990
83009
  mark("verify");
82991
83010
  if (verified?.isValid !== true) {
@@ -83174,7 +83193,7 @@ async function createSellerAdapter({
83174
83193
  };
83175
83194
  return { server, handle, close, signerPublicKey, settledTransactions, offerSummaries, discardUnsentOffer };
83176
83195
  }
83177
- var import_web3113, LOOPBACK_ORIGIN, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PROGRAM_DATA_HEADER_BYTES, hashedProgramDataHeaders, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, ANCHOR_BUSY_DEFAULT_SECONDS, ANCHOR_BUSY_MAX_SECONDS, MEMO_PRECOMPUTES_MAX, MEMO_PRECOMPUTE_WAIT_MS, WALLET_MERCHANT_SLOT, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, INTAKE_REUSE_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM, UPSTREAM_FAILED, UPSTREAM_BODY_MAX, upstreamFailure, forwardedContentType, CONFIRMED_TRANSACTION_READ;
83196
+ var import_web3113, LOOPBACK_ORIGIN, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PROGRAM_DATA_HEADER_BYTES, hashedProgramDataHeaders, ringModeReads, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, ANCHOR_BUSY_DEFAULT_SECONDS, ANCHOR_BUSY_MAX_SECONDS, MEMO_PRECOMPUTES_MAX, MEMO_PRECOMPUTE_WAIT_MS, WALLET_MERCHANT_SLOT, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, INTAKE_REUSE_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM, UPSTREAM_FAILED, UPSTREAM_BODY_MAX, upstreamFailure, forwardedContentType, CONFIRMED_TRANSACTION_READ;
83178
83197
  var init_service = __esm({
83179
83198
  "wallet/src/seller/service.mjs"() {
83180
83199
  "use strict";
@@ -83211,6 +83230,7 @@ var init_service = __esm({
83211
83230
  encodeHeader = (v) => Buffer.from(JSON.stringify(v)).toString("base64");
83212
83231
  PROGRAM_DATA_HEADER_BYTES = 45;
83213
83232
  hashedProgramDataHeaders = /* @__PURE__ */ new Map();
83233
+ ringModeReads = /* @__PURE__ */ new WeakSet();
83214
83234
  PAYMENT_REFUSED = "payment_refused_pay_again";
83215
83235
  FACILITATOR_UNDERFUNDED = "facilitator_underfunded";
83216
83236
  DEFINITE_VERIFY_REFUSALS = /* @__PURE__ */ new Set([
@@ -130149,6 +130169,14 @@ function createWalletTools({
130149
130169
  }
130150
130170
  };
130151
130171
  const joinCounts = { sent: 0, final: 0 };
130172
+ const joinWaiters = /* @__PURE__ */ new Set();
130173
+ let joinWakes = 0;
130174
+ const wakeJoinWaiters = () => {
130175
+ joinWakes += 1;
130176
+ const waiting = [...joinWaiters];
130177
+ joinWaiters.clear();
130178
+ for (const resolve38 of waiting) resolve38();
130179
+ };
130152
130180
  const joiner = (typeof ops.joiner === "function" ? ops.joiner : createAutoJoin)({
130153
130181
  session,
130154
130182
  underLease,
@@ -130160,7 +130188,10 @@ function createWalletTools({
130160
130188
  joinCounts.final += 1;
130161
130189
  markJoinIntents("final");
130162
130190
  refreshAtFinality();
130163
- Promise.resolve(finalityWait).finally(() => continueJoinIntents());
130191
+ Promise.resolve(finalityWait).finally(() => {
130192
+ wakeJoinWaiters();
130193
+ continueJoinIntents();
130194
+ });
130164
130195
  },
130165
130196
  onSent: () => {
130166
130197
  joinCounts.sent += 1;
@@ -131228,8 +131259,9 @@ ${canonical5}`;
131228
131259
  if (joined.ready) {
131229
131260
  payJoinSeen.delete(requestId);
131230
131261
  if (canProgress) {
131231
- payFrom = Date.now();
131232
- payStartedAt.set(requestId, payFrom);
131262
+ const startedPay = Date.now();
131263
+ payFrom = Math.min(startedPay, calledAt + joinCallMaxMs + PAY_ANSWER_MARGIN_MS - CALL_BUDGET_MS);
131264
+ payStartedAt.set(requestId, startedPay);
131233
131265
  }
131234
131266
  log(`MCP_PAY_RETRY_IN_CALL requestId=${requestId} ${code2} join`);
131235
131267
  await refreshIfStale((phase, outcome) => mark(phase, Date.now(), outcome));
@@ -134637,6 +134669,7 @@ ${canonical5}`;
134637
134669
  joinWaitingCalls += 1;
134638
134670
  try {
134639
134671
  for (; ; ) {
134672
+ const wakesSeen = joinWakes;
134640
134673
  const step = await each();
134641
134674
  if (step.stop !== void 0) return { end: "stop", value: step.stop };
134642
134675
  if (finalityClosed) return { end: "close" };
@@ -134662,7 +134695,17 @@ ${canonical5}`;
134662
134695
  }
134663
134696
  }
134664
134697
  const toStart = step.atMs - Date.now();
134665
- await Promise.race([sleep2(Math.min(stepMs, Math.max(0, until - Date.now()), toStart > 0 ? toStart + 50 : stepMs)), stopped, wake()]);
134698
+ if (toStart <= 0 && joinWakes !== wakesSeen) continue;
134699
+ let woke;
134700
+ const stepEnded = new Promise((resolve38) => {
134701
+ woke = resolve38;
134702
+ joinWaiters.add(resolve38);
134703
+ });
134704
+ try {
134705
+ await Promise.race([sleep2(Math.min(stepMs, Math.max(0, until - Date.now()), toStart > 0 ? toStart + 50 : stepMs)), stopped, wake(), stepEnded]);
134706
+ } finally {
134707
+ joinWaiters.delete(woke);
134708
+ }
134666
134709
  }
134667
134710
  } finally {
134668
134711
  joinWaitingCalls -= 1;
@@ -139515,7 +139558,7 @@ var init_tools = __esm({
139515
139558
  BALANCE_AFTER_LANDING_MS = 5e3;
139516
139559
  JOIN_CALL_MAX_MS = 95e3;
139517
139560
  JOIN_CALL_ANSWER_MARGIN_S = 5;
139518
- PAY_AFTER_JOIN_MS = CALL_BUDGET_MS - PAY_ANSWER_MARGIN_MS;
139561
+ PAY_AFTER_JOIN_MS = EARLY_ANSWER_MS + PAY_ANSWER_MARGIN_MS;
139519
139562
  joinAnswerSeconds = (maxMs) => Math.ceil(maxMs / 1e3) + JOIN_CALL_ANSWER_MARGIN_S;
139520
139563
  JOIN_TIME_MS = Object.freeze({ joinLikely: 22e3, joinMost: 4e4, sendLikely: 35e3, sendMost: 5e4 });
139521
139564
  JOIN_NUDGE_QUIET_MS = 15e3;