facinet 2.2.2 → 2.4.1
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 +248 -244
- package/dist/browser.js +2773 -27534
- package/dist/browser.js.map +4 -4
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +7 -8
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/facilitator.d.ts +4 -15
- package/dist/commands/facilitator.d.ts.map +1 -1
- package/dist/commands/facilitator.js +40 -36
- package/dist/commands/facilitator.js.map +1 -1
- package/dist/commands/pay.d.ts +1 -8
- package/dist/commands/pay.d.ts.map +1 -1
- package/dist/commands/pay.js +47 -35
- package/dist/commands/pay.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +659 -92
- package/dist/index.js.map +7 -1
- package/dist/sdk/Facinet.d.ts +21 -5
- package/dist/sdk/Facinet.d.ts.map +1 -1
- package/dist/sdk/Facinet.js +165 -62
- package/dist/sdk/Facinet.js.map +1 -1
- package/dist/sdk/types.d.ts +8 -2
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +386 -25
- package/dist/sdk.js.map +7 -1
- package/dist/sdk.mjs +140 -45
- package/dist/sdk.mjs.map +2 -2
- package/dist/utils/api.d.ts +18 -13
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +33 -40
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/config.d.ts +2 -9
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +0 -1
- package/dist/utils/config.js.map +1 -1
- package/package.json +4 -2
package/dist/sdk/types.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ export interface FacinetConfig {
|
|
|
14
14
|
privateKey?: string;
|
|
15
15
|
/**
|
|
16
16
|
* Network to use
|
|
17
|
-
* @default 'avalanche'
|
|
17
|
+
* @default 'avalanche-fuji'
|
|
18
18
|
*/
|
|
19
|
-
network?: 'avalanche' | 'ethereum' | 'polygon';
|
|
19
|
+
network?: 'avalanche-fuji' | 'ethereum-sepolia' | 'base-sepolia' | 'polygon-amoy' | 'avalanche' | 'ethereum' | 'polygon' | 'base';
|
|
20
20
|
/**
|
|
21
21
|
* Custom RPC URL (optional)
|
|
22
22
|
*/
|
|
@@ -74,13 +74,19 @@ export interface Facilitator {
|
|
|
74
74
|
status: 'active' | 'inactive' | 'needs_funding';
|
|
75
75
|
totalPayments: number;
|
|
76
76
|
gasBalance?: string;
|
|
77
|
+
network?: string;
|
|
78
|
+
chainId?: number;
|
|
77
79
|
}
|
|
78
80
|
export interface ChainConfig {
|
|
79
81
|
name: string;
|
|
82
|
+
displayName: string;
|
|
80
83
|
chainId: number;
|
|
81
84
|
rpcUrl: string;
|
|
82
85
|
usdcAddress: `0x${string}`;
|
|
86
|
+
usdcDecimals: number;
|
|
83
87
|
gasToken: string;
|
|
84
88
|
blockExplorer: string;
|
|
89
|
+
erc3009DomainName: string;
|
|
90
|
+
erc3009DomainVersion: string;
|
|
85
91
|
}
|
|
86
92
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/sdk/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sdk/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sdk/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;O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,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
|
package/dist/sdk.d.ts
CHANGED
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/sdk.js
CHANGED
|
@@ -1,26 +1,387 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/sdk.ts
|
|
31
|
+
var sdk_exports = {};
|
|
32
|
+
__export(sdk_exports, {
|
|
33
|
+
Facinet: () => Facinet,
|
|
34
|
+
default: () => Facinet
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(sdk_exports);
|
|
37
|
+
|
|
38
|
+
// src/sdk/Facinet.ts
|
|
39
|
+
var import_axios = __toESM(require("axios"));
|
|
40
|
+
var import_ethers = require("ethers");
|
|
41
|
+
var CHAINS = {
|
|
42
|
+
"avalanche-fuji": {
|
|
43
|
+
name: "avalanche-fuji",
|
|
44
|
+
displayName: "Avalanche Fuji",
|
|
45
|
+
chainId: 43113,
|
|
46
|
+
rpcUrl: "https://api.avax-test.network/ext/bc/C/rpc",
|
|
47
|
+
usdcAddress: "0x5425890298aed601595a70AB815c96711a31Bc65",
|
|
48
|
+
usdcDecimals: 6,
|
|
49
|
+
gasToken: "AVAX",
|
|
50
|
+
blockExplorer: "https://testnet.snowtrace.io",
|
|
51
|
+
erc3009DomainName: "USD Coin",
|
|
52
|
+
erc3009DomainVersion: "2"
|
|
53
|
+
},
|
|
54
|
+
"ethereum-sepolia": {
|
|
55
|
+
name: "ethereum-sepolia",
|
|
56
|
+
displayName: "Ethereum Sepolia",
|
|
57
|
+
chainId: 11155111,
|
|
58
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
59
|
+
usdcAddress: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
60
|
+
usdcDecimals: 6,
|
|
61
|
+
gasToken: "ETH",
|
|
62
|
+
blockExplorer: "https://sepolia.etherscan.io",
|
|
63
|
+
erc3009DomainName: "USDC",
|
|
64
|
+
erc3009DomainVersion: "2"
|
|
65
|
+
},
|
|
66
|
+
"base-sepolia": {
|
|
67
|
+
name: "base-sepolia",
|
|
68
|
+
displayName: "Base Sepolia",
|
|
69
|
+
chainId: 84532,
|
|
70
|
+
rpcUrl: "https://sepolia.base.org",
|
|
71
|
+
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
72
|
+
usdcDecimals: 6,
|
|
73
|
+
gasToken: "ETH",
|
|
74
|
+
blockExplorer: "https://sepolia.basescan.org",
|
|
75
|
+
erc3009DomainName: "USDC",
|
|
76
|
+
erc3009DomainVersion: "2"
|
|
77
|
+
},
|
|
78
|
+
"polygon-amoy": {
|
|
79
|
+
name: "polygon-amoy",
|
|
80
|
+
displayName: "Polygon Amoy",
|
|
81
|
+
chainId: 80002,
|
|
82
|
+
rpcUrl: "https://rpc-amoy.polygon.technology",
|
|
83
|
+
usdcAddress: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
|
|
84
|
+
usdcDecimals: 6,
|
|
85
|
+
gasToken: "MATIC",
|
|
86
|
+
blockExplorer: "https://amoy.polygonscan.com",
|
|
87
|
+
erc3009DomainName: "USDC",
|
|
88
|
+
erc3009DomainVersion: "2"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var NETWORK_ALIASES = {
|
|
92
|
+
"avalanche": "avalanche-fuji",
|
|
93
|
+
"ethereum": "ethereum-sepolia",
|
|
94
|
+
"polygon": "polygon-amoy",
|
|
95
|
+
"base": "base-sepolia"
|
|
96
|
+
};
|
|
97
|
+
var NETWORK_API_URLS = {
|
|
98
|
+
"avalanche-fuji": "https://x402-avalanche-chi.vercel.app",
|
|
99
|
+
"ethereum-sepolia": "https://x402-ethereum-chi.vercel.app",
|
|
100
|
+
"base-sepolia": "https://x402-base-chi.vercel.app",
|
|
101
|
+
"polygon-amoy": "https://x402-polygon-chi.vercel.app"
|
|
102
|
+
};
|
|
103
|
+
function resolveNetwork(network) {
|
|
104
|
+
return NETWORK_ALIASES[network] || network;
|
|
105
|
+
}
|
|
106
|
+
function getApiUrlForNetwork(network, customApiUrl) {
|
|
107
|
+
if (customApiUrl) {
|
|
108
|
+
return customApiUrl.replace(/\/$/, "");
|
|
109
|
+
}
|
|
110
|
+
const resolvedNetwork = resolveNetwork(network);
|
|
111
|
+
return NETWORK_API_URLS[resolvedNetwork] || NETWORK_API_URLS["avalanche-fuji"];
|
|
112
|
+
}
|
|
113
|
+
var Facinet = class _Facinet {
|
|
114
|
+
constructor(config = {}) {
|
|
115
|
+
const resolvedNetwork = resolveNetwork(config.network || "avalanche-fuji");
|
|
116
|
+
const apiUrl = getApiUrlForNetwork(resolvedNetwork, config.apiUrl);
|
|
117
|
+
this.config = {
|
|
118
|
+
apiUrl,
|
|
119
|
+
privateKey: config.privateKey || "",
|
|
120
|
+
network: resolvedNetwork,
|
|
121
|
+
rpcUrl: config.rpcUrl || ""
|
|
122
|
+
};
|
|
123
|
+
this.chain = CHAINS[resolvedNetwork];
|
|
124
|
+
if (!this.chain) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`Unsupported network: ${config.network}. Supported networks: ${Object.keys(CHAINS).join(", ")}`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (this.config.privateKey) {
|
|
130
|
+
const provider = new import_ethers.JsonRpcProvider(
|
|
131
|
+
this.config.rpcUrl || this.chain.rpcUrl
|
|
132
|
+
);
|
|
133
|
+
this.wallet = new import_ethers.Wallet(this.config.privateKey, provider);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get the current chain configuration
|
|
138
|
+
*/
|
|
139
|
+
getChain() {
|
|
140
|
+
return { ...this.chain };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get all supported chains
|
|
144
|
+
*/
|
|
145
|
+
static getSupportedChains() {
|
|
146
|
+
return Object.values(CHAINS);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get supported network names
|
|
150
|
+
*/
|
|
151
|
+
static getSupportedNetworks() {
|
|
152
|
+
return Object.keys(CHAINS);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Make a payment via x402 facilitator network
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const facinet = new Facinet({ network: 'base-sepolia' });
|
|
160
|
+
* const result = await facinet.pay({
|
|
161
|
+
* amount: '1',
|
|
162
|
+
* recipient: '0xMerchantAddress',
|
|
163
|
+
* payerAddress: '0xCustomerAddress'
|
|
164
|
+
* });
|
|
165
|
+
* console.log('Payment successful!', result.txHash);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
async pay(params) {
|
|
169
|
+
if (!params.amount || parseFloat(params.amount) <= 0) {
|
|
170
|
+
throw new Error("Invalid amount");
|
|
171
|
+
}
|
|
172
|
+
if (!params.recipient.match(/^0x[a-fA-F0-9]{40}$/)) {
|
|
173
|
+
throw new Error("Invalid recipient address");
|
|
174
|
+
}
|
|
175
|
+
let payerAddress = params.payerAddress || "";
|
|
176
|
+
if (!payerAddress) {
|
|
177
|
+
if (this.wallet) {
|
|
178
|
+
payerAddress = this.wallet.address;
|
|
179
|
+
} else if (typeof window !== "undefined" && window.ethereum) {
|
|
180
|
+
const accounts = await window.ethereum.request({
|
|
181
|
+
method: "eth_requestAccounts"
|
|
182
|
+
});
|
|
183
|
+
payerAddress = accounts[0];
|
|
184
|
+
} else {
|
|
185
|
+
throw new Error(
|
|
186
|
+
"No payer address provided and no wallet available. Provide payerAddress or privateKey in config."
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
payerAddress = payerAddress.toLowerCase();
|
|
191
|
+
const recipientAddress = params.recipient.toLowerCase();
|
|
192
|
+
const facilitator = await this.selectRandomFacilitator();
|
|
193
|
+
const amount = BigInt(parseFloat(params.amount) * 1e6);
|
|
194
|
+
const validAfter = Math.floor(Date.now() / 1e3) - 60;
|
|
195
|
+
const validBefore = validAfter + 3600;
|
|
196
|
+
const nonce = "0x" + Array.from(
|
|
197
|
+
{ length: 64 },
|
|
198
|
+
() => Math.floor(Math.random() * 16).toString(16)
|
|
199
|
+
).join("");
|
|
200
|
+
const domain = {
|
|
201
|
+
name: this.chain.erc3009DomainName,
|
|
202
|
+
version: this.chain.erc3009DomainVersion,
|
|
203
|
+
chainId: this.chain.chainId,
|
|
204
|
+
verifyingContract: this.chain.usdcAddress
|
|
205
|
+
};
|
|
206
|
+
const types = {
|
|
207
|
+
TransferWithAuthorization: [
|
|
208
|
+
{ name: "from", type: "address" },
|
|
209
|
+
{ name: "to", type: "address" },
|
|
210
|
+
{ name: "value", type: "uint256" },
|
|
211
|
+
{ name: "validAfter", type: "uint256" },
|
|
212
|
+
{ name: "validBefore", type: "uint256" },
|
|
213
|
+
{ name: "nonce", type: "bytes32" }
|
|
214
|
+
]
|
|
215
|
+
};
|
|
216
|
+
const value = {
|
|
217
|
+
from: payerAddress,
|
|
218
|
+
to: recipientAddress,
|
|
219
|
+
value: amount,
|
|
220
|
+
validAfter,
|
|
221
|
+
validBefore,
|
|
222
|
+
nonce
|
|
223
|
+
};
|
|
224
|
+
let signature;
|
|
225
|
+
if (this.wallet) {
|
|
226
|
+
signature = await this.wallet.signTypedData(domain, types, value);
|
|
227
|
+
} else if (typeof window !== "undefined" && window.ethereum) {
|
|
228
|
+
const { TypedDataEncoder } = await import("ethers");
|
|
229
|
+
const messageForSigning = {
|
|
230
|
+
from: payerAddress,
|
|
231
|
+
to: recipientAddress,
|
|
232
|
+
value: amount.toString(),
|
|
233
|
+
validAfter: validAfter.toString(),
|
|
234
|
+
validBefore: validBefore.toString(),
|
|
235
|
+
nonce
|
|
236
|
+
};
|
|
237
|
+
const typedDataPayload = JSON.stringify({
|
|
238
|
+
types: {
|
|
239
|
+
EIP712Domain: [
|
|
240
|
+
{ name: "name", type: "string" },
|
|
241
|
+
{ name: "version", type: "string" },
|
|
242
|
+
{ name: "chainId", type: "uint256" },
|
|
243
|
+
{ name: "verifyingContract", type: "address" }
|
|
244
|
+
],
|
|
245
|
+
TransferWithAuthorization: types.TransferWithAuthorization
|
|
246
|
+
},
|
|
247
|
+
domain,
|
|
248
|
+
primaryType: "TransferWithAuthorization",
|
|
249
|
+
message: messageForSigning
|
|
250
|
+
});
|
|
251
|
+
signature = await window.ethereum.request({
|
|
252
|
+
method: "eth_signTypedData_v4",
|
|
253
|
+
params: [payerAddress, typedDataPayload]
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
throw new Error("No signing method available");
|
|
257
|
+
}
|
|
258
|
+
const paymentPayload = {
|
|
259
|
+
signature,
|
|
260
|
+
authorization: {
|
|
261
|
+
from: payerAddress,
|
|
262
|
+
to: recipientAddress,
|
|
263
|
+
value: amount.toString(),
|
|
264
|
+
validAfter: validAfter.toString(),
|
|
265
|
+
validBefore: validBefore.toString(),
|
|
266
|
+
nonce
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
try {
|
|
270
|
+
const response = await import_axios.default.post(
|
|
271
|
+
`${this.config.apiUrl}/api/x402/settle-custom`,
|
|
272
|
+
{
|
|
273
|
+
facilitatorId: facilitator.id,
|
|
274
|
+
paymentPayload
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
if (!response.data.success) {
|
|
278
|
+
throw new Error(
|
|
279
|
+
response.data.error || response.data.message || "Payment failed"
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
success: true,
|
|
284
|
+
txHash: response.data.txHash,
|
|
285
|
+
facilitator: {
|
|
286
|
+
id: facilitator.id,
|
|
287
|
+
name: facilitator.name || `Facilitator ${facilitator.id.slice(0, 8)}`,
|
|
288
|
+
wallet: facilitator.facilitatorWallet
|
|
289
|
+
},
|
|
290
|
+
payment: {
|
|
291
|
+
from: payerAddress,
|
|
292
|
+
to: recipientAddress,
|
|
293
|
+
amount: params.amount,
|
|
294
|
+
network: this.config.network
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if (error.response?.data) {
|
|
299
|
+
const backendError = error.response.data.message || error.response.data.error;
|
|
300
|
+
throw new Error(`Payment failed: ${backendError}`);
|
|
301
|
+
}
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get all active facilitators for the current network
|
|
307
|
+
*/
|
|
308
|
+
async getFacilitators() {
|
|
309
|
+
try {
|
|
310
|
+
const response = await import_axios.default.get(
|
|
311
|
+
`${this.config.apiUrl}/api/facilitator/list`,
|
|
312
|
+
{
|
|
313
|
+
timeout: 1e4,
|
|
314
|
+
headers: {
|
|
315
|
+
"User-Agent": "Facinet-SDK/2.3.0"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
if (response.data.success && Array.isArray(response.data.facilitators)) {
|
|
320
|
+
return response.data.facilitators.filter((f) => {
|
|
321
|
+
if (f.status !== "active") {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
if (f.network) {
|
|
325
|
+
return f.network === this.config.network;
|
|
326
|
+
}
|
|
327
|
+
if (f.chainId !== void 0) {
|
|
328
|
+
return f.chainId === this.chain.chainId;
|
|
329
|
+
}
|
|
330
|
+
return true;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return [];
|
|
334
|
+
} catch (error) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
`Failed to fetch facilitators for ${this.chain.displayName} (${this.config.network}): ${error.message || "Unknown error"}`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Select a random active facilitator for the current network
|
|
342
|
+
*/
|
|
343
|
+
async selectRandomFacilitator() {
|
|
344
|
+
const facilitators = await this.getFacilitators();
|
|
345
|
+
if (facilitators.length === 0) {
|
|
346
|
+
throw new Error(
|
|
347
|
+
`No active facilitators available for ${this.chain.displayName} (${this.config.network}, Chain ID: ${this.chain.chainId}). Please check that facilitators are registered for this network. API URL: ${this.config.apiUrl}`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
const randomIndex = Math.floor(Math.random() * facilitators.length);
|
|
351
|
+
const selectedFacilitator = facilitators[randomIndex];
|
|
352
|
+
if (!selectedFacilitator.name) {
|
|
353
|
+
selectedFacilitator.name = `Facilitator ${selectedFacilitator.id.slice(0, 8)}`;
|
|
354
|
+
}
|
|
355
|
+
return selectedFacilitator;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Quick payment helper (static method)
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* // Pay on Base Sepolia
|
|
363
|
+
* await Facinet.quickPay({
|
|
364
|
+
* amount: '1',
|
|
365
|
+
* recipient: '0xMerchantAddress',
|
|
366
|
+
* privateKey: process.env.PRIVATE_KEY,
|
|
367
|
+
* network: 'base-sepolia'
|
|
368
|
+
* });
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
static async quickPay(params) {
|
|
372
|
+
const facinet = new _Facinet({
|
|
373
|
+
privateKey: params.privateKey,
|
|
374
|
+
network: params.network
|
|
375
|
+
});
|
|
376
|
+
return facinet.pay({
|
|
377
|
+
amount: params.amount,
|
|
378
|
+
recipient: params.recipient,
|
|
379
|
+
payerAddress: params.payerAddress
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
384
|
+
0 && (module.exports = {
|
|
385
|
+
Facinet
|
|
386
|
+
});
|
|
387
|
+
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/sdk.ts", "../src/sdk/Facinet.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Facinet SDK - Main Export\n *\n * Use this when installing as a library:\n * npm install facinet\n *\n * @example\n * ```typescript\n * import { Facinet } from 'facinet';\n *\n * const facinet = new Facinet({ network: 'base-sepolia' });\n * await facinet.pay({\n * amount: '1',\n * recipient: '0xYourAddress'\n * });\n * ```\n */\n\nexport { Facinet } from './sdk/Facinet';\nexport type {\n FacinetConfig,\n PaymentParams,\n PaymentResult,\n Facilitator,\n ChainConfig,\n} from './sdk/types';\nexport { Facinet as default } from './sdk/Facinet';\n", "/**\n * Facinet SDK - Main Class\n *\n * JavaScript/TypeScript SDK for integrating x402 payments\n * Supports multichain: Avalanche Fuji, Ethereum Sepolia, Base Sepolia, Polygon Amoy\n */\n\nimport axios from 'axios';\nimport { Wallet, JsonRpcProvider } from 'ethers';\nimport type { FacinetConfig, PaymentParams, PaymentResult, Facilitator, ChainConfig } from './types';\n\n// All 4 supported chains\nconst CHAINS: Record<string, ChainConfig> = {\n 'avalanche-fuji': {\n name: 'avalanche-fuji',\n displayName: 'Avalanche Fuji',\n chainId: 43113,\n rpcUrl: 'https://api.avax-test.network/ext/bc/C/rpc',\n usdcAddress: '0x5425890298aed601595a70AB815c96711a31Bc65',\n usdcDecimals: 6,\n gasToken: 'AVAX',\n blockExplorer: 'https://testnet.snowtrace.io',\n erc3009DomainName: 'USD Coin',\n erc3009DomainVersion: '2',\n },\n 'ethereum-sepolia': {\n name: 'ethereum-sepolia',\n displayName: 'Ethereum Sepolia',\n chainId: 11155111,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n usdcAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n usdcDecimals: 6,\n gasToken: 'ETH',\n blockExplorer: 'https://sepolia.etherscan.io',\n erc3009DomainName: 'USDC',\n erc3009DomainVersion: '2',\n },\n 'base-sepolia': {\n name: 'base-sepolia',\n displayName: 'Base Sepolia',\n chainId: 84532,\n rpcUrl: 'https://sepolia.base.org',\n usdcAddress: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n usdcDecimals: 6,\n gasToken: 'ETH',\n blockExplorer: 'https://sepolia.basescan.org',\n erc3009DomainName: 'USDC',\n erc3009DomainVersion: '2',\n },\n 'polygon-amoy': {\n name: 'polygon-amoy',\n displayName: 'Polygon Amoy',\n chainId: 80002,\n rpcUrl: 'https://rpc-amoy.polygon.technology',\n usdcAddress: '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582',\n usdcDecimals: 6,\n gasToken: 'MATIC',\n blockExplorer: 'https://amoy.polygonscan.com',\n erc3009DomainName: 'USDC',\n erc3009DomainVersion: '2',\n },\n};\n\n// Legacy aliases for backwards compatibility\nconst NETWORK_ALIASES: Record<string, string> = {\n 'avalanche': 'avalanche-fuji',\n 'ethereum': 'ethereum-sepolia',\n 'polygon': 'polygon-amoy',\n 'base': 'base-sepolia',\n};\n\n// Network-specific API URLs\nconst NETWORK_API_URLS: Record<string, string> = {\n 'avalanche-fuji': 'https://x402-avalanche-chi.vercel.app',\n 'ethereum-sepolia': 'https://x402-ethereum-chi.vercel.app',\n 'base-sepolia': 'https://x402-base-chi.vercel.app',\n 'polygon-amoy': 'https://x402-polygon-chi.vercel.app',\n};\n\n/**\n * Resolve network name (handles legacy aliases)\n */\nfunction resolveNetwork(network: string): string {\n return NETWORK_ALIASES[network] || network;\n}\n\n/**\n * Get API URL for a network\n */\nfunction getApiUrlForNetwork(network: string, customApiUrl?: string): string {\n if (customApiUrl) {\n return customApiUrl.replace(/\\/$/, '');\n }\n const resolvedNetwork = resolveNetwork(network);\n return NETWORK_API_URLS[resolvedNetwork] || NETWORK_API_URLS['avalanche-fuji'];\n}\n\nexport class Facinet {\n private config: Required<Pick<FacinetConfig, 'apiUrl' | 'privateKey' | 'network' | 'rpcUrl'>>;\n private chain: ChainConfig;\n private wallet?: InstanceType<typeof Wallet>;\n\n constructor(config: FacinetConfig = {}) {\n const resolvedNetwork = resolveNetwork(config.network || 'avalanche-fuji');\n const apiUrl = getApiUrlForNetwork(resolvedNetwork, config.apiUrl);\n\n this.config = {\n apiUrl,\n privateKey: config.privateKey || '',\n network: resolvedNetwork as any,\n rpcUrl: config.rpcUrl || '',\n };\n\n this.chain = CHAINS[resolvedNetwork];\n if (!this.chain) {\n throw new Error(\n `Unsupported network: ${config.network}. Supported networks: ${Object.keys(CHAINS).join(', ')}`\n );\n }\n\n if (this.config.privateKey) {\n const provider = new JsonRpcProvider(\n this.config.rpcUrl || this.chain.rpcUrl\n );\n this.wallet = new Wallet(this.config.privateKey, provider);\n }\n }\n\n /**\n * Get the current chain configuration\n */\n getChain(): ChainConfig {\n return { ...this.chain };\n }\n\n /**\n * Get all supported chains\n */\n static getSupportedChains(): ChainConfig[] {\n return Object.values(CHAINS);\n }\n\n /**\n * Get supported network names\n */\n static getSupportedNetworks(): string[] {\n return Object.keys(CHAINS);\n }\n\n /**\n * Make a payment via x402 facilitator network\n *\n * @example\n * ```typescript\n * const facinet = new Facinet({ network: 'base-sepolia' });\n * const result = await facinet.pay({\n * amount: '1',\n * recipient: '0xMerchantAddress',\n * payerAddress: '0xCustomerAddress'\n * });\n * console.log('Payment successful!', result.txHash);\n * ```\n */\n async pay(params: PaymentParams): Promise<PaymentResult> {\n if (!params.amount || parseFloat(params.amount) <= 0) {\n throw new Error('Invalid amount');\n }\n\n if (!params.recipient.match(/^0x[a-fA-F0-9]{40}$/)) {\n throw new Error('Invalid recipient address');\n }\n\n // Resolve payer address\n let payerAddress = params.payerAddress || '';\n if (!payerAddress) {\n if (this.wallet) {\n payerAddress = this.wallet.address as `0x${string}`;\n } else if (typeof window !== 'undefined' && (window as any).ethereum) {\n const accounts = await (window as any).ethereum.request({\n method: 'eth_requestAccounts',\n });\n payerAddress = accounts[0];\n } else {\n throw new Error(\n 'No payer address provided and no wallet available. Provide payerAddress or privateKey in config.'\n );\n }\n }\n\n payerAddress = payerAddress.toLowerCase() as `0x${string}`;\n const recipientAddress = params.recipient.toLowerCase();\n\n // Select random facilitator\n const facilitator = await this.selectRandomFacilitator();\n\n // Create ERC-3009 authorization\n const amount = BigInt(parseFloat(params.amount) * 1e6); // 6 decimals for USDC\n const validAfter = Math.floor(Date.now() / 1000) - 60;\n const validBefore = validAfter + 3600; // 1 hour validity\n const nonce =\n '0x' +\n Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('');\n\n // EIP-712 Domain - uses chain-specific domain name\n const domain = {\n name: this.chain.erc3009DomainName,\n version: this.chain.erc3009DomainVersion,\n chainId: this.chain.chainId,\n verifyingContract: this.chain.usdcAddress,\n };\n\n const types = {\n TransferWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n };\n\n const value = {\n from: payerAddress,\n to: recipientAddress,\n value: amount,\n validAfter,\n validBefore,\n nonce,\n };\n\n // Sign the authorization\n let signature: string;\n\n if (this.wallet) {\n signature = await this.wallet.signTypedData(domain, types, value);\n } else if (typeof window !== 'undefined' && (window as any).ethereum) {\n const { TypedDataEncoder } = await import('ethers');\n\n const messageForSigning = {\n from: payerAddress,\n to: recipientAddress,\n value: amount.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n };\n\n const typedDataPayload = JSON.stringify({\n types: {\n EIP712Domain: [\n { name: 'name', type: 'string' },\n { name: 'version', type: 'string' },\n { name: 'chainId', type: 'uint256' },\n { name: 'verifyingContract', type: 'address' },\n ],\n TransferWithAuthorization: types.TransferWithAuthorization,\n },\n domain,\n primaryType: 'TransferWithAuthorization',\n message: messageForSigning,\n });\n\n signature = await (window as any).ethereum.request({\n method: 'eth_signTypedData_v4',\n params: [payerAddress, typedDataPayload],\n });\n } else {\n throw new Error('No signing method available');\n }\n\n // Build payment payload\n const paymentPayload = {\n signature,\n authorization: {\n from: payerAddress,\n to: recipientAddress,\n value: amount.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n },\n };\n\n // Submit to facilitator\n try {\n const response = await axios.post(\n `${this.config.apiUrl}/api/x402/settle-custom`,\n {\n facilitatorId: facilitator.id,\n paymentPayload,\n }\n );\n\n if (!response.data.success) {\n throw new Error(\n response.data.error || response.data.message || 'Payment failed'\n );\n }\n\n return {\n success: true,\n txHash: response.data.txHash,\n facilitator: {\n id: facilitator.id,\n name: facilitator.name || `Facilitator ${facilitator.id.slice(0, 8)}`,\n wallet: facilitator.facilitatorWallet,\n },\n payment: {\n from: payerAddress,\n to: recipientAddress,\n amount: params.amount,\n network: this.config.network,\n },\n };\n } catch (error: any) {\n if (error.response?.data) {\n const backendError =\n error.response.data.message || error.response.data.error;\n throw new Error(`Payment failed: ${backendError}`);\n }\n throw error;\n }\n }\n\n /**\n * Get all active facilitators for the current network\n */\n async getFacilitators(): Promise<Facilitator[]> {\n try {\n const response = await axios.get(\n `${this.config.apiUrl}/api/facilitator/list`,\n {\n timeout: 10000,\n headers: {\n 'User-Agent': 'Facinet-SDK/2.3.0',\n },\n }\n );\n\n if (response.data.success && Array.isArray(response.data.facilitators)) {\n // Filter by status and network/chainId\n return response.data.facilitators.filter((f: Facilitator) => {\n // Must be active\n if (f.status !== 'active') {\n return false;\n }\n \n // If facilitator has network or chainId, match it with current chain\n if (f.network) {\n return f.network === this.config.network;\n }\n \n if (f.chainId !== undefined) {\n return f.chainId === this.chain.chainId;\n }\n \n // If no network/chainId specified, include it (backwards compatibility)\n return true;\n });\n }\n\n return [];\n } catch (error: any) {\n throw new Error(\n `Failed to fetch facilitators for ${this.chain.displayName} (${this.config.network}): ${error.message || 'Unknown error'}`\n );\n }\n }\n\n /**\n * Select a random active facilitator for the current network\n */\n async selectRandomFacilitator(): Promise<Facilitator> {\n const facilitators = await this.getFacilitators();\n\n if (facilitators.length === 0) {\n throw new Error(\n `No active facilitators available for ${this.chain.displayName} (${this.config.network}, Chain ID: ${this.chain.chainId}). ` +\n `Please check that facilitators are registered for this network. API URL: ${this.config.apiUrl}`\n );\n }\n\n const randomIndex = Math.floor(Math.random() * facilitators.length);\n const selectedFacilitator = facilitators[randomIndex];\n \n // Ensure facilitator has a name\n if (!selectedFacilitator.name) {\n selectedFacilitator.name = `Facilitator ${selectedFacilitator.id.slice(0, 8)}`;\n }\n \n return selectedFacilitator;\n }\n\n /**\n * Quick payment helper (static method)\n *\n * @example\n * ```typescript\n * // Pay on Base Sepolia\n * await Facinet.quickPay({\n * amount: '1',\n * recipient: '0xMerchantAddress',\n * privateKey: process.env.PRIVATE_KEY,\n * network: 'base-sepolia'\n * });\n * ```\n */\n static async quickPay(\n params: PaymentParams & { privateKey?: string; network?: FacinetConfig['network'] }\n ): Promise<PaymentResult> {\n const facinet = new Facinet({\n privateKey: params.privateKey,\n network: params.network,\n });\n\n return facinet.pay({\n amount: params.amount,\n recipient: params.recipient,\n payerAddress: params.payerAddress,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,mBAAkB;AAClB,oBAAwC;AAIxC,IAAM,SAAsC;AAAA,EAC1C,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,UAAU;AAAA,IACV,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,EACxB;AAAA,EACA,oBAAoB;AAAA,IAClB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,UAAU;AAAA,IACV,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,EACxB;AAAA,EACA,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,UAAU;AAAA,IACV,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,EACxB;AAAA,EACA,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,UAAU;AAAA,IACV,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,EACxB;AACF;AAGA,IAAM,kBAA0C;AAAA,EAC9C,aAAa;AAAA,EACb,YAAY;AAA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