@agent-score/commerce 2.6.8 → 2.7.1

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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/challenge/index.d.mts +3 -3
  3. package/dist/challenge/index.d.ts +3 -3
  4. package/dist/challenge/index.js.map +1 -1
  5. package/dist/challenge/index.mjs.map +1 -1
  6. package/dist/{checkout-PjmMESkc.d.mts → checkout-DKq9gV3G.d.mts} +15 -14
  7. package/dist/{checkout-U3tGU1Au.d.ts → checkout-DW7GgRrl.d.ts} +15 -14
  8. package/dist/core.js +1 -1
  9. package/dist/core.mjs +1 -1
  10. package/dist/discovery/index.d.mts +4 -4
  11. package/dist/discovery/index.d.ts +4 -4
  12. package/dist/identity/express.js +1 -1
  13. package/dist/identity/express.mjs +1 -1
  14. package/dist/identity/fastify.js +1 -1
  15. package/dist/identity/fastify.mjs +1 -1
  16. package/dist/identity/hono.js +1 -1
  17. package/dist/identity/hono.mjs +1 -1
  18. package/dist/identity/nextjs.js +1 -1
  19. package/dist/identity/nextjs.mjs +1 -1
  20. package/dist/identity/web.js +1 -1
  21. package/dist/identity/web.mjs +1 -1
  22. package/dist/index.d.mts +7 -7
  23. package/dist/index.d.ts +7 -7
  24. package/dist/index.js +17 -23
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +17 -23
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/{network_kind-D2xpo2Fj.d.mts → network_kind-CLdLbqU5.d.mts} +1 -1
  29. package/dist/{network_kind-BmbWKNud.d.ts → network_kind-toxNABqw.d.ts} +1 -1
  30. package/dist/payment/index.d.mts +3 -3
  31. package/dist/payment/index.d.ts +3 -3
  32. package/dist/payment/index.js +0 -2
  33. package/dist/payment/index.js.map +1 -1
  34. package/dist/payment/index.mjs +0 -2
  35. package/dist/payment/index.mjs.map +1 -1
  36. package/dist/{pricing-CytRwhC2.d.ts → pricing-Dx3F1VAv.d.ts} +1 -1
  37. package/dist/{pricing-KHDqMLd7.d.mts → pricing-sfv3CPiY.d.mts} +1 -1
  38. package/dist/{rail_spec-BFZmW9RN.d.mts → rail_spec-DGdb4Gnd.d.mts} +0 -25
  39. package/dist/{rail_spec-BFZmW9RN.d.ts → rail_spec-DGdb4Gnd.d.ts} +0 -25
  40. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -22574,7 +22574,7 @@ function createAgentScoreCore(options) {
22574
22574
  } = options;
22575
22575
  const baseUrl = stripTrailingSlashes(rawBaseUrl);
22576
22576
  const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
22577
- const defaultUa = `@agent-score/commerce@${"2.6.8"}`;
22577
+ const defaultUa = `@agent-score/commerce@${"2.7.1"}`;
22578
22578
  const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
22579
22579
  const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
22580
22580
  const sessionSdkCache = /* @__PURE__ */ new Map();
@@ -24727,13 +24727,11 @@ async function registerSolana(spec) {
24727
24727
  "createMppxServer: SolanaMppRailSpec requires a string recipient (per-order factories not supported here)."
24728
24728
  );
24729
24729
  }
24730
- const ataCreationRequired = spec.ataCreationRequired !== false;
24731
24730
  const baseMethod = solanaMpp.charge({
24732
24731
  recipient: spec.recipient,
24733
24732
  currency: spec.token ?? defaultMint,
24734
24733
  decimals: spec.decimals ?? defaultDecimals,
24735
24734
  network,
24736
- ...ataCreationRequired ? { splits: [{ recipient: spec.recipient, amount: "0", ataCreationRequired: true }] } : {},
24737
24735
  ...spec.rpcUrl ? { rpcUrl: spec.rpcUrl } : {},
24738
24736
  ...spec.signer ? { signer: spec.signer } : {},
24739
24737
  ...spec.tokenProgram ? { tokenProgram: spec.tokenProgram } : {}
@@ -25713,7 +25711,7 @@ var Checkout = class {
25713
25711
  const malformed = malformedPaymentCredential(request.headers);
25714
25712
  const enforced = malformed !== null && (malformed.channel === "x402" ? this.x402ServerAvailable() && this.x402BaseNetwork !== null : this.composeMppx !== void 0);
25715
25713
  if (enforced) {
25716
- const result = await this.emitFreshChallenge(this.discoveryView(ctx));
25714
+ const result = await this.handle(this.stripPaymentHeaders(request));
25717
25715
  return { ...result, settlePhase: "credential_malformed" };
25718
25716
  }
25719
25717
  }
@@ -26232,12 +26230,10 @@ var Checkout = class {
26232
26230
  settlePhase: "verify_failed"
26233
26231
  };
26234
26232
  }
26235
- /** Emit a fresh 402 challenge: compute pricing, mint per-order recipients,
26236
- * ask the (optional) MPP compose hook for a fresh WWW-Authenticate, and
26237
- * build the rich 402 body. This is the discovery leg, factored out so the
26238
- * malformed-credential path can reuse it verbatim. Idempotent on already
26239
- * computed pricing / resolved recipients, so the normal discovery leg (which
26240
- * primes both) pays nothing extra. */
26233
+ /** Emit the discovery-leg 402: pricing (idempotent), mint per-order
26234
+ * recipients, ask the optional MPP compose hook for a fresh WWW-Authenticate,
26235
+ * and build the rich 402 body. preValidate + pricing already ran in the main
26236
+ * flow before this is reached, so it primes nothing twice. */
26241
26237
  async emitFreshChallenge(ctx) {
26242
26238
  if (ctx.pricing === null) ctx.pricing = await this.computePricing(ctx);
26243
26239
  await this.resolveRecipientsForCtx(ctx);
@@ -26251,25 +26247,23 @@ var Checkout = class {
26251
26247
  }
26252
26248
  return await this.emit402(ctx, mppxHeaders);
26253
26249
  }
26254
- /** Return a copy of `ctx` with every payment-credential header removed, so
26255
- * downstream recipient minting and MPP compose take their discovery
26256
- * (fresh-mint, fresh-challenge) path instead of trying to bind the inbound
26257
- * credential. Used to turn a malformed-credential request into a clean 402
26258
- * re-challenge. Pricing / recipients are reset so they mint fresh. */
26259
- discoveryView(ctx) {
26250
+ /** Return a copy of the request with every payment-credential header removed,
26251
+ * so re-entering handle() treats it as a discovery (no-credential) request:
26252
+ * preValidate + pricing + minting + compose all run their fresh path, and the
26253
+ * gate/assess and settle are skipped. Turns a malformed-credential request
26254
+ * into a clean 402 re-challenge. The raw request is left intact (its body may
26255
+ * already be consumed); MPP compose reads it only best-effort under a
26256
+ * try/catch, while the stripped headers are what the credential-shape check,
26257
+ * gate dispatch, and recipient minting read. */
26258
+ stripPaymentHeaders(request) {
26260
26259
  const headers = {};
26261
- for (const [k, v] of Object.entries(ctx.request.headers)) {
26260
+ for (const [k, v] of Object.entries(request.headers)) {
26262
26261
  const lk = k.toLowerCase();
26263
26262
  if (lk === "payment-signature" || lk === "x-payment") continue;
26264
26263
  if (lk === "authorization" && v.startsWith("Payment ")) continue;
26265
26264
  headers[k] = v;
26266
26265
  }
26267
- return {
26268
- ...ctx,
26269
- request: { ...ctx.request, headers },
26270
- pricing: null,
26271
- recipients: {}
26272
- };
26266
+ return { ...request, headers };
26273
26267
  }
26274
26268
  async emit402(ctx, mppxHeaders = {}) {
26275
26269
  if (ctx.pricing === null) {