@moneymq/sdk 0.3.2 → 0.5.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/dist/index.d.mts +316 -60
- package/dist/index.d.ts +316 -60
- package/dist/index.js +252 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// src/catalog.ts
|
|
2
|
+
var PaymentRequiredError = class extends Error {
|
|
3
|
+
constructor(message, paymentRequirements, raw) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.paymentRequirements = paymentRequirements;
|
|
6
|
+
this.raw = raw;
|
|
7
|
+
this.name = "PaymentRequiredError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
2
10
|
var ProductsAPI = class {
|
|
3
11
|
constructor(config) {
|
|
4
12
|
this.config = config;
|
|
@@ -39,7 +47,15 @@ var ProductsAPI = class {
|
|
|
39
47
|
if (params?.limit) query.set("limit", String(params.limit));
|
|
40
48
|
if (params?.startingAfter) query.set("starting_after", params.startingAfter);
|
|
41
49
|
const queryString = query.toString();
|
|
42
|
-
|
|
50
|
+
const result = await this.request(
|
|
51
|
+
"GET",
|
|
52
|
+
`/catalog/v1/products${queryString ? `?${queryString}` : ""}`
|
|
53
|
+
);
|
|
54
|
+
result.data = result.data.map((product) => ({
|
|
55
|
+
...product,
|
|
56
|
+
accessUrl: `${this.config.endpoint}/catalog/v1/products/${product.id}/access`
|
|
57
|
+
}));
|
|
58
|
+
return result;
|
|
43
59
|
}
|
|
44
60
|
/**
|
|
45
61
|
* Update a product
|
|
@@ -53,6 +69,59 @@ var ProductsAPI = class {
|
|
|
53
69
|
async delete(id) {
|
|
54
70
|
return this.request("DELETE", `/catalog/v1/products/${id}`);
|
|
55
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Access a product - gated by x402 payment
|
|
74
|
+
*
|
|
75
|
+
* This endpoint requires payment. If no payment header is provided (or payment is invalid),
|
|
76
|
+
* throws a PaymentRequiredError with the payment requirements.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* try {
|
|
81
|
+
* // First attempt without payment - will throw PaymentRequiredError
|
|
82
|
+
* const access = await moneymq.catalog.products.access('surfnet-max');
|
|
83
|
+
* } catch (error) {
|
|
84
|
+
* if (error instanceof PaymentRequiredError) {
|
|
85
|
+
* // Get payment requirements and create payment
|
|
86
|
+
* const requirements = error.paymentRequirements[0];
|
|
87
|
+
* const paymentHeader = await createPayment(requirements);
|
|
88
|
+
*
|
|
89
|
+
* // Retry with payment
|
|
90
|
+
* const access = await moneymq.catalog.products.access('surfnet-max', {
|
|
91
|
+
* paymentHeader,
|
|
92
|
+
* });
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
async access(id, params) {
|
|
98
|
+
const url = `${this.config.endpoint}/catalog/v1/products/${id}/access`;
|
|
99
|
+
const headers = { "Content-Type": "application/json" };
|
|
100
|
+
if (this.config.secret) {
|
|
101
|
+
headers["Authorization"] = `Bearer ${this.config.secret}`;
|
|
102
|
+
}
|
|
103
|
+
if (params?.paymentHeader) {
|
|
104
|
+
headers["X-Payment"] = params.paymentHeader;
|
|
105
|
+
}
|
|
106
|
+
const response = await fetch(url, {
|
|
107
|
+
method: "GET",
|
|
108
|
+
headers
|
|
109
|
+
});
|
|
110
|
+
if (response.status === 402) {
|
|
111
|
+
const x402Response = await response.json().catch(() => ({}));
|
|
112
|
+
const paymentRequirements = x402Response.accepts || [];
|
|
113
|
+
throw new PaymentRequiredError(
|
|
114
|
+
"Payment required",
|
|
115
|
+
paymentRequirements,
|
|
116
|
+
x402Response
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
const errorData = await response.json().catch(() => ({}));
|
|
121
|
+
throw new Error(errorData.message || `Request failed: ${response.status}`);
|
|
122
|
+
}
|
|
123
|
+
return response.json();
|
|
124
|
+
}
|
|
56
125
|
};
|
|
57
126
|
var PricesAPI = class {
|
|
58
127
|
constructor(config) {
|
|
@@ -256,15 +325,92 @@ var WebhooksAPI = class {
|
|
|
256
325
|
return this.request("POST", "/payment/v1/webhooks/test", { event, data });
|
|
257
326
|
}
|
|
258
327
|
};
|
|
328
|
+
var PaymentIntentsAPI = class {
|
|
329
|
+
constructor(config) {
|
|
330
|
+
this.request = createRequester(config);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Create a payment intent
|
|
334
|
+
* Use this for simple payments without the full checkout session flow
|
|
335
|
+
*/
|
|
336
|
+
async create(params) {
|
|
337
|
+
return this.request("POST", "/catalog/v1/payment_intents", params);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Retrieve a payment intent
|
|
341
|
+
*/
|
|
342
|
+
async retrieve(id) {
|
|
343
|
+
return this.request("GET", `/catalog/v1/payment_intents/${id}`);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Confirm a payment intent
|
|
347
|
+
* This triggers the actual payment (and x402 flow if required)
|
|
348
|
+
*/
|
|
349
|
+
async confirm(id) {
|
|
350
|
+
return this.request("POST", `/catalog/v1/payment_intents/${id}/confirm`, {});
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Cancel a payment intent
|
|
354
|
+
*/
|
|
355
|
+
async cancel(id) {
|
|
356
|
+
return this.request("POST", `/catalog/v1/payment_intents/${id}/cancel`, {});
|
|
357
|
+
}
|
|
358
|
+
};
|
|
259
359
|
var PaymentAPI = class {
|
|
260
360
|
constructor(config) {
|
|
261
361
|
this.request = createRequester(config);
|
|
262
362
|
this.checkout = new CheckoutAPI(config);
|
|
363
|
+
this.intents = new PaymentIntentsAPI(config);
|
|
263
364
|
this.links = new LinksAPI(config);
|
|
264
365
|
this.customers = new CustomersAPI(config);
|
|
265
366
|
this.payouts = new PayoutsAPI(config);
|
|
266
367
|
this.webhooks = new WebhooksAPI(config);
|
|
267
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Simple one-liner payment - creates a checkout session with inline product data
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* const result = await moneymq.payment.pay({
|
|
375
|
+
* amount: 999,
|
|
376
|
+
* currency: 'usd',
|
|
377
|
+
* productName: 'Pro Plan',
|
|
378
|
+
* productId: 'pro-plan',
|
|
379
|
+
* customer: 'wallet_address',
|
|
380
|
+
* });
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
async pay(params) {
|
|
384
|
+
const session = await this.request("POST", "/catalog/v1/checkout/sessions", {
|
|
385
|
+
line_items: [
|
|
386
|
+
{
|
|
387
|
+
price_data: {
|
|
388
|
+
currency: params.currency,
|
|
389
|
+
unit_amount: params.amount,
|
|
390
|
+
product_data: {
|
|
391
|
+
name: params.productName,
|
|
392
|
+
description: params.description,
|
|
393
|
+
metadata: {
|
|
394
|
+
product_id: params.productId || params.productName.toLowerCase().replace(/\s+/g, "-")
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
quantity: 1
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
customer: params.customer,
|
|
402
|
+
metadata: params.metadata,
|
|
403
|
+
mode: "payment"
|
|
404
|
+
});
|
|
405
|
+
return {
|
|
406
|
+
sessionId: session.id,
|
|
407
|
+
paymentIntentId: session.payment_intent,
|
|
408
|
+
clientSecret: session.client_secret,
|
|
409
|
+
amount: session.amount_total,
|
|
410
|
+
currency: session.currency,
|
|
411
|
+
status: "requires_confirmation"
|
|
412
|
+
};
|
|
413
|
+
}
|
|
268
414
|
/**
|
|
269
415
|
* Retrieve a payment by ID
|
|
270
416
|
*/
|
|
@@ -285,8 +431,110 @@ var PaymentAPI = class {
|
|
|
285
431
|
}
|
|
286
432
|
};
|
|
287
433
|
|
|
434
|
+
// src/config.ts
|
|
435
|
+
async function fetchConfig(apiUrl) {
|
|
436
|
+
const response = await fetch(`${apiUrl}/config`);
|
|
437
|
+
if (!response.ok) {
|
|
438
|
+
throw new Error(`Failed to fetch config: ${response.status}`);
|
|
439
|
+
}
|
|
440
|
+
return response.json();
|
|
441
|
+
}
|
|
442
|
+
async function getRpcUrl(apiUrl, fallback = "https://api.devnet.solana.com") {
|
|
443
|
+
try {
|
|
444
|
+
const config = await fetchConfig(apiUrl);
|
|
445
|
+
return config.x402.validator.rpcUrl || fallback;
|
|
446
|
+
} catch {
|
|
447
|
+
return fallback;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/x402.ts
|
|
452
|
+
import { createSigner } from "x402-fetch";
|
|
453
|
+
var X402API = class {
|
|
454
|
+
constructor(config) {
|
|
455
|
+
this.config = config;
|
|
456
|
+
this.serverConfig = null;
|
|
457
|
+
this.sandboxAccounts = null;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Fetch sandbox accounts from the server
|
|
461
|
+
*/
|
|
462
|
+
async fetchSandboxAccounts() {
|
|
463
|
+
if (this.sandboxAccounts) {
|
|
464
|
+
return this.sandboxAccounts;
|
|
465
|
+
}
|
|
466
|
+
const response = await fetch(`${this.config.endpoint}/sandbox/accounts`);
|
|
467
|
+
if (!response.ok) {
|
|
468
|
+
throw new Error(`Failed to fetch sandbox accounts: ${response.status}`);
|
|
469
|
+
}
|
|
470
|
+
this.sandboxAccounts = await response.json();
|
|
471
|
+
return this.sandboxAccounts;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Get a signer for a sandbox account by tag/label
|
|
475
|
+
*
|
|
476
|
+
* @param params - Parameters containing the wallet tag/label
|
|
477
|
+
* @returns A Signer that can be used directly with wrapFetchWithPayment
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* const payer = await moneymq.x402.getSigner({ tag: 'alice' });
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
async getSigner(params) {
|
|
485
|
+
const accounts = await this.fetchSandboxAccounts();
|
|
486
|
+
for (const networkData of Object.values(accounts)) {
|
|
487
|
+
for (const account of networkData.userAccounts) {
|
|
488
|
+
if (account.label === params.tag) {
|
|
489
|
+
if (!account.secretKeyHex) {
|
|
490
|
+
throw new Error(`Account '${params.tag}' does not have a secret key (not locally managed)`);
|
|
491
|
+
}
|
|
492
|
+
return createSigner("solana", account.secretKeyHex);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
throw new Error(`No sandbox account found with label '${params.tag}'`);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Get x402 configuration for use with wrapFetchWithPayment
|
|
500
|
+
*
|
|
501
|
+
* @returns Configuration object compatible with x402-fetch
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const config = await moneymq.x402.getConfig();
|
|
506
|
+
* const fetchWithPayment = wrapFetchWithPayment(fetch, payer, undefined, undefined, config);
|
|
507
|
+
* ```
|
|
508
|
+
*/
|
|
509
|
+
async getConfig() {
|
|
510
|
+
if (!this.serverConfig) {
|
|
511
|
+
this.serverConfig = await fetchConfig(this.config.endpoint);
|
|
512
|
+
}
|
|
513
|
+
return {
|
|
514
|
+
svmConfig: {
|
|
515
|
+
rpcUrl: this.serverConfig.x402.validator.rpcUrl
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Get the full server configuration
|
|
521
|
+
*
|
|
522
|
+
* @returns The complete server configuration including x402 settings
|
|
523
|
+
*/
|
|
524
|
+
async getServerConfig() {
|
|
525
|
+
if (!this.serverConfig) {
|
|
526
|
+
this.serverConfig = await fetchConfig(this.config.endpoint);
|
|
527
|
+
}
|
|
528
|
+
return this.serverConfig;
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
288
532
|
// src/client.ts
|
|
289
533
|
var MoneyMQ = class {
|
|
534
|
+
/** MoneyMQ API endpoint */
|
|
535
|
+
get endpoint() {
|
|
536
|
+
return this.config.endpoint;
|
|
537
|
+
}
|
|
290
538
|
constructor(config) {
|
|
291
539
|
this.config = {
|
|
292
540
|
timeout: 3e4,
|
|
@@ -294,6 +542,7 @@ var MoneyMQ = class {
|
|
|
294
542
|
};
|
|
295
543
|
this.catalog = new CatalogAPI(this.config);
|
|
296
544
|
this.payment = new PaymentAPI(this.config);
|
|
545
|
+
this.x402 = new X402API(this.config);
|
|
297
546
|
}
|
|
298
547
|
/**
|
|
299
548
|
* Make an authenticated request to the MoneyMQ API
|
|
@@ -331,25 +580,9 @@ var MoneyMQError = class extends Error {
|
|
|
331
580
|
this.name = "MoneyMQError";
|
|
332
581
|
}
|
|
333
582
|
};
|
|
334
|
-
|
|
335
|
-
// src/config.ts
|
|
336
|
-
async function fetchConfig(apiUrl) {
|
|
337
|
-
const response = await fetch(`${apiUrl}/config`);
|
|
338
|
-
if (!response.ok) {
|
|
339
|
-
throw new Error(`Failed to fetch config: ${response.status}`);
|
|
340
|
-
}
|
|
341
|
-
return response.json();
|
|
342
|
-
}
|
|
343
|
-
async function getRpcUrl(apiUrl, fallback = "https://api.devnet.solana.com") {
|
|
344
|
-
try {
|
|
345
|
-
const config = await fetchConfig(apiUrl);
|
|
346
|
-
return config.x402.validator.rpcUrl || fallback;
|
|
347
|
-
} catch {
|
|
348
|
-
return fallback;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
583
|
export {
|
|
352
584
|
MoneyMQ,
|
|
585
|
+
PaymentRequiredError,
|
|
353
586
|
fetchConfig,
|
|
354
587
|
getRpcUrl
|
|
355
588
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/catalog.ts","../src/payment.ts","../src/client.ts","../src/config.ts"],"sourcesContent":["import type { MoneyMQConfig } from './client';\n\n// Types\nexport interface Product {\n id: string;\n object: 'product';\n name: string;\n description?: string;\n active: boolean;\n metadata?: Record<string, string>;\n created: number;\n updated: number;\n}\n\nexport interface ProductCreateParams {\n name: string;\n description?: string;\n active?: boolean;\n metadata?: Record<string, string>;\n}\n\nexport interface ProductListParams {\n active?: boolean;\n limit?: number;\n startingAfter?: string;\n}\n\nexport interface Price {\n id: string;\n object: 'price';\n product: string;\n currency: string;\n amount: number;\n type: 'one_time' | 'recurring';\n recurring?: {\n interval: 'day' | 'week' | 'month' | 'year';\n intervalCount: number;\n };\n active: boolean;\n metadata?: Record<string, string>;\n created: number;\n}\n\nexport interface PriceCreateParams {\n product: string;\n currency: string;\n amount: number;\n type: 'one_time' | 'recurring';\n recurring?: {\n interval: 'day' | 'week' | 'month' | 'year';\n intervalCount?: number;\n };\n metadata?: Record<string, string>;\n}\n\n// API Classes\nclass ProductsAPI {\n constructor(private config: MoneyMQConfig) {}\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (this.config.secret) headers['Authorization'] = `Bearer ${this.config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n }\n\n /**\n * Create a new product\n */\n async create(params: ProductCreateParams): Promise<Product> {\n return this.request('POST', '/catalog/v1/products', params);\n }\n\n /**\n * Retrieve a product by ID\n */\n async retrieve(id: string): Promise<Product> {\n return this.request('GET', `/catalog/v1/products/${id}`);\n }\n\n /**\n * List all products\n */\n async list(params?: ProductListParams): Promise<{ data: Product[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.active !== undefined) query.set('active', String(params.active));\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n return this.request('GET', `/catalog/v1/products${queryString ? `?${queryString}` : ''}`);\n }\n\n /**\n * Update a product\n */\n async update(id: string, params: Partial<ProductCreateParams>): Promise<Product> {\n return this.request('PUT', `/catalog/v1/products/${id}`, params);\n }\n\n /**\n * Delete a product\n */\n async delete(id: string): Promise<{ deleted: boolean }> {\n return this.request('DELETE', `/catalog/v1/products/${id}`);\n }\n}\n\nclass PricesAPI {\n constructor(private config: MoneyMQConfig) {}\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (this.config.secret) headers['Authorization'] = `Bearer ${this.config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n }\n\n /**\n * Create a new price\n */\n async create(params: PriceCreateParams): Promise<Price> {\n return this.request('POST', '/catalog/v1/prices', params);\n }\n\n /**\n * Retrieve a price by ID\n */\n async retrieve(id: string): Promise<Price> {\n return this.request('GET', `/catalog/v1/prices/${id}`);\n }\n\n /**\n * List all prices\n */\n async list(params?: {\n product?: string;\n active?: boolean;\n limit?: number;\n }): Promise<{ data: Price[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.product) query.set('product', params.product);\n if (params?.active !== undefined) query.set('active', String(params.active));\n if (params?.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return this.request('GET', `/catalog/v1/prices${queryString ? `?${queryString}` : ''}`);\n }\n}\n\n/**\n * Catalog API for managing products and prices\n */\nexport class CatalogAPI {\n /** Products API */\n public readonly products: ProductsAPI;\n\n /** Prices API */\n public readonly prices: PricesAPI;\n\n constructor(config: MoneyMQConfig) {\n this.products = new ProductsAPI(config);\n this.prices = new PricesAPI(config);\n }\n}\n","import type { MoneyMQConfig } from './client';\n\n// Types\nexport interface LineItem {\n price: string;\n quantity: number;\n}\n\nexport interface CheckoutSession {\n id: string;\n object: 'checkout.session';\n url: string;\n status: 'open' | 'complete' | 'expired';\n paymentStatus: 'unpaid' | 'paid';\n customer?: string;\n lineItems: LineItem[];\n successUrl: string;\n cancelUrl: string;\n expiresAt: number;\n created: number;\n}\n\nexport interface CheckoutCreateParams {\n lineItems: LineItem[];\n successUrl: string;\n cancelUrl: string;\n customerEmail?: string;\n customer?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface PaymentLink {\n id: string;\n object: 'payment_link';\n url: string;\n active: boolean;\n lineItems: LineItem[];\n expiresAt?: number;\n created: number;\n}\n\nexport interface PaymentLinkCreateParams {\n lineItems: LineItem[];\n expiresAt?: Date | number;\n metadata?: Record<string, string>;\n}\n\nexport interface Payment {\n id: string;\n object: 'payment';\n amount: number;\n currency: string;\n status: 'completed' | 'pending' | 'failed';\n customer?: string;\n checkout?: string;\n signature?: string;\n metadata?: Record<string, string>;\n created: number;\n}\n\nexport interface PaymentListParams {\n customerId?: string;\n status?: 'completed' | 'pending' | 'failed';\n limit?: number;\n startingAfter?: string;\n}\n\nexport interface Customer {\n id: string;\n object: 'customer';\n email: string;\n name?: string;\n metadata?: Record<string, string>;\n subscriptions?: unknown[];\n payments?: Payment[];\n created: number;\n}\n\nexport interface CustomerCreateParams {\n email: string;\n name?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface CustomerUpdateParams {\n email?: string;\n name?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface Payout {\n id: string;\n object: 'payout';\n amount: number;\n currency: string;\n status: 'pending' | 'completed' | 'failed';\n destination: string;\n created: number;\n}\n\nexport interface PayoutCreateParams {\n amount: number;\n currency: string;\n destination: string;\n}\n\nexport interface PayoutListParams {\n status?: 'pending' | 'completed' | 'failed';\n limit?: number;\n startingAfter?: string;\n}\n\nexport interface PayoutSettings {\n destination: {\n type: 'wallet';\n address: string;\n currency: string;\n };\n schedule: 'instant' | 'daily' | 'weekly' | 'monthly';\n minimumAmount?: number;\n}\n\nexport interface PayoutSettingsUpdateParams {\n destination?: PayoutSettings['destination'];\n schedule?: PayoutSettings['schedule'];\n minimumAmount?: number;\n}\n\n// Helper for making requests\nfunction createRequester(config: MoneyMQConfig) {\n return async function request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (config.secret) headers['Authorization'] = `Bearer ${config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n };\n}\n\n// API Classes\nclass CheckoutAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a checkout session\n */\n async create(params: CheckoutCreateParams): Promise<CheckoutSession> {\n return this.request('POST', '/payment/v1/checkout', params);\n }\n\n /**\n * Retrieve a checkout session\n */\n async retrieve(id: string): Promise<CheckoutSession> {\n return this.request('GET', `/payment/v1/checkout/${id}`);\n }\n}\n\nclass LinksAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a payment link\n */\n async create(params: PaymentLinkCreateParams): Promise<PaymentLink> {\n return this.request('POST', '/payment/v1/links', {\n ...params,\n expiresAt: params.expiresAt instanceof Date ? params.expiresAt.getTime() : params.expiresAt,\n });\n }\n\n /**\n * Retrieve a payment link\n */\n async retrieve(id: string): Promise<PaymentLink> {\n return this.request('GET', `/payment/v1/links/${id}`);\n }\n\n /**\n * Deactivate a payment link\n */\n async deactivate(id: string): Promise<PaymentLink> {\n return this.request('PUT', `/payment/v1/links/${id}`, { active: false });\n }\n}\n\nclass CustomersAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a customer\n */\n async create(params: CustomerCreateParams): Promise<Customer> {\n return this.request('POST', '/payment/v1/customers', params);\n }\n\n /**\n * Retrieve a customer\n */\n async retrieve(id: string, options?: { expand?: string[] }): Promise<Customer> {\n const query = options?.expand ? `?expand=${options.expand.join(',')}` : '';\n return this.request('GET', `/payment/v1/customers/${id}${query}`);\n }\n\n /**\n * Update a customer\n */\n async update(id: string, params: CustomerUpdateParams): Promise<Customer> {\n return this.request('PUT', `/payment/v1/customers/${id}`, params);\n }\n\n /**\n * List customers\n */\n async list(params?: {\n email?: string;\n limit?: number;\n }): Promise<{ data: Customer[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.email) query.set('email', params.email);\n if (params?.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1/customers${queryString ? `?${queryString}` : ''}`);\n }\n}\n\nclass PayoutsAPI {\n private request: ReturnType<typeof createRequester>;\n\n /** Payout settings */\n public readonly settings: PayoutSettingsAPI;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n this.settings = new PayoutSettingsAPI(config);\n }\n\n /**\n * Create a manual payout\n */\n async create(params: PayoutCreateParams): Promise<Payout> {\n return this.request('POST', '/payment/v1/payouts', params);\n }\n\n /**\n * Retrieve a payout\n */\n async retrieve(id: string): Promise<Payout> {\n return this.request('GET', `/payment/v1/payouts/${id}`);\n }\n\n /**\n * List payouts\n */\n async list(params?: PayoutListParams): Promise<{ data: Payout[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.status) query.set('status', params.status);\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1/payouts${queryString ? `?${queryString}` : ''}`);\n }\n}\n\nclass PayoutSettingsAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Get payout settings\n */\n async retrieve(): Promise<PayoutSettings> {\n return this.request('GET', '/payment/v1/payouts/settings');\n }\n\n /**\n * Update payout settings\n */\n async update(params: PayoutSettingsUpdateParams): Promise<PayoutSettings> {\n return this.request('PUT', '/payment/v1/payouts/settings', params);\n }\n}\n\nclass WebhooksAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Trigger a test webhook event (for testing)\n */\n async trigger(event: string, data: Record<string, unknown>): Promise<{ success: boolean }> {\n return this.request('POST', '/payment/v1/webhooks/test', { event, data });\n }\n}\n\n/**\n * Payment API for checkout, links, customers, and payouts\n */\nexport class PaymentAPI {\n private request: ReturnType<typeof createRequester>;\n\n /** Checkout sessions API */\n public readonly checkout: CheckoutAPI;\n\n /** Payment links API */\n public readonly links: LinksAPI;\n\n /** Customers API */\n public readonly customers: CustomersAPI;\n\n /** Payouts API */\n public readonly payouts: PayoutsAPI;\n\n /** Webhooks API */\n public readonly webhooks: WebhooksAPI;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n this.checkout = new CheckoutAPI(config);\n this.links = new LinksAPI(config);\n this.customers = new CustomersAPI(config);\n this.payouts = new PayoutsAPI(config);\n this.webhooks = new WebhooksAPI(config);\n }\n\n /**\n * Retrieve a payment by ID\n */\n async retrieve(id: string): Promise<Payment> {\n return this.request('GET', `/payment/v1/${id}`);\n }\n\n /**\n * List payments\n */\n async list(params?: PaymentListParams): Promise<{ data: Payment[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.customerId) query.set('customer', params.customerId);\n if (params?.status) query.set('status', params.status);\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1${queryString ? `?${queryString}` : ''}`);\n }\n}\n","import { CatalogAPI } from './catalog';\nimport { PaymentAPI } from './payment';\n\n/**\n * Configuration options for the MoneyMQ client\n *\n * @example\n * ```typescript\n * const config: MoneyMQConfig = {\n * endpoint: 'https://api.moneymq.com',\n * secret: 'your-api-secret', // Optional\n * timeout: 30000,\n * };\n * ```\n */\nexport interface MoneyMQConfig {\n /**\n * MoneyMQ API endpoint\n * @example 'http://localhost:8488' or 'https://api.moneymq.com'\n */\n endpoint: string;\n /**\n * Optional secret key for authenticated requests\n * Used for server-side operations that require authentication\n */\n secret?: string;\n /**\n * Request timeout in milliseconds\n * @default 30000\n */\n timeout?: number;\n}\n\n/**\n * MoneyMQ SDK client for accepting stablecoin payments\n *\n * @example\n * ```typescript\n * import { MoneyMQ } from '@moneymq/sdk';\n *\n * const moneymq = new MoneyMQ({\n * endpoint: process.env.MONEYMQ_ENDPOINT ?? 'http://localhost:8488',\n * });\n *\n * // Create a product\n * const product = await moneymq.catalog.products.create({\n * name: 'Pro Plan',\n * description: 'Full access to all features',\n * });\n *\n * // Create a checkout session\n * const session = await moneymq.payment.checkout.create({\n * lineItems: [{ price: 'price_xxx', quantity: 1 }],\n * successUrl: 'https://example.com/success',\n * cancelUrl: 'https://example.com/cancel',\n * });\n * ```\n */\nexport class MoneyMQ {\n public readonly config: MoneyMQConfig;\n\n /** Catalog API for products and prices */\n public readonly catalog: CatalogAPI;\n\n /** Payment API for checkout, links, customers, and payouts */\n public readonly payment: PaymentAPI;\n\n constructor(config: MoneyMQConfig) {\n this.config = {\n timeout: 30000,\n ...config,\n };\n\n this.catalog = new CatalogAPI(this.config);\n this.payment = new PaymentAPI(this.config);\n }\n\n /**\n * Make an authenticated request to the MoneyMQ API\n */\n async request<T>(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n\n if (this.config.secret) {\n headers['Authorization'] = `Bearer ${this.config.secret}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.config.timeout!),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new MoneyMQError(\n errorData.message || `Request failed with status ${response.status}`,\n response.status,\n errorData,\n );\n }\n\n return response.json() as Promise<T>;\n }\n}\n\n/**\n * MoneyMQ API error\n */\nexport class MoneyMQError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n public readonly raw?: unknown,\n ) {\n super(message);\n this.name = 'MoneyMQError';\n }\n}\n","/**\n * MoneyMQ server configuration returned from /config endpoint\n */\nexport interface ServerConfig {\n account: {\n name: string;\n description: string;\n };\n x402: {\n payoutAccount: {\n currency: string;\n decimals: number;\n address: string;\n tokenAddress: string;\n };\n facilitator: {\n operatorAccount: {\n out: string;\n in: {\n currency: string;\n decimals: number;\n address: string;\n tokenAddress: string;\n };\n };\n url: string;\n };\n validator: {\n network: string;\n rpcUrl: string;\n bindHost: string;\n rpcPort: number;\n wsPort: number;\n };\n };\n}\n\n/**\n * Fetch server configuration from MoneyMQ API\n *\n * @param apiUrl - The MoneyMQ API URL\n * @returns Server configuration including RPC URL\n *\n * @example\n * ```typescript\n * const config = await fetchConfig('http://localhost:8488');\n * console.log(config.x402.validator.rpcUrl);\n * ```\n */\nexport async function fetchConfig(apiUrl: string): Promise<ServerConfig> {\n const response = await fetch(`${apiUrl}/config`);\n if (!response.ok) {\n throw new Error(`Failed to fetch config: ${response.status}`);\n }\n return response.json() as Promise<ServerConfig>;\n}\n\n/**\n * Get the Solana RPC URL from server config\n *\n * @param apiUrl - The MoneyMQ API URL\n * @param fallback - Fallback RPC URL if fetch fails\n * @returns RPC URL string\n */\nexport async function getRpcUrl(\n apiUrl: string,\n fallback = 'https://api.devnet.solana.com'\n): Promise<string> {\n try {\n const config = await fetchConfig(apiUrl);\n return config.x402.validator.rpcUrl || fallback;\n } catch {\n return fallback;\n }\n}\n"],"mappings":";AAwDA,IAAM,cAAN,MAAkB;AAAA,EA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O,KAAK,UAAU,UAAU;AAAA,EACzC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/catalog.ts","../src/payment.ts","../src/config.ts","../src/x402.ts","../src/client.ts"],"sourcesContent":["import type { MoneyMQConfig } from './client';\n\n// Types\n\n/** Payment requirements returned when payment is required (402) */\nexport interface PaymentRequirements {\n scheme: string;\n network: string;\n max_amount_required: string;\n resource: string;\n description: string;\n mime_type: string;\n pay_to: string;\n max_timeout_seconds: number;\n asset: string;\n extra?: {\n feePayer?: string;\n product?: string;\n };\n}\n\n/** Error thrown when payment is required to access a resource */\nexport class PaymentRequiredError extends Error {\n constructor(\n message: string,\n public readonly paymentRequirements: PaymentRequirements[],\n public readonly raw: unknown,\n ) {\n super(message);\n this.name = 'PaymentRequiredError';\n }\n}\n\n/** Response from product access endpoint */\nexport interface ProductAccessResponse {\n object: 'product_access';\n product_id: string;\n access_granted: boolean;\n message: string;\n}\n\n/** Parameters for accessing a product with x402 payment */\nexport interface ProductAccessParams {\n /** Base64-encoded X-Payment header value */\n paymentHeader?: string;\n}\n\nexport interface Product {\n id: string;\n object: 'product';\n name: string;\n description?: string;\n active: boolean;\n metadata?: Record<string, string>;\n created: number;\n updated: number;\n /** URL path for accessing this product (x402 gated) */\n accessUrl: string;\n}\n\nexport interface ProductCreateParams {\n name: string;\n description?: string;\n active?: boolean;\n metadata?: Record<string, string>;\n}\n\nexport interface ProductListParams {\n active?: boolean;\n limit?: number;\n startingAfter?: string;\n}\n\nexport interface Price {\n id: string;\n object: 'price';\n product: string;\n currency: string;\n amount: number;\n type: 'one_time' | 'recurring';\n recurring?: {\n interval: 'day' | 'week' | 'month' | 'year';\n intervalCount: number;\n };\n active: boolean;\n metadata?: Record<string, string>;\n created: number;\n}\n\nexport interface PriceCreateParams {\n product: string;\n currency: string;\n amount: number;\n type: 'one_time' | 'recurring';\n recurring?: {\n interval: 'day' | 'week' | 'month' | 'year';\n intervalCount?: number;\n };\n metadata?: Record<string, string>;\n}\n\n// API Classes\nclass ProductsAPI {\n constructor(private config: MoneyMQConfig) {}\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (this.config.secret) headers['Authorization'] = `Bearer ${this.config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n }\n\n /**\n * Create a new product\n */\n async create(params: ProductCreateParams): Promise<Product> {\n return this.request('POST', '/catalog/v1/products', params);\n }\n\n /**\n * Retrieve a product by ID\n */\n async retrieve(id: string): Promise<Product> {\n return this.request('GET', `/catalog/v1/products/${id}`);\n }\n\n /**\n * List all products\n */\n async list(params?: ProductListParams): Promise<{ data: Product[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.active !== undefined) query.set('active', String(params.active));\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n const result = await this.request<{ data: Product[]; hasMore: boolean }>(\n 'GET',\n `/catalog/v1/products${queryString ? `?${queryString}` : ''}`,\n );\n\n // Add accessUrl to each product (full URL)\n result.data = result.data.map((product) => ({\n ...product,\n accessUrl: `${this.config.endpoint}/catalog/v1/products/${product.id}/access`,\n }));\n\n return result;\n }\n\n /**\n * Update a product\n */\n async update(id: string, params: Partial<ProductCreateParams>): Promise<Product> {\n return this.request('PUT', `/catalog/v1/products/${id}`, params);\n }\n\n /**\n * Delete a product\n */\n async delete(id: string): Promise<{ deleted: boolean }> {\n return this.request('DELETE', `/catalog/v1/products/${id}`);\n }\n\n /**\n * Access a product - gated by x402 payment\n *\n * This endpoint requires payment. If no payment header is provided (or payment is invalid),\n * throws a PaymentRequiredError with the payment requirements.\n *\n * @example\n * ```ts\n * try {\n * // First attempt without payment - will throw PaymentRequiredError\n * const access = await moneymq.catalog.products.access('surfnet-max');\n * } catch (error) {\n * if (error instanceof PaymentRequiredError) {\n * // Get payment requirements and create payment\n * const requirements = error.paymentRequirements[0];\n * const paymentHeader = await createPayment(requirements);\n *\n * // Retry with payment\n * const access = await moneymq.catalog.products.access('surfnet-max', {\n * paymentHeader,\n * });\n * }\n * }\n * ```\n */\n async access(id: string, params?: ProductAccessParams): Promise<ProductAccessResponse> {\n const url = `${this.config.endpoint}/catalog/v1/products/${id}/access`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n\n if (this.config.secret) {\n headers['Authorization'] = `Bearer ${this.config.secret}`;\n }\n\n if (params?.paymentHeader) {\n headers['X-Payment'] = params.paymentHeader;\n }\n\n const response = await fetch(url, {\n method: 'GET',\n headers,\n });\n\n if (response.status === 402) {\n // Payment required - extract payment requirements from x402 response\n const x402Response = (await response.json().catch(() => ({}))) as {\n x402Version?: number;\n accepts?: PaymentRequirements[];\n };\n\n const paymentRequirements = x402Response.accepts || [];\n throw new PaymentRequiredError(\n 'Payment required',\n paymentRequirements,\n x402Response,\n );\n }\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<ProductAccessResponse>;\n }\n}\n\nclass PricesAPI {\n constructor(private config: MoneyMQConfig) {}\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (this.config.secret) headers['Authorization'] = `Bearer ${this.config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n }\n\n /**\n * Create a new price\n */\n async create(params: PriceCreateParams): Promise<Price> {\n return this.request('POST', '/catalog/v1/prices', params);\n }\n\n /**\n * Retrieve a price by ID\n */\n async retrieve(id: string): Promise<Price> {\n return this.request('GET', `/catalog/v1/prices/${id}`);\n }\n\n /**\n * List all prices\n */\n async list(params?: {\n product?: string;\n active?: boolean;\n limit?: number;\n }): Promise<{ data: Price[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.product) query.set('product', params.product);\n if (params?.active !== undefined) query.set('active', String(params.active));\n if (params?.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return this.request('GET', `/catalog/v1/prices${queryString ? `?${queryString}` : ''}`);\n }\n}\n\n/**\n * Catalog API for managing products and prices\n */\nexport class CatalogAPI {\n /** Products API */\n public readonly products: ProductsAPI;\n\n /** Prices API */\n public readonly prices: PricesAPI;\n\n constructor(config: MoneyMQConfig) {\n this.products = new ProductsAPI(config);\n this.prices = new PricesAPI(config);\n }\n}\n","import type { MoneyMQConfig } from './client';\n\n// Types\nexport interface LineItem {\n price: string;\n quantity: number;\n}\n\nexport interface CheckoutSession {\n id: string;\n object: 'checkout.session';\n url: string;\n status: 'open' | 'complete' | 'expired';\n paymentStatus: 'unpaid' | 'paid';\n customer?: string;\n lineItems: LineItem[];\n successUrl: string;\n cancelUrl: string;\n expiresAt: number;\n created: number;\n}\n\nexport interface CheckoutCreateParams {\n lineItems: LineItem[];\n successUrl: string;\n cancelUrl: string;\n customerEmail?: string;\n customer?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface PaymentLink {\n id: string;\n object: 'payment_link';\n url: string;\n active: boolean;\n lineItems: LineItem[];\n expiresAt?: number;\n created: number;\n}\n\nexport interface PaymentLinkCreateParams {\n lineItems: LineItem[];\n expiresAt?: Date | number;\n metadata?: Record<string, string>;\n}\n\nexport interface Payment {\n id: string;\n object: 'payment';\n amount: number;\n currency: string;\n status: 'completed' | 'pending' | 'failed';\n customer?: string;\n checkout?: string;\n signature?: string;\n metadata?: Record<string, string>;\n created: number;\n}\n\nexport interface PaymentListParams {\n customerId?: string;\n status?: 'completed' | 'pending' | 'failed';\n limit?: number;\n startingAfter?: string;\n}\n\n// Simple pay params - for one-liner payments\nexport interface PayParams {\n /** Amount in smallest currency unit (e.g., cents for USD) */\n amount: number;\n /** Currency code (e.g., 'usd', 'usdc') */\n currency: string;\n /** Product name for display */\n productName: string;\n /** Product ID for tracking */\n productId?: string;\n /** Optional product description */\n description?: string;\n /** Customer wallet address */\n customer?: string;\n /** Additional metadata */\n metadata?: Record<string, string>;\n}\n\nexport interface PayResult {\n /** Checkout session ID */\n sessionId: string;\n /** Payment intent ID */\n paymentIntentId: string;\n /** Client secret for confirming payment */\n clientSecret: string;\n /** Total amount in smallest currency unit */\n amount: number;\n /** Currency */\n currency: string;\n /** Status */\n status: 'requires_confirmation' | 'succeeded' | 'failed';\n}\n\n// Payment Intent types (simpler than checkout sessions)\nexport interface PaymentIntent {\n id: string;\n object: 'payment_intent';\n amount: number;\n currency: string;\n status: 'requires_payment_method' | 'requires_confirmation' | 'processing' | 'succeeded' | 'canceled';\n customer?: string;\n description?: string;\n metadata: Record<string, string>;\n clientSecret?: string;\n created: number;\n}\n\nexport interface PaymentIntentCreateParams {\n /** Amount in smallest currency unit */\n amount: number;\n /** Currency code */\n currency: string;\n /** Customer wallet address */\n customer?: string;\n /** Description */\n description?: string;\n /** Metadata including product info */\n metadata?: Record<string, string>;\n}\n\nexport interface Customer {\n id: string;\n object: 'customer';\n email: string;\n name?: string;\n metadata?: Record<string, string>;\n subscriptions?: unknown[];\n payments?: Payment[];\n created: number;\n}\n\nexport interface CustomerCreateParams {\n email: string;\n name?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface CustomerUpdateParams {\n email?: string;\n name?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface Payout {\n id: string;\n object: 'payout';\n amount: number;\n currency: string;\n status: 'pending' | 'completed' | 'failed';\n destination: string;\n created: number;\n}\n\nexport interface PayoutCreateParams {\n amount: number;\n currency: string;\n destination: string;\n}\n\nexport interface PayoutListParams {\n status?: 'pending' | 'completed' | 'failed';\n limit?: number;\n startingAfter?: string;\n}\n\nexport interface PayoutSettings {\n destination: {\n type: 'wallet';\n address: string;\n currency: string;\n };\n schedule: 'instant' | 'daily' | 'weekly' | 'monthly';\n minimumAmount?: number;\n}\n\nexport interface PayoutSettingsUpdateParams {\n destination?: PayoutSettings['destination'];\n schedule?: PayoutSettings['schedule'];\n minimumAmount?: number;\n}\n\n// Helper for making requests\nfunction createRequester(config: MoneyMQConfig) {\n return async function request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const url = `${config.endpoint}${path}`;\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (config.secret) headers['Authorization'] = `Bearer ${config.secret}`;\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new Error(errorData.message || `Request failed: ${response.status}`);\n }\n\n return response.json() as Promise<T>;\n };\n}\n\n// API Classes\nclass CheckoutAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a checkout session\n */\n async create(params: CheckoutCreateParams): Promise<CheckoutSession> {\n return this.request('POST', '/payment/v1/checkout', params);\n }\n\n /**\n * Retrieve a checkout session\n */\n async retrieve(id: string): Promise<CheckoutSession> {\n return this.request('GET', `/payment/v1/checkout/${id}`);\n }\n}\n\nclass LinksAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a payment link\n */\n async create(params: PaymentLinkCreateParams): Promise<PaymentLink> {\n return this.request('POST', '/payment/v1/links', {\n ...params,\n expiresAt: params.expiresAt instanceof Date ? params.expiresAt.getTime() : params.expiresAt,\n });\n }\n\n /**\n * Retrieve a payment link\n */\n async retrieve(id: string): Promise<PaymentLink> {\n return this.request('GET', `/payment/v1/links/${id}`);\n }\n\n /**\n * Deactivate a payment link\n */\n async deactivate(id: string): Promise<PaymentLink> {\n return this.request('PUT', `/payment/v1/links/${id}`, { active: false });\n }\n}\n\nclass CustomersAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a customer\n */\n async create(params: CustomerCreateParams): Promise<Customer> {\n return this.request('POST', '/payment/v1/customers', params);\n }\n\n /**\n * Retrieve a customer\n */\n async retrieve(id: string, options?: { expand?: string[] }): Promise<Customer> {\n const query = options?.expand ? `?expand=${options.expand.join(',')}` : '';\n return this.request('GET', `/payment/v1/customers/${id}${query}`);\n }\n\n /**\n * Update a customer\n */\n async update(id: string, params: CustomerUpdateParams): Promise<Customer> {\n return this.request('PUT', `/payment/v1/customers/${id}`, params);\n }\n\n /**\n * List customers\n */\n async list(params?: {\n email?: string;\n limit?: number;\n }): Promise<{ data: Customer[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.email) query.set('email', params.email);\n if (params?.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1/customers${queryString ? `?${queryString}` : ''}`);\n }\n}\n\nclass PayoutsAPI {\n private request: ReturnType<typeof createRequester>;\n\n /** Payout settings */\n public readonly settings: PayoutSettingsAPI;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n this.settings = new PayoutSettingsAPI(config);\n }\n\n /**\n * Create a manual payout\n */\n async create(params: PayoutCreateParams): Promise<Payout> {\n return this.request('POST', '/payment/v1/payouts', params);\n }\n\n /**\n * Retrieve a payout\n */\n async retrieve(id: string): Promise<Payout> {\n return this.request('GET', `/payment/v1/payouts/${id}`);\n }\n\n /**\n * List payouts\n */\n async list(params?: PayoutListParams): Promise<{ data: Payout[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.status) query.set('status', params.status);\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1/payouts${queryString ? `?${queryString}` : ''}`);\n }\n}\n\nclass PayoutSettingsAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Get payout settings\n */\n async retrieve(): Promise<PayoutSettings> {\n return this.request('GET', '/payment/v1/payouts/settings');\n }\n\n /**\n * Update payout settings\n */\n async update(params: PayoutSettingsUpdateParams): Promise<PayoutSettings> {\n return this.request('PUT', '/payment/v1/payouts/settings', params);\n }\n}\n\nclass WebhooksAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Trigger a test webhook event (for testing)\n */\n async trigger(event: string, data: Record<string, unknown>): Promise<{ success: boolean }> {\n return this.request('POST', '/payment/v1/webhooks/test', { event, data });\n }\n}\n\n/**\n * Payment Intents API - for direct payments without full checkout flow\n * Similar to Stripe's Payment Intents API\n */\nclass PaymentIntentsAPI {\n private request: ReturnType<typeof createRequester>;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n }\n\n /**\n * Create a payment intent\n * Use this for simple payments without the full checkout session flow\n */\n async create(params: PaymentIntentCreateParams): Promise<PaymentIntent> {\n return this.request('POST', '/catalog/v1/payment_intents', params);\n }\n\n /**\n * Retrieve a payment intent\n */\n async retrieve(id: string): Promise<PaymentIntent> {\n return this.request('GET', `/catalog/v1/payment_intents/${id}`);\n }\n\n /**\n * Confirm a payment intent\n * This triggers the actual payment (and x402 flow if required)\n */\n async confirm(id: string): Promise<PaymentIntent> {\n return this.request('POST', `/catalog/v1/payment_intents/${id}/confirm`, {});\n }\n\n /**\n * Cancel a payment intent\n */\n async cancel(id: string): Promise<PaymentIntent> {\n return this.request('POST', `/catalog/v1/payment_intents/${id}/cancel`, {});\n }\n}\n\n/**\n * Payment API for checkout, links, customers, and payouts\n */\nexport class PaymentAPI {\n private request: ReturnType<typeof createRequester>;\n\n /** Checkout sessions API - for full e-commerce flows with line items */\n public readonly checkout: CheckoutAPI;\n\n /** Payment intents API - for simpler direct payments */\n public readonly intents: PaymentIntentsAPI;\n\n /** Payment links API */\n public readonly links: LinksAPI;\n\n /** Customers API */\n public readonly customers: CustomersAPI;\n\n /** Payouts API */\n public readonly payouts: PayoutsAPI;\n\n /** Webhooks API */\n public readonly webhooks: WebhooksAPI;\n\n constructor(config: MoneyMQConfig) {\n this.request = createRequester(config);\n this.checkout = new CheckoutAPI(config);\n this.intents = new PaymentIntentsAPI(config);\n this.links = new LinksAPI(config);\n this.customers = new CustomersAPI(config);\n this.payouts = new PayoutsAPI(config);\n this.webhooks = new WebhooksAPI(config);\n }\n\n /**\n * Simple one-liner payment - creates a checkout session with inline product data\n *\n * @example\n * ```ts\n * const result = await moneymq.payment.pay({\n * amount: 999,\n * currency: 'usd',\n * productName: 'Pro Plan',\n * productId: 'pro-plan',\n * customer: 'wallet_address',\n * });\n * ```\n */\n async pay(params: PayParams): Promise<PayResult> {\n // Create a checkout session with inline price_data\n const session = await this.request<{\n id: string;\n payment_intent: string;\n client_secret: string;\n amount_total: number;\n currency: string;\n status: string;\n }>('POST', '/catalog/v1/checkout/sessions', {\n line_items: [\n {\n price_data: {\n currency: params.currency,\n unit_amount: params.amount,\n product_data: {\n name: params.productName,\n description: params.description,\n metadata: {\n product_id: params.productId || params.productName.toLowerCase().replace(/\\s+/g, '-'),\n },\n },\n },\n quantity: 1,\n },\n ],\n customer: params.customer,\n metadata: params.metadata,\n mode: 'payment',\n });\n\n return {\n sessionId: session.id,\n paymentIntentId: session.payment_intent,\n clientSecret: session.client_secret,\n amount: session.amount_total,\n currency: session.currency,\n status: 'requires_confirmation',\n };\n }\n\n /**\n * Retrieve a payment by ID\n */\n async retrieve(id: string): Promise<Payment> {\n return this.request('GET', `/payment/v1/${id}`);\n }\n\n /**\n * List payments\n */\n async list(params?: PaymentListParams): Promise<{ data: Payment[]; hasMore: boolean }> {\n const query = new URLSearchParams();\n if (params?.customerId) query.set('customer', params.customerId);\n if (params?.status) query.set('status', params.status);\n if (params?.limit) query.set('limit', String(params.limit));\n if (params?.startingAfter) query.set('starting_after', params.startingAfter);\n\n const queryString = query.toString();\n return this.request('GET', `/payment/v1${queryString ? `?${queryString}` : ''}`);\n }\n}\n","/**\n * MoneyMQ server configuration returned from /config endpoint\n */\nexport interface ServerConfig {\n account: {\n name: string;\n description: string;\n };\n x402: {\n payoutAccount: {\n currency: string;\n decimals: number;\n address: string;\n tokenAddress: string;\n };\n facilitator: {\n operatorAccount: {\n out: string;\n in: {\n currency: string;\n decimals: number;\n address: string;\n tokenAddress: string;\n };\n };\n url: string;\n };\n validator: {\n network: string;\n rpcUrl: string;\n bindHost: string;\n rpcPort: number;\n wsPort: number;\n };\n };\n}\n\n/**\n * Fetch server configuration from MoneyMQ API\n *\n * @param apiUrl - The MoneyMQ API URL\n * @returns Server configuration including RPC URL\n *\n * @example\n * ```typescript\n * const config = await fetchConfig('http://localhost:8488');\n * console.log(config.x402.validator.rpcUrl);\n * ```\n */\nexport async function fetchConfig(apiUrl: string): Promise<ServerConfig> {\n const response = await fetch(`${apiUrl}/config`);\n if (!response.ok) {\n throw new Error(`Failed to fetch config: ${response.status}`);\n }\n return response.json() as Promise<ServerConfig>;\n}\n\n/**\n * Get the Solana RPC URL from server config\n *\n * @param apiUrl - The MoneyMQ API URL\n * @param fallback - Fallback RPC URL if fetch fails\n * @returns RPC URL string\n */\nexport async function getRpcUrl(\n apiUrl: string,\n fallback = 'https://api.devnet.solana.com'\n): Promise<string> {\n try {\n const config = await fetchConfig(apiUrl);\n return config.x402.validator.rpcUrl || fallback;\n } catch {\n return fallback;\n }\n}\n","import type { MoneyMQConfig } from './client';\nimport { fetchConfig, type ServerConfig } from './config';\nimport { createSigner, type Signer } from 'x402-fetch';\n\n/**\n * Parameters for getting a signer by tag\n */\nexport interface GetSignerParams {\n /**\n * Tag/label identifying the sandbox wallet account\n * @example 'alice', 'bob', 'agent-1'\n */\n tag: string;\n}\n\n/**\n * Re-export Signer type from x402-fetch\n */\nexport type { Signer } from 'x402-fetch';\n\n/**\n * X402 configuration compatible with x402-fetch wrapFetchWithPayment\n */\nexport interface X402ClientConfig {\n svmConfig?: {\n rpcUrl: string;\n };\n}\n\n/**\n * Response structure from /sandbox/accounts endpoint\n */\ninterface SandboxAccountsResponse {\n [network: string]: {\n network: string;\n payTo: string;\n userAccounts: Array<{\n address: string;\n secretKeyHex?: string;\n label?: string;\n stablecoins?: {\n usdc?: string;\n };\n }>;\n };\n}\n\n/**\n * X402 API for agentic payments\n *\n * @example\n * ```typescript\n * import { wrapFetchWithPayment } from 'x402-fetch';\n *\n * const moneymq = new MoneyMQ({\n * endpoint: 'http://localhost:8488',\n * });\n *\n * // Get signer for sandbox account by label\n * const payer = await moneymq.x402.getSigner({ tag: 'alice' });\n *\n * // Get x402 config for the fetch wrapper\n * const config = await moneymq.x402.getConfig();\n *\n * // Create the payment-enabled fetch\n * const fetchWithPayment = wrapFetchWithPayment(\n * fetch,\n * payer,\n * undefined,\n * undefined,\n * config,\n * );\n *\n * // Make requests that automatically handle 402 payments\n * const response = await fetchWithPayment(url, { method: 'GET' });\n * ```\n */\nexport class X402API {\n private serverConfig: ServerConfig | null = null;\n private sandboxAccounts: SandboxAccountsResponse | null = null;\n\n constructor(private config: MoneyMQConfig) {}\n\n /**\n * Fetch sandbox accounts from the server\n */\n private async fetchSandboxAccounts(): Promise<SandboxAccountsResponse> {\n if (this.sandboxAccounts) {\n return this.sandboxAccounts;\n }\n\n const response = await fetch(`${this.config.endpoint}/sandbox/accounts`);\n if (!response.ok) {\n throw new Error(`Failed to fetch sandbox accounts: ${response.status}`);\n }\n\n this.sandboxAccounts = await response.json() as SandboxAccountsResponse;\n return this.sandboxAccounts;\n }\n\n /**\n * Get a signer for a sandbox account by tag/label\n *\n * @param params - Parameters containing the wallet tag/label\n * @returns A Signer that can be used directly with wrapFetchWithPayment\n *\n * @example\n * ```typescript\n * const payer = await moneymq.x402.getSigner({ tag: 'alice' });\n * ```\n */\n async getSigner(params: GetSignerParams): Promise<Signer> {\n const accounts = await this.fetchSandboxAccounts();\n\n // Search through all networks for an account with matching label\n for (const networkData of Object.values(accounts)) {\n for (const account of networkData.userAccounts) {\n if (account.label === params.tag) {\n if (!account.secretKeyHex) {\n throw new Error(`Account '${params.tag}' does not have a secret key (not locally managed)`);\n }\n // Create and return the signer directly\n return createSigner('solana', account.secretKeyHex);\n }\n }\n }\n\n throw new Error(`No sandbox account found with label '${params.tag}'`);\n }\n\n /**\n * Get x402 configuration for use with wrapFetchWithPayment\n *\n * @returns Configuration object compatible with x402-fetch\n *\n * @example\n * ```typescript\n * const config = await moneymq.x402.getConfig();\n * const fetchWithPayment = wrapFetchWithPayment(fetch, payer, undefined, undefined, config);\n * ```\n */\n async getConfig(): Promise<X402ClientConfig> {\n // Cache the server config\n if (!this.serverConfig) {\n this.serverConfig = await fetchConfig(this.config.endpoint);\n }\n\n return {\n svmConfig: {\n rpcUrl: this.serverConfig.x402.validator.rpcUrl,\n },\n };\n }\n\n /**\n * Get the full server configuration\n *\n * @returns The complete server configuration including x402 settings\n */\n async getServerConfig(): Promise<ServerConfig> {\n if (!this.serverConfig) {\n this.serverConfig = await fetchConfig(this.config.endpoint);\n }\n return this.serverConfig;\n }\n}\n","import { CatalogAPI } from './catalog';\nimport { PaymentAPI } from './payment';\nimport { X402API } from './x402';\n\n/**\n * Configuration options for the MoneyMQ client\n *\n * @example\n * ```typescript\n * const config: MoneyMQConfig = {\n * endpoint: 'https://api.moneymq.com',\n * secret: 'your-api-secret', // Optional\n * timeout: 30000,\n * };\n * ```\n */\nexport interface MoneyMQConfig {\n /**\n * MoneyMQ API endpoint\n * @example 'http://localhost:8488' or 'https://api.moneymq.com'\n */\n endpoint: string;\n /**\n * Optional secret key for authenticated requests\n * Used for server-side operations that require authentication\n */\n secret?: string;\n /**\n * Request timeout in milliseconds\n * @default 30000\n */\n timeout?: number;\n}\n\n/**\n * MoneyMQ SDK client for accepting stablecoin payments\n *\n * @example\n * ```typescript\n * import { MoneyMQ } from '@moneymq/sdk';\n *\n * const moneymq = new MoneyMQ({\n * endpoint: process.env.MONEYMQ_ENDPOINT ?? 'http://localhost:8488',\n * });\n *\n * // Create a product\n * const product = await moneymq.catalog.products.create({\n * name: 'Pro Plan',\n * description: 'Full access to all features',\n * });\n *\n * // Create a checkout session\n * const session = await moneymq.payment.checkout.create({\n * lineItems: [{ price: 'price_xxx', quantity: 1 }],\n * successUrl: 'https://example.com/success',\n * cancelUrl: 'https://example.com/cancel',\n * });\n * ```\n */\nexport class MoneyMQ {\n public readonly config: MoneyMQConfig;\n\n /** Catalog API for products and prices */\n public readonly catalog: CatalogAPI;\n\n /** Payment API for checkout, links, customers, and payouts */\n public readonly payment: PaymentAPI;\n\n /** X402 API for agentic payments */\n public readonly x402: X402API;\n\n /** MoneyMQ API endpoint */\n get endpoint(): string {\n return this.config.endpoint;\n }\n\n constructor(config: MoneyMQConfig) {\n this.config = {\n timeout: 30000,\n ...config,\n };\n\n this.catalog = new CatalogAPI(this.config);\n this.payment = new PaymentAPI(this.config);\n this.x402 = new X402API(this.config);\n }\n\n /**\n * Make an authenticated request to the MoneyMQ API\n */\n async request<T>(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.config.endpoint}${path}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n\n if (this.config.secret) {\n headers['Authorization'] = `Bearer ${this.config.secret}`;\n }\n\n const response = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.config.timeout!),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { message?: string };\n throw new MoneyMQError(\n errorData.message || `Request failed with status ${response.status}`,\n response.status,\n errorData,\n );\n }\n\n return response.json() as Promise<T>;\n }\n}\n\n/**\n * MoneyMQ API error\n */\nexport class MoneyMQError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n public readonly raw?: unknown,\n ) {\n super(message);\n this.name = 'MoneyMQError';\n }\n}\n"],"mappings":";AAsBO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,YACE,SACgB,qBACA,KAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAuEA,IAAM,cAAN,MAAkB;AAAA,EAChB,YAAoB,QAAuB;AAAvB;AAAA,EAAwB;AAAA,EAE5C,MAAc,QAAW,QAAgB,MAAc,MAA4B;AACjF,UAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,GAAG,IAAI;AAC1C,UAAM,UAAkC,EAAE,gBAAgB,mBAAmB;AAC7E,QAAI,KAAK,OAAO,OAAQ,SAAQ,eAAe,IAAI,UAAU,KAAK,OAAO,MAAM;AAE/E,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC;AAAA,MACA;AAAA,MACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AAAA,IACtC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAa,MAAM,SAAS,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AACzD,YAAM,IAAI,MAAM,UAAU,WAAW,mBAAmB,SAAS,MAAM,EAAE;AAAA,IAC3E;AAEA,WAAO,SAAS,KAAK;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,QAA+C;AAC1D,WAAO,KAAK,QAAQ,QAAQ,wBAAwB,MAAM;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAS,IAA8B;AAC3C,WAAO,KAAK,QAAQ,OAAO,wBAAwB,EAAE,EAAE;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,QAA4E;AACrF,UAAM,QAAQ,IAAI,gBAAgB;AAClC,QAAI,QAAQ,WAAW,OAAW,OAAM,IAAI,U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OAAO,QAAQ,GAAG,IAAI;AAE1C,UAAM,UAAkC;AAAA,MACtC,gBAAgB;AAAA,IAClB;AAEA,QAAI,KAAK,OAAO,QAAQ;AACtB,cAAQ,eAAe,IAAI,UAAU,KAAK,OAAO,MAAM;AAAA,IACzD;AAEA,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC;AAAA,MACA;AAAA,MACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AAAA,MACpC,QAAQ,YAAY,QAAQ,KAAK,OAAO,OAAQ;AAAA,IAClD,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAa,MAAM,SAAS,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AACzD,YAAM,IAAI;AAAA,QACR,UAAU,WAAW,8BAA8B,SAAS,MAAM;AAAA,QAClE,SAAS;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAEA,WAAO,SAAS,KAAK;AAAA,EACvB;AACF;AAKO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YACE,SACgB,YACA,KAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneymq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "MoneyMQ SDK for accepting stablecoin payments",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -30,10 +30,19 @@
|
|
|
30
30
|
],
|
|
31
31
|
"author": "MoneyMQ",
|
|
32
32
|
"license": "MIT",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"x402-fetch": "^0.7.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"x402-fetch": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
33
41
|
"devDependencies": {
|
|
34
42
|
"@types/node": "^20",
|
|
35
43
|
"tsup": "^8.0.0",
|
|
36
|
-
"typescript": "^5"
|
|
44
|
+
"typescript": "^5",
|
|
45
|
+
"x402-fetch": "^0.7.0"
|
|
37
46
|
},
|
|
38
47
|
"scripts": {
|
|
39
48
|
"build": "tsup",
|