@puga-labs/x402-mantle-sdk 0.3.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.
- package/dist/chunk-23QNUJIB.js +136 -0
- package/dist/chunk-6GLR5EBK.js +96 -0
- package/dist/chunk-BRGW36P7.js +211 -0
- package/dist/chunk-E46A7I6B.js +274 -0
- package/dist/chunk-FHU6CFHF.js +0 -0
- package/dist/chunk-GHUWTX7J.js +66 -0
- package/dist/chunk-HEZZ74SI.js +62 -0
- package/dist/chunk-NQWSCY44.js +70 -0
- package/dist/chunk-PCJEJYP6.js +68 -0
- package/dist/chunk-PPVS3X5Z.js +99 -0
- package/dist/chunk-U73CZU3X.js +237 -0
- package/dist/chunk-WAKJRVUP.js +135 -0
- package/dist/chunk-WFUDGBKK.js +68 -0
- package/dist/chunk-WO2MYZXT.js +0 -0
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +2 -2
- package/dist/constants-0ncqvV_O.d.ts +17 -0
- package/dist/constants-CsIL25uQ.d.cts +17 -0
- package/dist/createMantleClient-CO0uWPb-.d.cts +87 -0
- package/dist/createMantleClient-CuiPsTa6.d.ts +87 -0
- package/dist/express-Ck7eryef.d.cts +66 -0
- package/dist/express-CmEg5hR3.d.ts +66 -0
- package/dist/express-D8EwEcOL.d.ts +66 -0
- package/dist/express-eQOPxfnI.d.cts +66 -0
- package/dist/index.cjs +186 -109
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +6 -4
- package/dist/nextjs-Bp8DxYDN.d.ts +45 -0
- package/dist/nextjs-CliiaTPe.d.cts +45 -0
- package/dist/nextjs-D7t-BC4N.d.ts +45 -0
- package/dist/nextjs-Duecps0q.d.cts +45 -0
- package/dist/nextjs-TFhFiQuL.d.ts +45 -0
- package/dist/nextjs-ZO2J9mdo.d.cts +45 -0
- package/dist/react.cjs +3 -2
- package/dist/react.d.cts +7 -4
- package/dist/react.d.ts +7 -4
- package/dist/react.js +3 -3
- package/dist/server-express.cjs +368 -0
- package/dist/server-express.d.cts +5 -0
- package/dist/server-express.d.ts +5 -0
- package/dist/server-express.js +13 -0
- package/dist/server-nextjs.cjs +339 -0
- package/dist/server-nextjs.d.cts +5 -0
- package/dist/server-nextjs.d.ts +5 -0
- package/dist/server-nextjs.js +11 -0
- package/dist/server-web.cjs +339 -0
- package/dist/server-web.d.cts +4 -0
- package/dist/server-web.d.ts +4 -0
- package/dist/server-web.js +11 -0
- package/dist/server.cjs +316 -111
- package/dist/server.d.cts +67 -104
- package/dist/server.d.ts +67 -104
- package/dist/server.js +29 -5
- package/dist/types-BFUqKBBO.d.cts +63 -0
- package/dist/types-BFUqKBBO.d.ts +63 -0
- package/dist/types-C7EPJ6Hd.d.ts +85 -0
- package/dist/types-CEttmr1U.d.cts +97 -0
- package/dist/types-CoOdbZSp.d.cts +97 -0
- package/dist/types-CqQ6OgRi.d.ts +85 -0
- package/dist/types-CrOsOHcX.d.cts +85 -0
- package/dist/types-D20K36pc.d.ts +97 -0
- package/dist/types-DTzov_EE.d.ts +97 -0
- package/dist/types-xkNm0uzE.d.cts +85 -0
- package/dist/web-standards-BNQyWzBC.d.cts +77 -0
- package/dist/web-standards-C3D2vdTg.d.ts +77 -0
- package/dist/web-standards-D8j1kZxd.d.ts +77 -0
- package/dist/web-standards-DOYp0UDT.d.cts +77 -0
- package/package.json +49 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { M as MinimalPaywallOptions } from './types-xkNm0uzE.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Web Standards route handler type.
|
|
5
|
+
* Takes a Request and returns a Response.
|
|
6
|
+
*/
|
|
7
|
+
type WebHandler = (request: Request) => Promise<Response>;
|
|
8
|
+
/**
|
|
9
|
+
* Wrapper function that adds x402 payment verification to Web Standards handler.
|
|
10
|
+
*/
|
|
11
|
+
type WebPaywallWrapper = (handler: WebHandler) => WebHandler;
|
|
12
|
+
/**
|
|
13
|
+
* Create Web Standards middleware for x402 payment verification.
|
|
14
|
+
* Uses Mantle mainnet defaults (USDC, exact scheme, etc.).
|
|
15
|
+
*
|
|
16
|
+
* Compatible with:
|
|
17
|
+
* - Hono
|
|
18
|
+
* - Cloudflare Workers
|
|
19
|
+
* - Deno
|
|
20
|
+
* - Bun
|
|
21
|
+
* - Any platform supporting Web Request/Response API
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Hono example
|
|
26
|
+
* import { Hono } from 'hono'
|
|
27
|
+
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web'
|
|
28
|
+
*
|
|
29
|
+
* const app = new Hono()
|
|
30
|
+
* const pay = mantlePaywall({
|
|
31
|
+
* priceUsd: 0.01,
|
|
32
|
+
* payTo: '0x...',
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* app.post('/api/generate', pay(async (req) => {
|
|
36
|
+
* const body = await req.json();
|
|
37
|
+
* // Your handler code here
|
|
38
|
+
* return new Response(JSON.stringify({ success: true }), {
|
|
39
|
+
* headers: { 'Content-Type': 'application/json' }
|
|
40
|
+
* });
|
|
41
|
+
* }));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Cloudflare Workers example
|
|
47
|
+
* import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web'
|
|
48
|
+
*
|
|
49
|
+
* const pay = mantlePaywall({
|
|
50
|
+
* priceUsd: 0.01,
|
|
51
|
+
* payTo: '0x...',
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* export default {
|
|
55
|
+
* async fetch(request: Request) {
|
|
56
|
+
* const handler = pay(async (req) => {
|
|
57
|
+
* // Your handler code here
|
|
58
|
+
* return new Response('Hello World');
|
|
59
|
+
* });
|
|
60
|
+
* return handler(request);
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param opts - Minimal configuration (price, payTo, optional facilitator/telemetry).
|
|
66
|
+
* @returns Function that wraps Web Standards handlers with payment verification.
|
|
67
|
+
*/
|
|
68
|
+
declare function mantlePaywall(opts: MinimalPaywallOptions): WebPaywallWrapper;
|
|
69
|
+
|
|
70
|
+
type webStandards_WebHandler = WebHandler;
|
|
71
|
+
type webStandards_WebPaywallWrapper = WebPaywallWrapper;
|
|
72
|
+
declare const webStandards_mantlePaywall: typeof mantlePaywall;
|
|
73
|
+
declare namespace webStandards {
|
|
74
|
+
export { type webStandards_WebHandler as WebHandler, type webStandards_WebPaywallWrapper as WebPaywallWrapper, webStandards_mantlePaywall as mantlePaywall };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { type WebHandler as W, type WebPaywallWrapper as a, mantlePaywall as m, webStandards as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puga-labs/x402-mantle-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "x402 payments SDK for Mantle (USDC, gasless, facilitator-based)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evgenii Pugachev <cyprus.pugamuga@gmail.com>",
|
|
@@ -47,6 +47,36 @@
|
|
|
47
47
|
"default": "./dist/server.cjs"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
+
"./server/express": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/server-express.d.ts",
|
|
53
|
+
"default": "./dist/server-express.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/server-express.d.cts",
|
|
57
|
+
"default": "./dist/server-express.cjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./server/nextjs": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/server-nextjs.d.ts",
|
|
63
|
+
"default": "./dist/server-nextjs.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/server-nextjs.d.cts",
|
|
67
|
+
"default": "./dist/server-nextjs.cjs"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./server/web": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/server-web.d.ts",
|
|
73
|
+
"default": "./dist/server-web.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/server-web.d.cts",
|
|
77
|
+
"default": "./dist/server-web.cjs"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
50
80
|
"./react": {
|
|
51
81
|
"import": {
|
|
52
82
|
"types": "./dist/react.d.ts",
|
|
@@ -62,7 +92,7 @@
|
|
|
62
92
|
"dist"
|
|
63
93
|
],
|
|
64
94
|
"scripts": {
|
|
65
|
-
"build": "tsup src/index.ts src/client.ts src/server.ts src/react.ts --format cjs,esm --dts",
|
|
95
|
+
"build": "tsup src/index.ts src/client.ts src/server.ts src/server-express.ts src/server-nextjs.ts src/server-web.ts src/react.ts --format cjs,esm --dts",
|
|
66
96
|
"dev": "tsup src/index.ts --format esm --watch",
|
|
67
97
|
"clean": "rimraf dist",
|
|
68
98
|
"lint": "eslint src --ext .ts",
|
|
@@ -77,13 +107,30 @@
|
|
|
77
107
|
},
|
|
78
108
|
"peerDependencies": {
|
|
79
109
|
"ethers": "^6.0.0",
|
|
110
|
+
"express": "^4.0.0 || ^5.0.0",
|
|
111
|
+
"next": "^14.0.0 || ^15.0.0",
|
|
80
112
|
"react": "^18.0.0 || ^19.0.0"
|
|
81
113
|
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"express": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"next": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"ethers": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"react": {
|
|
125
|
+
"optional": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
82
128
|
"devDependencies": {
|
|
83
129
|
"@eslint/js": "^9.17.0",
|
|
84
130
|
"@types/express": "^5.0.6",
|
|
85
131
|
"@types/node": "^22.0.0",
|
|
86
132
|
"@types/react": "^18.3.1",
|
|
133
|
+
"next": "^15.1.6",
|
|
87
134
|
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
88
135
|
"@typescript-eslint/parser": "^8.20.0",
|
|
89
136
|
"@vitest/coverage-v8": "^4.0.15",
|