shinjuku-shield 0.3.224 → 0.3.225

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
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
5
5
  not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
6
6
  a terminal. Only you hold the keys: they never leave your computer.
7
7
 
8
- This is version 0.3.224. The command is `shinjuku`.
8
+ This is version 0.3.225. The command is `shinjuku`.
9
9
 
10
10
  ## Set up
11
11
 
12
12
  ```sh
13
- npx -y shinjuku@0.3.224 setup
13
+ npx -y shinjuku@0.3.225 setup
14
14
  ```
15
15
 
16
16
  Setup does every step for you:
@@ -100,7 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
100
100
  Claude Code:
101
101
 
102
102
  ```sh
103
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.224 mcp
103
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.225 mcp
104
104
  ```
105
105
 
106
106
  ## For builders: check what you install
@@ -116,7 +116,7 @@ with the Releases table in
116
116
  Versions are published from GitHub Actions with npm provenance.
117
117
 
118
118
  `shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
119
- 0.3.224, its older name, runs this package at the same version, so wallets
119
+ 0.3.225, its older name, runs this package at the same version, so wallets
120
120
  installed under that name keep updating. New installs use `shinjuku`.
121
121
 
122
122
  The full guide is
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": "1d84992b84ede1559b296b31a0d0a67d0551a6dfb14a97830b10f019a71147a4",
5
- "bytes": 10309158,
6
- "sourceCommit": "f770bc410e82af84b537f8e55313af223dfe1bfb",
4
+ "sha256": "2b4f7b515193776162ffe330459c1be523d10c064f6da6d8d73cfb56581b4906",
5
+ "bytes": 10323486,
6
+ "sourceCommit": "226de414116943b6c9f83a963f099a34d7873fd0",
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",
@@ -1075,8 +1075,8 @@
1075
1075
  ],
1076
1076
  "seller": {
1077
1077
  "file": "shinjuku-seller.mjs",
1078
- "sha256": "e785def47b04adc745e1539616d38392c7e0ce990399d94cb20d7215122c26d6",
1079
- "bytes": 4188398,
1078
+ "sha256": "a1f1b00d8de3d75034777fa24c1aeda4d09ba8b8b5fd1f83cab7acf3ecf23e5d",
1079
+ "bytes": 4190663,
1080
1080
  "entry": "wallet/src/seller/exact/index.mjs",
1081
1081
  "external": [
1082
1082
  "@x402/core/http",
@@ -1968,5 +1968,5 @@
1968
1968
  }
1969
1969
  ]
1970
1970
  },
1971
- "publishedAt": "2026-11-12T18:01:50.905Z"
1971
+ "publishedAt": "2026-11-12T19:05:06.986Z"
1972
1972
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.224",
3
+ "version": "0.3.225",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
5
5
  "description": "Shinjuku Shield, private x402 payments 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": "1d84992b",
7
- "shinjukuSha256": "1d84992b84ede1559b296b31a0d0a67d0551a6dfb14a97830b10f019a71147a4",
6
+ "shinjukuRelease": "2b4f7b51",
7
+ "shinjukuSha256": "2b4f7b515193776162ffe330459c1be523d10c064f6da6d8d73cfb56581b4906",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shield",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -33049,9 +33049,23 @@ import { execFile } from "node:child_process";
33049
33049
  import { hostname } from "node:os";
33050
33050
  import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
33051
33051
  import { link, mkdir, open, readFile as readFile2, rename, unlink } from "node:fs/promises";
33052
- import { promisify } from "node:util";
33053
33052
  import { once } from "node:events";
33054
33053
  import { Worker } from "node:worker_threads";
33054
+ function processStartCommand(pid, platform = process.platform) {
33055
+ if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
33056
+ if (platform === "win32") {
33057
+ return { file: "powershell.exe", args: [
33058
+ "-NoProfile",
33059
+ "-NonInteractive",
33060
+ "-Command",
33061
+ `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`
33062
+ ], options: { windowsHide: true, timeout: 1e4 } };
33063
+ }
33064
+ if (platform === "darwin") {
33065
+ return { file: "/bin/ps", args: ["-o", "lstart=", "-p", String(pid)], options: { env: { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, timeout: 1e4 } };
33066
+ }
33067
+ return void 0;
33068
+ }
33055
33069
  async function processStart(pid) {
33056
33070
  if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
33057
33071
  try {
@@ -33060,31 +33074,15 @@ async function processStart(pid) {
33060
33074
  readFile2(`/proc/${pid}/stat`, "utf8"),
33061
33075
  readFile2("/proc/sys/kernel/random/boot_id", "utf8")
33062
33076
  ]);
33063
- const start = stat2.slice(stat2.lastIndexOf(")") + 1).trim().split(/\s+/)[19];
33064
- return start && boot.trim() ? `${boot.trim()}:${start}` : void 0;
33065
- }
33066
- if (process.platform === "win32") {
33067
- const { stdout } = await run(
33068
- "powershell.exe",
33069
- [
33070
- "-NoProfile",
33071
- "-NonInteractive",
33072
- "-Command",
33073
- `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`
33074
- ],
33075
- { windowsHide: true, timeout: 1e4 }
33076
- );
33077
- return /^\d+$/.test(stdout.trim()) ? stdout.trim() : void 0;
33078
- }
33079
- if (process.platform === "darwin") {
33080
- const { stdout } = await run(
33081
- "/bin/ps",
33082
- ["-o", "lstart=", "-p", String(pid)],
33083
- { env: { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, timeout: 1e4 }
33084
- );
33085
- const start = stdout.trim().replace(/\s+/g, " ");
33086
- return /^[A-Z][a-z]{2} [A-Z][a-z]{2} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}$/.test(start) ? start : void 0;
33087
- }
33077
+ const start2 = stat2.slice(stat2.lastIndexOf(")") + 1).trim().split(/\s+/)[19];
33078
+ return start2 && boot.trim() ? `${boot.trim()}:${start2}` : void 0;
33079
+ }
33080
+ const command = processStartCommand(pid);
33081
+ if (command === void 0) return void 0;
33082
+ const { stdout } = await run(command.file, command.args, command.options);
33083
+ if (process.platform === "win32") return /^\d+$/.test(stdout.trim()) ? stdout.trim() : void 0;
33084
+ const start = stdout.trim().replace(/\s+/g, " ");
33085
+ return /^[A-Z][a-z]{2} [A-Z][a-z]{2} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}$/.test(start) ? start : void 0;
33088
33086
  } catch {
33089
33087
  }
33090
33088
  return void 0;
@@ -33286,12 +33284,11 @@ async function removeIfToken(path, token) {
33286
33284
  await remove(aside);
33287
33285
  return false;
33288
33286
  }
33289
- var run, HEARTBEAT_MS, DEFAULT_STALE_MS, POLL_MS, MARKER_ABANDONED_MS, BEAT_THREAD, sleep, heartbeatPath, readBeat, locked, absent, remove, ownStart, LEASE_ROLES, leaseRole, LEASE_POLL_MS, WANT_FRESH_MS, WANT_STALE_MS;
33287
+ var HEARTBEAT_MS, DEFAULT_STALE_MS, POLL_MS, MARKER_ABANDONED_MS, BEAT_THREAD, sleep, heartbeatPath, readBeat, locked, absent, remove, run, ownStart, LEASE_ROLES, leaseRole, LEASE_POLL_MS, WANT_FRESH_MS, WANT_STALE_MS;
33290
33288
  var init_processLease = __esm({
33291
33289
  "wallet/src/store/processLease.mjs"() {
33292
33290
  "use strict";
33293
33291
  init_fs();
33294
- run = promisify(execFile);
33295
33292
  HEARTBEAT_MS = 1e3;
33296
33293
  DEFAULT_STALE_MS = 1e4;
33297
33294
  POLL_MS = 100;
@@ -33321,6 +33318,9 @@ var init_processLease = __esm({
33321
33318
  remove = (path) => unlink(path).catch((error) => {
33322
33319
  if (!absent(error)) throw error;
33323
33320
  });
33321
+ run = (file, args, options) => new Promise((resolveRun, rejectRun) => {
33322
+ execFile(file, args, options, (error, stdout, stderr) => error ? rejectRun(error) : resolveRun({ stdout, stderr }));
33323
+ });
33324
33324
  LEASE_ROLES = Object.freeze(["agent-app", "terminal", "local-ai"]);
33325
33325
  LEASE_POLL_MS = 1e3;
33326
33326
  WANT_FRESH_MS = 3 * LEASE_POLL_MS;
@@ -34884,6 +34884,21 @@ var init_keepAlive = __esm({
34884
34884
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
34885
34885
  import net from "node:net";
34886
34886
  import { Duplex } from "node:stream";
34887
+ function claimTunnelOpen() {
34888
+ const claim = tunnelOpenListener.getStore();
34889
+ if (claim === void 0 || claim.claimed) return void 0;
34890
+ claim.claimed = true;
34891
+ return claim;
34892
+ }
34893
+ function releaseTunnelOpen(claim) {
34894
+ if (claim) claim.claimed = false;
34895
+ }
34896
+ function tunnelOpened(claim, socket) {
34897
+ try {
34898
+ claim?.onOpen(socket);
34899
+ } catch {
34900
+ }
34901
+ }
34887
34902
  function claimTunnelSignal() {
34888
34903
  const claim = tunnelSignal.getStore();
34889
34904
  if (claim === void 0 || claim.claimed || claim.signal.aborted) return void 0;
@@ -34899,8 +34914,19 @@ function tunnelClient(Dispatcher, proxyPort, proxyHost) {
34899
34914
  return {
34900
34915
  async connect(params) {
34901
34916
  const target = String(params?.path ?? "");
34902
- if (optimisticTarget(target)) return optimisticConnect(params, { proxyHost, proxyPort, closedInRow });
34903
- if (runEnded()) throw runEndedError();
34917
+ const onOpen = claimTunnelOpen();
34918
+ if (optimisticTarget(target)) {
34919
+ try {
34920
+ return await optimisticConnect(params, { proxyHost, proxyPort, closedInRow, onOpen });
34921
+ } catch (error) {
34922
+ releaseTunnelOpen(onOpen);
34923
+ throw error;
34924
+ }
34925
+ }
34926
+ if (runEnded()) {
34927
+ releaseTunnelOpen(onOpen);
34928
+ throw runEndedError();
34929
+ }
34904
34930
  const own = claimTunnelSignal();
34905
34931
  const signal = own === void 0 ? params?.signal : params?.signal ? AbortSignal.any([params.signal, own]) : own;
34906
34932
  const startedAt = Date.now();
@@ -34908,8 +34934,10 @@ function tunnelClient(Dispatcher, proxyPort, proxyHost) {
34908
34934
  const answer = await direct.connect(signal === params?.signal ? params : { ...params, signal });
34909
34935
  closedInRow.delete(target);
34910
34936
  if (answer?.socket && typeof answer.socket === "object") tunnelConnectMs.set(answer.socket, Date.now() - startedAt);
34937
+ tunnelOpened(onOpen, answer?.socket);
34911
34938
  return answer;
34912
34939
  } catch (error) {
34940
+ releaseTunnelOpen(onOpen);
34913
34941
  if (error?.code !== "UND_ERR_SOCKET") throw error;
34914
34942
  const closed2 = (closedInRow.get(target) ?? 0) + 1;
34915
34943
  if (closed2 < TUNNEL_CLOSED_TRIES) {
@@ -34946,7 +34974,7 @@ function optimisticTarget(target) {
34946
34974
  function tunnelRefused(statusCode) {
34947
34975
  return Object.assign(new Error(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`), { name: "AbortError", code: "UND_ERR_ABORTED" });
34948
34976
  }
34949
- function optimisticConnect(params, { proxyHost, proxyPort, closedInRow }) {
34977
+ function optimisticConnect(params, { proxyHost, proxyPort, closedInRow, onOpen }) {
34950
34978
  const target = String(params.path);
34951
34979
  const mark = boundMarkPhase();
34952
34980
  const startedAt = Date.now();
@@ -35055,6 +35083,9 @@ ${Object.entries(params.headers ?? {}).filter(([name, value2]) => value2 !== voi
35055
35083
  });
35056
35084
  openTunnelStreams.add(stream);
35057
35085
  stream.once("close", () => openTunnelStreams.delete(stream));
35086
+ stream.once("close", () => {
35087
+ if (!open2) releaseTunnelOpen(onOpen);
35088
+ });
35058
35089
  if (runEnded()) {
35059
35090
  stream.destroy();
35060
35091
  return Promise.reject(runEndedError());
@@ -35115,6 +35146,7 @@ ${Object.entries(params.headers ?? {}).filter(([name, value2]) => value2 !== voi
35115
35146
  }
35116
35147
  mark("tunnel-200", `ms${Date.now() - startedAt}_dial${dials}`);
35117
35148
  open2 = true;
35149
+ tunnelOpened(onOpen, stream);
35118
35150
  closedInRow.delete(target);
35119
35151
  const rest = reply.subarray(end + 4);
35120
35152
  reply = Buffer.alloc(0);
@@ -35176,7 +35208,7 @@ ${Object.entries(params.headers ?? {}).filter(([name, value2]) => value2 !== voi
35176
35208
  throw error;
35177
35209
  });
35178
35210
  }
35179
- var openTunnelStreams, tunnelSignal, circuitProbe, RUN_MARK, tunnelConnectMs, tunnelConnectMsOf, TUNNEL_CLOSED_TRIES, REPLAY_LIMIT;
35211
+ var openTunnelStreams, tunnelSignal, tunnelOpenListener, circuitProbe, RUN_MARK, tunnelConnectMs, tunnelConnectMsOf, TUNNEL_CLOSED_TRIES, REPLAY_LIMIT;
35180
35212
  var init_tunnelGuard = __esm({
35181
35213
  "wallet/src/net/tunnelGuard.mjs"() {
35182
35214
  "use strict";
@@ -35186,6 +35218,7 @@ var init_tunnelGuard = __esm({
35186
35218
  openTunnelStreams = /* @__PURE__ */ new Set();
35187
35219
  registerRunSockets(() => openTunnelStreams);
35188
35220
  tunnelSignal = new AsyncLocalStorage2();
35221
+ tunnelOpenListener = new AsyncLocalStorage2();
35189
35222
  RUN_MARK = "SHINJUKU_WALLET_PROXIED";
35190
35223
  tunnelConnectMs = /* @__PURE__ */ new WeakMap();
35191
35224
  tunnelConnectMsOf = (socket) => socket && typeof socket === "object" ? tunnelConnectMs.get(socket) : void 0;
@@ -79795,6 +79828,7 @@ function controlCheck(home, state2, { circuits = false, halt = false, unref = fa
79795
79828
  let streaming = false;
79796
79829
  let skipping = false;
79797
79830
  let skipCr = false;
79831
+ let block;
79798
79832
  allowOwnTorControlOnce(state2.controlPort);
79799
79833
  let socket;
79800
79834
  try {
@@ -79839,7 +79873,23 @@ AUTHCHALLENGE SAFECOOKIE ${clientNonce.toString("hex")}\r
79839
79873
  skipping = false;
79840
79874
  continue;
79841
79875
  }
79842
- if (line.length > EVENT_LINE_MAX || !line.startsWith("650 ")) continue;
79876
+ if (line.length > EVENT_LINE_MAX) continue;
79877
+ if (block) {
79878
+ if (line === ".") {
79879
+ const { head, lines } = block;
79880
+ block = void 0;
79881
+ try {
79882
+ events(head, lines);
79883
+ } catch {
79884
+ }
79885
+ } else if (block.lines.length < EVENT_BLOCK_LINES) block.lines.push(line);
79886
+ continue;
79887
+ }
79888
+ if (line.startsWith("650+")) {
79889
+ block = { head: `650 ${line.slice(4)}`, lines: [] };
79890
+ continue;
79891
+ }
79892
+ if (!line.startsWith("650 ")) continue;
79843
79893
  try {
79844
79894
  events(line);
79845
79895
  } catch {
@@ -79884,7 +79934,7 @@ AUTHCHALLENGE SAFECOOKIE ${clientNonce.toString("hex")}\r
79884
79934
  }
79885
79935
  if (step === 2 && typeof events === "function") {
79886
79936
  step = 6;
79887
- socket.write("SETEVENTS HS_DESC CIRC STREAM\r\n");
79937
+ socket.write("SETEVENTS HS_DESC HS_DESC_CONTENT CIRC STREAM\r\n");
79888
79938
  continue;
79889
79939
  }
79890
79940
  if (step === 6) {
@@ -80579,6 +80629,7 @@ setTunnelCircuitProbe(async ({ proxyHost, proxyPort } = {}) => {
80579
80629
  return answer && answer.tunnelPort === Number(proxyPort) ? answer.circuits : void 0;
80580
80630
  });
80581
80631
  var EVENT_LINE_MAX = 4096;
80632
+ var EVENT_BLOCK_LINES = 16;
80582
80633
  var TOR_TIMING_MAX = 800;
80583
80634
  var HS_DESC_ACTIONS = /* @__PURE__ */ new Set(["REQUESTED", "RECEIVED", "FAILED"]);
80584
80635
  var HS_DESC_REASONS = /* @__PURE__ */ new Set([
@@ -80634,8 +80685,15 @@ function ownOnionPrefixes() {
80634
80685
  }
80635
80686
  return prefixes;
80636
80687
  }
80637
- function torTimingMark(line, ours) {
80688
+ function torTimingMark(line, ours, lines) {
80638
80689
  const field4 = (name) => new RegExp(`(?:^| )${name}=([A-Z_]+)(?: |$)`).exec(line)?.[1];
80690
+ const content = /^650 HS_DESC_CONTENT ([a-z2-7]{56}) /.exec(line);
80691
+ if (content) {
80692
+ const prefix2 = ours.get(content[1]);
80693
+ if (!prefix2 || !Array.isArray(lines)) return void 0;
80694
+ const revision = lines.map((one) => /^revision-counter (\d{1,20})$/.exec(one)?.[1]).find(Boolean);
80695
+ return { phase: "hs-desc-content", outcome: `onion_${prefix2}_${revision ? `rev${revision}` : lines.every((one) => one === "") ? "empty" : "norev"}` };
80696
+ }
80639
80697
  const desc = /^650 HS_DESC ([A-Z_]+) ([a-z2-7]{56}) /.exec(line);
80640
80698
  if (desc) {
80641
80699
  const prefix2 = ours.get(desc[2]);
@@ -80695,9 +80753,9 @@ function startTorTimingMarks() {
80695
80753
  closeSession();
80696
80754
  }
80697
80755
  };
80698
- session = await controlCheck(home, state2, { unref: true, events: (line) => {
80756
+ session = await controlCheck(home, state2, { unref: true, events: (line, lines) => {
80699
80757
  if (spent) return;
80700
- const one = torTimingMark(line, ours);
80758
+ const one = torTimingMark(line, ours, lines);
80701
80759
  if (one) once2(one.phase, one.outcome);
80702
80760
  } });
80703
80761
  if (!session) return;