@txnod/sdk 1.0.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.
Files changed (121) hide show
  1. package/AGENTS.md +29 -0
  2. package/CHANGELOG.md +22 -0
  3. package/LICENSE +21 -0
  4. package/README.md +434 -0
  5. package/dist/_shared/index.d.ts +68 -0
  6. package/dist/client-sandbox.d.ts +396 -0
  7. package/dist/client-sandbox.d.ts.map +1 -0
  8. package/dist/client-sandbox.js +448 -0
  9. package/dist/client-sandbox.js.map +1 -0
  10. package/dist/client.d.ts +429 -0
  11. package/dist/client.d.ts.map +1 -0
  12. package/dist/client.js +588 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/env.d.ts +29 -0
  15. package/dist/env.d.ts.map +1 -0
  16. package/dist/env.js +44 -0
  17. package/dist/env.js.map +1 -0
  18. package/dist/errors.d.ts +1887 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +2107 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/index.d.ts +35 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +32 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/internals/error-ctor-map.d.ts +11 -0
  27. package/dist/internals/error-ctor-map.d.ts.map +1 -0
  28. package/dist/internals/error-ctor-map.js +75 -0
  29. package/dist/internals/error-ctor-map.js.map +1 -0
  30. package/dist/internals/fetch-with-retry.d.ts +34 -0
  31. package/dist/internals/fetch-with-retry.d.ts.map +1 -0
  32. package/dist/internals/fetch-with-retry.js +233 -0
  33. package/dist/internals/fetch-with-retry.js.map +1 -0
  34. package/dist/internals/hmac.d.ts +2 -0
  35. package/dist/internals/hmac.d.ts.map +1 -0
  36. package/dist/internals/hmac.js +10 -0
  37. package/dist/internals/hmac.js.map +1 -0
  38. package/dist/internals/logger.d.ts +9 -0
  39. package/dist/internals/logger.d.ts.map +1 -0
  40. package/dist/internals/logger.js +16 -0
  41. package/dist/internals/logger.js.map +1 -0
  42. package/dist/internals/parse-problem-details.d.ts +3 -0
  43. package/dist/internals/parse-problem-details.d.ts.map +1 -0
  44. package/dist/internals/parse-problem-details.js +76 -0
  45. package/dist/internals/parse-problem-details.js.map +1 -0
  46. package/dist/internals/synthetic-details.d.ts +12 -0
  47. package/dist/internals/synthetic-details.d.ts.map +1 -0
  48. package/dist/internals/synthetic-details.js +19 -0
  49. package/dist/internals/synthetic-details.js.map +1 -0
  50. package/dist/verify/chains/bsc.d.ts +17 -0
  51. package/dist/verify/chains/bsc.d.ts.map +1 -0
  52. package/dist/verify/chains/bsc.js +15 -0
  53. package/dist/verify/chains/bsc.js.map +1 -0
  54. package/dist/verify/chains/btc.d.ts +22 -0
  55. package/dist/verify/chains/btc.d.ts.map +1 -0
  56. package/dist/verify/chains/btc.js +55 -0
  57. package/dist/verify/chains/btc.js.map +1 -0
  58. package/dist/verify/chains/cardano.d.ts +73 -0
  59. package/dist/verify/chains/cardano.d.ts.map +1 -0
  60. package/dist/verify/chains/cardano.js +175 -0
  61. package/dist/verify/chains/cardano.js.map +1 -0
  62. package/dist/verify/chains/evm.d.ts +21 -0
  63. package/dist/verify/chains/evm.d.ts.map +1 -0
  64. package/dist/verify/chains/evm.js +46 -0
  65. package/dist/verify/chains/evm.js.map +1 -0
  66. package/dist/verify/chains/polygon.d.ts +17 -0
  67. package/dist/verify/chains/polygon.d.ts.map +1 -0
  68. package/dist/verify/chains/polygon.js +15 -0
  69. package/dist/verify/chains/polygon.js.map +1 -0
  70. package/dist/verify/chains/secp256k1-bip32.d.ts +20 -0
  71. package/dist/verify/chains/secp256k1-bip32.d.ts.map +1 -0
  72. package/dist/verify/chains/secp256k1-bip32.js +88 -0
  73. package/dist/verify/chains/secp256k1-bip32.js.map +1 -0
  74. package/dist/verify/chains/ton-cell.d.ts +179 -0
  75. package/dist/verify/chains/ton-cell.d.ts.map +1 -0
  76. package/dist/verify/chains/ton-cell.js +614 -0
  77. package/dist/verify/chains/ton-cell.js.map +1 -0
  78. package/dist/verify/chains/ton.d.ts +84 -0
  79. package/dist/verify/chains/ton.d.ts.map +1 -0
  80. package/dist/verify/chains/ton.js +131 -0
  81. package/dist/verify/chains/ton.js.map +1 -0
  82. package/dist/verify/chains/tron.d.ts +21 -0
  83. package/dist/verify/chains/tron.d.ts.map +1 -0
  84. package/dist/verify/chains/tron.js +42 -0
  85. package/dist/verify/chains/tron.js.map +1 -0
  86. package/dist/verify/config.d.ts +41 -0
  87. package/dist/verify/config.d.ts.map +1 -0
  88. package/dist/verify/config.js +120 -0
  89. package/dist/verify/config.js.map +1 -0
  90. package/dist/verify/errors.d.ts +56 -0
  91. package/dist/verify/errors.d.ts.map +1 -0
  92. package/dist/verify/errors.js +58 -0
  93. package/dist/verify/errors.js.map +1 -0
  94. package/dist/verify/index.d.ts +119 -0
  95. package/dist/verify/index.d.ts.map +1 -0
  96. package/dist/verify/index.js +166 -0
  97. package/dist/verify/index.js.map +1 -0
  98. package/dist/verify/xpub-safety.d.ts +33 -0
  99. package/dist/verify/xpub-safety.d.ts.map +1 -0
  100. package/dist/verify/xpub-safety.js +54 -0
  101. package/dist/verify/xpub-safety.js.map +1 -0
  102. package/dist/verify-webhook-signature.d.ts +30 -0
  103. package/dist/verify-webhook-signature.d.ts.map +1 -0
  104. package/dist/verify-webhook-signature.js +84 -0
  105. package/dist/verify-webhook-signature.js.map +1 -0
  106. package/docs/00-getting-started.md +135 -0
  107. package/docs/01-authentication.md +114 -0
  108. package/docs/02-invoices.md +216 -0
  109. package/docs/03-rates-and-quotes.md +82 -0
  110. package/docs/04-webhooks.md +126 -0
  111. package/docs/05-errors.md +199 -0
  112. package/docs/05-sandbox.md +159 -0
  113. package/docs/06-idempotency.md +132 -0
  114. package/docs/examples/express-webhook-receiver.md +97 -0
  115. package/docs/examples/nextjs-route-handler.md +206 -0
  116. package/docs/examples/sandbox-vitest-suite.md +263 -0
  117. package/docs/index.md +66 -0
  118. package/docs/reference/client.md +392 -0
  119. package/docs/reference/errors.md +161 -0
  120. package/docs/reference/types.md +400 -0
  121. package/package.json +53 -0
@@ -0,0 +1,429 @@
1
+ import type { InvoiceCreateRequest, InvoiceResponse, InvoiceSearchQuery, CursorPaginatedInvoiceResponse, OrphanPaymentListQuery, CursorPaginatedOrphanPaymentResponse, OrphanAttributeRequest, WebhookEventListApiQuery, WebhookEventListResponse, WebhookEventResendResponse, RatesQuery, RatesResponse, QuoteQuery, QuoteResponse } from './_shared/index.js';
2
+ import { type SignedFetchRequestLogEntry, type SignedFetchRequestLogger } from './internals/fetch-with-retry.js';
3
+ import { TxnodClientSandbox } from './client-sandbox.js';
4
+ /**
5
+ * One log line per HTTP attempt — emitted to {@link TxnodClientOptions.requestLogger}
6
+ * if provided. Useful for correlating timeouts, 429 / 5xx retries, and slow
7
+ * downstream calls with `request_id` server-side.
8
+ */
9
+ export type TxnodRequestLogEntry = SignedFetchRequestLogEntry;
10
+ /**
11
+ * Per-attempt observer signature. Errors thrown from the logger are swallowed
12
+ * by the SDK so a buggy logger never fails a request.
13
+ */
14
+ export type TxnodRequestLogger = SignedFetchRequestLogger;
15
+ export interface TxnodClientOptions {
16
+ projectId: string;
17
+ apiSecret: string;
18
+ baseUrl?: string;
19
+ /**
20
+ * Per-attempt HTTP timeout in ms, applied to every retry separately.
21
+ * Defaults to 30,000 ms. Set to a higher value for slow chains or to a
22
+ * lower value for fast-fail user-facing flows.
23
+ */
24
+ requestTimeoutMs?: number;
25
+ /**
26
+ * Maximum acceptable response body size in bytes. Responses exceeding this
27
+ * are surfaced to the caller as `502 internal_error` so the SDK never
28
+ * buffers an unbounded payload from a hostile or misbehaving upstream.
29
+ * Defaults to 1 MiB — well above any legitimate TxNod response.
30
+ */
31
+ maxResponseBytes?: number;
32
+ /**
33
+ * Optional per-attempt logger. Receives one entry per HTTP call (success or
34
+ * failure, including each retry). Use it to correlate latency and
35
+ * `request_id` with your application logs.
36
+ */
37
+ requestLogger?: TxnodRequestLogger;
38
+ /**
39
+ * Explicit environment override. When set, takes precedence over
40
+ * TXNOD_ENVIRONMENT and NODE_ENV. Use this for staging replicas where
41
+ * NODE_ENV is conventionally 'production' but the secret is sandbox.
42
+ */
43
+ environment?: 'production' | 'non-production';
44
+ /**
45
+ * DELIBERATELY long, uncomfortable opt-in: bypass the SDK's
46
+ * sandbox-secret-in-production hard-fail. Setting this flag does NOT
47
+ * suppress the persistent console.error on every process start, and adds
48
+ * an X-Txnod-Client-Environment: production header to every API call.
49
+ *
50
+ * Renaming this option in any future SDK version requires a major-version
51
+ * bump and a deprecation cycle.
52
+ */
53
+ iAcknowledgeRoutingRealCustomerFundsToSandboxAddresses?: boolean;
54
+ }
55
+ /**
56
+ * Typed client for the TxNod integration API. Every method signs outbound
57
+ * requests with HMAC-SHA256 using `apiSecret`, retries on 429 and 5xx, and
58
+ * throws `TxnodError` on non-2xx responses.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { TxnodClient } from '@txnod/sdk';
63
+ *
64
+ * const client = new TxnodClient({
65
+ * projectId: process.env.TXNOD_PROJECT_ID!,
66
+ * apiSecret: process.env.TXNOD_API_SECRET!,
67
+ * });
68
+ *
69
+ * const invoice = await client.createInvoice({
70
+ * amount_usd: 10.0,
71
+ * coin: 'btc',
72
+ * external_id: 'order-123',
73
+ * callback_url: 'https://my-site.com/webhooks/txnod',
74
+ * });
75
+ * console.log(invoice.id, invoice.address);
76
+ * ```
77
+ */
78
+ export declare class TxnodClient {
79
+ #private;
80
+ /**
81
+ * Server `X-Txnod-Request-Id` header from the most recently completed call,
82
+ * regardless of HTTP status. Reset to `undefined` at the start of every call,
83
+ * so a value here always corresponds to the call that just finished. Use it
84
+ * to correlate a successful response with TxNod-side logs (on failure paths
85
+ * the same id is also surfaced as `err.request_id` on the thrown
86
+ * `TxnodError`).
87
+ *
88
+ * Caveat: the field is per-instance, not per-call. Concurrent calls on a
89
+ * shared `TxnodClient` will overwrite each other; create a new client per
90
+ * request scope, or read the field synchronously after `await`-ing a single
91
+ * call.
92
+ */
93
+ lastRequestId: string | undefined;
94
+ constructor(options: TxnodClientOptions);
95
+ /**
96
+ * Lazy accessor for the `client.sandbox.*` namespace exposing 14 thin HTTP
97
+ * wrappers around `/api/v1/sandbox/...` endpoints. The namespace class is
98
+ * only constructed on first access — when an integrator never references
99
+ * `client.sandbox`, the bundler's tree-shaker drops the entire
100
+ * `TxnodClientSandbox` class graph from the produced bundle.
101
+ *
102
+ * Methods throw the typed sandbox-specific error classes (e.g.
103
+ * `TxnodSandboxInvoiceTransitionInvalidError`) on 4xx/5xx server responses
104
+ * per FR55. See `docs/05-sandbox.md` in the bundled tarball for the full
105
+ * surface and code examples.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * import { TxnodClient, TxnodSandboxInvoiceTransitionInvalidError } from '@txnod/sdk';
110
+ *
111
+ * const client = new TxnodClient({
112
+ * projectId: process.env.TXNOD_PROJECT_ID!,
113
+ * apiSecret: process.env.TXNOD_API_SECRET!,
114
+ * environment: 'non-production',
115
+ * });
116
+ *
117
+ * try {
118
+ * const result = await client.sandbox.simulatePaid('01HK8MAR2QEXAMPLE000000000');
119
+ * console.log(result.event_id, result.status);
120
+ * } catch (err) {
121
+ * if (err instanceof TxnodSandboxInvoiceTransitionInvalidError) {
122
+ * console.error('forbidden simulate transition', err.request_id);
123
+ * } else {
124
+ * throw err;
125
+ * }
126
+ * }
127
+ * ```
128
+ */
129
+ get sandbox(): TxnodClientSandbox;
130
+ /**
131
+ * Re-read `TXNOD_<chain>_XPUB` env vars (and TON-specific siblings — the
132
+ * `TXNOD_TON_PUBKEY` family) into the client's xpub config. Useful after a
133
+ * wallet rotation in long-lived processes (Lambda containers, daemon-style
134
+ * workers) where the constructor ran with stale env values. Idempotent —
135
+ * calling it when env is unchanged is a no-op.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * import { TxnodClient } from '@txnod/sdk';
140
+ *
141
+ * const client = new TxnodClient({
142
+ * projectId: process.env.TXNOD_PROJECT_ID!,
143
+ * apiSecret: process.env.TXNOD_API_SECRET!,
144
+ * });
145
+ *
146
+ * // Operator rotated their xpub via the dashboard and your secrets manager
147
+ * // pushed the new TXNOD_BTC_XPUB into process.env. Pick it up without a restart:
148
+ * process.env.TXNOD_BTC_XPUB = 'zpub6r_NEW';
149
+ * client.refreshXpubConfig();
150
+ *
151
+ * // Subsequent createInvoice calls now verify the address against the new xpub.
152
+ * await client.createInvoice({
153
+ * external_id: 'after-rotation',
154
+ * coin: 'btc',
155
+ * amount_usd: 10,
156
+ * });
157
+ * ```
158
+ */
159
+ refreshXpubConfig(): void;
160
+ /**
161
+ * Create a new invoice. Idempotent on `(project_id, external_id)`. When the
162
+ * matching `TXNOD_<chain>_XPUB` env var is set, the SDK automatically
163
+ * verifies the returned address derives from the configured xpub at the
164
+ * invoice's `derivation_path` and throws `AddressVerificationError` on
165
+ * mismatch — no flag needed.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * import { TxnodClient, TxnodError, AddressVerificationError } from '@txnod/sdk';
170
+ *
171
+ * // Set TXNOD_BTC_XPUB=zpub6r... in env to enable address verification.
172
+ * const client = new TxnodClient({
173
+ * projectId: process.env.TXNOD_PROJECT_ID!,
174
+ * apiSecret: process.env.TXNOD_API_SECRET!,
175
+ * });
176
+ *
177
+ * try {
178
+ * const invoice = await client.createInvoice({
179
+ * amount_usd: 10.0,
180
+ * coin: 'btc',
181
+ * external_id: 'order-123',
182
+ * callback_url: 'https://my-site.com/webhooks/txnod',
183
+ * });
184
+ * console.log(invoice.id, invoice.address, invoice.payment_uri);
185
+ * } catch (err) {
186
+ * if (err instanceof AddressVerificationError) {
187
+ * console.error('address verify failed', err.expected_address, err.derived_address);
188
+ * } else if (err instanceof TxnodError) {
189
+ * console.error(err.error_code, err.status, err.request_id);
190
+ * }
191
+ * throw err;
192
+ * }
193
+ * ```
194
+ */
195
+ createInvoice(body: InvoiceCreateRequest): Promise<InvoiceResponse>;
196
+ /**
197
+ * Idempotent invoice creation. Tries `createInvoice`; on
198
+ * `TxnodExternalIdConflictError` fetches the pre-existing invoice via
199
+ * `searchInvoices({ external_id })` and returns it. Use this when your
200
+ * checkout flow may retry the same `external_id` (network glitches, idempotent
201
+ * upstream queues) and you want a single round-trip-then-fetch path.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const invoice = await client.createOrGetInvoice({
206
+ * external_id: 'order-42',
207
+ * coin: 'usdt_trc20',
208
+ * amount_usd: 9.99,
209
+ * });
210
+ * ```
211
+ */
212
+ createOrGetInvoice(body: InvoiceCreateRequest): Promise<InvoiceResponse>;
213
+ /**
214
+ * Fetch an invoice by ULID.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
219
+ *
220
+ * const client = new TxnodClient({
221
+ * projectId: process.env.TXNOD_PROJECT_ID!,
222
+ * apiSecret: process.env.TXNOD_API_SECRET!,
223
+ * });
224
+ *
225
+ * try {
226
+ * const invoice = await client.getInvoice('01HK8MAR2QEXAMPLE000000000');
227
+ * console.log(invoice.status);
228
+ * } catch (err) {
229
+ * if (err instanceof TxnodError) console.error(err.error_code);
230
+ * throw err;
231
+ * }
232
+ * ```
233
+ */
234
+ getInvoice(id: string): Promise<InvoiceResponse>;
235
+ /**
236
+ * Search invoices with snake_case query filters.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
241
+ *
242
+ * const client = new TxnodClient({
243
+ * projectId: process.env.TXNOD_PROJECT_ID!,
244
+ * apiSecret: process.env.TXNOD_API_SECRET!,
245
+ * });
246
+ *
247
+ * try {
248
+ * const page = await client.searchInvoices({
249
+ * status: 'paid',
250
+ * limit: 20,
251
+ * });
252
+ * for (const invoice of page.items) console.log(invoice.id);
253
+ * } catch (err) {
254
+ * if (err instanceof TxnodError) console.error(err.error_code);
255
+ * throw err;
256
+ * }
257
+ * ```
258
+ */
259
+ searchInvoices(query: InvoiceSearchQuery): Promise<CursorPaginatedInvoiceResponse>;
260
+ /**
261
+ * Cancel a pending invoice.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
266
+ *
267
+ * const client = new TxnodClient({
268
+ * projectId: process.env.TXNOD_PROJECT_ID!,
269
+ * apiSecret: process.env.TXNOD_API_SECRET!,
270
+ * });
271
+ *
272
+ * try {
273
+ * const cancelled = await client.cancelInvoice('01HK8MAR2QEXAMPLE000000000');
274
+ * console.log(cancelled.status);
275
+ * } catch (err) {
276
+ * if (err instanceof TxnodError) console.error(err.error_code);
277
+ * throw err;
278
+ * }
279
+ * ```
280
+ */
281
+ cancelInvoice(id: string): Promise<InvoiceResponse>;
282
+ /**
283
+ * List on-chain receipts that did not match any invoice address.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
288
+ *
289
+ * const client = new TxnodClient({
290
+ * projectId: process.env.TXNOD_PROJECT_ID!,
291
+ * apiSecret: process.env.TXNOD_API_SECRET!,
292
+ * });
293
+ *
294
+ * try {
295
+ * const page = await client.listOrphanPayments({ chain: 'btc', limit: 50 });
296
+ * for (const orphan of page.items) console.log(orphan.tx_hash);
297
+ * } catch (err) {
298
+ * if (err instanceof TxnodError) console.error(err.error_code);
299
+ * throw err;
300
+ * }
301
+ * ```
302
+ */
303
+ listOrphanPayments(query: OrphanPaymentListQuery): Promise<CursorPaginatedOrphanPaymentResponse>;
304
+ /**
305
+ * Attribute an orphan payment to an external invoice id.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
310
+ *
311
+ * const client = new TxnodClient({
312
+ * projectId: process.env.TXNOD_PROJECT_ID!,
313
+ * apiSecret: process.env.TXNOD_API_SECRET!,
314
+ * });
315
+ *
316
+ * try {
317
+ * const invoice = await client.attributeOrphanPayment('0xabc123', {
318
+ * external_id: 'order-123',
319
+ * });
320
+ * console.log(invoice.id);
321
+ * } catch (err) {
322
+ * if (err instanceof TxnodError) console.error(err.error_code);
323
+ * throw err;
324
+ * }
325
+ * ```
326
+ */
327
+ attributeOrphanPayment(txHash: string, body: OrphanAttributeRequest): Promise<InvoiceResponse>;
328
+ /**
329
+ * List outbound webhook events for the authenticated project.
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
334
+ *
335
+ * const client = new TxnodClient({
336
+ * projectId: process.env.TXNOD_PROJECT_ID!,
337
+ * apiSecret: process.env.TXNOD_API_SECRET!,
338
+ * });
339
+ *
340
+ * try {
341
+ * const page = await client.listWebhookEvents({
342
+ * status: 'delivered',
343
+ * limit: 100,
344
+ * });
345
+ * for (const event of page.items) console.log(event.id, event.status);
346
+ * } catch (err) {
347
+ * if (err instanceof TxnodError) console.error(err.error_code);
348
+ * throw err;
349
+ * }
350
+ * ```
351
+ */
352
+ listWebhookEvents(query: WebhookEventListApiQuery): Promise<WebhookEventListResponse>;
353
+ /**
354
+ * Resend a previously dispatched webhook event.
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
359
+ *
360
+ * const client = new TxnodClient({
361
+ * projectId: process.env.TXNOD_PROJECT_ID!,
362
+ * apiSecret: process.env.TXNOD_API_SECRET!,
363
+ * });
364
+ *
365
+ * try {
366
+ * const resent = await client.resendWebhookEvent(
367
+ * '01HK8MAR2QEXAMPLE000000000',
368
+ * );
369
+ * console.log(resent.event_id);
370
+ * } catch (err) {
371
+ * if (err instanceof TxnodError) console.error(err.error_code);
372
+ * throw err;
373
+ * }
374
+ * ```
375
+ */
376
+ resendWebhookEvent(eventId: string): Promise<WebhookEventResendResponse>;
377
+ /**
378
+ * Returns an indicative rate for pre-invoice pricing. The binding rate is
379
+ * captured by `createInvoice` in `rate_snapshot`; any delta between this
380
+ * quote and the invoice is the partner's responsibility per FR33c.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
385
+ *
386
+ * const client = new TxnodClient({
387
+ * projectId: process.env.TXNOD_PROJECT_ID!,
388
+ * apiSecret: process.env.TXNOD_API_SECRET!,
389
+ * });
390
+ *
391
+ * try {
392
+ * const rates = await client.getRates({ coins: 'btc,eth' });
393
+ * console.log(rates.rates.btc);
394
+ * } catch (err) {
395
+ * if (err instanceof TxnodError) console.error(err.error_code);
396
+ * throw err;
397
+ * }
398
+ * ```
399
+ */
400
+ getRates(query: RatesQuery): Promise<RatesResponse>;
401
+ /**
402
+ * Returns an indicative rate for pre-invoice pricing. The binding rate is
403
+ * captured by `createInvoice` in `rate_snapshot`; any delta between this
404
+ * quote and the invoice is the partner's responsibility per FR33c.
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * import { TxnodClient, TxnodError } from '@txnod/sdk';
409
+ *
410
+ * const client = new TxnodClient({
411
+ * projectId: process.env.TXNOD_PROJECT_ID!,
412
+ * apiSecret: process.env.TXNOD_API_SECRET!,
413
+ * });
414
+ *
415
+ * try {
416
+ * const quote = await client.quoteAmount({
417
+ * amount_usd: 10.0,
418
+ * coins: 'btc',
419
+ * });
420
+ * console.log(quote.quotes.btc);
421
+ * } catch (err) {
422
+ * if (err instanceof TxnodError) console.error(err.error_code);
423
+ * throw err;
424
+ * }
425
+ * ```
426
+ */
427
+ quoteAmount(query: QuoteQuery): Promise<QuoteResponse>;
428
+ }
429
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,8BAA8B,EAC9B,sBAAsB,EACtB,oCAAoC,EACpC,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AAWzC,OAAO,EA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