@agent-score/commerce 2.7.5 → 2.7.7

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 (53) hide show
  1. package/dist/challenge/index.d.mts +3 -3
  2. package/dist/challenge/index.d.ts +3 -3
  3. package/dist/{checkout-DKq9gV3G.d.mts → checkout-B0jIzAEo.d.mts} +5 -5
  4. package/dist/{checkout-DW7GgRrl.d.ts → checkout-BRdpPSnc.d.ts} +5 -5
  5. package/dist/core.js +1 -1
  6. package/dist/core.mjs +1 -1
  7. package/dist/discovery/index.d.mts +6 -6
  8. package/dist/discovery/index.d.ts +6 -6
  9. package/dist/{gate-GCXy4FHI.d.mts → gate-BMUMi-P0.d.mts} +2 -2
  10. package/dist/{gate-D2RP6bZg.d.ts → gate-Bhbi5zvG.d.ts} +2 -2
  11. package/dist/identity/express.d.mts +2 -2
  12. package/dist/identity/express.d.ts +2 -2
  13. package/dist/identity/express.js +1 -1
  14. package/dist/identity/express.mjs +1 -1
  15. package/dist/identity/fastify.d.mts +2 -2
  16. package/dist/identity/fastify.d.ts +2 -2
  17. package/dist/identity/fastify.js +1 -1
  18. package/dist/identity/fastify.mjs +1 -1
  19. package/dist/identity/hono.d.mts +2 -2
  20. package/dist/identity/hono.d.ts +2 -2
  21. package/dist/identity/hono.js +1 -1
  22. package/dist/identity/hono.mjs +1 -1
  23. package/dist/identity/nextjs.d.mts +2 -2
  24. package/dist/identity/nextjs.d.ts +2 -2
  25. package/dist/identity/nextjs.js +1 -1
  26. package/dist/identity/nextjs.mjs +1 -1
  27. package/dist/identity/web.d.mts +2 -2
  28. package/dist/identity/web.d.ts +2 -2
  29. package/dist/identity/web.js +1 -1
  30. package/dist/identity/web.mjs +1 -1
  31. package/dist/index.d.mts +11 -11
  32. package/dist/index.d.ts +11 -11
  33. package/dist/index.js +179 -65
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +179 -65
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/{network_kind-toxNABqw.d.ts → network_kind-C3NA2wX2.d.ts} +2 -2
  38. package/dist/{network_kind-CLdLbqU5.d.mts → network_kind-DmHbQbOb.d.mts} +2 -2
  39. package/dist/payment/index.d.mts +5 -5
  40. package/dist/payment/index.d.ts +5 -5
  41. package/dist/{pricing-Dx3F1VAv.d.ts → pricing-DUYE2hIy.d.ts} +1 -1
  42. package/dist/{pricing-sfv3CPiY.d.mts → pricing-Wqbq6xIR.d.mts} +1 -1
  43. package/dist/{rail_spec-DGdb4Gnd.d.mts → rail_spec-C-jTQ7g6.d.mts} +1 -1
  44. package/dist/{rail_spec-DGdb4Gnd.d.ts → rail_spec-C-jTQ7g6.d.ts} +1 -1
  45. package/dist/stripe-multichain/index.js +175 -61
  46. package/dist/stripe-multichain/index.js.map +1 -1
  47. package/dist/stripe-multichain/index.mjs +175 -61
  48. package/dist/stripe-multichain/index.mjs.map +1 -1
  49. package/dist/{types-D1slMt0H.d.mts → types-1Mr5ZDas.d.mts} +1 -1
  50. package/dist/{types-D1slMt0H.d.ts → types-1Mr5ZDas.d.ts} +1 -1
  51. package/dist/{x402_server-Ciz2mls2.d.mts → x402_server-hgQzWQwB.d.mts} +1 -1
  52. package/dist/{x402_server-Ciz2mls2.d.ts → x402_server-hgQzWQwB.d.ts} +1 -1
  53. package/package.json +15 -14
@@ -23,11 +23,11 @@ var __export = (target, all) => {
23
23
  for (var name in all)
24
24
  __defProp(target, name, { get: all[name], enumerable: true });
25
25
  };
26
- var __copyProps = (to, from9, except, desc) => {
27
- if (from9 && typeof from9 === "object" || typeof from9 === "function") {
28
- for (let key of __getOwnPropNames(from9))
26
+ var __copyProps = (to, from10, except, desc) => {
27
+ if (from10 && typeof from10 === "object" || typeof from10 === "function") {
28
+ for (let key of __getOwnPropNames(from10))
29
29
  if (!__hasOwnProp.call(to, key) && key !== except)
30
- __defProp(to, key, { get: () => from9[key], enumerable: !(desc = __getOwnPropDesc(from9, key)) || desc.enumerable });
30
+ __defProp(to, key, { get: () => from10[key], enumerable: !(desc = __getOwnPropDesc(from10, key)) || desc.enumerable });
31
31
  }
32
32
  return to;
33
33
  };
@@ -1006,7 +1006,7 @@ var init_sha256 = __esm({
1006
1006
  }
1007
1007
  });
1008
1008
 
1009
- // node_modules/@noble/curves/esm/abstract/utils.js
1009
+ // node_modules/ox/node_modules/@noble/curves/esm/abstract/utils.js
1010
1010
  function equalBytes(a, b) {
1011
1011
  if (a.length !== b.length)
1012
1012
  return false;
@@ -1017,7 +1017,7 @@ function equalBytes(a, b) {
1017
1017
  }
1018
1018
  var hasHexBuiltin;
1019
1019
  var init_utils2 = __esm({
1020
- "node_modules/@noble/curves/esm/abstract/utils.js"() {
1020
+ "node_modules/ox/node_modules/@noble/curves/esm/abstract/utils.js"() {
1021
1021
  "use strict";
1022
1022
  hasHexBuiltin = // @ts-ignore
1023
1023
  typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
@@ -19242,10 +19242,16 @@ var init_Errors2 = __esm({
19242
19242
  methodUnsupported: "Use a supported wallet to pay for this resource using one of the supported payment methods returned in the WWW-Authenticate header. See https://mpp.dev/tools/wallet.md"
19243
19243
  };
19244
19244
  PaymentError = class extends Error {
19245
+ /** Safe method-specific context for diagnostics and relay responses. */
19246
+ details;
19245
19247
  /** HTTP status code. */
19246
19248
  status = 402;
19247
19249
  /** Actionable hint for resolving the error (RFC 9457 extension member). */
19248
19250
  hint;
19251
+ constructor(message, options = {}) {
19252
+ super(message);
19253
+ this.details = options.details;
19254
+ }
19249
19255
  /** Converts the error to RFC 9457 Problem Details format. */
19250
19256
  toProblemDetails(challengeId) {
19251
19257
  return {
@@ -19253,6 +19259,7 @@ var init_Errors2 = __esm({
19253
19259
  title: this.title,
19254
19260
  status: this.status,
19255
19261
  detail: this.message,
19262
+ ...this.details && Object.keys(this.details).length > 0 && { details: this.details },
19256
19263
  ...this.hint && { hint: this.hint },
19257
19264
  ...challengeId && { challengeId }
19258
19265
  };
@@ -19286,8 +19293,10 @@ var init_Errors2 = __esm({
19286
19293
  title = "Verification Failed";
19287
19294
  type = "https://paymentauth.org/problems/verification-failed";
19288
19295
  constructor(options = {}) {
19289
- const { reason } = options;
19290
- super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed.");
19296
+ const { details, reason } = options;
19297
+ super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed.", {
19298
+ details
19299
+ });
19291
19300
  }
19292
19301
  };
19293
19302
  PaymentActionRequiredError = class extends PaymentError {
@@ -19519,7 +19528,7 @@ var version3;
19519
19528
  var init_version2 = __esm({
19520
19529
  "node_modules/viem/_esm/errors/version.js"() {
19521
19530
  "use strict";
19522
- version3 = "2.55.2";
19531
+ version3 = "2.55.8";
19523
19532
  }
19524
19533
  });
19525
19534
 
@@ -20004,60 +20013,93 @@ var init_isAddress = __esm({
20004
20013
  }
20005
20014
  });
20006
20015
 
20007
- // node_modules/viem/_esm/errors/unit.js
20008
- var InvalidDecimalNumberError;
20009
- var init_unit = __esm({
20010
- "node_modules/viem/_esm/errors/unit.js"() {
20011
- "use strict";
20012
- init_base();
20013
- InvalidDecimalNumberError = class extends BaseError3 {
20014
- constructor({ value }) {
20015
- super(`Number \`${value}\` is not a valid decimal number.`, {
20016
- name: "InvalidDecimalNumberError"
20017
- });
20018
- }
20019
- };
20020
- }
20021
- });
20022
-
20023
- // node_modules/viem/_esm/utils/unit/parseUnits.js
20024
- function parseUnits(value, decimals) {
20025
- if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(value))
20016
+ // node_modules/viem/_esm/utils/unit/Value.js
20017
+ function from6(value, decimals = 0) {
20018
+ if (!Number.isInteger(decimals) || decimals < 0)
20019
+ throw new InvalidDecimalsError({ decimals });
20020
+ if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
20026
20021
  throw new InvalidDecimalNumberError({ value });
20027
- let [integer2, fraction = "0"] = value.split(".");
20022
+ let [integer2 = "", fraction = "0"] = value.split(".");
20028
20023
  const negative = integer2.startsWith("-");
20029
20024
  if (negative)
20030
20025
  integer2 = integer2.slice(1);
20026
+ if (integer2 === "")
20027
+ integer2 = "0";
20031
20028
  fraction = fraction.replace(/(0+)$/, "");
20032
20029
  if (decimals === 0) {
20033
- if (Math.round(Number(`.${fraction}`)) === 1)
20030
+ if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
20034
20031
  integer2 = `${BigInt(integer2) + 1n}`;
20035
20032
  fraction = "";
20036
20033
  } else if (fraction.length > decimals) {
20037
- const [left, unit, right] = [
20038
- fraction.slice(0, decimals - 1),
20039
- fraction.slice(decimals - 1, decimals),
20040
- fraction.slice(decimals)
20041
- ];
20042
- const rounded = Math.round(Number(`${unit}.${right}`));
20043
- if (rounded > 9)
20044
- fraction = `${BigInt(left) + BigInt(1)}0`.padStart(left.length + 1, "0");
20045
- else
20046
- fraction = `${left}${rounded}`;
20047
- if (fraction.length > decimals) {
20048
- fraction = fraction.slice(1);
20049
- integer2 = `${BigInt(integer2) + 1n}`;
20034
+ const left = fraction.slice(0, decimals);
20035
+ const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
20036
+ if (roundDigit >= 5) {
20037
+ const carried = carry(left);
20038
+ if (carried.length > decimals) {
20039
+ fraction = carried.slice(1);
20040
+ integer2 = `${BigInt(integer2) + 1n}`;
20041
+ } else {
20042
+ fraction = carried;
20043
+ }
20044
+ } else {
20045
+ fraction = left;
20050
20046
  }
20051
- fraction = fraction.slice(0, decimals);
20052
20047
  } else {
20053
20048
  fraction = fraction.padEnd(decimals, "0");
20054
20049
  }
20055
20050
  return BigInt(`${negative ? "-" : ""}${integer2}${fraction}`);
20056
20051
  }
20052
+ function carry(digits) {
20053
+ const out = digits.split("");
20054
+ let i = out.length - 1;
20055
+ while (i >= 0) {
20056
+ const d = Number.parseInt(out[i], 10) + 1;
20057
+ if (d < 10) {
20058
+ out[i] = String(d);
20059
+ return out.join("");
20060
+ }
20061
+ out[i] = "0";
20062
+ i--;
20063
+ }
20064
+ return `1${out.join("")}`;
20065
+ }
20066
+ var InvalidDecimalNumberError, InvalidDecimalsError;
20067
+ var init_Value2 = __esm({
20068
+ "node_modules/viem/_esm/utils/unit/Value.js"() {
20069
+ "use strict";
20070
+ InvalidDecimalNumberError = class extends Error {
20071
+ constructor({ value }) {
20072
+ super(`Value \`${value}\` is not a valid decimal number.`);
20073
+ Object.defineProperty(this, "name", {
20074
+ enumerable: true,
20075
+ configurable: true,
20076
+ writable: true,
20077
+ value: "Value.InvalidDecimalNumberError"
20078
+ });
20079
+ }
20080
+ };
20081
+ InvalidDecimalsError = class extends Error {
20082
+ constructor({ decimals }) {
20083
+ super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
20084
+ Object.defineProperty(this, "name", {
20085
+ enumerable: true,
20086
+ configurable: true,
20087
+ writable: true,
20088
+ value: "Value.InvalidDecimalsError"
20089
+ });
20090
+ }
20091
+ };
20092
+ }
20093
+ });
20094
+
20095
+ // node_modules/viem/_esm/utils/unit/parseUnits.js
20096
+ function parseUnits(value, decimals) {
20097
+ return from6(value, decimals);
20098
+ }
20057
20099
  var init_parseUnits = __esm({
20058
20100
  "node_modules/viem/_esm/utils/unit/parseUnits.js"() {
20059
20101
  "use strict";
20060
- init_unit();
20102
+ init_Value2();
20061
20103
  }
20062
20104
  });
20063
20105
 
@@ -20281,13 +20323,70 @@ var init_Chains = __esm({
20281
20323
  // node_modules/mppx/dist/Method.js
20282
20324
  var Method_exports = {};
20283
20325
  __export(Method_exports, {
20284
- from: () => from6,
20326
+ broadcastCredential: () => broadcastCredential,
20327
+ from: () => from7,
20328
+ selectServerMethod: () => selectServerMethod,
20285
20329
  toClient: () => toClient,
20286
- toServer: () => toServer
20330
+ toServer: () => toServer,
20331
+ validateCredential: () => validateCredential
20287
20332
  });
20288
- function from6(method) {
20333
+ function from7(method) {
20289
20334
  return method;
20290
20335
  }
20336
+ async function validateCredential(methods, input) {
20337
+ const prepared = prepareCredential(methods, input);
20338
+ if (!prepared.method.validate)
20339
+ throw new VerificationFailedError({
20340
+ details: { intent: prepared.method.intent, method: prepared.method.name },
20341
+ reason: `${prepared.method.name}/${prepared.method.intent} does not support non-mutating credential validation`
20342
+ });
20343
+ return prepared.method.validate({
20344
+ credential: prepared.credential,
20345
+ request: prepared.request
20346
+ });
20347
+ }
20348
+ async function broadcastCredential(methods, input) {
20349
+ const prepared = prepareCredential(methods, input);
20350
+ const { method } = prepared;
20351
+ if (method.broadcast && method.validate)
20352
+ await method.validate({ credential: prepared.credential, request: prepared.request });
20353
+ const broadcast = method.broadcast ?? method.verify;
20354
+ return broadcast({ credential: prepared.credential, request: prepared.request });
20355
+ }
20356
+ function prepareCredential(methods, input) {
20357
+ const credential = typeof input === "string" ? deserialize3(input) : input;
20358
+ const candidates = methods.filter((method2) => method2.name === credential.challenge.method && method2.intent === credential.challenge.intent);
20359
+ const method = selectServerMethod(candidates, credential.challenge);
20360
+ if (!method)
20361
+ throw new InvalidChallengeError({
20362
+ id: credential.challenge.id,
20363
+ reason: `no registered method for ${credential.challenge.method}/${credential.challenge.intent}`
20364
+ });
20365
+ assert5(credential.challenge.expires, credential.challenge.id);
20366
+ let payload;
20367
+ try {
20368
+ payload = method.schema.credential.payload.parse(credential.payload);
20369
+ } catch (error51) {
20370
+ throw new InvalidPayloadError(error51 instanceof Error ? { reason: error51.message } : {});
20371
+ }
20372
+ return {
20373
+ credential: { ...credential, payload },
20374
+ method,
20375
+ request: credential.challenge.request
20376
+ };
20377
+ }
20378
+ function selectServerMethod(methods, challenge) {
20379
+ if (methods.length <= 1)
20380
+ return methods[0];
20381
+ if (challenge.method !== Methods.tempo || challenge.intent !== Intents.session)
20382
+ return methods[0];
20383
+ const sessionProtocol = getMethodDetail(challenge.request.methodDetails, MethodDetailKeys.sessionProtocol);
20384
+ if (sessionProtocol === void 0 || sessionProtocol === SessionProtocols.v1)
20385
+ return methods.find((method) => method.alias === "sessionLegacy") ?? methods[0];
20386
+ if (sessionProtocol === SessionProtocols.v2)
20387
+ return methods.find((method) => method.alias === void 0) ?? methods[0];
20388
+ return void 0;
20389
+ }
20291
20390
  function toClient(method, options) {
20292
20391
  const { canHandleChallenge, context, createCredential } = options;
20293
20392
  return {
@@ -20298,7 +20397,16 @@ function toClient(method, options) {
20298
20397
  };
20299
20398
  }
20300
20399
  function toServer(method, options) {
20301
- const { alias, authorize, defaults, extensions, html, preflight, request, respond, stableBinding, transport, verify: verify3 } = options;
20400
+ const { alias, authorize, defaults, extensions, html, preflight, request, respond, broadcast, stableBinding, transport, validate: validate4, verify: verify3 } = options;
20401
+ const effectiveVerify = verify3 ?? (async (parameters) => {
20402
+ if (validate4)
20403
+ await validate4(parameters);
20404
+ if (!broadcast)
20405
+ throw new VerificationFailedError({
20406
+ reason: `${method.name}/${method.intent} does not support credential broadcast`
20407
+ });
20408
+ return broadcast(parameters);
20409
+ });
20302
20410
  return {
20303
20411
  ...method,
20304
20412
  alias,
@@ -20309,14 +20417,20 @@ function toServer(method, options) {
20309
20417
  preflight,
20310
20418
  request,
20311
20419
  respond,
20420
+ broadcast,
20312
20421
  stableBinding,
20313
20422
  transport,
20314
- verify: verify3
20423
+ validate: validate4,
20424
+ verify: effectiveVerify
20315
20425
  };
20316
20426
  }
20317
20427
  var init_Method = __esm({
20318
20428
  "node_modules/mppx/dist/Method.js"() {
20319
20429
  "use strict";
20430
+ init_Constants();
20431
+ init_Credential();
20432
+ init_Errors2();
20433
+ init_Expires();
20320
20434
  }
20321
20435
  });
20322
20436
 
@@ -20445,7 +20559,7 @@ var init_Methods = __esm({
20445
20559
  init_Method();
20446
20560
  init_zod();
20447
20561
  init_Types();
20448
- charge = from6({
20562
+ charge = from7({
20449
20563
  name: paymentMethod,
20450
20564
  intent: chargeIntent,
20451
20565
  schema: {
@@ -20537,15 +20651,15 @@ var Receipt_exports = {};
20537
20651
  __export(Receipt_exports, {
20538
20652
  Schema: () => Schema2,
20539
20653
  deserialize: () => deserialize4,
20540
- from: () => from7,
20654
+ from: () => from8,
20541
20655
  fromResponse: () => fromResponse2,
20542
20656
  serialize: () => serialize4
20543
20657
  });
20544
20658
  function deserialize4(encoded) {
20545
20659
  const json2 = Base64_exports.toString(encoded);
20546
- return from7(JSON.parse(json2));
20660
+ return from8(JSON.parse(json2));
20547
20661
  }
20548
- function from7(parameters) {
20662
+ function from8(parameters) {
20549
20663
  return Schema2.parse(parameters);
20550
20664
  }
20551
20665
  function serialize4(receipt) {
@@ -20588,12 +20702,12 @@ var init_Receipt = __esm({
20588
20702
  var Store_exports = {};
20589
20703
  __export(Store_exports, {
20590
20704
  cloudflare: () => cloudflare,
20591
- from: () => from8,
20705
+ from: () => from9,
20592
20706
  memory: () => memory,
20593
20707
  redis: () => redis,
20594
20708
  upstash: () => upstash
20595
20709
  });
20596
- function from8(store, options) {
20710
+ function from9(store, options) {
20597
20711
  return withKeyPrefix(store, options?.keyPrefix);
20598
20712
  }
20599
20713
  function withKeyPrefix(store, keyPrefix = "") {
@@ -20604,7 +20718,7 @@ function withKeyPrefix(store, keyPrefix = "") {
20604
20718
  return cached2;
20605
20719
  const backing = store;
20606
20720
  const prefixedKey = (key) => `${keyPrefix}${key}`;
20607
- const prefixed = from8({
20721
+ const prefixed = from9({
20608
20722
  async get(key) {
20609
20723
  return backing.get(prefixedKey(key));
20610
20724
  },
@@ -20641,7 +20755,7 @@ function wrapJsonUpdate(update) {
20641
20755
  };
20642
20756
  }
20643
20757
  function cloudflare(kv, options) {
20644
- return from8({
20758
+ return from9({
20645
20759
  async get(key) {
20646
20760
  const raw = await kv.get(key);
20647
20761
  if (raw == null)
@@ -20659,7 +20773,7 @@ function cloudflare(kv, options) {
20659
20773
  }
20660
20774
  function memory(options) {
20661
20775
  const store = /* @__PURE__ */ new Map();
20662
- return from8({
20776
+ return from9({
20663
20777
  async get(key) {
20664
20778
  const raw = store.get(key);
20665
20779
  if (raw === void 0)
@@ -20684,7 +20798,7 @@ function memory(options) {
20684
20798
  }, options);
20685
20799
  }
20686
20800
  function redis(client, options) {
20687
- return from8({
20801
+ return from9({
20688
20802
  async get(key) {
20689
20803
  const raw = await client.get(key);
20690
20804
  if (raw == null)
@@ -20701,7 +20815,7 @@ function redis(client, options) {
20701
20815
  }, options);
20702
20816
  }
20703
20817
  function upstash(redis2, options) {
20704
- return from8({
20818
+ return from9({
20705
20819
  async get(key) {
20706
20820
  return await redis2.get(key);
20707
20821
  },