@puga-labs/x402-mantle-sdk 0.3.2 → 0.3.4
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/dist/{chunk-GHUWTX7J.js → chunk-CXRILT3C.js} +4 -2
- package/dist/chunk-IT6VV6YL.js +73 -0
- package/dist/{chunk-6GLR5EBK.js → chunk-QWQUSRLY.js} +5 -2
- package/dist/{chunk-BRGW36P7.js → chunk-ZLCKBFVJ.js} +27 -1
- package/dist/{chunk-WFUDGBKK.js → chunk-ZROK2XOB.js} +4 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/nextjs-BgyAWzT3.d.ts +82 -0
- package/dist/nextjs-CY13JXkV.d.cts +82 -0
- package/dist/server-express.cjs +1 -1
- package/dist/server-express.js +2 -2
- package/dist/server-nextjs.cjs +6 -1
- package/dist/server-nextjs.d.cts +1 -1
- package/dist/server-nextjs.d.ts +1 -1
- package/dist/server-nextjs.js +4 -2
- package/dist/server-web.cjs +1 -1
- package/dist/server-web.js +2 -2
- package/dist/server.cjs +5 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-CTI5CRDY.js +0 -274
- package/dist/chunk-DA6ZBXNO.js +0 -275
- package/dist/chunk-FD4HG7KR.js +0 -135
- package/dist/chunk-FHU6CFHF.js +0 -0
- package/dist/chunk-GWVWPS3R.js +0 -277
- package/dist/chunk-HTZ3QFY4.js +0 -135
- package/dist/chunk-MQALBRGV.js +0 -135
- package/dist/chunk-PYIYE3HI.js +0 -135
- package/dist/chunk-Q6SPMEIW.js +0 -235
- package/dist/chunk-RNKXSBT7.js +0 -135
- package/dist/chunk-SPCXFN7C.js +0 -284
- package/dist/chunk-T5DRYLNB.js +0 -135
- package/dist/chunk-TSEE5NSJ.js +0 -297
- package/dist/chunk-WAKJRVUP.js +0 -135
- package/dist/chunk-WELDWRDX.js +0 -307
- package/dist/chunk-XAQGMFSR.js +0 -56
- package/dist/constants-C7aY8u5b.d.cts +0 -77
- package/dist/constants-C7aY8u5b.d.ts +0 -77
- package/dist/constants-CVFF0ray.d.ts +0 -17
- package/dist/constants-DzCGK0Q3.d.cts +0 -17
- package/dist/createMantleClient-DS1Ghqrz.d.cts +0 -51
- package/dist/createMantleClient-DS1Ghqrz.d.ts +0 -51
- package/dist/createMantleClient-DVFkbBfS.d.ts +0 -87
- package/dist/createMantleClient-NN0Nitp9.d.cts +0 -87
- package/dist/express-Ck7eryef.d.cts +0 -66
- package/dist/express-CmEg5hR3.d.ts +0 -66
- package/dist/nextjs-Bp8DxYDN.d.ts +0 -45
- package/dist/nextjs-CliiaTPe.d.cts +0 -45
- package/dist/nextjs-D7t-BC4N.d.ts +0 -45
- package/dist/nextjs-ZO2J9mdo.d.cts +0 -45
- package/dist/types-2zqbJvcz.d.cts +0 -63
- package/dist/types-2zqbJvcz.d.ts +0 -63
- package/dist/types-C7EPJ6Hd.d.ts +0 -85
- package/dist/types-CEttmr1U.d.cts +0 -97
- package/dist/types-D20K36pc.d.ts +0 -97
- package/dist/types-xkNm0uzE.d.cts +0 -85
- package/dist/web-standards-C3D2vdTg.d.ts +0 -77
- package/dist/web-standards-DOYp0UDT.d.cts +0 -77
|
@@ -1,87 +0,0 @@
|
|
|
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 };
|
|
@@ -1,87 +0,0 @@
|
|
|
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 };
|
|
@@ -1,66 +0,0 @@
|
|
|
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 };
|
|
@@ -1,66 +0,0 @@
|
|
|
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 };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { M as MinimalPaywallOptions } from './types-CqQ6OgRi.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Next.js App Router route handler type.
|
|
6
|
-
*/
|
|
7
|
-
type NextJSHandler<T = any> = (req: NextRequest) => Promise<NextResponse<T>>;
|
|
8
|
-
/**
|
|
9
|
-
* Wrapper function that adds x402 payment verification to Next.js route handler.
|
|
10
|
-
*/
|
|
11
|
-
type NextJSPaywallWrapper = <T>(handler: NextJSHandler<T>) => NextJSHandler<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Create Next.js App Router middleware for x402 payment verification.
|
|
14
|
-
* Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // app/api/generate-image/route.ts
|
|
19
|
-
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/nextjs'
|
|
20
|
-
*
|
|
21
|
-
* const pay = mantlePaywall({
|
|
22
|
-
* priceUsd: 0.01,
|
|
23
|
-
* payTo: process.env.PAY_TO as `0x${string}`,
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* export const POST = pay(async (req: NextRequest) => {
|
|
27
|
-
* const { prompt } = await req.json();
|
|
28
|
-
* // Your handler code here
|
|
29
|
-
* return NextResponse.json({ success: true });
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
|
|
34
|
-
* @returns Function that wraps Next.js route handlers with payment verification.
|
|
35
|
-
*/
|
|
36
|
-
declare function mantlePaywall(opts: MinimalPaywallOptions): NextJSPaywallWrapper;
|
|
37
|
-
|
|
38
|
-
type nextjs_NextJSHandler<T = any> = NextJSHandler<T>;
|
|
39
|
-
type nextjs_NextJSPaywallWrapper = NextJSPaywallWrapper;
|
|
40
|
-
declare const nextjs_mantlePaywall: typeof mantlePaywall;
|
|
41
|
-
declare namespace nextjs {
|
|
42
|
-
export { type nextjs_NextJSHandler as NextJSHandler, type nextjs_NextJSPaywallWrapper as NextJSPaywallWrapper, nextjs_mantlePaywall as mantlePaywall };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { type NextJSHandler as N, type NextJSPaywallWrapper as a, mantlePaywall as m, nextjs as n };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { M as MinimalPaywallOptions } from './types-xkNm0uzE.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Next.js App Router route handler type.
|
|
6
|
-
*/
|
|
7
|
-
type NextJSHandler<T = any> = (req: NextRequest) => Promise<NextResponse<T>>;
|
|
8
|
-
/**
|
|
9
|
-
* Wrapper function that adds x402 payment verification to Next.js route handler.
|
|
10
|
-
*/
|
|
11
|
-
type NextJSPaywallWrapper = <T>(handler: NextJSHandler<T>) => NextJSHandler<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Create Next.js App Router middleware for x402 payment verification.
|
|
14
|
-
* Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // app/api/generate-image/route.ts
|
|
19
|
-
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/nextjs'
|
|
20
|
-
*
|
|
21
|
-
* const pay = mantlePaywall({
|
|
22
|
-
* priceUsd: 0.01,
|
|
23
|
-
* payTo: process.env.PAY_TO as `0x${string}`,
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* export const POST = pay(async (req: NextRequest) => {
|
|
27
|
-
* const { prompt } = await req.json();
|
|
28
|
-
* // Your handler code here
|
|
29
|
-
* return NextResponse.json({ success: true });
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
|
|
34
|
-
* @returns Function that wraps Next.js route handlers with payment verification.
|
|
35
|
-
*/
|
|
36
|
-
declare function mantlePaywall(opts: MinimalPaywallOptions): NextJSPaywallWrapper;
|
|
37
|
-
|
|
38
|
-
type nextjs_NextJSHandler<T = any> = NextJSHandler<T>;
|
|
39
|
-
type nextjs_NextJSPaywallWrapper = NextJSPaywallWrapper;
|
|
40
|
-
declare const nextjs_mantlePaywall: typeof mantlePaywall;
|
|
41
|
-
declare namespace nextjs {
|
|
42
|
-
export { type nextjs_NextJSHandler as NextJSHandler, type nextjs_NextJSPaywallWrapper as NextJSPaywallWrapper, nextjs_mantlePaywall as mantlePaywall };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { type NextJSHandler as N, type NextJSPaywallWrapper as a, mantlePaywall as m, nextjs as n };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { M as MinimalPaywallOptions } from './types-C7EPJ6Hd.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Next.js App Router route handler type.
|
|
6
|
-
*/
|
|
7
|
-
type NextJSHandler<T = any> = (req: NextRequest) => Promise<NextResponse<T>>;
|
|
8
|
-
/**
|
|
9
|
-
* Wrapper function that adds x402 payment verification to Next.js route handler.
|
|
10
|
-
*/
|
|
11
|
-
type NextJSPaywallWrapper = <T>(handler: NextJSHandler<T>) => NextJSHandler<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Create Next.js App Router middleware for x402 payment verification.
|
|
14
|
-
* Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // app/api/generate-image/route.ts
|
|
19
|
-
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/nextjs'
|
|
20
|
-
*
|
|
21
|
-
* const pay = mantlePaywall({
|
|
22
|
-
* priceUsd: 0.01,
|
|
23
|
-
* payTo: process.env.PAY_TO as `0x${string}`,
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* export const POST = pay(async (req: NextRequest) => {
|
|
27
|
-
* const { prompt } = await req.json();
|
|
28
|
-
* // Your handler code here
|
|
29
|
-
* return NextResponse.json({ success: true });
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
|
|
34
|
-
* @returns Function that wraps Next.js route handlers with payment verification.
|
|
35
|
-
*/
|
|
36
|
-
declare function mantlePaywall(opts: MinimalPaywallOptions): NextJSPaywallWrapper;
|
|
37
|
-
|
|
38
|
-
type nextjs_NextJSHandler<T = any> = NextJSHandler<T>;
|
|
39
|
-
type nextjs_NextJSPaywallWrapper = NextJSPaywallWrapper;
|
|
40
|
-
declare const nextjs_mantlePaywall: typeof mantlePaywall;
|
|
41
|
-
declare namespace nextjs {
|
|
42
|
-
export { type nextjs_NextJSHandler as NextJSHandler, type nextjs_NextJSPaywallWrapper as NextJSPaywallWrapper, nextjs_mantlePaywall as mantlePaywall };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { type NextJSHandler as N, type NextJSPaywallWrapper as a, mantlePaywall as m, nextjs as n };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { M as MinimalPaywallOptions } from './types-CrOsOHcX.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Next.js App Router route handler type.
|
|
6
|
-
*/
|
|
7
|
-
type NextJSHandler<T = any> = (req: NextRequest) => Promise<NextResponse<T>>;
|
|
8
|
-
/**
|
|
9
|
-
* Wrapper function that adds x402 payment verification to Next.js route handler.
|
|
10
|
-
*/
|
|
11
|
-
type NextJSPaywallWrapper = <T>(handler: NextJSHandler<T>) => NextJSHandler<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Create Next.js App Router middleware for x402 payment verification.
|
|
14
|
-
* Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // app/api/generate-image/route.ts
|
|
19
|
-
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/nextjs'
|
|
20
|
-
*
|
|
21
|
-
* const pay = mantlePaywall({
|
|
22
|
-
* priceUsd: 0.01,
|
|
23
|
-
* payTo: process.env.PAY_TO as `0x${string}`,
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* export const POST = pay(async (req: NextRequest) => {
|
|
27
|
-
* const { prompt } = await req.json();
|
|
28
|
-
* // Your handler code here
|
|
29
|
-
* return NextResponse.json({ success: true });
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
|
|
34
|
-
* @returns Function that wraps Next.js route handlers with payment verification.
|
|
35
|
-
*/
|
|
36
|
-
declare function mantlePaywall(opts: MinimalPaywallOptions): NextJSPaywallWrapper;
|
|
37
|
-
|
|
38
|
-
type nextjs_NextJSHandler<T = any> = NextJSHandler<T>;
|
|
39
|
-
type nextjs_NextJSPaywallWrapper = NextJSPaywallWrapper;
|
|
40
|
-
declare const nextjs_mantlePaywall: typeof mantlePaywall;
|
|
41
|
-
declare namespace nextjs {
|
|
42
|
-
export { type nextjs_NextJSHandler as NextJSHandler, type nextjs_NextJSPaywallWrapper as NextJSPaywallWrapper, nextjs_mantlePaywall as mantlePaywall };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { type NextJSHandler as N, type NextJSPaywallWrapper as a, mantlePaywall as m, nextjs as n };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/** Network identifier used in x402 paymentRequirements / paymentHeader. */
|
|
2
|
-
type NetworkId = "mantle-mainnet" | (string & {});
|
|
3
|
-
/** Basic ERC-20 asset config (e.g. USDC on Mantle). */
|
|
4
|
-
interface AssetConfig {
|
|
5
|
-
symbol: string;
|
|
6
|
-
address: string;
|
|
7
|
-
decimals: number;
|
|
8
|
-
}
|
|
9
|
-
/** x402-style payment requirements (returned in 402 response). */
|
|
10
|
-
interface PaymentRequirements {
|
|
11
|
-
scheme: "exact";
|
|
12
|
-
network: NetworkId;
|
|
13
|
-
asset: string;
|
|
14
|
-
maxAmountRequired: string;
|
|
15
|
-
payTo: `0x${string}`;
|
|
16
|
-
price?: string;
|
|
17
|
-
currency?: string;
|
|
18
|
-
}
|
|
19
|
-
/** EIP-3009 TransferWithAuthorization payload. */
|
|
20
|
-
interface Authorization {
|
|
21
|
-
from: string;
|
|
22
|
-
to: string;
|
|
23
|
-
value: string;
|
|
24
|
-
validAfter: string;
|
|
25
|
-
validBefore: string;
|
|
26
|
-
nonce: string;
|
|
27
|
-
}
|
|
28
|
-
/** Inner payload of x402-style payment header. */
|
|
29
|
-
interface PaymentHeaderPayload {
|
|
30
|
-
signature: string;
|
|
31
|
-
authorization: Authorization;
|
|
32
|
-
}
|
|
33
|
-
/** Structured x402-style payment header (before base64 encoding). */
|
|
34
|
-
interface PaymentHeaderObject {
|
|
35
|
-
x402Version: number;
|
|
36
|
-
scheme: "exact";
|
|
37
|
-
network: NetworkId;
|
|
38
|
-
payload: PaymentHeaderPayload;
|
|
39
|
-
}
|
|
40
|
-
/** Base64-encoded payment header, sent in X-PAYMENT. */
|
|
41
|
-
type PaymentHeaderBase64 = string;
|
|
42
|
-
/**
|
|
43
|
-
* EIP-1193 provider interface (window.ethereum, MetaMask, etc.)
|
|
44
|
-
* Standard interface for Ethereum wallet providers.
|
|
45
|
-
*/
|
|
46
|
-
interface EIP1193Provider {
|
|
47
|
-
request(args: {
|
|
48
|
-
method: string;
|
|
49
|
-
params?: unknown[];
|
|
50
|
-
}): Promise<unknown>;
|
|
51
|
-
on?(event: string, listener: (...args: unknown[]) => void): void;
|
|
52
|
-
removeListener?(event: string, listener: (...args: unknown[]) => void): void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Window ethereum extension for TypeScript
|
|
56
|
-
*/
|
|
57
|
-
declare global {
|
|
58
|
-
interface Window {
|
|
59
|
-
ethereum?: EIP1193Provider;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type { AssetConfig as A, EIP1193Provider as E, NetworkId as N, PaymentRequirements as P, Authorization as a, PaymentHeaderPayload as b, PaymentHeaderObject as c, PaymentHeaderBase64 as d };
|
package/dist/types-2zqbJvcz.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/** Network identifier used in x402 paymentRequirements / paymentHeader. */
|
|
2
|
-
type NetworkId = "mantle-mainnet" | (string & {});
|
|
3
|
-
/** Basic ERC-20 asset config (e.g. USDC on Mantle). */
|
|
4
|
-
interface AssetConfig {
|
|
5
|
-
symbol: string;
|
|
6
|
-
address: string;
|
|
7
|
-
decimals: number;
|
|
8
|
-
}
|
|
9
|
-
/** x402-style payment requirements (returned in 402 response). */
|
|
10
|
-
interface PaymentRequirements {
|
|
11
|
-
scheme: "exact";
|
|
12
|
-
network: NetworkId;
|
|
13
|
-
asset: string;
|
|
14
|
-
maxAmountRequired: string;
|
|
15
|
-
payTo: `0x${string}`;
|
|
16
|
-
price?: string;
|
|
17
|
-
currency?: string;
|
|
18
|
-
}
|
|
19
|
-
/** EIP-3009 TransferWithAuthorization payload. */
|
|
20
|
-
interface Authorization {
|
|
21
|
-
from: string;
|
|
22
|
-
to: string;
|
|
23
|
-
value: string;
|
|
24
|
-
validAfter: string;
|
|
25
|
-
validBefore: string;
|
|
26
|
-
nonce: string;
|
|
27
|
-
}
|
|
28
|
-
/** Inner payload of x402-style payment header. */
|
|
29
|
-
interface PaymentHeaderPayload {
|
|
30
|
-
signature: string;
|
|
31
|
-
authorization: Authorization;
|
|
32
|
-
}
|
|
33
|
-
/** Structured x402-style payment header (before base64 encoding). */
|
|
34
|
-
interface PaymentHeaderObject {
|
|
35
|
-
x402Version: number;
|
|
36
|
-
scheme: "exact";
|
|
37
|
-
network: NetworkId;
|
|
38
|
-
payload: PaymentHeaderPayload;
|
|
39
|
-
}
|
|
40
|
-
/** Base64-encoded payment header, sent in X-PAYMENT. */
|
|
41
|
-
type PaymentHeaderBase64 = string;
|
|
42
|
-
/**
|
|
43
|
-
* EIP-1193 provider interface (window.ethereum, MetaMask, etc.)
|
|
44
|
-
* Standard interface for Ethereum wallet providers.
|
|
45
|
-
*/
|
|
46
|
-
interface EIP1193Provider {
|
|
47
|
-
request(args: {
|
|
48
|
-
method: string;
|
|
49
|
-
params?: unknown[];
|
|
50
|
-
}): Promise<unknown>;
|
|
51
|
-
on?(event: string, listener: (...args: unknown[]) => void): void;
|
|
52
|
-
removeListener?(event: string, listener: (...args: unknown[]) => void): void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Window ethereum extension for TypeScript
|
|
56
|
-
*/
|
|
57
|
-
declare global {
|
|
58
|
-
interface Window {
|
|
59
|
-
ethereum?: EIP1193Provider;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type { AssetConfig as A, EIP1193Provider as E, NetworkId as N, PaymentRequirements as P, Authorization as a, PaymentHeaderPayload as b, PaymentHeaderObject as c, PaymentHeaderBase64 as d };
|