@zeroxyz/cli 1.18.0 → 1.20.0
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/dist/index.js +348 -131
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78449,7 +78449,7 @@ init_esm_shims();
|
|
|
78449
78449
|
// ../sdk/dist/index.js
|
|
78450
78450
|
init_esm_shims();
|
|
78451
78451
|
|
|
78452
|
-
// ../sdk/dist/chunk-
|
|
78452
|
+
// ../sdk/dist/chunk-FWHVWIO2.js
|
|
78453
78453
|
init_esm_shims();
|
|
78454
78454
|
|
|
78455
78455
|
// ../../node_modules/.pnpm/viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@6.0.6_zod@4.3.6/node_modules/viem/_esm/index.js
|
|
@@ -117572,69 +117572,6 @@ function createSIWxClientHook(signer) {
|
|
|
117572
117572
|
};
|
|
117573
117573
|
}
|
|
117574
117574
|
|
|
117575
|
-
// ../../node_modules/.pnpm/@x402+fetch@2.9.0_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@6.0.6/node_modules/@x402/fetch/dist/esm/index.mjs
|
|
117576
|
-
init_esm_shims();
|
|
117577
|
-
function wrapFetchWithPayment(fetch2, client) {
|
|
117578
|
-
const httpClient = client instanceof x402HTTPClient ? client : new x402HTTPClient(client);
|
|
117579
|
-
return async (input, init) => {
|
|
117580
|
-
const request3 = new Request(input, init);
|
|
117581
|
-
const clonedRequest = request3.clone();
|
|
117582
|
-
const response = await fetch2(request3);
|
|
117583
|
-
if (response.status !== 402) {
|
|
117584
|
-
return response;
|
|
117585
|
-
}
|
|
117586
|
-
let paymentRequired;
|
|
117587
|
-
try {
|
|
117588
|
-
const getHeader = (name) => response.headers.get(name);
|
|
117589
|
-
let body;
|
|
117590
|
-
try {
|
|
117591
|
-
const responseText = await response.text();
|
|
117592
|
-
if (responseText) {
|
|
117593
|
-
body = JSON.parse(responseText);
|
|
117594
|
-
}
|
|
117595
|
-
} catch {
|
|
117596
|
-
}
|
|
117597
|
-
paymentRequired = httpClient.getPaymentRequiredResponse(getHeader, body);
|
|
117598
|
-
} catch (error48) {
|
|
117599
|
-
throw new Error(
|
|
117600
|
-
`Failed to parse payment requirements: ${error48 instanceof Error ? error48.message : "Unknown error"}`
|
|
117601
|
-
);
|
|
117602
|
-
}
|
|
117603
|
-
const hookHeaders = await httpClient.handlePaymentRequired(paymentRequired);
|
|
117604
|
-
if (hookHeaders) {
|
|
117605
|
-
const hookRequest = clonedRequest.clone();
|
|
117606
|
-
for (const [key, value] of Object.entries(hookHeaders)) {
|
|
117607
|
-
hookRequest.headers.set(key, value);
|
|
117608
|
-
}
|
|
117609
|
-
const hookResponse = await fetch2(hookRequest);
|
|
117610
|
-
if (hookResponse.status !== 402) {
|
|
117611
|
-
return hookResponse;
|
|
117612
|
-
}
|
|
117613
|
-
}
|
|
117614
|
-
let paymentPayload;
|
|
117615
|
-
try {
|
|
117616
|
-
paymentPayload = await client.createPaymentPayload(paymentRequired);
|
|
117617
|
-
} catch (error48) {
|
|
117618
|
-
throw new Error(
|
|
117619
|
-
`Failed to create payment payload: ${error48 instanceof Error ? error48.message : "Unknown error"}`
|
|
117620
|
-
);
|
|
117621
|
-
}
|
|
117622
|
-
const paymentHeaders = httpClient.encodePaymentSignatureHeader(paymentPayload);
|
|
117623
|
-
if (clonedRequest.headers.has("PAYMENT-SIGNATURE") || clonedRequest.headers.has("X-PAYMENT")) {
|
|
117624
|
-
throw new Error("Payment already attempted");
|
|
117625
|
-
}
|
|
117626
|
-
for (const [key, value] of Object.entries(paymentHeaders)) {
|
|
117627
|
-
clonedRequest.headers.set(key, value);
|
|
117628
|
-
}
|
|
117629
|
-
clonedRequest.headers.set(
|
|
117630
|
-
"Access-Control-Expose-Headers",
|
|
117631
|
-
"PAYMENT-RESPONSE,X-PAYMENT-RESPONSE"
|
|
117632
|
-
);
|
|
117633
|
-
const secondResponse = await fetch2(clonedRequest);
|
|
117634
|
-
return secondResponse;
|
|
117635
|
-
};
|
|
117636
|
-
}
|
|
117637
|
-
|
|
117638
117575
|
// ../../node_modules/.pnpm/mppx@0.6.9_@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6__expr_0954cd65f6aa59a781b5373f235842da/node_modules/mppx/dist/index.js
|
|
117639
117576
|
init_esm_shims();
|
|
117640
117577
|
|
|
@@ -143831,37 +143768,41 @@ config(en_default2());
|
|
|
143831
143768
|
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
|
|
143832
143769
|
var zod_default = external_exports3;
|
|
143833
143770
|
|
|
143834
|
-
// ../sdk/dist/chunk-
|
|
143835
|
-
var createManagedAccount = (client, address2) =>
|
|
143836
|
-
|
|
143837
|
-
|
|
143838
|
-
|
|
143839
|
-
|
|
143840
|
-
|
|
143841
|
-
|
|
143842
|
-
|
|
143843
|
-
|
|
143844
|
-
|
|
143845
|
-
|
|
143846
|
-
|
|
143847
|
-
|
|
143848
|
-
|
|
143849
|
-
|
|
143850
|
-
|
|
143851
|
-
|
|
143852
|
-
|
|
143853
|
-
|
|
143854
|
-
|
|
143855
|
-
|
|
143856
|
-
|
|
143857
|
-
|
|
143858
|
-
|
|
143859
|
-
|
|
143860
|
-
|
|
143861
|
-
|
|
143862
|
-
|
|
143863
|
-
|
|
143864
|
-
|
|
143771
|
+
// ../sdk/dist/chunk-FWHVWIO2.js
|
|
143772
|
+
var createManagedAccount = (client, address2, opts = {}) => {
|
|
143773
|
+
const signOptions = {
|
|
143774
|
+
// expectedAddress pins verification to this adapter's frozen address.
|
|
143775
|
+
expectedAddress: address2,
|
|
143776
|
+
...opts.explicitWallet ? { walletAddress: address2 } : {}
|
|
143777
|
+
};
|
|
143778
|
+
return toAccount({
|
|
143779
|
+
address: address2,
|
|
143780
|
+
async signMessage({ message: message2 }) {
|
|
143781
|
+
return await client.auth.signMessage({ message: message2 }, signOptions);
|
|
143782
|
+
},
|
|
143783
|
+
async signTypedData(typedData) {
|
|
143784
|
+
const td = typedData;
|
|
143785
|
+
return await client.auth.signTypedData(
|
|
143786
|
+
{
|
|
143787
|
+
domain: td.domain,
|
|
143788
|
+
types: td.types,
|
|
143789
|
+
primaryType: td.primaryType,
|
|
143790
|
+
message: td.message
|
|
143791
|
+
},
|
|
143792
|
+
signOptions
|
|
143793
|
+
);
|
|
143794
|
+
},
|
|
143795
|
+
async signTransaction(transaction, options) {
|
|
143796
|
+
const serialize13 = options?.serializer ?? serializeTransaction;
|
|
143797
|
+
const unsigned = await serialize13(transaction);
|
|
143798
|
+
const signature2 = await client.auth.signTransaction(
|
|
143799
|
+
{ unsignedTransaction: unsigned },
|
|
143800
|
+
signOptions
|
|
143801
|
+
);
|
|
143802
|
+
return await serialize13(transaction, parseSignature2(signature2));
|
|
143803
|
+
}
|
|
143804
|
+
});
|
|
143805
|
+
};
|
|
143865
143806
|
var USDC_BASE = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
|
|
143866
143807
|
var USDC_TEMPO = "0x20c000000000000000000000b9537d11c60e8b50";
|
|
143867
143808
|
var TEMPO_CHAIN_ID = 4217;
|
|
@@ -144438,12 +144379,12 @@ var cancelBody = (response) => {
|
|
|
144438
144379
|
} catch {
|
|
144439
144380
|
}
|
|
144440
144381
|
};
|
|
144441
|
-
var resolveAccount = async (client, overrideAccount, signal) => {
|
|
144382
|
+
var resolveAccount = async (client, overrideAccount, signal, walletAddress) => {
|
|
144442
144383
|
if (overrideAccount) return overrideAccount;
|
|
144443
144384
|
const credentials = client.getCredentials();
|
|
144444
144385
|
if (credentials.kind === "account") return credentials.account;
|
|
144445
144386
|
if (credentials.kind === "session") {
|
|
144446
|
-
return await client.resolveManagedAccount(signal);
|
|
144387
|
+
return await client.resolveManagedAccount(signal, walletAddress);
|
|
144447
144388
|
}
|
|
144448
144389
|
throw new ZeroAuthError(
|
|
144449
144390
|
"auth_no_credentials",
|
|
@@ -144489,9 +144430,13 @@ var Payments = class {
|
|
|
144489
144430
|
const account = await resolveAccount(
|
|
144490
144431
|
this.client,
|
|
144491
144432
|
input.account,
|
|
144492
|
-
input.signal
|
|
144433
|
+
input.signal,
|
|
144434
|
+
input.walletAddress
|
|
144493
144435
|
);
|
|
144494
144436
|
let capturedAmount = null;
|
|
144437
|
+
let pendingAmountUnits = 0n;
|
|
144438
|
+
let identityChallengeHandled = false;
|
|
144439
|
+
let paidChallengeHandled = false;
|
|
144495
144440
|
let capturedNetwork;
|
|
144496
144441
|
let preflightError = null;
|
|
144497
144442
|
const x402 = registerExactEvmScheme(new x402Client(), { signer: account });
|
|
@@ -144520,11 +144465,25 @@ var Payments = class {
|
|
|
144520
144465
|
};
|
|
144521
144466
|
}
|
|
144522
144467
|
const rawAmountUnits = BigInt(rawAmount);
|
|
144523
|
-
|
|
144468
|
+
pendingAmountUnits = rawAmountUnits;
|
|
144469
|
+
const challengeAmount = formatUnits(rawAmountUnits, 6);
|
|
144470
|
+
if (rawAmountUnits === 0n) {
|
|
144471
|
+
if (identityChallengeHandled || paidChallengeHandled) {
|
|
144472
|
+
return {
|
|
144473
|
+
abort: true,
|
|
144474
|
+
reason: "Only one zero-value identity challenge is allowed, and it must precede payment."
|
|
144475
|
+
};
|
|
144476
|
+
}
|
|
144477
|
+
} else if (paidChallengeHandled) {
|
|
144478
|
+
return {
|
|
144479
|
+
abort: true,
|
|
144480
|
+
reason: "A positive-value x402 payment was already attempted for this fetch; refusing a second charge."
|
|
144481
|
+
};
|
|
144482
|
+
}
|
|
144524
144483
|
if (maxPayUnits !== null && rawAmountUnits > maxPayUnits) {
|
|
144525
144484
|
return {
|
|
144526
144485
|
abort: true,
|
|
144527
|
-
reason: `Payment of ${
|
|
144486
|
+
reason: `Payment of ${challengeAmount} USDC exceeds maxPay ${input.maxPay}`
|
|
144528
144487
|
};
|
|
144529
144488
|
}
|
|
144530
144489
|
const detected = networkToChain(capturedNetwork);
|
|
@@ -144544,9 +144503,10 @@ var Payments = class {
|
|
|
144544
144503
|
}
|
|
144545
144504
|
if (balance !== null && balance < rawAmountUnits) {
|
|
144546
144505
|
const have = formatUnits(balance, 6);
|
|
144506
|
+
const requiredAmount = formatUnits(rawAmountUnits, 6);
|
|
144547
144507
|
preflightError = new ZeroInsufficientFundsError(
|
|
144548
|
-
`wallet has ${have} USDC on Base, needs ${
|
|
144549
|
-
{ have, need:
|
|
144508
|
+
`wallet has ${have} USDC on Base, needs ${requiredAmount}.`,
|
|
144509
|
+
{ have, need: requiredAmount }
|
|
144550
144510
|
);
|
|
144551
144511
|
return { abort: true, reason: preflightError.message };
|
|
144552
144512
|
}
|
|
@@ -144557,18 +144517,64 @@ var Payments = class {
|
|
|
144557
144517
|
const httpClient = new x402HTTPClient(x402).onPaymentRequired(
|
|
144558
144518
|
createSIWxClientHook(account)
|
|
144559
144519
|
);
|
|
144560
|
-
const
|
|
144561
|
-
withSynthesizedX402Header(configuredFetch),
|
|
144562
|
-
httpClient
|
|
144563
|
-
);
|
|
144520
|
+
const paymentFetch = withSynthesizedX402Header(configuredFetch);
|
|
144564
144521
|
let response;
|
|
144565
144522
|
try {
|
|
144566
|
-
|
|
144523
|
+
const request22 = new Request(input.url, {
|
|
144567
144524
|
method: input.method ?? "GET",
|
|
144568
144525
|
headers: input.headers,
|
|
144569
144526
|
body: input.body,
|
|
144570
144527
|
signal: input.signal
|
|
144571
144528
|
});
|
|
144529
|
+
response = await paymentFetch(request22.clone());
|
|
144530
|
+
for (let paymentStage = 0; paymentStage < 2; paymentStage++) {
|
|
144531
|
+
if (response.status !== 402) break;
|
|
144532
|
+
const parseChallenge = async (challengeResponse) => {
|
|
144533
|
+
let body;
|
|
144534
|
+
try {
|
|
144535
|
+
const text = await challengeResponse.clone().text();
|
|
144536
|
+
if (text) body = JSON.parse(text);
|
|
144537
|
+
} catch {
|
|
144538
|
+
}
|
|
144539
|
+
return httpClient.getPaymentRequiredResponse(
|
|
144540
|
+
(name) => challengeResponse.headers.get(name),
|
|
144541
|
+
body
|
|
144542
|
+
);
|
|
144543
|
+
};
|
|
144544
|
+
let paymentRequired = await parseChallenge(response);
|
|
144545
|
+
const hookHeaders = await httpClient.handlePaymentRequired(paymentRequired);
|
|
144546
|
+
if (hookHeaders) {
|
|
144547
|
+
const hookRequest = request22.clone();
|
|
144548
|
+
for (const [key, value] of Object.entries(hookHeaders)) {
|
|
144549
|
+
hookRequest.headers.set(key, value);
|
|
144550
|
+
}
|
|
144551
|
+
response = await paymentFetch(hookRequest);
|
|
144552
|
+
if (response.status === 402) {
|
|
144553
|
+
paymentRequired = await parseChallenge(response);
|
|
144554
|
+
} else {
|
|
144555
|
+
break;
|
|
144556
|
+
}
|
|
144557
|
+
}
|
|
144558
|
+
pendingAmountUnits = 0n;
|
|
144559
|
+
const paymentPayload = await x402.createPaymentPayload(paymentRequired);
|
|
144560
|
+
if (pendingAmountUnits === 0n) {
|
|
144561
|
+
identityChallengeHandled = true;
|
|
144562
|
+
capturedAmount = "0";
|
|
144563
|
+
} else {
|
|
144564
|
+
paidChallengeHandled = true;
|
|
144565
|
+
capturedAmount = formatUnits(pendingAmountUnits, 6);
|
|
144566
|
+
}
|
|
144567
|
+
const paymentHeaders = httpClient.encodePaymentSignatureHeader(paymentPayload);
|
|
144568
|
+
const paidRequest = request22.clone();
|
|
144569
|
+
for (const [key, value] of Object.entries(paymentHeaders)) {
|
|
144570
|
+
paidRequest.headers.set(key, value);
|
|
144571
|
+
}
|
|
144572
|
+
paidRequest.headers.set(
|
|
144573
|
+
"Access-Control-Expose-Headers",
|
|
144574
|
+
"PAYMENT-RESPONSE,X-PAYMENT-RESPONSE"
|
|
144575
|
+
);
|
|
144576
|
+
response = await paymentFetch(paidRequest);
|
|
144577
|
+
}
|
|
144572
144578
|
} catch (err) {
|
|
144573
144579
|
if (preflightError) throw preflightError;
|
|
144574
144580
|
if (err instanceof ZeroError) throw err;
|
|
@@ -144624,7 +144630,8 @@ var Payments = class {
|
|
|
144624
144630
|
const account = await resolveAccount(
|
|
144625
144631
|
this.client,
|
|
144626
144632
|
input.account,
|
|
144627
|
-
input.signal
|
|
144633
|
+
input.signal,
|
|
144634
|
+
input.walletAddress
|
|
144628
144635
|
);
|
|
144629
144636
|
const configuredFetch = buildConfiguredFetch(this.client, {
|
|
144630
144637
|
timeoutMs: input.timeoutMs
|
|
@@ -145135,8 +145142,17 @@ var cancelBody2 = (response) => {
|
|
|
145135
145142
|
} catch {
|
|
145136
145143
|
}
|
|
145137
145144
|
};
|
|
145138
|
-
var detectPaymentRequirement = async (response) => {
|
|
145145
|
+
var detectPaymentRequirement = async (response, preferredProtocol) => {
|
|
145139
145146
|
if (response.status !== 402) return null;
|
|
145147
|
+
const wwwAuth = response.headers.get("www-authenticate");
|
|
145148
|
+
const advertisesMpp = wwwAuth ? splitWwwAuthenticateChallenges(wwwAuth).some((challenge2) => {
|
|
145149
|
+
const scheme = challenge2.trim().split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
145150
|
+
return MPP_SCHEME_TOKENS.has(scheme);
|
|
145151
|
+
}) : false;
|
|
145152
|
+
if (preferredProtocol === "mpp") {
|
|
145153
|
+
cancelBody2(response);
|
|
145154
|
+
return advertisesMpp ? { protocol: "mpp", raw: { "www-authenticate": wwwAuth } } : { protocol: "unknown", raw: { requestedProtocol: "mpp" } };
|
|
145155
|
+
}
|
|
145140
145156
|
const x402Header = response.headers.get("payment-required") ?? response.headers.get("x-payment-required");
|
|
145141
145157
|
if (x402Header) {
|
|
145142
145158
|
cancelBody2(response);
|
|
@@ -145166,15 +145182,13 @@ var detectPaymentRequirement = async (response) => {
|
|
|
145166
145182
|
} catch {
|
|
145167
145183
|
}
|
|
145168
145184
|
}
|
|
145169
|
-
|
|
145170
|
-
|
|
145171
|
-
|
|
145172
|
-
|
|
145173
|
-
|
|
145174
|
-
|
|
145175
|
-
|
|
145176
|
-
return { protocol: "mpp", raw: { "www-authenticate": wwwAuth } };
|
|
145177
|
-
}
|
|
145185
|
+
if (preferredProtocol === "x402") {
|
|
145186
|
+
cancelBody2(response);
|
|
145187
|
+
return { protocol: "unknown", raw: { requestedProtocol: "x402" } };
|
|
145188
|
+
}
|
|
145189
|
+
if (advertisesMpp) {
|
|
145190
|
+
cancelBody2(response);
|
|
145191
|
+
return { protocol: "mpp", raw: { "www-authenticate": wwwAuth } };
|
|
145178
145192
|
}
|
|
145179
145193
|
cancelBody2(response);
|
|
145180
145194
|
return { protocol: "unknown", raw: {} };
|
|
@@ -145404,7 +145418,8 @@ var recordErrorFetchRun = async (client, opts, result, capabilityIdOverride) =>
|
|
|
145404
145418
|
...fetchOriginForRecord && { fetchOrigin: fetchOriginForRecord },
|
|
145405
145419
|
...result.status !== null && { status: result.status },
|
|
145406
145420
|
latencyMs: result.latencyMs,
|
|
145407
|
-
...opts.requestSchema && { requestSchema: opts.requestSchema }
|
|
145421
|
+
...opts.requestSchema && { requestSchema: opts.requestSchema },
|
|
145422
|
+
...opts.walletAddress && !opts.account && { walletAddress: opts.walletAddress }
|
|
145408
145423
|
});
|
|
145409
145424
|
result.runId = created.runId;
|
|
145410
145425
|
delete result.runTrackingSkipped;
|
|
@@ -145499,7 +145514,10 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145499
145514
|
return result2;
|
|
145500
145515
|
}
|
|
145501
145516
|
if (response.status === 402) {
|
|
145502
|
-
const requirement = await detectPaymentRequirement(
|
|
145517
|
+
const requirement = await detectPaymentRequirement(
|
|
145518
|
+
response,
|
|
145519
|
+
opts.paymentProtocol
|
|
145520
|
+
);
|
|
145503
145521
|
if (requirement?.protocol === "x402" || requirement?.protocol === "mpp") {
|
|
145504
145522
|
const payCall = requirement.protocol === "x402" ? client.payments.pay : client.payments.payMpp;
|
|
145505
145523
|
try {
|
|
@@ -145513,6 +145531,7 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145513
145531
|
body: requestBody,
|
|
145514
145532
|
maxPay: opts.maxPay,
|
|
145515
145533
|
account: opts.account,
|
|
145534
|
+
...opts.walletAddress && { walletAddress: opts.walletAddress },
|
|
145516
145535
|
signal: opts.signal,
|
|
145517
145536
|
timeoutMs: opts.timeoutMs,
|
|
145518
145537
|
...opts.displayCostAmount && {
|
|
@@ -145570,7 +145589,7 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145570
145589
|
} else if (requirement?.protocol === "unknown") {
|
|
145571
145590
|
const result2 = errorFetchResult(
|
|
145572
145591
|
startedAt,
|
|
145573
|
-
"Capability returned 402 with an unrecognized payment protocol. Neither x402 nor MPP markers were detected in the response headers or body.",
|
|
145592
|
+
opts.paymentProtocol ? `Capability did not advertise the requested ${opts.paymentProtocol} payment protocol.` : "Capability returned 402 with an unrecognized payment protocol. Neither x402 nor MPP markers were detected in the response headers or body.",
|
|
145574
145593
|
"unrecognized_402_protocol",
|
|
145575
145594
|
capabilityIdRequested,
|
|
145576
145595
|
"payment_failed",
|
|
@@ -145685,6 +145704,10 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145685
145704
|
...opts.capabilityId === void 0 ? { fetchOrigin: "direct_url" } : opts.fetchOrigin && { fetchOrigin: opts.fetchOrigin },
|
|
145686
145705
|
status: response.status,
|
|
145687
145706
|
latencyMs,
|
|
145707
|
+
// Attribute to the selected wallet in session mode. Skipped when a
|
|
145708
|
+
// per-call `account` override records the run — that account's own
|
|
145709
|
+
// EIP-191 identity is the attribution.
|
|
145710
|
+
...opts.walletAddress && !opts.account && { walletAddress: opts.walletAddress },
|
|
145688
145711
|
...opts.requestSchema && { requestSchema: opts.requestSchema },
|
|
145689
145712
|
...derived?.responseSchema && {
|
|
145690
145713
|
responseSchema: derived.responseSchema
|
|
@@ -145748,7 +145771,7 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145748
145771
|
return result;
|
|
145749
145772
|
};
|
|
145750
145773
|
var package_default = {
|
|
145751
|
-
version: "0.
|
|
145774
|
+
version: "0.14.0"
|
|
145752
145775
|
};
|
|
145753
145776
|
var SDK_VERSION2 = package_default.version;
|
|
145754
145777
|
var agentAuthMetadataSchema = external_exports3.object({
|
|
@@ -146233,6 +146256,9 @@ var userWalletDtoSchema = external_exports3.object({
|
|
|
146233
146256
|
walletAddress: external_exports3.string(),
|
|
146234
146257
|
source: external_exports3.enum(["self_custody", "privy_embedded"]),
|
|
146235
146258
|
isPrimary: external_exports3.boolean(),
|
|
146259
|
+
// Owner-chosen display name; null/absent = unnamed (show the address).
|
|
146260
|
+
// Optional so the SDK tolerates servers that predate nicknames.
|
|
146261
|
+
nickname: external_exports3.string().nullable().optional(),
|
|
146236
146262
|
linkedAt: external_exports3.union([external_exports3.string(), external_exports3.date()]).nullable().optional(),
|
|
146237
146263
|
importedAt: external_exports3.union([external_exports3.string(), external_exports3.date()]).nullable().optional(),
|
|
146238
146264
|
delegationGranted: external_exports3.boolean(),
|
|
@@ -146446,7 +146472,10 @@ var Auth = class {
|
|
|
146446
146472
|
{
|
|
146447
146473
|
method: "POST",
|
|
146448
146474
|
path: "/v1/users/me/sign-message",
|
|
146449
|
-
body: {
|
|
146475
|
+
body: {
|
|
146476
|
+
message: normalizeMessage(input.message),
|
|
146477
|
+
...opts.walletAddress ? { walletAddress: opts.walletAddress } : {}
|
|
146478
|
+
}
|
|
146450
146479
|
},
|
|
146451
146480
|
signResponseSchema
|
|
146452
146481
|
);
|
|
@@ -146471,7 +146500,10 @@ var Auth = class {
|
|
|
146471
146500
|
{
|
|
146472
146501
|
method: "POST",
|
|
146473
146502
|
path: "/v1/users/me/sign-transaction",
|
|
146474
|
-
body: {
|
|
146503
|
+
body: {
|
|
146504
|
+
unsignedTransaction: input.unsignedTransaction,
|
|
146505
|
+
...opts.walletAddress ? { walletAddress: opts.walletAddress } : {}
|
|
146506
|
+
}
|
|
146475
146507
|
},
|
|
146476
146508
|
signResponseSchema
|
|
146477
146509
|
);
|
|
@@ -146510,7 +146542,10 @@ var Auth = class {
|
|
|
146510
146542
|
{
|
|
146511
146543
|
method: "POST",
|
|
146512
146544
|
path: "/v1/users/me/sign-typed-data",
|
|
146513
|
-
body: {
|
|
146545
|
+
body: {
|
|
146546
|
+
typedData: input,
|
|
146547
|
+
...opts.walletAddress ? { walletAddress: opts.walletAddress } : {}
|
|
146548
|
+
}
|
|
146514
146549
|
},
|
|
146515
146550
|
signResponseSchema
|
|
146516
146551
|
);
|
|
@@ -146881,6 +146916,9 @@ var Runs = class {
|
|
|
146881
146916
|
if (params.unreviewed !== void 0) query.unreviewed = params.unreviewed;
|
|
146882
146917
|
if (params.limit !== void 0) query.limit = params.limit;
|
|
146883
146918
|
if (params.cursor !== void 0) query.cursor = params.cursor;
|
|
146919
|
+
if (params.walletAddress !== void 0) {
|
|
146920
|
+
query.walletAddress = Array.isArray(params.walletAddress) ? params.walletAddress.join(",") : params.walletAddress;
|
|
146921
|
+
}
|
|
146884
146922
|
return request2(
|
|
146885
146923
|
this.client,
|
|
146886
146924
|
{
|
|
@@ -147016,6 +147054,50 @@ var Wallet = class {
|
|
|
147016
147054
|
},
|
|
147017
147055
|
userWalletDtoSchema
|
|
147018
147056
|
);
|
|
147057
|
+
// Re-stamp Zero's signing delegation on a profile wallet (default: the
|
|
147058
|
+
// primary). Session-only. Naming a wallet re-authorizes THAT wallet and
|
|
147059
|
+
// never provisions; the server 404s an address not on the profile.
|
|
147060
|
+
reauthorizeDelegation = (opts = {}) => request2(
|
|
147061
|
+
this.client,
|
|
147062
|
+
{
|
|
147063
|
+
method: "POST",
|
|
147064
|
+
path: "/v1/users/me/wallets/provision",
|
|
147065
|
+
...opts.walletAddress ? { body: { walletAddress: opts.walletAddress } } : {},
|
|
147066
|
+
signal: opts.signal
|
|
147067
|
+
},
|
|
147068
|
+
userWalletDtoSchema
|
|
147069
|
+
);
|
|
147070
|
+
// Revoke Zero's signing delegation on a profile wallet (default: the
|
|
147071
|
+
// primary). Session-only. Managed signing on that wallet 403s until it is
|
|
147072
|
+
// re-authorized. Note: this stamps the server-side gate — removing Zero's
|
|
147073
|
+
// signer cryptographically is owner-authorized and happens in the user's
|
|
147074
|
+
// Privy session (the web profile page does both).
|
|
147075
|
+
revokeDelegation = (opts = {}) => request2(
|
|
147076
|
+
this.client,
|
|
147077
|
+
{
|
|
147078
|
+
method: "DELETE",
|
|
147079
|
+
path: "/v1/users/me/wallets/delegation",
|
|
147080
|
+
...opts.walletAddress ? { query: { walletAddress: opts.walletAddress } } : {},
|
|
147081
|
+
signal: opts.signal
|
|
147082
|
+
},
|
|
147083
|
+
userWalletDtoSchema
|
|
147084
|
+
);
|
|
147085
|
+
// Set, change, or clear (null / empty string) the owner-chosen nickname on
|
|
147086
|
+
// a profile wallet. Session-only. Nicknames are private to the
|
|
147087
|
+
// authenticated user — they never appear on reviews or public surfaces.
|
|
147088
|
+
setNickname = (opts) => request2(
|
|
147089
|
+
this.client,
|
|
147090
|
+
{
|
|
147091
|
+
method: "PATCH",
|
|
147092
|
+
path: "/v1/users/me/wallets/nickname",
|
|
147093
|
+
body: {
|
|
147094
|
+
walletAddress: opts.walletAddress,
|
|
147095
|
+
nickname: opts.nickname
|
|
147096
|
+
},
|
|
147097
|
+
signal: opts.signal
|
|
147098
|
+
},
|
|
147099
|
+
userWalletDtoSchema
|
|
147100
|
+
);
|
|
147019
147101
|
// Link an existing self-custody wallet to the session user by private key.
|
|
147020
147102
|
// Session-only. 409s when the wallet is already linked (to this or another
|
|
147021
147103
|
// profile — the error message says which).
|
|
@@ -147026,7 +147108,8 @@ var Wallet = class {
|
|
|
147026
147108
|
path: "/v1/users/me/wallets/import",
|
|
147027
147109
|
body: {
|
|
147028
147110
|
privateKey: opts.privateKey,
|
|
147029
|
-
...opts.makePrimary !== void 0 ? { makePrimary: opts.makePrimary } : {}
|
|
147111
|
+
...opts.makePrimary !== void 0 ? { makePrimary: opts.makePrimary } : {},
|
|
147112
|
+
...opts.nickname !== void 0 ? { nickname: opts.nickname } : {}
|
|
147030
147113
|
},
|
|
147031
147114
|
signal: opts.signal
|
|
147032
147115
|
},
|
|
@@ -147223,6 +147306,9 @@ var ZeroClient = class _ZeroClient {
|
|
|
147223
147306
|
managedAccountInFlight = null;
|
|
147224
147307
|
managedAccountAC = null;
|
|
147225
147308
|
managedAccountGen = 0;
|
|
147309
|
+
// Explicitly-selected (non-default) managed wallets, keyed by lowercased
|
|
147310
|
+
// address. Same lifecycle as managedAccount: cleared on clearManagedAccount.
|
|
147311
|
+
managedAccountByAddress = /* @__PURE__ */ new Map();
|
|
147226
147312
|
// Multi-tenant servers calling `client.fetch(url, { account: tenantAccount })`
|
|
147227
147313
|
// on every request would otherwise construct a new ZeroClient (with
|
|
147228
147314
|
// five namespace instances) per call. Keyed by lowercased account
|
|
@@ -147444,8 +147530,16 @@ var ZeroClient = class _ZeroClient {
|
|
|
147444
147530
|
}
|
|
147445
147531
|
this.withAccountCache.clear();
|
|
147446
147532
|
};
|
|
147447
|
-
/**
|
|
147448
|
-
|
|
147533
|
+
/**
|
|
147534
|
+
* @internal — used by payments.pay() in session mode. Cached, dedupes
|
|
147535
|
+
* concurrent lookups. Pass `walletAddress` to sign as a specific profile
|
|
147536
|
+
* wallet instead of the primary; explicit wallets are cached per address
|
|
147537
|
+
* and their sign requests carry the address so intent and signer agree.
|
|
147538
|
+
*/
|
|
147539
|
+
resolveManagedAccount = (signal, walletAddress) => {
|
|
147540
|
+
if (walletAddress) {
|
|
147541
|
+
return this.resolveManagedAccountByAddress(walletAddress, signal);
|
|
147542
|
+
}
|
|
147449
147543
|
if (this.managedAccount) return Promise.resolve(this.managedAccount);
|
|
147450
147544
|
if (this.managedAccountInFlight) {
|
|
147451
147545
|
return this.raceWithSignal(this.managedAccountInFlight, signal);
|
|
@@ -147487,6 +147581,42 @@ var ZeroClient = class _ZeroClient {
|
|
|
147487
147581
|
});
|
|
147488
147582
|
return this.raceWithSignal(this.managedAccountInFlight, signal);
|
|
147489
147583
|
};
|
|
147584
|
+
// Explicit-wallet variant of resolveManagedAccount. No in-flight dedupe:
|
|
147585
|
+
// this is the rare path (per-wallet pay), the resolution is idempotent, and
|
|
147586
|
+
// the per-address cache absorbs repeat calls.
|
|
147587
|
+
resolveManagedAccountByAddress = async (walletAddress, signal) => {
|
|
147588
|
+
if (this.credentials.kind !== "session") {
|
|
147589
|
+
throw new ZeroAuthError(
|
|
147590
|
+
"auth_no_credentials",
|
|
147591
|
+
"resolveManagedAccount() requires session credentials."
|
|
147592
|
+
);
|
|
147593
|
+
}
|
|
147594
|
+
const canonical = getAddress(walletAddress);
|
|
147595
|
+
const cached2 = this.managedAccountByAddress.get(canonical.toLowerCase());
|
|
147596
|
+
if (cached2) return cached2;
|
|
147597
|
+
const startedAtGen = this.managedAccountGen;
|
|
147598
|
+
const wallets = await this.auth.wallets({ signal });
|
|
147599
|
+
const match = wallets.find(
|
|
147600
|
+
(w) => w.walletAddress.toLowerCase() === canonical.toLowerCase()
|
|
147601
|
+
);
|
|
147602
|
+
if (!match || match.source !== "privy_embedded") {
|
|
147603
|
+
throw new ZeroAuthError(
|
|
147604
|
+
"auth_error",
|
|
147605
|
+
`Wallet ${canonical} is not a Privy-embedded wallet on this profile. Managed signing can only use profile wallets (see client.wallet.list()).`
|
|
147606
|
+
);
|
|
147607
|
+
}
|
|
147608
|
+
if (this.managedAccountGen !== startedAtGen) {
|
|
147609
|
+
throw new ZeroAuthError(
|
|
147610
|
+
"auth_session_expired",
|
|
147611
|
+
"Session cleared during managed-account resolution. Retry to rebuild against the current session."
|
|
147612
|
+
);
|
|
147613
|
+
}
|
|
147614
|
+
const acc = createManagedAccount(this, canonical, {
|
|
147615
|
+
explicitWallet: true
|
|
147616
|
+
});
|
|
147617
|
+
this.managedAccountByAddress.set(canonical.toLowerCase(), acc);
|
|
147618
|
+
return acc;
|
|
147619
|
+
};
|
|
147490
147620
|
// Per-caller signal gate: each caller can reject on their own abort
|
|
147491
147621
|
// without cancelling the shared underlying promise.
|
|
147492
147622
|
raceWithSignal = (p, signal) => {
|
|
@@ -147517,6 +147647,7 @@ var ZeroClient = class _ZeroClient {
|
|
|
147517
147647
|
this.managedAccountAC?.abort();
|
|
147518
147648
|
this.managedAccountInFlight = null;
|
|
147519
147649
|
this.managedAccountAC = null;
|
|
147650
|
+
this.managedAccountByAddress.clear();
|
|
147520
147651
|
this.managedAccountGen++;
|
|
147521
147652
|
};
|
|
147522
147653
|
/** @internal — Read cached managed account without triggering resolution. */
|
|
@@ -147782,7 +147913,7 @@ var placeholderFor = (fieldName, propSchema) => String(sampleValueFor(fieldName,
|
|
|
147782
147913
|
|
|
147783
147914
|
// package.json
|
|
147784
147915
|
var package_default2 = {
|
|
147785
|
-
version: "1.
|
|
147916
|
+
version: "1.20.0"};
|
|
147786
147917
|
|
|
147787
147918
|
// src/app.ts
|
|
147788
147919
|
init_esm_shims();
|
|
@@ -149408,6 +149539,12 @@ var fetchCommand = (appContext) => new Command("fetch").description(
|
|
|
149408
149539
|
"--data-stdin",
|
|
149409
149540
|
"Read the request body from stdin (equivalent to `-d @-`)."
|
|
149410
149541
|
).option("-H, --header <header...>", "Headers in Key:Value format").option("--max-pay <amount>", "Maximum per-call spend limit (USDC)").option(
|
|
149542
|
+
"--protocol <protocol>",
|
|
149543
|
+
"Force payment protocol when multiple are offered (x402 or mpp)"
|
|
149544
|
+
).option(
|
|
149545
|
+
"--wallet-address <address>",
|
|
149546
|
+
"Pay/sign from this profile wallet instead of the primary (managed signing; must be a delegated wallet on your profile)"
|
|
149547
|
+
).option(
|
|
149411
149548
|
"--timeout <seconds>",
|
|
149412
149549
|
"Per-request timeout in seconds, overriding the default (180). Applies to each HTTP leg of the call (probe and paid retry), not as a wall-clock deadline."
|
|
149413
149550
|
).option(
|
|
@@ -149425,6 +149562,11 @@ var fetchCommand = (appContext) => new Command("fetch").description(
|
|
|
149425
149562
|
).action(
|
|
149426
149563
|
async (url4, options) => {
|
|
149427
149564
|
try {
|
|
149565
|
+
if (options.protocol && !["x402", "mpp"].includes(options.protocol)) {
|
|
149566
|
+
throw new Error(
|
|
149567
|
+
`Invalid protocol "${options.protocol}". Must be x402 or mpp.`
|
|
149568
|
+
);
|
|
149569
|
+
}
|
|
149428
149570
|
const { analyticsService, client, walletAddress, lowBalanceWarning } = appContext.services;
|
|
149429
149571
|
const fromToken = options.capability ? isShortToken(options.capability) : false;
|
|
149430
149572
|
const effectiveCapRef = options.capability;
|
|
@@ -149545,6 +149687,12 @@ var fetchCommand = (appContext) => new Command("fetch").description(
|
|
|
149545
149687
|
headers,
|
|
149546
149688
|
...resolvedBody !== void 0 && { body: resolvedBody },
|
|
149547
149689
|
...options.maxPay && { maxPay: options.maxPay },
|
|
149690
|
+
...options.protocol && {
|
|
149691
|
+
paymentProtocol: options.protocol
|
|
149692
|
+
},
|
|
149693
|
+
...options.walletAddress && {
|
|
149694
|
+
walletAddress: options.walletAddress
|
|
149695
|
+
},
|
|
149548
149696
|
...timeoutMs !== void 0 && { timeoutMs },
|
|
149549
149697
|
// Raise the SDK's default 10 MB response cap — the CLI
|
|
149550
149698
|
// is a streaming sink for paid binary media (audio, video,
|
|
@@ -151420,9 +151568,13 @@ Examples:
|
|
|
151420
151568
|
zero runs # most recent runs
|
|
151421
151569
|
zero runs --unreviewed # filter to runs without a review
|
|
151422
151570
|
zero runs --capability translate-en # filter to one capability (uid or slug)
|
|
151571
|
+
zero runs --wallet-address 0xabc\u2026 # filter to one of your profile wallets
|
|
151423
151572
|
zero runs --json # full structured output for scripts
|
|
151424
151573
|
zero runs detail <runId> # full server-side metadata for a run`
|
|
151425
151574
|
).option("--capability <id>", "Filter by capability uid or slug").option("--unreviewed", "Only show runs without a review").option(
|
|
151575
|
+
"--wallet-address <addresses>",
|
|
151576
|
+
"Filter to specific profile wallets (comma-separated). Default: all profile wallets"
|
|
151577
|
+
).option(
|
|
151426
151578
|
"--limit <n>",
|
|
151427
151579
|
"Max rows (1-100, default 25)",
|
|
151428
151580
|
(v) => Number.parseInt(v, 10)
|
|
@@ -151436,6 +151588,7 @@ Examples:
|
|
|
151436
151588
|
const result = await client.runs.list({
|
|
151437
151589
|
capabilityId: options.capability,
|
|
151438
151590
|
unreviewed: options.unreviewed,
|
|
151591
|
+
...options.walletAddress ? { walletAddress: options.walletAddress } : {},
|
|
151439
151592
|
limit: options.limit
|
|
151440
151593
|
});
|
|
151441
151594
|
if (options.json) {
|
|
@@ -152133,7 +152286,10 @@ var walletImportCommand = (appContext) => new Command("import").description(
|
|
|
152133
152286
|
).argument("[privateKey]", "Hex-encoded private key (0x prefix optional)").option(
|
|
152134
152287
|
"--key-stdin",
|
|
152135
152288
|
"Read the private key from stdin instead of an argument"
|
|
152136
|
-
).option("--primary", "Make the imported wallet your primary payer wallet").
|
|
152289
|
+
).option("--primary", "Make the imported wallet your primary payer wallet").option(
|
|
152290
|
+
"--nickname <name>",
|
|
152291
|
+
"Nickname for the imported wallet (private to you; max 64 chars)"
|
|
152292
|
+
).action(
|
|
152137
152293
|
async (privateKeyArg, options) => {
|
|
152138
152294
|
const { analyticsService, client } = appContext.services;
|
|
152139
152295
|
if (privateKeyArg && options.keyStdin) {
|
|
@@ -152180,7 +152336,8 @@ var walletImportCommand = (appContext) => new Command("import").description(
|
|
|
152180
152336
|
try {
|
|
152181
152337
|
wallet = await client.wallet.import({
|
|
152182
152338
|
privateKey,
|
|
152183
|
-
...options.primary ? { makePrimary: true } : {}
|
|
152339
|
+
...options.primary ? { makePrimary: true } : {},
|
|
152340
|
+
...options.nickname ? { nickname: options.nickname } : {}
|
|
152184
152341
|
});
|
|
152185
152342
|
} catch (err) {
|
|
152186
152343
|
if (err instanceof ZeroApiError) {
|
|
@@ -152259,6 +152416,7 @@ var walletListCommand = (appContext) => new Command("list").description("List th
|
|
|
152259
152416
|
(wallet.isPrimary ? "PRIMARY" : "").padEnd(7),
|
|
152260
152417
|
wallet.delegationGranted ? "delegated" : "not delegated"
|
|
152261
152418
|
];
|
|
152419
|
+
if (wallet.nickname) columns.push(`"${wallet.nickname}"`);
|
|
152262
152420
|
console.log(columns.join(" ").trimEnd());
|
|
152263
152421
|
}
|
|
152264
152422
|
}
|
|
@@ -152344,6 +152502,64 @@ var walletGenerateCommand = (appContext) => new Command("generate").description(
|
|
|
152344
152502
|
});
|
|
152345
152503
|
}
|
|
152346
152504
|
);
|
|
152505
|
+
var walletNicknameCommand = (appContext) => new Command("nickname").description(
|
|
152506
|
+
"Set or clear a nickname on one of your profile wallets (private to you)"
|
|
152507
|
+
).argument("<address>", "Wallet address (0x\u2026) on your profile").argument(
|
|
152508
|
+
"[name]",
|
|
152509
|
+
"Nickname to set (max 64 chars). Omit with --clear to remove it."
|
|
152510
|
+
).option("--clear", "Clear the wallet's nickname").action(
|
|
152511
|
+
async (address2, name, options) => {
|
|
152512
|
+
const { analyticsService, client } = appContext.services;
|
|
152513
|
+
if (options.clear && name !== void 0) {
|
|
152514
|
+
console.error("Pass a nickname OR --clear, not both.");
|
|
152515
|
+
process.exitCode = 1;
|
|
152516
|
+
return;
|
|
152517
|
+
}
|
|
152518
|
+
if (!options.clear && (name === void 0 || name.trim() === "")) {
|
|
152519
|
+
console.error(
|
|
152520
|
+
"Missing nickname. Pass one as an argument, or use --clear to remove it."
|
|
152521
|
+
);
|
|
152522
|
+
process.exitCode = 1;
|
|
152523
|
+
return;
|
|
152524
|
+
}
|
|
152525
|
+
if (client.getCredentials().kind !== "session") {
|
|
152526
|
+
console.error(SIGN_IN_FIRST_MESSAGE);
|
|
152527
|
+
process.exitCode = 1;
|
|
152528
|
+
return;
|
|
152529
|
+
}
|
|
152530
|
+
let wallet;
|
|
152531
|
+
try {
|
|
152532
|
+
wallet = await client.wallet.setNickname({
|
|
152533
|
+
walletAddress: address2,
|
|
152534
|
+
nickname: options.clear ? null : name
|
|
152535
|
+
});
|
|
152536
|
+
} catch (err) {
|
|
152537
|
+
if (err instanceof ZeroApiError) {
|
|
152538
|
+
if (err.status === 401) {
|
|
152539
|
+
console.error(
|
|
152540
|
+
"Session expired. Run `zero auth login` and try again."
|
|
152541
|
+
);
|
|
152542
|
+
} else if (err.status === 404) {
|
|
152543
|
+
console.error(
|
|
152544
|
+
"Wallet not found on your profile. Run `zero wallet list` to see your wallets."
|
|
152545
|
+
);
|
|
152546
|
+
} else {
|
|
152547
|
+
console.error(`Could not update nickname: ${err.message}`);
|
|
152548
|
+
}
|
|
152549
|
+
} else {
|
|
152550
|
+
console.error("Could not update nickname: network error.");
|
|
152551
|
+
}
|
|
152552
|
+
process.exitCode = 1;
|
|
152553
|
+
return;
|
|
152554
|
+
}
|
|
152555
|
+
console.log(
|
|
152556
|
+
wallet.nickname ? `Nickname set: ${wallet.walletAddress} \u2192 "${wallet.nickname}"` : `Nickname cleared for ${wallet.walletAddress}`
|
|
152557
|
+
);
|
|
152558
|
+
analyticsService.capture("wallet_nickname_set", {
|
|
152559
|
+
cleared: Boolean(options.clear)
|
|
152560
|
+
});
|
|
152561
|
+
}
|
|
152562
|
+
);
|
|
152347
152563
|
var walletCommand = (appContext) => {
|
|
152348
152564
|
const cmd = new Command("wallet").description("Manage your wallet");
|
|
152349
152565
|
cmd.addCommand(walletBalanceCommand(appContext));
|
|
@@ -152353,6 +152569,7 @@ var walletCommand = (appContext) => {
|
|
|
152353
152569
|
cmd.addCommand(walletGenerateCommand(appContext));
|
|
152354
152570
|
cmd.addCommand(walletImportCommand(appContext));
|
|
152355
152571
|
cmd.addCommand(walletListCommand(appContext));
|
|
152572
|
+
cmd.addCommand(walletNicknameCommand(appContext));
|
|
152356
152573
|
return cmd;
|
|
152357
152574
|
};
|
|
152358
152575
|
|