@txnod/sdk 1.1.0 → 1.2.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/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "@txnod/sdk — agent entry point"
3
3
  description: "How AI coding agents should consume @txnod/sdk documentation shipped inside the npm tarball."
4
- sdk_version: 1.1.0
4
+ sdk_version: 1.2.0
5
5
  ---
6
6
 
7
7
  # @txnod/sdk — agent entry point
package/CHANGELOG.md CHANGED
@@ -4,10 +4,18 @@ All notable changes to `@txnod/sdk` are documented here. Format: [Keep a Changel
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
- ## [1.1.0] - 2026-06-11
7
+ ## [1.2.0] - 2026-06-24
8
8
 
9
9
  ### Added
10
10
 
11
+ - New coin/chain helpers exported from the package root: `COIN_TO_CHAIN` (a `Record<Coin, Chain>` map), `coinToChain(coin)` (the function form), and `COIN_DECIMALS` (base-unit decimal places per coin). Use these when an API that speaks `coin` (invoices) meets one that speaks `chain` (orphan payments), or when you need a coin's on-chain precision.
12
+ - New amount converters `toBaseUnits(coin, humanString)` and `fromBaseUnits(coin, baseUnitsString)`. `toBaseUnits` turns a human decimal (`"1.5"`) into integer base units; `fromBaseUnits` is the inverse and trims trailing zeros. Both honour each coin's true precision — note that BEP-20 USDT/USDC use **18** decimals (not 6 like their ERC-20/TRC-20 siblings) and TON uses 9, so always round-trip `amount_units` through `fromBaseUnits` rather than assuming a width.
13
+ - `verifyWebhookSignature` now accepts the raw body as `string | Buffer` (Node HTTP frameworks hand back a `Buffer` — no `.toString()` boilerplate needed) and a headers bag that is a structural superset of Node's `IncomingHttpHeaders`, so Express/Fastify `req.headers` work alongside the Web `Headers` object. The accepted header shape is exported as the new type `WebhookHeadersInput`.
14
+ - New `client.environment` getter — resolves to `'production'`, `'non-production'`, or `'unknown'` after applying the constructor `environment` option and the `TXNOD_ENVIRONMENT` / `NODE_ENV` fallbacks. Read it at startup to fail fast on a misconfigured deploy.
15
+ - `OrphanPaymentResponse` now carries a `coin` field.
16
+ - The webhook event `data` payload now includes `external_id`, `metadata`, `amount_crypto`, and `amount_usd`.
17
+ - The webhook event envelope now carries `resent_from_event_id` (`string | null`) — honest redelivery lineage, **not** a restore flag. It is `null` on first-time events and set to the original event's `event_id` for BOTH operator-triggered resends **and** reorg re-confirmations. Key webhook idempotency on the unique `event_id` — **never on `tx_hash`**. The reorg-restore signal specifically is an `invoice.paid` whose `data.reason === 'reorg'` (it repeats a previously-reverted `tx_hash`); on that event re-apply the credit you reversed on the prior `invoice.reverted` rather than dropping it as a `tx_hash` duplicate. An operator resend (`resent_from_event_id` set, `data.reason` not `'reorg'`) is a duplicate delivery of an already-processed event — dedupe it via your `event_id` ledger.
18
+ - `createInvoice` accepts an optional `matching_mode` (`'exact' | 'at_least' | 'any'`) to override the project default per invoice. `exact` requires the deposit amount to equal the invoice amount; `at_least` accepts any amount ≥ the invoice amount (overpayment OK); `any` accepts any amount (donations / pay-what-you-want). Omit the field to inherit the project's configured default. When the address pool is saturated such that the invoice would share a deposit address, only `exact` is permitted — `at_least`/`any` reject with `TxnodOverlayMatchingModeError` (`overlay_matching_mode_required_exact`, HTTP 422). The same field now appears on every invoice response (`matching_mode`).
11
19
  - New sandbox invoice CRUD methods on `client.sandbox.*` — `createInvoice(body)`, `getInvoice(invoiceId)`, `listInvoices(query?)`, `cancelInvoice(invoiceId)` — mirroring the kind-locked production invoice surface against `/api/v1/sandbox/invoices`. The production `/api/v1/invoices` endpoints are production-kind-only and reject sandbox projects with `production_project_required`; sandbox projects must use these mirrors. Same request/response schemas and `(project_id, external_id)` idempotency contract; subject to the sandbox 10k active-invoice cap (`TxnodSandboxActiveInvoiceCapReachedError`).
12
20
  - New sandbox webhook delivery-log methods on `client.sandbox.*` — `listWebhookEvents(query?)` and `resendWebhookEvent(eventId)` — mirroring the kind-locked production `/api/v1/webhooks/events` surface against `/api/v1/sandbox/webhooks/events`. Same snake_case filters and response envelopes (`WebhookEventListResponse`, `WebhookEventResendResponse`); every listed row corresponds to an envelope delivered with `mode: 'sandbox'`.
13
21
  - New re-exported types from `@txnod/shared`: `ClockAdvance`, `CursorPaginatedInvoiceResponse`, `CursorPaginatedOrphanPaymentResponse`, `InvoiceCreateRequest`, `InvoiceResponse`, `InvoiceSearchQuery`, `OrphanAttributeRequest`, `OrphanPaymentListQuery`, `QuoteQuery`, `QuoteResponse`, `RatesQuery`, `RatesResponse`, `SimulateEvent`, `SimulateLatePayment`, `SimulateOverpaid`, `SimulatePartial`, `WalletsListResponse`, `WebhookEventListApiQuery`, `WebhookEventListResponse`, `WebhookEventResendResponse`.
package/README.md CHANGED
@@ -55,6 +55,29 @@ Operators enable coins per-project in the TxNod dashboard; a single `TxnodClient
55
55
  | `ton` | `ton` | TON native (Toncoin). |
56
56
  | `usdt_ton` | `ton` | Tether USD jetton on TON. |
57
57
 
58
+ ### Coin/chain helpers and amount conversion
59
+
60
+ The package root exports a small set of pure helpers for working with coins, chains, and on-chain amounts:
61
+
62
+ - `COIN_TO_CHAIN` — a `Record<Coin, Chain>` map; `coinToChain(coin)` is the function form. Use either when an API that speaks `coin` (invoices) meets one that speaks `chain` (orphan payments).
63
+ - `COIN_DECIMALS` — a `Record<Coin, number>` of base-unit decimal places per coin.
64
+ - `toBaseUnits(coin, humanString)` — converts a human decimal (`"1.5"`) into integer base units. Throws on malformed input, too many fractional digits for the coin, or a zero result.
65
+ - `fromBaseUnits(coin, baseUnitsString)` — the inverse: formats integer base units (e.g. an invoice/webhook `amount_units` string) as a human decimal, trimming trailing zeros.
66
+
67
+ ```ts
68
+ import { coinToChain, COIN_DECIMALS, toBaseUnits, fromBaseUnits } from '@txnod/sdk';
69
+
70
+ coinToChain('usdt_trc20'); // 'tron'
71
+ COIN_DECIMALS.usdt_bep20; // 18
72
+
73
+ // BEP-20 trap: usdt_bep20 / usdc_bep20 / bnb use 18 decimals on-chain, unlike
74
+ // the 6-decimal ERC-20 / TRC-20 / Polygon stablecoins (and TON, which is 9).
75
+ // Always round-trip `amount_units` through fromBaseUnits rather than assuming 6.
76
+ fromBaseUnits('usdt_bep20', '1500000000000000000'); // '1.5'
77
+ fromBaseUnits('usdt_trc20', '1500000'); // '1.5'
78
+ toBaseUnits('usdt_bep20', '1.5'); // '1500000000000000000'
79
+ ```
80
+
58
81
  ## SDK-side address verification (`TXNOD_<chain>_XPUB`)
59
82
 
60
83
  When the matching env var is set, `createInvoice` automatically derives the expected deposit address from the operator's xpub at the invoice's `derivation_path` and rejects with `AddressVerificationError` on mismatch. This is the SDK's defense against a compromised gateway silently swapping the deposit address. Set per chain you accept; omit to skip verification on that chain.
@@ -168,6 +191,35 @@ export async function POST(request: Request): Promise<Response> {
168
191
  }
169
192
  ```
170
193
 
194
+ ### Per-invoice amount matching — `matching_mode`
195
+
196
+ `createInvoice` accepts an optional `matching_mode` that controls how strictly a deposit's amount must match the invoice at attribution time:
197
+
198
+ | Mode | Meaning | Use for |
199
+ |---|---|---|
200
+ | `exact` | The deposit amount must equal the invoice amount. | Standard fixed-price checkout. |
201
+ | `at_least` | Any amount **≥** the invoice amount matches (overpayment is accepted). | Tips on top of a price, "pay at least X". |
202
+ | `any` | **Any** amount matches. | Donations, pay-what-you-want, top-ups. |
203
+
204
+ Omit the field to inherit the project's configured default (set in the dashboard). The chosen mode is echoed back on every invoice response as `matching_mode`.
205
+
206
+ ```ts
207
+ import { TxnodClient } from '@txnod/sdk';
208
+
209
+ declare const client: TxnodClient;
210
+
211
+ // Donation: accept whatever the supporter sends.
212
+ const donation = await client.createInvoice({
213
+ external_id: 'donation-2026-06',
214
+ coin: 'usdt_trc20',
215
+ amount_usd: 5, // suggested amount; `any` accepts more or less
216
+ matching_mode: 'any',
217
+ });
218
+ console.log(donation.matching_mode); // 'any'
219
+ ```
220
+
221
+ > **Saturation caveat (`overlay_matching_mode_required_exact`, HTTP 422):** when the operator's address pool is fully allocated, a new invoice may have to share a deposit address with another invoice. In that case TxNod can only tell the two apart by amount, so only `exact` is permitted — `at_least` and `any` reject with `TxnodOverlayMatchingModeError`. Catch it and retry with `exact`, or surface "checkout temporarily unavailable" and notify the operator to grow the pool.
222
+
171
223
  ## Quickstart — verify a webhook
172
224
 
173
225
  A complete `app/api/txnod-webhook/route.ts` that validates the inbound HMAC and narrows the typed event:
@@ -205,6 +257,84 @@ export async function POST(request: Request): Promise<Response> {
205
257
  }
206
258
  ```
207
259
 
260
+ `verifyWebhookSignature(headers, rawBody, secret)` is framework-agnostic on both arguments:
261
+
262
+ - **`headers`** accepts either the Web `Headers` object (shown above) or any plain header bag whose values are `string | string[] | undefined` — a structural superset of Node's `IncomingHttpHeaders`, so Express/Fastify `req.headers` work unchanged. The accepted shape is exported as the type `WebhookHeadersInput`.
263
+ - **`rawBody`** accepts `string | Buffer`. Node HTTP frameworks hand back the raw body as a `Buffer`, so you can pass it straight through with no `.toString()` boilerplate.
264
+
265
+ ```js
266
+ import express from 'express';
267
+ import { verifyWebhookSignature } from '@txnod/sdk';
268
+
269
+ const app = express();
270
+ // Capture the *raw* bytes — HMAC is computed over the exact payload, so this
271
+ // must run before any JSON body parser rewrites the buffer.
272
+ app.post('/api/txnod-webhook', express.raw({ type: '*/*' }), (req, res) => {
273
+ // req.headers is a WebhookHeadersInput (IncomingHttpHeaders); req.body is a
274
+ // Buffer — both accepted by verifyWebhookSignature with no conversion.
275
+ const event = verifyWebhookSignature(req.headers, req.body, process.env.TXNOD_WEBHOOK_SECRET);
276
+ if (event.event_type === 'invoice.paid') {
277
+ console.log('paid invoice', event.data.invoice_id);
278
+ }
279
+ res.json({ ok: true });
280
+ });
281
+ ```
282
+
283
+ ### Webhook idempotency and reorg restores — read this
284
+
285
+ Key your webhook idempotency on the envelope's unique `event_id` — **never on `tx_hash`**. A blockchain reorg can roll back a confirmed payment and then re-confirm it, and the SDK surfaces that cycle explicitly so you don't lose (or silently drop) the restore:
286
+
287
+ 1. The invoice confirms → `invoice.paid` with `event_id = A` (and `data.reason` absent). Fulfill the order.
288
+ 2. A reorg orphans the confirming block → `invoice.reverted`. Reverse the credit.
289
+ 3. The payment re-lands on the canonical chain → a **new** `invoice.paid` arrives with a **fresh** `event_id = C` and **`data.reason === 'reorg'`**. This is a **restore**: re-apply the credit.
290
+
291
+ The restoring `invoice.paid` may carry the **same `tx_hash`** as the original. If you dedupe on `tx_hash`, you would drop the restore and the user would stay un-credited after you reversed them on step 2. So:
292
+
293
+ - **Idempotency key = `event_id`** (unique per delivery). Never `tx_hash`.
294
+ - **The reorg-restore signal = `data.reason === 'reorg'`** on an `invoice.paid`.
295
+ - **`resent_from_event_id`** is honest redelivery lineage — `null` on first-time events, set to the original event's `event_id` for BOTH operator-triggered resends **and** reorg re-confirmations. It is *not* a restore flag; an operator resend (`resent_from_event_id` set, `data.reason` not `'reorg'`) is just a duplicate delivery, absorbed by your `event_id` dedupe.
296
+
297
+ ```ts
298
+ import { verifyWebhookSignature } from '@txnod/sdk';
299
+
300
+ export async function POST(request: Request): Promise<Response> {
301
+ const event = verifyWebhookSignature(
302
+ request.headers,
303
+ await request.text(),
304
+ process.env.TXNOD_WEBHOOK_SECRET!,
305
+ );
306
+
307
+ // Dedupe on event_id — the ONLY safe idempotency key. Never tx_hash.
308
+ // This also absorbs operator resends (a duplicate of an already-seen event).
309
+ if (await alreadyProcessed(event.event_id)) {
310
+ return Response.json({ ok: true });
311
+ }
312
+
313
+ if (event.event_type === 'invoice.reverted') {
314
+ await reverseCredit(event.data.invoice_id); // undo fulfillment
315
+ } else if (event.event_type === 'invoice.paid') {
316
+ if (event.data.reason === 'reorg') {
317
+ // Restore after a reorg revert. Same invoice (and possibly the same
318
+ // tx_hash) — re-apply the credit; do NOT drop it as a duplicate.
319
+ await restoreCredit(event.data.invoice_id);
320
+ } else {
321
+ await fulfillOrder(event.data.invoice_id); // first-time payment
322
+ }
323
+ }
324
+
325
+ await markProcessed(event.event_id);
326
+ return Response.json({ ok: true });
327
+ }
328
+
329
+ declare function alreadyProcessed(eventId: string): Promise<boolean>;
330
+ declare function markProcessed(eventId: string): Promise<void>;
331
+ declare function fulfillOrder(invoiceId: string): Promise<void>;
332
+ declare function reverseCredit(invoiceId: string): Promise<void>;
333
+ declare function restoreCredit(invoiceId: string): Promise<void>;
334
+ ```
335
+
336
+ Correlate the revert/restore pair by `data.invoice_id`. An invoice that goes through the revert/re-confirm cycle legitimately emits `invoice.paid` more than once — `invoice.paid` is **not** a once-per-invoice event.
337
+
208
338
  ## Polygon PoS — create and verify (usdt_polygon)
209
339
 
210
340
  Polygon PoS invoices settle after 128 blocks — the Heimdall checkpoint depth at which the SDK marks an `invoice.paid` event terminal. The snippet below creates a USDT-Polygon invoice and, in the webhook route, matches the inbound `invoice.paid` event against the invoice id.
@@ -365,6 +495,25 @@ console.log(client.lastRequestId);
365
495
 
366
496
  `TXNOD_SDK_LOG_LEVEL` controls the SDK's internal pino logger (default `warn`). Set to `info`/`debug` for more verbose internals. The logger redacts `xpub` and `apiSecret` keys.
367
497
 
498
+ ### Resolved environment — `client.environment`
499
+
500
+ `client.environment` reports the SDK's resolved deployment context as `'production'`, `'non-production'`, or `'unknown'`, after applying the constructor `environment` option and the `TXNOD_ENVIRONMENT` / `NODE_ENV` fallbacks. Read it at startup to fail fast on a misconfigured deploy, or to gate logging verbosity.
501
+
502
+ ```ts
503
+ import { TxnodClient } from '@txnod/sdk';
504
+
505
+ const client = new TxnodClient({
506
+ projectId: process.env.TXNOD_PROJECT_ID!,
507
+ apiSecret: process.env.TXNOD_API_SECRET!,
508
+ });
509
+
510
+ // Fail fast instead of silently signing production requests with a
511
+ // non-production wiring.
512
+ if (client.environment !== 'production') {
513
+ throw new Error(`TxNod: expected production, got ${client.environment}`);
514
+ }
515
+ ```
516
+
368
517
  ## Idempotent invoice creation — `createOrGetInvoice`
369
518
 
370
519
  If your checkout flow may retry the same `external_id` (network glitch, queue at-least-once delivery), `createOrGetInvoice` collapses the "create-then-conflict-then-search" pattern into one call:
@@ -5,7 +5,7 @@
5
5
 
6
6
  export type InvoiceStatus = "pending" | "detected" | "paid" | "overpaid" | "partial" | "expired" | "expired_paid_late" | "reverted" | "cancelled" | "ambiguous";
7
7
 
8
- export type InvoiceCreateRequest = { external_id: string; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; amount_usd?: number | undefined; amount_crypto?: string | undefined; callback_url?: string | undefined; metadata?: Record<string, unknown> | undefined; };
8
+ export type InvoiceCreateRequest = { external_id: string; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; amount_usd?: number | undefined; amount_crypto?: string | undefined; callback_url?: string | undefined; metadata?: Record<string, unknown> | undefined; matching_mode?: "any" | "exact" | "at_least" | undefined; };
9
9
 
10
10
  export type InvoiceResponse = { id: string; project_id: string; external_id: string; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; address: string; amount_crypto: string; amount_crypto_units: string; amount_usd: number | null; rate_snapshot: { rate: string; source: "coinpaprika" | "coingecko"; quoted_at: string; rate_is_stale: boolean; rate_age_seconds: number; } | null; payment_token: string | null; payment_uri: string; callback_url: string | null; metadata: Record<string, unknown> | null; matching_mode: "any" | "exact" | "at_least"; confirmation_threshold: number; status: "pending" | "detected" | "paid" | "overpaid" | "partial" | "expired" | "expired_paid_late" | "reverted" | "cancelled" | "ambiguous"; expires_at: number; expires_at_iso: string; created_at: number; created_at_iso: string; derivation_path?: string | undefined; verification_standard?: "bip84" | "bip44" | "cip1852" | "bip44_ed25519" | undefined; transactions?: { id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; tx_hash: string; to_address: string | null; tx_output_index: number | null; amount_units: string; block_height: number | null; confirmations: number; received_at: number; received_at_iso: string; orphaned_at: number | null; orphaned_at_iso: string | null; }[] | undefined; confirmations?: number | undefined; };
11
11
 
@@ -25,7 +25,7 @@ export type ResolvedFacts = { sender_address: string; recipient_address: string;
25
25
 
26
26
  export type OrphanPaymentListQuery = { attributed?: boolean | undefined; chain?: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc" | undefined; tx_hash?: string | undefined; date_from?: string | undefined; date_to?: string | undefined; amount_units_gte?: string | undefined; amount_units_lte?: string | undefined; cursor?: string | undefined; limit?: number | undefined; };
27
27
 
28
- export type CursorPaginatedOrphanPaymentResponse = { items: { id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; tx_hash: string; to_address: string; tx_output_index: number; amount_units: string; block_height: number | null; received_at: number; received_at_iso: string; attributed: boolean; attributed_invoice_id: string | null; attributed_external_id: string | null; attributed_at: number | null; attributed_at_iso: string | null; }[]; next_cursor?: string | undefined; };
28
+ export type CursorPaginatedOrphanPaymentResponse = { items: { id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton" | null; tx_hash: string; to_address: string; tx_output_index: number; amount_units: string; block_height: number | null; received_at: number; received_at_iso: string; attributed: boolean; attributed_invoice_id: string | null; attributed_external_id: string | null; attributed_at: number | null; attributed_at_iso: string | null; }[]; next_cursor?: string | undefined; };
29
29
 
30
30
  export type OrphanAttributeRequest = { external_id: string; user_id?: string | undefined; metadata?: Record<string, unknown> | undefined; to_address?: string | undefined; tx_output_index?: number | undefined; };
31
31
 
@@ -35,9 +35,9 @@ export type WebhookEventListResponse = { items: { id: string; event_type: "invoi
35
35
 
36
36
  export type WebhookEventResendResponse = { event_id: string; original_event_id: string; event_type: "invoice.detected" | "invoice.paid" | "invoice.overpaid" | "invoice.partial" | "invoice.expired" | "invoice.expired_paid_late" | "invoice.reverted" | "invoice.ambiguous"; project_id: string; invoice_id: string | null; target_url: string | null; created_at: number; created_at_iso: string; };
37
37
 
38
- export type WebhookEvent = { event_id: string; event_type: "invoice.detected"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.paid"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.overpaid"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.partial"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.expired"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.expired_paid_late"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.reverted"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; } | { event_id: string; event_type: "invoice.ambiguous"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; };
38
+ export type WebhookEvent = { event_id: string; event_type: "invoice.detected"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.paid"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.overpaid"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.partial"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.expired"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.expired_paid_late"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.reverted"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; } | { event_id: string; event_type: "invoice.ambiguous"; created_at: number; created_at_iso: string; project_id: string; data: { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; }; attempt: number; mode: "production" | "testnet" | "sandbox"; resent_from_event_id: string | null; };
39
39
 
40
- export type WebhookEventData = { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; };
40
+ export type WebhookEventData = { invoice_id: string; project_id: string; chain: "btc" | "eth" | "ada" | "ton" | "tron" | "polygon" | "bsc"; coin: "btc" | "eth" | "usdt_erc20" | "usdc_erc20" | "trx" | "usdt_trc20" | "ada" | "pol" | "usdt_polygon" | "usdc_polygon" | "bnb" | "usdt_bep20" | "usdc_bep20" | "ton" | "usdt_ton"; external_id: string; metadata: Record<string, unknown> | null; amount_crypto: string; amount_usd: string | null; tx_hash: string; to_address: string | null; amount_units: string; confirmations: number; block_height: number | null; payment_token: string | null; matched_payment_token: string | null; chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string | undefined; } | undefined; } | null; reason?: "reorg" | "late_arrival" | undefined; };
41
41
 
42
42
  export type WebhookEventMode = "production" | "testnet" | "sandbox";
43
43
 
package/dist/client.d.ts CHANGED
@@ -127,6 +127,30 @@ export declare class TxnodClient {
127
127
  * ```
128
128
  */
129
129
  get sandbox(): TxnodClientSandbox;
130
+ /**
131
+ * The resolved SDK environment — `'production'`, `'non-production'`, or
132
+ * `'unknown'` — after applying the constructor `environment` option and the
133
+ * `TXNOD_ENVIRONMENT` / `NODE_ENV` fallbacks. Read it at startup to assert
134
+ * your wiring (e.g. fail fast if a production deploy resolved to
135
+ * `'non-production'`/`'unknown'`, or to gate logging/verbosity).
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
+ * // Fail fast on a misconfigured deploy instead of silently signing
147
+ * // production requests with a non-production wiring.
148
+ * if (client.environment !== 'production') {
149
+ * throw new Error(`TxNod: expected production, got ${client.environment}`);
150
+ * }
151
+ * ```
152
+ */
153
+ get environment(): 'production' | 'non-production' | 'unknown';
130
154
  /**
131
155
  * Re-read `TXNOD_<chain>_XPUB` env vars (and TON-specific siblings — the
132
156
  * `TXNOD_TON_PUBKEY` family) into the client's xpub config. Useful after a
@@ -164,6 +188,14 @@ export declare class TxnodClient {
164
188
  * invoice's `derivation_path` and throws `AddressVerificationError` on
165
189
  * mismatch — no flag needed.
166
190
  *
191
+ * Pass the optional `matching_mode` (`'exact' | 'at_least' | 'any'`) to
192
+ * override the project's default amount-matching policy for this invoice.
193
+ * When omitted the invoice inherits the project default. Note: `'any'` /
194
+ * `'at_least'` are rejected (HTTP 422 `overlay_matching_mode_required_exact`)
195
+ * when the address pool is saturated and the invoice would land as an
196
+ * amount-overlay sibling on a shared pool address — amount disambiguation
197
+ * there requires `'exact'`.
198
+ *
167
199
  * @example
168
200
  * ```ts
169
201
  * import { TxnodClient, TxnodError, AddressVerificationError } from '@txnod/sdk';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,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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AQ3B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,iBAAiB,CACf,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAOxE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAQnD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;CAOvD"}
package/dist/client.js CHANGED
@@ -165,6 +165,32 @@ export class TxnodClient {
165
165
  }
166
166
  return this.#sandboxNamespace;
167
167
  }
168
+ /**
169
+ * The resolved SDK environment — `'production'`, `'non-production'`, or
170
+ * `'unknown'` — after applying the constructor `environment` option and the
171
+ * `TXNOD_ENVIRONMENT` / `NODE_ENV` fallbacks. Read it at startup to assert
172
+ * your wiring (e.g. fail fast if a production deploy resolved to
173
+ * `'non-production'`/`'unknown'`, or to gate logging/verbosity).
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * import { TxnodClient } from '@txnod/sdk';
178
+ *
179
+ * const client = new TxnodClient({
180
+ * projectId: process.env.TXNOD_PROJECT_ID!,
181
+ * apiSecret: process.env.TXNOD_API_SECRET!,
182
+ * });
183
+ *
184
+ * // Fail fast on a misconfigured deploy instead of silently signing
185
+ * // production requests with a non-production wiring.
186
+ * if (client.environment !== 'production') {
187
+ * throw new Error(`TxNod: expected production, got ${client.environment}`);
188
+ * }
189
+ * ```
190
+ */
191
+ get environment() {
192
+ return getSdkEnv(this.#environmentOption);
193
+ }
168
194
  /**
169
195
  * Re-read `TXNOD_<chain>_XPUB` env vars (and TON-specific siblings — the
170
196
  * `TXNOD_TON_PUBKEY` family) into the client's xpub config. Useful after a
@@ -239,6 +265,14 @@ export class TxnodClient {
239
265
  * invoice's `derivation_path` and throws `AddressVerificationError` on
240
266
  * mismatch — no flag needed.
241
267
  *
268
+ * Pass the optional `matching_mode` (`'exact' | 'at_least' | 'any'`) to
269
+ * override the project's default amount-matching policy for this invoice.
270
+ * When omitted the invoice inherits the project default. Note: `'any'` /
271
+ * `'at_least'` are rejected (HTTP 422 `overlay_matching_mode_required_exact`)
272
+ * when the address pool is saturated and the invoice would land as an
273
+ * amount-overlay sibling on a shared pool address — amount disambiguation
274
+ * there requires `'exact'`.
275
+ *
242
276
  * @example
243
277
  * ```ts
244
278
  * import { TxnodClient, TxnodError, AddressVerificationError } from '@txnod/sdk';
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,WAAW,GAIZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACpD,CAAC;AAED,SAAS,aAAa,CACpB,CAAwD;IAExD,MAAM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@link Coin} (e.g. `usdt_trc20`) to the {@link Chain} it settles on
4
+ * (e.g. `tron`). Useful when an API that speaks `Coin` (invoices) meets one
5
+ * that speaks `Chain` (orphan payments).
6
+ */
7
+ export declare const COIN_TO_CHAIN: Record<Coin, Chain>;
8
+ /** Returns the {@link Chain} a {@link Coin} settles on. */
9
+ export declare function coinToChain(coin: Coin): Chain;
10
+ /**
11
+ * Base-unit decimal places per {@link Coin}. NOTE the traps: BEP-20 USDT/USDC
12
+ * are **18** decimals (not 6 like their ERC-20/TRC-20 siblings), and TON is 9.
13
+ * Always format `amount_units` (base units, from invoices and webhooks)
14
+ * through {@link fromBaseUnits} rather than assuming a width.
15
+ */
16
+ export declare const COIN_DECIMALS: Record<Coin, number>;
17
+ /**
18
+ * Converts a human decimal amount (e.g. `"1.5"`) into integer base units
19
+ * (e.g. `"1500000"` for a 6-decimal coin). Throws on malformed input, too many
20
+ * fractional digits for the coin, or a zero result.
21
+ */
22
+ export declare function toBaseUnits(coin: Coin, humanString: string): string;
23
+ /**
24
+ * Formats integer base units (e.g. an invoice/webhook `amount_units` string)
25
+ * as a human decimal string (e.g. `"1500000"` → `"1.5"` for a 6-decimal
26
+ * coin), trimming trailing zeros. The inverse of {@link toBaseUnits}.
27
+ */
28
+ export declare function fromBaseUnits(coin: Coin, baseUnitsString: string): string;
29
+ //# sourceMappingURL=coins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coins.d.ts","sourceRoot":"","sources":["../src/coins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAQjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAgB7C,CAAC;AAEF,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,CAE7C;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAgB9C,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA2BnE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAczE"}
package/dist/coins.js ADDED
@@ -0,0 +1,107 @@
1
+ // Vendored copies of the shared coin metadata. The published SDK has ZERO
2
+ // runtime dependency on `@txnod/shared` (it imports only *types*), so these
3
+ // maps are duplicated here as plain data — kept honest by the drift guard in
4
+ // `coins.test.ts`, which compares them against the shared source. The
5
+ // `Record<Coin, …>` shape makes the type-checker reject any missing coin.
6
+ /**
7
+ * Maps a {@link Coin} (e.g. `usdt_trc20`) to the {@link Chain} it settles on
8
+ * (e.g. `tron`). Useful when an API that speaks `Coin` (invoices) meets one
9
+ * that speaks `Chain` (orphan payments).
10
+ */
11
+ export const COIN_TO_CHAIN = {
12
+ btc: 'btc',
13
+ eth: 'eth',
14
+ usdt_erc20: 'eth',
15
+ usdc_erc20: 'eth',
16
+ trx: 'tron',
17
+ usdt_trc20: 'tron',
18
+ ada: 'ada',
19
+ pol: 'polygon',
20
+ usdt_polygon: 'polygon',
21
+ usdc_polygon: 'polygon',
22
+ bnb: 'bsc',
23
+ usdt_bep20: 'bsc',
24
+ usdc_bep20: 'bsc',
25
+ ton: 'ton',
26
+ usdt_ton: 'ton',
27
+ };
28
+ /** Returns the {@link Chain} a {@link Coin} settles on. */
29
+ export function coinToChain(coin) {
30
+ return COIN_TO_CHAIN[coin];
31
+ }
32
+ /**
33
+ * Base-unit decimal places per {@link Coin}. NOTE the traps: BEP-20 USDT/USDC
34
+ * are **18** decimals (not 6 like their ERC-20/TRC-20 siblings), and TON is 9.
35
+ * Always format `amount_units` (base units, from invoices and webhooks)
36
+ * through {@link fromBaseUnits} rather than assuming a width.
37
+ */
38
+ export const COIN_DECIMALS = {
39
+ btc: 8,
40
+ eth: 18,
41
+ usdt_erc20: 6,
42
+ usdc_erc20: 6,
43
+ trx: 6,
44
+ usdt_trc20: 6,
45
+ ada: 6,
46
+ pol: 18,
47
+ usdt_polygon: 6,
48
+ usdc_polygon: 6,
49
+ bnb: 18,
50
+ usdt_bep20: 18,
51
+ usdc_bep20: 18,
52
+ ton: 9,
53
+ usdt_ton: 6,
54
+ };
55
+ const VALID_AMOUNT_REGEX = /^(0|[1-9][0-9]*)(\.[0-9]+)?$/;
56
+ /**
57
+ * Converts a human decimal amount (e.g. `"1.5"`) into integer base units
58
+ * (e.g. `"1500000"` for a 6-decimal coin). Throws on malformed input, too many
59
+ * fractional digits for the coin, or a zero result.
60
+ */
61
+ export function toBaseUnits(coin, humanString) {
62
+ if (typeof humanString !== 'string') {
63
+ throw new Error('amount must be a string');
64
+ }
65
+ if (humanString !== humanString.trim()) {
66
+ throw new Error('amount must not have leading or trailing whitespace');
67
+ }
68
+ if (humanString === '') {
69
+ throw new Error('amount must not be empty');
70
+ }
71
+ if (!VALID_AMOUNT_REGEX.test(humanString)) {
72
+ throw new Error(`invalid amount format: ${humanString}`);
73
+ }
74
+ const decimals = COIN_DECIMALS[coin];
75
+ const [whole, frac = ''] = humanString.split('.');
76
+ if (frac.length > decimals) {
77
+ throw new Error(`amount has more than ${decimals} fractional digits for ${coin}: ${humanString}`);
78
+ }
79
+ const fracPadded = frac.padEnd(decimals, '0');
80
+ const combined = `${whole}${fracPadded}`;
81
+ const asBig = BigInt(combined);
82
+ if (asBig === 0n) {
83
+ throw new Error('amount must be greater than zero');
84
+ }
85
+ return asBig.toString();
86
+ }
87
+ /**
88
+ * Formats integer base units (e.g. an invoice/webhook `amount_units` string)
89
+ * as a human decimal string (e.g. `"1500000"` → `"1.5"` for a 6-decimal
90
+ * coin), trimming trailing zeros. The inverse of {@link toBaseUnits}.
91
+ */
92
+ export function fromBaseUnits(coin, baseUnitsString) {
93
+ if (!/^[0-9]+$/.test(baseUnitsString)) {
94
+ throw new Error(`invalid base-units string: ${baseUnitsString}`);
95
+ }
96
+ const decimals = COIN_DECIMALS[coin];
97
+ const value = BigInt(baseUnitsString);
98
+ const divisor = 10n ** BigInt(decimals);
99
+ const whole = value / divisor;
100
+ const frac = value % divisor;
101
+ if (frac === 0n) {
102
+ return whole.toString();
103
+ }
104
+ const fracStr = frac.toString().padStart(decimals, '0').replace(/0+$/, '');
105
+ return `${whole.toString()}.${fracStr}`;
106
+ }
107
+ //# sourceMappingURL=coins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coins.js","sourceRoot":"","sources":["../src/coins.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,0EAA0E;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;IACjB,GAAG,EAAE,MAAM;IACX,UAAU,EAAE,MAAM;IAClB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,SAAS;IACd,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,SAAS;IACvB,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;IACjB,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,2DAA2D;AAC3D,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAyB;IACjD,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IACP,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,CAAC;IACb,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IAC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,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAU,EAAE,eAAuB;IAC/D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,8BAA8B,eAAe,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;IAC9B,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;IAC7B,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3E,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,OAAO,EAAE,CAAC;AAC1C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -19,12 +19,13 @@ export declare const PACKAGE_NAME: "@txnod/sdk";
19
19
  * console.log(`@txnod/sdk v${SDK_VERSION}`);
20
20
  * ```
21
21
  */
22
- export declare const SDK_VERSION: "1.1.0";
22
+ export declare const SDK_VERSION: "1.2.0";
23
23
  export { TxnodClient, type TxnodClientOptions, type TxnodRequestLogEntry, type TxnodRequestLogger, } from './client.js';
24
24
  export { getSdkEnv } from './env.js';
25
25
  export { TxnodClientSandbox, type SandboxClockAdvanceResult, type SandboxLifecycleResult, type SandboxSimulateResult, } from './client-sandbox.js';
26
26
  export { TxnodAmountOutOfRangeError, TxnodAuthInvalidError, TxnodCoinNotEnabledError, TxnodEnvironmentUnknownError, TxnodError, TxnodEventNotFoundError, TxnodEventNotResendableError, TxnodExternalIdConflictError, TxnodHmacError, TxnodInvalidCoinError, TxnodInvalidStateTransitionError, TxnodInvalidWebhookUrlError, TxnodInvalidXpubFormatError, TxnodInvoiceNotCancellableError, TxnodInvoiceNotFoundError, TxnodKeyRevokedError, TxnodKeySuspendedError, TxnodOrphanAlreadyAttributedError, TxnodOrphanNotFoundError, TxnodOverlayMatchingModeError, TxnodPermissionDeniedError, TxnodPoolExhaustedError, TxnodProductionKeyAgainstSandboxProjectError, TxnodProjectNotFoundError, TxnodProjectSuspendedError, TxnodRateLimitError, TxnodRateQuoteUnavailableError, TxnodSandboxActiveInvoiceCapReachedError, TxnodSandboxDeleteFailedError, TxnodSandboxInvoiceNotFoundError, TxnodSandboxInvoiceTerminalError, TxnodSandboxInvoiceTransitionInvalidError, TxnodSandboxKeyAgainstProductionProjectError, TxnodSandboxKeyInProductionError, TxnodSandboxPerOperatorCapReachedError, TxnodSandboxProjectRequiredError, TxnodProductionProjectRequiredError, TxnodSandboxProvisioningFailedError, TxnodSandboxRateLimitExceededError, TxnodSandboxResetFailedError, TxnodSandboxXpubInProductionError, TxnodServerError, TxnodSignatureFormatError, TxnodSignatureInvalidError, TxnodSignatureReplayedError, TxnodSubscriptionExpiredError, TxnodTimestampError, TxnodTimestampOutOfWindowError, TxnodTonCommentParseFailedError, TxnodTonConnectDomainMismatchError, TxnodTonConnectNetworkMismatchError, TxnodTonConnectPayloadExpiredError, TxnodTonConnectPayloadUnknownError, TxnodTonConnectSignatureInvalidError, TxnodTonConnectTimestampSkewError, TxnodTonConnectUnknownWalletVersionError, TxnodTonInvalidWalletVersionError, TxnodTonJettonResolveFailedError, TxnodTonOperatorWalletNotDeployedError, TxnodTronNoActivatedAddressesError, TxnodValidationError, TxnodWalletHasActiveBindingsError, TxnodWalletKindMismatchError, TxnodWalletNotBoundError, TxnodWalletNotFoundError, TxnodWalletNotOwnedError, TxnodTxNotFoundError, TxnodTxAlreadyAttributedError, TxnodWebhookCapacityExhaustedError, TxnodWebhookPayloadParseError, TxnodXpubNotVerifiedError, } from './errors.js';
27
- export { verifyWebhookSignature } from './verify-webhook-signature.js';
27
+ export { verifyWebhookSignature, type WebhookHeadersInput, } from './verify-webhook-signature.js';
28
+ export { COIN_TO_CHAIN, coinToChain, COIN_DECIMALS, toBaseUnits, fromBaseUnits, } from './coins.js';
28
29
  export { verifyAddress } from './verify/index.js';
29
30
  export type { VerifyAddressInput, VerificationResult } from './verify/index.js';
30
31
  export { verifyTonAddress } from './verify/chains/ton.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAG,YAAqB,CAAC;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,EAAG,OAAgB,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,gCAAgC,EAChC,2BAA2B,E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AE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACJ,8BAA8B,EAC9B,oCAAoC,EACpC,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAG,YAAqB,CAAC;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,EAAG,OAAgB,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,gCAAgC,EAChC,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B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wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACJ,8BAA8B,EAC9B,oCAAoC,EACpC,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -19,12 +19,13 @@ export const PACKAGE_NAME = '@txnod/sdk';
19
19
  * console.log(`@txnod/sdk v${SDK_VERSION}`);
20
20
  * ```
21
21
  */
22
- export const SDK_VERSION = '1.1.0';
22
+ export const SDK_VERSION = '1.2.0';
23
23
  export { TxnodClient, } from './client.js';
24
24
  export { getSdkEnv } from './env.js';
25
25
  export { TxnodClientSandbox, } from './client-sandbox.js';
26
26
  export { TxnodAmountOutOfRangeError, TxnodAuthInvalidError, TxnodCoinNotEnabledError, TxnodEnvironmentUnknownError, TxnodError, TxnodEventNotFoundError, TxnodEventNotResendableError, TxnodExternalIdConflictError, TxnodHmacError, TxnodInvalidCoinError, TxnodInvalidStateTransitionError, TxnodInvalidWebhookUrlError, TxnodInvalidXpubFormatError, TxnodInvoiceNotCancellableError, TxnodInvoiceNotFoundError, TxnodKeyRevokedError, TxnodKeySuspendedError, TxnodOrphanAlreadyAttributedError, TxnodOrphanNotFoundError, TxnodOverlayMatchingModeError, TxnodPermissionDeniedError, TxnodPoolExhaustedError, TxnodProductionKeyAgainstSandboxProjectError, TxnodProjectNotFoundError, TxnodProjectSuspendedError, TxnodRateLimitError, TxnodRateQuoteUnavailableError, TxnodSandboxActiveInvoiceCapReachedError, TxnodSandboxDeleteFailedError, TxnodSandboxInvoiceNotFoundError, TxnodSandboxInvoiceTerminalError, TxnodSandboxInvoiceTransitionInvalidError, TxnodSandboxKeyAgainstProductionProjectError, TxnodSandboxKeyInProductionError, TxnodSandboxPerOperatorCapReachedError, TxnodSandboxProjectRequiredError, TxnodProductionProjectRequiredError, TxnodSandboxProvisioningFailedError, TxnodSandboxRateLimitExceededError, TxnodSandboxResetFailedError, TxnodSandboxXpubInProductionError, TxnodServerError, TxnodSignatureFormatError, TxnodSignatureInvalidError, TxnodSignatureReplayedError, TxnodSubscriptionExpiredError, TxnodTimestampError, TxnodTimestampOutOfWindowError, TxnodTonCommentParseFailedError, TxnodTonConnectDomainMismatchError, TxnodTonConnectNetworkMismatchError, TxnodTonConnectPayloadExpiredError, TxnodTonConnectPayloadUnknownError, TxnodTonConnectSignatureInvalidError, TxnodTonConnectTimestampSkewError, TxnodTonConnectUnknownWalletVersionError, TxnodTonInvalidWalletVersionError, TxnodTonJettonResolveFailedError, TxnodTonOperatorWalletNotDeployedError, TxnodTronNoActivatedAddressesError, TxnodValidationError, TxnodWalletHasActiveBindingsError, TxnodWalletKindMismatchError, TxnodWalletNotBoundError, TxnodWalletNotFoundError, TxnodWalletNotOwnedError, TxnodTxNotFoundError, TxnodTxAlreadyAttributedError, TxnodWebhookCapacityExhaustedError, TxnodWebhookPayloadParseError, TxnodXpubNotVerifiedError, } from './errors.js';
27
- export { verifyWebhookSignature } from './verify-webhook-signature.js';
27
+ export { verifyWebhookSignature, } from './verify-webhook-signature.js';
28
+ export { COIN_TO_CHAIN, coinToChain, COIN_DECIMALS, toBaseUnits, fromBaseUnits, } from './coins.js';
28
29
  export { verifyAddress } from './verify/index.js';
29
30
  export { verifyTonAddress } from './verify/chains/ton.js';
30
31
  export { parseXpubConfig, parseTonConfig } from './verify/config.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,YAAqB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAgB,CAAC;AAE5C,OAAO,EACL,WAAW,GAIZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,kBAAkB,GAInB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,gCAAgC,EAChC,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,EACjC,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,uBAAuB,EACvB,4CAA4C,EAC5C,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,8BAA8B,EAC9B,wCAAwC,EACxC,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,EAChC,yCAAyC,EACzC,4CAA4C,EAC5C,gCAAgC,EAChC,sCAAsC,EACtC,gCAAgC,EAChC,mCAAmC,EACnC,mCAAmC,EACnC,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,mBAAmB,EACnB,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,mCAAmC,EACnC,kCAAkC,E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7B,0BAA0B,EAC1B,uBAAuB,EACvB,4CAA4C,EAC5C,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,8BAA8B,EAC9B,wCAAwC,EACxC,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,EAChC,yCAAyC,EACzC,4CAA4C,EAC5C,gCAAgC,EAChC,sCAAsC,EACtC,gCAAgC,EAChC,mCAAmC,EACnC,mCAAmC,EACnC,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,mBAAmB,EACnB,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,mCAAmC,EACnC,kCAAkC,EAClC,kCAAkC,EAClC,oCAAoC,EACpC,iCAAiC,EACjC,wCAAwC,EACxC,iCAAiC,EACjC,gCAAgC,EAChC,sCAAsC,EACtC,kCAAkC,EAClC,oBAAoB,EACpB,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,kCAAkC,EAClC,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,4 +1,11 @@
1
1
  import type { WebhookEvent } from './_shared/index.js';
2
+ /**
3
+ * Header bag accepted by {@link verifyWebhookSignature}. The
4
+ * `string | string[] | undefined` value shape makes this a structural
5
+ * superset of Node's `IncomingHttpHeaders` (Express/Fastify `req.headers`),
6
+ * so the verifier is drop-in there as well as with the Web `Headers` object.
7
+ */
8
+ export type WebhookHeadersInput = Headers | Record<string, string | string[] | undefined>;
2
9
  /**
3
10
  * Verifies an inbound webhook signature and returns a typed event. Parses
4
11
  * the `X-Txnod-Signature: t=<unix>,v1=<hex>` header, recomputes HMAC-SHA256
@@ -26,5 +33,5 @@ import type { WebhookEvent } from './_shared/index.js';
26
33
  * }
27
34
  * ```
28
35
  */
29
- export declare function verifyWebhookSignature(headers: Headers | Record<string, string> | Record<string, string[]>, rawBody: string, secret: string): WebhookEvent;
36
+ export declare function verifyWebhookSignature(headers: WebhookHeadersInput, rawBody: string | Buffer, secret: string): WebhookEvent;
30
37
  //# sourceMappingURL=verify-webhook-signature.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-webhook-signature.d.ts","sourceRoot":"","sources":["../src/verify-webhook-signature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8BlD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACpE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,YAAY,CAqCd"}
1
+ {"version":3,"file":"verify-webhook-signature.d.ts","sourceRoot":"","sources":["../src/verify-webhook-signature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAalD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAsBlD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,GACb,YAAY,CAwCd"}
@@ -11,6 +11,9 @@ function getHeader(headers, name) {
11
11
  for (const [key, value] of Object.entries(headers)) {
12
12
  if (key.toLowerCase() !== name)
13
13
  continue;
14
+ if (value === undefined) {
15
+ return undefined;
16
+ }
14
17
  if (Array.isArray(value)) {
15
18
  return value[0];
16
19
  }
@@ -46,6 +49,9 @@ function getHeader(headers, name) {
46
49
  * ```
47
50
  */
48
51
  export function verifyWebhookSignature(headers, rawBody, secret) {
52
+ // Node HTTP frameworks hand back the body as a Buffer; decode to the exact
53
+ // UTF-8 bytes the gateway signed so `.toString()` boilerplate is unnecessary.
54
+ const body = typeof rawBody === 'string' ? rawBody : rawBody.toString('utf8');
49
55
  const raw = getHeader(headers, SIGNATURE_HEADER);
50
56
  if (raw === undefined) {
51
57
  throw new TxnodSignatureFormatError();
@@ -66,7 +72,7 @@ export function verifyWebhookSignature(headers, rawBody, secret) {
66
72
  throw new TxnodTimestampError(skewSeconds);
67
73
  }
68
74
  const expected = createHmac('sha256', secret)
69
- .update(`${timestamp}.${rawBody}`)
75
+ .update(`${timestamp}.${body}`)
70
76
  .digest();
71
77
  // `provided` is structurally `DIGEST_BYTES` long: HEADER_PATTERN + the
72
78
  // `providedHex.length === DIGEST_BYTES * 2` check above guarantee 64 hex
@@ -75,7 +81,7 @@ export function verifyWebhookSignature(headers, rawBody, secret) {
75
81
  throw new TxnodHmacError();
76
82
  }
77
83
  try {
78
- return JSON.parse(rawBody);
84
+ return JSON.parse(body);
79
85
  }
80
86
  catch (cause) {
81
87
  throw new TxnodWebhookPayloadParseError(cause);
@@ -1 +1 @@
1
- {"version":3,"file":"verify-webhook-signature.js","sourceRoot":"","sources":["../src/verify-webhook-signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UA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A6B,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txnod/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript SDK for the txnod non-custodial crypto payment gateway — sign requests, verify webhook signatures, and verify invoice deposit-address derivation across BTC, ETH, TRON, Cardano, Polygon PoS, BNB Smart Chain, and TON. Pure Node >= 20; runs in any server-side framework (Express, Fastify, Hono, Next.js, Nuxt, SvelteKit, etc.).",
5
5
  "license": "MIT",
6
6
  "type": "module",