@agent-score/commerce 2.3.0 → 2.4.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 (66) hide show
  1. package/README.md +6 -6
  2. package/dist/challenge/index.d.mts +4 -4
  3. package/dist/challenge/index.d.ts +4 -4
  4. package/dist/challenge/index.js.map +1 -1
  5. package/dist/challenge/index.mjs.map +1 -1
  6. package/dist/{checkout-ChyOi7aU.d.ts → checkout-B-MIzYzW.d.ts} +8 -11
  7. package/dist/{checkout-Ceo1_rVJ.d.mts → checkout-Bn7ZKIBD.d.mts} +8 -11
  8. package/dist/core.d.mts +4 -6
  9. package/dist/core.d.ts +4 -6
  10. package/dist/core.js +1 -1
  11. package/dist/core.js.map +1 -1
  12. package/dist/core.mjs +1 -1
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/discovery/index.d.mts +10 -9
  15. package/dist/discovery/index.d.ts +10 -9
  16. package/dist/discovery/index.js +44 -6
  17. package/dist/discovery/index.js.map +1 -1
  18. package/dist/discovery/index.mjs +44 -6
  19. package/dist/discovery/index.mjs.map +1 -1
  20. package/dist/identity/express.js +13 -13
  21. package/dist/identity/express.js.map +1 -1
  22. package/dist/identity/express.mjs +13 -13
  23. package/dist/identity/express.mjs.map +1 -1
  24. package/dist/identity/fastify.js +13 -13
  25. package/dist/identity/fastify.js.map +1 -1
  26. package/dist/identity/fastify.mjs +13 -13
  27. package/dist/identity/fastify.mjs.map +1 -1
  28. package/dist/identity/hono.js +13 -13
  29. package/dist/identity/hono.js.map +1 -1
  30. package/dist/identity/hono.mjs +13 -13
  31. package/dist/identity/hono.mjs.map +1 -1
  32. package/dist/identity/nextjs.js +13 -13
  33. package/dist/identity/nextjs.js.map +1 -1
  34. package/dist/identity/nextjs.mjs +13 -13
  35. package/dist/identity/nextjs.mjs.map +1 -1
  36. package/dist/identity/policy.js.map +1 -1
  37. package/dist/identity/policy.mjs.map +1 -1
  38. package/dist/identity/web.js +13 -13
  39. package/dist/identity/web.js.map +1 -1
  40. package/dist/identity/web.mjs +13 -13
  41. package/dist/identity/web.mjs.map +1 -1
  42. package/dist/index.d.mts +12 -13
  43. package/dist/index.d.ts +12 -13
  44. package/dist/index.js +86 -65
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +84 -65
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/{default_rails-DtR_E9N9.d.ts → network_kind-BIJM2peR.d.ts} +22 -8
  49. package/dist/{default_rails-K25PtWrL.d.mts → network_kind-C0EMkdzz.d.mts} +22 -8
  50. package/dist/payment/index.d.mts +16 -26
  51. package/dist/payment/index.d.ts +16 -26
  52. package/dist/payment/index.js +62 -57
  53. package/dist/payment/index.js.map +1 -1
  54. package/dist/payment/index.mjs +62 -57
  55. package/dist/payment/index.mjs.map +1 -1
  56. package/dist/{pricing-B3-aKxSz.d.ts → pricing-CytRwhC2.d.ts} +1 -1
  57. package/dist/{pricing-BReyZiqN.d.mts → pricing-KHDqMLd7.d.mts} +1 -1
  58. package/dist/{rail_spec-B1239jPp.d.mts → rail_spec-BFZmW9RN.d.mts} +3 -4
  59. package/dist/{rail_spec-B1239jPp.d.ts → rail_spec-BFZmW9RN.d.ts} +3 -4
  60. package/dist/stripe-multichain/index.d.mts +2 -9
  61. package/dist/stripe-multichain/index.d.ts +2 -9
  62. package/dist/stripe-multichain/index.js.map +1 -1
  63. package/dist/stripe-multichain/index.mjs.map +1 -1
  64. package/dist/{wwwauthenticate-D_FMnPgU.d.mts → wwwauthenticate-CVaGUMjU.d.mts} +8 -6
  65. package/dist/{wwwauthenticate-D_FMnPgU.d.ts → wwwauthenticate-CVaGUMjU.d.ts} +8 -6
  66. package/package.json +9 -8
package/dist/index.d.mts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { VerifyWalletSignerResult, DenialReason } from './core.mjs';
2
2
  export { AccountVerification, AgentIdentity, AgentMemoryHint, AgentScoreCore, AssessResult, CreateSessionOnMissing, DenialCode, EvaluateOutcome, OperatorVerification, PolicyCheck, PolicyResult, SignerVerdict, buildAgentMemoryHint } from './core.mjs';
3
3
  export { P as PaymentSigner, S as SignerNetwork, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from './signer-3FAit11j.mjs';
4
- import { q as UCPSigningKey, n as UCPProfile } from './checkout-Ceo1_rVJ.mjs';
5
- export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-Ceo1_rVJ.mjs';
4
+ import { q as UCPSigningKey, n as UCPProfile } from './checkout-Bn7ZKIBD.mjs';
5
+ export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-Bn7ZKIBD.mjs';
6
6
  export { EnforcementMode, GateResult, IdentityStatus, PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy } from './identity/policy.mjs';
7
- import { H as HeadersLike } from './default_rails-K25PtWrL.mjs';
8
- export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, l as loadSolanaFeePayer } from './default_rails-K25PtWrL.mjs';
9
- import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-B1239jPp.mjs';
10
- export { c as TempoSessionRailSpec } from './rail_spec-B1239jPp.mjs';
7
+ import { H as HeadersLike } from './network_kind-C0EMkdzz.mjs';
8
+ export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, i as isEvmNetwork, j as isSolanaNetwork, l as loadSolanaFeePayer } from './network_kind-C0EMkdzz.mjs';
9
+ import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-BFZmW9RN.mjs';
10
+ export { c as TempoSessionRailSpec } from './rail_spec-BFZmW9RN.mjs';
11
11
  import { Context } from 'hono';
12
- import './pricing-BReyZiqN.mjs';
12
+ import './pricing-KHDqMLd7.mjs';
13
13
  import './x402_server-Ciz2mls2.mjs';
14
14
 
15
15
  /**
@@ -163,7 +163,7 @@ declare function verificationAgentInstructions({ userAction, retryStep, extraSte
163
163
  * status: 403,
164
164
  * body: buildVerificationRequiredBody(reason, {
165
165
  * message: 'Identity verification is required to call this endpoint.',
166
- * agentInstructions: VERIFICATION_AGENT_INSTRUCTIONS,
166
+ * agentInstructions: JSON.stringify(VERIFICATION_AGENT_INSTRUCTIONS),
167
167
  * }),
168
168
  * };
169
169
  * }
@@ -599,9 +599,8 @@ declare function extractOwnerScope(input: Request | HeadersLike): OwnerScope;
599
599
  * Cross-module typed errors.
600
600
  *
601
601
  * Lives in its own module so `payment/` and `stripe-multichain/` helpers can
602
- * throw `CheckoutValidationError` without importing from `checkout.ts`. (In
603
- * the python sibling this avoids a checkout → payment → checkout cycle; in
604
- * node it sidesteps tsup's per-entry class duplication.)
602
+ * throw `CheckoutValidationError` without importing from `checkout.ts` — this
603
+ * also sidesteps tsup's per-entry class duplication.
605
604
  *
606
605
  * Re-exported from `checkout.ts` and the top-level entry to preserve the
607
606
  * public import path.
@@ -866,8 +865,8 @@ interface ComputeFirstHandler {
866
865
  declare function computeFirstCheckout(opts: ComputeFirstOptions): ComputeFirstHandler;
867
866
 
868
867
  /** Factory for the standard `onDenied` callback shape used by Checkout's
869
- * gate config. Replaces the ~100-line switch every consumer codebase
870
- * (sayer, martin, sandbox) wrote by hand.
868
+ * gate config. Replaces the denial-mapping switch a merchant would otherwise
869
+ * hand-write.
871
870
  *
872
871
  * The shape is framework-neutral (`{status, body, headers?}`) — matches
873
872
  * `Checkout`'s `onDenied` signature directly. For per-framework gate
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { VerifyWalletSignerResult, DenialReason } from './core.js';
2
2
  export { AccountVerification, AgentIdentity, AgentMemoryHint, AgentScoreCore, AssessResult, CreateSessionOnMissing, DenialCode, EvaluateOutcome, OperatorVerification, PolicyCheck, PolicyResult, SignerVerdict, buildAgentMemoryHint } from './core.js';
3
3
  export { P as PaymentSigner, S as SignerNetwork, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from './signer-3FAit11j.js';
4
- import { q as UCPSigningKey, n as UCPProfile } from './checkout-ChyOi7aU.js';
5
- export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-ChyOi7aU.js';
4
+ import { q as UCPSigningKey, n as UCPProfile } from './checkout-B-MIzYzW.js';
5
+ export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-B-MIzYzW.js';
6
6
  export { EnforcementMode, GateResult, IdentityStatus, PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy } from './identity/policy.js';
7
- import { H as HeadersLike } from './default_rails-DtR_E9N9.js';
8
- export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, l as loadSolanaFeePayer } from './default_rails-DtR_E9N9.js';
9
- import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-B1239jPp.js';
10
- export { c as TempoSessionRailSpec } from './rail_spec-B1239jPp.js';
7
+ import { H as HeadersLike } from './network_kind-BIJM2peR.js';
8
+ export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, i as isEvmNetwork, j as isSolanaNetwork, l as loadSolanaFeePayer } from './network_kind-BIJM2peR.js';
9
+ import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-BFZmW9RN.js';
10
+ export { c as TempoSessionRailSpec } from './rail_spec-BFZmW9RN.js';
11
11
  import { Context } from 'hono';
12
- import './pricing-B3-aKxSz.js';
12
+ import './pricing-CytRwhC2.js';
13
13
  import './x402_server-Ciz2mls2.js';
14
14
 
15
15
  /**
@@ -163,7 +163,7 @@ declare function verificationAgentInstructions({ userAction, retryStep, extraSte
163
163
  * status: 403,
164
164
  * body: buildVerificationRequiredBody(reason, {
165
165
  * message: 'Identity verification is required to call this endpoint.',
166
- * agentInstructions: VERIFICATION_AGENT_INSTRUCTIONS,
166
+ * agentInstructions: JSON.stringify(VERIFICATION_AGENT_INSTRUCTIONS),
167
167
  * }),
168
168
  * };
169
169
  * }
@@ -599,9 +599,8 @@ declare function extractOwnerScope(input: Request | HeadersLike): OwnerScope;
599
599
  * Cross-module typed errors.
600
600
  *
601
601
  * Lives in its own module so `payment/` and `stripe-multichain/` helpers can
602
- * throw `CheckoutValidationError` without importing from `checkout.ts`. (In
603
- * the python sibling this avoids a checkout → payment → checkout cycle; in
604
- * node it sidesteps tsup's per-entry class duplication.)
602
+ * throw `CheckoutValidationError` without importing from `checkout.ts` — this
603
+ * also sidesteps tsup's per-entry class duplication.
605
604
  *
606
605
  * Re-exported from `checkout.ts` and the top-level entry to preserve the
607
606
  * public import path.
@@ -866,8 +865,8 @@ interface ComputeFirstHandler {
866
865
  declare function computeFirstCheckout(opts: ComputeFirstOptions): ComputeFirstHandler;
867
866
 
868
867
  /** Factory for the standard `onDenied` callback shape used by Checkout's
869
- * gate config. Replaces the ~100-line switch every consumer codebase
870
- * (sayer, martin, sandbox) wrote by hand.
868
+ * gate config. Replaces the denial-mapping switch a merchant would otherwise
869
+ * hand-write.
871
870
  *
872
871
  * The shape is framework-neutral (`{status, body, headers?}`) — matches
873
872
  * `Checkout`'s `onDenied` signature directly. For per-framework gate
package/dist/index.js CHANGED
@@ -331,19 +331,19 @@ function stableStringify(value) {
331
331
  }
332
332
  if (!Number.isInteger(value)) {
333
333
  throw new Error(
334
- `UCP profile canonicalization rejects non-integer Number ${value}. Use a decimal string (e.g. "9.99") for monetary or fractional fields to preserve cross-language byte-parity.`
334
+ `UCP profile canonicalization rejects non-integer Number ${value}. Use a decimal string (e.g. "9.99") for monetary or fractional fields so the signed canonical bytes stay stable for any verifier.`
335
335
  );
336
336
  }
337
337
  if (!Number.isSafeInteger(value)) {
338
338
  throw new Error(
339
- `stableStringify: integer ${value} exceeds Number.MAX_SAFE_INTEGER. For values >2^53, use a decimal string to preserve cross-language byte parity.`
339
+ `stableStringify: integer ${value} exceeds Number.MAX_SAFE_INTEGER. For values >2^53, use a decimal string to keep the signed bytes stable across implementations.`
340
340
  );
341
341
  }
342
342
  }
343
343
  if (typeof value === "string") {
344
344
  if (value.includes("\u2028") || value.includes("\u2029")) {
345
345
  throw new Error(
346
- "stableStringify: strings containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; cross-language byte parity requires neither be present (Node JSON.stringify on older V8 escapes them; Python json.dumps with ensure_ascii=False does not)."
346
+ "stableStringify: strings containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; stable canonical bytes require neither be present (some JSON encoders escape them, others emit them raw)."
347
347
  );
348
348
  }
349
349
  return JSON.stringify(value);
@@ -363,7 +363,7 @@ function stableStringify(value) {
363
363
  for (const k of keys) {
364
364
  if (k.includes("\u2028") || k.includes("\u2029")) {
365
365
  throw new Error(
366
- "stableStringify: object keys containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; cross-language byte parity (Node JSON.stringify on older V8 escapes them; Python json.dumps with ensure_ascii=False does not)."
366
+ "stableStringify: object keys containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; stable canonical bytes require neither be present (some JSON encoders escape them, others emit them raw)."
367
367
  );
368
368
  }
369
369
  }
@@ -20330,6 +20330,53 @@ var init_networks = __esm({
20330
20330
  }
20331
20331
  });
20332
20332
 
20333
+ // src/payment/amounts.ts
20334
+ function usdToAtomic(usd, opts) {
20335
+ const { decimals } = opts;
20336
+ if (!Number.isInteger(decimals) || decimals < 0) {
20337
+ throw new RangeError(`decimals must be a non-negative integer, got ${decimals}`);
20338
+ }
20339
+ if (typeof usd === "number") {
20340
+ if (!Number.isFinite(usd)) {
20341
+ throw new RangeError(`usd must be finite, got ${usd}`);
20342
+ }
20343
+ if (usd < 0) {
20344
+ throw new RangeError(`usd must be non-negative, got ${usd}`);
20345
+ }
20346
+ }
20347
+ const s = (typeof usd === "number" ? usd.toString() : usd).trim();
20348
+ if (s.startsWith("-")) {
20349
+ throw new RangeError(`usd must be non-negative, got ${s}`);
20350
+ }
20351
+ if (s === "NaN" || s === "Infinity") {
20352
+ throw new RangeError(`usd must be finite, got ${s}`);
20353
+ }
20354
+ const match = /^(\d*)(?:\.(\d*))?$/.exec(s);
20355
+ if (!match || match[1] === "" && (match[2] === void 0 || match[2] === "")) {
20356
+ throw new SyntaxError(`invalid usd value: ${JSON.stringify(usd)}`);
20357
+ }
20358
+ const intPart = match[1] || "0";
20359
+ const fracPart = match[2] ?? "";
20360
+ if (fracPart.length <= decimals) {
20361
+ return BigInt(intPart + fracPart.padEnd(decimals, "0"));
20362
+ }
20363
+ const kept = fracPart.slice(0, decimals);
20364
+ const roundDigit = fracPart[decimals];
20365
+ let result = BigInt(intPart + kept);
20366
+ if (roundDigit >= "5") {
20367
+ result += 1n;
20368
+ }
20369
+ return result;
20370
+ }
20371
+ function formatUsdCents(cents, decimals = 2) {
20372
+ return (cents / 100).toFixed(decimals);
20373
+ }
20374
+ var init_amounts = __esm({
20375
+ "src/payment/amounts.ts"() {
20376
+ "use strict";
20377
+ }
20378
+ });
20379
+
20333
20380
  // src/payment/rails.ts
20334
20381
  function lookupRail(name) {
20335
20382
  return rails[name];
@@ -20429,8 +20476,7 @@ function buildPaymentRequestBlob({
20429
20476
  const decimalsResolved = decimals ?? railDef?.decimals ?? 6;
20430
20477
  const currencyResolved = currency ?? railDef?.currency ?? "usd";
20431
20478
  const chainIdResolved = chainId ?? railDef?.chainId;
20432
- const amountNum = typeof amountUsd === "string" ? Number(amountUsd) : amountUsd;
20433
- const amountRaw = BigInt(Math.round(amountNum * 10 ** decimalsResolved)).toString();
20479
+ const amountRaw = usdToAtomic(amountUsd, { decimals: decimalsResolved }).toString();
20434
20480
  const blob = { amount: amountRaw, currency: currencyResolved, decimals: decimalsResolved };
20435
20481
  if (recipient) blob.recipient = recipient;
20436
20482
  const methodDetails = {};
@@ -20457,6 +20503,7 @@ function paymentDirective({
20457
20503
  var init_directive = __esm({
20458
20504
  "src/payment/directive.ts"() {
20459
20505
  "use strict";
20506
+ init_amounts();
20460
20507
  init_rails();
20461
20508
  }
20462
20509
  });
@@ -20844,7 +20891,9 @@ __export(index_exports, {
20844
20891
  hasPaymentHeader: () => hasPaymentHeader,
20845
20892
  hasX402Header: () => hasX402Header,
20846
20893
  hashOperatorToken: () => hashOperatorToken,
20894
+ isEvmNetwork: () => isEvmNetwork,
20847
20895
  isFixableDenial: () => isFixableDenial,
20896
+ isSolanaNetwork: () => isSolanaNetwork,
20848
20897
  loadSolanaFeePayer: () => loadSolanaFeePayer,
20849
20898
  loadUCPSigningKeyFromEnv: () => loadUCPSigningKeyFromEnv,
20850
20899
  makeMppxComposeHook: () => makeMppxComposeHook,
@@ -21222,7 +21271,7 @@ function createAgentScoreCore(options) {
21222
21271
  } = options;
21223
21272
  const baseUrl = stripTrailingSlashes(rawBaseUrl);
21224
21273
  const agentMemoryHint = buildAgentMemoryHint();
21225
- const defaultUa = `@agent-score/commerce@${"2.3.0"}`;
21274
+ const defaultUa = `@agent-score/commerce@${"2.4.0"}`;
21226
21275
  const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
21227
21276
  const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
21228
21277
  const sessionSdkCache = /* @__PURE__ */ new Map();
@@ -21562,6 +21611,18 @@ async function extractSolanaSignerFromCredential(credential) {
21562
21611
  }
21563
21612
  }
21564
21613
  async function extractPaymentSigner(request, x402PaymentHeader) {
21614
+ if (x402PaymentHeader) {
21615
+ try {
21616
+ const decoded = atob(x402PaymentHeader);
21617
+ const parsed = JSON.parse(decoded);
21618
+ const from9 = parsed?.payload?.authorization?.from;
21619
+ if (typeof from9 === "string" && /^0x[0-9a-fA-F]{40}$/.test(from9)) {
21620
+ return { address: from9.toLowerCase(), network: "evm" };
21621
+ }
21622
+ } catch (err) {
21623
+ console.warn("[gate] x402 signer extraction failed:", err instanceof Error ? err.message : err);
21624
+ }
21625
+ }
21565
21626
  const authHeader = request.headers.get("authorization");
21566
21627
  if (authHeader) {
21567
21628
  try {
@@ -21581,18 +21642,6 @@ async function extractPaymentSigner(request, x402PaymentHeader) {
21581
21642
  console.warn("[gate] MPP signer extraction failed:", err instanceof Error ? err.message : err);
21582
21643
  }
21583
21644
  }
21584
- if (x402PaymentHeader) {
21585
- try {
21586
- const decoded = atob(x402PaymentHeader);
21587
- const parsed = JSON.parse(decoded);
21588
- const from9 = parsed?.payload?.authorization?.from;
21589
- if (typeof from9 === "string" && /^0x[0-9a-fA-F]{40}$/.test(from9)) {
21590
- return { address: from9.toLowerCase(), network: "evm" };
21591
- }
21592
- } catch (err) {
21593
- console.warn("[gate] x402 signer extraction failed:", err instanceof Error ? err.message : err);
21594
- }
21595
- }
21596
21645
  return null;
21597
21646
  }
21598
21647
  async function extractPaymentSignerFromAuth(authHeader, x402PaymentHeader) {
@@ -23365,10 +23414,9 @@ var Checkout = class {
23365
23414
  ...gate.cacheSeconds !== void 0 && { cacheSeconds: gate.cacheSeconds },
23366
23415
  ...gate.chain !== void 0 && { chain: gate.chain },
23367
23416
  // Auto-default `createSessionOnMissing` from gate config when the merchant
23368
- // didn't supply one. Matches python-commerce's behavior every gated route
23369
- // gets the bootstrap session-mint UX out of the box. Merchants who need
23370
- // custom session context or onBeforeSession side effects (goods merchants
23371
- // pre-minting an order_id) supply their own config instead.
23417
+ // didn't supply one, so every gated route gets the bootstrap session-mint UX
23418
+ // out of the box. Merchants who need custom session context or onBeforeSession
23419
+ // side effects (goods merchants pre-minting an order_id) supply their own config.
23372
23420
  createSessionOnMissing: gate.createSessionOnMissing ?? {
23373
23421
  apiKey: gate.apiKey,
23374
23422
  ...gate.baseUrl !== void 0 && { baseUrl: gate.baseUrl },
@@ -24105,47 +24153,8 @@ init_wwwauthenticate();
24105
24153
  init_directive();
24106
24154
  init_wwwauthenticate();
24107
24155
 
24108
- // src/payment/amounts.ts
24109
- function usdToAtomic(usd, opts) {
24110
- const { decimals } = opts;
24111
- if (!Number.isInteger(decimals) || decimals < 0) {
24112
- throw new RangeError(`decimals must be a non-negative integer, got ${decimals}`);
24113
- }
24114
- if (typeof usd === "number") {
24115
- if (!Number.isFinite(usd)) {
24116
- throw new RangeError(`usd must be finite, got ${usd}`);
24117
- }
24118
- if (usd < 0) {
24119
- throw new RangeError(`usd must be non-negative, got ${usd}`);
24120
- }
24121
- }
24122
- const s = (typeof usd === "number" ? usd.toString() : usd).trim();
24123
- if (s.startsWith("-")) {
24124
- throw new RangeError(`usd must be non-negative, got ${s}`);
24125
- }
24126
- if (s === "NaN" || s === "Infinity") {
24127
- throw new RangeError(`usd must be finite, got ${s}`);
24128
- }
24129
- const match = /^(\d*)(?:\.(\d*))?$/.exec(s);
24130
- if (!match || match[1] === "" && (match[2] === void 0 || match[2] === "")) {
24131
- throw new SyntaxError(`invalid usd value: ${JSON.stringify(usd)}`);
24132
- }
24133
- const intPart = match[1] || "0";
24134
- const fracPart = match[2] ?? "";
24135
- if (fracPart.length <= decimals) {
24136
- return BigInt(intPart + fracPart.padEnd(decimals, "0"));
24137
- }
24138
- const kept = fracPart.slice(0, decimals);
24139
- const roundDigit = fracPart[decimals];
24140
- let result = BigInt(intPart + kept);
24141
- if (roundDigit >= "5") {
24142
- result += 1n;
24143
- }
24144
- return result;
24145
- }
24146
- function formatUsdCents(cents, decimals = 2) {
24147
- return (cents / 100).toFixed(decimals);
24148
- }
24156
+ // src/payment/index.ts
24157
+ init_amounts();
24149
24158
 
24150
24159
  // src/payment/solana.ts
24151
24160
  async function loadSolanaFeePayer(opts) {
@@ -24169,6 +24178,7 @@ async function loadSolanaFeePayer(opts) {
24169
24178
  }
24170
24179
 
24171
24180
  // src/payment/compose_rails.ts
24181
+ init_amounts();
24172
24182
  init_usdc();
24173
24183
  var warnedStripeBelowMinimum = false;
24174
24184
  function buildMppxComposeRails(opts) {
@@ -24213,7 +24223,13 @@ init_usdc();
24213
24223
  function buildDefaultCheckoutRails(opts) {
24214
24224
  const out = {};
24215
24225
  if (opts.tempo) {
24216
- out.tempo = { recipient: "", ...RAIL_SPEC_DEFAULTS.tempo, ...opts.tempo };
24226
+ const merged = { recipient: "", ...RAIL_SPEC_DEFAULTS.tempo, ...opts.tempo };
24227
+ if (merged.testnet) {
24228
+ if (opts.tempo.network === void 0) merged.network = "tempo-testnet";
24229
+ if (opts.tempo.chainId === void 0) merged.chainId = 42431;
24230
+ if (opts.tempo.token === void 0) merged.token = USDC.tempo.testnet.address;
24231
+ }
24232
+ out.tempo = merged;
24217
24233
  }
24218
24234
  if (opts.x402Base) {
24219
24235
  const merged = { recipient: "", ...RAIL_SPEC_DEFAULTS.x402Base, ...opts.x402Base };
@@ -24268,6 +24284,9 @@ function buildSuccessNextSteps(opts) {
24268
24284
  // src/discovery/index.ts
24269
24285
  init_well_known();
24270
24286
 
24287
+ // src/checkout_compute_first.ts
24288
+ init_amounts();
24289
+
24271
24290
  // src/quote_cache.ts
24272
24291
  var import_crypto = require("crypto");
24273
24292
 
@@ -24871,7 +24890,9 @@ function defaultReadOnlyOnDenied(reason) {
24871
24890
  hasPaymentHeader,
24872
24891
  hasX402Header,
24873
24892
  hashOperatorToken,
24893
+ isEvmNetwork,
24874
24894
  isFixableDenial,
24895
+ isSolanaNetwork,
24875
24896
  loadSolanaFeePayer,
24876
24897
  loadUCPSigningKeyFromEnv,
24877
24898
  makeMppxComposeHook,