@cosmosapp/pay_sdk 1.0.1 → 1.1.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/CHANGELOG.md +4 -0
- package/README.md +244 -6
- package/dist/chunk-RCLT7E4Y.js +216 -0
- package/dist/chunk-RCLT7E4Y.js.map +1 -0
- package/dist/index.cjs +173 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -427
- package/dist/index.d.ts +8 -427
- package/dist/index.js +5 -67
- package/dist/index.js.map +1 -1
- package/dist/intent-input-Caauq1Vl.d.cts +626 -0
- package/dist/intent-input-Caauq1Vl.d.ts +626 -0
- package/dist/web/index.cjs +1260 -0
- package/dist/web/index.cjs.map +1 -0
- package/dist/web/index.d.cts +758 -0
- package/dist/web/index.d.ts +758 -0
- package/dist/web/index.js +1015 -0
- package/dist/web/index.js.map +1 -0
- package/package.json +32 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,386 +1,8 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { A as AnalyticsSummaryData, a as AnalyticsBalancesData, b as ApiLogsData, W as WebhookLogsData, C as CustomerData, U as UpdateCustomerOptions, c as CreateCustomerOptions, H as HealthCheckData, P as PaymentIntentData, d as PaymentIntentKind, e as PaymentIntentStatus, f as UpdatePaymentIntentOptions, D as DeletedData, V as ValidationOutcomeData, g as CreateTxPaymentIntentOptions, h as CreatePayPaymentIntentOptions, L as ListPaymentIntentsOptions, i as ValidatePaymentIntentOptions, j as ProductData, k as ProductKind, l as UpdateProductOptions, m as CreateProductOptions, n as WebhookDeliveryData, o as WebhookEventType, p as WebhookDeliveryStatus, q as WebhookEndpointData, r as WebhookEndpointWithSecretData, s as UpdateWebhookEndpointOptions, t as WebhookPingData, u as ListWebhookDeliveriesOptions, v as WebhookEvent, w as CreateWebhookEndpointOptions } from './intent-input-Caauq1Vl.cjs';
|
|
3
|
+
export { x as AddressBook, y as AddressRef, z as AnalyticsBalanceEntry, B as AnalyticsRecentRow, E as AnalyticsSeriesPoint, F as AnalyticsVolumeEntry, G as ApiLogRow, I as AssetDefinition, J as AssetRef, K as Assets, M as CosmosPayAPIError, N as CosmosPayRequestError, O as CustomerListData, Q as PaymentIntentListData, R as ResolvableIntentInput, S as ResolvedAsset, T as TestnetAssets, X as WalletId, Y as Wallets, Z as WebhookDeliveryListData, _ as WebhookLogRow, $ as addresses, a0 as assertAddress, a1 as defineAsset, a2 as isAddress, a3 as isContractAddress, a4 as isMuxedAddress, a5 as isNativeAsset, a6 as isStellarAddress, a7 as resolveAddress, a8 as resolveAsset, a9 as resolveIntentBody } from './intent-input-Caauq1Vl.cjs';
|
|
2
4
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
* Type definitions for the Cosmos Pay Payments API.
|
|
6
|
-
*
|
|
7
|
-
* These mirror the server's OpenAPI schema (Stellar SEP-7 payment intents,
|
|
8
|
-
* webhooks, products, customers and analytics). Every type is exported so
|
|
9
|
-
* TypeScript consumers get full intellisense; JavaScript consumers can ignore
|
|
10
|
-
* them entirely.
|
|
11
|
-
*/
|
|
12
|
-
/** Lifecycle state of a payment intent. */
|
|
13
|
-
declare const PaymentIntentStatus: {
|
|
14
|
-
readonly Pending: "PENDING";
|
|
15
|
-
readonly Submitted: "SUBMITTED";
|
|
16
|
-
readonly Succeeded: "SUCCEEDED";
|
|
17
|
-
readonly Failed: "FAILED";
|
|
18
|
-
readonly Cancelled: "CANCELLED";
|
|
19
|
-
readonly Expired: "EXPIRED";
|
|
20
|
-
};
|
|
21
|
-
type PaymentIntentStatus = (typeof PaymentIntentStatus)[keyof typeof PaymentIntentStatus];
|
|
22
|
-
/** SEP-7 operation a payment intent represents. */
|
|
23
|
-
declare const PaymentIntentKind: {
|
|
24
|
-
/** Source account is known → unsigned XDR + `web+stellar:tx` URI. */
|
|
25
|
-
readonly Tx: "TX";
|
|
26
|
-
/** No source → `web+stellar:pay` URI only (wallet picks the source). */
|
|
27
|
-
readonly Pay: "PAY";
|
|
28
|
-
};
|
|
29
|
-
type PaymentIntentKind = (typeof PaymentIntentKind)[keyof typeof PaymentIntentKind];
|
|
30
|
-
/** Domain events an integrator can subscribe a webhook to. */
|
|
31
|
-
declare const WebhookEventType: {
|
|
32
|
-
readonly PaymentIntentCreated: "PAYMENT_INTENT_CREATED";
|
|
33
|
-
readonly PaymentIntentUpdated: "PAYMENT_INTENT_UPDATED";
|
|
34
|
-
readonly PaymentIntentSucceeded: "PAYMENT_INTENT_SUCCEEDED";
|
|
35
|
-
readonly PaymentIntentFailed: "PAYMENT_INTENT_FAILED";
|
|
36
|
-
readonly PaymentIntentCancelled: "PAYMENT_INTENT_CANCELLED";
|
|
37
|
-
readonly PaymentIntentDeleted: "PAYMENT_INTENT_DELETED";
|
|
38
|
-
};
|
|
39
|
-
type WebhookEventType = (typeof WebhookEventType)[keyof typeof WebhookEventType];
|
|
40
|
-
/** Delivery state of a single webhook attempt. */
|
|
41
|
-
declare const WebhookDeliveryStatus: {
|
|
42
|
-
readonly Pending: "PENDING";
|
|
43
|
-
readonly Succeeded: "SUCCEEDED";
|
|
44
|
-
readonly Failed: "FAILED";
|
|
45
|
-
};
|
|
46
|
-
type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus];
|
|
47
|
-
/** Product billing kind. */
|
|
48
|
-
declare const ProductKind: {
|
|
49
|
-
readonly Recurring: "recurring";
|
|
50
|
-
readonly OneTime: "one_time";
|
|
51
|
-
readonly Link: "link";
|
|
52
|
-
};
|
|
53
|
-
type ProductKind = (typeof ProductKind)[keyof typeof ProductKind];
|
|
54
|
-
/** Body for `POST /v1/payment-intents/tx`. */
|
|
55
|
-
interface CreateTxPaymentIntentOptions {
|
|
56
|
-
/** Payer's Stellar account — the transaction source. */
|
|
57
|
-
source: string;
|
|
58
|
-
/** Payee's Stellar account. */
|
|
59
|
-
destination: string;
|
|
60
|
-
/** Amount as a decimal string (max 7 decimals). */
|
|
61
|
-
amount: string;
|
|
62
|
-
/** Asset code. Omit (or `XLM`/`native`) for native lumens. */
|
|
63
|
-
assetCode?: string;
|
|
64
|
-
/** Issuer account for a non-native asset. */
|
|
65
|
-
assetIssuer?: string;
|
|
66
|
-
/** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
|
|
67
|
-
memo?: string;
|
|
68
|
-
/** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
|
|
69
|
-
msg?: string;
|
|
70
|
-
/** SEP-7 `callback` where the wallet POSTs the signed XDR, e.g. `url:https://...`. */
|
|
71
|
-
callback?: string;
|
|
72
|
-
}
|
|
73
|
-
/** Body for `POST /v1/payment-intents/pay`. */
|
|
74
|
-
interface CreatePayPaymentIntentOptions {
|
|
75
|
-
/** Payee's Stellar account. */
|
|
76
|
-
destination: string;
|
|
77
|
-
/** Amount the destination should receive. Omit to let the user enter it (e.g. donations). */
|
|
78
|
-
amount?: string;
|
|
79
|
-
/** Asset code the destination receives. Omit for native lumens (XLM). */
|
|
80
|
-
assetCode?: string;
|
|
81
|
-
/** Issuer account for a non-native asset. */
|
|
82
|
-
assetIssuer?: string;
|
|
83
|
-
/** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
|
|
84
|
-
memo?: string;
|
|
85
|
-
/** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
|
|
86
|
-
msg?: string;
|
|
87
|
-
/** SEP-7 `callback`, e.g. `url:https://...`. */
|
|
88
|
-
callback?: string;
|
|
89
|
-
}
|
|
90
|
-
/** Body for `PATCH /v1/payment-intents/:id`. */
|
|
91
|
-
interface UpdatePaymentIntentOptions {
|
|
92
|
-
status?: PaymentIntentStatus;
|
|
93
|
-
/** Stellar transaction hash once the signed tx is submitted. */
|
|
94
|
-
txHash?: string;
|
|
95
|
-
/** Merchant reference. */
|
|
96
|
-
reference?: string;
|
|
97
|
-
}
|
|
98
|
-
/** Query for `GET /v1/payment-intents`. */
|
|
99
|
-
interface ListPaymentIntentsOptions {
|
|
100
|
-
status?: PaymentIntentStatus;
|
|
101
|
-
/** Page size (max 100, default 20). */
|
|
102
|
-
take?: number;
|
|
103
|
-
/** Offset (default 0). */
|
|
104
|
-
skip?: number;
|
|
105
|
-
}
|
|
106
|
-
/** Raw payment intent payload returned by the API. */
|
|
107
|
-
interface PaymentIntentData {
|
|
108
|
-
id: string;
|
|
109
|
-
kind: PaymentIntentKind;
|
|
110
|
-
status: PaymentIntentStatus;
|
|
111
|
-
network: string;
|
|
112
|
-
source: string | null;
|
|
113
|
-
destination: string;
|
|
114
|
-
amount: string | null;
|
|
115
|
-
asset: string;
|
|
116
|
-
assetIssuer: string | null;
|
|
117
|
-
memo: string;
|
|
118
|
-
msg: string | null;
|
|
119
|
-
callback: string | null;
|
|
120
|
-
xdr: string | null;
|
|
121
|
-
uri: string;
|
|
122
|
-
qr: string;
|
|
123
|
-
txHash: string | null;
|
|
124
|
-
reference: string | null;
|
|
125
|
-
createdAt: string;
|
|
126
|
-
updatedAt: string;
|
|
127
|
-
}
|
|
128
|
-
/** Raw paginated list of payment intents. */
|
|
129
|
-
interface PaymentIntentListData {
|
|
130
|
-
data: PaymentIntentData[];
|
|
131
|
-
total: number;
|
|
132
|
-
take: number;
|
|
133
|
-
skip: number;
|
|
134
|
-
}
|
|
135
|
-
/** Body for `POST /v1/payment-intents/:id/validate`. */
|
|
136
|
-
interface ValidatePaymentIntentOptions {
|
|
137
|
-
/** Hash of the submitted Stellar transaction to validate against this intent. */
|
|
138
|
-
txHash: string;
|
|
139
|
-
}
|
|
140
|
-
/** Raw outcome of a validation attempt. */
|
|
141
|
-
interface ValidationOutcomeData {
|
|
142
|
-
valid: boolean;
|
|
143
|
-
status: PaymentIntentStatus;
|
|
144
|
-
reason?: string | null;
|
|
145
|
-
paymentIntent?: PaymentIntentData;
|
|
146
|
-
}
|
|
147
|
-
/** Raw `{ id, deleted }` response. */
|
|
148
|
-
interface DeletedData {
|
|
149
|
-
id: string;
|
|
150
|
-
deleted: boolean;
|
|
151
|
-
}
|
|
152
|
-
/** Body for `POST /v1/webhooks`. */
|
|
153
|
-
interface CreateWebhookEndpointOptions {
|
|
154
|
-
/** HTTPS URL that will receive POSTed event notifications. */
|
|
155
|
-
url: string;
|
|
156
|
-
description?: string;
|
|
157
|
-
/** Event types to subscribe to. Omit/empty to receive all events. */
|
|
158
|
-
eventTypes?: WebhookEventType[];
|
|
159
|
-
}
|
|
160
|
-
/** Body for `PATCH /v1/webhooks/:id`. */
|
|
161
|
-
interface UpdateWebhookEndpointOptions {
|
|
162
|
-
url?: string;
|
|
163
|
-
description?: string;
|
|
164
|
-
/** Pause/resume deliveries to this endpoint. */
|
|
165
|
-
enabled?: boolean;
|
|
166
|
-
eventTypes?: WebhookEventType[];
|
|
167
|
-
}
|
|
168
|
-
/** Raw webhook endpoint payload. */
|
|
169
|
-
interface WebhookEndpointData {
|
|
170
|
-
id: string;
|
|
171
|
-
url: string;
|
|
172
|
-
description: string | null;
|
|
173
|
-
enabled: boolean;
|
|
174
|
-
eventTypes: WebhookEventType[];
|
|
175
|
-
createdAt: string;
|
|
176
|
-
updatedAt: string;
|
|
177
|
-
}
|
|
178
|
-
/** Raw webhook endpoint payload including the one-time signing secret. */
|
|
179
|
-
interface WebhookEndpointWithSecretData extends WebhookEndpointData {
|
|
180
|
-
/** HMAC signing secret — shown once. Store it securely. */
|
|
181
|
-
secret: string;
|
|
182
|
-
}
|
|
183
|
-
/** Raw result of a webhook ping. */
|
|
184
|
-
interface WebhookPingData {
|
|
185
|
-
ok: boolean;
|
|
186
|
-
responseStatus: number | null;
|
|
187
|
-
error: string | null;
|
|
188
|
-
}
|
|
189
|
-
/** Raw webhook delivery (audit) record. */
|
|
190
|
-
interface WebhookDeliveryData {
|
|
191
|
-
id: string;
|
|
192
|
-
endpointId: string;
|
|
193
|
-
eventType: WebhookEventType;
|
|
194
|
-
eventId: string;
|
|
195
|
-
payload: Record<string, unknown>;
|
|
196
|
-
status: WebhookDeliveryStatus;
|
|
197
|
-
attempts: number;
|
|
198
|
-
responseStatus: number | null;
|
|
199
|
-
error: string | null;
|
|
200
|
-
lastAttemptAt: string | null;
|
|
201
|
-
createdAt: string;
|
|
202
|
-
updatedAt: string;
|
|
203
|
-
}
|
|
204
|
-
/** Raw paginated list of webhook deliveries. */
|
|
205
|
-
interface WebhookDeliveryListData {
|
|
206
|
-
data: WebhookDeliveryData[];
|
|
207
|
-
total: number;
|
|
208
|
-
take: number;
|
|
209
|
-
skip: number;
|
|
210
|
-
}
|
|
211
|
-
/** Query for `GET /v1/webhooks/:id/deliveries`. */
|
|
212
|
-
interface ListWebhookDeliveriesOptions {
|
|
213
|
-
status?: WebhookDeliveryStatus;
|
|
214
|
-
take?: number;
|
|
215
|
-
skip?: number;
|
|
216
|
-
}
|
|
217
|
-
/** Shape of the JSON body POSTed to an integrator's webhook URL. */
|
|
218
|
-
interface WebhookEvent<T = PaymentIntentData> {
|
|
219
|
-
/** Stable event id (use for idempotency). */
|
|
220
|
-
id: string;
|
|
221
|
-
type: WebhookEventType;
|
|
222
|
-
createdAt: string;
|
|
223
|
-
data: T;
|
|
224
|
-
}
|
|
225
|
-
/** Body for `POST /v1/products`. */
|
|
226
|
-
interface CreateProductOptions {
|
|
227
|
-
name: string;
|
|
228
|
-
description?: string;
|
|
229
|
-
/** Decimal price (≤ 7 decimals). Omit for a customer-set amount. */
|
|
230
|
-
amount?: string;
|
|
231
|
-
/** Asset code the price is in. Omit for native lumens (XLM). */
|
|
232
|
-
assetCode?: string;
|
|
233
|
-
kind?: ProductKind;
|
|
234
|
-
active?: boolean;
|
|
235
|
-
reference?: string;
|
|
236
|
-
}
|
|
237
|
-
/** Body for `PATCH /v1/products/:id`. */
|
|
238
|
-
type UpdateProductOptions = Partial<CreateProductOptions>;
|
|
239
|
-
/** Raw product payload. */
|
|
240
|
-
interface ProductData {
|
|
241
|
-
id: string;
|
|
242
|
-
name: string;
|
|
243
|
-
description: string | null;
|
|
244
|
-
amount: string | null;
|
|
245
|
-
asset: string;
|
|
246
|
-
kind: ProductKind;
|
|
247
|
-
active: boolean;
|
|
248
|
-
reference: string | null;
|
|
249
|
-
createdAt: string;
|
|
250
|
-
updatedAt: string;
|
|
251
|
-
}
|
|
252
|
-
/** Body for `POST /v1/customers`. */
|
|
253
|
-
interface CreateCustomerOptions {
|
|
254
|
-
name: string;
|
|
255
|
-
alias?: string;
|
|
256
|
-
note?: string;
|
|
257
|
-
email?: string;
|
|
258
|
-
/** Optional Stellar account to associate the customer with. */
|
|
259
|
-
account?: string;
|
|
260
|
-
reference?: string;
|
|
261
|
-
}
|
|
262
|
-
/** Body for `PATCH /v1/customers/:id`. */
|
|
263
|
-
type UpdateCustomerOptions = Partial<CreateCustomerOptions>;
|
|
264
|
-
/** Raw customer payload. */
|
|
265
|
-
interface CustomerData {
|
|
266
|
-
id: string;
|
|
267
|
-
consumerId: string;
|
|
268
|
-
name: string;
|
|
269
|
-
alias: string | null;
|
|
270
|
-
note: string | null;
|
|
271
|
-
email: string | null;
|
|
272
|
-
account: string | null;
|
|
273
|
-
reference: string | null;
|
|
274
|
-
createdAt: string;
|
|
275
|
-
updatedAt: string;
|
|
276
|
-
/** Derived on-chain stats (present in list responses). */
|
|
277
|
-
payments?: number;
|
|
278
|
-
succeeded?: number;
|
|
279
|
-
total?: string;
|
|
280
|
-
}
|
|
281
|
-
/** Raw `{ data, total }` list of customers. */
|
|
282
|
-
interface CustomerListData {
|
|
283
|
-
data: CustomerData[];
|
|
284
|
-
total: number;
|
|
285
|
-
}
|
|
286
|
-
interface AnalyticsVolumeEntry {
|
|
287
|
-
asset: string;
|
|
288
|
-
amount: string;
|
|
289
|
-
count: number;
|
|
290
|
-
}
|
|
291
|
-
interface AnalyticsSeriesPoint {
|
|
292
|
-
date: string;
|
|
293
|
-
count: number;
|
|
294
|
-
volume: string;
|
|
295
|
-
}
|
|
296
|
-
interface AnalyticsRecentRow {
|
|
297
|
-
id: string;
|
|
298
|
-
kind: string;
|
|
299
|
-
status: PaymentIntentStatus;
|
|
300
|
-
amount: string | null;
|
|
301
|
-
asset: string;
|
|
302
|
-
destination: string;
|
|
303
|
-
createdAt: string;
|
|
304
|
-
}
|
|
305
|
-
/** Raw overview metrics returned by `GET /v1/summary`. */
|
|
306
|
-
interface AnalyticsSummaryData {
|
|
307
|
-
totals: {
|
|
308
|
-
all: number;
|
|
309
|
-
succeeded: number;
|
|
310
|
-
pending: number;
|
|
311
|
-
submitted: number;
|
|
312
|
-
failed: number;
|
|
313
|
-
cancelled: number;
|
|
314
|
-
expired: number;
|
|
315
|
-
successRate: number;
|
|
316
|
-
};
|
|
317
|
-
volume: AnalyticsVolumeEntry[];
|
|
318
|
-
webhooks: {
|
|
319
|
-
endpoints: number;
|
|
320
|
-
deliveries: number;
|
|
321
|
-
failedDeliveries: number;
|
|
322
|
-
};
|
|
323
|
-
customers: number;
|
|
324
|
-
series: AnalyticsSeriesPoint[];
|
|
325
|
-
recent: AnalyticsRecentRow[];
|
|
326
|
-
}
|
|
327
|
-
interface AnalyticsBalanceEntry {
|
|
328
|
-
asset: string;
|
|
329
|
-
amount: string;
|
|
330
|
-
pending: string;
|
|
331
|
-
count: number;
|
|
332
|
-
}
|
|
333
|
-
/** Raw balances returned by `GET /v1/balances`. */
|
|
334
|
-
interface AnalyticsBalancesData {
|
|
335
|
-
data: AnalyticsBalanceEntry[];
|
|
336
|
-
total: number;
|
|
337
|
-
}
|
|
338
|
-
interface ApiLogRow {
|
|
339
|
-
id: string;
|
|
340
|
-
method: string;
|
|
341
|
-
path: string;
|
|
342
|
-
statusCode: number;
|
|
343
|
-
durationMs: number;
|
|
344
|
-
ip: string | null;
|
|
345
|
-
userAgent: string | null;
|
|
346
|
-
status: 'ok' | 'pending' | 'fail';
|
|
347
|
-
at: string;
|
|
348
|
-
}
|
|
349
|
-
/** Raw API request log returned by `GET /v1/logs`. */
|
|
350
|
-
interface ApiLogsData {
|
|
351
|
-
data: ApiLogRow[];
|
|
352
|
-
total: number;
|
|
353
|
-
}
|
|
354
|
-
interface WebhookLogRow {
|
|
355
|
-
id: string;
|
|
356
|
-
endpointId: string;
|
|
357
|
-
url: string | null;
|
|
358
|
-
eventType: WebhookEventType;
|
|
359
|
-
eventId: string;
|
|
360
|
-
attempts: number;
|
|
361
|
-
responseStatus: number | null;
|
|
362
|
-
error: string | null;
|
|
363
|
-
status: 'ok' | 'pending' | 'fail';
|
|
364
|
-
at: string;
|
|
365
|
-
}
|
|
366
|
-
/** Raw webhook delivery log returned by `GET /v1/logs/webhooks`. */
|
|
367
|
-
interface WebhookLogsData {
|
|
368
|
-
data: WebhookLogRow[];
|
|
369
|
-
total: number;
|
|
370
|
-
}
|
|
371
|
-
interface HealthCheckData {
|
|
372
|
-
status: string;
|
|
373
|
-
info?: Record<string, {
|
|
374
|
-
status: string;
|
|
375
|
-
} & Record<string, unknown>> | null;
|
|
376
|
-
error?: Record<string, {
|
|
377
|
-
status: string;
|
|
378
|
-
} & Record<string, unknown>> | null;
|
|
379
|
-
details?: Record<string, {
|
|
380
|
-
status: string;
|
|
381
|
-
} & Record<string, unknown>>;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
6
|
/**
|
|
385
7
|
* Read-only analytics derived from the consumer's intents and deliveries —
|
|
386
8
|
* `client.analytics`. Powers dashboard-style Overview / Balances / Logs views.
|
|
@@ -537,7 +159,7 @@ declare class REST extends EventEmitter {
|
|
|
537
159
|
/**
|
|
538
160
|
* Base class for all resource managers. Each manager owns a slice of the API
|
|
539
161
|
* (payment intents, webhooks, ...) and a lightweight in-memory cache of the
|
|
540
|
-
* structures it has materialized —
|
|
162
|
+
* structures it has materialized — an atomic, per-resource manager pattern.
|
|
541
163
|
*
|
|
542
164
|
* Extends EventEmitter so managers that surface real-time events (e.g. the
|
|
543
165
|
* webhook listener) can `emit`/`on` without extra plumbing.
|
|
@@ -1072,7 +694,7 @@ interface Client {
|
|
|
1072
694
|
}
|
|
1073
695
|
/**
|
|
1074
696
|
* The main entry point of the SDK — a single, atomic client that exposes every
|
|
1075
|
-
* resource through its own manager
|
|
697
|
+
* resource through its own manager — an atomic, single-client design.
|
|
1076
698
|
*
|
|
1077
699
|
* @example
|
|
1078
700
|
* import { Client } from '@cosmosapp/pay_sdk';
|
|
@@ -1085,7 +707,7 @@ interface Client {
|
|
|
1085
707
|
*/
|
|
1086
708
|
declare class Client extends EventEmitter {
|
|
1087
709
|
/** Library version. */
|
|
1088
|
-
static readonly version = "1.
|
|
710
|
+
static readonly version = "1.1.0";
|
|
1089
711
|
/**
|
|
1090
712
|
* Process-wide shared defaults maintained by Cosmos Pay (gateway URL, version,
|
|
1091
713
|
* internal secrets). Mutate once at startup to change them for every client
|
|
@@ -1119,47 +741,6 @@ declare class Client extends EventEmitter {
|
|
|
1119
741
|
setGatewayCredentials(secret: string, consumerUsername: string): this;
|
|
1120
742
|
}
|
|
1121
743
|
|
|
1122
|
-
/**
|
|
1123
|
-
* Error thrown when the Cosmos Pay API responds with a non-2xx status.
|
|
1124
|
-
*
|
|
1125
|
-
* Carries the HTTP status, the parsed response body and the request context so
|
|
1126
|
-
* callers can branch on `error.status` (e.g. 404 → not found, 403 → gateway).
|
|
1127
|
-
*/
|
|
1128
|
-
declare class CosmosPayAPIError extends Error {
|
|
1129
|
-
/** HTTP status code returned by the API. */
|
|
1130
|
-
readonly status: number;
|
|
1131
|
-
/** HTTP method of the failed request. */
|
|
1132
|
-
readonly method: string;
|
|
1133
|
-
/** Absolute URL of the failed request. */
|
|
1134
|
-
readonly url: string;
|
|
1135
|
-
/** Parsed response body (object when JSON, string otherwise, or null). */
|
|
1136
|
-
readonly body: unknown;
|
|
1137
|
-
/** Machine-readable error code extracted from the body when present. */
|
|
1138
|
-
readonly code: string | undefined;
|
|
1139
|
-
constructor(options: {
|
|
1140
|
-
status: number;
|
|
1141
|
-
method: string;
|
|
1142
|
-
url: string;
|
|
1143
|
-
body: unknown;
|
|
1144
|
-
});
|
|
1145
|
-
private static resolveMessage;
|
|
1146
|
-
private static resolveCode;
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Error thrown when a request never reaches the API: network failure, abort or
|
|
1150
|
-
* timeout. Distinct from {@link CosmosPayAPIError}, which always has a status.
|
|
1151
|
-
*/
|
|
1152
|
-
declare class CosmosPayRequestError extends Error {
|
|
1153
|
-
readonly method: string;
|
|
1154
|
-
readonly url: string;
|
|
1155
|
-
readonly cause: unknown;
|
|
1156
|
-
constructor(options: {
|
|
1157
|
-
method: string;
|
|
1158
|
-
url: string;
|
|
1159
|
-
cause: unknown;
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
744
|
/** Options for {@link Webhooks.verify} / {@link Webhooks.constructEvent}. */
|
|
1164
745
|
interface VerifyWebhookOptions {
|
|
1165
746
|
/**
|
|
@@ -1215,7 +796,7 @@ declare const Webhooks: {
|
|
|
1215
796
|
};
|
|
1216
797
|
|
|
1217
798
|
/** Library version, kept in sync with package.json. */
|
|
1218
|
-
declare const version = "1.
|
|
799
|
+
declare const version = "1.1.0";
|
|
1219
800
|
/**
|
|
1220
801
|
* Default base URL of the Cosmos Pay gateway. Maintained by Cosmos Pay — users
|
|
1221
802
|
* never need to set this; it's part of the {@link shared} configuration. Override
|
|
@@ -1237,7 +818,7 @@ declare const DEFAULT_RETRIES = 2;
|
|
|
1237
818
|
declare const SIGNATURE_HEADER = "x-cosmos-signature";
|
|
1238
819
|
/**
|
|
1239
820
|
* Client debug/telemetry events. The {@link Client} extends EventEmitter and
|
|
1240
|
-
* emits these for observability
|
|
821
|
+
* emits these for observability (`debug`/`rateLimit`-style events).
|
|
1241
822
|
*/
|
|
1242
823
|
declare const Events: {
|
|
1243
824
|
readonly Debug: "debug";
|
|
@@ -1247,4 +828,4 @@ declare const Events: {
|
|
|
1247
828
|
};
|
|
1248
829
|
type ClientEvent = (typeof Events)[keyof typeof Events];
|
|
1249
830
|
|
|
1250
|
-
export {
|
|
831
|
+
export { AnalyticsBalancesData, AnalyticsManager, AnalyticsSummaryData, ApiLogsData, Base, BaseManager, Client, type ClientEvent, type ClientEvents, type ClientOptions, CreateCustomerOptions, CreatePayPaymentIntentOptions, CreateProductOptions, CreateTxPaymentIntentOptions, CreateWebhookEndpointOptions, Customer, CustomerData, CustomerManager, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, DeletedData, Events, type FetchLike, HealthCheckData, HealthManager, ListPaymentIntentsOptions, ListWebhookDeliveriesOptions, PaymentIntent, PaymentIntentData, PaymentIntentKind, PaymentIntentManager, type PaymentIntentPage, PaymentIntentStatus, Product, ProductData, ProductKind, ProductManager, REST, type RESTOptions, type RequestOptions, SIGNATURE_HEADER, type SharedConfig, UpdateCustomerOptions, UpdatePaymentIntentOptions, UpdateProductOptions, UpdateWebhookEndpointOptions, ValidatePaymentIntentOptions, type ValidationOutcome, ValidationOutcomeData, type VerifyWebhookOptions, WebhookDelivery, WebhookDeliveryData, type WebhookDeliveryPage, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointData, WebhookEndpointWithSecretData, WebhookEvent, WebhookEventType, type WebhookHandlerOptions, type WebhookListenerEvents, WebhookLogsData, WebhookManager, WebhookPingData, type WebhookProcessOptions, WebhookSignatureError, Webhooks, resolveShared, shared, version };
|