@puga-labs/x402-mantle-sdk 0.3.1 → 0.3.3

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 (71) hide show
  1. package/dist/{chunk-HTZ3QFY4.js → chunk-23QNUJIB.js} +4 -3
  2. package/dist/chunk-CXRILT3C.js +68 -0
  3. package/dist/{chunk-CTI5CRDY.js → chunk-E46A7I6B.js} +1 -1
  4. package/dist/{chunk-XAQGMFSR.js → chunk-HEZZ74SI.js} +6 -0
  5. package/dist/chunk-NQWSCY44.js +70 -0
  6. package/dist/chunk-PCJEJYP6.js +68 -0
  7. package/dist/chunk-PPVS3X5Z.js +99 -0
  8. package/dist/chunk-QWQUSRLY.js +99 -0
  9. package/dist/chunk-U73CZU3X.js +237 -0
  10. package/dist/chunk-WO2MYZXT.js +0 -0
  11. package/dist/chunk-ZLCKBFVJ.js +237 -0
  12. package/dist/chunk-ZROK2XOB.js +70 -0
  13. package/dist/client.d.cts +4 -4
  14. package/dist/client.d.ts +4 -4
  15. package/dist/client.js +2 -2
  16. package/dist/{constants-CVFF0ray.d.ts → constants-0ncqvV_O.d.ts} +1 -1
  17. package/dist/{constants-DzCGK0Q3.d.cts → constants-CsIL25uQ.d.cts} +1 -1
  18. package/dist/{createMantleClient-NN0Nitp9.d.cts → createMantleClient-CO0uWPb-.d.cts} +1 -1
  19. package/dist/{createMantleClient-DVFkbBfS.d.ts → createMantleClient-CuiPsTa6.d.ts} +1 -1
  20. package/dist/express-D8EwEcOL.d.ts +66 -0
  21. package/dist/express-eQOPxfnI.d.cts +66 -0
  22. package/dist/index.cjs +186 -109
  23. package/dist/index.d.cts +6 -4
  24. package/dist/index.d.ts +6 -4
  25. package/dist/index.js +6 -4
  26. package/dist/nextjs-Duecps0q.d.cts +45 -0
  27. package/dist/nextjs-TFhFiQuL.d.ts +45 -0
  28. package/dist/react.cjs +3 -2
  29. package/dist/react.d.cts +7 -4
  30. package/dist/react.d.ts +7 -4
  31. package/dist/react.js +3 -3
  32. package/dist/server-express.cjs +368 -0
  33. package/dist/server-express.d.cts +5 -0
  34. package/dist/server-express.d.ts +5 -0
  35. package/dist/server-express.js +13 -0
  36. package/dist/server-nextjs.cjs +339 -0
  37. package/dist/server-nextjs.d.cts +5 -0
  38. package/dist/server-nextjs.d.ts +5 -0
  39. package/dist/server-nextjs.js +11 -0
  40. package/dist/server-web.cjs +339 -0
  41. package/dist/server-web.d.cts +4 -0
  42. package/dist/server-web.d.ts +4 -0
  43. package/dist/server-web.js +11 -0
  44. package/dist/server.cjs +316 -111
  45. package/dist/server.d.cts +67 -104
  46. package/dist/server.d.ts +67 -104
  47. package/dist/server.js +29 -5
  48. package/dist/{types-2zqbJvcz.d.cts → types-BFUqKBBO.d.cts} +1 -1
  49. package/dist/{types-2zqbJvcz.d.ts → types-BFUqKBBO.d.ts} +1 -1
  50. package/dist/types-CoOdbZSp.d.cts +97 -0
  51. package/dist/types-CqQ6OgRi.d.ts +85 -0
  52. package/dist/types-CrOsOHcX.d.cts +85 -0
  53. package/dist/types-DTzov_EE.d.ts +97 -0
  54. package/dist/web-standards-BNQyWzBC.d.cts +77 -0
  55. package/dist/web-standards-D8j1kZxd.d.ts +77 -0
  56. package/package.json +49 -2
  57. package/dist/chunk-DA6ZBXNO.js +0 -275
  58. package/dist/chunk-FD4HG7KR.js +0 -135
  59. package/dist/chunk-GWVWPS3R.js +0 -277
  60. package/dist/chunk-MQALBRGV.js +0 -135
  61. package/dist/chunk-PYIYE3HI.js +0 -135
  62. package/dist/chunk-Q6SPMEIW.js +0 -235
  63. package/dist/chunk-RNKXSBT7.js +0 -135
  64. package/dist/chunk-SPCXFN7C.js +0 -284
  65. package/dist/chunk-T5DRYLNB.js +0 -135
  66. package/dist/chunk-TSEE5NSJ.js +0 -297
  67. package/dist/chunk-WELDWRDX.js +0 -307
  68. package/dist/constants-C7aY8u5b.d.cts +0 -77
  69. package/dist/constants-C7aY8u5b.d.ts +0 -77
  70. package/dist/createMantleClient-DS1Ghqrz.d.cts +0 -51
  71. package/dist/createMantleClient-DS1Ghqrz.d.ts +0 -51
@@ -0,0 +1,237 @@
1
+ import {
2
+ getDefaultAssetForNetwork
3
+ } from "./chunk-HEZZ74SI.js";
4
+
5
+ // src/server/core/utils.ts
6
+ function validateAddress(address, paramName = "address") {
7
+ if (!address) {
8
+ throw new Error(`${paramName} is required`);
9
+ }
10
+ if (typeof address !== "string") {
11
+ throw new Error(`${paramName} must be a string, got ${typeof address}`);
12
+ }
13
+ if (!address.startsWith("0x")) {
14
+ const preview = address.length > 10 ? `${address.substring(0, 10)}...` : address;
15
+ throw new Error(
16
+ `${paramName} must start with "0x", got: ${preview}`
17
+ );
18
+ }
19
+ if (address.length !== 42) {
20
+ throw new Error(
21
+ `${paramName} must be 42 characters (0x + 40 hex), got ${address.length} characters`
22
+ );
23
+ }
24
+ const hexPart = address.slice(2);
25
+ if (!/^[0-9a-fA-F]{40}$/.test(hexPart)) {
26
+ throw new Error(
27
+ `${paramName} must contain only hexadecimal characters (0-9, a-f, A-F) after "0x"`
28
+ );
29
+ }
30
+ }
31
+ function decodePaymentHeader(paymentHeaderBase64) {
32
+ try {
33
+ if (typeof Buffer !== "undefined") {
34
+ const json = Buffer.from(paymentHeaderBase64, "base64").toString("utf8");
35
+ return JSON.parse(json);
36
+ }
37
+ if (typeof atob === "function") {
38
+ const json = atob(paymentHeaderBase64);
39
+ return JSON.parse(json);
40
+ }
41
+ throw new Error("No base64 decoding available in this environment");
42
+ } catch (err) {
43
+ const msg = err instanceof Error ? err.message : "Unknown error";
44
+ throw new Error(`Failed to decode paymentHeader: ${msg}`);
45
+ }
46
+ }
47
+ function buildRouteKey(method, path) {
48
+ const normalizedMethod = (method || "GET").toUpperCase();
49
+ const normalizedPath = path || "/";
50
+ return `${normalizedMethod} ${normalizedPath}`;
51
+ }
52
+
53
+ // src/server/constants.ts
54
+ var DEFAULT_TELEMETRY_ENDPOINT = void 0;
55
+
56
+ // src/server/telemetry.ts
57
+ function createTelemetryEvent(entry, config) {
58
+ const assetConfig = getDefaultAssetForNetwork(entry.network);
59
+ return {
60
+ event: "payment_verified",
61
+ ts: entry.timestamp,
62
+ projectKey: config.projectKey,
63
+ network: entry.network,
64
+ buyer: entry.from,
65
+ payTo: entry.to,
66
+ amountAtomic: entry.valueAtomic,
67
+ asset: entry.asset,
68
+ decimals: assetConfig.decimals,
69
+ nonce: entry.id,
70
+ route: entry.route ?? "unknown",
71
+ // Facilitator metadata
72
+ facilitatorType: "hosted",
73
+ // SDK always uses hosted mode
74
+ facilitatorUrl: entry.facilitatorUrl,
75
+ // From PaymentLogEntry
76
+ // facilitatorAddress is undefined for SDK (not available)
77
+ // Optional metadata
78
+ txHash: entry.txHash,
79
+ priceUsd: entry.paymentRequirements?.price
80
+ };
81
+ }
82
+ async function sendTelemetry(event, endpoint) {
83
+ const targetEndpoint = endpoint ?? DEFAULT_TELEMETRY_ENDPOINT;
84
+ if (!targetEndpoint) {
85
+ return;
86
+ }
87
+ try {
88
+ const response = await fetch(targetEndpoint, {
89
+ method: "POST",
90
+ headers: {
91
+ "Content-Type": "application/json",
92
+ "Authorization": `Bearer ${event.projectKey}`
93
+ },
94
+ body: JSON.stringify(event)
95
+ });
96
+ if (!response.ok) {
97
+ console.warn(
98
+ `[x402-telemetry] Failed to send event: HTTP ${response.status}`
99
+ );
100
+ }
101
+ } catch (err) {
102
+ console.error("[x402-telemetry] Error sending telemetry:", err);
103
+ }
104
+ }
105
+
106
+ // src/server/core/verifyPayment.ts
107
+ async function checkPayment(input) {
108
+ const {
109
+ paymentHeader,
110
+ paymentRequirements,
111
+ facilitatorUrl,
112
+ routeKey,
113
+ network,
114
+ asset,
115
+ telemetry,
116
+ onPaymentSettled
117
+ } = input;
118
+ if (!paymentHeader || paymentHeader.trim() === "") {
119
+ return {
120
+ status: "require_payment",
121
+ statusCode: 402,
122
+ responseBody: {
123
+ error: "Payment Required",
124
+ paymentRequirements,
125
+ paymentHeader: null
126
+ },
127
+ isValid: false
128
+ };
129
+ }
130
+ try {
131
+ const verifyUrl = `${facilitatorUrl.replace(/\/+$/, "")}/verify`;
132
+ const verifyRes = await fetch(verifyUrl, {
133
+ method: "POST",
134
+ headers: {
135
+ "Content-Type": "application/json"
136
+ },
137
+ body: JSON.stringify({
138
+ x402Version: 1,
139
+ paymentHeader,
140
+ paymentRequirements
141
+ })
142
+ });
143
+ if (!verifyRes.ok) {
144
+ const text = await verifyRes.text().catch(() => "");
145
+ console.error(
146
+ "[x402-mantle-sdk] Facilitator /verify returned non-OK:",
147
+ verifyRes.status,
148
+ text
149
+ );
150
+ return {
151
+ status: "verification_error",
152
+ statusCode: 500,
153
+ responseBody: {
154
+ error: "Payment verification error",
155
+ details: `Facilitator responded with HTTP ${verifyRes.status}`
156
+ },
157
+ isValid: false
158
+ };
159
+ }
160
+ const verifyJson = await verifyRes.json();
161
+ if (!verifyJson.isValid) {
162
+ return {
163
+ status: "invalid_payment",
164
+ statusCode: 402,
165
+ responseBody: {
166
+ error: "Payment verification failed",
167
+ invalidReason: verifyJson.invalidReason ?? null,
168
+ paymentRequirements,
169
+ paymentHeader: null
170
+ },
171
+ isValid: false
172
+ };
173
+ }
174
+ if (onPaymentSettled) {
175
+ try {
176
+ const headerObj = decodePaymentHeader(paymentHeader);
177
+ const { authorization } = headerObj.payload;
178
+ const assetConfig = getDefaultAssetForNetwork(network);
179
+ const logEntry = {
180
+ id: authorization.nonce,
181
+ from: authorization.from,
182
+ to: authorization.to,
183
+ valueAtomic: authorization.value,
184
+ network,
185
+ asset,
186
+ route: routeKey,
187
+ timestamp: Date.now(),
188
+ facilitatorUrl,
189
+ paymentRequirements
190
+ };
191
+ onPaymentSettled(logEntry);
192
+ if (telemetry) {
193
+ const event = createTelemetryEvent(logEntry, telemetry);
194
+ sendTelemetry(event, telemetry.endpoint).catch(
195
+ (err) => console.error("[x402-telemetry] Async send failed:", err)
196
+ );
197
+ }
198
+ } catch (err) {
199
+ console.error(
200
+ "[x402-mantle-sdk] Error calling onPaymentSettled hook:",
201
+ err
202
+ );
203
+ }
204
+ }
205
+ return {
206
+ status: "verified",
207
+ statusCode: 200,
208
+ responseBody: null,
209
+ isValid: true
210
+ };
211
+ } catch (err) {
212
+ console.error(
213
+ "[x402-mantle-sdk] Error while calling facilitator /verify:",
214
+ err
215
+ );
216
+ const message = err instanceof Error ? err.message : "Unknown verification error";
217
+ return {
218
+ status: "verification_error",
219
+ statusCode: 500,
220
+ responseBody: {
221
+ error: "Payment verification error",
222
+ details: message
223
+ },
224
+ isValid: false
225
+ };
226
+ }
227
+ }
228
+
229
+ export {
230
+ validateAddress,
231
+ decodePaymentHeader,
232
+ buildRouteKey,
233
+ DEFAULT_TELEMETRY_ENDPOINT,
234
+ createTelemetryEvent,
235
+ sendTelemetry,
236
+ checkPayment
237
+ };
@@ -0,0 +1,70 @@
1
+ import {
2
+ buildRouteKey,
3
+ checkPayment,
4
+ validateAddress
5
+ } from "./chunk-ZLCKBFVJ.js";
6
+ import {
7
+ MANTLE_DEFAULTS,
8
+ __export,
9
+ getDefaultAssetForNetwork,
10
+ usdCentsToAtomic
11
+ } from "./chunk-HEZZ74SI.js";
12
+
13
+ // src/server/adapters/web-standards.ts
14
+ var web_standards_exports = {};
15
+ __export(web_standards_exports, {
16
+ mantlePaywall: () => mantlePaywall
17
+ });
18
+ function mantlePaywall(opts) {
19
+ const { priceUsd, payTo, facilitatorUrl, telemetry, onPaymentSettled } = opts;
20
+ validateAddress(payTo, "payTo");
21
+ const priceUsdCents = Math.round(priceUsd * 100);
22
+ return function(handler) {
23
+ return async (request) => {
24
+ const url = new URL(request.url);
25
+ const method = request.method;
26
+ const path = url.pathname;
27
+ const routeKey = buildRouteKey(method, path);
28
+ const network = MANTLE_DEFAULTS.NETWORK;
29
+ const assetConfig = getDefaultAssetForNetwork(network);
30
+ const maxAmountRequiredBigInt = usdCentsToAtomic(
31
+ priceUsdCents,
32
+ assetConfig.decimals
33
+ );
34
+ const paymentRequirements = {
35
+ scheme: "exact",
36
+ network,
37
+ asset: assetConfig.address,
38
+ maxAmountRequired: maxAmountRequiredBigInt.toString(),
39
+ payTo,
40
+ price: `$${(priceUsdCents / 100).toFixed(2)}`,
41
+ currency: "USD"
42
+ };
43
+ const paymentHeader = request.headers.get("X-PAYMENT") || request.headers.get("x-payment") || null;
44
+ const result = await checkPayment({
45
+ paymentHeader,
46
+ paymentRequirements,
47
+ facilitatorUrl: facilitatorUrl || MANTLE_DEFAULTS.FACILITATOR_URL,
48
+ routeKey,
49
+ network,
50
+ asset: assetConfig.address,
51
+ telemetry,
52
+ onPaymentSettled
53
+ });
54
+ if (!result.isValid) {
55
+ return new Response(JSON.stringify(result.responseBody), {
56
+ status: result.statusCode,
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ }
60
+ });
61
+ }
62
+ return handler(request);
63
+ };
64
+ };
65
+ }
66
+
67
+ export {
68
+ mantlePaywall,
69
+ web_standards_exports
70
+ };
package/dist/client.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as PaymentClientConfig, b as PaymentClient } from './createMantleClient-NN0Nitp9.cjs';
2
- export { C as CallWithPaymentResult, M as MantleClient, a as MantleClientConfig, c as createMantleClient } from './createMantleClient-NN0Nitp9.cjs';
3
- export { A as AssetConfig, a as Authorization, E as EIP1193Provider, N as NetworkId, d as PaymentHeaderBase64, c as PaymentHeaderObject, b as PaymentHeaderPayload, P as PaymentRequirements } from './types-2zqbJvcz.cjs';
4
- export { M as MANTLE_DEFAULTS } from './constants-DzCGK0Q3.cjs';
1
+ import { P as PaymentClientConfig, b as PaymentClient } from './createMantleClient-CO0uWPb-.cjs';
2
+ export { C as CallWithPaymentResult, M as MantleClient, a as MantleClientConfig, c as createMantleClient } from './createMantleClient-CO0uWPb-.cjs';
3
+ export { A as AssetConfig, a as Authorization, E as EIP1193Provider, N as NetworkId, d as PaymentHeaderBase64, c as PaymentHeaderObject, b as PaymentHeaderPayload, P as PaymentRequirements } from './types-BFUqKBBO.cjs';
4
+ export { M as MANTLE_DEFAULTS } from './constants-CsIL25uQ.cjs';
5
5
 
6
6
  /**
7
7
  * Creates a high-level payment client that:
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as PaymentClientConfig, b as PaymentClient } from './createMantleClient-DVFkbBfS.js';
2
- export { C as CallWithPaymentResult, M as MantleClient, a as MantleClientConfig, c as createMantleClient } from './createMantleClient-DVFkbBfS.js';
3
- export { A as AssetConfig, a as Authorization, E as EIP1193Provider, N as NetworkId, d as PaymentHeaderBase64, c as PaymentHeaderObject, b as PaymentHeaderPayload, P as PaymentRequirements } from './types-2zqbJvcz.js';
4
- export { M as MANTLE_DEFAULTS } from './constants-CVFF0ray.js';
1
+ import { P as PaymentClientConfig, b as PaymentClient } from './createMantleClient-CuiPsTa6.js';
2
+ export { C as CallWithPaymentResult, M as MantleClient, a as MantleClientConfig, c as createMantleClient } from './createMantleClient-CuiPsTa6.js';
3
+ export { A as AssetConfig, a as Authorization, E as EIP1193Provider, N as NetworkId, d as PaymentHeaderBase64, c as PaymentHeaderObject, b as PaymentHeaderPayload, P as PaymentRequirements } from './types-BFUqKBBO.js';
4
+ export { M as MANTLE_DEFAULTS } from './constants-0ncqvV_O.js';
5
5
 
6
6
  /**
7
7
  * Creates a high-level payment client that:
package/dist/client.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createMantleClient,
3
3
  createPaymentClient
4
- } from "./chunk-CTI5CRDY.js";
4
+ } from "./chunk-E46A7I6B.js";
5
5
  import {
6
6
  MANTLE_DEFAULTS
7
- } from "./chunk-XAQGMFSR.js";
7
+ } from "./chunk-HEZZ74SI.js";
8
8
  export {
9
9
  MANTLE_DEFAULTS,
10
10
  createMantleClient,
@@ -1,4 +1,4 @@
1
- import './types-2zqbJvcz.js';
1
+ import './types-BFUqKBBO.js';
2
2
 
3
3
  /**
4
4
  * Default values for Mantle mainnet x402 payments.
@@ -1,4 +1,4 @@
1
- import './types-2zqbJvcz.cjs';
1
+ import './types-BFUqKBBO.cjs';
2
2
 
3
3
  /**
4
4
  * Default values for Mantle mainnet x402 payments.
@@ -1,4 +1,4 @@
1
- import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-2zqbJvcz.cjs';
1
+ import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-BFUqKBBO.cjs';
2
2
 
3
3
  /** Config for the client-side payment helper. */
4
4
  interface PaymentClientConfig {
@@ -1,4 +1,4 @@
1
- import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-2zqbJvcz.js';
1
+ import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-BFUqKBBO.js';
2
2
 
3
3
  /** Config for the client-side payment helper. */
4
4
  interface PaymentClientConfig {
@@ -0,0 +1,66 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { b as RoutesConfig, M as MinimalPaywallOptions } from './types-CqQ6OgRi.js';
3
+
4
+ /**
5
+ * Express middleware function type for Mantle paywall.
6
+ */
7
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
8
+ /** Config for createPaymentMiddleware. */
9
+ interface PaymentMiddlewareConfig {
10
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
11
+ facilitatorUrl: string;
12
+ /** Recipient address (developer). Validated at runtime. */
13
+ receiverAddress: string;
14
+ /** Map of protected routes and their pricing. */
15
+ routes: RoutesConfig;
16
+ /**
17
+ * Optional hook called whenever a payment is successfully settled.
18
+ */
19
+ onPaymentSettled?: MinimalPaywallOptions["onPaymentSettled"];
20
+ /** Optional: Send usage telemetry for billing/analytics. */
21
+ telemetry?: MinimalPaywallOptions["telemetry"];
22
+ }
23
+ /**
24
+ * Create Express middleware for x402 payment verification on multiple routes.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const middleware = createPaymentMiddleware({
29
+ * facilitatorUrl: 'https://facilitator.nosubs.ai',
30
+ * receiverAddress: '0x...',
31
+ * routes: {
32
+ * 'POST /api/generate': { priceUsdCents: 1, network: 'mantle-mainnet' },
33
+ * 'GET /api/data': { priceUsdCents: 5, network: 'mantle-mainnet' },
34
+ * }
35
+ * });
36
+ *
37
+ * app.use(middleware);
38
+ * ```
39
+ */
40
+ declare function createPaymentMiddleware(config: PaymentMiddlewareConfig): MantleMiddleware;
41
+ /**
42
+ * Simplified wrapper for protecting a single route with x402 payments.
43
+ * Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const pay = mantlePaywall({ priceUsd: 0.01, payTo: "0x..." });
48
+ * app.post('/api/generate', pay, async (req, res) => {
49
+ * // Your handler code here
50
+ * });
51
+ * ```
52
+ *
53
+ * @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
54
+ * @returns Express middleware function for single-route protection.
55
+ */
56
+ declare function mantlePaywall(opts: MinimalPaywallOptions): MantleMiddleware;
57
+
58
+ type express_MantleMiddleware = MantleMiddleware;
59
+ type express_PaymentMiddlewareConfig = PaymentMiddlewareConfig;
60
+ declare const express_createPaymentMiddleware: typeof createPaymentMiddleware;
61
+ declare const express_mantlePaywall: typeof mantlePaywall;
62
+ declare namespace express {
63
+ export { type express_MantleMiddleware as MantleMiddleware, type express_PaymentMiddlewareConfig as PaymentMiddlewareConfig, express_createPaymentMiddleware as createPaymentMiddleware, express_mantlePaywall as mantlePaywall };
64
+ }
65
+
66
+ export { type MantleMiddleware as M, type PaymentMiddlewareConfig as P, createPaymentMiddleware as c, express as e, mantlePaywall as m };
@@ -0,0 +1,66 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { b as RoutesConfig, M as MinimalPaywallOptions } from './types-CrOsOHcX.cjs';
3
+
4
+ /**
5
+ * Express middleware function type for Mantle paywall.
6
+ */
7
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
8
+ /** Config for createPaymentMiddleware. */
9
+ interface PaymentMiddlewareConfig {
10
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
11
+ facilitatorUrl: string;
12
+ /** Recipient address (developer). Validated at runtime. */
13
+ receiverAddress: string;
14
+ /** Map of protected routes and their pricing. */
15
+ routes: RoutesConfig;
16
+ /**
17
+ * Optional hook called whenever a payment is successfully settled.
18
+ */
19
+ onPaymentSettled?: MinimalPaywallOptions["onPaymentSettled"];
20
+ /** Optional: Send usage telemetry for billing/analytics. */
21
+ telemetry?: MinimalPaywallOptions["telemetry"];
22
+ }
23
+ /**
24
+ * Create Express middleware for x402 payment verification on multiple routes.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const middleware = createPaymentMiddleware({
29
+ * facilitatorUrl: 'https://facilitator.nosubs.ai',
30
+ * receiverAddress: '0x...',
31
+ * routes: {
32
+ * 'POST /api/generate': { priceUsdCents: 1, network: 'mantle-mainnet' },
33
+ * 'GET /api/data': { priceUsdCents: 5, network: 'mantle-mainnet' },
34
+ * }
35
+ * });
36
+ *
37
+ * app.use(middleware);
38
+ * ```
39
+ */
40
+ declare function createPaymentMiddleware(config: PaymentMiddlewareConfig): MantleMiddleware;
41
+ /**
42
+ * Simplified wrapper for protecting a single route with x402 payments.
43
+ * Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const pay = mantlePaywall({ priceUsd: 0.01, payTo: "0x..." });
48
+ * app.post('/api/generate', pay, async (req, res) => {
49
+ * // Your handler code here
50
+ * });
51
+ * ```
52
+ *
53
+ * @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
54
+ * @returns Express middleware function for single-route protection.
55
+ */
56
+ declare function mantlePaywall(opts: MinimalPaywallOptions): MantleMiddleware;
57
+
58
+ type express_MantleMiddleware = MantleMiddleware;
59
+ type express_PaymentMiddlewareConfig = PaymentMiddlewareConfig;
60
+ declare const express_createPaymentMiddleware: typeof createPaymentMiddleware;
61
+ declare const express_mantlePaywall: typeof mantlePaywall;
62
+ declare namespace express {
63
+ export { type express_MantleMiddleware as MantleMiddleware, type express_PaymentMiddlewareConfig as PaymentMiddlewareConfig, express_createPaymentMiddleware as createPaymentMiddleware, express_mantlePaywall as mantlePaywall };
64
+ }
65
+
66
+ export { type MantleMiddleware as M, type PaymentMiddlewareConfig as P, createPaymentMiddleware as c, express as e, mantlePaywall as m };