x402z-server 0.0.19 → 0.1.2
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 +110 -20
- package/dist/index.d.mts +101 -14
- package/dist/index.d.ts +101 -14
- package/dist/index.js +423 -67
- package/dist/index.mjs +418 -62
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# x402z-server
|
|
2
2
|
|
|
3
|
-
Server-side helpers for
|
|
3
|
+
Server-side helpers for erc7984-mind-v1 and exact x402 schemes.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -17,7 +17,12 @@ pnpm add x402z-server
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
buildAcceptsFromConfigs,
|
|
22
|
+
buildConfidentialServerConfigFromSchemeConfig,
|
|
23
|
+
createX402zServer,
|
|
24
|
+
} from "x402z-server";
|
|
25
|
+
import { SCHEME_CONFIG } from "x402z-scheme-config";
|
|
21
26
|
import { createRelayer, SepoliaConfig } from "x402z-shared";
|
|
22
27
|
|
|
23
28
|
const relayer = await createRelayer({
|
|
@@ -25,22 +30,32 @@ const relayer = await createRelayer({
|
|
|
25
30
|
network: "https://sepolia.infura.io/v3/...",
|
|
26
31
|
});
|
|
27
32
|
|
|
33
|
+
const allowedPayments = [
|
|
34
|
+
{
|
|
35
|
+
method: "exact.USDC.base",
|
|
36
|
+
payTo: "0xPayTo",
|
|
37
|
+
price: "$0.01",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
method: SCHEME_CONFIG["erc7984-mind-v1"].CONFIDENTIAL_USDC.sepolia,
|
|
41
|
+
payTo: "0xPayTo",
|
|
42
|
+
price: "1.0",
|
|
43
|
+
maxTimeoutSeconds: 300,
|
|
44
|
+
},
|
|
45
|
+
] as const;
|
|
46
|
+
|
|
47
|
+
const confidentialEntry = SCHEME_CONFIG["erc7984-mind-v1"].CONFIDENTIAL_USDC.sepolia;
|
|
48
|
+
|
|
28
49
|
const server = await createX402zServer({
|
|
29
50
|
facilitatorUrl: "http://localhost:8040",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
relayer,
|
|
51
|
+
confidential: buildConfidentialServerConfigFromSchemeConfig({
|
|
52
|
+
config: confidentialEntry,
|
|
53
|
+
signer: { address, signTypedData },
|
|
54
|
+
relayer,
|
|
55
|
+
}),
|
|
36
56
|
routes: {
|
|
37
57
|
"GET /demo": {
|
|
38
|
-
accepts:
|
|
39
|
-
payTo: "0xPayTo",
|
|
40
|
-
price: "1.0",
|
|
41
|
-
network: "eip155:11155111",
|
|
42
|
-
maxTimeoutSeconds: 300,
|
|
43
|
-
},
|
|
58
|
+
accepts: buildAcceptsFromConfigs(allowedPayments),
|
|
44
59
|
description: "Demo content",
|
|
45
60
|
mimeType: "text/plain",
|
|
46
61
|
},
|
|
@@ -57,20 +72,83 @@ server.listen(8080);
|
|
|
57
72
|
|
|
58
73
|
- `createX402zServer(config)`
|
|
59
74
|
- `facilitatorUrl` (required): HTTP facilitator endpoint
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
- `confidential` (optional): confidential scheme config (required if any route uses `erc7984-mind-v1`)
|
|
76
|
+
- `confidential.signer`: signer used to decrypt transfer amounts
|
|
77
|
+
- `confidential.relayer`: FHEVM relayer instance used for decryption
|
|
78
|
+
- `routes`: map of `METHOD /path` to payment requirements
|
|
79
|
+
- `onPaid`: handler for successful payment (returns response body + optional headers)
|
|
65
80
|
|
|
66
81
|
## Examples
|
|
67
82
|
|
|
68
83
|
See `examples/README.md` for the full-process server + facilitator setup.
|
|
69
84
|
|
|
85
|
+
## Exact scheme (ERC20) usage
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { createX402zServer } from "x402z-server";
|
|
89
|
+
|
|
90
|
+
const server = await createX402zServer({
|
|
91
|
+
facilitatorUrl: "http://localhost:8040",
|
|
92
|
+
routes: {
|
|
93
|
+
"GET /erc20-demo": {
|
|
94
|
+
accepts: [
|
|
95
|
+
{
|
|
96
|
+
scheme: "exact",
|
|
97
|
+
payTo: "0xYourAddress",
|
|
98
|
+
price: "$0.01",
|
|
99
|
+
network: "eip155:84532",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
description: "Exact USDC payment demo",
|
|
103
|
+
mimeType: "text/plain",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
onPaid: async () => ({ body: "paid content" }),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
server.listen(8090);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Choosing Payment Methods (Server)
|
|
113
|
+
|
|
114
|
+
Server routes accept an ordered list of payment methods, each paired with its own `payTo` and `price`.
|
|
115
|
+
|
|
116
|
+
You can specify methods in two ways:
|
|
117
|
+
|
|
118
|
+
1) **Name string** (scheme + token + network alias):
|
|
119
|
+
```ts
|
|
120
|
+
const method = "exact.USDC.base";
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
2) **Config entry** (from `SCHEME_CONFIG`):
|
|
124
|
+
```ts
|
|
125
|
+
const method = SCHEME_CONFIG.exact.USDC.base;
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Build your `accepts` array from these entries:
|
|
129
|
+
```ts
|
|
130
|
+
const accepts = buildAcceptsFromConfigs([
|
|
131
|
+
{ method: "exact.USDC.base", payTo, price: "$0.01" },
|
|
132
|
+
{ method: SCHEME_CONFIG["erc7984-mind-v1"].CONFIDENTIAL_USDC.sepolia, payTo, price: "1.0" },
|
|
133
|
+
]);
|
|
134
|
+
```
|
|
135
|
+
|
|
70
136
|
## Notes
|
|
71
137
|
|
|
72
|
-
-
|
|
138
|
+
- Confidential scheme name: `erc7984-mind-v1`
|
|
139
|
+
- Exact scheme name: `exact`
|
|
73
140
|
- `confidential.batcherAddress` is required in requirements; clients bind encrypted inputs to it.
|
|
141
|
+
- Scheme defaults are exported as `SCHEME_CONFIG` from `x402z-scheme-config` (and re-exported by `x402z-server`). Keys are `scheme -> token -> networkAlias` (e.g., `SCHEME_CONFIG.exact.USDC.base`).
|
|
142
|
+
- You can also refer to a method by its string name (e.g., `exact.USDC.base`). A full list is available as `SCHEME_CONFIG_NAMES`.
|
|
143
|
+
|
|
144
|
+
## Choosing Schemes/Networks
|
|
145
|
+
|
|
146
|
+
Select supported methods using `SCHEME_CONFIG` entries in your server code. Pair each entry with its own `payTo` and `price`.
|
|
147
|
+
|
|
148
|
+
## Scheme Naming Guidance
|
|
149
|
+
|
|
150
|
+
- Use a single scheme name when the payment flow is identical and only the asset changes (for example, multiple ERC-20 tokens using the exact same exact-scheme logic).
|
|
151
|
+
- Introduce a new scheme name only when the payment flow differs (for example, different contract method, different typed data, or different authorization logic).
|
|
74
152
|
|
|
75
153
|
## API surface
|
|
76
154
|
|
|
@@ -78,6 +156,12 @@ Exports:
|
|
|
78
156
|
- `X402zEvmServerScheme`: server scheme implementation for erc7984-mind-v1.
|
|
79
157
|
- `registerX402zEvmServerScheme`: registers the scheme with x402 server.
|
|
80
158
|
- `createX402zServer`: helper to configure the paywalled server.
|
|
159
|
+
- `buildExactAccept`, `buildConfidentialAccept`, `buildConfidentialServerConfig`: helpers to construct accept items and confidential config.
|
|
160
|
+
- `buildAcceptsFromConfigs`: build `accepts` from `SCHEME_CONFIG` entries paired with `payTo`/`price`.
|
|
161
|
+
- `SCHEME_CONFIG`: full scheme/token/network config (addresses, network, decimals, EIP-712, batcher). Source of truth lives in `x402z-scheme-config`.
|
|
162
|
+
- `buildConfidentialServerConfigFromSchemeConfig`: build confidential server config from a `SCHEME_CONFIG` entry.
|
|
163
|
+
- `SCHEME_CONFIG_NAMES`: all supported method names as strings (e.g., `exact.USDC.base`).
|
|
164
|
+
- `getSchemeConfigByName`: resolve a method name string to its config entry.
|
|
81
165
|
- `x402ResourceServer`: core x402 resource server.
|
|
82
166
|
- `HTTPFacilitatorClient`: HTTP facilitator client wrapper.
|
|
83
167
|
- `x402HTTPResourceServer`: HTTP resource server helpers.
|
|
@@ -87,8 +171,10 @@ Types:
|
|
|
87
171
|
- `X402zServerNetworkOptions`: network config for the scheme.
|
|
88
172
|
- `X402zServerRegistrationOptions`: registration options for the scheme.
|
|
89
173
|
- `X402zRouteOptions`: route config for paywalled endpoints.
|
|
174
|
+
- `X402zRouteAccept`: accept config item for confidential or exact schemes.
|
|
90
175
|
- `X402zRouteHandler`: handler signature for paid requests.
|
|
91
176
|
- `X402zServerOptions`: options for `createX402zServer`.
|
|
177
|
+
- `X402zConfidentialServerConfig`: options for confidential server config.
|
|
92
178
|
- `CompiledRoute`: compiled route metadata.
|
|
93
179
|
- `DynamicPayTo`: callback for dynamic payee address.
|
|
94
180
|
- `DynamicPrice`: callback for dynamic pricing.
|
|
@@ -110,3 +196,7 @@ Types:
|
|
|
110
196
|
- `UnpaidResponseBody`: unpaid response shape.
|
|
111
197
|
- `UnpaidResponseResult`: unpaid response result.
|
|
112
198
|
- re-exported types from `@x402/core/types`: shared x402 types.
|
|
199
|
+
- `ExactTokenConfig`, `ConfidentialTokenConfig`: resolved token config for exact/confidential schemes.
|
|
200
|
+
- `ExactTokenSymbol`, `ConfidentialTokenSymbol`: allowed token symbols per scheme.
|
|
201
|
+
- `PaymentMethodPricing`: `{ method, payTo, price, maxTimeoutSeconds? }` for `buildAcceptsFromConfigs`.
|
|
202
|
+
- `BuildConfidentialServerConfigFromConfigInput`: input shape for `buildConfidentialServerConfigFromSchemeConfig`.
|
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,14 @@ import { x402ResourceServer } from '@x402/core/server';
|
|
|
4
4
|
export { x402ResourceServer } from '@x402/core/server';
|
|
5
5
|
import * as http from 'http';
|
|
6
6
|
import { RelayerSigner, RelayerInstance } from 'x402z-shared';
|
|
7
|
+
import { ExactTokenConfig, SchemeConfigName, ConfidentialTokenConfig } from 'x402z-scheme-config';
|
|
8
|
+
export { ConfidentialTokenConfig, ConfidentialTokenSymbol, ExactTokenConfig, ExactTokenSymbol, SCHEME_CONFIG, SCHEME_CONFIG_NAMES, SchemeConfig, SchemeConfigName, getSchemeConfigByName, isConfidentialTokenConfig } from 'x402z-scheme-config';
|
|
7
9
|
export { CompiledRoute, DynamicPayTo, DynamicPrice, FacilitatorClient, FacilitatorConfig, HTTPAdapter, HTTPFacilitatorClient, HTTPProcessResult, HTTPRequestContext, HTTPResponseInstructions, PaymentOption, PaywallConfig, PaywallProvider, ProcessSettleFailureResponse, ProcessSettleResultResponse, ProcessSettleSuccessResponse, RouteConfigurationError, RouteValidationError, RoutesConfig, UnpaidResponseBody, UnpaidResponseResult, x402HTTPResourceServer } from '@x402/core/http';
|
|
8
10
|
|
|
9
|
-
type
|
|
11
|
+
type NoScheme$1 = {
|
|
12
|
+
scheme?: never;
|
|
13
|
+
};
|
|
14
|
+
type X402zServerNetworkOptions = NoScheme$1 & {
|
|
10
15
|
asset: `0x${string}`;
|
|
11
16
|
eip712: {
|
|
12
17
|
name: string;
|
|
@@ -39,13 +44,24 @@ type X402zServerRegistrationOptions = X402zServerSchemeOptions & {
|
|
|
39
44
|
};
|
|
40
45
|
declare function registerX402zEvmServerScheme(server: x402ResourceServer, config: X402zServerRegistrationOptions): x402ResourceServer;
|
|
41
46
|
|
|
42
|
-
type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
type X402zRouteAccept = {
|
|
48
|
+
scheme: "erc7984-mind-v1";
|
|
49
|
+
payTo: string;
|
|
50
|
+
price: string;
|
|
51
|
+
network: Network;
|
|
52
|
+
maxTimeoutSeconds: number;
|
|
53
|
+
} | {
|
|
54
|
+
scheme: "exact";
|
|
55
|
+
payTo: string;
|
|
56
|
+
price: Price;
|
|
57
|
+
network: Network;
|
|
58
|
+
maxTimeoutSeconds?: number;
|
|
59
|
+
};
|
|
60
|
+
type NoScheme = {
|
|
61
|
+
scheme?: never;
|
|
62
|
+
};
|
|
63
|
+
type X402zRouteOptions = NoScheme & {
|
|
64
|
+
accepts: X402zRouteAccept[];
|
|
49
65
|
description: string;
|
|
50
66
|
mimeType: string;
|
|
51
67
|
};
|
|
@@ -57,12 +73,8 @@ type X402zRouteHandler = (args: {
|
|
|
57
73
|
headers?: Record<string, string>;
|
|
58
74
|
body: string;
|
|
59
75
|
}>;
|
|
60
|
-
type
|
|
76
|
+
type X402zBaseServerOptions = {
|
|
61
77
|
facilitatorUrl: string;
|
|
62
|
-
routes: Record<string, X402zRouteOptions>;
|
|
63
|
-
onPaid: X402zRouteHandler;
|
|
64
|
-
signer: RelayerSigner;
|
|
65
|
-
relayer: RelayerInstance;
|
|
66
78
|
debug?: boolean;
|
|
67
79
|
cors?: {
|
|
68
80
|
allowOrigin: string;
|
|
@@ -73,6 +85,81 @@ type X402zServerOptions = X402zServerRegistrationOptions & {
|
|
|
73
85
|
maxAgeSeconds?: number;
|
|
74
86
|
};
|
|
75
87
|
};
|
|
88
|
+
type X402zConfidentialServerConfig = {
|
|
89
|
+
getNetworkConfig?: (network: Network) => X402zServerNetworkOptions;
|
|
90
|
+
networks?: Network[];
|
|
91
|
+
asset?: `0x${string}`;
|
|
92
|
+
eip712?: {
|
|
93
|
+
name: string;
|
|
94
|
+
version: string;
|
|
95
|
+
};
|
|
96
|
+
decimals?: number;
|
|
97
|
+
resourceHash?: `0x${string}`;
|
|
98
|
+
batcherAddress?: `0x${string}`;
|
|
99
|
+
signer: RelayerSigner;
|
|
100
|
+
relayer: RelayerInstance;
|
|
101
|
+
} & NoScheme;
|
|
102
|
+
type X402zServerOptions = X402zBaseServerOptions & {
|
|
103
|
+
routes: Record<string, X402zRouteOptions>;
|
|
104
|
+
onPaid: X402zRouteHandler;
|
|
105
|
+
confidential?: X402zConfidentialServerConfig;
|
|
106
|
+
} & NoScheme;
|
|
76
107
|
declare function createX402zServer(config: X402zServerOptions): Promise<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>;
|
|
77
108
|
|
|
78
|
-
|
|
109
|
+
type ExactAcceptInput = {
|
|
110
|
+
network: Network;
|
|
111
|
+
payTo: string;
|
|
112
|
+
price: Price;
|
|
113
|
+
asset: `0x${string}`;
|
|
114
|
+
decimals: number;
|
|
115
|
+
eip712Name: string;
|
|
116
|
+
eip712Version: string;
|
|
117
|
+
maxTimeoutSeconds?: number;
|
|
118
|
+
};
|
|
119
|
+
type ConfidentialAcceptInput = {
|
|
120
|
+
network: Network;
|
|
121
|
+
payTo: string;
|
|
122
|
+
price: string;
|
|
123
|
+
maxTimeoutSeconds?: number;
|
|
124
|
+
};
|
|
125
|
+
type ExactMethodPricing = {
|
|
126
|
+
method: ExactTokenConfig | SchemeConfigName;
|
|
127
|
+
payTo: string;
|
|
128
|
+
price: Price;
|
|
129
|
+
maxTimeoutSeconds?: number;
|
|
130
|
+
};
|
|
131
|
+
type ConfidentialMethodPricing = {
|
|
132
|
+
method: ConfidentialTokenConfig | SchemeConfigName;
|
|
133
|
+
payTo: string;
|
|
134
|
+
price: string;
|
|
135
|
+
maxTimeoutSeconds?: number;
|
|
136
|
+
};
|
|
137
|
+
type PaymentMethodPricing = ExactMethodPricing | ConfidentialMethodPricing;
|
|
138
|
+
type ConfidentialRuntimeInput = {
|
|
139
|
+
signer: X402zConfidentialServerConfig["signer"];
|
|
140
|
+
relayer: X402zConfidentialServerConfig["relayer"];
|
|
141
|
+
resourceHash?: X402zConfidentialServerConfig["resourceHash"];
|
|
142
|
+
};
|
|
143
|
+
type ConfidentialConfigInput = {
|
|
144
|
+
asset: `0x${string}`;
|
|
145
|
+
eip712: {
|
|
146
|
+
name: string;
|
|
147
|
+
version: string;
|
|
148
|
+
};
|
|
149
|
+
decimals: number;
|
|
150
|
+
batcherAddress: `0x${string}`;
|
|
151
|
+
resourceHash?: `0x${string}`;
|
|
152
|
+
};
|
|
153
|
+
type BuildConfidentialServerConfigFromConfigInput = {
|
|
154
|
+
config: ConfidentialTokenConfig | SchemeConfigName | null | undefined;
|
|
155
|
+
signer: X402zConfidentialServerConfig["signer"];
|
|
156
|
+
relayer: X402zConfidentialServerConfig["relayer"];
|
|
157
|
+
resourceHash?: X402zConfidentialServerConfig["resourceHash"];
|
|
158
|
+
};
|
|
159
|
+
declare function buildExactAccept(config: ExactAcceptInput): X402zRouteAccept;
|
|
160
|
+
declare function buildConfidentialAccept(config: ConfidentialAcceptInput): X402zRouteAccept;
|
|
161
|
+
declare function buildAcceptsFromConfigs(methods: PaymentMethodPricing[]): X402zRouteAccept[];
|
|
162
|
+
declare function buildConfidentialServerConfig(config: ConfidentialConfigInput, runtime: ConfidentialRuntimeInput): X402zConfidentialServerConfig;
|
|
163
|
+
declare function buildConfidentialServerConfigFromSchemeConfig(input: BuildConfidentialServerConfigFromConfigInput): X402zConfidentialServerConfig | undefined;
|
|
164
|
+
|
|
165
|
+
export { type BuildConfidentialServerConfigFromConfigInput, type ConfidentialAcceptInput, type ExactAcceptInput, type PaymentMethodPricing, type X402zConfidentialServerConfig, X402zEvmServerScheme, type X402zRouteAccept, type X402zRouteHandler, type X402zRouteOptions, type X402zServerNetworkOptions, type X402zServerOptions, type X402zServerRegistrationOptions, type X402zServerSchemeOptions, buildAcceptsFromConfigs, buildConfidentialAccept, buildConfidentialServerConfig, buildConfidentialServerConfigFromSchemeConfig, buildExactAccept, createX402zServer, registerX402zEvmServerScheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,14 @@ import { x402ResourceServer } from '@x402/core/server';
|
|
|
4
4
|
export { x402ResourceServer } from '@x402/core/server';
|
|
5
5
|
import * as http from 'http';
|
|
6
6
|
import { RelayerSigner, RelayerInstance } from 'x402z-shared';
|
|
7
|
+
import { ExactTokenConfig, SchemeConfigName, ConfidentialTokenConfig } from 'x402z-scheme-config';
|
|
8
|
+
export { ConfidentialTokenConfig, ConfidentialTokenSymbol, ExactTokenConfig, ExactTokenSymbol, SCHEME_CONFIG, SCHEME_CONFIG_NAMES, SchemeConfig, SchemeConfigName, getSchemeConfigByName, isConfidentialTokenConfig } from 'x402z-scheme-config';
|
|
7
9
|
export { CompiledRoute, DynamicPayTo, DynamicPrice, FacilitatorClient, FacilitatorConfig, HTTPAdapter, HTTPFacilitatorClient, HTTPProcessResult, HTTPRequestContext, HTTPResponseInstructions, PaymentOption, PaywallConfig, PaywallProvider, ProcessSettleFailureResponse, ProcessSettleResultResponse, ProcessSettleSuccessResponse, RouteConfigurationError, RouteValidationError, RoutesConfig, UnpaidResponseBody, UnpaidResponseResult, x402HTTPResourceServer } from '@x402/core/http';
|
|
8
10
|
|
|
9
|
-
type
|
|
11
|
+
type NoScheme$1 = {
|
|
12
|
+
scheme?: never;
|
|
13
|
+
};
|
|
14
|
+
type X402zServerNetworkOptions = NoScheme$1 & {
|
|
10
15
|
asset: `0x${string}`;
|
|
11
16
|
eip712: {
|
|
12
17
|
name: string;
|
|
@@ -39,13 +44,24 @@ type X402zServerRegistrationOptions = X402zServerSchemeOptions & {
|
|
|
39
44
|
};
|
|
40
45
|
declare function registerX402zEvmServerScheme(server: x402ResourceServer, config: X402zServerRegistrationOptions): x402ResourceServer;
|
|
41
46
|
|
|
42
|
-
type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
type X402zRouteAccept = {
|
|
48
|
+
scheme: "erc7984-mind-v1";
|
|
49
|
+
payTo: string;
|
|
50
|
+
price: string;
|
|
51
|
+
network: Network;
|
|
52
|
+
maxTimeoutSeconds: number;
|
|
53
|
+
} | {
|
|
54
|
+
scheme: "exact";
|
|
55
|
+
payTo: string;
|
|
56
|
+
price: Price;
|
|
57
|
+
network: Network;
|
|
58
|
+
maxTimeoutSeconds?: number;
|
|
59
|
+
};
|
|
60
|
+
type NoScheme = {
|
|
61
|
+
scheme?: never;
|
|
62
|
+
};
|
|
63
|
+
type X402zRouteOptions = NoScheme & {
|
|
64
|
+
accepts: X402zRouteAccept[];
|
|
49
65
|
description: string;
|
|
50
66
|
mimeType: string;
|
|
51
67
|
};
|
|
@@ -57,12 +73,8 @@ type X402zRouteHandler = (args: {
|
|
|
57
73
|
headers?: Record<string, string>;
|
|
58
74
|
body: string;
|
|
59
75
|
}>;
|
|
60
|
-
type
|
|
76
|
+
type X402zBaseServerOptions = {
|
|
61
77
|
facilitatorUrl: string;
|
|
62
|
-
routes: Record<string, X402zRouteOptions>;
|
|
63
|
-
onPaid: X402zRouteHandler;
|
|
64
|
-
signer: RelayerSigner;
|
|
65
|
-
relayer: RelayerInstance;
|
|
66
78
|
debug?: boolean;
|
|
67
79
|
cors?: {
|
|
68
80
|
allowOrigin: string;
|
|
@@ -73,6 +85,81 @@ type X402zServerOptions = X402zServerRegistrationOptions & {
|
|
|
73
85
|
maxAgeSeconds?: number;
|
|
74
86
|
};
|
|
75
87
|
};
|
|
88
|
+
type X402zConfidentialServerConfig = {
|
|
89
|
+
getNetworkConfig?: (network: Network) => X402zServerNetworkOptions;
|
|
90
|
+
networks?: Network[];
|
|
91
|
+
asset?: `0x${string}`;
|
|
92
|
+
eip712?: {
|
|
93
|
+
name: string;
|
|
94
|
+
version: string;
|
|
95
|
+
};
|
|
96
|
+
decimals?: number;
|
|
97
|
+
resourceHash?: `0x${string}`;
|
|
98
|
+
batcherAddress?: `0x${string}`;
|
|
99
|
+
signer: RelayerSigner;
|
|
100
|
+
relayer: RelayerInstance;
|
|
101
|
+
} & NoScheme;
|
|
102
|
+
type X402zServerOptions = X402zBaseServerOptions & {
|
|
103
|
+
routes: Record<string, X402zRouteOptions>;
|
|
104
|
+
onPaid: X402zRouteHandler;
|
|
105
|
+
confidential?: X402zConfidentialServerConfig;
|
|
106
|
+
} & NoScheme;
|
|
76
107
|
declare function createX402zServer(config: X402zServerOptions): Promise<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>;
|
|
77
108
|
|
|
78
|
-
|
|
109
|
+
type ExactAcceptInput = {
|
|
110
|
+
network: Network;
|
|
111
|
+
payTo: string;
|
|
112
|
+
price: Price;
|
|
113
|
+
asset: `0x${string}`;
|
|
114
|
+
decimals: number;
|
|
115
|
+
eip712Name: string;
|
|
116
|
+
eip712Version: string;
|
|
117
|
+
maxTimeoutSeconds?: number;
|
|
118
|
+
};
|
|
119
|
+
type ConfidentialAcceptInput = {
|
|
120
|
+
network: Network;
|
|
121
|
+
payTo: string;
|
|
122
|
+
price: string;
|
|
123
|
+
maxTimeoutSeconds?: number;
|
|
124
|
+
};
|
|
125
|
+
type ExactMethodPricing = {
|
|
126
|
+
method: ExactTokenConfig | SchemeConfigName;
|
|
127
|
+
payTo: string;
|
|
128
|
+
price: Price;
|
|
129
|
+
maxTimeoutSeconds?: number;
|
|
130
|
+
};
|
|
131
|
+
type ConfidentialMethodPricing = {
|
|
132
|
+
method: ConfidentialTokenConfig | SchemeConfigName;
|
|
133
|
+
payTo: string;
|
|
134
|
+
price: string;
|
|
135
|
+
maxTimeoutSeconds?: number;
|
|
136
|
+
};
|
|
137
|
+
type PaymentMethodPricing = ExactMethodPricing | ConfidentialMethodPricing;
|
|
138
|
+
type ConfidentialRuntimeInput = {
|
|
139
|
+
signer: X402zConfidentialServerConfig["signer"];
|
|
140
|
+
relayer: X402zConfidentialServerConfig["relayer"];
|
|
141
|
+
resourceHash?: X402zConfidentialServerConfig["resourceHash"];
|
|
142
|
+
};
|
|
143
|
+
type ConfidentialConfigInput = {
|
|
144
|
+
asset: `0x${string}`;
|
|
145
|
+
eip712: {
|
|
146
|
+
name: string;
|
|
147
|
+
version: string;
|
|
148
|
+
};
|
|
149
|
+
decimals: number;
|
|
150
|
+
batcherAddress: `0x${string}`;
|
|
151
|
+
resourceHash?: `0x${string}`;
|
|
152
|
+
};
|
|
153
|
+
type BuildConfidentialServerConfigFromConfigInput = {
|
|
154
|
+
config: ConfidentialTokenConfig | SchemeConfigName | null | undefined;
|
|
155
|
+
signer: X402zConfidentialServerConfig["signer"];
|
|
156
|
+
relayer: X402zConfidentialServerConfig["relayer"];
|
|
157
|
+
resourceHash?: X402zConfidentialServerConfig["resourceHash"];
|
|
158
|
+
};
|
|
159
|
+
declare function buildExactAccept(config: ExactAcceptInput): X402zRouteAccept;
|
|
160
|
+
declare function buildConfidentialAccept(config: ConfidentialAcceptInput): X402zRouteAccept;
|
|
161
|
+
declare function buildAcceptsFromConfigs(methods: PaymentMethodPricing[]): X402zRouteAccept[];
|
|
162
|
+
declare function buildConfidentialServerConfig(config: ConfidentialConfigInput, runtime: ConfidentialRuntimeInput): X402zConfidentialServerConfig;
|
|
163
|
+
declare function buildConfidentialServerConfigFromSchemeConfig(input: BuildConfidentialServerConfigFromConfigInput): X402zConfidentialServerConfig | undefined;
|
|
164
|
+
|
|
165
|
+
export { type BuildConfidentialServerConfigFromConfigInput, type ConfidentialAcceptInput, type ExactAcceptInput, type PaymentMethodPricing, type X402zConfidentialServerConfig, X402zEvmServerScheme, type X402zRouteAccept, type X402zRouteHandler, type X402zRouteOptions, type X402zServerNetworkOptions, type X402zServerOptions, type X402zServerRegistrationOptions, type X402zServerSchemeOptions, buildAcceptsFromConfigs, buildConfidentialAccept, buildConfidentialServerConfig, buildConfidentialServerConfigFromSchemeConfig, buildExactAccept, createX402zServer, registerX402zEvmServerScheme };
|