x402-express-mantle 1.0.4 → 1.0.6
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 +2 -2
- package/lib/cjs/index.d.ts +81 -119
- package/lib/esm/index.d.mts +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Complete x402 Express middleware SDK with built-in Mantle testnet support and US
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install x402-express-mantle@1.0.
|
|
17
|
+
npm install x402-express-mantle@1.0.4
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Quick Start
|
|
@@ -144,7 +144,7 @@ This SDK includes custom Mantle configurations:
|
|
|
144
144
|
### Vercel
|
|
145
145
|
|
|
146
146
|
````bash
|
|
147
|
-
npm install x402-express-mantle@1.0.
|
|
147
|
+
npm install x402-express-mantle@1.0.4
|
|
148
148
|
|
|
149
149
|
## Quick Example
|
|
150
150
|
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,111 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
PaywallProvider,
|
|
7
|
-
FacilitatorClient,
|
|
8
|
-
} from "x402-core-mantle/server";
|
|
9
|
-
export {
|
|
10
|
-
PaywallConfig,
|
|
11
|
-
PaywallProvider,
|
|
12
|
-
RouteConfigurationError,
|
|
13
|
-
RouteValidationError,
|
|
14
|
-
x402HTTPResourceServer,
|
|
15
|
-
x402ResourceServer,
|
|
16
|
-
} from "x402-core-mantle/server";
|
|
17
|
-
import { Network, SchemeNetworkServer } from "x402-core-mantle/types";
|
|
18
|
-
export {
|
|
19
|
-
Network,
|
|
20
|
-
PaymentPayload,
|
|
21
|
-
PaymentRequired,
|
|
22
|
-
PaymentRequirements,
|
|
23
|
-
SchemeNetworkServer,
|
|
24
|
-
} from "x402-core-mantle/types";
|
|
25
|
-
import { Request, Response, NextFunction } from "express";
|
|
1
|
+
import { HTTPAdapter, RoutesConfig, x402ResourceServer, PaywallConfig, PaywallProvider, FacilitatorClient } from '@x402/core/server';
|
|
2
|
+
export { PaywallConfig, PaywallProvider, RouteConfigurationError, RouteValidationError, x402HTTPResourceServer, x402ResourceServer } from '@x402/core/server';
|
|
3
|
+
import { Network, SchemeNetworkServer } from '@x402/core/types';
|
|
4
|
+
export { Network, PaymentPayload, PaymentRequired, PaymentRequirements, SchemeNetworkServer } from '@x402/core/types';
|
|
5
|
+
import { Request, Response, NextFunction } from 'express';
|
|
26
6
|
|
|
27
7
|
/**
|
|
28
8
|
* Express adapter implementation
|
|
29
9
|
*/
|
|
30
10
|
declare class ExpressAdapter implements HTTPAdapter {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
11
|
+
private req;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new ExpressAdapter instance.
|
|
14
|
+
*
|
|
15
|
+
* @param req - The Express request object
|
|
16
|
+
*/
|
|
17
|
+
constructor(req: Request);
|
|
18
|
+
/**
|
|
19
|
+
* Gets a header value from the request.
|
|
20
|
+
*
|
|
21
|
+
* @param name - The header name
|
|
22
|
+
* @returns The header value or undefined
|
|
23
|
+
*/
|
|
24
|
+
getHeader(name: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the HTTP method of the request.
|
|
27
|
+
*
|
|
28
|
+
* @returns The HTTP method
|
|
29
|
+
*/
|
|
30
|
+
getMethod(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the path of the request.
|
|
33
|
+
*
|
|
34
|
+
* @returns The request path
|
|
35
|
+
*/
|
|
36
|
+
getPath(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the full URL of the request.
|
|
39
|
+
*
|
|
40
|
+
* @returns The full request URL
|
|
41
|
+
*/
|
|
42
|
+
getUrl(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the Accept header from the request.
|
|
45
|
+
*
|
|
46
|
+
* @returns The Accept header value or empty string
|
|
47
|
+
*/
|
|
48
|
+
getAcceptHeader(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the User-Agent header from the request.
|
|
51
|
+
*
|
|
52
|
+
* @returns The User-Agent header value or empty string
|
|
53
|
+
*/
|
|
54
|
+
getUserAgent(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Gets all query parameters from the request URL.
|
|
57
|
+
*
|
|
58
|
+
* @returns Record of query parameter key-value pairs
|
|
59
|
+
*/
|
|
60
|
+
getQueryParams(): Record<string, string | string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets a specific query parameter by name.
|
|
63
|
+
*
|
|
64
|
+
* @param name - The query parameter name
|
|
65
|
+
* @returns The query parameter value(s) or undefined
|
|
66
|
+
*/
|
|
67
|
+
getQueryParam(name: string): string | string[] | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the parsed request body.
|
|
70
|
+
* Requires express.json() or express.urlencoded() middleware.
|
|
71
|
+
*
|
|
72
|
+
* @returns The parsed request body
|
|
73
|
+
*/
|
|
74
|
+
getBody(): unknown;
|
|
95
75
|
}
|
|
96
76
|
|
|
97
77
|
/**
|
|
98
78
|
* Configuration for registering a payment scheme with a specific network
|
|
99
79
|
*/
|
|
100
80
|
interface SchemeRegistration {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
/**
|
|
82
|
+
* The network identifier (e.g., 'eip155:84532', 'solana:mainnet')
|
|
83
|
+
*/
|
|
84
|
+
network: Network;
|
|
85
|
+
/**
|
|
86
|
+
* The scheme server implementation for this network
|
|
87
|
+
*/
|
|
88
|
+
server: SchemeNetworkServer;
|
|
109
89
|
}
|
|
110
90
|
/**
|
|
111
91
|
* Express payment middleware for x402 protocol (direct server instance).
|
|
@@ -124,7 +104,7 @@ interface SchemeRegistration {
|
|
|
124
104
|
* @example
|
|
125
105
|
* ```typescript
|
|
126
106
|
* import { paymentMiddleware } from "@x402/express";
|
|
127
|
-
* import { x402ResourceServer } from "x402
|
|
107
|
+
* import { x402ResourceServer } from "@x402/core/server";
|
|
128
108
|
* import { registerExactEvmScheme } from "@x402/evm/exact/server";
|
|
129
109
|
*
|
|
130
110
|
* const server = new x402ResourceServer(myFacilitatorClient);
|
|
@@ -133,13 +113,7 @@ interface SchemeRegistration {
|
|
|
133
113
|
* app.use(paymentMiddleware(routes, server, paywallConfig));
|
|
134
114
|
* ```
|
|
135
115
|
*/
|
|
136
|
-
declare function paymentMiddleware(
|
|
137
|
-
routes: RoutesConfig,
|
|
138
|
-
server: x402ResourceServer,
|
|
139
|
-
paywallConfig?: PaywallConfig,
|
|
140
|
-
paywall?: PaywallProvider,
|
|
141
|
-
syncFacilitatorOnStart?: boolean
|
|
142
|
-
): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
116
|
+
declare function paymentMiddleware(routes: RoutesConfig, server: x402ResourceServer, paywallConfig?: PaywallConfig, paywall?: PaywallProvider, syncFacilitatorOnStart?: boolean): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
143
117
|
/**
|
|
144
118
|
* Express payment middleware for x402 protocol (configuration-based).
|
|
145
119
|
*
|
|
@@ -166,18 +140,6 @@ declare function paymentMiddleware(
|
|
|
166
140
|
* ));
|
|
167
141
|
* ```
|
|
168
142
|
*/
|
|
169
|
-
declare function paymentMiddlewareFromConfig(
|
|
170
|
-
routes: RoutesConfig,
|
|
171
|
-
facilitatorClients?: FacilitatorClient | FacilitatorClient[],
|
|
172
|
-
schemes?: SchemeRegistration[],
|
|
173
|
-
paywallConfig?: PaywallConfig,
|
|
174
|
-
paywall?: PaywallProvider,
|
|
175
|
-
syncFacilitatorOnStart?: boolean
|
|
176
|
-
): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
143
|
+
declare function paymentMiddlewareFromConfig(routes: RoutesConfig, facilitatorClients?: FacilitatorClient | FacilitatorClient[], schemes?: SchemeRegistration[], paywallConfig?: PaywallConfig, paywall?: PaywallProvider, syncFacilitatorOnStart?: boolean): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
177
144
|
|
|
178
|
-
export {
|
|
179
|
-
ExpressAdapter,
|
|
180
|
-
type SchemeRegistration,
|
|
181
|
-
paymentMiddleware,
|
|
182
|
-
paymentMiddlewareFromConfig,
|
|
183
|
-
};
|
|
145
|
+
export { ExpressAdapter, type SchemeRegistration, paymentMiddleware, paymentMiddlewareFromConfig };
|
package/lib/esm/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HTTPAdapter, RoutesConfig, x402ResourceServer, PaywallConfig, PaywallProvider, FacilitatorClient } from 'x402
|
|
2
|
-
export { PaywallConfig, PaywallProvider, RouteConfigurationError, RouteValidationError, x402HTTPResourceServer, x402ResourceServer } from 'x402
|
|
3
|
-
import { Network, SchemeNetworkServer } from 'x402
|
|
4
|
-
export { Network, PaymentPayload, PaymentRequired, PaymentRequirements, SchemeNetworkServer } from 'x402
|
|
1
|
+
import { HTTPAdapter, RoutesConfig, x402ResourceServer, PaywallConfig, PaywallProvider, FacilitatorClient } from '@x402/core/server';
|
|
2
|
+
export { PaywallConfig, PaywallProvider, RouteConfigurationError, RouteValidationError, x402HTTPResourceServer, x402ResourceServer } from '@x402/core/server';
|
|
3
|
+
import { Network, SchemeNetworkServer } from '@x402/core/types';
|
|
4
|
+
export { Network, PaymentPayload, PaymentRequired, PaymentRequirements, SchemeNetworkServer } from '@x402/core/types';
|
|
5
5
|
import { Request, Response, NextFunction } from 'express';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -104,7 +104,7 @@ interface SchemeRegistration {
|
|
|
104
104
|
* @example
|
|
105
105
|
* ```typescript
|
|
106
106
|
* import { paymentMiddleware } from "@x402/express";
|
|
107
|
-
* import { x402ResourceServer } from "x402
|
|
107
|
+
* import { x402ResourceServer } from "@x402/core/server";
|
|
108
108
|
* import { registerExactEvmScheme } from "@x402/evm/exact/server";
|
|
109
109
|
*
|
|
110
110
|
* const server = new x402ResourceServer(myFacilitatorClient);
|