@zeroxyz/cli 1.32.0 → 1.33.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.
Files changed (2) hide show
  1. package/dist/index.js +34 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -93043,7 +93043,7 @@ init_esm_shims();
93043
93043
  // ../sdk/dist/index.js
93044
93044
  init_esm_shims();
93045
93045
 
93046
- // ../sdk/dist/chunk-4H5K6DCA.js
93046
+ // ../sdk/dist/chunk-QNTZREQD.js
93047
93047
  init_esm_shims();
93048
93048
 
93049
93049
  // ../../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
@@ -166839,7 +166839,7 @@ var redactUrl = (raw) => {
166839
166839
  };
166840
166840
  var truncateError = (raw) => raw.length > ERROR_MAX ? `${raw.slice(0, ERROR_MAX)}\u2026` : raw;
166841
166841
  var package_default = {
166842
- version: "0.25.0"
166842
+ version: "0.26.0"
166843
166843
  };
166844
166844
  var SDK_VERSION2 = package_default.version;
166845
166845
  var ZeroError = class extends Error {
@@ -167631,6 +167631,17 @@ var withSynthesizedX402Header = (baseFetch) => async (input, init) => {
167631
167631
  headers
167632
167632
  });
167633
167633
  };
167634
+ var readPaymentRejectionReason = (body) => {
167635
+ if (!body || typeof body !== "object" || Array.isArray(body)) return null;
167636
+ const b = body;
167637
+ const str = (v) => typeof v === "string" && v.trim().length > 0 ? v.trim() : null;
167638
+ const code = str(b.reason) ?? str(b.error);
167639
+ if (!code) return null;
167640
+ const outer = str(b.error);
167641
+ const label = outer && outer !== code ? `${code} (${outer})` : code;
167642
+ const detail = str(b.detail) ?? str(b.message) ?? str(b.hint);
167643
+ return detail ? `${label} \u2014 ${detail}` : label;
167644
+ };
167634
167645
  var USDC_BASE2 = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
167635
167646
  var USDC_BASE_SEPOLIA = "0x036cbd53842c5426634e7929541ec2318f3dcf7e";
167636
167647
  var UINT_RE = /^[0-9]+$/;
@@ -168280,10 +168291,23 @@ var Payments = class {
168280
168291
  if (text) body = JSON.parse(text);
168281
168292
  } catch {
168282
168293
  }
168283
- return httpClient.getPaymentRequiredResponse(
168284
- (name) => challengeResponse.headers.get(name),
168285
- body
168286
- );
168294
+ try {
168295
+ return httpClient.getPaymentRequiredResponse(
168296
+ (name) => challengeResponse.headers.get(name),
168297
+ body
168298
+ );
168299
+ } catch (err) {
168300
+ const reason = readPaymentRejectionReason(body);
168301
+ if (!reason) throw err;
168302
+ input.diagnostics?.fail(
168303
+ "paid_replay",
168304
+ FETCH_DIAGNOSTIC_CODES.paymentRejected
168305
+ );
168306
+ throw new ZeroPaymentError(
168307
+ `the seller rejected the payment: ${reason}`,
168308
+ { cause: err }
168309
+ );
168310
+ }
168287
168311
  };
168288
168312
  let paymentRequired2 = await parseChallenge(response);
168289
168313
  const hookHeaders = await httpClient.handlePaymentRequired(paymentRequired2);
@@ -169568,6 +169592,9 @@ var computeFixHint = (status, message2, bodyRaw) => {
169568
169592
  if (status === 415 || /content-?type|unsupported media|media type/.test(hay)) {
169569
169593
  return "set the Content-Type header to what the capability expects (usually application/json), then retry";
169570
169594
  }
169595
+ if ((status === 401 || status === 403) && /bearer|identity|unauthorized|credential|agent_auth/.test(hay)) {
169596
+ return 'the seller requires an agent identity credential \u2014 run `zero auth identity <host>` and resend with `-H "Authorization: Bearer <token>"`';
169597
+ }
169571
169598
  if (/required|missing|must (include|provide|have|contain)|is expected/.test(hay)) {
169572
169599
  const field = extractFieldName(message2 ?? "");
169573
169600
  return field ? `add the required field '${field}' to the request body, then retry` : "the request is missing one or more required fields \u2014 check the capability schema (`zero get <slug>`), then retry";
@@ -176637,7 +176664,7 @@ var placeholderFor = (fieldName, propSchema) => String(sampleValueFor(fieldName,
176637
176664
  // package.json
176638
176665
  var package_default2 = {
176639
176666
  name: "@zeroxyz/cli",
176640
- version: "1.32.0",
176667
+ version: "1.33.0",
176641
176668
  type: "module",
176642
176669
  bin: {
176643
176670
  zero: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroxyz/cli",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "zero": "dist/index.js",