@elizaos/plugin-x402 2.0.0-alpha.5 → 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.
- package/dist/index.d.ts +57 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30914 -1844
- package/dist/index.js.map +114 -21
- package/dist/payment-config.d.ts +256 -0
- package/dist/payment-config.d.ts.map +1 -0
- package/dist/payment-wrapper.d.ts +42 -0
- package/dist/payment-wrapper.d.ts.map +1 -0
- package/dist/startup-validator.d.ts +28 -0
- package/dist/startup-validator.d.ts.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/x402-facilitator-binding.d.ts +9 -0
- package/dist/x402-facilitator-binding.d.ts.map +1 -0
- package/dist/x402-replay-durable.d.ts +30 -0
- package/dist/x402-replay-durable.d.ts.map +1 -0
- package/dist/x402-replay-guard.d.ts +28 -0
- package/dist/x402-replay-guard.d.ts.map +1 -0
- package/dist/x402-replay-keys.d.ts +21 -0
- package/dist/x402-replay-keys.d.ts.map +1 -0
- package/dist/x402-resolve.d.ts +6 -0
- package/dist/x402-resolve.d.ts.map +1 -0
- package/dist/x402-standard-payment.d.ts +130 -0
- package/dist/x402-standard-payment.d.ts.map +1 -0
- package/dist/x402-types.d.ts +130 -0
- package/dist/x402-types.d.ts.map +1 -0
- package/package.json +43 -94
- package/src/index.ts +113 -0
- package/src/payment-config.ts +737 -0
- package/src/payment-wrapper.ts +1991 -0
- package/src/startup-validator.ts +349 -0
- package/src/types.ts +177 -0
- package/src/x402-facilitator-binding.ts +104 -0
- package/src/x402-replay-durable.ts +320 -0
- package/src/x402-replay-guard.ts +165 -0
- package/src/x402-replay-keys.ts +151 -0
- package/src/x402-resolve.ts +43 -0
- package/src/x402-standard-payment.ts +519 -0
- package/src/x402-types.ts +376 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* x402 Payment Middleware for ElizaOS
|
|
3
|
+
*
|
|
4
|
+
* Provides micropayment protection for plugin routes using the x402 protocol.
|
|
5
|
+
*
|
|
6
|
+
* **Why this module exists (product):** plugin authors should declare `x402` on
|
|
7
|
+
* routes and get a consistent gate—402 with payment options, verification, and
|
|
8
|
+
* optional facilitator settlement—without reimplementing payment math, replay
|
|
9
|
+
* safety, or HTTP header quirks in every plugin.
|
|
10
|
+
*
|
|
11
|
+
* **Why both “legacy JSON 402” and V2 headers:** older clients and scanners read
|
|
12
|
+
* the JSON body; protocol V2 buyers read `PAYMENT-REQUIRED` / `PAYMENT-RESPONSE`.
|
|
13
|
+
* Serving both avoids breaking existing integrations while still interoperating
|
|
14
|
+
* with modern wallets.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { applyPaymentProtection } from '@elizaos/plugin-x402';
|
|
19
|
+
*
|
|
20
|
+
* // In your plugin:
|
|
21
|
+
* export const routes: Route[] = [
|
|
22
|
+
* {
|
|
23
|
+
* type: 'GET',
|
|
24
|
+
* path: '/api/analytics/trending',
|
|
25
|
+
* public: true,
|
|
26
|
+
* x402: {
|
|
27
|
+
* priceInCents: 10,
|
|
28
|
+
* paymentConfigs: ['base_usdc', 'solana_usdc']
|
|
29
|
+
* },
|
|
30
|
+
* handler: async (req, res, runtime) => {
|
|
31
|
+
* // Your handler logic
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ];
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type { BuiltInPaymentConfig, CharacterX402Settings, PaymentEnabledRoute, X402Config, X402RequestValidator, X402ValidationResult, } from "@elizaos/core";
|
|
38
|
+
export type { Network } from "./payment-config.js";
|
|
39
|
+
export { atomicAmountForPriceInCents, BUILT_IN_NETWORKS, getBaseUrl, getPaymentAddress, getPaymentConfig, getX402Health, listX402Configs, PAYMENT_ADDRESSES, PAYMENT_CONFIGS, type PaymentConfigDefinition, registerX402Config, toResourceUrl, toX402Network, } from "./payment-config.js";
|
|
40
|
+
export { applyPaymentProtection, createPaymentAwareHandler, isRoutePaymentWrapped, X402_ROUTE_PAYMENT_WRAPPED, } from "./payment-wrapper.js";
|
|
41
|
+
export { resolveEffectiveX402, X402_EVENT_PAYMENT_REQUIRED, X402_EVENT_PAYMENT_VERIFIED, } from "./x402-resolve.js";
|
|
42
|
+
export { type StartupValidationResult, validateAndThrowIfInvalid, validateX402Startup, } from "./startup-validator.js";
|
|
43
|
+
export { type Accepts, createAccepts, createX402Response, type OutputSchema, validateAccepts, validateX402Response, type X402Response, type X402ScanNetwork, } from "./x402-types.js";
|
|
44
|
+
import type { Plugin } from "@elizaos/core";
|
|
45
|
+
/**
|
|
46
|
+
* elizaOS plugin descriptor for x402.
|
|
47
|
+
*
|
|
48
|
+
* The middleware exported above is the actual integration surface — plugins
|
|
49
|
+
* declare `x402` on their routes and the agent's HTTP dispatch wraps them via
|
|
50
|
+
* `applyPaymentProtection` / `createPaymentAwareHandler`. This Plugin object
|
|
51
|
+
* exists so the runtime's plugin loader can register `@elizaos/plugin-x402` as
|
|
52
|
+
* a first-class auto-loadable plugin (config: `x402.enabled`).
|
|
53
|
+
*/
|
|
54
|
+
declare const x402Plugin: Plugin;
|
|
55
|
+
export default x402Plugin;
|
|
56
|
+
export { x402Plugin };
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,uBAAuB,EAC5B,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,KAAK,OAAO,EACZ,aAAa,EACb,kBAAkB,EAClB,KAAK,YAAY,EACjB,eAAe,EACf,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;GAQG;AACH,QAAA,MAAM,UAAU,EAAE,MAQjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,CAAC"}
|