@alleyboss/micropay-solana-x402-paywall 3.3.4 → 3.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -241,7 +241,31 @@ function createX402Middleware(config) {
241
241
  network: config.network === "mainnet-beta" ? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" : "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
242
242
  }
243
243
  };
244
- return next.withX402(handler, finalConfig, server$2);
244
+ const wrappedHandler = next.withX402(handler, finalConfig, server$2);
245
+ return async (req, ctx) => {
246
+ const compatibleReq = new Proxy(req, {
247
+ get(target, prop) {
248
+ if (prop === "url") {
249
+ return target.nextUrl?.pathname || target.url;
250
+ }
251
+ if (prop === "headers") {
252
+ const headers = target.headers;
253
+ return new Proxy(headers, {
254
+ get(hTarget, hProp) {
255
+ if (typeof hProp === "string" && !["get", "set", "has", "delete", "entries", "keys", "values", "forEach", "append"].includes(hProp) && typeof hTarget[hProp] === "undefined") {
256
+ return hTarget.get(hProp) || void 0;
257
+ }
258
+ const val2 = hTarget[hProp];
259
+ return typeof val2 === "function" ? val2.bind(hTarget) : val2;
260
+ }
261
+ });
262
+ }
263
+ const val = target[prop];
264
+ return typeof val === "function" ? val.bind(target) : val;
265
+ }
266
+ });
267
+ return wrappedHandler(compatibleReq, ctx);
268
+ };
245
269
  };
246
270
  }
247
271
  var withX402 = next.withX402;
@@ -1,4 +1,3 @@
1
- import * as next_server from 'next/server';
2
1
  import { withX402 as withX402$1 } from '@x402/next';
3
2
  export { x402ResourceServer } from '@x402/core/server';
4
3
 
@@ -20,7 +19,7 @@ interface X402Config {
20
19
  /**
21
20
  * Create a specialized Next.js middleware with Solana support pre-configured
22
21
  */
23
- declare function createX402Middleware(config: X402Config): (handler: any, routeConfig?: any) => (request: next_server.NextRequest) => Promise<next_server.NextResponse<unknown>>;
22
+ declare function createX402Middleware(config: X402Config): (handler: any, routeConfig?: any) => (req: any, ctx: any) => Promise<any>;
24
23
  declare const withX402: typeof withX402$1;
25
24
 
26
25
  export { type X402Config, createX402Middleware, withX402 };
@@ -1,4 +1,3 @@
1
- import * as next_server from 'next/server';
2
1
  import { withX402 as withX402$1 } from '@x402/next';
3
2
  export { x402ResourceServer } from '@x402/core/server';
4
3
 
@@ -20,7 +19,7 @@ interface X402Config {
20
19
  /**
21
20
  * Create a specialized Next.js middleware with Solana support pre-configured
22
21
  */
23
- declare function createX402Middleware(config: X402Config): (handler: any, routeConfig?: any) => (request: next_server.NextRequest) => Promise<next_server.NextResponse<unknown>>;
22
+ declare function createX402Middleware(config: X402Config): (handler: any, routeConfig?: any) => (req: any, ctx: any) => Promise<any>;
24
23
  declare const withX402: typeof withX402$1;
25
24
 
26
25
  export { type X402Config, createX402Middleware, withX402 };
@@ -240,7 +240,31 @@ function createX402Middleware(config) {
240
240
  network: config.network === "mainnet-beta" ? "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" : "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
241
241
  }
242
242
  };
243
- return withX402$1(handler, finalConfig, server);
243
+ const wrappedHandler = withX402$1(handler, finalConfig, server);
244
+ return async (req, ctx) => {
245
+ const compatibleReq = new Proxy(req, {
246
+ get(target, prop) {
247
+ if (prop === "url") {
248
+ return target.nextUrl?.pathname || target.url;
249
+ }
250
+ if (prop === "headers") {
251
+ const headers = target.headers;
252
+ return new Proxy(headers, {
253
+ get(hTarget, hProp) {
254
+ if (typeof hProp === "string" && !["get", "set", "has", "delete", "entries", "keys", "values", "forEach", "append"].includes(hProp) && typeof hTarget[hProp] === "undefined") {
255
+ return hTarget.get(hProp) || void 0;
256
+ }
257
+ const val2 = hTarget[hProp];
258
+ return typeof val2 === "function" ? val2.bind(hTarget) : val2;
259
+ }
260
+ });
261
+ }
262
+ const val = target[prop];
263
+ return typeof val === "function" ? val.bind(target) : val;
264
+ }
265
+ });
266
+ return wrappedHandler(compatibleReq, ctx);
267
+ };
244
268
  };
245
269
  }
246
270
  var withX402 = withX402$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alleyboss/micropay-solana-x402-paywall",
3
- "version": "3.3.4",
3
+ "version": "3.3.6",
4
4
  "description": "Production-ready Solana micropayments library wrapper for official x402 SDK",
5
5
  "author": "AlleyBoss",
6
6
  "license": "MIT",