@cryptonly/x402 0.4.0 → 0.5.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.
package/README.md CHANGED
@@ -4,136 +4,88 @@
4
4
 
5
5
  # Cryptonly — x402 facilitator
6
6
 
7
- Facilitator client for x402 payments.
7
+ Accept x402 payments in Node.js, with Cryptonly as the facilitator.
8
8
 
9
- [Website](https://cryptonly.net) · [Documentation](https://docs.cryptonly.net/api-reference/openapi/operations/x402supported/) · [Contact](https://cryptonly.net/contact/)
9
+ [Website](https://cryptonly.net) · [Documentation](https://docs.cryptonly.net/guides/x402/) · [Contact](https://cryptonly.net/contact/)
10
10
 
11
11
  </div>
12
12
 
13
13
  ---
14
14
 
15
- Pass it to `x402ResourceServer` from `@x402/express`, `@x402/hono`, or `@x402/next`.
15
+ Cryptonly verifies and settles each payment, and pays the network fee. Payments go straight to your wallet.
16
16
 
17
- ```bash
18
- npm install @cryptonly/x402
19
- ```
20
-
21
- `@x402/core` ^2 is a peer dependency. Also install the framework package you use, such as `@x402/express` or `@x402/evm`.
22
-
23
- ```ts
24
- import { CryptonlyFacilitatorClient } from '@cryptonly/x402';
25
- import { ExactEvmScheme } from '@x402/evm/exact/server';
26
- import { x402ResourceServer } from '@x402/express';
27
-
28
- const facilitator = new CryptonlyFacilitatorClient({
29
- apiKey: process.env.CRYPTONLY_API_KEY!,
30
- });
17
+ Pick the package for your framework. Each one loads your prices from the Cryptonly dashboard, so a price change needs no deploy:
31
18
 
32
- const server = new x402ResourceServer(facilitator).register(
33
- 'eip155:8453',
34
- new ExactEvmScheme(),
35
- );
36
- ```
19
+ | Framework | Package |
20
+ | --- | --- |
21
+ | Express | [`@cryptonly/x402-express`](https://www.npmjs.com/package/@cryptonly/x402-express) |
22
+ | Fastify | [`@cryptonly/x402-fastify`](https://www.npmjs.com/package/@cryptonly/x402-fastify) |
23
+ | NestJS (Express or Fastify platform) | [`@cryptonly/x402-nestjs`](https://www.npmjs.com/package/@cryptonly/x402-nestjs) |
37
24
 
38
- ## Options
25
+ This package, `@cryptonly/x402`, is what they share: the facilitator client and the dashboard price loader. Use it directly for prices in your code, or for another framework.
39
26
 
40
- | Option | Default | |
41
- | --- | --- | --- |
42
- | `apiKey` | required | Your Cryptonly API key, with the `x402.verify` and `x402.settle` scopes. Sent as `x-tenant-api-key` on every facilitator call. |
43
- | `sandbox` | `false` | Use the sandbox facilitator, which settles on Base Sepolia (`eip155:84532`). |
44
- | `baseUrl` | — | Merchant API origin, for example a local API. `/x402` is appended. Takes precedence over `sandbox`. |
45
-
46
- ```ts
47
- // Sandbox: Base Sepolia, with test USDC from the Circle faucet.
48
- const facilitator = new CryptonlyFacilitatorClient({
49
- apiKey: process.env.CRYPTONLY_API_KEY!,
50
- sandbox: true,
51
- });
52
- const server = new x402ResourceServer(facilitator).register(
53
- 'eip155:84532',
54
- new ExactEvmScheme(),
55
- );
56
- ```
27
+ You need a Cryptonly API key with the `x402.verify` and `x402.settle` scopes. The [quickstart](https://docs.cryptonly.net/guides/x402/quickstart/) covers getting one.
57
28
 
58
- ## Dashboard-configured routes
29
+ ## Prices in your code
59
30
 
60
- `@cryptonly/x402/express` reads your paid resources, prices and payout address from the Cryptonly dashboard, so you do not write routes in code. A price change in the dashboard reaches production within a minute, without a deploy.
31
+ `CryptonlyFacilitatorClient` plugs into the stock `@x402/express`, `@x402/fastify`, `@x402/hono` or `@x402/next` middleware.
61
32
 
62
33
  ```bash
63
- npm install @cryptonly/x402 @x402/core @x402/express @x402/evm express
34
+ npm install @cryptonly/x402 @x402/core @x402/express @x402/evm
64
35
  ```
65
36
 
66
37
  ```ts
67
- import express from 'express';
68
- import { cryptonlyPaymentMiddleware } from '@cryptonly/x402/express';
69
-
70
- const app = express();
71
-
72
- app.get('/health', (_req, res) => res.send('ok')); // free routes first
73
-
74
- const payments = cryptonlyPaymentMiddleware({
75
- apiKey: process.env.CRYPTONLY_API_KEY!, // scopes x402.verify and x402.settle
76
- });
77
- app.use(payments);
78
-
79
- // Priced in the dashboard as `GET /weather/:city`.
80
- app.get('/weather/:city', (req, res) => {
81
- res.json({ city: req.params.city, temperatureC: 21 });
82
- });
83
-
84
- await payments.ready(); // optional: fail at startup if the config cannot load
85
- app.listen(4021);
38
+ import { CryptonlyFacilitatorClient } from '@cryptonly/x402';
39
+ import { ExactEvmScheme } from '@x402/evm/exact/server';
40
+ import { paymentMiddleware, x402ResourceServer } from '@x402/express';
41
+
42
+ const facilitator = new CryptonlyFacilitatorClient({ apiKey: process.env.CRYPTONLY_API_KEY! });
43
+ const server = new x402ResourceServer(facilitator).register('eip155:8453', new ExactEvmScheme());
44
+
45
+ app.use(
46
+ paymentMiddleware(
47
+ {
48
+ 'GET /weather/:city': {
49
+ accepts: [{ scheme: 'exact', price: '$0.01', network: 'eip155:8453', payTo: process.env.PAY_TO! }],
50
+ },
51
+ },
52
+ server,
53
+ ),
54
+ );
86
55
  ```
87
56
 
88
- How it works:
89
-
90
- - It loads `GET /x402/config` with your API key on the first request (or on `ready()`), then every minute.
91
- - It turns each resource into a stock `@x402/express` route: `METHOD /path` (or just `/path` for method `*`), the price in atomic units of the chosen asset, your `payTo`, and the token's EIP-712 domain in `extra`. A Permit2-only token gets `assetTransferMethod: 'permit2'` and EIP-2612 gas sponsoring.
92
- - Resources marked discoverable get the bazaar discovery extension, with their input and output schemas, when `@x402/extensions` is installed.
93
- - It rebuilds the stock middleware only when the routes change.
94
-
95
- It fails closed, so paid endpoints are never served for free:
57
+ `CryptonlyFacilitatorClient` takes `apiKey`, `sandbox` and `baseUrl`. `payTo` must be a wallet you added in the dashboard. On Solana, register `ExactSvmScheme` from `@x402/svm/exact/server` for `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`.
96
58
 
97
- - If the first load fails, every request through the middleware answers `503` with `Retry-After` until a load succeeds. This covers a bad key, an account that is not active, or no payout address. Mount the middleware after your free routes.
98
- - If a refresh fails, the last good routes stay in use and a warning is logged.
59
+ ## Prices in the dashboard, another framework
99
60
 
100
- | Option | Default | |
101
- | --- | --- | --- |
102
- | `apiKey` | required | Same key as for `CryptonlyFacilitatorClient`. It also needs `x402.verify` for `GET /x402/config`. |
103
- | `sandbox`, `baseUrl` | production | As for `CryptonlyFacilitatorClient`. |
104
- | `refreshIntervalMs` | `60000` | How often to reload the configuration. `0` turns refreshing off. |
105
- | `schemes` | `[new ExactEvmScheme()]` | Scheme servers registered on the account's Base network. Resources with another scheme are skipped. |
106
- | `svmSchemes` | `[new ExactSvmScheme()]` when `@x402/svm` is installed, else none | Scheme servers registered on the account's Solana network. Without one, Solana-priced resources are skipped. |
107
- | `paywallConfig` | — | Passed to the stock `paymentMiddleware`. |
108
- | `logger` | `console` | Receives refresh failures and skipped resources. |
109
- | `createMiddleware` | stock `paymentMiddleware` | Builds the inner middleware for a set of routes, for example to add hooks. |
110
-
111
- The returned middleware also has these methods:
112
-
113
- - `ready()`: load now.
114
- - `refresh()`: reload now. It resolves `true` when the routes changed.
115
- - `routes()`: the routes in use.
116
- - `close()`: stop refreshing. The refresh timer is `unref()`ed and never keeps the process alive.
117
-
118
- For another framework, build the routes yourself with `fetchX402Config()` and `routesFromConfig()` from `@cryptonly/x402`, and pass them to its stock x402 middleware.
119
-
120
- ### Discovery
121
-
122
- `CryptonlyFacilitatorClient` also sends the key on bazaar calls:
61
+ - `fetchX402Config()` and `routesFromConfig()` turn your dashboard prices into stock `@x402/core` routes for any x402 middleware.
62
+ - `createX402RouteSource()` adds what the framework packages do on top: one load, a refresh every minute, and the last good routes kept when a refresh fails.
123
63
 
124
64
  ```ts
125
- import { withBazaar } from '@x402/extensions/bazaar';
65
+ import { createResourceServer, createX402RouteSource } from '@cryptonly/x402';
66
+ import { x402HTTPResourceServer } from '@x402/core/server';
67
+
68
+ const source = createX402RouteSource({ apiKey: process.env.CRYPTONLY_API_KEY! }, (routes, config) =>
69
+ new x402HTTPResourceServer(
70
+ createResourceServer(config, source.facilitator, source.schemes, source.svmSchemes),
71
+ routes,
72
+ ),
73
+ );
126
74
 
127
- const client = withBazaar(new CryptonlyFacilitatorClient({ apiKey }));
128
- const { items } = await client.extensions.bazaar.listResources();
75
+ await source.ready(); // rejects if the prices can't load
76
+ const httpServer = source.current()!.value; // rebuilt only when the prices change
129
77
  ```
130
78
 
131
- ## Networks and assets
79
+ ## Sandbox
80
+
81
+ Pass `sandbox: true` and use a key from your [sandbox account](https://docs.cryptonly.net/guides/sandbox-environment/). The sandbox settles on Base Sepolia (`eip155:84532`) and Solana Devnet.
132
82
 
133
- Production settles on Base (`eip155:8453`) and Solana (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`); sandbox on Base Sepolia (`eip155:84532`) and Solana Devnet (`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`). On Base, USDC and EURC settle with EIP-3009, and allowlisted tokens also through Permit2. On Solana, USDC and USDT settle with the `exact` SVM scheme: the buyer signs a token transfer and Cryptonly co-signs it as fee payer (`extra.feePayer` in `GET /x402/supported`). The buyer never needs ETH or SOL. `GET /x402/supported` lists what the facilitator accepts.
83
+ ## Learn more
134
84
 
135
- To take Solana payments with `cryptonlyPaymentMiddleware`, install `@x402/svm` and `@solana/kit` next to it and price resources in a Solana asset in the dashboard. Payouts are set up per network, so the account also needs a Solana `payTo`.
85
+ - [x402 quickstart](https://docs.cryptonly.net/guides/x402/quickstart/)
86
+ - [Discovery](https://docs.cryptonly.net/guides/x402/discovery/): list your endpoints for AI agents
87
+ - [Reference](https://docs.cryptonly.net/guides/x402/reference/): key scopes, limits and reason codes
136
88
 
137
- ## Settlement results
89
+ ## License
138
90
 
139
- USDC goes straight from the buyer to your `payTo` address; Cryptonly never holds it. If the transaction has not mined when `/settle` answers, the answer is `settlement_pending` with the transaction hash. List your settlements, including their final status, with `GET /x402/settlements` (scope `x402.list`) or `client.x402Settlements.list()` in `@cryptonly/sdk`.
91
+ [MIT](https://github.com/cryptonly-net/x402/blob/main/LICENSE)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { CryptonlyFacilitatorClient, resolveMerchantApiOrigin, } from './client.js';
2
2
  export type { CryptonlyFacilitatorConfig } from './client.js';
3
- export { X402ConfigError, assertPayableConfig, fetchX402Config, loadX402Extensions, parseX402Config, routeKey, routesFromConfig, } from './config.js';
3
+ export { X402ConfigError, assertPayableConfig, fetchX402Config, isSolanaNetwork, loadX402Extensions, parseX402Config, routeKey, routesFromConfig, } from './config.js';
4
4
  export type { FetchX402ConfigOptions, RoutesFromConfigOptions, X402AccountStatus, X402Config, X402ConfigAsset, X402ConfigErrorCode, X402ConfigResource, X402ExtensionsModule, } from './config.js';
5
5
  export { MERCHANT_API_BASE_URL, MERCHANT_API_KEY_HEADER, SANDBOX_MERCHANT_API_BASE_URL, } from './constants.js';
6
+ export { X402_CONFIG_UNAVAILABLE, X402_LOG_PREFIX, createResourceServer, createX402RouteSource, defaultEvmSchemes, defaultSvmSchemes, describeError, solanaNetworksOf, } from './route-source.js';
7
+ export type { X402Logger, X402RouteSet, X402RouteSetBuilder, X402RouteSource, X402RouteSourceOptions, } from './route-source.js';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SANDBOX_MERCHANT_API_BASE_URL = exports.MERCHANT_API_KEY_HEADER = exports.MERCHANT_API_BASE_URL = exports.routesFromConfig = exports.routeKey = exports.parseX402Config = exports.loadX402Extensions = exports.fetchX402Config = exports.assertPayableConfig = exports.X402ConfigError = exports.resolveMerchantApiOrigin = exports.CryptonlyFacilitatorClient = void 0;
3
+ exports.solanaNetworksOf = exports.describeError = exports.defaultSvmSchemes = exports.defaultEvmSchemes = exports.createX402RouteSource = exports.createResourceServer = exports.X402_LOG_PREFIX = exports.X402_CONFIG_UNAVAILABLE = exports.SANDBOX_MERCHANT_API_BASE_URL = exports.MERCHANT_API_KEY_HEADER = exports.MERCHANT_API_BASE_URL = exports.routesFromConfig = exports.routeKey = exports.parseX402Config = exports.loadX402Extensions = exports.isSolanaNetwork = exports.fetchX402Config = exports.assertPayableConfig = exports.X402ConfigError = exports.resolveMerchantApiOrigin = exports.CryptonlyFacilitatorClient = void 0;
4
4
  var client_js_1 = require("./client.js");
5
5
  Object.defineProperty(exports, "CryptonlyFacilitatorClient", { enumerable: true, get: function () { return client_js_1.CryptonlyFacilitatorClient; } });
6
6
  Object.defineProperty(exports, "resolveMerchantApiOrigin", { enumerable: true, get: function () { return client_js_1.resolveMerchantApiOrigin; } });
@@ -8,6 +8,7 @@ var config_js_1 = require("./config.js");
8
8
  Object.defineProperty(exports, "X402ConfigError", { enumerable: true, get: function () { return config_js_1.X402ConfigError; } });
9
9
  Object.defineProperty(exports, "assertPayableConfig", { enumerable: true, get: function () { return config_js_1.assertPayableConfig; } });
10
10
  Object.defineProperty(exports, "fetchX402Config", { enumerable: true, get: function () { return config_js_1.fetchX402Config; } });
11
+ Object.defineProperty(exports, "isSolanaNetwork", { enumerable: true, get: function () { return config_js_1.isSolanaNetwork; } });
11
12
  Object.defineProperty(exports, "loadX402Extensions", { enumerable: true, get: function () { return config_js_1.loadX402Extensions; } });
12
13
  Object.defineProperty(exports, "parseX402Config", { enumerable: true, get: function () { return config_js_1.parseX402Config; } });
13
14
  Object.defineProperty(exports, "routeKey", { enumerable: true, get: function () { return config_js_1.routeKey; } });
@@ -16,4 +17,13 @@ var constants_js_1 = require("./constants.js");
16
17
  Object.defineProperty(exports, "MERCHANT_API_BASE_URL", { enumerable: true, get: function () { return constants_js_1.MERCHANT_API_BASE_URL; } });
17
18
  Object.defineProperty(exports, "MERCHANT_API_KEY_HEADER", { enumerable: true, get: function () { return constants_js_1.MERCHANT_API_KEY_HEADER; } });
18
19
  Object.defineProperty(exports, "SANDBOX_MERCHANT_API_BASE_URL", { enumerable: true, get: function () { return constants_js_1.SANDBOX_MERCHANT_API_BASE_URL; } });
20
+ var route_source_js_1 = require("./route-source.js");
21
+ Object.defineProperty(exports, "X402_CONFIG_UNAVAILABLE", { enumerable: true, get: function () { return route_source_js_1.X402_CONFIG_UNAVAILABLE; } });
22
+ Object.defineProperty(exports, "X402_LOG_PREFIX", { enumerable: true, get: function () { return route_source_js_1.X402_LOG_PREFIX; } });
23
+ Object.defineProperty(exports, "createResourceServer", { enumerable: true, get: function () { return route_source_js_1.createResourceServer; } });
24
+ Object.defineProperty(exports, "createX402RouteSource", { enumerable: true, get: function () { return route_source_js_1.createX402RouteSource; } });
25
+ Object.defineProperty(exports, "defaultEvmSchemes", { enumerable: true, get: function () { return route_source_js_1.defaultEvmSchemes; } });
26
+ Object.defineProperty(exports, "defaultSvmSchemes", { enumerable: true, get: function () { return route_source_js_1.defaultSvmSchemes; } });
27
+ Object.defineProperty(exports, "describeError", { enumerable: true, get: function () { return route_source_js_1.describeError; } });
28
+ Object.defineProperty(exports, "solanaNetworksOf", { enumerable: true, get: function () { return route_source_js_1.solanaNetworksOf; } });
19
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAGqB;AAFnB,uHAAA,0BAA0B,OAAA;AAC1B,qHAAA,wBAAwB,OAAA;AAG1B,yCAQqB;AAPnB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAYlB,+CAIwB;AAHtB,qHAAA,qBAAqB,OAAA;AACrB,uHAAA,uBAAuB,OAAA;AACvB,6HAAA,6BAA6B,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAGqB;AAFnB,uHAAA,0BAA0B,OAAA;AAC1B,qHAAA,wBAAwB,OAAA;AAG1B,yCASqB;AARnB,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,4GAAA,eAAe,OAAA;AACf,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAYlB,+CAIwB;AAHtB,qHAAA,qBAAqB,OAAA;AACrB,uHAAA,uBAAuB,OAAA;AACvB,6HAAA,6BAA6B,OAAA;AAE/B,qDAS2B;AARzB,0HAAA,uBAAuB,OAAA;AACvB,kHAAA,eAAe,OAAA;AACf,uHAAA,oBAAoB,OAAA;AACpB,wHAAA,qBAAqB,OAAA;AACrB,oHAAA,iBAAiB,OAAA;AACjB,oHAAA,iBAAiB,OAAA;AACjB,gHAAA,aAAa,OAAA;AACb,mHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,105 @@
1
+ import { x402ResourceServer, type RoutesConfig } from '@x402/core/server';
2
+ import type { SchemeNetworkServer } from '@x402/core/types';
3
+ import { CryptonlyFacilitatorClient, type CryptonlyFacilitatorConfig } from './client.js';
4
+ import { type X402Config, type X402ExtensionsModule } from './config.js';
5
+ /** Logger used for refresh failures and skipped resources. */
6
+ export type X402Logger = Pick<Console, 'info' | 'warn' | 'error'>;
7
+ /** Options shared by every framework adapter. */
8
+ export type X402RouteSourceOptions = CryptonlyFacilitatorConfig & {
9
+ /**
10
+ * How often to reload `GET /x402/config`. Defaults to 60 s; `0` turns
11
+ * refreshing off.
12
+ */
13
+ refreshIntervalMs?: number;
14
+ /**
15
+ * Scheme servers registered on the account's EVM network. Defaults to
16
+ * `[new ExactEvmScheme()]` from `@x402/evm`. Resources with another scheme
17
+ * are skipped.
18
+ */
19
+ schemes?: readonly SchemeNetworkServer[];
20
+ /**
21
+ * Scheme servers registered on the account's Solana networks. Defaults
22
+ * to `[new ExactSvmScheme()]` from `@x402/svm` when it is installed, and
23
+ * to none otherwise (Solana resources are then skipped).
24
+ */
25
+ svmSchemes?: readonly SchemeNetworkServer[];
26
+ /** `fetch` for `GET /x402/config`. Defaults to the global `fetch`. */
27
+ fetch?: typeof fetch;
28
+ /**
29
+ * After a failed first load, how long requests answer 503 before the
30
+ * next attempt. Defaults to 5 s.
31
+ */
32
+ retryAfterMs?: number;
33
+ /** Defaults to `console`. */
34
+ logger?: X402Logger;
35
+ /** `@x402/extensions` override; `null` leaves extensions out. */
36
+ extensions?: X402ExtensionsModule | null;
37
+ };
38
+ /** One loaded configuration, its routes and what the adapter built for them. */
39
+ export type X402RouteSet<T> = {
40
+ config: X402Config;
41
+ routes: RoutesConfig;
42
+ /** Identity of the routes: equal keys mean nothing to rebuild. */
43
+ key: string;
44
+ /** What the adapter's `build` returned for these routes. */
45
+ value: T;
46
+ };
47
+ /** The dashboard routes, kept fresh. See {@link createX402RouteSource}. */
48
+ export type X402RouteSource<T> = {
49
+ readonly facilitator: CryptonlyFacilitatorClient;
50
+ /** Scheme servers in use on the EVM network. */
51
+ readonly schemes: readonly SchemeNetworkServer[];
52
+ /** Scheme servers in use on the Solana networks. */
53
+ readonly svmSchemes: readonly SchemeNetworkServer[];
54
+ /** For `Retry-After` while the configuration is unavailable. */
55
+ readonly retryAfterMs: number;
56
+ readonly logger: X402Logger;
57
+ /** The route set in use, or `undefined` before the first successful load. */
58
+ current(): X402RouteSet<T> | undefined;
59
+ /**
60
+ * Loads the configuration now (if not loaded yet) and starts refreshing.
61
+ * Rejects when the first load fails; within `retryAfterMs` of a failure
62
+ * it rejects again without a new attempt.
63
+ */
64
+ ready(): Promise<void>;
65
+ /** Reloads the configuration now. Resolves `true` when the routes changed. */
66
+ refresh(): Promise<boolean>;
67
+ /** Stops refreshing. The last routes stay in use. */
68
+ close(): void;
69
+ };
70
+ /** Builds what an adapter serves for one set of routes. Throwing keeps the last set. */
71
+ export type X402RouteSetBuilder<T> = (routes: RoutesConfig, config: X402Config) => T;
72
+ /** Body of the `503` answered while the configuration is unavailable. */
73
+ export declare const X402_CONFIG_UNAVAILABLE: {
74
+ readonly error: "x402_config_unavailable";
75
+ readonly message: "Payment configuration is unavailable; retry shortly.";
76
+ };
77
+ /** Prefix of every log line the packages write. */
78
+ export declare const X402_LOG_PREFIX = "[@cryptonly/x402]";
79
+ /**
80
+ * Loads the paid routes from the Cryptonly dashboard (`GET /x402/config`)
81
+ * and refreshes them every minute. The framework adapters share it.
82
+ *
83
+ * - The configuration loads on {@link X402RouteSource.ready}, once.
84
+ * - Each refresh calls `build` only when the routes changed. A failed
85
+ * refresh, or a `build` that throws, keeps the last good set.
86
+ */
87
+ export declare function createX402RouteSource<T>(options: X402RouteSourceOptions, build: X402RouteSetBuilder<T>): X402RouteSource<T>;
88
+ /**
89
+ * A fresh `x402ResourceServer` on the facilitator, with the EVM schemes
90
+ * registered on the account's network and the SVM schemes on each of its
91
+ * Solana networks.
92
+ *
93
+ * Build one per route set: `initialize()` on a shared one would clear its
94
+ * facilitator data under requests still in flight.
95
+ */
96
+ export declare function createResourceServer(config: X402Config, facilitator: CryptonlyFacilitatorClient, schemes: readonly SchemeNetworkServer[], svmSchemes: readonly SchemeNetworkServer[]): x402ResourceServer;
97
+ /** The Solana networks an account accepts payments on. */
98
+ export declare function solanaNetworksOf(config: X402Config): X402Config['network'][];
99
+ /** `[new ExactEvmScheme()]` from `@x402/evm`. Throws when it is not installed. */
100
+ export declare function defaultEvmSchemes(): SchemeNetworkServer[];
101
+ /** `[new ExactSvmScheme()]` from `@x402/svm` when installed (optional peer), else none. */
102
+ export declare function defaultSvmSchemes(): SchemeNetworkServer[];
103
+ /** An error's message, for log lines. */
104
+ export declare function describeError(error: unknown): string;
105
+ //# sourceMappingURL=route-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-source.d.ts","sourceRoot":"","sources":["../src/route-source.ts"],"names":[],"mappings":"AAAA,OAAO,E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3F,wBAAgB,iBAAiB,IAAI,mBAAmB,EAAE,CAUzD;AAED,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
@@ -1,81 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routesFromConfig = exports.fetchX402Config = exports.stockPaymentMiddleware = void 0;
4
- exports.cryptonlyPaymentMiddleware = cryptonlyPaymentMiddleware;
5
- const server_1 = require("@x402/evm/exact/server");
6
- const express_1 = require("@x402/express");
3
+ exports.X402_LOG_PREFIX = exports.X402_CONFIG_UNAVAILABLE = void 0;
4
+ exports.createX402RouteSource = createX402RouteSource;
5
+ exports.createResourceServer = createResourceServer;
6
+ exports.solanaNetworksOf = solanaNetworksOf;
7
+ exports.defaultEvmSchemes = defaultEvmSchemes;
8
+ exports.defaultSvmSchemes = defaultSvmSchemes;
9
+ exports.describeError = describeError;
10
+ const server_1 = require("@x402/core/server");
7
11
  const client_js_1 = require("./client.js");
8
12
  const config_js_1 = require("./config.js");
13
+ /** Body of the `503` answered while the configuration is unavailable. */
14
+ exports.X402_CONFIG_UNAVAILABLE = {
15
+ error: 'x402_config_unavailable',
16
+ message: 'Payment configuration is unavailable; retry shortly.',
17
+ };
18
+ /** Prefix of every log line the packages write. */
19
+ exports.X402_LOG_PREFIX = '[@cryptonly/x402]';
9
20
  const DEFAULT_REFRESH_INTERVAL_MS = 60_000;
10
21
  const DEFAULT_RETRY_AFTER_MS = 5_000;
11
- const LOG_PREFIX = '[@cryptonly/x402]';
12
- /** The default {@link InnerMiddlewareFactory}: stock `@x402/express`. */
13
- const stockPaymentMiddleware = (routes, { config, facilitator, schemes, svmSchemes, paywallConfig }) => {
14
- // A fresh resource server per route set: `initialize()` on a shared one
15
- // would clear its facilitator data under requests still in flight.
16
- const server = new express_1.x402ResourceServer(facilitator);
17
- for (const scheme of schemes) {
18
- server.register(config.network, scheme);
19
- }
20
- for (const network of solanaNetworksOf(config)) {
21
- for (const scheme of svmSchemes) {
22
- server.register(network, scheme);
23
- }
24
- }
25
- return (0, express_1.paymentMiddleware)(routes, server, paywallConfig);
26
- };
27
- exports.stockPaymentMiddleware = stockPaymentMiddleware;
28
- function solanaNetworksOf(config) {
29
- const networks = new Set();
30
- for (const entry of config.networks ?? []) {
31
- if ((0, config_js_1.isSolanaNetwork)(entry.network))
32
- networks.add(entry.network);
33
- }
34
- for (const asset of config.assets) {
35
- if (asset.network && (0, config_js_1.isSolanaNetwork)(asset.network))
36
- networks.add(asset.network);
37
- }
38
- return [...networks];
39
- }
40
- let svmModule;
41
- /** `@x402/svm`'s exact server scheme when installed (optional peer). */
42
- function defaultSvmSchemes() {
43
- if (svmModule === undefined) {
44
- try {
45
- // eslint-disable-next-line @typescript-eslint/no-require-imports
46
- svmModule = require('@x402/svm/exact/server');
47
- }
48
- catch {
49
- svmModule = null;
50
- }
51
- }
52
- return svmModule ? [new svmModule.ExactSvmScheme()] : [];
53
- }
54
22
  /**
55
- * Express middleware whose paid routes and prices come from the Cryptonly
56
- * dashboard (`GET /x402/config`), refreshed every minute, so a price change
57
- * reaches production without a deploy.
58
- *
59
- * - The configuration loads on the first request (or on `ready()`), once.
60
- * - Each refresh rebuilds the stock `@x402/express` middleware only when the
61
- * routes changed. A failed refresh keeps the last good routes.
62
- * - Until a first load succeeds, every request through it answers 503
63
- * (fail closed): paid endpoints are never served for free. Mount it after
64
- * health checks and other free routes.
23
+ * Loads the paid routes from the Cryptonly dashboard (`GET /x402/config`)
24
+ * and refreshes them every minute. The framework adapters share it.
65
25
  *
66
- * @example
67
- * ```ts
68
- * import { cryptonlyPaymentMiddleware } from '@cryptonly/x402/express';
69
- *
70
- * app.use(cryptonlyPaymentMiddleware({ apiKey: process.env.CRYPTONLY_API_KEY! }));
71
- * app.get('/weather', (req, res) => res.json({ temperatureC: 21 }));
72
- * ```
26
+ * - The configuration loads on {@link X402RouteSource.ready}, once.
27
+ * - Each refresh calls `build` only when the routes changed. A failed
28
+ * refresh, or a `build` that throws, keeps the last good set.
73
29
  */
74
- function cryptonlyPaymentMiddleware(options) {
30
+ function createX402RouteSource(options, build) {
75
31
  const facilitator = new client_js_1.CryptonlyFacilitatorClient(options);
76
- const schemes = options.schemes ?? [new server_1.ExactEvmScheme()];
32
+ const schemes = options.schemes ?? defaultEvmSchemes();
77
33
  const svmSchemes = options.svmSchemes ?? defaultSvmSchemes();
78
- const createMiddleware = options.createMiddleware ?? exports.stockPaymentMiddleware;
79
34
  const logger = options.logger ?? console;
80
35
  const refreshIntervalMs = options.refreshIntervalMs ?? DEFAULT_REFRESH_INTERVAL_MS;
81
36
  const retryAfterMs = options.retryAfterMs ?? DEFAULT_RETRY_AFTER_MS;
@@ -115,18 +70,12 @@ function cryptonlyPaymentMiddleware(options) {
115
70
  if (current?.key === key)
116
71
  return false;
117
72
  for (const line of skipped)
118
- logger.warn(`${LOG_PREFIX} skipped ${line}`);
119
- const handler = createMiddleware(routes, {
120
- config,
121
- facilitator,
122
- schemes,
123
- svmSchemes,
124
- ...(options.paywallConfig ? { paywallConfig: options.paywallConfig } : {}),
125
- });
73
+ logger.warn(`${exports.X402_LOG_PREFIX} skipped ${line}`);
74
+ const value = build(routes, config);
126
75
  const previous = current;
127
- current = { key, routes, handler };
76
+ current = { config, routes, key, value };
128
77
  if (previous) {
129
- logger.info(`${LOG_PREFIX} x402 routes updated: ${Object.keys(routes).join(', ') || '(none)'}`);
78
+ logger.info(`${exports.X402_LOG_PREFIX} x402 routes updated: ${Object.keys(routes).join(', ') || '(none)'}`);
130
79
  }
131
80
  return true;
132
81
  }
@@ -145,8 +94,8 @@ function cryptonlyPaymentMiddleware(options) {
145
94
  timer = setInterval(() => {
146
95
  refresh().catch((error) => {
147
96
  logger.warn(current
148
- ? `${LOG_PREFIX} config refresh failed; keeping the last routes: ${describe(error)}`
149
- : `${LOG_PREFIX} config load failed: ${describe(error)}`);
97
+ ? `${exports.X402_LOG_PREFIX} config refresh failed; keeping the last routes: ${describeError(error)}`
98
+ : `${exports.X402_LOG_PREFIX} config load failed: ${describeError(error)}`);
150
99
  });
151
100
  }, refreshIntervalMs);
152
101
  timer.unref?.();
@@ -165,49 +114,98 @@ function cryptonlyPaymentMiddleware(options) {
165
114
  firstLoad = undefined;
166
115
  lastFailureAt = Date.now();
167
116
  lastFailure = error;
168
- logger.error(`${LOG_PREFIX} x402 config unavailable: ${describe(error)}`);
117
+ logger.error(`${exports.X402_LOG_PREFIX} x402 config unavailable: ${describeError(error)}`);
169
118
  throw error;
170
119
  });
171
120
  }
172
121
  return firstLoad;
173
122
  }
174
- const middleware = async (req, res, next) => {
175
- if (!current) {
176
- try {
177
- await ready();
178
- }
179
- catch {
180
- if (!res.headersSent) {
181
- res.setHeader('Retry-After', String(Math.ceil(retryAfterMs / 1000)));
182
- res.status(503).json({
183
- error: 'x402_config_unavailable',
184
- message: 'Payment configuration is unavailable; retry shortly.',
185
- });
186
- }
187
- return;
188
- }
189
- }
190
- await current.handler(req, res, next);
191
- };
192
- return Object.assign(middleware, {
123
+ return {
124
+ facilitator,
125
+ schemes,
126
+ svmSchemes,
127
+ retryAfterMs,
128
+ logger,
129
+ current: () => current,
193
130
  ready,
194
131
  refresh: () => {
195
132
  startRefreshing();
196
133
  return refresh();
197
134
  },
198
- routes: () => current?.routes,
199
135
  close: () => {
200
136
  closed = true;
201
137
  if (timer)
202
138
  clearInterval(timer);
203
139
  timer = undefined;
204
140
  },
205
- });
141
+ };
142
+ }
143
+ /**
144
+ * A fresh `x402ResourceServer` on the facilitator, with the EVM schemes
145
+ * registered on the account's network and the SVM schemes on each of its
146
+ * Solana networks.
147
+ *
148
+ * Build one per route set: `initialize()` on a shared one would clear its
149
+ * facilitator data under requests still in flight.
150
+ */
151
+ function createResourceServer(config, facilitator, schemes, svmSchemes) {
152
+ const server = new server_1.x402ResourceServer(facilitator);
153
+ for (const scheme of schemes) {
154
+ server.register(config.network, scheme);
155
+ }
156
+ for (const network of solanaNetworksOf(config)) {
157
+ for (const scheme of svmSchemes) {
158
+ server.register(network, scheme);
159
+ }
160
+ }
161
+ return server;
162
+ }
163
+ /** The Solana networks an account accepts payments on. */
164
+ function solanaNetworksOf(config) {
165
+ const networks = new Set();
166
+ for (const entry of config.networks ?? []) {
167
+ if ((0, config_js_1.isSolanaNetwork)(entry.network))
168
+ networks.add(entry.network);
169
+ }
170
+ for (const asset of config.assets) {
171
+ if (asset.network && (0, config_js_1.isSolanaNetwork)(asset.network))
172
+ networks.add(asset.network);
173
+ }
174
+ return [...networks];
175
+ }
176
+ let evmModule;
177
+ let svmModule;
178
+ /** `[new ExactEvmScheme()]` from `@x402/evm`. Throws when it is not installed. */
179
+ function defaultEvmSchemes() {
180
+ if (evmModule === undefined) {
181
+ try {
182
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
183
+ evmModule = require('@x402/evm/exact/server');
184
+ }
185
+ catch {
186
+ evmModule = null;
187
+ }
188
+ }
189
+ if (!evmModule) {
190
+ throw new TypeError(`${exports.X402_LOG_PREFIX} @x402/evm is not installed; install it or pass \`schemes\``);
191
+ }
192
+ return [new evmModule.ExactEvmScheme()];
193
+ }
194
+ /** `[new ExactSvmScheme()]` from `@x402/svm` when installed (optional peer), else none. */
195
+ function defaultSvmSchemes() {
196
+ if (svmModule === undefined) {
197
+ try {
198
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
199
+ svmModule = require('@x402/svm/exact/server');
200
+ }
201
+ catch {
202
+ svmModule = null;
203
+ }
204
+ }
205
+ return svmModule ? [new svmModule.ExactSvmScheme()] : [];
206
206
  }
207
- function describe(error) {
207
+ /** An error's message, for log lines. */
208
+ function describeError(error) {
208
209
  return error instanceof Error ? error.message : String(error);
209
210
  }
210
- var config_js_2 = require("./config.js");
211
- Object.defineProperty(exports, "fetchX402Config", { enumerable: true, get: function () { return config_js_2.fetchX402Config; } });
212
- Object.defineProperty(exports, "routesFromConfig", { enumerable: true, get: function () { return config_js_2.routesFromConfig; } });
213
- //# sourceMappingURL=express.js.map
211
+ //# sourceMappingURL=route-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-source.js","sourceRoot":"","sources":["../src/route-source.ts"],"names":[],"mappings":";;;AAuGA,sDA4HC;AAUD,oDAgBC;AAGD,4CASC;AAOD,8CAeC;AAGD,8CAUC;AAGD,sCAEC;AAjTD,8CAA0E;AAE1E,2CAA0F;AAC1F,2CAMqB;AA0ErB,yEAAyE;AAC5D,QAAA,uBAAuB,GAAG;IACrC,KAAK,EAAE,yBAAyB;IAChC,OAAO,EAAE,sDAAsD;CACvD,CAAC;AAEX,mDAAmD;AACtC,QAAA,eAAe,GAAG,mBAAmB,CAAC;AAEnD,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAC3C,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAA+B,EAC/B,KAA6B;IAE7B,MAAM,WAAW,GAAG,IAAI,sCAA0B,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,iBAAiB,EAAE,CAAC;IACvD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,iBAAiB,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC;IACzC,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,2BAA2B,CAAC;IACnF,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,sBAAsB,CAAC;IAEpE,IAAI,OAAoC,CAAC;IACzC,IAAI,QAAsC,CAAC;IAC3C,IAAI,SAAoC,CAAC;IACzC,IAAI,aAAiC,CAAC;IACtC,IAAI,WAAoB,CAAC;IACzB,IAAI,KAAiD,CAAC;IACtD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,KAAK,UAAU,IAAI;QACjB,MAAM,MAAM,GAAG,MAAM,IAAA,2B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AAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cryptonly/x402",
3
- "version": "0.4.0",
4
- "description": "Cryptonly facilitator client and dashboard-configured payment middleware for the x402 protocol.",
3
+ "version": "0.5.0",
4
+ "description": "Cryptonly x402 facilitator client and dashboard price loader. Framework adapters: @cryptonly/x402-express, @cryptonly/x402-fastify, @cryptonly/x402-nestjs.",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "type": "commonjs",
@@ -12,9 +12,9 @@
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/cryptonly-net/x402.git",
15
- "directory": "typescript"
15
+ "directory": "typescript/packages/x402"
16
16
  },
17
- "homepage": "https://github.com/cryptonly-net/x402#readme",
17
+ "homepage": "https://github.com/cryptonly-net/x402/tree/main/typescript/packages/x402#readme",
18
18
  "bugs": {
19
19
  "url": "https://github.com/cryptonly-net/x402/issues"
20
20
  },
@@ -24,9 +24,7 @@
24
24
  "facilitator",
25
25
  "payments",
26
26
  "client",
27
- "typescript",
28
- "express",
29
- "middleware"
27
+ "typescript"
30
28
  ],
31
29
  "main": "./dist/index.js",
32
30
  "types": "./dist/index.d.ts",
@@ -37,30 +35,17 @@
37
35
  "require": "./dist/index.js",
38
36
  "default": "./dist/index.js"
39
37
  },
40
- "./express": {
41
- "types": "./dist/express.d.ts",
42
- "import": "./dist/express.js",
43
- "require": "./dist/express.js",
44
- "default": "./dist/express.js"
45
- },
46
38
  "./package.json": "./package.json"
47
39
  },
48
- "typesVersions": {
49
- "*": {
50
- "express": [
51
- "./dist/express.d.ts"
52
- ]
53
- }
54
- },
55
40
  "files": [
56
41
  "dist"
57
42
  ],
58
43
  "scripts": {
59
44
  "build": "tsc -p tsconfig.build.json",
60
45
  "clean": "rm -rf dist",
61
- "prepare": "npm run build",
62
46
  "prepublishOnly": "npm run build",
63
- "test": "jest"
47
+ "test": "jest",
48
+ "typecheck": "tsc -p tsconfig.json"
64
49
  },
65
50
  "publishConfig": {
66
51
  "access": "public"
@@ -68,40 +53,24 @@
68
53
  "peerDependencies": {
69
54
  "@x402/core": "^2",
70
55
  "@x402/evm": "^2",
71
- "@x402/express": "^2",
72
56
  "@x402/extensions": "^2",
73
- "@x402/svm": "^2",
74
- "express": "^4 || ^5"
57
+ "@x402/svm": "^2"
75
58
  },
76
59
  "peerDependenciesMeta": {
77
60
  "@x402/evm": {
78
61
  "optional": true
79
62
  },
80
- "@x402/express": {
81
- "optional": true
82
- },
83
63
  "@x402/extensions": {
84
64
  "optional": true
85
65
  },
86
- "express": {
87
- "optional": true
88
- },
89
66
  "@x402/svm": {
90
67
  "optional": true
91
68
  }
92
69
  },
93
70
  "devDependencies": {
94
- "@types/express": "^5.0.6",
95
- "@types/jest": "^29.5.14",
96
- "@types/node": "^22.20.5",
97
71
  "@x402/core": "^2.28.0",
98
72
  "@x402/evm": "^2.28.0",
99
- "@x402/express": "^2.28.0",
100
73
  "@x402/extensions": "^2.28.0",
101
- "@x402/svm": "^2.28.0",
102
- "express": "^5.3.0",
103
- "jest": "^29.7.0",
104
- "ts-jest": "^29.2.0",
105
- "typescript": "^5.9.3"
74
+ "@x402/svm": "^2.28.0"
106
75
  }
107
76
  }
package/dist/express.d.ts DELETED
@@ -1,100 +0,0 @@
1
- import type { NextFunction, Request, Response } from 'express';
2
- import type { RoutesConfig } from '@x402/core/server';
3
- import { type PaywallConfig, type SchemeNetworkServer } from '@x402/express';
4
- import { CryptonlyFacilitatorClient, type CryptonlyFacilitatorConfig } from './client.js';
5
- import { type X402Config, type X402ExtensionsModule } from './config.js';
6
- /** An Express middleware. */
7
- export type ExpressMiddleware = (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
8
- /** What {@link InnerMiddlewareFactory} gets besides the routes. */
9
- export type InnerMiddlewareContext = {
10
- config: X402Config;
11
- facilitator: CryptonlyFacilitatorClient;
12
- /** Registered on the account's EVM network. */
13
- schemes: readonly SchemeNetworkServer[];
14
- /** Registered on each Solana network of the account. */
15
- svmSchemes: readonly SchemeNetworkServer[];
16
- paywallConfig?: PaywallConfig;
17
- };
18
- /**
19
- * Builds the payment middleware for one set of routes. The default is the
20
- * stock `paymentMiddleware` from `@x402/express` over a fresh
21
- * `x402ResourceServer`; replace it to add hooks, or in tests.
22
- */
23
- export type InnerMiddlewareFactory = (routes: RoutesConfig, context: InnerMiddlewareContext) => ExpressMiddleware;
24
- /** Logger used for refresh failures and skipped resources. */
25
- export type CryptonlyMiddlewareLogger = Pick<Console, 'info' | 'warn' | 'error'>;
26
- /** Options for {@link cryptonlyPaymentMiddleware}. */
27
- export type CryptonlyPaymentMiddlewareOptions = CryptonlyFacilitatorConfig & {
28
- /**
29
- * How often to reload `GET /x402/config`. Defaults to 60 s; `0` turns
30
- * refreshing off.
31
- */
32
- refreshIntervalMs?: number;
33
- /**
34
- * Scheme servers registered on the account's network. Defaults to
35
- * `[new ExactEvmScheme()]`. Resources with another scheme are skipped.
36
- */
37
- schemes?: readonly SchemeNetworkServer[];
38
- /**
39
- * Scheme servers registered on the account's Solana networks. Defaults
40
- * to `[new ExactSvmScheme()]` from `@x402/svm` when it is installed, and
41
- * to none otherwise (Solana resources are then skipped).
42
- */
43
- svmSchemes?: readonly SchemeNetworkServer[];
44
- /** Passed to the stock `paymentMiddleware` for the browser paywall. */
45
- paywallConfig?: PaywallConfig;
46
- /** `fetch` for `GET /x402/config`. Defaults to the global `fetch`. */
47
- fetch?: typeof fetch;
48
- /**
49
- * After a failed first load, how long requests answer 503 before the
50
- * next attempt. Defaults to 5 s.
51
- */
52
- retryAfterMs?: number;
53
- /** Defaults to `console`. */
54
- logger?: CryptonlyMiddlewareLogger;
55
- /** `@x402/extensions` override; `null` leaves extensions out. */
56
- extensions?: X402ExtensionsModule | null;
57
- /** Builds the inner middleware. See {@link InnerMiddlewareFactory}. */
58
- createMiddleware?: InnerMiddlewareFactory;
59
- };
60
- /** The middleware returned by {@link cryptonlyPaymentMiddleware}. */
61
- export type CryptonlyPaymentMiddleware = ((req: Request, res: Response, next: NextFunction) => Promise<void>) & {
62
- /**
63
- * Loads the configuration now (if not loaded yet) and starts refreshing.
64
- * Rejects when the first load fails. Await it before `listen` to fail
65
- * fast at startup.
66
- */
67
- ready(): Promise<void>;
68
- /** Reloads the configuration now. Resolves `true` when the routes changed. */
69
- refresh(): Promise<boolean>;
70
- /** The routes in use, or `undefined` before the first successful load. */
71
- routes(): RoutesConfig | undefined;
72
- /** Stops refreshing. The last routes stay in use. */
73
- close(): void;
74
- };
75
- /** The default {@link InnerMiddlewareFactory}: stock `@x402/express`. */
76
- export declare const stockPaymentMiddleware: InnerMiddlewareFactory;
77
- /**
78
- * Express middleware whose paid routes and prices come from the Cryptonly
79
- * dashboard (`GET /x402/config`), refreshed every minute, so a price change
80
- * reaches production without a deploy.
81
- *
82
- * - The configuration loads on the first request (or on `ready()`), once.
83
- * - Each refresh rebuilds the stock `@x402/express` middleware only when the
84
- * routes changed. A failed refresh keeps the last good routes.
85
- * - Until a first load succeeds, every request through it answers 503
86
- * (fail closed): paid endpoints are never served for free. Mount it after
87
- * health checks and other free routes.
88
- *
89
- * @example
90
- * ```ts
91
- * import { cryptonlyPaymentMiddleware } from '@cryptonly/x402/express';
92
- *
93
- * app.use(cryptonlyPaymentMiddleware({ apiKey: process.env.CRYPTONLY_API_KEY! }));
94
- * app.get('/weather', (req, res) => res.json({ temperatureC: 21 }));
95
- * ```
96
- */
97
- export declare function cryptonlyPaymentMiddleware(options: CryptonlyPaymentMiddlewareOptions): CryptonlyPaymentMiddleware;
98
- export { fetchX402Config, routesFromConfig } from './config.js';
99
- export type { X402Config } from './config.js';
100
- //# sourceMappingURL=express.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAAA,OAAO,K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