@genobank/biofs 2.4.1 → 2.5.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/CHANGELOG.md +2 -0
- package/LICENSE +37 -0
- package/README.md +2 -1
- package/bin/biofs.js +2 -1
- package/contracts/ClaraJobNFT.sol +101 -0
- package/dist/commands/agent/health.js +1 -1
- package/dist/commands/agent/health.js.map +1 -1
- package/dist/commands/agent/list.d.ts +14 -0
- package/dist/commands/agent/list.d.ts.map +1 -0
- package/dist/commands/agent/list.js +101 -0
- package/dist/commands/agent/list.js.map +1 -0
- package/dist/commands/agent/register.d.ts +18 -0
- package/dist/commands/agent/register.d.ts.map +1 -0
- package/dist/commands/agent/register.js +120 -0
- package/dist/commands/agent/register.js.map +1 -0
- package/dist/commands/agent/status.d.ts +14 -0
- package/dist/commands/agent/status.d.ts.map +1 -0
- package/dist/commands/agent/status.js +151 -0
- package/dist/commands/agent/status.js.map +1 -0
- package/dist/commands/annotate/status.d.ts +11 -0
- package/dist/commands/annotate/status.d.ts.map +1 -0
- package/dist/commands/annotate/status.js +123 -0
- package/dist/commands/annotate/status.js.map +1 -0
- package/dist/commands/annotate/submit.d.ts +23 -0
- package/dist/commands/annotate/submit.d.ts.map +1 -0
- package/dist/commands/annotate/submit.js +296 -0
- package/dist/commands/annotate/submit.js.map +1 -0
- package/dist/commands/family-status.d.ts +12 -0
- package/dist/commands/family-status.d.ts.map +1 -0
- package/dist/commands/family-status.js +220 -0
- package/dist/commands/family-status.js.map +1 -0
- package/dist/commands/job/status.d.ts +1 -0
- package/dist/commands/job/status.d.ts.map +1 -1
- package/dist/commands/job/status.js.map +1 -1
- package/dist/commands/link-clara.d.ts +20 -0
- package/dist/commands/link-clara.d.ts.map +1 -0
- package/dist/commands/link-clara.js +234 -0
- package/dist/commands/link-clara.js.map +1 -0
- package/dist/commands/mount-remote.d.ts +1 -1
- package/dist/commands/mount-remote.js +1 -1
- package/dist/commands/payment/balance.d.ts +12 -0
- package/dist/commands/payment/balance.d.ts.map +1 -0
- package/dist/commands/payment/balance.js +101 -0
- package/dist/commands/payment/balance.js.map +1 -0
- package/dist/commands/payment/faucet.d.ts +11 -0
- package/dist/commands/payment/faucet.d.ts.map +1 -0
- package/dist/commands/payment/faucet.js +92 -0
- package/dist/commands/payment/faucet.js.map +1 -0
- package/dist/commands/payment/history.d.ts +27 -0
- package/dist/commands/payment/history.d.ts.map +1 -0
- package/dist/commands/payment/history.js +162 -0
- package/dist/commands/payment/history.js.map +1 -0
- package/dist/commands/payment/pricing.d.ts +12 -0
- package/dist/commands/payment/pricing.d.ts.map +1 -0
- package/dist/commands/payment/pricing.js +65 -0
- package/dist/commands/payment/pricing.js.map +1 -0
- package/dist/commands/payment/setup.d.ts +25 -0
- package/dist/commands/payment/setup.d.ts.map +1 -0
- package/dist/commands/payment/setup.js +155 -0
- package/dist/commands/payment/setup.js.map +1 -0
- package/dist/commands/tokenize-biosample.d.ts +19 -0
- package/dist/commands/tokenize-biosample.d.ts.map +1 -0
- package/dist/commands/tokenize-biosample.js +253 -0
- package/dist/commands/tokenize-biosample.js.map +1 -0
- package/dist/index.js +281 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/api/bionft-client.d.ts +35 -7
- package/dist/lib/api/bionft-client.d.ts.map +1 -1
- package/dist/lib/api/bionft-client.js +106 -16
- package/dist/lib/api/bionft-client.js.map +1 -1
- package/dist/lib/kite/agent.d.ts +85 -0
- package/dist/lib/kite/agent.d.ts.map +1 -0
- package/dist/lib/kite/agent.js +332 -0
- package/dist/lib/kite/agent.js.map +1 -0
- package/dist/lib/kite/index.d.ts +9 -0
- package/dist/lib/kite/index.d.ts.map +1 -0
- package/dist/lib/kite/index.js +25 -0
- package/dist/lib/kite/index.js.map +1 -0
- package/dist/lib/kite/passport.d.ts +69 -0
- package/dist/lib/kite/passport.d.ts.map +1 -0
- package/dist/lib/kite/passport.js +312 -0
- package/dist/lib/kite/passport.js.map +1 -0
- package/dist/lib/x402/client.d.ts +78 -0
- package/dist/lib/x402/client.d.ts.map +1 -0
- package/dist/lib/x402/client.js +298 -0
- package/dist/lib/x402/client.js.map +1 -0
- package/dist/lib/x402/index.d.ts +9 -0
- package/dist/lib/x402/index.d.ts.map +1 -0
- package/dist/lib/x402/index.js +37 -0
- package/dist/lib/x402/index.js.map +1 -0
- package/dist/lib/x402/middleware.d.ts +37 -0
- package/dist/lib/x402/middleware.d.ts.map +1 -0
- package/dist/lib/x402/middleware.js +220 -0
- package/dist/lib/x402/middleware.js.map +1 -0
- package/dist/types/kite.d.ts +157 -0
- package/dist/types/kite.d.ts.map +1 -0
- package/dist/types/kite.js +107 -0
- package/dist/types/kite.js.map +1 -0
- package/dist/types/x402.d.ts +78 -0
- package/dist/types/x402.d.ts.map +1 -0
- package/dist/types/x402.js +79 -0
- package/dist/types/x402.js.map +1 -0
- package/docs/AI_AGENT_MCP_MANUAL.md +1029 -0
- package/docs/USER_MANUAL.md +603 -0
- package/docs/technical-details.html +555 -0
- package/lib/bionfs-client.js +2 -0
- package/lib/consent-manager.js +2 -0
- package/lib/consent-prompt.js +2 -0
- package/package.json +9 -3
- package/presentation/biofs-x402-kite-presentation.html +813 -0
- package/scripts/build_annotator_dictionary.py +1 -0
- package/scripts/deploy-clara-nft.js +37 -0
- package/test-complete-flow.sh +1 -1
- package/test.vcf +1 -0
- package/test_23andme.txt +1 -0
- package/ADMIN_REGISTER_LAB.md +0 -252
- package/ANNOTATOR_RECOMMENDATIONS_API.md +0 -490
- package/BIOFS_QUICK_START.md +0 -200
- package/BIOFS_TOKENIZE_COMPLETE.md +0 -541
- package/BIOFS_V1.2.7_PUBLISHED.md +0 -317
- package/BIOFS_V1.2.9_FIXES.md +0 -306
- package/BIOFS_V1.3.0_DIRECT_GRANT.md +0 -381
- package/BIOFS_V1.3.1_GRANTED_FILES.md +0 -328
- package/BIONFS_DEPLOYMENT_GUIDE.md +0 -408
- package/BIONFS_MOUNT_INTEGRATION_PLAN.md +0 -415
- package/BIONFS_PROTOCOL_SPECIFICATION.md +0 -688
- package/BIONFS_SEQUENTIAS_INTEGRATION.md +0 -457
- package/BIONFT_GATED_REMOTE_MOUNTING.md +0 -1260
- package/BIONFT_NFS_PROTOCOL_ARCHITECTURE.md +0 -583
- package/BIOOS_CLI_IMPLEMENTATION_COMPLETE.md +0 -422
- package/BIOOS_JOB_MANAGEMENT.md +0 -681
- package/BUGFIX_V2.1.3.md +0 -72
- package/CHANGELOG_V2.1.0.md +0 -386
- package/CHANGELOG_V2.2.0.md +0 -284
- package/ENHANCEMENT_DOCUMENTATION.md +0 -218
- package/GDPR_BIONFS_CONSENT_ARCHITECTURE.md +0 -798
- package/GDPR_BIONFS_IMPLEMENTATION_STATUS.md +0 -462
- package/INSTALL_V1.2.7_ON_MAC.md +0 -306
- package/LABNFT_BIOFS_INTEGRATION.md +0 -396
- package/OPENCRAVAT_ANNOTATORS_REFERENCE.md +0 -340
- package/OPENCRAVAT_ANNOTATOR_INTELLIGENCE_COMPLETE.md +0 -479
- package/QUICK_START_V2.1.0.md +0 -116
- package/RELEASE_SUMMARY_V1.2.7.md +0 -479
- package/RELEASE_SUMMARY_V1.3.0.md +0 -324
- package/SEQUENTIAS_PROTOCOL_ARCHITECTURE.md +0 -880
- package/SEQUENTIA_MIGRATION_GUIDE.md +0 -337
- package/SESSION_SUMMARY_DIRECT_GRANT.md +0 -321
- package/ULTRATHINK_BIONFS_COMPLETE.md +0 -458
- package/WEB3FUSE_LICENSE_TOKEN_ANALYSIS.md +0 -494
- package/WHERE_PERMISSIONS_LIVE.md +0 -165
- package/config.json +0 -21
- package/opencravat_annotators_dictionary.json +0 -2356
- package/package.json.working.v1.9.2.20251105_023952 +0 -48
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* x402 Client for BioFS
|
|
4
|
+
*
|
|
5
|
+
* Handles x402 payment protocol on Avalanche C-Chain
|
|
6
|
+
* - Automatic payment handling for HTTP 402 responses
|
|
7
|
+
* - EIP-712 typed signature generation
|
|
8
|
+
* - Facilitator integration for settlement
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.X402Client = void 0;
|
|
15
|
+
exports.createBioFSPaymentClient = createBioFSPaymentClient;
|
|
16
|
+
exports.getPaymentClient = getPaymentClient;
|
|
17
|
+
const ethers_1 = require("ethers");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const x402_1 = require("../../types/x402");
|
|
20
|
+
const logger_1 = require("../utils/logger");
|
|
21
|
+
const credentials_1 = require("../auth/credentials");
|
|
22
|
+
// USDC has 6 decimals
|
|
23
|
+
const USDC_DECIMALS = 6;
|
|
24
|
+
/**
|
|
25
|
+
* X402 Payment Client
|
|
26
|
+
*
|
|
27
|
+
* Wraps HTTP client with automatic x402 payment handling
|
|
28
|
+
*/
|
|
29
|
+
class X402Client {
|
|
30
|
+
constructor(config = {}) {
|
|
31
|
+
this.signer = null;
|
|
32
|
+
this.nonce = BigInt(0);
|
|
33
|
+
this.config = {
|
|
34
|
+
facilitatorUrl: config.facilitatorUrl || x402_1.FACILITATOR_URLS.public,
|
|
35
|
+
network: config.network || 'avalanche-fuji',
|
|
36
|
+
maxAmount: config.maxAmount || '10.00', // Default $10 max auto-approve
|
|
37
|
+
privateKey: config.privateKey
|
|
38
|
+
};
|
|
39
|
+
// Initialize provider
|
|
40
|
+
this.provider = new ethers_1.ethers.JsonRpcProvider(x402_1.RPC_URLS[this.config.network]);
|
|
41
|
+
// Initialize HTTP client
|
|
42
|
+
this.httpClient = axios_1.default.create({
|
|
43
|
+
timeout: 60000,
|
|
44
|
+
validateStatus: () => true // Handle all status codes
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initialize signer from credentials or config
|
|
49
|
+
*/
|
|
50
|
+
async initSigner() {
|
|
51
|
+
if (this.signer)
|
|
52
|
+
return;
|
|
53
|
+
if (this.config.privateKey) {
|
|
54
|
+
this.signer = new ethers_1.ethers.Wallet(this.config.privateKey, this.provider);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Try to get from BioFS credentials
|
|
58
|
+
const credentials = await (0, credentials_1.getCredentials)();
|
|
59
|
+
if (credentials?.user_signature) {
|
|
60
|
+
// Derive ephemeral key from signature (for CLI use)
|
|
61
|
+
// This creates a deterministic wallet from the user's signature
|
|
62
|
+
const hash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(credentials.user_signature));
|
|
63
|
+
this.signer = new ethers_1.ethers.Wallet(hash, this.provider);
|
|
64
|
+
logger_1.Logger.debug('Using ephemeral key derived from signature');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!this.signer) {
|
|
68
|
+
throw new Error('No signer available. Please run "biofs login" or provide private key.');
|
|
69
|
+
}
|
|
70
|
+
// Initialize nonce
|
|
71
|
+
this.nonce = BigInt(Date.now());
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get current signer address
|
|
75
|
+
*/
|
|
76
|
+
async getAddress() {
|
|
77
|
+
await this.initSigner();
|
|
78
|
+
return this.signer.address;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Convert price string to USDC amount (wei)
|
|
82
|
+
* e.g., "$5.00" -> 5000000 (6 decimals)
|
|
83
|
+
*/
|
|
84
|
+
parsePrice(priceStr) {
|
|
85
|
+
// Remove $ and parse as float
|
|
86
|
+
const amount = parseFloat(priceStr.replace('$', ''));
|
|
87
|
+
// Convert to USDC units (6 decimals)
|
|
88
|
+
return BigInt(Math.round(amount * 10 ** USDC_DECIMALS));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Format USDC amount to human readable
|
|
92
|
+
*/
|
|
93
|
+
formatPrice(amount) {
|
|
94
|
+
const value = Number(amount) / 10 ** USDC_DECIMALS;
|
|
95
|
+
return `$${value.toFixed(2)}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create EIP-712 signature for payment
|
|
99
|
+
*/
|
|
100
|
+
async signPayment(requirement) {
|
|
101
|
+
await this.initSigner();
|
|
102
|
+
const chainId = x402_1.CHAIN_IDS[this.config.network];
|
|
103
|
+
const usdcAddress = x402_1.USDC_ADDRESSES[this.config.network];
|
|
104
|
+
const amount = this.parsePrice(requirement.amount);
|
|
105
|
+
const deadline = Math.floor(Date.now() / 1000) + 3600; // 1 hour expiry
|
|
106
|
+
this.nonce += BigInt(1);
|
|
107
|
+
// EIP-712 domain
|
|
108
|
+
const domain = {
|
|
109
|
+
name: 'x402 Payment',
|
|
110
|
+
version: '1',
|
|
111
|
+
chainId: chainId,
|
|
112
|
+
verifyingContract: usdcAddress
|
|
113
|
+
};
|
|
114
|
+
// Payment data
|
|
115
|
+
const message = {
|
|
116
|
+
token: usdcAddress,
|
|
117
|
+
amount: amount,
|
|
118
|
+
receiver: requirement.receiver,
|
|
119
|
+
sender: this.signer.address,
|
|
120
|
+
nonce: this.nonce,
|
|
121
|
+
deadline: deadline
|
|
122
|
+
};
|
|
123
|
+
// Sign typed data
|
|
124
|
+
const signature = await this.signer.signTypedData(domain, x402_1.X402_TYPES, message);
|
|
125
|
+
return {
|
|
126
|
+
network: this.config.network,
|
|
127
|
+
token: usdcAddress,
|
|
128
|
+
amount: requirement.amount,
|
|
129
|
+
receiver: requirement.receiver,
|
|
130
|
+
sender: this.signer.address,
|
|
131
|
+
signature: signature,
|
|
132
|
+
nonce: this.nonce.toString(),
|
|
133
|
+
deadline: deadline,
|
|
134
|
+
chainId: chainId
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Verify and settle payment through facilitator
|
|
139
|
+
*/
|
|
140
|
+
async settlePayment(payment) {
|
|
141
|
+
try {
|
|
142
|
+
const response = await this.httpClient.post(`${this.config.facilitatorUrl}/verify`, { payment }, {
|
|
143
|
+
headers: { 'Content-Type': 'application/json' }
|
|
144
|
+
});
|
|
145
|
+
if (response.status === 200 && response.data.valid) {
|
|
146
|
+
// Submit to chain
|
|
147
|
+
const settleResponse = await this.httpClient.post(`${this.config.facilitatorUrl}/settle`, { payment }, {
|
|
148
|
+
headers: { 'Content-Type': 'application/json' }
|
|
149
|
+
});
|
|
150
|
+
if (settleResponse.status === 200) {
|
|
151
|
+
return {
|
|
152
|
+
success: true,
|
|
153
|
+
transactionHash: settleResponse.data.transactionHash,
|
|
154
|
+
blockNumber: settleResponse.data.blockNumber
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: settleResponse.data.error || 'Settlement failed'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
success: false,
|
|
164
|
+
error: response.data.error || 'Verification failed'
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
error: error.message
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Parse 402 response to extract payment requirement
|
|
176
|
+
*/
|
|
177
|
+
parsePaymentRequirement(response) {
|
|
178
|
+
const paymentHeader = response.headers['x-payment-required'];
|
|
179
|
+
if (!paymentHeader)
|
|
180
|
+
return null;
|
|
181
|
+
try {
|
|
182
|
+
return JSON.parse(paymentHeader);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// Try parsing from body
|
|
186
|
+
if (response.data?.payment_required) {
|
|
187
|
+
return response.data.payment_required;
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Make HTTP request with automatic x402 payment handling
|
|
194
|
+
*/
|
|
195
|
+
async request(config) {
|
|
196
|
+
// Make initial request
|
|
197
|
+
let response = await this.httpClient.request(config);
|
|
198
|
+
// Check for 402 Payment Required
|
|
199
|
+
if (response.status === 402) {
|
|
200
|
+
const requirement = this.parsePaymentRequirement(response);
|
|
201
|
+
if (!requirement) {
|
|
202
|
+
throw new Error('402 Payment Required but no payment details provided');
|
|
203
|
+
}
|
|
204
|
+
// Check if amount exceeds max auto-approve
|
|
205
|
+
const amount = this.parsePrice(requirement.amount);
|
|
206
|
+
const maxAmount = this.parsePrice(this.config.maxAmount);
|
|
207
|
+
if (amount > maxAmount) {
|
|
208
|
+
throw new Error(`Payment of ${this.formatPrice(amount)} exceeds max auto-approve of ${this.formatPrice(maxAmount)}. ` +
|
|
209
|
+
`Use --approve-payment flag to proceed.`);
|
|
210
|
+
}
|
|
211
|
+
logger_1.Logger.info(`Payment required: ${requirement.amount} for ${requirement.description || requirement.route}`);
|
|
212
|
+
// Sign payment
|
|
213
|
+
const payment = await this.signPayment(requirement);
|
|
214
|
+
// Settle payment
|
|
215
|
+
const result = await this.settlePayment(payment);
|
|
216
|
+
if (!result.success) {
|
|
217
|
+
throw new Error(`Payment failed: ${result.error}`);
|
|
218
|
+
}
|
|
219
|
+
logger_1.Logger.success(`Payment settled: ${result.transactionHash}`);
|
|
220
|
+
// Retry original request with payment proof
|
|
221
|
+
config.headers = {
|
|
222
|
+
...config.headers,
|
|
223
|
+
'X-Payment-Proof': JSON.stringify({
|
|
224
|
+
transactionHash: result.transactionHash,
|
|
225
|
+
payment: payment
|
|
226
|
+
})
|
|
227
|
+
};
|
|
228
|
+
response = await this.httpClient.request(config);
|
|
229
|
+
}
|
|
230
|
+
return response;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* GET request with payment handling
|
|
234
|
+
*/
|
|
235
|
+
async get(url, config) {
|
|
236
|
+
return this.request({ ...config, method: 'GET', url });
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* POST request with payment handling
|
|
240
|
+
*/
|
|
241
|
+
async post(url, data, config) {
|
|
242
|
+
return this.request({ ...config, method: 'POST', url, data });
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Check USDC balance
|
|
246
|
+
*/
|
|
247
|
+
async getUSDCBalance() {
|
|
248
|
+
await this.initSigner();
|
|
249
|
+
const usdcAddress = x402_1.USDC_ADDRESSES[this.config.network];
|
|
250
|
+
const usdcAbi = ['function balanceOf(address) view returns (uint256)'];
|
|
251
|
+
const usdc = new ethers_1.ethers.Contract(usdcAddress, usdcAbi, this.provider);
|
|
252
|
+
const balance = await usdc.balanceOf(this.signer.address);
|
|
253
|
+
return this.formatPrice(balance);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Approve USDC spending for facilitator
|
|
257
|
+
*/
|
|
258
|
+
async approveUSDC(amount = '1000000') {
|
|
259
|
+
await this.initSigner();
|
|
260
|
+
const usdcAddress = x402_1.USDC_ADDRESSES[this.config.network];
|
|
261
|
+
const usdcAbi = [
|
|
262
|
+
'function approve(address spender, uint256 amount) returns (bool)',
|
|
263
|
+
'function allowance(address owner, address spender) view returns (uint256)'
|
|
264
|
+
];
|
|
265
|
+
const usdc = new ethers_1.ethers.Contract(usdcAddress, usdcAbi, this.signer);
|
|
266
|
+
// Parse amount
|
|
267
|
+
const amountWei = this.parsePrice(amount);
|
|
268
|
+
// Check existing allowance
|
|
269
|
+
// For now, approve a high amount (no specific facilitator contract needed for EIP-712)
|
|
270
|
+
// In production, you'd approve the specific payment contract
|
|
271
|
+
logger_1.Logger.info(`Approving ${amount} USDC for payments...`);
|
|
272
|
+
// This is a simplified version - actual x402 uses permit or direct EIP-712
|
|
273
|
+
return 'EIP-712 payments do not require pre-approval';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.X402Client = X402Client;
|
|
277
|
+
/**
|
|
278
|
+
* Create a pre-configured x402 client for BioFS
|
|
279
|
+
*/
|
|
280
|
+
async function createBioFSPaymentClient(network = 'avalanche-fuji') {
|
|
281
|
+
const client = new X402Client({
|
|
282
|
+
network,
|
|
283
|
+
facilitatorUrl: process.env.X402_FACILITATOR_URL || x402_1.FACILITATOR_URLS.public
|
|
284
|
+
});
|
|
285
|
+
await client.initSigner();
|
|
286
|
+
return client;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Singleton instance for CLI
|
|
290
|
+
*/
|
|
291
|
+
let _clientInstance = null;
|
|
292
|
+
async function getPaymentClient() {
|
|
293
|
+
if (!_clientInstance) {
|
|
294
|
+
_clientInstance = await createBioFSPaymentClient();
|
|
295
|
+
}
|
|
296
|
+
return _clientInstance;
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/x402/client.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;AA6UH,4DAUC;AAOD,4CAKC;AAjWD,mCAAgC;AAChC,kDAAgF;AAChF,2CAW0B;AAC1B,4CAAyC;AACzC,qDAAqD;AAErD,sBAAsB;AACtB,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;GAIG;AACH,MAAa,UAAU;IAOrB,YAAY,SAAoC,EAAE;QAL1C,WAAM,GAAyB,IAAI,CAAC;QAGpC,UAAK,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;QAGhC,IAAI,CAAC,MAAM,GAAG;YACZ,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,uBAAgB,CAAC,MAAM;YAChE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,gBAAgB;YAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,OAAO,EAAG,+BAA+B;YACxE,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC;QAEF,sBAAsB;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,eAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAE1E,yBAAy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,CAAC;QACxD,MAAM,OAAO,GAAG;YACd,kEAAkE;YAClE,2EAA2E;SAC5E,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,eAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,MAAO,CAAC,CAAC;QAErE,eAAe;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAE1C,2BAA2B;QAC3B,uFAAuF;QACvF,6DAA6D;QAE7D,eAAM,CAAC,IAAI,CAAC,aAAa,MAAM,uBAAuB,CAAC,CAAC;QAExD,2EAA2E;QAC3E,OAAO,8CAA8C,CAAC;IACxD,CAAC;CACF;AA7SD,gCA6SC;AAED;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAC5C,UAAuB,gBAAgB;IAEvC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;QAC5B,OAAO;QACP,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,uBAAgB,CAAC,MAAM;KAC5E,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,IAAI,eAAe,GAAsB,IAAI,CAAC;AAEvC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,MAAM,wBAAwB,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 Protocol Library for BioFS
|
|
3
|
+
*
|
|
4
|
+
* HTTP 402 Payment Required protocol implementation for Avalanche
|
|
5
|
+
*/
|
|
6
|
+
export { X402Client, createBioFSPaymentClient, getPaymentClient } from './client';
|
|
7
|
+
export { x402Middleware, priceTag, requirePayment, dynamicPricing, downloadPricing } from './middleware';
|
|
8
|
+
export * from '../../types/x402';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/x402/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGlF,OAAO,EACL,cAAc,EACd,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* x402 Protocol Library for BioFS
|
|
4
|
+
*
|
|
5
|
+
* HTTP 402 Payment Required protocol implementation for Avalanche
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.downloadPricing = exports.dynamicPricing = exports.requirePayment = exports.priceTag = exports.x402Middleware = exports.getPaymentClient = exports.createBioFSPaymentClient = exports.X402Client = void 0;
|
|
23
|
+
// Client
|
|
24
|
+
var client_1 = require("./client");
|
|
25
|
+
Object.defineProperty(exports, "X402Client", { enumerable: true, get: function () { return client_1.X402Client; } });
|
|
26
|
+
Object.defineProperty(exports, "createBioFSPaymentClient", { enumerable: true, get: function () { return client_1.createBioFSPaymentClient; } });
|
|
27
|
+
Object.defineProperty(exports, "getPaymentClient", { enumerable: true, get: function () { return client_1.getPaymentClient; } });
|
|
28
|
+
// Server Middleware
|
|
29
|
+
var middleware_1 = require("./middleware");
|
|
30
|
+
Object.defineProperty(exports, "x402Middleware", { enumerable: true, get: function () { return middleware_1.x402Middleware; } });
|
|
31
|
+
Object.defineProperty(exports, "priceTag", { enumerable: true, get: function () { return middleware_1.priceTag; } });
|
|
32
|
+
Object.defineProperty(exports, "requirePayment", { enumerable: true, get: function () { return middleware_1.requirePayment; } });
|
|
33
|
+
Object.defineProperty(exports, "dynamicPricing", { enumerable: true, get: function () { return middleware_1.dynamicPricing; } });
|
|
34
|
+
Object.defineProperty(exports, "downloadPricing", { enumerable: true, get: function () { return middleware_1.downloadPricing; } });
|
|
35
|
+
// Re-export types
|
|
36
|
+
__exportStar(require("../../types/x402"), exports);
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/x402/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,SAAS;AACT,mCAAkF;AAAzE,oGAAA,UAAU,OAAA;AAAE,kHAAA,wBAAwB,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAE/D,oBAAoB;AACpB,2CAMsB;AALpB,4GAAA,cAAc,OAAA;AACd,sGAAA,QAAQ,OAAA;AACR,4GAAA,cAAc,OAAA;AACd,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA;AAGjB,kBAAkB;AAClB,mDAAiC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 Express Middleware for BioFS Node Server
|
|
3
|
+
*
|
|
4
|
+
* Protects routes with HTTP 402 Payment Required
|
|
5
|
+
* Uses Avalanche C-Chain USDC for payments
|
|
6
|
+
*/
|
|
7
|
+
import { Request, RequestHandler } from 'express';
|
|
8
|
+
import { X402Network, X402PriceTag, X402RouteConfig } from '../../types/x402';
|
|
9
|
+
/**
|
|
10
|
+
* x402 Payment Middleware Factory
|
|
11
|
+
*
|
|
12
|
+
* Creates Express middleware that requires payment for protected routes
|
|
13
|
+
*/
|
|
14
|
+
export declare function x402Middleware(options: {
|
|
15
|
+
receiver: string;
|
|
16
|
+
pricing?: X402RouteConfig;
|
|
17
|
+
network?: X402Network;
|
|
18
|
+
facilitatorUrl?: string;
|
|
19
|
+
}): RequestHandler;
|
|
20
|
+
/**
|
|
21
|
+
* Create price tag for a route
|
|
22
|
+
*/
|
|
23
|
+
export declare function priceTag(price: string, receiver: string, description?: string, network?: X402Network): X402PriceTag;
|
|
24
|
+
/**
|
|
25
|
+
* Helper to wrap existing route handlers with payment requirement
|
|
26
|
+
*/
|
|
27
|
+
export declare function requirePayment(priceTag: X402PriceTag, handler: RequestHandler): RequestHandler[];
|
|
28
|
+
/**
|
|
29
|
+
* Dynamic pricing based on request parameters
|
|
30
|
+
* (e.g., price per GB for downloads)
|
|
31
|
+
*/
|
|
32
|
+
export declare function dynamicPricing(calculatePrice: (req: Request) => X402PriceTag | null): RequestHandler;
|
|
33
|
+
/**
|
|
34
|
+
* Example: Dynamic pricing for file downloads (per GB)
|
|
35
|
+
*/
|
|
36
|
+
export declare function downloadPricing(pricePerGB: string, receiver: string): RequestHandler;
|
|
37
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/x402/middleware.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EACL,WAAW,EAGX,YAAY,EACZ,eAAe,EAMhB,MAAM,kBAAkB,CAAC;AAgG1B;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,cAAc,CAwDjB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,WAA8B,GACtC,YAAY,CAOd;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,cAAc,GACtB,cAAc,EAAE,CAQlB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,YAAY,GAAG,IAAI,GACpD,cAAc,CAmChB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAmBpF"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* x402 Express Middleware for BioFS Node Server
|
|
4
|
+
*
|
|
5
|
+
* Protects routes with HTTP 402 Payment Required
|
|
6
|
+
* Uses Avalanche C-Chain USDC for payments
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.x402Middleware = x402Middleware;
|
|
10
|
+
exports.priceTag = priceTag;
|
|
11
|
+
exports.requirePayment = requirePayment;
|
|
12
|
+
exports.dynamicPricing = dynamicPricing;
|
|
13
|
+
exports.downloadPricing = downloadPricing;
|
|
14
|
+
const ethers_1 = require("ethers");
|
|
15
|
+
const x402_1 = require("../../types/x402");
|
|
16
|
+
const logger_1 = require("../utils/logger");
|
|
17
|
+
const USDC_DECIMALS = 6;
|
|
18
|
+
/**
|
|
19
|
+
* Verify EIP-712 payment signature
|
|
20
|
+
*/
|
|
21
|
+
async function verifyPaymentSignature(payment, network) {
|
|
22
|
+
try {
|
|
23
|
+
const chainId = x402_1.CHAIN_IDS[network];
|
|
24
|
+
const usdcAddress = x402_1.USDC_ADDRESSES[network];
|
|
25
|
+
// EIP-712 domain
|
|
26
|
+
const domain = {
|
|
27
|
+
name: 'x402 Payment',
|
|
28
|
+
version: '1',
|
|
29
|
+
chainId: chainId,
|
|
30
|
+
verifyingContract: usdcAddress
|
|
31
|
+
};
|
|
32
|
+
// Parse amount
|
|
33
|
+
const amount = parseFloat(payment.amount.replace('$', ''));
|
|
34
|
+
const amountWei = BigInt(Math.round(amount * 10 ** USDC_DECIMALS));
|
|
35
|
+
// Payment message
|
|
36
|
+
const message = {
|
|
37
|
+
token: usdcAddress,
|
|
38
|
+
amount: amountWei,
|
|
39
|
+
receiver: payment.receiver,
|
|
40
|
+
sender: payment.sender,
|
|
41
|
+
nonce: BigInt(payment.nonce),
|
|
42
|
+
deadline: payment.deadline
|
|
43
|
+
};
|
|
44
|
+
// Verify signature
|
|
45
|
+
const recoveredAddress = ethers_1.ethers.verifyTypedData(domain, x402_1.X402_TYPES, message, payment.signature);
|
|
46
|
+
if (recoveredAddress.toLowerCase() !== payment.sender.toLowerCase()) {
|
|
47
|
+
return { valid: false, error: 'Signature does not match sender' };
|
|
48
|
+
}
|
|
49
|
+
// Check deadline
|
|
50
|
+
if (payment.deadline < Math.floor(Date.now() / 1000)) {
|
|
51
|
+
return { valid: false, error: 'Payment has expired' };
|
|
52
|
+
}
|
|
53
|
+
return { valid: true };
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return { valid: false, error: error.message };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if payment proof is valid and settled on-chain
|
|
61
|
+
*/
|
|
62
|
+
async function verifyPaymentProof(proofHeader, network) {
|
|
63
|
+
try {
|
|
64
|
+
const proof = JSON.parse(proofHeader);
|
|
65
|
+
// First verify signature
|
|
66
|
+
const sigResult = await verifyPaymentSignature(proof.payment, network);
|
|
67
|
+
if (!sigResult.valid) {
|
|
68
|
+
logger_1.Logger.warn(`Payment signature invalid: ${sigResult.error}`);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
// If transaction hash provided, verify on-chain
|
|
72
|
+
if (proof.transactionHash) {
|
|
73
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(x402_1.RPC_URLS[network]);
|
|
74
|
+
const receipt = await provider.getTransactionReceipt(proof.transactionHash);
|
|
75
|
+
if (!receipt || receipt.status !== 1) {
|
|
76
|
+
logger_1.Logger.warn('Payment transaction not confirmed');
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
logger_1.Logger.warn(`Payment proof verification failed: ${error.message}`);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* x402 Payment Middleware Factory
|
|
89
|
+
*
|
|
90
|
+
* Creates Express middleware that requires payment for protected routes
|
|
91
|
+
*/
|
|
92
|
+
function x402Middleware(options) {
|
|
93
|
+
const network = options.network || 'avalanche-fuji';
|
|
94
|
+
const pricing = options.pricing || x402_1.BIOFS_PRICING;
|
|
95
|
+
return async (req, res, next) => {
|
|
96
|
+
const route = req.path;
|
|
97
|
+
// Check if route requires payment
|
|
98
|
+
const priceTag = pricing[route];
|
|
99
|
+
if (!priceTag) {
|
|
100
|
+
return next(); // No payment required for this route
|
|
101
|
+
}
|
|
102
|
+
// Check for payment proof header
|
|
103
|
+
const paymentProof = req.headers['x-payment-proof'];
|
|
104
|
+
if (paymentProof) {
|
|
105
|
+
// Verify payment
|
|
106
|
+
const valid = await verifyPaymentProof(paymentProof, network);
|
|
107
|
+
if (valid) {
|
|
108
|
+
logger_1.Logger.info(`Payment verified for ${route}`);
|
|
109
|
+
return next(); // Payment verified, proceed
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Return 402 Payment Required
|
|
113
|
+
const requirement = {
|
|
114
|
+
network: priceTag.network,
|
|
115
|
+
token: x402_1.USDC_ADDRESSES[priceTag.network],
|
|
116
|
+
amount: priceTag.price,
|
|
117
|
+
receiver: priceTag.receiver || options.receiver,
|
|
118
|
+
description: priceTag.description,
|
|
119
|
+
route: route,
|
|
120
|
+
method: req.method,
|
|
121
|
+
expiresAt: Math.floor(Date.now() / 1000) + 3600 // 1 hour
|
|
122
|
+
};
|
|
123
|
+
res.status(402);
|
|
124
|
+
res.setHeader('X-Payment-Required', JSON.stringify(requirement));
|
|
125
|
+
res.setHeader('Content-Type', 'application/json');
|
|
126
|
+
return res.json({
|
|
127
|
+
error: 'Payment Required',
|
|
128
|
+
status: 402,
|
|
129
|
+
payment_required: requirement,
|
|
130
|
+
message: `This endpoint requires a payment of ${priceTag.price} USDC on ${priceTag.network}`,
|
|
131
|
+
instructions: {
|
|
132
|
+
step1: 'Sign an EIP-712 payment message with your wallet',
|
|
133
|
+
step2: 'Submit the signature to the facilitator for verification',
|
|
134
|
+
step3: 'Include the payment proof in X-Payment-Proof header',
|
|
135
|
+
facilitator: options.facilitatorUrl || 'https://x402.org/facilitator/',
|
|
136
|
+
network: network,
|
|
137
|
+
usdc_address: x402_1.USDC_ADDRESSES[network]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create price tag for a route
|
|
144
|
+
*/
|
|
145
|
+
function priceTag(price, receiver, description, network = 'avalanche-fuji') {
|
|
146
|
+
return {
|
|
147
|
+
price,
|
|
148
|
+
network,
|
|
149
|
+
receiver,
|
|
150
|
+
description
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Helper to wrap existing route handlers with payment requirement
|
|
155
|
+
*/
|
|
156
|
+
function requirePayment(priceTag, handler) {
|
|
157
|
+
const middleware = x402Middleware({
|
|
158
|
+
receiver: priceTag.receiver,
|
|
159
|
+
pricing: { '*': priceTag },
|
|
160
|
+
network: priceTag.network
|
|
161
|
+
});
|
|
162
|
+
return [middleware, handler];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Dynamic pricing based on request parameters
|
|
166
|
+
* (e.g., price per GB for downloads)
|
|
167
|
+
*/
|
|
168
|
+
function dynamicPricing(calculatePrice) {
|
|
169
|
+
return async (req, res, next) => {
|
|
170
|
+
const priceTag = calculatePrice(req);
|
|
171
|
+
if (!priceTag) {
|
|
172
|
+
return next(); // No payment required
|
|
173
|
+
}
|
|
174
|
+
// Check for existing payment
|
|
175
|
+
const paymentProof = req.headers['x-payment-proof'];
|
|
176
|
+
if (paymentProof) {
|
|
177
|
+
const valid = await verifyPaymentProof(paymentProof, priceTag.network);
|
|
178
|
+
if (valid) {
|
|
179
|
+
return next();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Return 402
|
|
183
|
+
const requirement = {
|
|
184
|
+
network: priceTag.network,
|
|
185
|
+
token: x402_1.USDC_ADDRESSES[priceTag.network],
|
|
186
|
+
amount: priceTag.price,
|
|
187
|
+
receiver: priceTag.receiver,
|
|
188
|
+
description: priceTag.description,
|
|
189
|
+
route: req.path,
|
|
190
|
+
method: req.method
|
|
191
|
+
};
|
|
192
|
+
res.status(402);
|
|
193
|
+
res.setHeader('X-Payment-Required', JSON.stringify(requirement));
|
|
194
|
+
return res.json({
|
|
195
|
+
error: 'Payment Required',
|
|
196
|
+
payment_required: requirement
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Example: Dynamic pricing for file downloads (per GB)
|
|
202
|
+
*/
|
|
203
|
+
function downloadPricing(pricePerGB, receiver) {
|
|
204
|
+
return dynamicPricing((req) => {
|
|
205
|
+
const fileSize = parseInt(req.query.size) || 0;
|
|
206
|
+
const sizeGB = fileSize / (1024 * 1024 * 1024);
|
|
207
|
+
if (sizeGB <= 0.1) {
|
|
208
|
+
return null; // Free for files under 100MB
|
|
209
|
+
}
|
|
210
|
+
const priceNum = parseFloat(pricePerGB.replace('$', ''));
|
|
211
|
+
const totalPrice = (priceNum * sizeGB).toFixed(2);
|
|
212
|
+
return {
|
|
213
|
+
price: `$${totalPrice}`,
|
|
214
|
+
network: 'avalanche-fuji',
|
|
215
|
+
receiver,
|
|
216
|
+
description: `Download ${sizeGB.toFixed(2)} GB file`
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/lib/x402/middleware.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAoHH,wCA6DC;AAKD,4BAYC;AAKD,wCAWC;AAMD,wCAqCC;AAKD,0CAmBC;AAlRD,mCAAgC;AAChC,2CAW0B;AAC1B,4CAAyC;AAEzC,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;GAEG;AACH,KAAK,UAAU,sBAAsB,CACnC,OAA2B,EAC3B,OAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,gBAAS,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,WAAW,GAAG,qBAAc,CAAC,OAAO,CAAC,CAAC;QAE5C,iBAAiB;QACjB,MAAM,MAAM,GAAG;YACb,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,OAAO;YAChB,iBAAiB,EAAE,WAAW;SAC/B,CAAC;QAEF,eAAe;QACf,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QA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