@agent-score/commerce 2.0.1 → 2.0.2

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.
@@ -19087,7 +19087,7 @@ function deserialize3(value) {
19087
19087
  try {
19088
19088
  const json2 = Base64_exports.toString(prefixMatch[1]);
19089
19089
  const parsed = JSON.parse(json2);
19090
- const { opaque: challengeOpaque, request, ...challengeFields } = parsed.challenge;
19090
+ const { opaque: challengeOpaque, request, meta: _meta, ...challengeFields } = parsed.challenge;
19091
19091
  const { meta: meta4, opaque } = normalizeCredentialOpaque(challengeOpaque);
19092
19092
  const challenge = Schema.parse({
19093
19093
  ...challengeFields,
@@ -21056,7 +21056,7 @@ function createAgentScoreCore(options) {
21056
21056
  } = options;
21057
21057
  const baseUrl = stripTrailingSlashes(rawBaseUrl);
21058
21058
  const agentMemoryHint = buildAgentMemoryHint();
21059
- const defaultUa = `@agent-score/commerce@${"2.0.1"}`;
21059
+ const defaultUa = `@agent-score/commerce@${"2.0.2"}`;
21060
21060
  const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
21061
21061
  const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
21062
21062
  const sessionSdkCache = /* @__PURE__ */ new Map();
@@ -22516,6 +22516,38 @@ var Checkout = class {
22516
22516
  }
22517
22517
  return "tempo";
22518
22518
  }
22519
+ /** Map an mppx credential `method` (`tempo` | `solana` | `stripe`) to the
22520
+ * merchant's rails-dict key. Used in handleMppx so onSettled outcomes
22521
+ * distinguish Solana from Tempo (both settle under `rail: 'mpp'`) and from
22522
+ * Stripe SPT. Returns the first matching key or `undefined` when no rail in
22523
+ * the merchant's config corresponds to that method. */
22524
+ railsKeyForMppxMethod(method) {
22525
+ if (method === "stripe") {
22526
+ for (const [k, v] of Object.entries(this.rails)) {
22527
+ if (isStripeRailSpec2(v)) return k;
22528
+ }
22529
+ return void 0;
22530
+ }
22531
+ if (method === "solana") {
22532
+ for (const [k, v] of Object.entries(this.rails)) {
22533
+ if (isStripeRailSpec2(v) || isTempoSessionRailSpec3(v)) continue;
22534
+ const network = v.network ?? "";
22535
+ if (network.startsWith("solana:") || "rpcUrl" in v || "tokenProgram" in v) return k;
22536
+ }
22537
+ return void 0;
22538
+ }
22539
+ if (method === "tempo") {
22540
+ for (const [k, v] of Object.entries(this.rails)) {
22541
+ if (isStripeRailSpec2(v)) continue;
22542
+ const network = v.network ?? "";
22543
+ if (network.startsWith("solana:") || "rpcUrl" in v || "tokenProgram" in v) continue;
22544
+ if (network.startsWith("eip155:")) continue;
22545
+ return k;
22546
+ }
22547
+ return void 0;
22548
+ }
22549
+ return void 0;
22550
+ }
22519
22551
  /** CAIP-2 read from `rails['x402_base'].network` (or its default).
22520
22552
  * Defined only when an `X402BaseRailSpec` is present in rails AND a server
22521
22553
  * is configured (explicit or auto-derived); otherwise `null`. */
@@ -22862,15 +22894,20 @@ var Checkout = class {
22862
22894
  }
22863
22895
  const composed = await this.composeMppx(ctx);
22864
22896
  if (composed.status === 200) {
22897
+ const paymentReceiptHeader = composed.paymentReceiptHeader ?? extractMppxReceiptHeaderFromRaw(composed.raw);
22898
+ const directMethod = composed.raw?.receipt?.method;
22899
+ const headerMethod = paymentReceiptHeader ? await extractMppxReceiptMethod(paymentReceiptHeader) : void 0;
22900
+ const receiptMethod = directMethod ?? headerMethod;
22901
+ const derivedKey = typeof receiptMethod === "string" ? this.railsKeyForMppxMethod(receiptMethod) : void 0;
22865
22902
  const outcome = {
22866
22903
  rail: "mpp",
22867
22904
  paymentResponseHeader: composed.paymentResponseHeader ?? null,
22868
- paymentReceiptHeader: composed.paymentReceiptHeader ?? extractMppxReceiptHeaderFromRaw(composed.raw),
22905
+ paymentReceiptHeader,
22869
22906
  raw: composed.raw,
22870
22907
  txHash: composed.txHash ?? null,
22871
22908
  signerAddress: composed.signerAddress ?? null,
22872
22909
  signerNetwork: composed.signerNetwork ?? null,
22873
- railKey: composed.railKey ?? this.mppRailKey()
22910
+ railKey: derivedKey ?? composed.railKey ?? this.mppRailKey()
22874
22911
  };
22875
22912
  return await this.buildSuccess(ctx, outcome);
22876
22913
  }
@@ -23035,6 +23072,14 @@ function extractMppxReceiptHeaderFromRaw(raw) {
23035
23072
  return null;
23036
23073
  }
23037
23074
  }
23075
+ async function extractMppxReceiptMethod(header) {
23076
+ try {
23077
+ const { Receipt } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
23078
+ return Receipt.deserialize(header).method;
23079
+ } catch {
23080
+ return void 0;
23081
+ }
23082
+ }
23038
23083
  function headersToRecord(h) {
23039
23084
  if (h === void 0) return {};
23040
23085
  if (h instanceof Headers) {