@wtflabs/x402 0.0.1-beta.0
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 +60 -0
- package/dist/cjs/client/index.d.ts +64 -0
- package/dist/cjs/client/index.js +832 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/config-CFBSAuxW.d.ts +10 -0
- package/dist/cjs/config-Dfuvno71.d.ts +19 -0
- package/dist/cjs/facilitator/index.d.ts +42 -0
- package/dist/cjs/facilitator/index.js +2574 -0
- package/dist/cjs/facilitator/index.js.map +1 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +2974 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/middleware-6_1ApcJn.d.ts +93 -0
- package/dist/cjs/middleware-B_ewwsQp.d.ts +93 -0
- package/dist/cjs/middleware-Brgsx32F.d.ts +93 -0
- package/dist/cjs/middleware-BwfW7mAs.d.ts +93 -0
- package/dist/cjs/middleware-CQb61c1k.d.ts +93 -0
- package/dist/cjs/middleware-DB9lqy9f.d.ts +93 -0
- package/dist/cjs/middleware-DcHctwQV.d.ts +93 -0
- package/dist/cjs/middleware-De0jD3Bp.d.ts +93 -0
- package/dist/cjs/middleware-HoFOmpgv.d.ts +93 -0
- package/dist/cjs/middleware-Y8AiAfYw.d.ts +93 -0
- package/dist/cjs/middleware-pnres9YM.d.ts +93 -0
- package/dist/cjs/network-FrFmmiyj.d.ts +11 -0
- package/dist/cjs/network-RtNddYQk.d.ts +11 -0
- package/dist/cjs/paywall/index.d.ts +30 -0
- package/dist/cjs/paywall/index.js +131 -0
- package/dist/cjs/paywall/index.js.map +1 -0
- package/dist/cjs/rpc-BMvnNNHd.d.ts +35 -0
- package/dist/cjs/rpc-Ca8eHCWz.d.ts +35 -0
- package/dist/cjs/schemes/index.d.ts +533 -0
- package/dist/cjs/schemes/index.js +3144 -0
- package/dist/cjs/schemes/index.js.map +1 -0
- package/dist/cjs/shared/evm/index.d.ts +71 -0
- package/dist/cjs/shared/evm/index.js +947 -0
- package/dist/cjs/shared/evm/index.js.map +1 -0
- package/dist/cjs/shared/index.d.ts +182 -0
- package/dist/cjs/shared/index.js +674 -0
- package/dist/cjs/shared/index.js.map +1 -0
- package/dist/cjs/types/index.d.ts +1515 -0
- package/dist/cjs/types/index.js +1645 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/verify/index.d.ts +7 -0
- package/dist/cjs/verify/index.js +438 -0
- package/dist/cjs/verify/index.js.map +1 -0
- package/dist/cjs/wallet-BRWfOM5D.d.ts +153 -0
- package/dist/cjs/wallet-BTqCm9Zp.d.ts +27 -0
- package/dist/cjs/wallet-BYRAGtOB.d.ts +153 -0
- package/dist/cjs/wallet-BmEtlgEf.d.ts +48 -0
- package/dist/cjs/wallet-CNOAmyZ6.d.ts +48 -0
- package/dist/cjs/wallet-CQ0Fe_M5.d.ts +88 -0
- package/dist/cjs/wallet-D1SoxFTw.d.ts +48 -0
- package/dist/cjs/wallet-SJ-hbjm9.d.ts +153 -0
- package/dist/cjs/wallet-SJKJpUgQ.d.ts +167 -0
- package/dist/cjs/wallet-ecnda4Aj.d.ts +48 -0
- package/dist/cjs/wallet-gP8Qoi-c.d.ts +74 -0
- package/dist/cjs/x402Specs-B7InXo2L.d.ts +1065 -0
- package/dist/cjs/x402Specs-BLH3j34O.d.ts +1696 -0
- package/dist/cjs/x402Specs-C7LipAZg.d.ts +1715 -0
- package/dist/cjs/x402Specs-CYq5tSY1.d.ts +1745 -0
- package/dist/cjs/x402Specs-CeajqonG.d.ts +1696 -0
- package/dist/cjs/x402Specs-qMujgEV5.d.ts +1715 -0
- package/dist/cjs/x402Specs-qUBCpcuz.d.ts +1715 -0
- package/dist/esm/chunk-34YNR4LY.mjs +106 -0
- package/dist/esm/chunk-34YNR4LY.mjs.map +1 -0
- package/dist/esm/chunk-57UEJN5U.mjs +1416 -0
- package/dist/esm/chunk-57UEJN5U.mjs.map +1 -0
- package/dist/esm/chunk-5LTKIVOA.mjs +858 -0
- package/dist/esm/chunk-5LTKIVOA.mjs.map +1 -0
- package/dist/esm/chunk-AQQR4PXH.mjs +80 -0
- package/dist/esm/chunk-AQQR4PXH.mjs.map +1 -0
- package/dist/esm/chunk-LGXWNXCO.mjs +76 -0
- package/dist/esm/chunk-LGXWNXCO.mjs.map +1 -0
- package/dist/esm/chunk-RX2JKK4O.mjs +349 -0
- package/dist/esm/chunk-RX2JKK4O.mjs.map +1 -0
- package/dist/esm/chunk-UCBE7FDY.mjs +1041 -0
- package/dist/esm/chunk-UCBE7FDY.mjs.map +1 -0
- package/dist/esm/client/index.mjs +17 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/facilitator/index.mjs +14 -0
- package/dist/esm/facilitator/index.mjs.map +1 -0
- package/dist/esm/index.mjs +28 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/paywall/index.mjs +46 -0
- package/dist/esm/paywall/index.mjs.map +1 -0
- package/dist/esm/schemes/index.mjs +16 -0
- package/dist/esm/schemes/index.mjs.map +1 -0
- package/dist/esm/shared/evm/index.mjs +20 -0
- package/dist/esm/shared/evm/index.mjs.map +1 -0
- package/dist/esm/shared/index.mjs +31 -0
- package/dist/esm/shared/index.mjs.map +1 -0
- package/dist/esm/types/index.mjs +87 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/verify/index.mjs +105 -0
- package/dist/esm/verify/index.mjs.map +1 -0
- package/package.json +148 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { N as Network } from './network-FrFmmiyj.js';
|
|
3
|
+
import { E as EvmSigner } from './wallet-BYRAGtOB.js';
|
|
4
|
+
import { a as PaymentPayload, P as PaymentRequirements, J as VerifyResponse, S as SettleResponse, X as SupportedPaymentKindsResponse, M as ListDiscoveryResourcesRequest, O as ListDiscoveryResourcesResponse, z as HTTPRequestStructure } from './x402Specs-CYq5tSY1.js';
|
|
5
|
+
|
|
6
|
+
declare const moneySchema: z.ZodPipeline<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNumber]>, z.ZodNumber>;
|
|
7
|
+
type Money = z.input<typeof moneySchema>;
|
|
8
|
+
|
|
9
|
+
type Resource = `${string}://${string}`;
|
|
10
|
+
|
|
11
|
+
type CreateHeaders = () => Promise<{
|
|
12
|
+
verify: Record<string, string>;
|
|
13
|
+
settle: Record<string, string>;
|
|
14
|
+
supported: Record<string, string>;
|
|
15
|
+
list?: Record<string, string>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a facilitator client for interacting with the X402 payment facilitator service
|
|
19
|
+
*
|
|
20
|
+
* @param facilitator - The facilitator config to use. If not provided, the default facilitator will be used.
|
|
21
|
+
* @returns An object containing verify and settle functions for interacting with the facilitator
|
|
22
|
+
*/
|
|
23
|
+
declare function useFacilitator(facilitator?: FacilitatorConfig): {
|
|
24
|
+
verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
25
|
+
settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
26
|
+
supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
27
|
+
list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
28
|
+
};
|
|
29
|
+
declare const verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
30
|
+
declare const settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
31
|
+
declare const supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
32
|
+
declare const list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
33
|
+
|
|
34
|
+
type FacilitatorConfig = {
|
|
35
|
+
url: Resource;
|
|
36
|
+
createAuthHeaders?: CreateHeaders;
|
|
37
|
+
};
|
|
38
|
+
type PaywallConfig = {
|
|
39
|
+
cdpClientKey?: string;
|
|
40
|
+
appName?: string;
|
|
41
|
+
appLogo?: string;
|
|
42
|
+
sessionTokenEndpoint?: string;
|
|
43
|
+
};
|
|
44
|
+
type PaymentMiddlewareConfig = {
|
|
45
|
+
description?: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
maxTimeoutSeconds?: number;
|
|
48
|
+
inputSchema?: Omit<HTTPRequestStructure, "type" | "method">;
|
|
49
|
+
outputSchema?: object;
|
|
50
|
+
discoverable?: boolean;
|
|
51
|
+
customPaywallHtml?: string;
|
|
52
|
+
resource?: Resource;
|
|
53
|
+
errorMessages?: {
|
|
54
|
+
paymentRequired?: string;
|
|
55
|
+
invalidPayment?: string;
|
|
56
|
+
noMatchingRequirements?: string;
|
|
57
|
+
verificationFailed?: string;
|
|
58
|
+
settlementFailed?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
interface ERC20TokenAmount {
|
|
62
|
+
amount: string;
|
|
63
|
+
asset: {
|
|
64
|
+
address: `0x${string}`;
|
|
65
|
+
decimals: number;
|
|
66
|
+
eip712: {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface SPLTokenAmount {
|
|
73
|
+
amount: string;
|
|
74
|
+
asset: {
|
|
75
|
+
address: string;
|
|
76
|
+
decimals: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
type Price = Money | ERC20TokenAmount | SPLTokenAmount;
|
|
80
|
+
interface RouteConfig {
|
|
81
|
+
price: Price;
|
|
82
|
+
network: Network;
|
|
83
|
+
config?: PaymentMiddlewareConfig;
|
|
84
|
+
}
|
|
85
|
+
type RoutesConfig = Record<string, Price | RouteConfig>;
|
|
86
|
+
interface RoutePattern {
|
|
87
|
+
verb: string;
|
|
88
|
+
pattern: RegExp;
|
|
89
|
+
config: RouteConfig;
|
|
90
|
+
}
|
|
91
|
+
type Wallet = EvmSigner;
|
|
92
|
+
|
|
93
|
+
export { type CreateHeaders as C, type ERC20TokenAmount as E, type FacilitatorConfig as F, type Money as M, type Price as P, type RoutesConfig as R, type SPLTokenAmount as S, type Wallet as W, type RoutePattern as a, type Resource as b, type PaywallConfig as c, type PaymentMiddlewareConfig as d, type RouteConfig as e, supported as f, list as l, moneySchema as m, settle as s, useFacilitator as u, verify as v };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { N as Network } from './network-RtNddYQk.js';
|
|
3
|
+
import { E as EvmSigner } from './wallet-gP8Qoi-c.js';
|
|
4
|
+
import { a as PaymentPayload, P as PaymentRequirements, J as VerifyResponse, S as SettleResponse, X as SupportedPaymentKindsResponse, M as ListDiscoveryResourcesRequest, O as ListDiscoveryResourcesResponse, z as HTTPRequestStructure } from './x402Specs-qMujgEV5.js';
|
|
5
|
+
|
|
6
|
+
declare const moneySchema: z.ZodPipeline<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNumber]>, z.ZodNumber>;
|
|
7
|
+
type Money = z.input<typeof moneySchema>;
|
|
8
|
+
|
|
9
|
+
type Resource = `${string}://${string}`;
|
|
10
|
+
|
|
11
|
+
type CreateHeaders = () => Promise<{
|
|
12
|
+
verify: Record<string, string>;
|
|
13
|
+
settle: Record<string, string>;
|
|
14
|
+
supported: Record<string, string>;
|
|
15
|
+
list?: Record<string, string>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a facilitator client for interacting with the X402 payment facilitator service
|
|
19
|
+
*
|
|
20
|
+
* @param facilitator - The facilitator config to use. If not provided, the default facilitator will be used.
|
|
21
|
+
* @returns An object containing verify and settle functions for interacting with the facilitator
|
|
22
|
+
*/
|
|
23
|
+
declare function useFacilitator(facilitator?: FacilitatorConfig): {
|
|
24
|
+
verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
25
|
+
settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
26
|
+
supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
27
|
+
list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
28
|
+
};
|
|
29
|
+
declare const verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
30
|
+
declare const settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
31
|
+
declare const supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
32
|
+
declare const list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
33
|
+
|
|
34
|
+
type FacilitatorConfig = {
|
|
35
|
+
url: Resource;
|
|
36
|
+
createAuthHeaders?: CreateHeaders;
|
|
37
|
+
};
|
|
38
|
+
type PaywallConfig = {
|
|
39
|
+
cdpClientKey?: string;
|
|
40
|
+
appName?: string;
|
|
41
|
+
appLogo?: string;
|
|
42
|
+
sessionTokenEndpoint?: string;
|
|
43
|
+
};
|
|
44
|
+
type PaymentMiddlewareConfig = {
|
|
45
|
+
description?: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
maxTimeoutSeconds?: number;
|
|
48
|
+
inputSchema?: Omit<HTTPRequestStructure, "type" | "method">;
|
|
49
|
+
outputSchema?: object;
|
|
50
|
+
discoverable?: boolean;
|
|
51
|
+
customPaywallHtml?: string;
|
|
52
|
+
resource?: Resource;
|
|
53
|
+
errorMessages?: {
|
|
54
|
+
paymentRequired?: string;
|
|
55
|
+
invalidPayment?: string;
|
|
56
|
+
noMatchingRequirements?: string;
|
|
57
|
+
verificationFailed?: string;
|
|
58
|
+
settlementFailed?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
interface ERC20TokenAmount {
|
|
62
|
+
amount: string;
|
|
63
|
+
asset: {
|
|
64
|
+
address: `0x${string}`;
|
|
65
|
+
decimals: number;
|
|
66
|
+
eip712: {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface SPLTokenAmount {
|
|
73
|
+
amount: string;
|
|
74
|
+
asset: {
|
|
75
|
+
address: string;
|
|
76
|
+
decimals: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
type Price = Money | ERC20TokenAmount | SPLTokenAmount;
|
|
80
|
+
interface RouteConfig {
|
|
81
|
+
price: Price;
|
|
82
|
+
network: Network;
|
|
83
|
+
config?: PaymentMiddlewareConfig;
|
|
84
|
+
}
|
|
85
|
+
type RoutesConfig = Record<string, Price | RouteConfig>;
|
|
86
|
+
interface RoutePattern {
|
|
87
|
+
verb: string;
|
|
88
|
+
pattern: RegExp;
|
|
89
|
+
config: RouteConfig;
|
|
90
|
+
}
|
|
91
|
+
type Wallet = EvmSigner;
|
|
92
|
+
|
|
93
|
+
export { type CreateHeaders as C, type ERC20TokenAmount as E, type FacilitatorConfig as F, type Money as M, type Price as P, type RoutesConfig as R, type SPLTokenAmount as S, type Wallet as W, type RoutePattern as a, type Resource as b, type PaywallConfig as c, type PaymentMiddlewareConfig as d, type RouteConfig as e, supported as f, list as l, moneySchema as m, settle as s, useFacilitator as u, verify as v };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { N as Network } from './network-RtNddYQk.js';
|
|
3
|
+
import { E as EvmSigner } from './wallet-gP8Qoi-c.js';
|
|
4
|
+
import { a as PaymentPayload, P as PaymentRequirements, u as VerifyResponse, S as SettleResponse, F as SupportedPaymentKindsResponse, w as ListDiscoveryResourcesRequest, z as ListDiscoveryResourcesResponse, m as HTTPRequestStructure } from './x402Specs-B7InXo2L.js';
|
|
5
|
+
|
|
6
|
+
declare const moneySchema: z.ZodPipeline<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNumber]>, z.ZodNumber>;
|
|
7
|
+
type Money = z.input<typeof moneySchema>;
|
|
8
|
+
|
|
9
|
+
type Resource = `${string}://${string}`;
|
|
10
|
+
|
|
11
|
+
type CreateHeaders = () => Promise<{
|
|
12
|
+
verify: Record<string, string>;
|
|
13
|
+
settle: Record<string, string>;
|
|
14
|
+
supported: Record<string, string>;
|
|
15
|
+
list?: Record<string, string>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a facilitator client for interacting with the X402 payment facilitator service
|
|
19
|
+
*
|
|
20
|
+
* @param facilitator - The facilitator config to use. If not provided, the default facilitator will be used.
|
|
21
|
+
* @returns An object containing verify and settle functions for interacting with the facilitator
|
|
22
|
+
*/
|
|
23
|
+
declare function useFacilitator(facilitator?: FacilitatorConfig): {
|
|
24
|
+
verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
25
|
+
settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
26
|
+
supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
27
|
+
list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
28
|
+
};
|
|
29
|
+
declare const verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
30
|
+
declare const settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
31
|
+
declare const supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
32
|
+
declare const list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
33
|
+
|
|
34
|
+
type FacilitatorConfig = {
|
|
35
|
+
url: Resource;
|
|
36
|
+
createAuthHeaders?: CreateHeaders;
|
|
37
|
+
};
|
|
38
|
+
type PaywallConfig = {
|
|
39
|
+
cdpClientKey?: string;
|
|
40
|
+
appName?: string;
|
|
41
|
+
appLogo?: string;
|
|
42
|
+
sessionTokenEndpoint?: string;
|
|
43
|
+
};
|
|
44
|
+
type PaymentMiddlewareConfig = {
|
|
45
|
+
description?: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
maxTimeoutSeconds?: number;
|
|
48
|
+
inputSchema?: Omit<HTTPRequestStructure, "type" | "method">;
|
|
49
|
+
outputSchema?: object;
|
|
50
|
+
discoverable?: boolean;
|
|
51
|
+
customPaywallHtml?: string;
|
|
52
|
+
resource?: Resource;
|
|
53
|
+
errorMessages?: {
|
|
54
|
+
paymentRequired?: string;
|
|
55
|
+
invalidPayment?: string;
|
|
56
|
+
noMatchingRequirements?: string;
|
|
57
|
+
verificationFailed?: string;
|
|
58
|
+
settlementFailed?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
interface ERC20TokenAmount {
|
|
62
|
+
amount: string;
|
|
63
|
+
asset: {
|
|
64
|
+
address: `0x${string}`;
|
|
65
|
+
decimals: number;
|
|
66
|
+
eip712: {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface SPLTokenAmount {
|
|
73
|
+
amount: string;
|
|
74
|
+
asset: {
|
|
75
|
+
address: string;
|
|
76
|
+
decimals: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
type Price = Money | ERC20TokenAmount | SPLTokenAmount;
|
|
80
|
+
interface RouteConfig {
|
|
81
|
+
price: Price;
|
|
82
|
+
network: Network;
|
|
83
|
+
config?: PaymentMiddlewareConfig;
|
|
84
|
+
}
|
|
85
|
+
type RoutesConfig = Record<string, Price | RouteConfig>;
|
|
86
|
+
interface RoutePattern {
|
|
87
|
+
verb: string;
|
|
88
|
+
pattern: RegExp;
|
|
89
|
+
config: RouteConfig;
|
|
90
|
+
}
|
|
91
|
+
type Wallet = EvmSigner;
|
|
92
|
+
|
|
93
|
+
export { type CreateHeaders as C, type ERC20TokenAmount as E, type FacilitatorConfig as F, type Money as M, type Price as P, type RoutesConfig as R, type SPLTokenAmount as S, type Wallet as W, type RoutePattern as a, type Resource as b, type PaywallConfig as c, type PaymentMiddlewareConfig as d, type RouteConfig as e, supported as f, list as l, moneySchema as m, settle as s, useFacilitator as u, verify as v };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { N as Network } from './network-FrFmmiyj.js';
|
|
3
|
+
import { E as EvmSigner } from './wallet-gP8Qoi-c.js';
|
|
4
|
+
import { a as PaymentPayload, P as PaymentRequirements, J as VerifyResponse, S as SettleResponse, X as SupportedPaymentKindsResponse, M as ListDiscoveryResourcesRequest, O as ListDiscoveryResourcesResponse, z as HTTPRequestStructure } from './x402Specs-CYq5tSY1.js';
|
|
5
|
+
|
|
6
|
+
declare const moneySchema: z.ZodPipeline<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNumber]>, z.ZodNumber>;
|
|
7
|
+
type Money = z.input<typeof moneySchema>;
|
|
8
|
+
|
|
9
|
+
type Resource = `${string}://${string}`;
|
|
10
|
+
|
|
11
|
+
type CreateHeaders = () => Promise<{
|
|
12
|
+
verify: Record<string, string>;
|
|
13
|
+
settle: Record<string, string>;
|
|
14
|
+
supported: Record<string, string>;
|
|
15
|
+
list?: Record<string, string>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a facilitator client for interacting with the X402 payment facilitator service
|
|
19
|
+
*
|
|
20
|
+
* @param facilitator - The facilitator config to use. If not provided, the default facilitator will be used.
|
|
21
|
+
* @returns An object containing verify and settle functions for interacting with the facilitator
|
|
22
|
+
*/
|
|
23
|
+
declare function useFacilitator(facilitator?: FacilitatorConfig): {
|
|
24
|
+
verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
25
|
+
settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
26
|
+
supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
27
|
+
list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
28
|
+
};
|
|
29
|
+
declare const verify: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<VerifyResponse>;
|
|
30
|
+
declare const settle: (payload: PaymentPayload, paymentRequirements: PaymentRequirements) => Promise<SettleResponse>;
|
|
31
|
+
declare const supported: () => Promise<SupportedPaymentKindsResponse>;
|
|
32
|
+
declare const list: (config?: ListDiscoveryResourcesRequest) => Promise<ListDiscoveryResourcesResponse>;
|
|
33
|
+
|
|
34
|
+
type FacilitatorConfig = {
|
|
35
|
+
url: Resource;
|
|
36
|
+
createAuthHeaders?: CreateHeaders;
|
|
37
|
+
};
|
|
38
|
+
type PaywallConfig = {
|
|
39
|
+
cdpClientKey?: string;
|
|
40
|
+
appName?: string;
|
|
41
|
+
appLogo?: string;
|
|
42
|
+
sessionTokenEndpoint?: string;
|
|
43
|
+
};
|
|
44
|
+
type PaymentMiddlewareConfig = {
|
|
45
|
+
description?: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
maxTimeoutSeconds?: number;
|
|
48
|
+
inputSchema?: Omit<HTTPRequestStructure, "type" | "method">;
|
|
49
|
+
outputSchema?: object;
|
|
50
|
+
discoverable?: boolean;
|
|
51
|
+
customPaywallHtml?: string;
|
|
52
|
+
resource?: Resource;
|
|
53
|
+
errorMessages?: {
|
|
54
|
+
paymentRequired?: string;
|
|
55
|
+
invalidPayment?: string;
|
|
56
|
+
noMatchingRequirements?: string;
|
|
57
|
+
verificationFailed?: string;
|
|
58
|
+
settlementFailed?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
interface ERC20TokenAmount {
|
|
62
|
+
amount: string;
|
|
63
|
+
asset: {
|
|
64
|
+
address: `0x${string}`;
|
|
65
|
+
decimals: number;
|
|
66
|
+
eip712: {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface SPLTokenAmount {
|
|
73
|
+
amount: string;
|
|
74
|
+
asset: {
|
|
75
|
+
address: string;
|
|
76
|
+
decimals: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
type Price = Money | ERC20TokenAmount | SPLTokenAmount;
|
|
80
|
+
interface RouteConfig {
|
|
81
|
+
price: Price;
|
|
82
|
+
network: Network;
|
|
83
|
+
config?: PaymentMiddlewareConfig;
|
|
84
|
+
}
|
|
85
|
+
type RoutesConfig = Record<string, Price | RouteConfig>;
|
|
86
|
+
interface RoutePattern {
|
|
87
|
+
verb: string;
|
|
88
|
+
pattern: RegExp;
|
|
89
|
+
config: RouteConfig;
|
|
90
|
+
}
|
|
91
|
+
type Wallet = EvmSigner;
|
|
92
|
+
|
|
93
|
+
export { type CreateHeaders as C, type ERC20TokenAmount as E, type FacilitatorConfig as F, type Money as M, type Price as P, type RoutesConfig as R, type SPLTokenAmount as S, type Wallet as W, type RoutePattern as a, type Resource as b, type PaywallConfig as c, type PaymentMiddlewareConfig as d, type RouteConfig as e, supported as f, list as l, moneySchema as m, settle as s, useFacilitator as u, verify as v };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const NetworkSchema: z.ZodEnum<["base-sepolia", "base", "avalanche-fuji", "avalanche", "iotex", "solana-devnet", "solana", "sei", "sei-testnet", "polygon", "polygon-amoy", "peaq", "bsc", "bsc-testnet"]>;
|
|
4
|
+
type Network = z.infer<typeof NetworkSchema>;
|
|
5
|
+
declare const SupportedEVMNetworks: Network[];
|
|
6
|
+
declare const EvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "bsc" | "bsc-testnet" | "solana-devnet" | "solana", number>;
|
|
7
|
+
declare const SupportedSVMNetworks: Network[];
|
|
8
|
+
declare const SvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "bsc" | "bsc-testnet" | "solana-devnet" | "solana", number>;
|
|
9
|
+
declare const ChainIdToNetwork: Record<number, Network>;
|
|
10
|
+
|
|
11
|
+
export { ChainIdToNetwork as C, EvmNetworkToChainId as E, type Network as N, SupportedEVMNetworks as S, NetworkSchema as a, SupportedSVMNetworks as b, SvmNetworkToChainId as c };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const NetworkSchema: z.ZodEnum<["base-sepolia", "base", "avalanche-fuji", "avalanche", "iotex", "solana-devnet", "solana", "sei", "sei-testnet", "polygon", "polygon-amoy", "peaq"]>;
|
|
4
|
+
type Network = z.infer<typeof NetworkSchema>;
|
|
5
|
+
declare const SupportedEVMNetworks: Network[];
|
|
6
|
+
declare const EvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "solana-devnet" | "solana", number>;
|
|
7
|
+
declare const SupportedSVMNetworks: Network[];
|
|
8
|
+
declare const SvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "solana-devnet" | "solana", number>;
|
|
9
|
+
declare const ChainIdToNetwork: Record<number, Network>;
|
|
10
|
+
|
|
11
|
+
export { ChainIdToNetwork as C, EvmNetworkToChainId as E, type Network as N, SupportedEVMNetworks as S, NetworkSchema as a, SupportedSVMNetworks as b, SvmNetworkToChainId as c };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { P as PaymentRequirements } from '../x402Specs-CYq5tSY1.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
interface PaywallOptions {
|
|
5
|
+
amount: number;
|
|
6
|
+
paymentRequirements: PaymentRequirements[];
|
|
7
|
+
currentUrl: string;
|
|
8
|
+
testnet: boolean;
|
|
9
|
+
cdpClientKey?: string;
|
|
10
|
+
appName?: string;
|
|
11
|
+
appLogo?: string;
|
|
12
|
+
sessionTokenEndpoint?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates an HTML paywall page that allows users to pay for content access
|
|
16
|
+
*
|
|
17
|
+
* @param options - The options for generating the paywall
|
|
18
|
+
* @param options.amount - The amount to be paid in USD
|
|
19
|
+
* @param options.paymentRequirements - The payment requirements for the content
|
|
20
|
+
* @param options.currentUrl - The URL of the content being accessed
|
|
21
|
+
* @param options.testnet - Whether to use testnet or mainnet
|
|
22
|
+
* @param options.cdpClientKey - CDP client API key for OnchainKit
|
|
23
|
+
* @param options.appName - The name of the application to display in the wallet connection modal
|
|
24
|
+
* @param options.appLogo - The logo of the application to display in the wallet connection modal
|
|
25
|
+
* @param options.sessionTokenEndpoint - The API endpoint for generating session tokens for Onramp authentication
|
|
26
|
+
* @returns An HTML string containing the paywall page
|
|
27
|
+
*/
|
|
28
|
+
declare function getPaywallHtml({ amount, testnet, paymentRequirements, currentUrl, cdpClientKey, appName, appLogo, sessionTokenEndpoint, }: PaywallOptions): string;
|
|
29
|
+
|
|
30
|
+
export { getPaywallHtml };
|