sf-x402x 0.6.6-patch.3 → 0.7.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.
Files changed (72) hide show
  1. package/dist/cjs/client/index.d.ts +2 -2
  2. package/dist/cjs/client/index.js +52 -17
  3. package/dist/cjs/client/index.js.map +1 -1
  4. package/dist/{esm/config-CFBSAuxW.d.mts → cjs/config-21jxVzCt.d.ts} +1 -0
  5. package/dist/cjs/facilitator/index.d.ts +1 -1
  6. package/dist/cjs/facilitator/index.js +52 -17
  7. package/dist/cjs/facilitator/index.js.map +1 -1
  8. package/dist/cjs/index.d.ts +2 -2
  9. package/dist/cjs/index.js +52 -17
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/middleware-5zVJ5R-N.d.ts +93 -0
  12. package/dist/{esm/network--RYzQfBg.d.mts → cjs/network-BkSsZzNC.d.ts} +3 -3
  13. package/dist/cjs/paywall/index.d.ts +1 -1
  14. package/dist/cjs/paywall/index.js +45 -16
  15. package/dist/cjs/paywall/index.js.map +1 -1
  16. package/dist/{esm/rpc-22QIQWIu.d.mts → cjs/rpc-MOfP_dWc.d.ts} +1 -1
  17. package/dist/cjs/schemes/index.d.ts +3 -3
  18. package/dist/cjs/schemes/index.js +52 -17
  19. package/dist/cjs/schemes/index.js.map +1 -1
  20. package/dist/cjs/shared/evm/index.d.ts +1 -1
  21. package/dist/cjs/shared/evm/index.js +45 -16
  22. package/dist/cjs/shared/evm/index.js.map +1 -1
  23. package/dist/cjs/shared/index.d.ts +5 -5
  24. package/dist/cjs/shared/index.js +53 -18
  25. package/dist/cjs/shared/index.js.map +1 -1
  26. package/dist/cjs/types/index.d.ts +10 -10
  27. package/dist/cjs/types/index.js +52 -17
  28. package/dist/cjs/types/index.js.map +1 -1
  29. package/dist/cjs/verify/index.d.ts +3 -3
  30. package/dist/cjs/verify/index.js +7 -1
  31. package/dist/cjs/verify/index.js.map +1 -1
  32. package/dist/{esm/x402Specs-7OH8g851.d.mts → cjs/x402Specs-CqECt1ac.d.ts} +73 -73
  33. package/dist/esm/{chunk-WS2W5DJT.mjs → chunk-JLKXOYVK.mjs} +3 -3
  34. package/dist/esm/{chunk-R2NI44QI.mjs → chunk-KIDCIVC3.mjs} +3 -3
  35. package/dist/esm/{chunk-MWDK4RSB.mjs → chunk-QNNM7SGM.mjs} +5 -5
  36. package/dist/esm/{chunk-Z3INM7T4.mjs → chunk-U5KNHXVP.mjs} +4 -4
  37. package/dist/esm/{chunk-5UPAZUO6.mjs → chunk-UD3U554N.mjs} +46 -17
  38. package/dist/esm/chunk-UD3U554N.mjs.map +1 -0
  39. package/dist/esm/{chunk-XZA3USQF.mjs → chunk-WQJKXB4L.mjs} +11 -5
  40. package/dist/esm/chunk-WQJKXB4L.mjs.map +1 -0
  41. package/dist/esm/{chunk-7CWEZNFA.mjs → chunk-YHBBWW7M.mjs} +2 -2
  42. package/dist/esm/client/index.d.mts +2 -2
  43. package/dist/esm/client/index.mjs +5 -5
  44. package/dist/esm/config-21jxVzCt.d.mts +11 -0
  45. package/dist/esm/facilitator/index.d.mts +1 -1
  46. package/dist/esm/facilitator/index.mjs +6 -6
  47. package/dist/esm/index.d.mts +2 -2
  48. package/dist/esm/index.mjs +7 -7
  49. package/dist/esm/{middleware-CAOp-bv4.d.mts → middleware-DON8RJFB.d.mts} +2 -2
  50. package/dist/esm/network-BkSsZzNC.d.mts +11 -0
  51. package/dist/esm/paywall/index.d.mts +1 -1
  52. package/dist/esm/paywall/index.mjs +1 -1
  53. package/dist/esm/rpc-DXTxMYe2.d.mts +35 -0
  54. package/dist/esm/schemes/index.d.mts +3 -3
  55. package/dist/esm/schemes/index.mjs +5 -5
  56. package/dist/esm/shared/evm/index.d.mts +1 -1
  57. package/dist/esm/shared/evm/index.mjs +2 -2
  58. package/dist/esm/shared/index.d.mts +5 -5
  59. package/dist/esm/shared/index.mjs +3 -3
  60. package/dist/esm/types/index.d.mts +10 -10
  61. package/dist/esm/types/index.mjs +3 -3
  62. package/dist/esm/verify/index.d.mts +3 -3
  63. package/dist/esm/verify/index.mjs +3 -3
  64. package/dist/esm/x402Specs-CqECt1ac.d.mts +1306 -0
  65. package/package.json +15 -15
  66. package/dist/esm/chunk-5UPAZUO6.mjs.map +0 -1
  67. package/dist/esm/chunk-XZA3USQF.mjs.map +0 -1
  68. /package/dist/esm/{chunk-WS2W5DJT.mjs.map → chunk-JLKXOYVK.mjs.map} +0 -0
  69. /package/dist/esm/{chunk-R2NI44QI.mjs.map → chunk-KIDCIVC3.mjs.map} +0 -0
  70. /package/dist/esm/{chunk-MWDK4RSB.mjs.map → chunk-QNNM7SGM.mjs.map} +0 -0
  71. /package/dist/esm/{chunk-Z3INM7T4.mjs.map → chunk-U5KNHXVP.mjs.map} +0 -0
  72. /package/dist/esm/{chunk-7CWEZNFA.mjs.map → chunk-YHBBWW7M.mjs.map} +0 -0
@@ -0,0 +1,93 @@
1
+ import { z } from 'zod';
2
+ import { N as Network } from './network-BkSsZzNC.js';
3
+ import { E as EvmSigner } from './wallet-BReyvAJs.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-CqECt1ac.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 };
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const NetworkSchema: z.ZodEnum<["base-sepolia", "base", "avalanche-fuji", "avalanche", "iotex", "solana-devnet", "solana", "sei", "sei-testnet", "polygon", "polygon-amoy", "peaq", "x-layer", "x-layer-testnet", "sepolia", "filecoin-calibration"]>;
3
+ declare const NetworkSchema: z.ZodEnum<["base-sepolia", "base", "avalanche-fuji", "avalanche", "iotex", "solana-devnet", "solana", "sei", "sei-testnet", "ethereum", "polygon", "polygon-amoy", "peaq", "x-layer", "x-layer-testnet", "sepolia", "filecoin", "filecoin-calibration"]>;
4
4
  type Network = z.infer<typeof NetworkSchema>;
5
5
  declare const SupportedEVMNetworks: Network[];
6
- declare const EvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "x-layer" | "x-layer-testnet" | "solana-devnet" | "solana" | "sepolia" | "filecoin-calibration", number>;
6
+ declare const EvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "x-layer" | "x-layer-testnet" | "solana-devnet" | "solana" | "ethereum" | "sepolia" | "filecoin" | "filecoin-calibration", number>;
7
7
  declare const SupportedSVMNetworks: Network[];
8
- declare const SvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "x-layer" | "x-layer-testnet" | "solana-devnet" | "solana" | "sepolia" | "filecoin-calibration", number>;
8
+ declare const SvmNetworkToChainId: Map<"base-sepolia" | "avalanche-fuji" | "base" | "avalanche" | "sei" | "sei-testnet" | "polygon" | "polygon-amoy" | "peaq" | "iotex" | "x-layer" | "x-layer-testnet" | "solana-devnet" | "solana" | "ethereum" | "sepolia" | "filecoin" | "filecoin-calibration", number>;
9
9
  declare const ChainIdToNetwork: Record<number, Network>;
10
10
 
11
11
  export { ChainIdToNetwork as C, EvmNetworkToChainId as E, type Network as N, SupportedEVMNetworks as S, NetworkSchema as a, SupportedSVMNetworks as b, SvmNetworkToChainId as c };
@@ -1,4 +1,4 @@
1
- import { P as PaymentRequirements } from '../x402Specs-7OH8g851.js';
1
+ import { P as PaymentRequirements } from '../x402Specs-CqECt1ac.js';
2
2
  import 'zod';
3
3
 
4
4
  interface PaywallOptions {
@@ -31,71 +31,100 @@ var PAYWALL_TEMPLATE = '<!DOCTYPE html><html lang="en"><head>\n <meta cha
31
31
  var config = {
32
32
  "84532": {
33
33
  usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
34
- usdcName: "USDC"
34
+ usdcName: "USDC",
35
+ decimals: 6
35
36
  },
36
37
  "8453": {
37
38
  usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
38
- usdcName: "USD Coin"
39
+ usdcName: "USD Coin",
40
+ decimals: 6
39
41
  },
40
42
  "43113": {
41
43
  usdcAddress: "0x5425890298aed601595a70AB815c96711a31Bc65",
42
- usdcName: "USD Coin"
44
+ usdcName: "USD Coin",
45
+ decimals: 6
43
46
  },
44
47
  "43114": {
45
48
  usdcAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
46
- usdcName: "USD Coin"
49
+ usdcName: "USD Coin",
50
+ decimals: 6
47
51
  },
48
52
  "4689": {
49
53
  usdcAddress: "0xcdf79194c6c285077a58da47641d4dbe51f63542",
50
- usdcName: "Bridged USDC"
54
+ usdcName: "Bridged USDC",
55
+ decimals: 6
51
56
  },
52
57
  // solana devnet
53
58
  "103": {
54
59
  usdcAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
55
- usdcName: "USDC"
60
+ usdcName: "USDC",
61
+ decimals: 6
56
62
  },
57
63
  // solana mainnet
58
64
  "101": {
59
65
  usdcAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
60
- usdcName: "USDC"
66
+ usdcName: "USDC",
67
+ decimals: 6
61
68
  },
62
69
  "1328": {
63
70
  usdcAddress: "0x4fcf1784b31630811181f670aea7a7bef803eaed",
64
- usdcName: "USDC"
71
+ usdcName: "USDC",
72
+ decimals: 6
65
73
  },
66
74
  "1329": {
67
75
  usdcAddress: "0xe15fc38f6d8c56af07bbcbe3baf5708a2bf42392",
68
- usdcName: "USDC"
76
+ usdcName: "USDC",
77
+ decimals: 6
69
78
  },
70
79
  "137": {
71
80
  usdcAddress: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
72
- usdcName: "USD Coin"
81
+ usdcName: "USD Coin",
82
+ decimals: 6
73
83
  },
74
84
  "80002": {
75
85
  usdcAddress: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
76
- usdcName: "USDC"
86
+ usdcName: "USDC",
87
+ decimals: 6
77
88
  },
78
89
  "3338": {
79
90
  usdcAddress: "0xbbA60da06c2c5424f03f7434542280FCAd453d10",
80
- usdcName: "USDC"
91
+ usdcName: "USDC",
92
+ decimals: 6
81
93
  },
82
94
  "196": {
83
95
  usdcAddress: "0x74b7f16337b8972027f6196a17a631ac6de26d22",
84
- usdcName: "USD Coin"
96
+ usdcName: "USD Coin",
97
+ decimals: 6
85
98
  },
86
99
  "1952": {
87
100
  usdcAddress: "0xcb8bf24c6ce16ad21d707c9505421a17f2bec79d",
88
- usdcName: "USDC_TEST"
101
+ usdcName: "USDC_TEST",
102
+ decimals: 6
103
+ },
104
+ // ethereum mainnet
105
+ "1": {
106
+ usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
107
+ usdcName: "USD Coin",
108
+ decimals: 6
89
109
  },
90
110
  // sepolia - using JPYC (JPY Coin)
91
111
  "11155111": {
92
112
  usdcAddress: "0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29",
93
- usdcName: "JPY Coin"
113
+ usdcName: "JPY Coin",
114
+ decimals: 18
115
+ // JPYC uses 18 decimals
116
+ },
117
+ // filecoin mainnet
118
+ "314": {
119
+ usdcAddress: "0x2421db204968A367CC2C866CD057fA754Cb84EdF",
120
+ usdcName: "USD Coin",
121
+ decimals: 6
94
122
  },
95
123
  // filecoin-calibration - using USD for Filecoin Community
96
124
  "314159": {
97
125
  usdcAddress: "0xb3042734b608a1B16e9e86B374A3f3e389B4cDf0",
98
- usdcName: "USD for Filecoin Community"
126
+ usdcName: "USD for Filecoin Community",
127
+ decimals: 6
99
128
  }
100
129
  };
101
130