@puga-labs/x402-mantle-sdk 0.2.1 → 0.3.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.
Files changed (95) hide show
  1. package/dist/chunk-23QNUJIB.js +136 -0
  2. package/dist/chunk-6GLR5EBK.js +96 -0
  3. package/dist/chunk-BRGW36P7.js +211 -0
  4. package/dist/chunk-CTI5CRDY.js +274 -0
  5. package/dist/chunk-DA6ZBXNO.js +275 -0
  6. package/dist/chunk-E46A7I6B.js +274 -0
  7. package/dist/chunk-FD4HG7KR.js +135 -0
  8. package/dist/chunk-FHU6CFHF.js +0 -0
  9. package/dist/chunk-GHUWTX7J.js +66 -0
  10. package/dist/chunk-GWVWPS3R.js +277 -0
  11. package/dist/chunk-HEZZ74SI.js +62 -0
  12. package/dist/chunk-HTZ3QFY4.js +135 -0
  13. package/dist/chunk-MQALBRGV.js +135 -0
  14. package/dist/chunk-NQWSCY44.js +70 -0
  15. package/dist/chunk-PCJEJYP6.js +68 -0
  16. package/dist/chunk-PPVS3X5Z.js +99 -0
  17. package/dist/chunk-PYIYE3HI.js +135 -0
  18. package/dist/chunk-Q6SPMEIW.js +235 -0
  19. package/dist/chunk-RNKXSBT7.js +135 -0
  20. package/dist/chunk-SPCXFN7C.js +284 -0
  21. package/dist/chunk-T5DRYLNB.js +135 -0
  22. package/dist/chunk-TSEE5NSJ.js +297 -0
  23. package/dist/chunk-U73CZU3X.js +237 -0
  24. package/dist/chunk-WAKJRVUP.js +135 -0
  25. package/dist/chunk-WELDWRDX.js +307 -0
  26. package/dist/chunk-WFUDGBKK.js +68 -0
  27. package/dist/chunk-WO2MYZXT.js +0 -0
  28. package/dist/chunk-XAQGMFSR.js +56 -0
  29. package/dist/client.cjs +328 -0
  30. package/dist/client.d.cts +17 -0
  31. package/dist/client.d.ts +17 -0
  32. package/dist/client.js +12 -0
  33. package/dist/constants-0ncqvV_O.d.ts +17 -0
  34. package/dist/constants-C7aY8u5b.d.cts +77 -0
  35. package/dist/constants-C7aY8u5b.d.ts +77 -0
  36. package/dist/constants-CVFF0ray.d.ts +17 -0
  37. package/dist/constants-CsIL25uQ.d.cts +17 -0
  38. package/dist/constants-DzCGK0Q3.d.cts +17 -0
  39. package/dist/createMantleClient-CO0uWPb-.d.cts +87 -0
  40. package/dist/createMantleClient-CuiPsTa6.d.ts +87 -0
  41. package/dist/createMantleClient-DS1Ghqrz.d.cts +51 -0
  42. package/dist/createMantleClient-DS1Ghqrz.d.ts +51 -0
  43. package/dist/createMantleClient-DVFkbBfS.d.ts +87 -0
  44. package/dist/createMantleClient-NN0Nitp9.d.cts +87 -0
  45. package/dist/express-Ck7eryef.d.cts +66 -0
  46. package/dist/express-CmEg5hR3.d.ts +66 -0
  47. package/dist/express-D8EwEcOL.d.ts +66 -0
  48. package/dist/express-eQOPxfnI.d.cts +66 -0
  49. package/dist/index.cjs +342 -155
  50. package/dist/index.d.cts +10 -290
  51. package/dist/index.d.ts +10 -290
  52. package/dist/index.js +18 -567
  53. package/dist/nextjs-Bp8DxYDN.d.ts +45 -0
  54. package/dist/nextjs-CliiaTPe.d.cts +45 -0
  55. package/dist/nextjs-D7t-BC4N.d.ts +45 -0
  56. package/dist/nextjs-Duecps0q.d.cts +45 -0
  57. package/dist/nextjs-TFhFiQuL.d.ts +45 -0
  58. package/dist/nextjs-ZO2J9mdo.d.cts +45 -0
  59. package/dist/react.cjs +454 -0
  60. package/dist/react.d.cts +93 -0
  61. package/dist/react.d.ts +93 -0
  62. package/dist/react.js +10 -0
  63. package/dist/server-express.cjs +368 -0
  64. package/dist/server-express.d.cts +5 -0
  65. package/dist/server-express.d.ts +5 -0
  66. package/dist/server-express.js +13 -0
  67. package/dist/server-nextjs.cjs +339 -0
  68. package/dist/server-nextjs.d.cts +5 -0
  69. package/dist/server-nextjs.d.ts +5 -0
  70. package/dist/server-nextjs.js +11 -0
  71. package/dist/server-web.cjs +339 -0
  72. package/dist/server-web.d.cts +4 -0
  73. package/dist/server-web.d.ts +4 -0
  74. package/dist/server-web.js +11 -0
  75. package/dist/server.cjs +497 -0
  76. package/dist/server.d.cts +79 -0
  77. package/dist/server.d.ts +79 -0
  78. package/dist/server.js +36 -0
  79. package/dist/types-2zqbJvcz.d.cts +63 -0
  80. package/dist/types-2zqbJvcz.d.ts +63 -0
  81. package/dist/types-BFUqKBBO.d.cts +63 -0
  82. package/dist/types-BFUqKBBO.d.ts +63 -0
  83. package/dist/types-C7EPJ6Hd.d.ts +85 -0
  84. package/dist/types-CEttmr1U.d.cts +97 -0
  85. package/dist/types-CoOdbZSp.d.cts +97 -0
  86. package/dist/types-CqQ6OgRi.d.ts +85 -0
  87. package/dist/types-CrOsOHcX.d.cts +85 -0
  88. package/dist/types-D20K36pc.d.ts +97 -0
  89. package/dist/types-DTzov_EE.d.ts +97 -0
  90. package/dist/types-xkNm0uzE.d.cts +85 -0
  91. package/dist/web-standards-BNQyWzBC.d.cts +77 -0
  92. package/dist/web-standards-C3D2vdTg.d.ts +77 -0
  93. package/dist/web-standards-D8j1kZxd.d.ts +77 -0
  94. package/dist/web-standards-DOYp0UDT.d.cts +77 -0
  95. package/package.json +80 -8
@@ -0,0 +1,87 @@
1
+ import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-BFUqKBBO.js';
2
+
3
+ /** Config for the client-side payment helper. */
4
+ interface PaymentClientConfig {
5
+ /** Base URL of your protected resource server. */
6
+ resourceUrl: string;
7
+ /** Facilitator URL (hosted or self-hosted). */
8
+ facilitatorUrl: string;
9
+ /** EIP-1193 provider (window.ethereum) or similar. */
10
+ provider: unknown;
11
+ /** Optional user address override; otherwise derived from provider. */
12
+ userAddress?: string;
13
+ /** Optional: Project key for hosted facilitator billing. */
14
+ projectKey?: string;
15
+ }
16
+ /** Result of a callWithPayment() client operation. */
17
+ interface CallWithPaymentResult<TResponseBody = unknown> {
18
+ response: TResponseBody;
19
+ txHash?: string;
20
+ paymentHeader?: PaymentHeaderBase64;
21
+ paymentRequirements?: PaymentRequirements;
22
+ }
23
+ /** Shape of the client instance returned by createPaymentClient. */
24
+ interface PaymentClient {
25
+ callWithPayment<TBody = unknown, TResp = unknown>(path: string, options?: {
26
+ method?: "GET" | "POST" | "PUT" | "DELETE";
27
+ body?: TBody;
28
+ headers?: Record<string, string>;
29
+ /**
30
+ * Optional override if you want to send less than maxAmountRequired.
31
+ * In most cases you won't need this and will just pay maxAmountRequired.
32
+ */
33
+ valueOverrideAtomic?: string;
34
+ }): Promise<CallWithPaymentResult<TResp>>;
35
+ }
36
+
37
+ /**
38
+ * Configuration for createMantleClient().
39
+ * All fields are optional - the client auto-detects sensible defaults.
40
+ */
41
+ interface MantleClientConfig {
42
+ /** Optional facilitator URL (auto-detects from NEXT_PUBLIC_FACILITATOR_URL or defaults to localhost:8080). */
43
+ facilitatorUrl?: string;
44
+ /** Optional resource URL (defaults to current origin in browser, or empty string for relative paths). */
45
+ resourceUrl?: string;
46
+ /** Function to get user's wallet address (required for payments). */
47
+ getAccount?: () => Promise<string | undefined> | string | undefined;
48
+ /** Function to get wallet provider/client (e.g., viem WalletClient or window.ethereum). */
49
+ getProvider?: () => any;
50
+ /** Optional project key for hosted facilitator billing. */
51
+ projectKey?: string;
52
+ }
53
+ /**
54
+ * Simplified Mantle payment client interface.
55
+ * Provides a clean API for making paid POST requests.
56
+ */
57
+ interface MantleClient {
58
+ /**
59
+ * Make a paid POST request to a protected endpoint.
60
+ * Automatically handles x402 flow (402 response, signing, payment, retry).
61
+ *
62
+ * @param url - API endpoint path (e.g., "/api/generate-image").
63
+ * @param body - Request body (will be JSON stringified).
64
+ * @returns Full payment result including response body and tx hash.
65
+ * @throws Error if wallet is not connected or payment fails.
66
+ */
67
+ postWithPayment<TResp = any>(url: string, body?: any): Promise<CallWithPaymentResult<TResp>>;
68
+ }
69
+ /**
70
+ * Create a simplified Mantle payment client with auto-detected defaults.
71
+ *
72
+ * Usage:
73
+ * ```typescript
74
+ * const client = createMantleClient({
75
+ * getAccount: () => account?.address,
76
+ * getProvider: () => walletClient,
77
+ * });
78
+ *
79
+ * const data = await client.postWithPayment("/api/generate", { prompt: "..." });
80
+ * ```
81
+ *
82
+ * @param config - Optional configuration (auto-detects facilitatorUrl and resourceUrl).
83
+ * @returns MantleClient instance with simplified postWithPayment() method.
84
+ */
85
+ declare function createMantleClient(config?: MantleClientConfig): MantleClient;
86
+
87
+ export { type CallWithPaymentResult as C, type MantleClient as M, type PaymentClientConfig as P, type MantleClientConfig as a, type PaymentClient as b, createMantleClient as c };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Configuration for createMantleClient().
3
+ * All fields are optional - the client auto-detects sensible defaults.
4
+ */
5
+ interface MantleClientConfig {
6
+ /** Optional facilitator URL (auto-detects from NEXT_PUBLIC_FACILITATOR_URL or defaults to localhost:8080). */
7
+ facilitatorUrl?: string;
8
+ /** Optional resource URL (defaults to current origin in browser, or empty string for relative paths). */
9
+ resourceUrl?: string;
10
+ /** Function to get user's wallet address (required for payments). */
11
+ getAccount?: () => Promise<string | undefined> | string | undefined;
12
+ /** Function to get wallet provider/client (e.g., viem WalletClient or window.ethereum). */
13
+ getProvider?: () => any;
14
+ /** Optional project key for hosted facilitator billing. */
15
+ projectKey?: string;
16
+ }
17
+ /**
18
+ * Simplified Mantle payment client interface.
19
+ * Provides a clean API for making paid POST requests.
20
+ */
21
+ interface MantleClient {
22
+ /**
23
+ * Make a paid POST request to a protected endpoint.
24
+ * Automatically handles x402 flow (402 response, signing, payment, retry).
25
+ *
26
+ * @param url - API endpoint path (e.g., "/api/generate-image").
27
+ * @param body - Request body (will be JSON stringified).
28
+ * @returns Response data from the protected endpoint.
29
+ * @throws Error if wallet is not connected or payment fails.
30
+ */
31
+ postWithPayment<TResp = any>(url: string, body?: any): Promise<TResp>;
32
+ }
33
+ /**
34
+ * Create a simplified Mantle payment client with auto-detected defaults.
35
+ *
36
+ * Usage:
37
+ * ```typescript
38
+ * const client = createMantleClient({
39
+ * getAccount: () => account?.address,
40
+ * getProvider: () => walletClient,
41
+ * });
42
+ *
43
+ * const data = await client.postWithPayment("/api/generate", { prompt: "..." });
44
+ * ```
45
+ *
46
+ * @param config - Optional configuration (auto-detects facilitatorUrl and resourceUrl).
47
+ * @returns MantleClient instance with simplified postWithPayment() method.
48
+ */
49
+ declare function createMantleClient(config?: MantleClientConfig): MantleClient;
50
+
51
+ export { type MantleClient as M, type MantleClientConfig as a, createMantleClient as c };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Configuration for createMantleClient().
3
+ * All fields are optional - the client auto-detects sensible defaults.
4
+ */
5
+ interface MantleClientConfig {
6
+ /** Optional facilitator URL (auto-detects from NEXT_PUBLIC_FACILITATOR_URL or defaults to localhost:8080). */
7
+ facilitatorUrl?: string;
8
+ /** Optional resource URL (defaults to current origin in browser, or empty string for relative paths). */
9
+ resourceUrl?: string;
10
+ /** Function to get user's wallet address (required for payments). */
11
+ getAccount?: () => Promise<string | undefined> | string | undefined;
12
+ /** Function to get wallet provider/client (e.g., viem WalletClient or window.ethereum). */
13
+ getProvider?: () => any;
14
+ /** Optional project key for hosted facilitator billing. */
15
+ projectKey?: string;
16
+ }
17
+ /**
18
+ * Simplified Mantle payment client interface.
19
+ * Provides a clean API for making paid POST requests.
20
+ */
21
+ interface MantleClient {
22
+ /**
23
+ * Make a paid POST request to a protected endpoint.
24
+ * Automatically handles x402 flow (402 response, signing, payment, retry).
25
+ *
26
+ * @param url - API endpoint path (e.g., "/api/generate-image").
27
+ * @param body - Request body (will be JSON stringified).
28
+ * @returns Response data from the protected endpoint.
29
+ * @throws Error if wallet is not connected or payment fails.
30
+ */
31
+ postWithPayment<TResp = any>(url: string, body?: any): Promise<TResp>;
32
+ }
33
+ /**
34
+ * Create a simplified Mantle payment client with auto-detected defaults.
35
+ *
36
+ * Usage:
37
+ * ```typescript
38
+ * const client = createMantleClient({
39
+ * getAccount: () => account?.address,
40
+ * getProvider: () => walletClient,
41
+ * });
42
+ *
43
+ * const data = await client.postWithPayment("/api/generate", { prompt: "..." });
44
+ * ```
45
+ *
46
+ * @param config - Optional configuration (auto-detects facilitatorUrl and resourceUrl).
47
+ * @returns MantleClient instance with simplified postWithPayment() method.
48
+ */
49
+ declare function createMantleClient(config?: MantleClientConfig): MantleClient;
50
+
51
+ export { type MantleClient as M, type MantleClientConfig as a, createMantleClient as c };
@@ -0,0 +1,87 @@
1
+ import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-2zqbJvcz.js';
2
+
3
+ /** Config for the client-side payment helper. */
4
+ interface PaymentClientConfig {
5
+ /** Base URL of your protected resource server. */
6
+ resourceUrl: string;
7
+ /** Facilitator URL (hosted or self-hosted). */
8
+ facilitatorUrl: string;
9
+ /** EIP-1193 provider (window.ethereum) or similar. */
10
+ provider: unknown;
11
+ /** Optional user address override; otherwise derived from provider. */
12
+ userAddress?: string;
13
+ /** Optional: Project key for hosted facilitator billing. */
14
+ projectKey?: string;
15
+ }
16
+ /** Result of a callWithPayment() client operation. */
17
+ interface CallWithPaymentResult<TResponseBody = unknown> {
18
+ response: TResponseBody;
19
+ txHash?: string;
20
+ paymentHeader?: PaymentHeaderBase64;
21
+ paymentRequirements?: PaymentRequirements;
22
+ }
23
+ /** Shape of the client instance returned by createPaymentClient. */
24
+ interface PaymentClient {
25
+ callWithPayment<TBody = unknown, TResp = unknown>(path: string, options?: {
26
+ method?: "GET" | "POST" | "PUT" | "DELETE";
27
+ body?: TBody;
28
+ headers?: Record<string, string>;
29
+ /**
30
+ * Optional override if you want to send less than maxAmountRequired.
31
+ * In most cases you won't need this and will just pay maxAmountRequired.
32
+ */
33
+ valueOverrideAtomic?: string;
34
+ }): Promise<CallWithPaymentResult<TResp>>;
35
+ }
36
+
37
+ /**
38
+ * Configuration for createMantleClient().
39
+ * All fields are optional - the client auto-detects sensible defaults.
40
+ */
41
+ interface MantleClientConfig {
42
+ /** Optional facilitator URL (auto-detects from NEXT_PUBLIC_FACILITATOR_URL or defaults to localhost:8080). */
43
+ facilitatorUrl?: string;
44
+ /** Optional resource URL (defaults to current origin in browser, or empty string for relative paths). */
45
+ resourceUrl?: string;
46
+ /** Function to get user's wallet address (required for payments). */
47
+ getAccount?: () => Promise<string | undefined> | string | undefined;
48
+ /** Function to get wallet provider/client (e.g., viem WalletClient or window.ethereum). */
49
+ getProvider?: () => any;
50
+ /** Optional project key for hosted facilitator billing. */
51
+ projectKey?: string;
52
+ }
53
+ /**
54
+ * Simplified Mantle payment client interface.
55
+ * Provides a clean API for making paid POST requests.
56
+ */
57
+ interface MantleClient {
58
+ /**
59
+ * Make a paid POST request to a protected endpoint.
60
+ * Automatically handles x402 flow (402 response, signing, payment, retry).
61
+ *
62
+ * @param url - API endpoint path (e.g., "/api/generate-image").
63
+ * @param body - Request body (will be JSON stringified).
64
+ * @returns Full payment result including response body and tx hash.
65
+ * @throws Error if wallet is not connected or payment fails.
66
+ */
67
+ postWithPayment<TResp = any>(url: string, body?: any): Promise<CallWithPaymentResult<TResp>>;
68
+ }
69
+ /**
70
+ * Create a simplified Mantle payment client with auto-detected defaults.
71
+ *
72
+ * Usage:
73
+ * ```typescript
74
+ * const client = createMantleClient({
75
+ * getAccount: () => account?.address,
76
+ * getProvider: () => walletClient,
77
+ * });
78
+ *
79
+ * const data = await client.postWithPayment("/api/generate", { prompt: "..." });
80
+ * ```
81
+ *
82
+ * @param config - Optional configuration (auto-detects facilitatorUrl and resourceUrl).
83
+ * @returns MantleClient instance with simplified postWithPayment() method.
84
+ */
85
+ declare function createMantleClient(config?: MantleClientConfig): MantleClient;
86
+
87
+ export { type CallWithPaymentResult as C, type MantleClient as M, type PaymentClientConfig as P, type MantleClientConfig as a, type PaymentClient as b, createMantleClient as c };
@@ -0,0 +1,87 @@
1
+ import { d as PaymentHeaderBase64, P as PaymentRequirements } from './types-2zqbJvcz.cjs';
2
+
3
+ /** Config for the client-side payment helper. */
4
+ interface PaymentClientConfig {
5
+ /** Base URL of your protected resource server. */
6
+ resourceUrl: string;
7
+ /** Facilitator URL (hosted or self-hosted). */
8
+ facilitatorUrl: string;
9
+ /** EIP-1193 provider (window.ethereum) or similar. */
10
+ provider: unknown;
11
+ /** Optional user address override; otherwise derived from provider. */
12
+ userAddress?: string;
13
+ /** Optional: Project key for hosted facilitator billing. */
14
+ projectKey?: string;
15
+ }
16
+ /** Result of a callWithPayment() client operation. */
17
+ interface CallWithPaymentResult<TResponseBody = unknown> {
18
+ response: TResponseBody;
19
+ txHash?: string;
20
+ paymentHeader?: PaymentHeaderBase64;
21
+ paymentRequirements?: PaymentRequirements;
22
+ }
23
+ /** Shape of the client instance returned by createPaymentClient. */
24
+ interface PaymentClient {
25
+ callWithPayment<TBody = unknown, TResp = unknown>(path: string, options?: {
26
+ method?: "GET" | "POST" | "PUT" | "DELETE";
27
+ body?: TBody;
28
+ headers?: Record<string, string>;
29
+ /**
30
+ * Optional override if you want to send less than maxAmountRequired.
31
+ * In most cases you won't need this and will just pay maxAmountRequired.
32
+ */
33
+ valueOverrideAtomic?: string;
34
+ }): Promise<CallWithPaymentResult<TResp>>;
35
+ }
36
+
37
+ /**
38
+ * Configuration for createMantleClient().
39
+ * All fields are optional - the client auto-detects sensible defaults.
40
+ */
41
+ interface MantleClientConfig {
42
+ /** Optional facilitator URL (auto-detects from NEXT_PUBLIC_FACILITATOR_URL or defaults to localhost:8080). */
43
+ facilitatorUrl?: string;
44
+ /** Optional resource URL (defaults to current origin in browser, or empty string for relative paths). */
45
+ resourceUrl?: string;
46
+ /** Function to get user's wallet address (required for payments). */
47
+ getAccount?: () => Promise<string | undefined> | string | undefined;
48
+ /** Function to get wallet provider/client (e.g., viem WalletClient or window.ethereum). */
49
+ getProvider?: () => any;
50
+ /** Optional project key for hosted facilitator billing. */
51
+ projectKey?: string;
52
+ }
53
+ /**
54
+ * Simplified Mantle payment client interface.
55
+ * Provides a clean API for making paid POST requests.
56
+ */
57
+ interface MantleClient {
58
+ /**
59
+ * Make a paid POST request to a protected endpoint.
60
+ * Automatically handles x402 flow (402 response, signing, payment, retry).
61
+ *
62
+ * @param url - API endpoint path (e.g., "/api/generate-image").
63
+ * @param body - Request body (will be JSON stringified).
64
+ * @returns Full payment result including response body and tx hash.
65
+ * @throws Error if wallet is not connected or payment fails.
66
+ */
67
+ postWithPayment<TResp = any>(url: string, body?: any): Promise<CallWithPaymentResult<TResp>>;
68
+ }
69
+ /**
70
+ * Create a simplified Mantle payment client with auto-detected defaults.
71
+ *
72
+ * Usage:
73
+ * ```typescript
74
+ * const client = createMantleClient({
75
+ * getAccount: () => account?.address,
76
+ * getProvider: () => walletClient,
77
+ * });
78
+ *
79
+ * const data = await client.postWithPayment("/api/generate", { prompt: "..." });
80
+ * ```
81
+ *
82
+ * @param config - Optional configuration (auto-detects facilitatorUrl and resourceUrl).
83
+ * @returns MantleClient instance with simplified postWithPayment() method.
84
+ */
85
+ declare function createMantleClient(config?: MantleClientConfig): MantleClient;
86
+
87
+ export { type CallWithPaymentResult as C, type MantleClient as M, type PaymentClientConfig as P, type MantleClientConfig as a, type PaymentClient as b, createMantleClient as c };
@@ -0,0 +1,66 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { b as RoutesConfig, M as MinimalPaywallOptions } from './types-xkNm0uzE.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). */
13
+ receiverAddress: `0x${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-C7EPJ6Hd.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). */
13
+ receiverAddress: `0x${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-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 };