thunder-bridge 0.8.9 → 1.0.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/README.md +60 -62
- package/dist/index.cjs +291 -118
- package/dist/index.d.cts +63 -10
- package/dist/index.d.ts +63 -10
- package/dist/index.js +287 -118
- package/dist/{rail-J8QoYbSr.d.cts → rail-CL9QkiHo.d.cts} +30 -6
- package/dist/{rail-J8QoYbSr.d.ts → rail-CL9QkiHo.d.ts} +30 -6
- package/dist/server.cjs +35 -30
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +35 -30
- package/openapi.yaml +43 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
import { T as ThunderBridge, P as Payment, C as CreatePaymentParams,
|
|
2
|
-
export { B as BankRailConfig,
|
|
1
|
+
import { T as ThunderBridge, a as ThunderBridgeOptions, W as WatchPaymentParams, b as TriggerEvent, c as WaitOptions, P as Payment, C as CreatePaymentParams, S as Settlement, d as WalletFailure } from './rail-CL9QkiHo.cjs';
|
|
2
|
+
export { B as BankRailConfig, e as CreateOptions, f as CreateQuoteParams, F as FollowOptions, L as Leg, g as LightningRailConfig, O as Order, h as PaymentKind, i as PaymentStatus, Q as Quote, R as Rail, j as WalletReason, k as bankRail, l as lightningRail } from './rail-CL9QkiHo.cjs';
|
|
3
|
+
|
|
4
|
+
interface GatewaysOptions extends ThunderBridgeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Called for each gateway that would not take the watch, with the url and what
|
|
7
|
+
* it said. Registering at three and having one refuse still leaves you watched,
|
|
8
|
+
* so this is how you find out you are less covered than you asked to be, rather
|
|
9
|
+
* than finding out when the one that took it goes away
|
|
10
|
+
*/
|
|
11
|
+
onRefused?: (baseUrl: string, refusal: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The same payment watched at several gateways at once, which is what makes any
|
|
15
|
+
* one of them replaceable. They all answer with the same name for it, because a
|
|
16
|
+
* payment is named after the caller and not after any gateway, so the first
|
|
17
|
+
* delivery to arrive is the answer and the rest are the same news twice.
|
|
18
|
+
*
|
|
19
|
+
* For watching only. Two gateways asked to mint would fetch two different invoices
|
|
20
|
+
* from the wallet and only one of them could ever be paid
|
|
21
|
+
*/
|
|
22
|
+
declare class Gateways {
|
|
23
|
+
readonly each: readonly ThunderBridge[];
|
|
24
|
+
private readonly urls;
|
|
25
|
+
private readonly onRefused;
|
|
26
|
+
constructor(baseUrls: string[], options?: GatewaysOptions);
|
|
27
|
+
/** What this payment is called, which every gateway here will agree on */
|
|
28
|
+
nameFor(paymentHash: string): Promise<string | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Hand the same invoice to every gateway. Throws only when none of them took it,
|
|
31
|
+
* carrying the first refusal, because one gateway that agreed is enough to be
|
|
32
|
+
* watched
|
|
33
|
+
*/
|
|
34
|
+
watchPayment(params: WatchPaymentParams): Promise<TriggerEvent>;
|
|
35
|
+
/**
|
|
36
|
+
* Wait for whichever gateway speaks first. A settlement from any of them is the
|
|
37
|
+
* settlement, and each has already proved the preimage against the hash before
|
|
38
|
+
* saying so. When they all end without a payment, the first ending is the answer,
|
|
39
|
+
* and when they all fail, the first failure is thrown
|
|
40
|
+
*/
|
|
41
|
+
waitForWatched(id: string, options?: WaitOptions): Promise<TriggerEvent>;
|
|
42
|
+
}
|
|
3
43
|
|
|
4
44
|
/**
|
|
5
45
|
* Encrypt what the watcher needs and the gateway must not have. The gateway
|
|
@@ -71,8 +111,6 @@ interface BankTransferParams {
|
|
|
71
111
|
* a transfer is only ever learned by following the trigger or asking
|
|
72
112
|
*/
|
|
73
113
|
webhookUrl?: string;
|
|
74
|
-
/** Signs that delivery, so `verifyWebhookSignature` can tell it came from the gateway */
|
|
75
|
-
webhookSecret?: string;
|
|
76
114
|
/**
|
|
77
115
|
* Register on a gateway you do not own anyway. The verify URL names the amount
|
|
78
116
|
* and the reference, so its operator ends up reading your order book, and the
|
|
@@ -346,11 +384,12 @@ type WebhookOptions = {
|
|
|
346
384
|
toleranceSecs?: number;
|
|
347
385
|
};
|
|
348
386
|
/**
|
|
349
|
-
* What checks a delivery
|
|
350
|
-
*
|
|
351
|
-
*
|
|
387
|
+
* What checks a delivery: the hex the gateway publishes at `/webhook-key`. There
|
|
388
|
+
* is no shared secret to register, so a gateway holds nothing of yours. Rotating
|
|
389
|
+
* its cluster key rotates this too, so a signature that stops verifying is a
|
|
390
|
+
* reason to read the key again before it is a reason to distrust the gateway
|
|
352
391
|
*/
|
|
353
|
-
type WebhookCredential =
|
|
392
|
+
type WebhookCredential = {
|
|
354
393
|
publicKey: string;
|
|
355
394
|
};
|
|
356
395
|
/** Verify the `X-Signature` header against the raw body and the `X-Timestamp` that came with it */
|
|
@@ -370,6 +409,20 @@ declare function parseWebhookRequest(request: Request, credential: WebhookCreden
|
|
|
370
409
|
declare function parseWatchedWebhook(body: string | Uint8Array, signature: string, credential: WebhookCredential, timestamp: string, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
371
410
|
/** `parseWatchedWebhook` from a Fetch API `Request`, the way `parseWebhookRequest` is */
|
|
372
411
|
declare function parseWatchedWebhookRequest(request: Request, credential: WebhookCredential, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
412
|
+
/**
|
|
413
|
+
* Verify a delivery and read the settlement out of it. Null on a bad signature or
|
|
414
|
+
* on a body that is not a settlement, so a handler that gets null did not just
|
|
415
|
+
* miss a payment, it was handed something it had no reason to believe
|
|
416
|
+
*/
|
|
417
|
+
declare function parseSettlement(body: string | Uint8Array, signature: string, credential: WebhookCredential, timestamp: string, options?: WebhookOptions): Promise<Settlement | null>;
|
|
418
|
+
/** {@link parseSettlement} from a Fetch API `Request` */
|
|
419
|
+
declare function parseSettlementRequest(request: Request, credential: WebhookCredential, options?: WebhookOptions): Promise<Settlement | null>;
|
|
420
|
+
/**
|
|
421
|
+
* Whether a delivery proves what it claims, which is the only question that
|
|
422
|
+
* matters about one: it says paid and it carries a preimage that hashes to the
|
|
423
|
+
* payment hash the delivery itself names
|
|
424
|
+
*/
|
|
425
|
+
declare function isProvablySettled(settled: Settlement): boolean;
|
|
373
426
|
/**
|
|
374
427
|
* Answer the one challenge the gateway sends before it will watch a payment your
|
|
375
428
|
* webhook is registered on. Returns the body to send back with a 200, or null when
|
|
@@ -398,7 +451,7 @@ declare function answerVerifyChallengeRequest(request: Request): Promise<Respons
|
|
|
398
451
|
* The way a gateway was caught out, every code is a check that held against the
|
|
399
452
|
* recipient's own server and failed against what the gateway returned
|
|
400
453
|
*/
|
|
401
|
-
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch";
|
|
454
|
+
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch" | "id_not_mine";
|
|
402
455
|
/**
|
|
403
456
|
* Thrown when the gateway demonstrably misbehaved, the invoice it returned is
|
|
404
457
|
* not the one the address you asked for issued, or a settlement it reported
|
|
@@ -470,4 +523,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
470
523
|
}, wallets: WalletFailure[]);
|
|
471
524
|
}
|
|
472
525
|
|
|
473
|
-
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, type Statement, ThunderBridge, type Ticker, TriggerEvent, UnverifiedRecipientError, WalletFailure, type WebhookCredential, type WebhookOptions, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|
|
526
|
+
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, Gateways, type GatewaysOptions, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, Settlement, type Statement, ThunderBridge, ThunderBridgeOptions, type Ticker, TriggerEvent, UnverifiedRecipientError, WaitOptions, WalletFailure, WatchPaymentParams, type WebhookCredential, type WebhookOptions, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, isProvablySettled, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseSettlement, parseSettlementRequest, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
import { T as ThunderBridge, P as Payment, C as CreatePaymentParams,
|
|
2
|
-
export { B as BankRailConfig,
|
|
1
|
+
import { T as ThunderBridge, a as ThunderBridgeOptions, W as WatchPaymentParams, b as TriggerEvent, c as WaitOptions, P as Payment, C as CreatePaymentParams, S as Settlement, d as WalletFailure } from './rail-CL9QkiHo.js';
|
|
2
|
+
export { B as BankRailConfig, e as CreateOptions, f as CreateQuoteParams, F as FollowOptions, L as Leg, g as LightningRailConfig, O as Order, h as PaymentKind, i as PaymentStatus, Q as Quote, R as Rail, j as WalletReason, k as bankRail, l as lightningRail } from './rail-CL9QkiHo.js';
|
|
3
|
+
|
|
4
|
+
interface GatewaysOptions extends ThunderBridgeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Called for each gateway that would not take the watch, with the url and what
|
|
7
|
+
* it said. Registering at three and having one refuse still leaves you watched,
|
|
8
|
+
* so this is how you find out you are less covered than you asked to be, rather
|
|
9
|
+
* than finding out when the one that took it goes away
|
|
10
|
+
*/
|
|
11
|
+
onRefused?: (baseUrl: string, refusal: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The same payment watched at several gateways at once, which is what makes any
|
|
15
|
+
* one of them replaceable. They all answer with the same name for it, because a
|
|
16
|
+
* payment is named after the caller and not after any gateway, so the first
|
|
17
|
+
* delivery to arrive is the answer and the rest are the same news twice.
|
|
18
|
+
*
|
|
19
|
+
* For watching only. Two gateways asked to mint would fetch two different invoices
|
|
20
|
+
* from the wallet and only one of them could ever be paid
|
|
21
|
+
*/
|
|
22
|
+
declare class Gateways {
|
|
23
|
+
readonly each: readonly ThunderBridge[];
|
|
24
|
+
private readonly urls;
|
|
25
|
+
private readonly onRefused;
|
|
26
|
+
constructor(baseUrls: string[], options?: GatewaysOptions);
|
|
27
|
+
/** What this payment is called, which every gateway here will agree on */
|
|
28
|
+
nameFor(paymentHash: string): Promise<string | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Hand the same invoice to every gateway. Throws only when none of them took it,
|
|
31
|
+
* carrying the first refusal, because one gateway that agreed is enough to be
|
|
32
|
+
* watched
|
|
33
|
+
*/
|
|
34
|
+
watchPayment(params: WatchPaymentParams): Promise<TriggerEvent>;
|
|
35
|
+
/**
|
|
36
|
+
* Wait for whichever gateway speaks first. A settlement from any of them is the
|
|
37
|
+
* settlement, and each has already proved the preimage against the hash before
|
|
38
|
+
* saying so. When they all end without a payment, the first ending is the answer,
|
|
39
|
+
* and when they all fail, the first failure is thrown
|
|
40
|
+
*/
|
|
41
|
+
waitForWatched(id: string, options?: WaitOptions): Promise<TriggerEvent>;
|
|
42
|
+
}
|
|
3
43
|
|
|
4
44
|
/**
|
|
5
45
|
* Encrypt what the watcher needs and the gateway must not have. The gateway
|
|
@@ -71,8 +111,6 @@ interface BankTransferParams {
|
|
|
71
111
|
* a transfer is only ever learned by following the trigger or asking
|
|
72
112
|
*/
|
|
73
113
|
webhookUrl?: string;
|
|
74
|
-
/** Signs that delivery, so `verifyWebhookSignature` can tell it came from the gateway */
|
|
75
|
-
webhookSecret?: string;
|
|
76
114
|
/**
|
|
77
115
|
* Register on a gateway you do not own anyway. The verify URL names the amount
|
|
78
116
|
* and the reference, so its operator ends up reading your order book, and the
|
|
@@ -346,11 +384,12 @@ type WebhookOptions = {
|
|
|
346
384
|
toleranceSecs?: number;
|
|
347
385
|
};
|
|
348
386
|
/**
|
|
349
|
-
* What checks a delivery
|
|
350
|
-
*
|
|
351
|
-
*
|
|
387
|
+
* What checks a delivery: the hex the gateway publishes at `/webhook-key`. There
|
|
388
|
+
* is no shared secret to register, so a gateway holds nothing of yours. Rotating
|
|
389
|
+
* its cluster key rotates this too, so a signature that stops verifying is a
|
|
390
|
+
* reason to read the key again before it is a reason to distrust the gateway
|
|
352
391
|
*/
|
|
353
|
-
type WebhookCredential =
|
|
392
|
+
type WebhookCredential = {
|
|
354
393
|
publicKey: string;
|
|
355
394
|
};
|
|
356
395
|
/** Verify the `X-Signature` header against the raw body and the `X-Timestamp` that came with it */
|
|
@@ -370,6 +409,20 @@ declare function parseWebhookRequest(request: Request, credential: WebhookCreden
|
|
|
370
409
|
declare function parseWatchedWebhook(body: string | Uint8Array, signature: string, credential: WebhookCredential, timestamp: string, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
371
410
|
/** `parseWatchedWebhook` from a Fetch API `Request`, the way `parseWebhookRequest` is */
|
|
372
411
|
declare function parseWatchedWebhookRequest(request: Request, credential: WebhookCredential, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
412
|
+
/**
|
|
413
|
+
* Verify a delivery and read the settlement out of it. Null on a bad signature or
|
|
414
|
+
* on a body that is not a settlement, so a handler that gets null did not just
|
|
415
|
+
* miss a payment, it was handed something it had no reason to believe
|
|
416
|
+
*/
|
|
417
|
+
declare function parseSettlement(body: string | Uint8Array, signature: string, credential: WebhookCredential, timestamp: string, options?: WebhookOptions): Promise<Settlement | null>;
|
|
418
|
+
/** {@link parseSettlement} from a Fetch API `Request` */
|
|
419
|
+
declare function parseSettlementRequest(request: Request, credential: WebhookCredential, options?: WebhookOptions): Promise<Settlement | null>;
|
|
420
|
+
/**
|
|
421
|
+
* Whether a delivery proves what it claims, which is the only question that
|
|
422
|
+
* matters about one: it says paid and it carries a preimage that hashes to the
|
|
423
|
+
* payment hash the delivery itself names
|
|
424
|
+
*/
|
|
425
|
+
declare function isProvablySettled(settled: Settlement): boolean;
|
|
373
426
|
/**
|
|
374
427
|
* Answer the one challenge the gateway sends before it will watch a payment your
|
|
375
428
|
* webhook is registered on. Returns the body to send back with a 200, or null when
|
|
@@ -398,7 +451,7 @@ declare function answerVerifyChallengeRequest(request: Request): Promise<Respons
|
|
|
398
451
|
* The way a gateway was caught out, every code is a check that held against the
|
|
399
452
|
* recipient's own server and failed against what the gateway returned
|
|
400
453
|
*/
|
|
401
|
-
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch";
|
|
454
|
+
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch" | "id_not_mine";
|
|
402
455
|
/**
|
|
403
456
|
* Thrown when the gateway demonstrably misbehaved, the invoice it returned is
|
|
404
457
|
* not the one the address you asked for issued, or a settlement it reported
|
|
@@ -470,4 +523,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
470
523
|
}, wallets: WalletFailure[]);
|
|
471
524
|
}
|
|
472
525
|
|
|
473
|
-
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, type Statement, ThunderBridge, type Ticker, TriggerEvent, UnverifiedRecipientError, WalletFailure, type WebhookCredential, type WebhookOptions, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|
|
526
|
+
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, Gateways, type GatewaysOptions, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, Settlement, type Statement, ThunderBridge, ThunderBridgeOptions, type Ticker, TriggerEvent, UnverifiedRecipientError, WaitOptions, WalletFailure, WatchPaymentParams, type WebhookCredential, type WebhookOptions, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, isProvablySettled, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseSettlement, parseSettlementRequest, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|