@agent-score/commerce 2.6.3 → 2.6.5

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 (42) hide show
  1. package/README.md +2 -2
  2. package/dist/{checkout-CzB9f_jf.d.mts → checkout-DOd9GDmt.d.mts} +15 -3
  3. package/dist/{checkout-C4RD7M0Z.d.ts → checkout-GcDNDzSK.d.ts} +15 -3
  4. package/dist/core.js +1 -1
  5. package/dist/core.mjs +1 -1
  6. package/dist/discovery/index.d.mts +1 -1
  7. package/dist/discovery/index.d.ts +1 -1
  8. package/dist/identity/express.js +1 -1
  9. package/dist/identity/express.js.map +1 -1
  10. package/dist/identity/express.mjs +1 -1
  11. package/dist/identity/express.mjs.map +1 -1
  12. package/dist/identity/fastify.js +1 -1
  13. package/dist/identity/fastify.js.map +1 -1
  14. package/dist/identity/fastify.mjs +1 -1
  15. package/dist/identity/fastify.mjs.map +1 -1
  16. package/dist/identity/hono.js +1 -1
  17. package/dist/identity/hono.js.map +1 -1
  18. package/dist/identity/hono.mjs +1 -1
  19. package/dist/identity/hono.mjs.map +1 -1
  20. package/dist/identity/nextjs.js +1 -1
  21. package/dist/identity/nextjs.js.map +1 -1
  22. package/dist/identity/nextjs.mjs +1 -1
  23. package/dist/identity/nextjs.mjs.map +1 -1
  24. package/dist/identity/web.js +1 -1
  25. package/dist/identity/web.js.map +1 -1
  26. package/dist/identity/web.mjs +1 -1
  27. package/dist/identity/web.mjs.map +1 -1
  28. package/dist/index.d.mts +35 -17
  29. package/dist/index.d.ts +35 -17
  30. package/dist/index.js +99 -9
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +97 -9
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/{network_kind-BIJM2peR.d.ts → network_kind-BmbWKNud.d.ts} +23 -1
  35. package/dist/{network_kind-C0EMkdzz.d.mts → network_kind-D2xpo2Fj.d.mts} +23 -1
  36. package/dist/payment/index.d.mts +42 -21
  37. package/dist/payment/index.d.ts +42 -21
  38. package/dist/payment/index.js +53 -0
  39. package/dist/payment/index.js.map +1 -1
  40. package/dist/payment/index.mjs +51 -0
  41. package/dist/payment/index.mjs.map +1 -1
  42. package/package.json +1 -1
@@ -34,6 +34,28 @@ declare function hasX402Header(input: Request | HeadersLike): boolean;
34
34
  /** True when the request carries an mppx payment credential
35
35
  * (`Authorization: Payment <jwt>`). Use to dispatch to the MPP settle path. */
36
36
  declare function hasMppxHeader(input: Request | HeadersLike): boolean;
37
+ interface MalformedPaymentCredential {
38
+ /** Which credential channel carried the malformed value. */
39
+ channel: 'x402' | 'mpp';
40
+ message: string;
41
+ }
42
+ /**
43
+ * Wire-shape gate for payment credentials, cheap enough to run before any
44
+ * merchant hook. A request whose payment header cannot possibly be a
45
+ * credential (not base64/base64url JSON, not a JWT-shaped token) is rejected
46
+ * up front, so junk headers never trigger per-request hooks (`preValidate`,
47
+ * pricing, recipient minting) or the identity-gate API call.
48
+ *
49
+ * This is deliberately a SHAPE check only. Signature verification, payTo
50
+ * binding, and challenge validation stay where they are (the x402 validator
51
+ * and the mppx settle path) — those need per-request state the hooks produce.
52
+ * A well-formed-but-invalid credential still reaches the real validators and
53
+ * fails there.
54
+ *
55
+ * Returns `null` when every present credential channel is plausibly shaped
56
+ * (or no payment header is present).
57
+ */
58
+ declare function malformedPaymentCredential(input: Request | HeadersLike): MalformedPaymentCredential | null;
37
59
 
38
60
  /**
39
61
  * USD ↔ atomic-unit conversion for token amounts.
@@ -209,4 +231,4 @@ declare function isEvmNetwork(input: NetworkLike): boolean;
209
231
  * network spec — this helper treats it as false. */
210
232
  declare function isSolanaNetwork(input: NetworkLike): boolean;
211
233
 
212
- export { type BuildDefaultCheckoutRailsOptions as B, type HeadersLike as H, type BuildMppxComposeRailsOptions as a, asHeaders as b, buildDefaultCheckoutRails as c, buildMppxComposeRails as d, hasPaymentHeader as e, formatUsdCents as f, hasX402Header as g, hasMppxHeader as h, isEvmNetwork as i, isSolanaNetwork as j, loadSolanaFeePayer as l, readHeader as r, usdToAtomic as u };
234
+ export { type BuildDefaultCheckoutRailsOptions as B, type HeadersLike as H, type MalformedPaymentCredential as M, type BuildMppxComposeRailsOptions as a, asHeaders as b, buildDefaultCheckoutRails as c, buildMppxComposeRails as d, hasPaymentHeader as e, formatUsdCents as f, hasX402Header as g, hasMppxHeader as h, isEvmNetwork as i, isSolanaNetwork as j, loadSolanaFeePayer as l, malformedPaymentCredential as m, readHeader as r, usdToAtomic as u };
@@ -34,6 +34,28 @@ declare function hasX402Header(input: Request | HeadersLike): boolean;
34
34
  /** True when the request carries an mppx payment credential
35
35
  * (`Authorization: Payment <jwt>`). Use to dispatch to the MPP settle path. */
36
36
  declare function hasMppxHeader(input: Request | HeadersLike): boolean;
37
+ interface MalformedPaymentCredential {
38
+ /** Which credential channel carried the malformed value. */
39
+ channel: 'x402' | 'mpp';
40
+ message: string;
41
+ }
42
+ /**
43
+ * Wire-shape gate for payment credentials, cheap enough to run before any
44
+ * merchant hook. A request whose payment header cannot possibly be a
45
+ * credential (not base64/base64url JSON, not a JWT-shaped token) is rejected
46
+ * up front, so junk headers never trigger per-request hooks (`preValidate`,
47
+ * pricing, recipient minting) or the identity-gate API call.
48
+ *
49
+ * This is deliberately a SHAPE check only. Signature verification, payTo
50
+ * binding, and challenge validation stay where they are (the x402 validator
51
+ * and the mppx settle path) — those need per-request state the hooks produce.
52
+ * A well-formed-but-invalid credential still reaches the real validators and
53
+ * fails there.
54
+ *
55
+ * Returns `null` when every present credential channel is plausibly shaped
56
+ * (or no payment header is present).
57
+ */
58
+ declare function malformedPaymentCredential(input: Request | HeadersLike): MalformedPaymentCredential | null;
37
59
 
38
60
  /**
39
61
  * USD ↔ atomic-unit conversion for token amounts.
@@ -209,4 +231,4 @@ declare function isEvmNetwork(input: NetworkLike): boolean;
209
231
  * network spec — this helper treats it as false. */
210
232
  declare function isSolanaNetwork(input: NetworkLike): boolean;
211
233
 
212
- export { type BuildDefaultCheckoutRailsOptions as B, type HeadersLike as H, type BuildMppxComposeRailsOptions as a, asHeaders as b, buildDefaultCheckoutRails as c, buildMppxComposeRails as d, hasPaymentHeader as e, formatUsdCents as f, hasX402Header as g, hasMppxHeader as h, isEvmNetwork as i, isSolanaNetwork as j, loadSolanaFeePayer as l, readHeader as r, usdToAtomic as u };
234
+ export { type BuildDefaultCheckoutRailsOptions as B, type HeadersLike as H, type MalformedPaymentCredential as M, type BuildMppxComposeRailsOptions as a, asHeaders as b, buildDefaultCheckoutRails as c, buildMppxComposeRails as d, hasPaymentHeader as e, formatUsdCents as f, hasX402Header as g, hasMppxHeader as h, isEvmNetwork as i, isSolanaNetwork as j, loadSolanaFeePayer as l, malformedPaymentCredential as m, readHeader as r, usdToAtomic as u };
@@ -5,7 +5,7 @@ export { B as BuildX402AcceptsForOptions, C as CreateX402ServerOptions, X as X40
5
5
  export { a as aliasAmountFields, p as paymentRequiredHeader, w as wwwAuthenticateHeader } from '../wwwauthenticate-Dgm-_af9.mjs';
6
6
  import { S as SignerNetwork } from '../signer-3FAit11j.mjs';
7
7
  export { P as PaymentSigner, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from '../signer-3FAit11j.mjs';
8
- export { B as BuildDefaultCheckoutRailsOptions, a as BuildMppxComposeRailsOptions, H as HeadersLike, b as asHeaders, 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, r as readHeader, u as usdToAtomic } from '../network_kind-C0EMkdzz.mjs';
8
+ export { B as BuildDefaultCheckoutRailsOptions, a as BuildMppxComposeRailsOptions, H as HeadersLike, M as MalformedPaymentCredential, b as asHeaders, 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, m as malformedPaymentCredential, r as readHeader, u as usdToAtomic } from '../network_kind-D2xpo2Fj.mjs';
9
9
 
10
10
  /**
11
11
  * Build the base64-encoded `request` blob for an MPP Payment directive (per the
@@ -786,25 +786,39 @@ declare function settlementOverrideHeader(overrides: SettlementOverrides): {
786
786
  };
787
787
 
788
788
  /**
789
- * Zero-amount carve-out: skip upstream verify+settle for $0 orders.
790
- *
791
- * CDP rejects EIP-3009 `transferWithAuthorization` with `value=0` as
792
- * `invalid_payload`; `mppx`'s tempo intents accept only `hash` and
793
- * `transaction` payload types (rejecting the `proof` payload that gets
794
- * emitted for $0 settles). Both upstream verify+settle paths fail when the
795
- * authorized amount is zero, so merchants that drop the settle to $0 in a
796
- * redemption-code flow need a way to skip verify+settle entirely while
797
- * still recovering the signer for wallet-capture attribution.
798
- *
799
- * `zeroAmountCarveOut` is that path: parse the credential, lift the
800
- * signer, return `{ signerAddress, signerNetwork, txHash: null }`. Identity
801
- * is still authenticated by the merchant's gate above; the redemption code
802
- * is single-use; nothing on-chain to verify.
803
- *
804
- * The MPP path uses inline base64+JSON parsing (no `mppx` dependency at
805
- * runtime) so the zero-settle path stays dependency-free. The full
806
- * `extractPaymentSigner` path is still mppx-backed for production traffic
807
- * where the credential is a real mppx-shaped object.
789
+ * Zero-amount carve-out: skip upstream verify+settle for $0 orders on the
790
+ * rails that cannot settle $0 upstream.
791
+ *
792
+ * Scope (which rail takes the carve-out is decided in `Checkout.handleZeroSettle`):
793
+ *
794
+ * - **x402 Base**: CDP rejects EIP-3009 `transferWithAuthorization` with
795
+ * `value=0` as `invalid_payload`, so $0 x402 orders take the carve-out. The
796
+ * credential is still run through `verifyX402Request` (signature shape +
797
+ * payTo binding) before the carve-out is honored.
798
+ * - **MPP `proof` credentials**: NOT carved out. mppx >= 0.8 settles
799
+ * zero-amount challenges natively via the wallet-bound EIP-712 proof
800
+ * credential (full verification, access-key authorization, replay
801
+ * protection). An agent that saw a $0 challenge signs a `proof`, so those
802
+ * delegate to the normal MPP settle path.
803
+ * - **Every other MPP credential at $0** (`hash` / `transaction` payloads,
804
+ * token-style credentials, Solana): carved out. These arise when the agent
805
+ * signed against a NONZERO quote that the merchant re-priced to $0 at
806
+ * settle (no-match / full-discount flows the authorization is simply
807
+ * never exercised), or on rails with no upstream $0 contract
808
+ * (`@solana/mpp` has no proof-credential surface). Upstream would reject
809
+ * all of them at $0, so the carve-out lifts the signer for wallet-capture
810
+ * attribution only; that signer block is UNAUTHENTICATED (parse-only) and
811
+ * must not be trusted beyond attribution hints. Identity is still
812
+ * authenticated by the merchant's gate above; nothing settles on-chain.
813
+ *
814
+ * `zeroAmountCarveOut` parses the credential, lifts the signer, and returns
815
+ * `{ signerAddress, signerNetwork, txHash: null }`. The MPP path uses inline
816
+ * base64+JSON parsing (no `mppx` dependency at runtime) so this module stays
817
+ * dependency-free. `mppCredentialPayloadType` is the router `handleZeroSettle`
818
+ * uses to decide delegation (`proof`) vs carve-out (everything else); signer
819
+ * recovery itself prefers the full `extractPaymentSigner` (which also decodes
820
+ * source-less Solana credentials from the signed transaction) with this
821
+ * module's inline parse as the dependency-free backstop.
808
822
  */
809
823
 
810
824
  type ZeroSettleRail = 'x402-base' | 'tempo' | 'solana';
@@ -838,6 +852,13 @@ declare function zeroAmountCarveOut({ rail, payload, authorizationHeader, }: {
838
852
  * header value. Reads the `did:pkh:*` source DID. */
839
853
  authorizationHeader?: string | null;
840
854
  }): ZeroSettleResult;
855
+ /**
856
+ * Read the MPP credential's `payload.type` (`'proof'` / `'hash'` /
857
+ * `'transaction'`) from an `Authorization: Payment <base64>` header without
858
+ * any `mppx` dependency. Returns `null` for token-style values (JWTs),
859
+ * unparseable headers, or credentials without a typed payload.
860
+ */
861
+ declare function mppCredentialPayloadType(authorizationHeader: string | null | undefined): string | null;
841
862
 
842
863
  /**
843
864
  * Lazy-init helpers for x402 + mppx servers.
@@ -880,4 +901,4 @@ declare function lazyMppxServer(opts: {
880
901
  secretKey: string;
881
902
  }): () => Promise<unknown>;
882
903
 
883
- export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
904
+ export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
@@ -5,7 +5,7 @@ export { B as BuildX402AcceptsForOptions, C as CreateX402ServerOptions, X as X40
5
5
  export { a as aliasAmountFields, p as paymentRequiredHeader, w as wwwAuthenticateHeader } from '../wwwauthenticate-Dgm-_af9.js';
6
6
  import { S as SignerNetwork } from '../signer-3FAit11j.js';
7
7
  export { P as PaymentSigner, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from '../signer-3FAit11j.js';
8
- export { B as BuildDefaultCheckoutRailsOptions, a as BuildMppxComposeRailsOptions, H as HeadersLike, b as asHeaders, 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, r as readHeader, u as usdToAtomic } from '../network_kind-BIJM2peR.js';
8
+ export { B as BuildDefaultCheckoutRailsOptions, a as BuildMppxComposeRailsOptions, H as HeadersLike, M as MalformedPaymentCredential, b as asHeaders, 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, m as malformedPaymentCredential, r as readHeader, u as usdToAtomic } from '../network_kind-BmbWKNud.js';
9
9
 
10
10
  /**
11
11
  * Build the base64-encoded `request` blob for an MPP Payment directive (per the
@@ -786,25 +786,39 @@ declare function settlementOverrideHeader(overrides: SettlementOverrides): {
786
786
  };
787
787
 
788
788
  /**
789
- * Zero-amount carve-out: skip upstream verify+settle for $0 orders.
790
- *
791
- * CDP rejects EIP-3009 `transferWithAuthorization` with `value=0` as
792
- * `invalid_payload`; `mppx`'s tempo intents accept only `hash` and
793
- * `transaction` payload types (rejecting the `proof` payload that gets
794
- * emitted for $0 settles). Both upstream verify+settle paths fail when the
795
- * authorized amount is zero, so merchants that drop the settle to $0 in a
796
- * redemption-code flow need a way to skip verify+settle entirely while
797
- * still recovering the signer for wallet-capture attribution.
798
- *
799
- * `zeroAmountCarveOut` is that path: parse the credential, lift the
800
- * signer, return `{ signerAddress, signerNetwork, txHash: null }`. Identity
801
- * is still authenticated by the merchant's gate above; the redemption code
802
- * is single-use; nothing on-chain to verify.
803
- *
804
- * The MPP path uses inline base64+JSON parsing (no `mppx` dependency at
805
- * runtime) so the zero-settle path stays dependency-free. The full
806
- * `extractPaymentSigner` path is still mppx-backed for production traffic
807
- * where the credential is a real mppx-shaped object.
789
+ * Zero-amount carve-out: skip upstream verify+settle for $0 orders on the
790
+ * rails that cannot settle $0 upstream.
791
+ *
792
+ * Scope (which rail takes the carve-out is decided in `Checkout.handleZeroSettle`):
793
+ *
794
+ * - **x402 Base**: CDP rejects EIP-3009 `transferWithAuthorization` with
795
+ * `value=0` as `invalid_payload`, so $0 x402 orders take the carve-out. The
796
+ * credential is still run through `verifyX402Request` (signature shape +
797
+ * payTo binding) before the carve-out is honored.
798
+ * - **MPP `proof` credentials**: NOT carved out. mppx >= 0.8 settles
799
+ * zero-amount challenges natively via the wallet-bound EIP-712 proof
800
+ * credential (full verification, access-key authorization, replay
801
+ * protection). An agent that saw a $0 challenge signs a `proof`, so those
802
+ * delegate to the normal MPP settle path.
803
+ * - **Every other MPP credential at $0** (`hash` / `transaction` payloads,
804
+ * token-style credentials, Solana): carved out. These arise when the agent
805
+ * signed against a NONZERO quote that the merchant re-priced to $0 at
806
+ * settle (no-match / full-discount flows the authorization is simply
807
+ * never exercised), or on rails with no upstream $0 contract
808
+ * (`@solana/mpp` has no proof-credential surface). Upstream would reject
809
+ * all of them at $0, so the carve-out lifts the signer for wallet-capture
810
+ * attribution only; that signer block is UNAUTHENTICATED (parse-only) and
811
+ * must not be trusted beyond attribution hints. Identity is still
812
+ * authenticated by the merchant's gate above; nothing settles on-chain.
813
+ *
814
+ * `zeroAmountCarveOut` parses the credential, lifts the signer, and returns
815
+ * `{ signerAddress, signerNetwork, txHash: null }`. The MPP path uses inline
816
+ * base64+JSON parsing (no `mppx` dependency at runtime) so this module stays
817
+ * dependency-free. `mppCredentialPayloadType` is the router `handleZeroSettle`
818
+ * uses to decide delegation (`proof`) vs carve-out (everything else); signer
819
+ * recovery itself prefers the full `extractPaymentSigner` (which also decodes
820
+ * source-less Solana credentials from the signed transaction) with this
821
+ * module's inline parse as the dependency-free backstop.
808
822
  */
809
823
 
810
824
  type ZeroSettleRail = 'x402-base' | 'tempo' | 'solana';
@@ -838,6 +852,13 @@ declare function zeroAmountCarveOut({ rail, payload, authorizationHeader, }: {
838
852
  * header value. Reads the `did:pkh:*` source DID. */
839
853
  authorizationHeader?: string | null;
840
854
  }): ZeroSettleResult;
855
+ /**
856
+ * Read the MPP credential's `payload.type` (`'proof'` / `'hash'` /
857
+ * `'transaction'`) from an `Authorization: Payment <base64>` header without
858
+ * any `mppx` dependency. Returns `null` for token-style values (JWTs),
859
+ * unparseable headers, or credentials without a typed payload.
860
+ */
861
+ declare function mppCredentialPayloadType(authorizationHeader: string | null | undefined): string | null;
841
862
 
842
863
  /**
843
864
  * Lazy-init helpers for x402 + mppx servers.
@@ -880,4 +901,4 @@ declare function lazyMppxServer(opts: {
880
901
  secretKey: string;
881
902
  }): () => Promise<unknown>;
882
903
 
883
- export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
904
+ export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
@@ -53,6 +53,8 @@ __export(payment_exports, {
53
53
  lazyX402Server: () => lazyX402Server,
54
54
  loadSolanaFeePayer: () => loadSolanaFeePayer,
55
55
  lookupRail: () => lookupRail,
56
+ malformedPaymentCredential: () => malformedPaymentCredential,
57
+ mppCredentialPayloadType: () => mppCredentialPayloadType,
56
58
  mppxChallengeHeaders: () => mppxChallengeHeaders,
57
59
  networkFamily: () => networkFamily,
58
60
  networks: () => networks,
@@ -1219,6 +1221,22 @@ function x402SignerFromPayload(payload) {
1219
1221
  txHash: null
1220
1222
  };
1221
1223
  }
1224
+ function mppCredentialPayloadType(authorizationHeader) {
1225
+ if (typeof authorizationHeader !== "string") return null;
1226
+ if (!authorizationHeader.toLowerCase().startsWith("payment ")) return null;
1227
+ const token = authorizationHeader.slice("payment ".length).trim();
1228
+ if (!token) return null;
1229
+ try {
1230
+ const credential = JSON.parse(atob(token));
1231
+ if (!credential || typeof credential !== "object") return null;
1232
+ const payload = credential.payload;
1233
+ if (!payload || typeof payload !== "object") return null;
1234
+ const type = payload.type;
1235
+ return typeof type === "string" ? type : null;
1236
+ } catch {
1237
+ return null;
1238
+ }
1239
+ }
1222
1240
  function mppSignerFromAuth(authorizationHeader) {
1223
1241
  if (typeof authorizationHeader !== "string") return NULL_RESULT;
1224
1242
  if (!authorizationHeader.toLowerCase().startsWith("payment ")) return NULL_RESULT;
@@ -1427,6 +1445,39 @@ function hasMppxHeader(input) {
1427
1445
  const headers = asHeaders(input);
1428
1446
  return Boolean(readHeader(headers, "authorization")?.startsWith("Payment "));
1429
1447
  }
1448
+ var JWT_SHAPE_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
1449
+ function decodesToJsonObject(token) {
1450
+ try {
1451
+ const parsed = JSON.parse(Buffer.from(token, "base64").toString("utf8"));
1452
+ return typeof parsed === "object" && parsed !== null;
1453
+ } catch {
1454
+ return false;
1455
+ }
1456
+ }
1457
+ function malformedPaymentCredential(input) {
1458
+ const headers = asHeaders(input);
1459
+ const x402Token = readHeader(headers, "payment-signature") ?? readHeader(headers, "x-payment");
1460
+ if (x402Token !== null && x402Token.length > 0) {
1461
+ if (!decodesToJsonObject(x402Token)) {
1462
+ return {
1463
+ channel: "x402",
1464
+ message: "X-Payment header is not decodable base64 JSON."
1465
+ };
1466
+ }
1467
+ return null;
1468
+ }
1469
+ const auth = readHeader(headers, "authorization");
1470
+ if (auth !== null && auth.startsWith("Payment ")) {
1471
+ const token = auth.slice("Payment ".length).trim();
1472
+ if (token.length === 0 || !decodesToJsonObject(token) && !JWT_SHAPE_RE.test(token)) {
1473
+ return {
1474
+ channel: "mpp",
1475
+ message: "Authorization: Payment credential is neither base64-encoded JSON nor a token-shaped value."
1476
+ };
1477
+ }
1478
+ }
1479
+ return null;
1480
+ }
1430
1481
 
1431
1482
  // src/payment/network_kind.ts
1432
1483
  function readNetwork(input) {
@@ -1478,6 +1529,8 @@ function isSolanaNetwork(input) {
1478
1529
  lazyX402Server,
1479
1530
  loadSolanaFeePayer,
1480
1531
  lookupRail,
1532
+ malformedPaymentCredential,
1533
+ mppCredentialPayloadType,
1481
1534
  mppxChallengeHeaders,
1482
1535
  networkFamily,
1483
1536
  networks,