@okxweb3/app-x402-core 0.1.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/README.md +267 -0
- package/dist/cjs/OKXFacilitatorClient-BvyQB1QM.d.ts +59 -0
- package/dist/cjs/client/index.d.ts +320 -0
- package/dist/cjs/client/index.js +564 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/facilitator/index.d.ts +198 -0
- package/dist/cjs/facilitator/index.js +533 -0
- package/dist/cjs/facilitator/index.js.map +1 -0
- package/dist/cjs/http/index.d.ts +51 -0
- package/dist/cjs/http/index.js +1226 -0
- package/dist/cjs/http/index.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +155 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mechanisms-sojpSwWW.d.ts +763 -0
- package/dist/cjs/schemas/index.d.ts +309 -0
- package/dist/cjs/schemas/index.js +127 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/cjs/server/index.d.ts +2 -0
- package/dist/cjs/server/index.js +1880 -0
- package/dist/cjs/server/index.js.map +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.js +97 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +48 -0
- package/dist/cjs/utils/index.js +116 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/x402HTTPResourceServer-CcsAkcgI.d.ts +466 -0
- package/dist/esm/OKXFacilitatorClient-D5E3LX50.d.mts +59 -0
- package/dist/esm/chunk-CAXWAW23.mjs +68 -0
- package/dist/esm/chunk-CAXWAW23.mjs.map +1 -0
- package/dist/esm/chunk-CS33MEMU.mjs +86 -0
- package/dist/esm/chunk-CS33MEMU.mjs.map +1 -0
- package/dist/esm/chunk-O3IYMTNT.mjs +118 -0
- package/dist/esm/chunk-O3IYMTNT.mjs.map +1 -0
- package/dist/esm/chunk-TDLQZ6MP.mjs +86 -0
- package/dist/esm/chunk-TDLQZ6MP.mjs.map +1 -0
- package/dist/esm/chunk-XBQG2CDV.mjs +1792 -0
- package/dist/esm/chunk-XBQG2CDV.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +320 -0
- package/dist/esm/client/index.mjs +318 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/facilitator/index.d.mts +198 -0
- package/dist/esm/facilitator/index.mjs +387 -0
- package/dist/esm/facilitator/index.mjs.map +1 -0
- package/dist/esm/http/index.d.mts +51 -0
- package/dist/esm/http/index.mjs +34 -0
- package/dist/esm/http/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +6 -0
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/mechanisms-sojpSwWW.d.mts +763 -0
- package/dist/esm/schemas/index.d.mts +309 -0
- package/dist/esm/schemas/index.mjs +41 -0
- package/dist/esm/schemas/index.mjs.map +1 -0
- package/dist/esm/server/index.d.mts +2 -0
- package/dist/esm/server/index.mjs +28 -0
- package/dist/esm/server/index.mjs.map +1 -0
- package/dist/esm/types/index.d.mts +1 -0
- package/dist/esm/types/index.mjs +13 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/utils/index.d.mts +48 -0
- package/dist/esm/utils/index.mjs +19 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/dist/esm/x402HTTPResourceServer-DBeutKxq.d.mts +466 -0
- package/package.json +121 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/index.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
Base64EncodedRegex: () => Base64EncodedRegex,
|
|
24
|
+
deepEqual: () => deepEqual,
|
|
25
|
+
findByNetworkAndScheme: () => findByNetworkAndScheme,
|
|
26
|
+
findFacilitatorBySchemeAndNetwork: () => findFacilitatorBySchemeAndNetwork,
|
|
27
|
+
findSchemesByNetwork: () => findSchemesByNetwork,
|
|
28
|
+
safeBase64Decode: () => safeBase64Decode,
|
|
29
|
+
safeBase64Encode: () => safeBase64Encode
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(utils_exports);
|
|
32
|
+
var findSchemesByNetwork = (map, network) => {
|
|
33
|
+
let implementationsByScheme = map.get(network);
|
|
34
|
+
if (!implementationsByScheme) {
|
|
35
|
+
for (const [registeredNetworkPattern, implementations] of map.entries()) {
|
|
36
|
+
const pattern = registeredNetworkPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\*/g, ".*");
|
|
37
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
38
|
+
if (regex.test(network)) {
|
|
39
|
+
implementationsByScheme = implementations;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return implementationsByScheme;
|
|
45
|
+
};
|
|
46
|
+
var findByNetworkAndScheme = (map, scheme, network) => {
|
|
47
|
+
return findSchemesByNetwork(map, network)?.get(scheme);
|
|
48
|
+
};
|
|
49
|
+
var findFacilitatorBySchemeAndNetwork = (schemeMap, scheme, network) => {
|
|
50
|
+
const schemeData = schemeMap.get(scheme);
|
|
51
|
+
if (!schemeData) return void 0;
|
|
52
|
+
if (schemeData.networks.has(network)) {
|
|
53
|
+
return schemeData.facilitator;
|
|
54
|
+
}
|
|
55
|
+
const patternRegex = new RegExp("^" + schemeData.pattern.replace("*", ".*") + "$");
|
|
56
|
+
if (patternRegex.test(network)) {
|
|
57
|
+
return schemeData.facilitator;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
};
|
|
61
|
+
var Base64EncodedRegex = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
62
|
+
function safeBase64Encode(data) {
|
|
63
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
|
|
64
|
+
const bytes = new TextEncoder().encode(data);
|
|
65
|
+
const binaryString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join("");
|
|
66
|
+
return globalThis.btoa(binaryString);
|
|
67
|
+
}
|
|
68
|
+
return Buffer.from(data, "utf8").toString("base64");
|
|
69
|
+
}
|
|
70
|
+
function safeBase64Decode(data) {
|
|
71
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.atob === "function") {
|
|
72
|
+
const binaryString = globalThis.atob(data);
|
|
73
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
74
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
75
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
76
|
+
}
|
|
77
|
+
const decoder = new TextDecoder("utf-8");
|
|
78
|
+
return decoder.decode(bytes);
|
|
79
|
+
}
|
|
80
|
+
return Buffer.from(data, "base64").toString("utf-8");
|
|
81
|
+
}
|
|
82
|
+
function deepEqual(obj1, obj2) {
|
|
83
|
+
const normalize = (obj) => {
|
|
84
|
+
if (obj === null || obj === void 0) return JSON.stringify(obj);
|
|
85
|
+
if (typeof obj !== "object") return JSON.stringify(obj);
|
|
86
|
+
if (Array.isArray(obj)) {
|
|
87
|
+
return JSON.stringify(
|
|
88
|
+
obj.map(
|
|
89
|
+
(item) => typeof item === "object" && item !== null ? JSON.parse(normalize(item)) : item
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const sorted = {};
|
|
94
|
+
Object.keys(obj).sort().forEach((key) => {
|
|
95
|
+
const value = obj[key];
|
|
96
|
+
sorted[key] = typeof value === "object" && value !== null ? JSON.parse(normalize(value)) : value;
|
|
97
|
+
});
|
|
98
|
+
return JSON.stringify(sorted);
|
|
99
|
+
};
|
|
100
|
+
try {
|
|
101
|
+
return normalize(obj1) === normalize(obj2);
|
|
102
|
+
} catch {
|
|
103
|
+
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
Base64EncodedRegex,
|
|
109
|
+
deepEqual,
|
|
110
|
+
findByNetworkAndScheme,
|
|
111
|
+
findFacilitatorBySchemeAndNetwork,
|
|
112
|
+
findSchemesByNetwork,
|
|
113
|
+
safeBase64Decode,
|
|
114
|
+
safeBase64Encode
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { Network } from \"../types\";\n\n/**\n * Scheme data structure for facilitator storage\n */\nexport interface SchemeData<T> {\n facilitator: T;\n networks: Set<Network>;\n pattern: Network;\n}\n\nexport const findSchemesByNetwork = <T>(\n map: Map<string, Map<string, T>>,\n network: Network,\n): Map<string, T> | undefined => {\n // Direct match first\n let implementationsByScheme = map.get(network);\n\n if (!implementationsByScheme) {\n // Try pattern matching for registered network patterns\n for (const [registeredNetworkPattern, implementations] of map.entries()) {\n // Convert the registered network pattern to a regex\n // e.g., \"eip155:*\" becomes /^eip155:.*$/\n const pattern = registeredNetworkPattern\n .replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\") // Escape special regex chars except *\n .replace(/\\\\\\*/g, \".*\"); // Replace escaped * with .*\n\n const regex = new RegExp(`^${pattern}$`);\n\n if (regex.test(network)) {\n implementationsByScheme = implementations;\n break;\n }\n }\n }\n\n return implementationsByScheme;\n};\n\nexport const findByNetworkAndScheme = <T>(\n map: Map<string, Map<string, T>>,\n scheme: string,\n network: Network,\n): T | undefined => {\n return findSchemesByNetwork(map, network)?.get(scheme);\n};\n\n/**\n * Finds a facilitator by scheme and network using pattern matching.\n * Works with new SchemeData storage structure.\n *\n * @param schemeMap - Map of scheme names to SchemeData\n * @param scheme - The scheme to find\n * @param network - The network to match against\n * @returns The facilitator if found, undefined otherwise\n */\nexport const findFacilitatorBySchemeAndNetwork = <T>(\n schemeMap: Map<string, SchemeData<T>>,\n scheme: string,\n network: Network,\n): T | undefined => {\n const schemeData = schemeMap.get(scheme);\n if (!schemeData) return undefined;\n\n // Check if network is in the stored networks set\n if (schemeData.networks.has(network)) {\n return schemeData.facilitator;\n }\n\n // Try pattern matching\n const patternRegex = new RegExp(\"^\" + schemeData.pattern.replace(\"*\", \".*\") + \"$\");\n if (patternRegex.test(network)) {\n return schemeData.facilitator;\n }\n\n return undefined;\n};\n\nexport const Base64EncodedRegex = /^[A-Za-z0-9+/]*={0,2}$/;\n\n/**\n * Encodes a string to base64 format\n *\n * @param data - The string to be encoded to base64\n * @returns The base64 encoded string\n */\nexport function safeBase64Encode(data: string): string {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.btoa === \"function\") {\n const bytes = new TextEncoder().encode(data);\n const binaryString = Array.from(bytes, byte => String.fromCharCode(byte)).join(\"\");\n return globalThis.btoa(binaryString);\n }\n return Buffer.from(data, \"utf8\").toString(\"base64\");\n}\n\n/**\n * Decodes a base64 string back to its original format\n *\n * @param data - The base64 encoded string to be decoded\n * @returns The decoded string in UTF-8 format\n */\nexport function safeBase64Decode(data: string): string {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.atob === \"function\") {\n const binaryString = globalThis.atob(data);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n const decoder = new TextDecoder(\"utf-8\");\n return decoder.decode(bytes);\n }\n return Buffer.from(data, \"base64\").toString(\"utf-8\");\n}\n\n/**\n * Deep equality comparison for payment requirements\n * Uses a normalized JSON.stringify for consistent comparison\n *\n * @param obj1 - First object to compare\n * @param obj2 - Second object to compare\n * @returns True if objects are deeply equal\n */\nexport function deepEqual(obj1: unknown, obj2: unknown): boolean {\n // Normalize and stringify both objects for comparison\n // This handles nested objects, arrays, and different property orders\n const normalize = (obj: unknown): string => {\n // Handle primitives and null/undefined\n if (obj === null || obj === undefined) return JSON.stringify(obj);\n if (typeof obj !== \"object\") return JSON.stringify(obj);\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return JSON.stringify(\n obj.map(item =>\n typeof item === \"object\" && item !== null ? JSON.parse(normalize(item)) : item,\n ),\n );\n }\n\n // Handle objects - sort keys and recursively normalize values\n const sorted: Record<string, unknown> = {};\n Object.keys(obj as Record<string, unknown>)\n .sort()\n .forEach(key => {\n const value = (obj as Record<string, unknown>)[key];\n sorted[key] =\n typeof value === \"object\" && value !== null ? JSON.parse(normalize(value)) : value;\n });\n return JSON.stringify(sorted);\n };\n\n try {\n return normalize(obj1) === normalize(obj2);\n } catch {\n // Fallback to simple comparison if normalization fails\n return JSON.stringify(obj1) === JSON.stringify(obj2);\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { o as Price, N as Network, S as SettleResponse, P as PaymentPayload, a as PaymentRequirements, c as PaymentRequired, x as x402ResourceServer, n as SettlementOverrides } from './mechanisms-sojpSwWW.js';
|
|
2
|
+
|
|
3
|
+
declare const SETTLEMENT_OVERRIDES_HEADER = "settlement-overrides";
|
|
4
|
+
/**
|
|
5
|
+
* Framework-agnostic HTTP adapter interface
|
|
6
|
+
* Implementations provide framework-specific HTTP operations
|
|
7
|
+
*/
|
|
8
|
+
interface HTTPAdapter {
|
|
9
|
+
getHeader(name: string): string | undefined;
|
|
10
|
+
getMethod(): string;
|
|
11
|
+
getPath(): string;
|
|
12
|
+
getUrl(): string;
|
|
13
|
+
getAcceptHeader(): string;
|
|
14
|
+
getUserAgent(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get query parameters from the request URL
|
|
17
|
+
*
|
|
18
|
+
* @returns Record of query parameter key-value pairs
|
|
19
|
+
*/
|
|
20
|
+
getQueryParams?(): Record<string, string | string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific query parameter by name
|
|
23
|
+
*
|
|
24
|
+
* @param name - The query parameter name
|
|
25
|
+
* @returns The query parameter value(s) or undefined
|
|
26
|
+
*/
|
|
27
|
+
getQueryParam?(name: string): string | string[] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get the parsed request body
|
|
30
|
+
* Framework adapters should parse JSON/form data appropriately
|
|
31
|
+
*
|
|
32
|
+
* @returns The parsed request body
|
|
33
|
+
*/
|
|
34
|
+
getBody?(): unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Paywall configuration for HTML responses
|
|
38
|
+
*/
|
|
39
|
+
interface PaywallConfig {
|
|
40
|
+
appName?: string;
|
|
41
|
+
appLogo?: string;
|
|
42
|
+
sessionTokenEndpoint?: string;
|
|
43
|
+
currentUrl?: string;
|
|
44
|
+
testnet?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Paywall provider interface for generating HTML
|
|
48
|
+
*/
|
|
49
|
+
interface PaywallProvider {
|
|
50
|
+
generateHtml(paymentRequired: PaymentRequired, config?: PaywallConfig): string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Dynamic payTo function that receives HTTP request context
|
|
54
|
+
*/
|
|
55
|
+
type DynamicPayTo = (context: HTTPRequestContext) => string | Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Dynamic price function that receives HTTP request context
|
|
58
|
+
*/
|
|
59
|
+
type DynamicPrice = (context: HTTPRequestContext) => Price | Promise<Price>;
|
|
60
|
+
/**
|
|
61
|
+
* Result of response body callbacks containing content type and body.
|
|
62
|
+
*/
|
|
63
|
+
interface HTTPResponseBody {
|
|
64
|
+
/**
|
|
65
|
+
* The content type for the response (e.g., 'application/json', 'text/plain').
|
|
66
|
+
*/
|
|
67
|
+
contentType: string;
|
|
68
|
+
/**
|
|
69
|
+
* The response body to include in the 402 response.
|
|
70
|
+
*/
|
|
71
|
+
body: unknown;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Dynamic function to generate a custom response for unpaid requests.
|
|
75
|
+
* Receives the HTTP request context and returns the content type and body to include in the 402 response.
|
|
76
|
+
*/
|
|
77
|
+
type UnpaidResponseBody = (context: HTTPRequestContext) => HTTPResponseBody | Promise<HTTPResponseBody>;
|
|
78
|
+
/**
|
|
79
|
+
* Dynamic function to generate a custom response for settlement failures.
|
|
80
|
+
* Receives the HTTP request context and settle failure result, returns the content type and body.
|
|
81
|
+
*/
|
|
82
|
+
type SettlementFailedResponseBody = (context: HTTPRequestContext, settleResult: Omit<ProcessSettleFailureResponse, "response">) => HTTPResponseBody | Promise<HTTPResponseBody>;
|
|
83
|
+
/**
|
|
84
|
+
* A single payment option for a route
|
|
85
|
+
* Represents one way a client can pay for access to the resource
|
|
86
|
+
*/
|
|
87
|
+
interface PaymentOption {
|
|
88
|
+
scheme: string;
|
|
89
|
+
payTo: string | DynamicPayTo;
|
|
90
|
+
price: Price | DynamicPrice;
|
|
91
|
+
network: Network;
|
|
92
|
+
maxTimeoutSeconds?: number;
|
|
93
|
+
extra?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Route configuration for HTTP endpoints
|
|
97
|
+
*
|
|
98
|
+
* The 'accepts' field defines payment options for the route.
|
|
99
|
+
* Can be a single PaymentOption or an array of PaymentOptions for multiple payment methods.
|
|
100
|
+
*/
|
|
101
|
+
interface RouteConfig {
|
|
102
|
+
accepts: PaymentOption | PaymentOption[];
|
|
103
|
+
resource?: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
mimeType?: string;
|
|
106
|
+
customPaywallHtml?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Optional callback to generate a custom response for unpaid API requests.
|
|
109
|
+
* This allows servers to return preview data, error messages, or other content
|
|
110
|
+
* when a request lacks payment.
|
|
111
|
+
*
|
|
112
|
+
* For browser requests (Accept: text/html), the paywall HTML takes precedence.
|
|
113
|
+
* This callback is only used for API clients.
|
|
114
|
+
*
|
|
115
|
+
* If not provided, defaults to { contentType: 'application/json', body: {} }.
|
|
116
|
+
*
|
|
117
|
+
* @param context - The HTTP request context
|
|
118
|
+
* @returns An object containing both contentType and body for the 402 response
|
|
119
|
+
*/
|
|
120
|
+
unpaidResponseBody?: UnpaidResponseBody;
|
|
121
|
+
/**
|
|
122
|
+
* Optional callback to generate a custom response for settlement failures.
|
|
123
|
+
* If not provided, defaults to { contentType: 'application/json', body: {} }.
|
|
124
|
+
*
|
|
125
|
+
* @param context - The HTTP request context
|
|
126
|
+
* @param settleResult - The settlement failure result
|
|
127
|
+
* @returns An object containing both contentType and body for the 402 response
|
|
128
|
+
*/
|
|
129
|
+
settlementFailedResponseBody?: SettlementFailedResponseBody;
|
|
130
|
+
extensions?: Record<string, unknown>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Routes configuration - maps path patterns to route configs
|
|
134
|
+
*/
|
|
135
|
+
type RoutesConfig = Record<string, RouteConfig> | RouteConfig;
|
|
136
|
+
/**
|
|
137
|
+
* Hook that runs on every request to a protected route, before payment processing.
|
|
138
|
+
* Can grant access without payment, deny the request, or continue to payment flow.
|
|
139
|
+
*
|
|
140
|
+
* @returns
|
|
141
|
+
* - `void` - Continue to payment processing (default behavior)
|
|
142
|
+
* - `{ grantAccess: true }` - Grant access without requiring payment
|
|
143
|
+
* - `{ abort: true; reason: string }` - Deny the request (returns 403)
|
|
144
|
+
*/
|
|
145
|
+
type ProtectedRequestHook = (context: HTTPRequestContext, routeConfig: RouteConfig) => Promise<void | {
|
|
146
|
+
grantAccess: true;
|
|
147
|
+
} | {
|
|
148
|
+
abort: true;
|
|
149
|
+
reason: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Compiled route for efficient matching
|
|
153
|
+
*/
|
|
154
|
+
interface CompiledRoute {
|
|
155
|
+
verb: string;
|
|
156
|
+
regex: RegExp;
|
|
157
|
+
config: RouteConfig;
|
|
158
|
+
pattern: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* HTTP request context that encapsulates all request data
|
|
162
|
+
*/
|
|
163
|
+
interface HTTPRequestContext {
|
|
164
|
+
adapter: HTTPAdapter;
|
|
165
|
+
path: string;
|
|
166
|
+
method: string;
|
|
167
|
+
paymentHeader?: string;
|
|
168
|
+
routePattern?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* HTTP transport context contains both request context and optional response data.
|
|
172
|
+
*/
|
|
173
|
+
interface HTTPTransportContext {
|
|
174
|
+
/** The HTTP request context */
|
|
175
|
+
request: HTTPRequestContext;
|
|
176
|
+
/** The response body buffer */
|
|
177
|
+
responseBody?: Buffer;
|
|
178
|
+
/** Response headers set by the route handler (used for settlement overrides) */
|
|
179
|
+
responseHeaders?: Record<string, string>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* HTTP response instructions for the framework middleware
|
|
183
|
+
*/
|
|
184
|
+
interface HTTPResponseInstructions {
|
|
185
|
+
status: number;
|
|
186
|
+
headers: Record<string, string>;
|
|
187
|
+
body?: unknown;
|
|
188
|
+
isHtml?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Result of processing an HTTP request for payment
|
|
192
|
+
*/
|
|
193
|
+
type HTTPProcessResult = {
|
|
194
|
+
type: "no-payment-required";
|
|
195
|
+
} | {
|
|
196
|
+
type: "payment-verified";
|
|
197
|
+
paymentPayload: PaymentPayload;
|
|
198
|
+
paymentRequirements: PaymentRequirements;
|
|
199
|
+
declaredExtensions?: Record<string, unknown>;
|
|
200
|
+
} | {
|
|
201
|
+
type: "payment-error";
|
|
202
|
+
response: HTTPResponseInstructions;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Result of processSettlement
|
|
206
|
+
*/
|
|
207
|
+
type ProcessSettleSuccessResponse = SettleResponse & {
|
|
208
|
+
success: true;
|
|
209
|
+
headers: Record<string, string>;
|
|
210
|
+
requirements: PaymentRequirements;
|
|
211
|
+
};
|
|
212
|
+
type ProcessSettleFailureResponse = SettleResponse & {
|
|
213
|
+
success: false;
|
|
214
|
+
errorReason: string;
|
|
215
|
+
errorMessage?: string;
|
|
216
|
+
headers: Record<string, string>;
|
|
217
|
+
response: HTTPResponseInstructions;
|
|
218
|
+
};
|
|
219
|
+
type ProcessSettleResultResponse = ProcessSettleSuccessResponse | ProcessSettleFailureResponse;
|
|
220
|
+
/**
|
|
221
|
+
* Represents a validation error for a specific route's payment configuration.
|
|
222
|
+
*/
|
|
223
|
+
interface RouteValidationError {
|
|
224
|
+
/** The route pattern (e.g., "GET /api/weather") */
|
|
225
|
+
routePattern: string;
|
|
226
|
+
/** The payment scheme that failed validation */
|
|
227
|
+
scheme: string;
|
|
228
|
+
/** The network that failed validation */
|
|
229
|
+
network: Network;
|
|
230
|
+
/** The type of validation failure */
|
|
231
|
+
reason: "missing_scheme" | "missing_facilitator";
|
|
232
|
+
/** Human-readable error message */
|
|
233
|
+
message: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Error thrown when route configuration validation fails.
|
|
237
|
+
*/
|
|
238
|
+
declare class RouteConfigurationError extends Error {
|
|
239
|
+
/** The validation errors that caused this exception */
|
|
240
|
+
readonly errors: RouteValidationError[];
|
|
241
|
+
/**
|
|
242
|
+
* Creates a new RouteConfigurationError with the given validation errors.
|
|
243
|
+
*
|
|
244
|
+
* @param errors - The validation errors that caused this exception.
|
|
245
|
+
*/
|
|
246
|
+
constructor(errors: RouteValidationError[]);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Hook called when the facilitator returns status="timeout".
|
|
250
|
+
* Receives the tx hash and network so the server can verify on-chain.
|
|
251
|
+
* Return { confirmed: true } to deliver the resource; { confirmed: false } to return 402.
|
|
252
|
+
*/
|
|
253
|
+
type OnSettlementTimeoutHook = (txHash: string, network: string) => Promise<{
|
|
254
|
+
confirmed: boolean;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* HTTP-enhanced x402 resource server
|
|
258
|
+
* Provides framework-agnostic HTTP protocol handling
|
|
259
|
+
*/
|
|
260
|
+
declare class x402HTTPResourceServer {
|
|
261
|
+
private ResourceServer;
|
|
262
|
+
private compiledRoutes;
|
|
263
|
+
private routesConfig;
|
|
264
|
+
private paywallProvider?;
|
|
265
|
+
private protectedRequestHooks;
|
|
266
|
+
private timeoutRecoveryHook?;
|
|
267
|
+
private pollDeadlineMs;
|
|
268
|
+
/**
|
|
269
|
+
* Creates a new x402HTTPResourceServer instance.
|
|
270
|
+
*
|
|
271
|
+
* @param ResourceServer - The core x402ResourceServer instance to use
|
|
272
|
+
* @param routes - Route configuration for payment-protected endpoints
|
|
273
|
+
*/
|
|
274
|
+
constructor(ResourceServer: x402ResourceServer, routes: RoutesConfig);
|
|
275
|
+
/**
|
|
276
|
+
* Get the underlying x402ResourceServer instance.
|
|
277
|
+
*
|
|
278
|
+
* @returns The underlying x402ResourceServer instance
|
|
279
|
+
*/
|
|
280
|
+
get server(): x402ResourceServer;
|
|
281
|
+
/**
|
|
282
|
+
* Get the routes configuration.
|
|
283
|
+
*
|
|
284
|
+
* @returns The routes configuration
|
|
285
|
+
*/
|
|
286
|
+
get routes(): RoutesConfig;
|
|
287
|
+
/**
|
|
288
|
+
* Initialize the HTTP resource server.
|
|
289
|
+
*
|
|
290
|
+
* This method initializes the underlying resource server (fetching facilitator support)
|
|
291
|
+
* and then validates that all route payment configurations have corresponding
|
|
292
|
+
* registered schemes and facilitator support.
|
|
293
|
+
*
|
|
294
|
+
* @throws RouteConfigurationError if any route's payment options don't have
|
|
295
|
+
* corresponding registered schemes or facilitator support
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const httpServer = new x402HTTPResourceServer(server, routes);
|
|
300
|
+
* await httpServer.initialize();
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
initialize(): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Register a custom paywall provider for generating HTML
|
|
306
|
+
*
|
|
307
|
+
* @param provider - PaywallProvider instance
|
|
308
|
+
* @returns This service instance for chaining
|
|
309
|
+
*/
|
|
310
|
+
registerPaywallProvider(provider: PaywallProvider): this;
|
|
311
|
+
/**
|
|
312
|
+
* Register a hook that runs on every request to a protected route, before payment processing.
|
|
313
|
+
* Hooks are executed in order of registration. The first hook to return a non-void result wins.
|
|
314
|
+
*
|
|
315
|
+
* @param hook - The request hook function
|
|
316
|
+
* @returns The x402HTTPResourceServer instance for chaining
|
|
317
|
+
*/
|
|
318
|
+
onProtectedRequest(hook: ProtectedRequestHook): this;
|
|
319
|
+
/**
|
|
320
|
+
* Register a hook to call when the facilitator returns status="timeout".
|
|
321
|
+
* The hook should verify the tx on-chain and return { confirmed: boolean }.
|
|
322
|
+
* If confirmed=true the resource is delivered (200); otherwise 402 is returned.
|
|
323
|
+
*
|
|
324
|
+
* @param hook - On-chain verification callback
|
|
325
|
+
* @returns The x402HTTPResourceServer instance for chaining
|
|
326
|
+
*/
|
|
327
|
+
onSettlementTimeout(hook: OnSettlementTimeoutHook): this;
|
|
328
|
+
/**
|
|
329
|
+
* Set the poll deadline for settle/status polling on timeout recovery.
|
|
330
|
+
* Default is 5000ms.
|
|
331
|
+
*
|
|
332
|
+
* @param deadlineMs - Maximum time to poll in milliseconds
|
|
333
|
+
* @returns The x402HTTPResourceServer instance for chaining
|
|
334
|
+
*/
|
|
335
|
+
setPollDeadline(deadlineMs: number): this;
|
|
336
|
+
/**
|
|
337
|
+
* Process HTTP request and return response instructions
|
|
338
|
+
* This is the main entry point for framework middleware
|
|
339
|
+
*
|
|
340
|
+
* @param context - HTTP request context
|
|
341
|
+
* @param paywallConfig - Optional paywall configuration
|
|
342
|
+
* @returns Process result indicating next action for middleware
|
|
343
|
+
*/
|
|
344
|
+
processHTTPRequest(context: HTTPRequestContext, paywallConfig?: PaywallConfig): Promise<HTTPProcessResult>;
|
|
345
|
+
/**
|
|
346
|
+
* Process settlement after successful response
|
|
347
|
+
*
|
|
348
|
+
* @param paymentPayload - The verified payment payload
|
|
349
|
+
* @param requirements - The matching payment requirements
|
|
350
|
+
* @param declaredExtensions - Optional declared extensions (for per-key enrichment)
|
|
351
|
+
* @param transportContext - Optional HTTP transport context
|
|
352
|
+
* @param settlementOverrides - Optional settlement overrides (e.g., partial settlement amount)
|
|
353
|
+
* @returns ProcessSettleResultResponse - SettleResponse with headers if success or errorReason if failure
|
|
354
|
+
*/
|
|
355
|
+
processSettlement(paymentPayload: PaymentPayload, requirements: PaymentRequirements, declaredExtensions?: Record<string, unknown>, transportContext?: HTTPTransportContext, settlementOverrides?: SettlementOverrides): Promise<ProcessSettleResultResponse>;
|
|
356
|
+
/**
|
|
357
|
+
* Check if a request requires payment based on route configuration
|
|
358
|
+
*
|
|
359
|
+
* @param context - HTTP request context
|
|
360
|
+
* @returns True if the route requires payment, false otherwise
|
|
361
|
+
*/
|
|
362
|
+
requiresPayment(context: HTTPRequestContext): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Build HTTPResponseInstructions for settlement failure.
|
|
365
|
+
* Uses settlementFailedResponseBody hook if configured, otherwise defaults to empty body.
|
|
366
|
+
*
|
|
367
|
+
* @param failure - Settlement failure result with headers
|
|
368
|
+
* @param transportContext - Optional HTTP transport context for the request
|
|
369
|
+
* @returns HTTP response instructions for the 402 settlement failure response
|
|
370
|
+
*/
|
|
371
|
+
private buildSettlementFailureResponse;
|
|
372
|
+
/**
|
|
373
|
+
* Normalizes a RouteConfig's accepts field into an array of PaymentOptions
|
|
374
|
+
* Handles both single PaymentOption and array formats
|
|
375
|
+
*
|
|
376
|
+
* @param routeConfig - Route configuration
|
|
377
|
+
* @returns Array of payment options
|
|
378
|
+
*/
|
|
379
|
+
private normalizePaymentOptions;
|
|
380
|
+
/**
|
|
381
|
+
* Validates that all payment options in routes have corresponding registered schemes
|
|
382
|
+
* and facilitator support.
|
|
383
|
+
*
|
|
384
|
+
* @returns Array of validation errors (empty if all routes are valid)
|
|
385
|
+
*/
|
|
386
|
+
private validateRouteConfiguration;
|
|
387
|
+
/**
|
|
388
|
+
* Get route configuration for a request
|
|
389
|
+
*
|
|
390
|
+
* @param path - Request path
|
|
391
|
+
* @param method - HTTP method
|
|
392
|
+
* @returns Route configuration and pattern, or undefined if no match
|
|
393
|
+
*/
|
|
394
|
+
private getRouteConfig;
|
|
395
|
+
/**
|
|
396
|
+
* Extract payment from HTTP headers (handles v1 and v2)
|
|
397
|
+
*
|
|
398
|
+
* @param adapter - HTTP adapter
|
|
399
|
+
* @returns Decoded payment payload or null
|
|
400
|
+
*/
|
|
401
|
+
private extractPayment;
|
|
402
|
+
/**
|
|
403
|
+
* Check if request is from a web browser
|
|
404
|
+
*
|
|
405
|
+
* @param adapter - HTTP adapter
|
|
406
|
+
* @returns True if request appears to be from a browser
|
|
407
|
+
*/
|
|
408
|
+
private isWebBrowser;
|
|
409
|
+
/**
|
|
410
|
+
* Create HTTP response instructions from payment required
|
|
411
|
+
*
|
|
412
|
+
* @param paymentRequired - Payment requirements
|
|
413
|
+
* @param isWebBrowser - Whether request is from browser
|
|
414
|
+
* @param paywallConfig - Paywall configuration
|
|
415
|
+
* @param customHtml - Custom HTML template
|
|
416
|
+
* @param unpaidResponse - Optional custom response (content type and body) for unpaid API requests
|
|
417
|
+
* @returns Response instructions
|
|
418
|
+
*/
|
|
419
|
+
private createHTTPResponse;
|
|
420
|
+
/**
|
|
421
|
+
* Create HTTP payment required response (v1 puts in body, v2 puts in header)
|
|
422
|
+
*
|
|
423
|
+
* @param paymentRequired - Payment required object
|
|
424
|
+
* @returns Headers and body for the HTTP response
|
|
425
|
+
*/
|
|
426
|
+
private createHTTPPaymentRequiredResponse;
|
|
427
|
+
/**
|
|
428
|
+
* Create settlement response headers
|
|
429
|
+
*
|
|
430
|
+
* @param settleResponse - Settlement response
|
|
431
|
+
* @returns Headers to add to response
|
|
432
|
+
*/
|
|
433
|
+
private createSettlementHeaders;
|
|
434
|
+
/**
|
|
435
|
+
* Parse route pattern into verb and regex
|
|
436
|
+
*
|
|
437
|
+
* @param pattern - Route pattern like "GET /api/*", "/api/[id]", or "/api/:id"
|
|
438
|
+
* @returns Parsed pattern with verb and regex
|
|
439
|
+
*/
|
|
440
|
+
private parseRoutePattern;
|
|
441
|
+
/**
|
|
442
|
+
* Normalize path for matching
|
|
443
|
+
*
|
|
444
|
+
* @param path - Raw path from request
|
|
445
|
+
* @returns Normalized path
|
|
446
|
+
*/
|
|
447
|
+
private normalizePath;
|
|
448
|
+
/**
|
|
449
|
+
* Generate paywall HTML for browser requests
|
|
450
|
+
*
|
|
451
|
+
* @param paymentRequired - Payment required response
|
|
452
|
+
* @param paywallConfig - Optional paywall configuration
|
|
453
|
+
* @param customHtml - Optional custom HTML template
|
|
454
|
+
* @returns HTML string
|
|
455
|
+
*/
|
|
456
|
+
private generatePaywallHTML;
|
|
457
|
+
/**
|
|
458
|
+
* Extract display amount from payment requirements.
|
|
459
|
+
*
|
|
460
|
+
* @param paymentRequired - The payment required object
|
|
461
|
+
* @returns The display amount in decimal format
|
|
462
|
+
*/
|
|
463
|
+
private getDisplayAmount;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export { type CompiledRoute as C, type DynamicPayTo as D, type HTTPAdapter as H, type OnSettlementTimeoutHook as O, type PaymentOption as P, type RouteConfig as R, type SettlementFailedResponseBody as S, type UnpaidResponseBody as U, type DynamicPrice as a, type HTTPProcessResult as b, type HTTPRequestContext as c, type HTTPResponseBody as d, type HTTPResponseInstructions as e, type HTTPTransportContext as f, type PaywallConfig as g, type PaywallProvider as h, type ProcessSettleFailureResponse as i, type ProcessSettleResultResponse as j, type ProcessSettleSuccessResponse as k, type ProtectedRequestHook as l, RouteConfigurationError as m, type RouteValidationError as n, type RoutesConfig as o, SETTLEMENT_OVERRIDES_HEADER as p, x402HTTPResourceServer as x };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { d as FacilitatorClient, h as SupportedResponse, P as PaymentPayload, a as PaymentRequirements, V as VerifyResponse, S as SettleResponse, i as SettleStatusResponse } from './mechanisms-sojpSwWW.mjs';
|
|
2
|
+
|
|
3
|
+
interface OKXConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
secretKey: string;
|
|
6
|
+
passphrase: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/**
|
|
9
|
+
* OKX exact-scheme extension: when true, the settle call tells the facilitator to
|
|
10
|
+
* wait for on-chain confirmation before responding (syncSettle=true in request body).
|
|
11
|
+
* The facilitator then returns status="success" directly (no polling needed).
|
|
12
|
+
* When false (default), the facilitator responds with status="pending" immediately.
|
|
13
|
+
*/
|
|
14
|
+
syncSettle?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* OKX facilitator client implementing the FacilitatorClient interface.
|
|
18
|
+
* Uses HMAC-SHA256 signing per OKX REST API authentication spec.
|
|
19
|
+
*/
|
|
20
|
+
declare class OKXFacilitatorClient implements FacilitatorClient {
|
|
21
|
+
private config;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param config
|
|
25
|
+
*/
|
|
26
|
+
constructor(config: OKXConfig);
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param method
|
|
30
|
+
* @param path
|
|
31
|
+
* @param body
|
|
32
|
+
*/
|
|
33
|
+
private createHeaders;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
getSupported(): Promise<SupportedResponse>;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param payload
|
|
41
|
+
* @param requirements
|
|
42
|
+
*/
|
|
43
|
+
verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param payload
|
|
47
|
+
* @param requirements
|
|
48
|
+
*/
|
|
49
|
+
settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Query on-chain settlement status by transaction hash.
|
|
52
|
+
*
|
|
53
|
+
* @param txHash - The transaction hash to query
|
|
54
|
+
* @returns Settlement status response
|
|
55
|
+
*/
|
|
56
|
+
getSettleStatus(txHash: string): Promise<SettleStatusResponse>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { type OKXConfig as O, OKXFacilitatorClient as a };
|