shinjuku-shielded 0.3.29 → 0.3.30
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 +3 -3
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +70 -46
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": "
|
|
5
|
-
"bytes":
|
|
6
|
-
"sourceCommit": "
|
|
4
|
+
"sha256": "a523d67b85ebcfd6f07f653c2a9bde16a7c9d87f908874ddae71cf91083fabc8",
|
|
5
|
+
"bytes": 11177579,
|
|
6
|
+
"sourceCommit": "025c6a4ab1a1c3e38019cdd7843b524a6a90d62a",
|
|
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.
|
|
3
|
+
"version": "0.3.30",
|
|
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": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "a523d67b",
|
|
7
|
+
"shinjukuSha256": "a523d67b85ebcfd6f07f653c2a9bde16a7c9d87f908874ddae71cf91083fabc8",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -91047,6 +91047,36 @@ var init_pay = __esm({
|
|
|
91047
91047
|
}
|
|
91048
91048
|
});
|
|
91049
91049
|
|
|
91050
|
+
// wallet/src/fetch/keepAlive.mjs
|
|
91051
|
+
function proxiedRun() {
|
|
91052
|
+
const env = process.env;
|
|
91053
|
+
return Boolean(env.SHINJUKU_WALLET_PROXIED || env.NODE_USE_ENV_PROXY || env.HTTPS_PROXY || env.HTTP_PROXY || env.https_proxy || env.http_proxy);
|
|
91054
|
+
}
|
|
91055
|
+
function keepAliveDispatcher() {
|
|
91056
|
+
if (shared !== void 0) return shared;
|
|
91057
|
+
try {
|
|
91058
|
+
if (proxiedRun()) return void 0;
|
|
91059
|
+
const global2 = globalThis[GLOBAL_DISPATCHER];
|
|
91060
|
+
if (global2?.constructor?.name !== "Agent") return void 0;
|
|
91061
|
+
shared = new global2.constructor({ keepAliveTimeout: KEEP_ALIVE_MS, keepAliveMaxTimeout: KEEP_ALIVE_MS });
|
|
91062
|
+
return shared;
|
|
91063
|
+
} catch {
|
|
91064
|
+
return void 0;
|
|
91065
|
+
}
|
|
91066
|
+
}
|
|
91067
|
+
function keepAliveInit(init = {}) {
|
|
91068
|
+
const dispatcher = keepAliveDispatcher();
|
|
91069
|
+
return dispatcher === void 0 ? init : { ...init, dispatcher };
|
|
91070
|
+
}
|
|
91071
|
+
var GLOBAL_DISPATCHER, KEEP_ALIVE_MS, shared;
|
|
91072
|
+
var init_keepAlive = __esm({
|
|
91073
|
+
"wallet/src/fetch/keepAlive.mjs"() {
|
|
91074
|
+
"use strict";
|
|
91075
|
+
GLOBAL_DISPATCHER = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
91076
|
+
KEEP_ALIVE_MS = 2e4;
|
|
91077
|
+
}
|
|
91078
|
+
});
|
|
91079
|
+
|
|
91050
91080
|
// wallet/src/pay/floatPay.mjs
|
|
91051
91081
|
import { createHash as createHash20, randomBytes as randomBytes11 } from "node:crypto";
|
|
91052
91082
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
@@ -91140,7 +91170,7 @@ async function readFloatConfig({ origin, fetchImpl = fetch }) {
|
|
|
91140
91170
|
try {
|
|
91141
91171
|
response = await fetchImpl(
|
|
91142
91172
|
new URL("/api/x402/float/config", origin).href,
|
|
91143
|
-
{ method: "GET", redirect: "error", signal: AbortSignal.timeout(CONFIG_TIMEOUT_MS) }
|
|
91173
|
+
keepAliveInit({ method: "GET", redirect: "error", signal: AbortSignal.timeout(CONFIG_TIMEOUT_MS) })
|
|
91144
91174
|
);
|
|
91145
91175
|
} catch (error) {
|
|
91146
91176
|
fail18("p03_float_config_unreadable", { cause: error });
|
|
@@ -91271,7 +91301,7 @@ function withSellerResource(xPayment, record) {
|
|
|
91271
91301
|
}
|
|
91272
91302
|
function floatFetch(base, seen) {
|
|
91273
91303
|
return async (target, init = {}) => {
|
|
91274
|
-
const response = await base(target, init);
|
|
91304
|
+
const response = await base(target, keepAliveInit(init));
|
|
91275
91305
|
const paid = Object.keys(init.headers ?? {}).some((name) => name.toLowerCase() === "payment-signature");
|
|
91276
91306
|
if (paid || response.status === 402 || response.status < 400) return response;
|
|
91277
91307
|
let answer;
|
|
@@ -91469,13 +91499,13 @@ async function payViaFloat({
|
|
|
91469
91499
|
mark("seller-sent");
|
|
91470
91500
|
let response;
|
|
91471
91501
|
try {
|
|
91472
|
-
response = await fetchImpl(record.url, {
|
|
91502
|
+
response = await fetchImpl(record.url, keepAliveInit({
|
|
91473
91503
|
method: record.request.method,
|
|
91474
91504
|
headers: { ...Object.fromEntries(record.request.headers), "PAYMENT-SIGNATURE": record.xPayment },
|
|
91475
91505
|
...record.request.method === "POST" ? { body: Buffer.from(record.request.bodyBase64, "base64") } : {},
|
|
91476
91506
|
redirect: "error",
|
|
91477
91507
|
signal: AbortSignal.timeout(SELLER_TIMEOUT_MS)
|
|
91478
|
-
});
|
|
91508
|
+
}));
|
|
91479
91509
|
} catch (error) {
|
|
91480
91510
|
fail18("p03_float_seller_unanswered_retry_same_request", { cause: error, floatId: record.floatId });
|
|
91481
91511
|
}
|
|
@@ -91548,6 +91578,7 @@ var init_floatPay = __esm({
|
|
|
91548
91578
|
init_http();
|
|
91549
91579
|
init_ShieldedSolanaP03QuoteCrypto();
|
|
91550
91580
|
init_chain2();
|
|
91581
|
+
init_keepAlive();
|
|
91551
91582
|
init_notes2();
|
|
91552
91583
|
init_pay();
|
|
91553
91584
|
init_quote2();
|
|
@@ -91934,7 +91965,7 @@ async function assertRefusedPaymentsCannotLand({ store, walName: walName2, payme
|
|
|
91934
91965
|
resolve38("proved-dead");
|
|
91935
91966
|
}
|
|
91936
91967
|
}
|
|
91937
|
-
async function finalizePendingReceipt({ store, connection, programId, name, timeoutMs, pollMs, deps = {} }) {
|
|
91968
|
+
async function finalizePendingReceipt({ store, connection, programId, name, timeoutMs, pollMs, deps = {}, shared: shared2 }) {
|
|
91938
91969
|
const sleep5 = deps.sleep ?? ((ms) => new Promise((resolve38) => setTimeout(resolve38, ms)));
|
|
91939
91970
|
const now = deps.now ?? Date.now;
|
|
91940
91971
|
const deadline = now() + timeoutMs;
|
|
@@ -91944,6 +91975,20 @@ async function finalizePendingReceipt({ store, connection, programId, name, time
|
|
|
91944
91975
|
const record = store.readWal(name);
|
|
91945
91976
|
if (!isPending(record)) return record;
|
|
91946
91977
|
if (!connection || !programId || typeof deps.walkHistory !== "function") fail19("receipt_finality_needs_chain");
|
|
91978
|
+
if (!gated && shared2?.history !== void 0) {
|
|
91979
|
+
gated = true;
|
|
91980
|
+
const { clock: clock3, history: history2 } = shared2;
|
|
91981
|
+
const settlement2 = settlementInHistory(history2, record.paymentHeader, store.state, programId);
|
|
91982
|
+
markPhase("walk-shared");
|
|
91983
|
+
if (settlement2) return writeFinalized(store, name, record, settlement2);
|
|
91984
|
+
if (!paymentBlockerAt(record, clock3, history2)) {
|
|
91985
|
+
const dead = { ...record, receiptFinality: "never-finalized" };
|
|
91986
|
+
store.writeWal(name, dead);
|
|
91987
|
+
return dead;
|
|
91988
|
+
}
|
|
91989
|
+
strict = true;
|
|
91990
|
+
continue;
|
|
91991
|
+
}
|
|
91947
91992
|
if (!gated) {
|
|
91948
91993
|
gated = true;
|
|
91949
91994
|
const answeredLongAgo = Number.isSafeInteger(record.answeredAtMs) && Date.now() - record.answeredAtMs >= FINALITY_GATE_SKIP_AFTER_MS;
|
|
@@ -91962,13 +92007,9 @@ async function finalizePendingReceipt({ store, connection, programId, name, time
|
|
|
91962
92007
|
await (strict ? withStrictHistorySource(() => deps.walkHistory()) : deps.walkHistory())
|
|
91963
92008
|
);
|
|
91964
92009
|
markPhase("walk");
|
|
92010
|
+
if (shared2) Object.assign(shared2, { clock: clock2, history });
|
|
91965
92011
|
const settlement = settlementInHistory(history, record.paymentHeader, store.state, programId);
|
|
91966
|
-
if (settlement)
|
|
91967
|
-
const settledTransaction = settlement.provenance?.signature;
|
|
91968
|
-
const finalized = settledTransaction === record.receipt.transaction ? { ...record, receiptFinality: "finalized" } : { ...record, receiptFinality: "finalized", receiptMismatch: "transaction", settledTransaction };
|
|
91969
|
-
store.writeWal(name, finalized);
|
|
91970
|
-
return finalized;
|
|
91971
|
-
}
|
|
92012
|
+
if (settlement) return writeFinalized(store, name, record, settlement);
|
|
91972
92013
|
if (!paymentBlockerAt(record, clock2, history)) {
|
|
91973
92014
|
const dead = { ...record, receiptFinality: "never-finalized" };
|
|
91974
92015
|
store.writeWal(name, dead);
|
|
@@ -91978,6 +92019,12 @@ async function finalizePendingReceipt({ store, connection, programId, name, time
|
|
|
91978
92019
|
await sleep5(pollMs);
|
|
91979
92020
|
}
|
|
91980
92021
|
}
|
|
92022
|
+
function writeFinalized(store, name, record, settlement) {
|
|
92023
|
+
const settledTransaction = settlement.provenance?.signature;
|
|
92024
|
+
const finalized = settledTransaction === record.receipt.transaction ? { ...record, receiptFinality: "finalized" } : { ...record, receiptFinality: "finalized", receiptMismatch: "transaction", settledTransaction };
|
|
92025
|
+
store.writeWal(name, finalized);
|
|
92026
|
+
return finalized;
|
|
92027
|
+
}
|
|
91981
92028
|
async function awaitResourceReceiptFinality({
|
|
91982
92029
|
store,
|
|
91983
92030
|
connection,
|
|
@@ -92208,13 +92255,13 @@ async function payResourceOnce({
|
|
|
92208
92255
|
rpcUrl: pocket.rpcUrl,
|
|
92209
92256
|
readResult,
|
|
92210
92257
|
deps: pocket.deps ?? {},
|
|
92211
|
-
send: (paymentHeaders) => (deps.fetchImpl ?? fetch)(url, {
|
|
92258
|
+
send: (paymentHeaders) => (deps.fetchImpl ?? fetch)(url, keepAliveInit({
|
|
92212
92259
|
method: suppliedRequest.method,
|
|
92213
92260
|
headers: { ...Object.fromEntries(suppliedRequest.headers), ...paymentHeaders },
|
|
92214
92261
|
...suppliedRequest.method === "POST" ? { body: Buffer.from(suppliedRequest.bodyBase64, "base64") } : {},
|
|
92215
92262
|
redirect: "error",
|
|
92216
92263
|
signal: AbortSignal.timeout(12e4)
|
|
92217
|
-
})
|
|
92264
|
+
}))
|
|
92218
92265
|
});
|
|
92219
92266
|
if (!record && store.readWal(pocketPaymentWalName(requestKey))) {
|
|
92220
92267
|
if (!pocket) fail19("pocket_payment_needs_rpc");
|
|
@@ -92272,13 +92319,13 @@ async function payResourceOnce({
|
|
|
92272
92319
|
}
|
|
92273
92320
|
let requestData = record?.request ?? suppliedRequest;
|
|
92274
92321
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
92275
|
-
const request = (paymentHeaders = {}) => fetchImpl(url, {
|
|
92322
|
+
const request = (paymentHeaders = {}) => fetchImpl(url, keepAliveInit({
|
|
92276
92323
|
method: requestData.method,
|
|
92277
92324
|
headers: { ...Object.fromEntries(requestData.headers), ...paymentHeaders },
|
|
92278
92325
|
...requestData.method === "POST" ? { body: Buffer.from(requestData.bodyBase64, "base64") } : {},
|
|
92279
92326
|
redirect: "error",
|
|
92280
92327
|
signal: AbortSignal.timeout(12e4)
|
|
92281
|
-
});
|
|
92328
|
+
}));
|
|
92282
92329
|
const challengeSleep = deps.sleep ?? ((ms) => new Promise((resolve38) => setTimeout(resolve38, ms)));
|
|
92283
92330
|
let prefetched = !record && typeof sellerChallenge === "string" && sellerChallenge.length > 0 && sellerChallenge.length <= 128 * 1024 ? sellerChallenge : void 0;
|
|
92284
92331
|
const requestChallenge = async () => {
|
|
@@ -92314,11 +92361,11 @@ async function payResourceOnce({
|
|
|
92314
92361
|
};
|
|
92315
92362
|
const held = /* @__PURE__ */ new Set();
|
|
92316
92363
|
const deferred = [];
|
|
92317
|
-
const settlePrior = async (name) => {
|
|
92364
|
+
const settlePrior = async (name, shared2) => {
|
|
92318
92365
|
let other = store.readWal(name);
|
|
92319
92366
|
if (isPending(other)) {
|
|
92320
92367
|
mark("prior-finality-wait");
|
|
92321
|
-
other = await withPhaseScope(mark, "fin", () => finalizePendingReceipt({ store, connection, programId, name, ...finalityWait, deps: finality }));
|
|
92368
|
+
other = await withPhaseScope(mark, "fin", () => finalizePendingReceipt({ store, connection, programId, name, ...finalityWait, deps: finality, shared: shared2 }));
|
|
92322
92369
|
if (isPending(other)) failUnresolved(other);
|
|
92323
92370
|
mark("prior-finality-done");
|
|
92324
92371
|
}
|
|
@@ -92483,7 +92530,9 @@ async function payResourceOnce({
|
|
|
92483
92530
|
const noProof = store.readWal(`resource-proof-${requestKey}`)?.proved === void 0;
|
|
92484
92531
|
if (noProof && deferred.length > 0 && /^p03_merchant_respend_inputs_held_by_pending_payment/.test(message)) {
|
|
92485
92532
|
mark("prior-finality-fallback");
|
|
92486
|
-
|
|
92533
|
+
const answeredAt = (name) => store.readWal(name)?.answeredAtMs ?? 0;
|
|
92534
|
+
const shared2 = {};
|
|
92535
|
+
for (const name of deferred.splice(0).sort((a, b) => answeredAt(b) - answeredAt(a))) await settlePrior(name, shared2);
|
|
92487
92536
|
held.clear();
|
|
92488
92537
|
continue;
|
|
92489
92538
|
}
|
|
@@ -92601,6 +92650,7 @@ var init_payResource = __esm({
|
|
|
92601
92650
|
init_anchorWait();
|
|
92602
92651
|
init_anchorClock();
|
|
92603
92652
|
init_requestId();
|
|
92653
|
+
init_keepAlive();
|
|
92604
92654
|
fail19 = (reason) => {
|
|
92605
92655
|
throw new Error(`p03_resource_payment_${reason}`);
|
|
92606
92656
|
};
|
|
@@ -117728,40 +117778,14 @@ init_payResource();
|
|
|
117728
117778
|
init_quote2();
|
|
117729
117779
|
init_floatPay();
|
|
117730
117780
|
init_walletHistory();
|
|
117731
|
-
|
|
117732
|
-
|
|
117733
|
-
// wallet/src/fetch/keepAlive.mjs
|
|
117734
|
-
var GLOBAL_DISPATCHER = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
117735
|
-
var KEEP_ALIVE_MS = 2e4;
|
|
117736
|
-
var shared;
|
|
117737
|
-
function proxiedRun() {
|
|
117738
|
-
const env = process.env;
|
|
117739
|
-
return Boolean(env.SHINJUKU_WALLET_PROXIED || env.NODE_USE_ENV_PROXY || env.HTTPS_PROXY || env.HTTP_PROXY || env.https_proxy || env.http_proxy);
|
|
117740
|
-
}
|
|
117741
|
-
function keepAliveDispatcher() {
|
|
117742
|
-
if (shared !== void 0) return shared;
|
|
117743
|
-
try {
|
|
117744
|
-
if (proxiedRun()) return void 0;
|
|
117745
|
-
const global2 = globalThis[GLOBAL_DISPATCHER];
|
|
117746
|
-
if (global2?.constructor?.name !== "Agent") return void 0;
|
|
117747
|
-
shared = new global2.constructor({ keepAliveTimeout: KEEP_ALIVE_MS, keepAliveMaxTimeout: KEEP_ALIVE_MS });
|
|
117748
|
-
return shared;
|
|
117749
|
-
} catch {
|
|
117750
|
-
return void 0;
|
|
117751
|
-
}
|
|
117752
|
-
}
|
|
117753
|
-
function keepAliveInit(init = {}) {
|
|
117754
|
-
const dispatcher = keepAliveDispatcher();
|
|
117755
|
-
return dispatcher === void 0 ? init : { ...init, dispatcher };
|
|
117756
|
-
}
|
|
117757
|
-
|
|
117758
|
-
// wallet/src/fetch/payAndFetch.mjs
|
|
117781
|
+
init_keepAlive();
|
|
117759
117782
|
init_phaseTiming();
|
|
117760
117783
|
init_chain2();
|
|
117761
117784
|
init_processLease();
|
|
117762
117785
|
init_store();
|
|
117763
117786
|
init_proxy();
|
|
117764
117787
|
init_book();
|
|
117788
|
+
import { randomBytes as randomBytes12 } from "node:crypto";
|
|
117765
117789
|
|
|
117766
117790
|
// wallet/src/caps/spendPolicy.mjs
|
|
117767
117791
|
init_book();
|