@agent-score/commerce 1.8.1 → 2.0.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 (90) hide show
  1. package/README.md +73 -9
  2. package/dist/{_response-9yp6Fit2.d.mts → _response-BFYN3b6i.d.mts} +17 -19
  3. package/dist/{_response-CC6jNb8q.d.ts → _response-_iPD5AIj.d.ts} +17 -19
  4. package/dist/challenge/index.d.mts +106 -198
  5. package/dist/challenge/index.d.ts +106 -198
  6. package/dist/challenge/index.js +238 -111
  7. package/dist/challenge/index.js.map +1 -1
  8. package/dist/challenge/index.mjs +238 -111
  9. package/dist/challenge/index.mjs.map +1 -1
  10. package/dist/checkout-BoFwnVsj.d.ts +931 -0
  11. package/dist/checkout-DRbQ0Fsh.d.mts +931 -0
  12. package/dist/core.d.mts +2 -2
  13. package/dist/core.d.ts +2 -2
  14. package/dist/core.js +1 -1
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/discovery/index.d.mts +453 -51
  19. package/dist/discovery/index.d.ts +453 -51
  20. package/dist/discovery/index.js +1092 -58
  21. package/dist/discovery/index.js.map +1 -1
  22. package/dist/discovery/index.mjs +1060 -57
  23. package/dist/discovery/index.mjs.map +1 -1
  24. package/dist/identity/express.d.mts +3 -3
  25. package/dist/identity/express.d.ts +3 -3
  26. package/dist/identity/express.js +30 -19
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +30 -19
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +4 -4
  31. package/dist/identity/fastify.d.ts +4 -4
  32. package/dist/identity/fastify.js +30 -19
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +30 -19
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +3 -3
  37. package/dist/identity/hono.d.ts +3 -3
  38. package/dist/identity/hono.js +30 -19
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +30 -19
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +6 -7
  43. package/dist/identity/nextjs.d.ts +6 -7
  44. package/dist/identity/nextjs.js +30 -19
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +30 -19
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +41 -4
  49. package/dist/identity/policy.d.ts +41 -4
  50. package/dist/identity/policy.js +3662 -18
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +3648 -3
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +3 -3
  55. package/dist/identity/web.d.ts +3 -3
  56. package/dist/identity/web.js +30 -19
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +30 -19
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +72 -329
  61. package/dist/index.d.ts +72 -329
  62. package/dist/index.js +3651 -373
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +3628 -361
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +256 -265
  67. package/dist/payment/index.d.ts +256 -265
  68. package/dist/payment/index.js +586 -149
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +573 -148
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
  73. package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
  74. package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
  75. package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
  76. package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
  77. package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
  78. package/dist/solana-Cds87OTu.d.mts +67 -0
  79. package/dist/solana-Cds87OTu.d.ts +67 -0
  80. package/dist/stripe-multichain/index.d.mts +55 -66
  81. package/dist/stripe-multichain/index.d.ts +55 -66
  82. package/dist/stripe-multichain/index.js +68 -42
  83. package/dist/stripe-multichain/index.js.map +1 -1
  84. package/dist/stripe-multichain/index.mjs +68 -41
  85. package/dist/stripe-multichain/index.mjs.map +1 -1
  86. package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
  87. package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
  88. package/dist/x402_server-hgQzWQwB.d.mts +81 -0
  89. package/dist/x402_server-hgQzWQwB.d.ts +81 -0
  90. package/package.json +9 -7
@@ -32,10 +32,36 @@ interface PaymentSigner {
32
32
  * Extracted separately because some frameworks (Express) don't expose a web `Request` object.
33
33
  */
34
34
  declare function extractPaymentSigner(request: Request, x402PaymentHeader?: string): Promise<PaymentSigner | null>;
35
+ /**
36
+ * Headers-only variant for adapters that don't natively expose a Web Fetch `Request`
37
+ * (Express, Fastify, ASGI-bridged frameworks). Constructs a synthetic Request carrying
38
+ * only the `authorization` header and delegates to {@link extractPaymentSigner}. Works
39
+ * because the MPP and x402 paths only read `request.headers.get('authorization')` and
40
+ * the explicit `x402PaymentHeader` arg — no body, query, or method semantics needed.
41
+ */
42
+ declare function extractPaymentSignerFromAuth(authHeader: string | null | undefined, x402PaymentHeader?: string): Promise<PaymentSigner | null>;
35
43
  /**
36
44
  * Read the x402 payment header from a `Request`, matching the alternate names merchants might
37
45
  * use. Falls back to reading either header directly.
38
46
  */
39
47
  declare function readX402PaymentHeader(request: Request): string | undefined;
48
+ /**
49
+ * One-call signer extraction across both supported credential formats.
50
+ *
51
+ * Tries the x402 `payment-signature` / `x-payment` header first (EIP-3009
52
+ * `payload.authorization.from`), then falls back to the MPP
53
+ * `Authorization: Payment` header DID. Returns the first one that resolves,
54
+ * or `null`.
55
+ *
56
+ * Use this for wallet-cap prechecks and other "did the agent claim to sign as
57
+ * X?" checks where you need the signer BEFORE invoking Checkout. Checkout's
58
+ * own settle path runs verification separately and surfaces the verified
59
+ * signer on `SettleOutcome.signerAddress`.
60
+ *
61
+ * Accepts a plain headers dict so it works regardless of which framework the
62
+ * merchant uses (the gate adapters all serialize headers down to a dict by
63
+ * the time they reach the merchant's hooks).
64
+ */
65
+ declare function extractSignerForPrecheck(headers: Record<string, string>): Promise<PaymentSigner | null>;
40
66
 
41
- export { type PaymentSigner as P, type SignerNetwork as S, extractPaymentSigner as e, readX402PaymentHeader as r };
67
+ export { type PaymentSigner as P, type SignerNetwork as S, extractPaymentSignerFromAuth as a, extractSignerForPrecheck as b, extractPaymentSigner as e, readX402PaymentHeader as r };
@@ -32,10 +32,36 @@ interface PaymentSigner {
32
32
  * Extracted separately because some frameworks (Express) don't expose a web `Request` object.
33
33
  */
34
34
  declare function extractPaymentSigner(request: Request, x402PaymentHeader?: string): Promise<PaymentSigner | null>;
35
+ /**
36
+ * Headers-only variant for adapters that don't natively expose a Web Fetch `Request`
37
+ * (Express, Fastify, ASGI-bridged frameworks). Constructs a synthetic Request carrying
38
+ * only the `authorization` header and delegates to {@link extractPaymentSigner}. Works
39
+ * because the MPP and x402 paths only read `request.headers.get('authorization')` and
40
+ * the explicit `x402PaymentHeader` arg — no body, query, or method semantics needed.
41
+ */
42
+ declare function extractPaymentSignerFromAuth(authHeader: string | null | undefined, x402PaymentHeader?: string): Promise<PaymentSigner | null>;
35
43
  /**
36
44
  * Read the x402 payment header from a `Request`, matching the alternate names merchants might
37
45
  * use. Falls back to reading either header directly.
38
46
  */
39
47
  declare function readX402PaymentHeader(request: Request): string | undefined;
48
+ /**
49
+ * One-call signer extraction across both supported credential formats.
50
+ *
51
+ * Tries the x402 `payment-signature` / `x-payment` header first (EIP-3009
52
+ * `payload.authorization.from`), then falls back to the MPP
53
+ * `Authorization: Payment` header DID. Returns the first one that resolves,
54
+ * or `null`.
55
+ *
56
+ * Use this for wallet-cap prechecks and other "did the agent claim to sign as
57
+ * X?" checks where you need the signer BEFORE invoking Checkout. Checkout's
58
+ * own settle path runs verification separately and surfaces the verified
59
+ * signer on `SettleOutcome.signerAddress`.
60
+ *
61
+ * Accepts a plain headers dict so it works regardless of which framework the
62
+ * merchant uses (the gate adapters all serialize headers down to a dict by
63
+ * the time they reach the merchant's hooks).
64
+ */
65
+ declare function extractSignerForPrecheck(headers: Record<string, string>): Promise<PaymentSigner | null>;
40
66
 
41
- export { type PaymentSigner as P, type SignerNetwork as S, extractPaymentSigner as e, readX402PaymentHeader as r };
67
+ export { type PaymentSigner as P, type SignerNetwork as S, extractPaymentSignerFromAuth as a, extractSignerForPrecheck as b, extractPaymentSigner as e, readX402PaymentHeader as r };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * USD ↔ atomic-unit conversion for token amounts.
3
+ *
4
+ * `usdToAtomic(usd, { decimals: 6 })` returns the bigint atomic value of a USD
5
+ * amount for a token with `decimals` places of precision (USDC is 6). String
6
+ * parsing + bigint arithmetic so the result is exact; ROUND_HALF_UP at the
7
+ * rounding boundary matches the cross-language Python sibling.
8
+ *
9
+ * Rejects negative, NaN, infinite, and unparseable inputs. Fixed-notation only;
10
+ * scientific notation (e.g. `"1e6"`) is not parsed (mirrors the locked cross-
11
+ * language fixture corpus, which uses fixed notation exclusively).
12
+ */
13
+ /**
14
+ * Convert a USD amount to atomic units for a token with `decimals` places.
15
+ *
16
+ * @param usd USD amount. Strings (`"1.23"`) and `number`s (`1.23`) are accepted.
17
+ * `number` is converted via `String(usd)` before parsing, so JS float precision
18
+ * limits apply when the float can't represent the value exactly.
19
+ * @param opts.decimals Number of decimal places in the atomic unit (6 for USDC,
20
+ * 18 for ETH, etc.). Must be a non-negative integer.
21
+ *
22
+ * @returns Integer atomic units as a `bigint`. `"1.23"` with `decimals: 6`
23
+ * returns `1_230_000n`.
24
+ *
25
+ * @throws RangeError when `usd` is negative, NaN, infinite, or `decimals` is
26
+ * not a non-negative integer.
27
+ * @throws SyntaxError when `usd` cannot be parsed as a fixed-notation decimal.
28
+ */
29
+ declare function usdToAtomic(usd: string | number, opts: {
30
+ decimals: number;
31
+ }): bigint;
32
+ /**
33
+ * Format an integer cent amount as a fixed-2-decimal USD string.
34
+ *
35
+ * `formatUsdCents(500)` returns `"5.00"`. Negative values are formatted with a
36
+ * leading minus. Use everywhere a merchant emits `(cents / 100).toFixed(2)`;
37
+ * consistent formatting across catalog rows, order responses, and 402 bodies
38
+ * prevents agent-side string-comparison flakiness.
39
+ */
40
+ declare function formatUsdCents(cents: number): string;
41
+
42
+ /**
43
+ * Solana MPP fee-payer signer loader.
44
+ *
45
+ * Buyers paying via Solana MPP USDC don't typically carry SOL for transaction
46
+ * fees, so merchants commonly co-sign the buyer's `solana/charge` tx as the
47
+ * fee payer (~5000 lamports per tx; negligible vs the USDC value moved).
48
+ *
49
+ * `loadSolanaFeePayer({ privateKey })` accepts a Solana keypair in any of the
50
+ * three forms agents commonly export it as:
51
+ *
52
+ * - **base58** (Phantom export format) — 64-byte secret+public, or 32-byte
53
+ * secret-only
54
+ * - **hex** — 128-char string (64 bytes hex: 32-byte secret + 32-byte public)
55
+ *
56
+ * Returns a `KeyPairSigner` from `@solana/kit` ready to pass as the `signer`
57
+ * field on a `SolanaMppRailSpec`. Returns `undefined` when `privateKey` is
58
+ * empty / absent (so consumers can use `process.env.X` directly without
59
+ * null-checks).
60
+ *
61
+ * Requires the `@solana/kit` peer dependency.
62
+ */
63
+ declare function loadSolanaFeePayer(opts: {
64
+ privateKey: string | undefined;
65
+ }): Promise<unknown | undefined>;
66
+
67
+ export { formatUsdCents as f, loadSolanaFeePayer as l, usdToAtomic as u };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * USD ↔ atomic-unit conversion for token amounts.
3
+ *
4
+ * `usdToAtomic(usd, { decimals: 6 })` returns the bigint atomic value of a USD
5
+ * amount for a token with `decimals` places of precision (USDC is 6). String
6
+ * parsing + bigint arithmetic so the result is exact; ROUND_HALF_UP at the
7
+ * rounding boundary matches the cross-language Python sibling.
8
+ *
9
+ * Rejects negative, NaN, infinite, and unparseable inputs. Fixed-notation only;
10
+ * scientific notation (e.g. `"1e6"`) is not parsed (mirrors the locked cross-
11
+ * language fixture corpus, which uses fixed notation exclusively).
12
+ */
13
+ /**
14
+ * Convert a USD amount to atomic units for a token with `decimals` places.
15
+ *
16
+ * @param usd USD amount. Strings (`"1.23"`) and `number`s (`1.23`) are accepted.
17
+ * `number` is converted via `String(usd)` before parsing, so JS float precision
18
+ * limits apply when the float can't represent the value exactly.
19
+ * @param opts.decimals Number of decimal places in the atomic unit (6 for USDC,
20
+ * 18 for ETH, etc.). Must be a non-negative integer.
21
+ *
22
+ * @returns Integer atomic units as a `bigint`. `"1.23"` with `decimals: 6`
23
+ * returns `1_230_000n`.
24
+ *
25
+ * @throws RangeError when `usd` is negative, NaN, infinite, or `decimals` is
26
+ * not a non-negative integer.
27
+ * @throws SyntaxError when `usd` cannot be parsed as a fixed-notation decimal.
28
+ */
29
+ declare function usdToAtomic(usd: string | number, opts: {
30
+ decimals: number;
31
+ }): bigint;
32
+ /**
33
+ * Format an integer cent amount as a fixed-2-decimal USD string.
34
+ *
35
+ * `formatUsdCents(500)` returns `"5.00"`. Negative values are formatted with a
36
+ * leading minus. Use everywhere a merchant emits `(cents / 100).toFixed(2)`;
37
+ * consistent formatting across catalog rows, order responses, and 402 bodies
38
+ * prevents agent-side string-comparison flakiness.
39
+ */
40
+ declare function formatUsdCents(cents: number): string;
41
+
42
+ /**
43
+ * Solana MPP fee-payer signer loader.
44
+ *
45
+ * Buyers paying via Solana MPP USDC don't typically carry SOL for transaction
46
+ * fees, so merchants commonly co-sign the buyer's `solana/charge` tx as the
47
+ * fee payer (~5000 lamports per tx; negligible vs the USDC value moved).
48
+ *
49
+ * `loadSolanaFeePayer({ privateKey })` accepts a Solana keypair in any of the
50
+ * three forms agents commonly export it as:
51
+ *
52
+ * - **base58** (Phantom export format) — 64-byte secret+public, or 32-byte
53
+ * secret-only
54
+ * - **hex** — 128-char string (64 bytes hex: 32-byte secret + 32-byte public)
55
+ *
56
+ * Returns a `KeyPairSigner` from `@solana/kit` ready to pass as the `signer`
57
+ * field on a `SolanaMppRailSpec`. Returns `undefined` when `privateKey` is
58
+ * empty / absent (so consumers can use `process.env.X` directly without
59
+ * null-checks).
60
+ *
61
+ * Requires the `@solana/kit` peer dependency.
62
+ */
63
+ declare function loadSolanaFeePayer(opts: {
64
+ privateKey: string | undefined;
65
+ }): Promise<unknown | undefined>;
66
+
67
+ export { formatUsdCents as f, loadSolanaFeePayer as l, usdToAtomic as u };
@@ -21,20 +21,6 @@ interface StripePaymentIntent {
21
21
  } | null;
22
22
  [key: string]: unknown;
23
23
  }
24
- interface CreateMultichainPaymentIntentInput {
25
- /** A configured Stripe SDK instance. */
26
- stripe: StripeClientLike;
27
- /** Amount in cents (Stripe convention — $1.00 = 100). */
28
- amount: number;
29
- /** Currency code. Default 'usd'. */
30
- currency?: string;
31
- /** Networks to advertise to Stripe deposit_options. Default ['tempo', 'base', 'solana']. */
32
- networks?: string[];
33
- /** Metadata to attach to the PI (visible in Stripe dashboard). */
34
- metadata?: Record<string, string>;
35
- /** Idempotency key — agent retries of the same purchase won't create duplicate PIs. */
36
- idempotencyKey?: string;
37
- }
38
24
  interface MultichainPaymentIntentResult {
39
25
  /** Stripe PaymentIntent ID. */
40
26
  paymentIntentId: string;
@@ -51,13 +37,20 @@ interface MultichainPaymentIntentResult {
51
37
  * Distinct from the Stripe SPT (Shared Payment Token) flow, which is handled via
52
38
  * `createMppxStripe` + the agent's own Stripe account or `link-cli`.
53
39
  */
54
- declare function createMultichainPaymentIntent(input: CreateMultichainPaymentIntentInput): Promise<MultichainPaymentIntentResult>;
55
- /**
56
- * Convenience accessor: get the deposit address for a specific network from a
57
- * createMultichainPaymentIntent result. Returns undefined if Stripe didn't issue
58
- * an address for that network.
59
- */
60
- declare function getDepositAddress(result: MultichainPaymentIntentResult, network: string): string | undefined;
40
+ declare function createMultichainPaymentIntent({ stripe, amount, currency, networks, metadata, idempotencyKey, }: {
41
+ /** A configured Stripe SDK instance. */
42
+ stripe: StripeClientLike;
43
+ /** Amount in cents (Stripe convention $1.00 = 100). */
44
+ amount: number;
45
+ /** Currency code. Default 'usd'. */
46
+ currency?: string;
47
+ /** Networks to advertise to Stripe deposit_options. Default ['tempo', 'base', 'solana']. */
48
+ networks?: string[];
49
+ /** Metadata to attach to the PI (visible in Stripe dashboard). */
50
+ metadata?: Record<string, string>;
51
+ /** Idempotency key — agent retries of the same purchase won't create duplicate PIs. */
52
+ idempotencyKey?: string;
53
+ }): Promise<MultichainPaymentIntentResult>;
61
54
 
62
55
  /**
63
56
  * Stripe's documented magic test_helpers transaction hash that resolves the
@@ -73,7 +66,14 @@ declare const STRIPE_TEST_TX_HASH_SUCCESS = "0x000000000000000000000000000000000
73
66
  * (PaymentIntent returns to `requires_payment_method` within 15 seconds).
74
67
  */
75
68
  declare const STRIPE_TEST_TX_HASH_FAILED = "0x000000000000000000000000000000000000000000000000000000testfailed";
76
- interface SimulateCryptoDepositInput {
69
+ /**
70
+ * Call Stripe's `test_helpers/payment_intents/{id}/simulate_crypto_deposit` endpoint. Used
71
+ * in testnet/dev to simulate a deposit landing on a PaymentIntent so the integration
72
+ * end-to-end can be exercised without on-chain transfers.
73
+ *
74
+ * Throws on non-2xx responses (returns Stripe's error body in the message).
75
+ */
76
+ declare function simulateCryptoDeposit({ paymentIntentId, network, buyerWallet, tokenCurrency, transactionHash, stripeSecretKey, stripeVersion, stripeApiBase, extra, }: {
77
77
  /** Stripe PaymentIntent id to simulate a deposit on. */
78
78
  paymentIntentId: string;
79
79
  /** Network the simulated deposit lands on. */
@@ -92,16 +92,23 @@ interface SimulateCryptoDepositInput {
92
92
  stripeApiBase?: string;
93
93
  /** Arbitrary additional form params to merge into the request body. */
94
94
  extra?: Record<string, string>;
95
- }
95
+ }): Promise<void>;
96
96
  /**
97
- * Call Stripe's `test_helpers/payment_intents/{id}/simulate_crypto_deposit` endpoint. Used
98
- * in testnet/dev to simulate a deposit landing on a PaymentIntent so the integration
99
- * end-to-end can be exercised without on-chain transfers.
97
+ * Higher-level wrapper around {@link simulateCryptoDeposit} for the testnet/dev path.
98
+ * Bundles the three steps every Stripe-multichain merchant repeats:
100
99
  *
101
- * Throws on non-2xx responses (returns Stripe's error body in the message).
100
+ * 1. Gate on `sk_test_` key prefix production keys reject the test_helpers endpoint
101
+ * with 400; live deposits reach Stripe's real crypto-deposit watcher instead.
102
+ * 2. Resolve the PaymentIntent id from the deposit address (cache lookup).
103
+ * 3. Call `simulate_crypto_deposit` with Stripe's documented success magic hash.
104
+ *
105
+ * Logs `[stripe] ✓ Simulated <network> deposit for PI <id>` on success and
106
+ * `[stripe] ✗ Failed to simulate <network> deposit for PI <id>: <err>` on failure.
107
+ * Errors are caught + logged (never thrown) so a sim hiccup doesn't fail the order.
108
+ *
109
+ * Use case is exclusively dev/testnet end-to-end — production servers (sk_live_) no-op.
102
110
  */
103
- declare function simulateCryptoDeposit(input: SimulateCryptoDepositInput): Promise<void>;
104
- interface SimulateDepositIfTestModeInput {
111
+ declare function simulateDepositIfTestMode({ getPaymentIntentId, depositAddress, network, buyerWallet, tokenCurrency, stripeSecretKey, stripeVersion, }: {
105
112
  /** Stripe PaymentIntent id resolver — given a deposit address, return the PI id (or undefined
106
113
  * if the cache TTL expired between 402 emit and settlement). Typically `cache.getPaymentIntentId`. */
107
114
  getPaymentIntentId: (depositAddress: string) => string | undefined;
@@ -117,32 +124,8 @@ interface SimulateDepositIfTestModeInput {
117
124
  stripeSecretKey: string;
118
125
  /** Stripe API version (e.g. `'2026-03-04.preview'` for the deposit-mode preview). */
119
126
  stripeVersion?: string;
120
- }
121
- /**
122
- * Higher-level wrapper around {@link simulateCryptoDeposit} for the testnet/dev path.
123
- * Bundles the three steps every Stripe-multichain merchant repeats:
124
- *
125
- * 1. Gate on `sk_test_` key prefix — production keys reject the test_helpers endpoint
126
- * with 400; live deposits reach Stripe's real crypto-deposit watcher instead.
127
- * 2. Resolve the PaymentIntent id from the deposit address (cache lookup).
128
- * 3. Call `simulate_crypto_deposit` with Stripe's documented success magic hash.
129
- *
130
- * Logs `[stripe] ✓ Simulated <network> deposit for PI <id>` on success and
131
- * `[stripe] ✗ Failed to simulate <network> deposit for PI <id>: <err>` on failure.
132
- * Errors are caught + logged (never thrown) so a sim hiccup doesn't fail the order.
133
- *
134
- * Use case is exclusively dev/testnet end-to-end — production servers (sk_live_) no-op.
135
- */
136
- declare function simulateDepositIfTestMode(input: SimulateDepositIfTestModeInput): Promise<void>;
127
+ }): Promise<void>;
137
128
 
138
- interface CreateMppxStripeInput {
139
- /** Stripe profile_id / network_id (the value advertised in your `stripe/charge` accepted_methods entry). */
140
- profileId: string;
141
- /** Stripe secret key — mppx uses it to validate inbound SharedPaymentTokens. */
142
- secretKey: string;
143
- /** Payment method types this stripe rail accepts. Default ['card', 'link']. */
144
- paymentMethodTypes?: string[];
145
- }
146
129
  /**
147
130
  * Wraps the `mppStripe.charge(...)` boilerplate from `mppx/server`. Returns the value
148
131
  * vendors pass into `Mppx.create({ methods: [...] })`. mppx is an OPTIONAL peer dependency —
@@ -165,7 +148,14 @@ interface CreateMppxStripeInput {
165
148
  *
166
149
  * Throws if mppx is not installed.
167
150
  */
168
- declare function createMppxStripe(input: CreateMppxStripeInput): Promise<unknown>;
151
+ declare function createMppxStripe({ profileId, secretKey, paymentMethodTypes, }: {
152
+ /** Stripe profile_id / network_id (the value advertised in your `stripe/charge` accepted_methods entry). */
153
+ profileId: string;
154
+ /** Stripe secret key — mppx uses it to validate inbound SharedPaymentTokens. */
155
+ secretKey: string;
156
+ /** Payment method types this stripe rail accepts. Default ['card', 'link']. */
157
+ paymentMethodTypes?: string[];
158
+ }): Promise<unknown>;
169
159
 
170
160
  /**
171
161
  * Stripe PaymentIntent + deposit-address cache.
@@ -191,15 +181,6 @@ declare function createMppxStripe(input: CreateMppxStripeInput): Promise<unknown
191
181
  * multi-instance deployments need a shared cache (Redis) so a deposit lands on
192
182
  * whichever instance settles it.
193
183
  */
194
- interface PiCacheOptions {
195
- /** Redis connection URL (e.g. `rediss://…cache.amazonaws.com:6379`). When omitted,
196
- * the cache falls back to in-process Maps with the same API. */
197
- redisUrl?: string;
198
- /** TTL for cached entries in seconds. Default 300. */
199
- ttlSeconds?: number;
200
- /** Prefix for Redis keys. Default `'payto:'`. */
201
- keyPrefix?: string;
202
- }
203
184
  interface PiCache {
204
185
  /** Mark an on-chain address as one this merchant minted. Idempotent + TTL-bounded. */
205
186
  cacheAddress(address: string): Promise<void>;
@@ -216,6 +197,14 @@ interface PiCache {
216
197
  /** Stop the background TTL-eviction loop. Call from server shutdown handlers. */
217
198
  stop(): void;
218
199
  }
219
- declare function createPiCache(opts?: PiCacheOptions): PiCache;
200
+ declare function createPiCache({ redisUrl, ttlSeconds, keyPrefix, }?: {
201
+ /** Redis connection URL (e.g. `rediss://…cache.amazonaws.com:6379`). When omitted,
202
+ * the cache falls back to in-process Maps with the same API. */
203
+ redisUrl?: string;
204
+ /** TTL for cached entries in seconds. Default 300. */
205
+ ttlSeconds?: number;
206
+ /** Prefix for Redis keys. Default `'payto:'`. */
207
+ keyPrefix?: string;
208
+ }): PiCache;
220
209
 
221
- export { type CreateMppxStripeInput, type CreateMultichainPaymentIntentInput, type MultichainPaymentIntentResult, type PiCache, type PiCacheOptions, STRIPE_TEST_TX_HASH_FAILED, STRIPE_TEST_TX_HASH_SUCCESS, type SimulateCryptoDepositInput, type SimulateDepositIfTestModeInput, type StripeClientLike, type StripePaymentIntent, createMppxStripe, createMultichainPaymentIntent, createPiCache, getDepositAddress, simulateCryptoDeposit, simulateDepositIfTestMode };
210
+ export { type MultichainPaymentIntentResult, type PiCache, STRIPE_TEST_TX_HASH_FAILED, STRIPE_TEST_TX_HASH_SUCCESS, type StripeClientLike, type StripePaymentIntent, createMppxStripe, createMultichainPaymentIntent, createPiCache, simulateCryptoDeposit, simulateDepositIfTestMode };
@@ -21,20 +21,6 @@ interface StripePaymentIntent {
21
21
  } | null;
22
22
  [key: string]: unknown;
23
23
  }
24
- interface CreateMultichainPaymentIntentInput {
25
- /** A configured Stripe SDK instance. */
26
- stripe: StripeClientLike;
27
- /** Amount in cents (Stripe convention — $1.00 = 100). */
28
- amount: number;
29
- /** Currency code. Default 'usd'. */
30
- currency?: string;
31
- /** Networks to advertise to Stripe deposit_options. Default ['tempo', 'base', 'solana']. */
32
- networks?: string[];
33
- /** Metadata to attach to the PI (visible in Stripe dashboard). */
34
- metadata?: Record<string, string>;
35
- /** Idempotency key — agent retries of the same purchase won't create duplicate PIs. */
36
- idempotencyKey?: string;
37
- }
38
24
  interface MultichainPaymentIntentResult {
39
25
  /** Stripe PaymentIntent ID. */
40
26
  paymentIntentId: string;
@@ -51,13 +37,20 @@ interface MultichainPaymentIntentResult {
51
37
  * Distinct from the Stripe SPT (Shared Payment Token) flow, which is handled via
52
38
  * `createMppxStripe` + the agent's own Stripe account or `link-cli`.
53
39
  */
54
- declare function createMultichainPaymentIntent(input: CreateMultichainPaymentIntentInput): Promise<MultichainPaymentIntentResult>;
55
- /**
56
- * Convenience accessor: get the deposit address for a specific network from a
57
- * createMultichainPaymentIntent result. Returns undefined if Stripe didn't issue
58
- * an address for that network.
59
- */
60
- declare function getDepositAddress(result: MultichainPaymentIntentResult, network: string): string | undefined;
40
+ declare function createMultichainPaymentIntent({ stripe, amount, currency, networks, metadata, idempotencyKey, }: {
41
+ /** A configured Stripe SDK instance. */
42
+ stripe: StripeClientLike;
43
+ /** Amount in cents (Stripe convention $1.00 = 100). */
44
+ amount: number;
45
+ /** Currency code. Default 'usd'. */
46
+ currency?: string;
47
+ /** Networks to advertise to Stripe deposit_options. Default ['tempo', 'base', 'solana']. */
48
+ networks?: string[];
49
+ /** Metadata to attach to the PI (visible in Stripe dashboard). */
50
+ metadata?: Record<string, string>;
51
+ /** Idempotency key — agent retries of the same purchase won't create duplicate PIs. */
52
+ idempotencyKey?: string;
53
+ }): Promise<MultichainPaymentIntentResult>;
61
54
 
62
55
  /**
63
56
  * Stripe's documented magic test_helpers transaction hash that resolves the
@@ -73,7 +66,14 @@ declare const STRIPE_TEST_TX_HASH_SUCCESS = "0x000000000000000000000000000000000
73
66
  * (PaymentIntent returns to `requires_payment_method` within 15 seconds).
74
67
  */
75
68
  declare const STRIPE_TEST_TX_HASH_FAILED = "0x000000000000000000000000000000000000000000000000000000testfailed";
76
- interface SimulateCryptoDepositInput {
69
+ /**
70
+ * Call Stripe's `test_helpers/payment_intents/{id}/simulate_crypto_deposit` endpoint. Used
71
+ * in testnet/dev to simulate a deposit landing on a PaymentIntent so the integration
72
+ * end-to-end can be exercised without on-chain transfers.
73
+ *
74
+ * Throws on non-2xx responses (returns Stripe's error body in the message).
75
+ */
76
+ declare function simulateCryptoDeposit({ paymentIntentId, network, buyerWallet, tokenCurrency, transactionHash, stripeSecretKey, stripeVersion, stripeApiBase, extra, }: {
77
77
  /** Stripe PaymentIntent id to simulate a deposit on. */
78
78
  paymentIntentId: string;
79
79
  /** Network the simulated deposit lands on. */
@@ -92,16 +92,23 @@ interface SimulateCryptoDepositInput {
92
92
  stripeApiBase?: string;
93
93
  /** Arbitrary additional form params to merge into the request body. */
94
94
  extra?: Record<string, string>;
95
- }
95
+ }): Promise<void>;
96
96
  /**
97
- * Call Stripe's `test_helpers/payment_intents/{id}/simulate_crypto_deposit` endpoint. Used
98
- * in testnet/dev to simulate a deposit landing on a PaymentIntent so the integration
99
- * end-to-end can be exercised without on-chain transfers.
97
+ * Higher-level wrapper around {@link simulateCryptoDeposit} for the testnet/dev path.
98
+ * Bundles the three steps every Stripe-multichain merchant repeats:
100
99
  *
101
- * Throws on non-2xx responses (returns Stripe's error body in the message).
100
+ * 1. Gate on `sk_test_` key prefix production keys reject the test_helpers endpoint
101
+ * with 400; live deposits reach Stripe's real crypto-deposit watcher instead.
102
+ * 2. Resolve the PaymentIntent id from the deposit address (cache lookup).
103
+ * 3. Call `simulate_crypto_deposit` with Stripe's documented success magic hash.
104
+ *
105
+ * Logs `[stripe] ✓ Simulated <network> deposit for PI <id>` on success and
106
+ * `[stripe] ✗ Failed to simulate <network> deposit for PI <id>: <err>` on failure.
107
+ * Errors are caught + logged (never thrown) so a sim hiccup doesn't fail the order.
108
+ *
109
+ * Use case is exclusively dev/testnet end-to-end — production servers (sk_live_) no-op.
102
110
  */
103
- declare function simulateCryptoDeposit(input: SimulateCryptoDepositInput): Promise<void>;
104
- interface SimulateDepositIfTestModeInput {
111
+ declare function simulateDepositIfTestMode({ getPaymentIntentId, depositAddress, network, buyerWallet, tokenCurrency, stripeSecretKey, stripeVersion, }: {
105
112
  /** Stripe PaymentIntent id resolver — given a deposit address, return the PI id (or undefined
106
113
  * if the cache TTL expired between 402 emit and settlement). Typically `cache.getPaymentIntentId`. */
107
114
  getPaymentIntentId: (depositAddress: string) => string | undefined;
@@ -117,32 +124,8 @@ interface SimulateDepositIfTestModeInput {
117
124
  stripeSecretKey: string;
118
125
  /** Stripe API version (e.g. `'2026-03-04.preview'` for the deposit-mode preview). */
119
126
  stripeVersion?: string;
120
- }
121
- /**
122
- * Higher-level wrapper around {@link simulateCryptoDeposit} for the testnet/dev path.
123
- * Bundles the three steps every Stripe-multichain merchant repeats:
124
- *
125
- * 1. Gate on `sk_test_` key prefix — production keys reject the test_helpers endpoint
126
- * with 400; live deposits reach Stripe's real crypto-deposit watcher instead.
127
- * 2. Resolve the PaymentIntent id from the deposit address (cache lookup).
128
- * 3. Call `simulate_crypto_deposit` with Stripe's documented success magic hash.
129
- *
130
- * Logs `[stripe] ✓ Simulated <network> deposit for PI <id>` on success and
131
- * `[stripe] ✗ Failed to simulate <network> deposit for PI <id>: <err>` on failure.
132
- * Errors are caught + logged (never thrown) so a sim hiccup doesn't fail the order.
133
- *
134
- * Use case is exclusively dev/testnet end-to-end — production servers (sk_live_) no-op.
135
- */
136
- declare function simulateDepositIfTestMode(input: SimulateDepositIfTestModeInput): Promise<void>;
127
+ }): Promise<void>;
137
128
 
138
- interface CreateMppxStripeInput {
139
- /** Stripe profile_id / network_id (the value advertised in your `stripe/charge` accepted_methods entry). */
140
- profileId: string;
141
- /** Stripe secret key — mppx uses it to validate inbound SharedPaymentTokens. */
142
- secretKey: string;
143
- /** Payment method types this stripe rail accepts. Default ['card', 'link']. */
144
- paymentMethodTypes?: string[];
145
- }
146
129
  /**
147
130
  * Wraps the `mppStripe.charge(...)` boilerplate from `mppx/server`. Returns the value
148
131
  * vendors pass into `Mppx.create({ methods: [...] })`. mppx is an OPTIONAL peer dependency —
@@ -165,7 +148,14 @@ interface CreateMppxStripeInput {
165
148
  *
166
149
  * Throws if mppx is not installed.
167
150
  */
168
- declare function createMppxStripe(input: CreateMppxStripeInput): Promise<unknown>;
151
+ declare function createMppxStripe({ profileId, secretKey, paymentMethodTypes, }: {
152
+ /** Stripe profile_id / network_id (the value advertised in your `stripe/charge` accepted_methods entry). */
153
+ profileId: string;
154
+ /** Stripe secret key — mppx uses it to validate inbound SharedPaymentTokens. */
155
+ secretKey: string;
156
+ /** Payment method types this stripe rail accepts. Default ['card', 'link']. */
157
+ paymentMethodTypes?: string[];
158
+ }): Promise<unknown>;
169
159
 
170
160
  /**
171
161
  * Stripe PaymentIntent + deposit-address cache.
@@ -191,15 +181,6 @@ declare function createMppxStripe(input: CreateMppxStripeInput): Promise<unknown
191
181
  * multi-instance deployments need a shared cache (Redis) so a deposit lands on
192
182
  * whichever instance settles it.
193
183
  */
194
- interface PiCacheOptions {
195
- /** Redis connection URL (e.g. `rediss://…cache.amazonaws.com:6379`). When omitted,
196
- * the cache falls back to in-process Maps with the same API. */
197
- redisUrl?: string;
198
- /** TTL for cached entries in seconds. Default 300. */
199
- ttlSeconds?: number;
200
- /** Prefix for Redis keys. Default `'payto:'`. */
201
- keyPrefix?: string;
202
- }
203
184
  interface PiCache {
204
185
  /** Mark an on-chain address as one this merchant minted. Idempotent + TTL-bounded. */
205
186
  cacheAddress(address: string): Promise<void>;
@@ -216,6 +197,14 @@ interface PiCache {
216
197
  /** Stop the background TTL-eviction loop. Call from server shutdown handlers. */
217
198
  stop(): void;
218
199
  }
219
- declare function createPiCache(opts?: PiCacheOptions): PiCache;
200
+ declare function createPiCache({ redisUrl, ttlSeconds, keyPrefix, }?: {
201
+ /** Redis connection URL (e.g. `rediss://…cache.amazonaws.com:6379`). When omitted,
202
+ * the cache falls back to in-process Maps with the same API. */
203
+ redisUrl?: string;
204
+ /** TTL for cached entries in seconds. Default 300. */
205
+ ttlSeconds?: number;
206
+ /** Prefix for Redis keys. Default `'payto:'`. */
207
+ keyPrefix?: string;
208
+ }): PiCache;
220
209
 
221
- export { type CreateMppxStripeInput, type CreateMultichainPaymentIntentInput, type MultichainPaymentIntentResult, type PiCache, type PiCacheOptions, STRIPE_TEST_TX_HASH_FAILED, STRIPE_TEST_TX_HASH_SUCCESS, type SimulateCryptoDepositInput, type SimulateDepositIfTestModeInput, type StripeClientLike, type StripePaymentIntent, createMppxStripe, createMultichainPaymentIntent, createPiCache, getDepositAddress, simulateCryptoDeposit, simulateDepositIfTestMode };
210
+ export { type MultichainPaymentIntentResult, type PiCache, STRIPE_TEST_TX_HASH_FAILED, STRIPE_TEST_TX_HASH_SUCCESS, type StripeClientLike, type StripePaymentIntent, createMppxStripe, createMultichainPaymentIntent, createPiCache, simulateCryptoDeposit, simulateDepositIfTestMode };