@elizaos/plugin-x402 2.0.0-alpha.6 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/index.d.ts +57 -2
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +30919 -1913
  4. package/dist/index.js.map +114 -21
  5. package/dist/payment-config.d.ts +256 -0
  6. package/dist/payment-config.d.ts.map +1 -0
  7. package/dist/payment-wrapper.d.ts +42 -0
  8. package/dist/payment-wrapper.d.ts.map +1 -0
  9. package/dist/startup-validator.d.ts +28 -0
  10. package/dist/startup-validator.d.ts.map +1 -0
  11. package/dist/types.d.ts +158 -0
  12. package/dist/types.d.ts.map +1 -0
  13. package/dist/x402-facilitator-binding.d.ts +9 -0
  14. package/dist/x402-facilitator-binding.d.ts.map +1 -0
  15. package/dist/x402-replay-durable.d.ts +30 -0
  16. package/dist/x402-replay-durable.d.ts.map +1 -0
  17. package/dist/x402-replay-guard.d.ts +28 -0
  18. package/dist/x402-replay-guard.d.ts.map +1 -0
  19. package/dist/x402-replay-keys.d.ts +21 -0
  20. package/dist/x402-replay-keys.d.ts.map +1 -0
  21. package/dist/x402-resolve.d.ts +6 -0
  22. package/dist/x402-resolve.d.ts.map +1 -0
  23. package/dist/x402-standard-payment.d.ts +130 -0
  24. package/dist/x402-standard-payment.d.ts.map +1 -0
  25. package/dist/x402-types.d.ts +130 -0
  26. package/dist/x402-types.d.ts.map +1 -0
  27. package/package.json +43 -94
  28. package/src/index.ts +113 -0
  29. package/src/payment-config.ts +737 -0
  30. package/src/payment-wrapper.ts +1991 -0
  31. package/src/startup-validator.ts +349 -0
  32. package/src/types.ts +177 -0
  33. package/src/x402-facilitator-binding.ts +104 -0
  34. package/src/x402-replay-durable.ts +320 -0
  35. package/src/x402-replay-guard.ts +165 -0
  36. package/src/x402-replay-keys.ts +151 -0
  37. package/src/x402-resolve.ts +43 -0
  38. package/src/x402-standard-payment.ts +519 -0
  39. package/src/x402-types.ts +376 -0
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Configuration for x402 micropayment system
3
+ * Route-specific pricing is now defined locally in each route definition
4
+ *
5
+ * Payment Verification Methods:
6
+ *
7
+ * 1. Direct Blockchain Proof (X-Payment-Proof header)
8
+ * - User sends payment transaction on-chain
9
+ * - Transaction signature is verified against blockchain
10
+ * - Supports: Solana, Base, Polygon
11
+ * - Format: base64-encoded JSON with signature and authorization
12
+ *
13
+ * 2. Facilitator Payment ID (X-Payment-Id header)
14
+ * - Third-party service handles payment
15
+ * - Service returns payment ID after successful payment
16
+ * - ID is verified through facilitator API
17
+ * - Configured via X402_FACILITATOR_URL environment variable
18
+ * - Example: X402_FACILITATOR_URL=https://facilitator.x402.ai
19
+ *
20
+ * 3. Standard X-Payment / PAYMENT-SIGNATURE (x402-fetch / CDP-style)
21
+ * - Base64(JSON) or raw JSON: `{ x402Version, accepted, payload }`
22
+ * - Verified and settled with POST `{ paymentPayload, paymentRequirements }`
23
+ * to facilitator `/verify` then `/settle`
24
+ * - Override endpoints with `X402_FACILITATOR_VERIFY_URL` and
25
+ * `X402_FACILITATOR_SETTLE_URL`; otherwise append `/verify` and `/settle`
26
+ * to `X402_FACILITATOR_URL`.
27
+ *
28
+ * The facilitator endpoint should implement:
29
+ * GET /verify/{paymentId}
30
+ * - 200 OK: Payment is valid (with optional { valid: true } JSON body)
31
+ * - 404 Not Found: Payment ID doesn't exist
32
+ * - 410 Gone: Payment already used (prevents replay attacks)
33
+ *
34
+ * Seller-side replay: proof / payment ID keys are atomically reserved in the
35
+ * SQL-backed runtime cache by default (`X402_REPLAY_DURABLE`, see x402 docs),
36
+ * then marked consumed after successful verification. Disable with
37
+ * `X402_REPLAY_DURABLE=0` for in-memory TTL-only behavior (dev / tests).
38
+ */
39
+ import type { X402ScanNetwork } from "./x402-types.js";
40
+ /** Networks supported by built-in x402 presets and verification */
41
+ export type Network = "BASE" | "SOLANA" | "POLYGON" | "BSC";
42
+ /**
43
+ * Built-in networks supported by default
44
+ */
45
+ export declare const BUILT_IN_NETWORKS: readonly ["BASE", "SOLANA", "POLYGON", "BSC"];
46
+ export declare const DEFAULT_NETWORK: Network;
47
+ /**
48
+ * Convert our Network type to x402scan-compliant network names
49
+ * @throws {Error} If network is not supported by x402scan
50
+ */
51
+ export declare function toX402Network(network: Network): X402ScanNetwork;
52
+ /** Shipped fallbacks — not your treasury; startup validation warns / errors in production. */
53
+ export declare const BUNDLED_EXAMPLE_EVM_PAYOUT = "0x066E94e1200aa765d0A6392777D543Aa6Dea606C";
54
+ export declare const BUNDLED_EXAMPLE_SOLANA_PAYOUT = "3nMBmufBUBVnk28sTp3NsrSJsdVGTyLZYmsqpMFaUT9J";
55
+ export declare function paymentAddressIsBundledExample(network: Network, paymentAddress: string): boolean;
56
+ /**
57
+ * Network-specific wallet addresses
58
+ * Uses existing environment variables from your project configuration
59
+ */
60
+ export declare const PAYMENT_ADDRESSES: Partial<Record<Network, string>>;
61
+ /**
62
+ * Get the base URL for the current server
63
+ * Used to construct full resource URLs for x402 responses
64
+ */
65
+ export declare function getBaseUrl(): string;
66
+ /**
67
+ * Convert a route path to a full resource URL
68
+ */
69
+ export declare function toResourceUrl(path: string): string;
70
+ /**
71
+ * Token configuration for Solana
72
+ */
73
+ export declare const SOLANA_TOKENS: {
74
+ readonly USDC: {
75
+ readonly symbol: "USDC";
76
+ readonly address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
77
+ readonly decimals: 6;
78
+ };
79
+ readonly AI16Z: {
80
+ readonly symbol: "ai16z";
81
+ readonly address: "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC";
82
+ readonly decimals: 6;
83
+ };
84
+ readonly DEGENAI: {
85
+ readonly symbol: "degenai";
86
+ readonly address: "Gu3LDkn7Vx3bmCzLafYNKcDxv2mH7YN44NJZFXnypump";
87
+ readonly decimals: 6;
88
+ };
89
+ readonly ELIZAOS: {
90
+ readonly symbol: "elizaOS";
91
+ readonly address: "DuMbhu7mvQvqQHGcnikDgb4XegXJRyhUBfdU22uELiZA";
92
+ readonly decimals: 6;
93
+ };
94
+ };
95
+ /**
96
+ * Token configuration for Base (EVM)
97
+ */
98
+ export declare const BASE_TOKENS: {
99
+ readonly USDC: {
100
+ readonly symbol: "USDC";
101
+ readonly address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
102
+ readonly decimals: 6;
103
+ };
104
+ readonly ELIZAOS: {
105
+ readonly symbol: "elizaOS";
106
+ readonly address: "0xea17Df5Cf6D172224892B5477A16ACb111182478";
107
+ readonly decimals: 18;
108
+ };
109
+ };
110
+ /**
111
+ * Token configuration for Polygon (EVM)
112
+ */
113
+ export declare const POLYGON_TOKENS: {
114
+ readonly USDC: {
115
+ readonly symbol: "USDC";
116
+ readonly address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
117
+ readonly decimals: 6;
118
+ };
119
+ };
120
+ /**
121
+ * Token configuration for BNB Smart Chain (EVM)
122
+ */
123
+ export declare const BSC_TOKENS: {
124
+ readonly USDC: {
125
+ readonly symbol: "USDC";
126
+ readonly address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d";
127
+ readonly decimals: 18;
128
+ };
129
+ };
130
+ /**
131
+ * Default asset for each network (used in x402 responses)
132
+ */
133
+ export declare const NETWORK_ASSETS: Partial<Record<Network, string>>;
134
+ /**
135
+ * Get all accepted assets for a network
136
+ * @throws {Error} If network is not supported
137
+ */
138
+ export declare function getNetworkAssets(network: Network): string[];
139
+ export declare const PAYMENT_RECEIVER_ADDRESS: string;
140
+ /**
141
+ * Named payment config definition - stores individual fields, CAIP-19 constructed on-demand
142
+ */
143
+ export interface PaymentConfigDefinition {
144
+ network: Network;
145
+ assetNamespace: string;
146
+ assetReference: string;
147
+ paymentAddress: string;
148
+ symbol: string;
149
+ chainId?: string;
150
+ }
151
+ /**
152
+ * Payment configuration registry - named configs for easy reference
153
+ */
154
+ export declare const PAYMENT_CONFIGS: Record<string, PaymentConfigDefinition>;
155
+ /**
156
+ * Construct CAIP-19 asset ID from payment config fields
157
+ */
158
+ export declare function getCAIP19FromConfig(config: PaymentConfigDefinition): string;
159
+ /**
160
+ * Register a custom payment configuration
161
+ * Plugins call this in their init() function
162
+ *
163
+ * A second call with the same `name` (or the same `agentId`+`name` for scoped
164
+ * keys) throws unless `override: true` is set, so two plugins cannot silently
165
+ * replace each other in `CUSTOM_PAYMENT_CONFIGS`.
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * registerX402Config('base_ai16z', {
170
+ * network: 'BASE',
171
+ * assetNamespace: 'erc20',
172
+ * assetReference: '0x...',
173
+ * paymentAddress: process.env.BASE_PUBLIC_KEY,
174
+ * symbol: 'AI16Z',
175
+ * chainId: '8453'
176
+ * });
177
+ *
178
+ * // Agent-specific override
179
+ * registerX402Config('base_usdc', {...}, { agentId: runtime.agentId });
180
+ * ```
181
+ */
182
+ export declare function registerX402Config(name: string, config: PaymentConfigDefinition, options?: {
183
+ override?: boolean;
184
+ agentId?: string;
185
+ }): void;
186
+ /**
187
+ * Get payment config - checks custom registry then built-in
188
+ * Supports agent-specific configs via agentId parameter
189
+ */
190
+ export declare function getPaymentConfig(name: string, agentId?: string): PaymentConfigDefinition;
191
+ /**
192
+ * List all available payment configs (built-in + custom)
193
+ * Optionally filter to agent-specific configs
194
+ */
195
+ export declare function listX402Configs(agentId?: string): string[];
196
+ /**
197
+ * Validate payment config name
198
+ */
199
+ export declare function validatePaymentConfigName(name: string): boolean;
200
+ export type { X402Config } from "@elizaos/core";
201
+ /**
202
+ * Get the payment address for a specific network
203
+ * @throws {Error} If network is not configured
204
+ */
205
+ export declare function getPaymentAddress(network: Network): string;
206
+ /**
207
+ * Get all network addresses with metadata
208
+ * Only returns networks that have configured addresses
209
+ */
210
+ export declare function getNetworkAddresses(networks: Network[]): Array<{
211
+ name: Network;
212
+ address: string;
213
+ facilitatorEndpoint?: string;
214
+ }>;
215
+ /**
216
+ * Approximate USD/token map (float) for dashboards or legacy callers.
217
+ * **Atomic amounts** use exact rational math from the same env defaults — see
218
+ * `atomicAmountForPriceInCents` / `getTokenUsdPerTokenRational` in this file.
219
+ */
220
+ export declare const TOKEN_PRICES_USD: Record<string, number>;
221
+ /**
222
+ * Smallest-unit token amount for x402 `maxAmountRequired` and verification,
223
+ * from integer USD cents and a concrete payment config (symbol + network).
224
+ */
225
+ export declare function atomicAmountForPriceInCents(priceInCents: number, config: PaymentConfigDefinition): string;
226
+ /**
227
+ * Parse price string (e.g., "$0.10") as a USD **dollar** amount and convert to
228
+ * the asset’s smallest units (ceil), using the same rational pricing as
229
+ * `atomicAmountForPriceInCents` / env overrides (`ELIZAOS_PRICE_USD`, etc.).
230
+ */
231
+ export declare function parsePrice(price: string, asset?: string, network?: Network): string;
232
+ /**
233
+ * Get token address for any network and asset
234
+ */
235
+ export declare function getTokenAddress(asset: string, network: Network): string | undefined;
236
+ /**
237
+ * Get the asset for a specific network
238
+ * @throws {Error} If network is not configured
239
+ */
240
+ export declare function getNetworkAsset(network: Network): string;
241
+ /**
242
+ * Get x402 system health status
243
+ * Useful for monitoring and debugging
244
+ */
245
+ export declare function getX402Health(): {
246
+ networks: Array<{
247
+ network: Network;
248
+ configured: boolean;
249
+ address: string | null;
250
+ }>;
251
+ facilitator: {
252
+ url: string | null;
253
+ configured: boolean;
254
+ };
255
+ };
256
+ //# sourceMappingURL=payment-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-config.d.ts","sourceRoot":"","sources":["../src/payment-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,mEAAmE;AACnE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,iBAAiB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AoBR;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAe,EACtB,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAcR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CAkBpB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CASxD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI;IAC/B,QAAQ,EAAE,KAAK,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;QACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC,CAAC;IACH,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1D,CAeA"}
@@ -0,0 +1,42 @@
1
+ import type { Character, PaymentEnabledRoute, Route } from "@elizaos/core";
2
+ /**
3
+ * x402 **seller** middleware for plugin HTTP routes.
4
+ *
5
+ * **Why one middleware layer:** plugins should not each reimplement 402 bodies,
6
+ * header encodings, facilitator POSTs, replay semantics, or chain RPC checks.
7
+ * This module is the single integration point for “paid route” behavior.
8
+ *
9
+ * **Why multiple verification strategies coexist:** deployments differ—some
10
+ * have on-chain receipts only, some use facilitator payment IDs, some use modern
11
+ * `PAYMENT-SIGNATURE` payloads. Keeping strategies behind one `verifyPayment`
12
+ * function preserves one gate while letting operators choose what their clients send.
13
+ *
14
+ * **Why standard path calls settle:** see `x402-standard-payment.ts`—settlement is
15
+ * the economically meaningful step after verify for facilitator-backed flows.
16
+ *
17
+ * **Why we still emit legacy JSON 402:** backward compatibility for wallets and
18
+ * tools that parse the body; V2 clients additionally read `PAYMENT-REQUIRED`.
19
+ */
20
+ /**
21
+ * Set on routes returned by {@link applyPaymentProtection} so HTTP dispatch
22
+ * (`tryHandleRuntimePluginRoute`) does not call {@link createPaymentAwareHandler} again.
23
+ */
24
+ export declare const X402_ROUTE_PAYMENT_WRAPPED: unique symbol;
25
+ export declare function isRoutePaymentWrapped(route: unknown): boolean;
26
+ /**
27
+ * Create a payment-aware route handler
28
+ */
29
+ export declare function createPaymentAwareHandler(route: PaymentEnabledRoute): NonNullable<Route["handler"]>;
30
+ export type { X402RequestValidator, X402ValidationResult } from "@elizaos/core";
31
+ /**
32
+ * Apply payment protection to an array of routes
33
+ * Runs comprehensive startup validation before applying protection. Pass
34
+ * `character`/`agentId` so routes that use the `x402: true` shorthand (which
35
+ * resolves price + paymentConfigs from `character.settings.x402`) can validate
36
+ * without errors.
37
+ */
38
+ export declare function applyPaymentProtection(routes: Route[], context?: {
39
+ character?: Character;
40
+ agentId?: string;
41
+ }): Route[];
42
+ //# sourceMappingURL=payment-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-wrapper.d.ts","sourceRoot":"","sources":["../src/payment-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAET,mBAAmB,EACnB,KAAK,EAIN,MAAM,eAAe,CAAC;AAsEvB;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,eAAO,MAAM,0BAA0B,eAEtC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM7D;AAquCD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,mBAAmB,GACzB,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CA0Q/B;AAqTD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEhF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACpD,KAAK,EAAE,CAkCT"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Startup validation for x402 payment system
3
+ * Validates payment configs and routes before the server starts
4
+ */
5
+ import type { Character, Route } from "@elizaos/core";
6
+ /**
7
+ * Validation result with warnings and errors
8
+ */
9
+ export interface StartupValidationResult {
10
+ valid: boolean;
11
+ errors: string[];
12
+ warnings: string[];
13
+ }
14
+ /**
15
+ * Comprehensive startup validation
16
+ * Call this before starting the server to catch configuration issues early
17
+ */
18
+ export declare function validateX402Startup(routes: Route[], character?: Character, options?: {
19
+ agentId?: string;
20
+ }): StartupValidationResult;
21
+ /**
22
+ * Validate routes and throw if invalid
23
+ * This is used by applyPaymentProtection to fail fast on startup
24
+ */
25
+ export declare function validateAndThrowIfInvalid(routes: Route[], character?: Character, options?: {
26
+ agentId?: string;
27
+ }): void;
28
+ //# sourceMappingURL=startup-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-validator.d.ts","sourceRoot":"","sources":["../src/startup-validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,SAAS,EAGT,KAAK,EACN,MAAM,eAAe,CAAC;AAUvB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAiQD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,CAAC,EAAE,SAAS,EACrB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,uBAAuB,CAoCzB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,CAAC,EAAE,SAAS,EACrB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,IAAI,CAUN"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Strict TypeScript types for x402 payment middleware
3
+ * Replaces all 'any' types with proper interfaces
4
+ */
5
+ import type { AgentRuntime, RouteRequest } from "@elizaos/core";
6
+ /**
7
+ * Request shape for x402 (matches plugin routes + IncomingMessage headers)
8
+ */
9
+ export type X402Request = RouteRequest & {
10
+ method: string;
11
+ path: string;
12
+ headers: Record<string, string | string[] | undefined>;
13
+ query: Record<string, string | string[] | undefined>;
14
+ params: Record<string, string>;
15
+ };
16
+ /**
17
+ * Express-like response object
18
+ */
19
+ export interface X402Response {
20
+ status(code: number): X402ResponseStatus;
21
+ json(data: unknown): void;
22
+ setHeader?(name: string, value: string | readonly string[]): void;
23
+ headersSent?: boolean;
24
+ }
25
+ export interface X402ResponseStatus {
26
+ json(data: unknown): void;
27
+ }
28
+ /**
29
+ * EIP-712 Authorization data structure
30
+ */
31
+ export interface EIP712Authorization {
32
+ from: string;
33
+ to: string;
34
+ value: string;
35
+ validAfter: string;
36
+ validBefore: string;
37
+ nonce: string;
38
+ }
39
+ /**
40
+ * EIP-712 Domain structure
41
+ */
42
+ export interface EIP712Domain {
43
+ name: string;
44
+ version: string;
45
+ chainId: number;
46
+ verifyingContract: string;
47
+ }
48
+ export type { EIP712Authorization as EIP712AuthorizationType, EIP712Domain as EIP712DomainType, };
49
+ /**
50
+ * Payment proof data (EIP-712 format)
51
+ */
52
+ export interface EIP712PaymentProof {
53
+ signature: string;
54
+ authorization: EIP712Authorization;
55
+ domain?: EIP712Domain;
56
+ network?: string;
57
+ scheme?: string;
58
+ v?: number;
59
+ r?: string;
60
+ s?: string;
61
+ payload?: {
62
+ signature: string;
63
+ authorization: EIP712Authorization;
64
+ };
65
+ }
66
+ /**
67
+ * Solana payment proof
68
+ */
69
+ export interface SolanaPaymentProof {
70
+ signature: string;
71
+ network: "SOLANA";
72
+ }
73
+ /**
74
+ * Legacy payment proof format
75
+ */
76
+ export interface LegacyPaymentProof {
77
+ network: string;
78
+ address: string;
79
+ signature: string;
80
+ }
81
+ /**
82
+ * Runtime interface with required methods for x402
83
+ * Uses IAgentRuntime directly to avoid type conflicts
84
+ */
85
+ export type X402Runtime = AgentRuntime;
86
+ /**
87
+ * Payment verification parameters (route price + allowed presets)
88
+ */
89
+ export interface PaymentVerificationParams {
90
+ paymentProof?: string;
91
+ paymentId?: string;
92
+ route: string;
93
+ /** Integer USD cents (same as route `x402.priceInCents`) */
94
+ priceInCents: number;
95
+ /** Names from `x402.paymentConfigs` (resolved), in declaration order */
96
+ paymentConfigNames: string[];
97
+ agentId?: string;
98
+ runtime: X402Runtime;
99
+ req?: X402Request;
100
+ }
101
+ /** Successful verification metadata for events / receipts */
102
+ export interface PaymentVerifiedDetails {
103
+ paymentConfig: string;
104
+ network: string;
105
+ /** Smallest units of the paid asset */
106
+ amountAtomic: string;
107
+ symbol?: string;
108
+ payer?: string;
109
+ proofId?: string;
110
+ paymentResponse?: string;
111
+ }
112
+ export type VerifyPaymentResult = {
113
+ ok: false;
114
+ } | {
115
+ ok: true;
116
+ details: PaymentVerifiedDetails;
117
+ };
118
+ /**
119
+ * Payment receipt for tracking
120
+ */
121
+ export interface PaymentReceipt {
122
+ paymentId: string;
123
+ route: string;
124
+ amount: string;
125
+ network: string;
126
+ timestamp: number;
127
+ signature?: string;
128
+ verified: boolean;
129
+ }
130
+ /**
131
+ * Facilitator verification response
132
+ */
133
+ export interface FacilitatorVerificationResponse {
134
+ valid?: boolean;
135
+ verified?: boolean;
136
+ status?: string;
137
+ message?: string;
138
+ /** When present, must equal the route’s `resource` URL we sent on verify */
139
+ resource?: string;
140
+ /** When present, must match the plugin route path */
141
+ routePath?: string;
142
+ /** Alias some facilitators use for path */
143
+ route?: string;
144
+ /** When present, must match the route’s `priceInCents` */
145
+ priceInCents?: number;
146
+ /** When present, must be one of the route’s allowed preset names */
147
+ paymentConfig?: string;
148
+ /** When present, every entry must be in the route’s allowlist */
149
+ paymentConfigs?: string[];
150
+ }
151
+ /** Sent to the facilitator so responses can be bound to a specific purchase */
152
+ export interface FacilitatorVerifyContext {
153
+ resource: string;
154
+ routePath: string;
155
+ priceInCents: number;
156
+ paymentConfigNames: string[];
157
+ }
158
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC;IACzC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAClE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UA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,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B"}
@@ -0,0 +1,9 @@
1
+ import type { FacilitatorVerificationResponse, FacilitatorVerifyContext } from "./types.js";
2
+ /**
3
+ * When true, facilitator JSON must echo `resource`, route, `priceInCents`, and
4
+ * `paymentConfig` so a generic 200 cannot unlock unrelated routes.
5
+ * Set `X402_FACILITATOR_RELAXED_BINDING=1` if your facilitator does not return these fields yet.
6
+ */
7
+ export declare function isFacilitatorBindingRelaxed(): boolean;
8
+ export declare function facilitatorVerifyResponseMatchesRoute(data: FacilitatorVerificationResponse, ctx: FacilitatorVerifyContext, relaxed: boolean): boolean;
9
+ //# sourceMappingURL=x402-facilitator-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-facilitator-binding.d.ts","sourceRoot":"","sources":["../src/x402-facilitator-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAKrD;AAgFD,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,+BAA+B,EACrC,GAAG,EAAE,wBAAwB,EAC7B,OAAO,EAAE,OAAO,GACf,OAAO,CAIT"}
@@ -0,0 +1,30 @@
1
+ import { type AgentRuntime } from "@elizaos/core";
2
+ /** Stored in the runtime cache while verification owns a durable reservation. */
3
+ export type X402ReplayInflightPayload = {
4
+ state: "inflight";
5
+ owner: string;
6
+ reservedAt: number;
7
+ expiresAt: number;
8
+ };
9
+ /** Stored in the runtime cache after a successful payment verification. */
10
+ export type X402ReplayConsumedPayload = {
11
+ state: "consumed";
12
+ consumedAt: number;
13
+ };
14
+ export type X402ReplayPayload = X402ReplayInflightPayload | X402ReplayConsumedPayload;
15
+ export type DurableReplayReservation = {
16
+ ok: true;
17
+ owner: string;
18
+ atomic: boolean;
19
+ } | {
20
+ ok: false;
21
+ };
22
+ /**
23
+ * Stable cache key for a replay credential, scoped by agent so two agents never
24
+ * share the same cache row.
25
+ */
26
+ export declare function durableReplayCacheKey(agentId: string | undefined, replayKey: string): string;
27
+ export declare function durableReplayTryReserve(runtime: AgentRuntime, agentId: string | undefined, keys: string[]): Promise<DurableReplayReservation>;
28
+ export declare function durableReplayAbortReservation(runtime: AgentRuntime, agentId: string | undefined, keys: string[], owner?: string): Promise<void>;
29
+ export declare function durableReplayCommitReservation(runtime: AgentRuntime, agentId: string | undefined, keys: string[], owner?: string): Promise<void>;
30
+ //# sourceMappingURL=x402-replay-durable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-replay-durable.d.ts","sourceRoot":"","sources":["../src/x402-replay-durable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,eAAe,CAAC;AAO1D,iFAAiF;AACjF,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,yBAAyB,GACzB,yBAAyB,CAAC;AAE9B,MAAM,MAAM,wBAAwB,GAChC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5C;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAMlB;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAmHD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,wBAAwB,CAAC,CAgFnC;AAED,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAqCf"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Replay + in-flight guard for x402 verification.
3
+ *
4
+ * - **In-flight (`inflight`)**: in-memory only; prevents concurrent duplicate
5
+ * verification in the same process (TOCTOU between check and verify).
6
+ * - **Consumed**: when `X402_REPLAY_DURABLE` is not disabled and `runtime` is
7
+ * passed, credentials are recorded via `runtime.setCache` / `getCache` so they
8
+ * survive restarts and work across multiple server processes sharing the DB.
9
+ * Entries do not expire (same tx hash / payment id must not unlock paid routes twice).
10
+ * - **Fallback**: set `X402_REPLAY_DURABLE=0` (or `false` / `off`) to use only an
11
+ * in-memory TTL map (`X402_REPLAY_WINDOW_MS` / `X402_REPLAY_TTL_MS`, default 10m).
12
+ * If `runtime` is omitted (e.g. isolated unit tests), that same in-memory path is used.
13
+ */
14
+ import { type AgentRuntime } from "@elizaos/core";
15
+ /** When true (default), use runtime cache for consumed credentials. */
16
+ export declare function isDurableReplayEnabled(): boolean;
17
+ /**
18
+ * Reserve canonical replay keys for the duration of verification.
19
+ * Returns false if any key is already consumed, or already in-flight in this process.
20
+ */
21
+ export declare function replayGuardTryBegin(keys: string[], runtime?: AgentRuntime, agentId?: string): Promise<boolean>;
22
+ /** Release reservation after a failed or abandoned verification attempt. */
23
+ export declare function replayGuardAbort(keys: string[]): void;
24
+ /** Release a durable reservation after a failed or abandoned verification attempt. */
25
+ export declare function replayGuardAbortAsync(keys: string[], runtime?: AgentRuntime, agentId?: string): Promise<void>;
26
+ /** Mark keys consumed after a successful verification (clears in-flight). */
27
+ export declare function replayGuardCommit(keys: string[], runtime?: AgentRuntime, agentId?: string): Promise<void>;
28
+ //# sourceMappingURL=x402-replay-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-replay-guard.d.ts","sourceRoot":"","sources":["../src/x402-replay-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,eAAe,CAAC;AAyB1D,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,OAAO,CAIhD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAgDlB;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAKrD;AAED,sFAAsF;AACtF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,6EAA6E;AAC7E,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAgCf"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Replay key for facilitator payment IDs (sanitized id → stable hash).
3
+ */
4
+ export declare function paymentIdReplayKey(paymentId: string): string | null;
5
+ /**
6
+ * For route handlers: only treat the proof as base64-wrapped UTF-8 when it passes
7
+ * the same heuristics as replay-key extraction. Raw `0x…` tx hashes and colon proofs
8
+ * stay intact (unlike unconditional `Buffer.from(s, "base64")`).
9
+ */
10
+ export declare function decodePaymentProofForParsing(proof: string): string;
11
+ /**
12
+ * Canonical replay keys derivable from a payment proof string (raw or base64-wrapped).
13
+ * Same on-chain tx / Solana signature / EIP-712 intent maps to the same key regardless
14
+ * of outer encoding (e.g. base64 vs plain).
15
+ */
16
+ export declare function replayKeysFromProofString(proof: string): string[];
17
+ /**
18
+ * All replay keys to consult before verification and to mark after a successful one.
19
+ */
20
+ export declare function collectReplayKeysToCheck(paymentProof?: string, paymentId?: string): string[];
21
+ //# sourceMappingURL=x402-replay-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-replay-keys.d.ts","sourceRoot":"","sources":["../src/x402-replay-keys.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInE;AAgCD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElE;AAgED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAWjE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,CAAC,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,EAAE,CAUV"}
@@ -0,0 +1,6 @@
1
+ import type { AgentRuntime, PaymentEnabledRoute, X402Config } from "@elizaos/core";
2
+ export declare const X402_EVENT_PAYMENT_VERIFIED = "PAYMENT_VERIFIED";
3
+ export declare const X402_EVENT_PAYMENT_REQUIRED = "PAYMENT_REQUIRED";
4
+ /** Resolves `x402: true` / partial route config using `character.settings.x402`. */
5
+ export declare function resolveEffectiveX402(route: PaymentEnabledRoute, runtime: AgentRuntime): X402Config | null;
6
+ //# sourceMappingURL=x402-resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-resolve.d.ts","sourceRoot":"","sources":["../src/x402-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGZ,mBAAmB,EACnB,UAAU,EACX,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAC9D,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAW9D,oFAAoF;AACpF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,YAAY,GACpB,UAAU,GAAG,IAAI,CAkBnB"}