thunder-bridge 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.d.cts +3 -10
- package/dist/index.d.ts +3 -10
- package/dist/{rail-CL9QkiHo.d.cts → rail-Dp8bs6uZ.d.cts} +25 -1
- package/dist/{rail-CL9QkiHo.d.ts → rail-Dp8bs6uZ.d.ts} +25 -1
- package/dist/server.cjs +2 -0
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -0
- package/openapi.yaml +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,6 +169,12 @@ const toPay = invoiceToSvg(payment.bolt11, { size: 320, color: "#1a1a2e" });
|
|
|
169
169
|
const tipJar = lnurlToSvg("https://agora.gripe/tip");
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
**Minting your own invoice** - [`src/rail.ts`](src/rail.ts): `invoiceFrom`, from
|
|
173
|
+
`thunder-bridge/server`. A gateway that does not mint is one that never sees an
|
|
174
|
+
address or an amount, so this is how a client gets a provable invoice itself and hands
|
|
175
|
+
the gateway only a hash, a url and an expiry. Server side, because it resolves
|
|
176
|
+
hostnames and refuses a private one.
|
|
177
|
+
|
|
172
178
|
**Webhooks** - [`src/webhook.ts`](src/webhook.ts): `parseSettlementRequest`,
|
|
173
179
|
`parseSettlement`, `isProvablySettled`, `parseWebhookRequest`, `parseWebhook`,
|
|
174
180
|
`parseWatchedWebhookRequest`, `parseWatchedWebhook`, `verifyWebhookSignature`,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-Dp8bs6uZ.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, t as toLnurl } from './rail-Dp8bs6uZ.cjs';
|
|
3
3
|
|
|
4
4
|
interface GatewaysOptions extends ThunderBridgeOptions {
|
|
5
5
|
/**
|
|
@@ -372,13 +372,6 @@ declare function qrToSvg(payload: string, options?: QrOptions): string;
|
|
|
372
372
|
/** SVG data URL of a leg's QR, for an `<img>` `src` */
|
|
373
373
|
declare function qrToDataUrl(payload: string, options?: QrOptions): string;
|
|
374
374
|
|
|
375
|
-
/**
|
|
376
|
-
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
377
|
-
* because that is the form it asks a QR to carry. An onion endpoint is http
|
|
378
|
-
* rather than https, which LUD-17 spells out, so both are taken here
|
|
379
|
-
*/
|
|
380
|
-
declare function toLnurl(endpoint: string): string;
|
|
381
|
-
|
|
382
375
|
/** How far the gateway's clock may drift from yours before a webhook is refused */
|
|
383
376
|
type WebhookOptions = {
|
|
384
377
|
toleranceSecs?: number;
|
|
@@ -523,4 +516,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
523
516
|
}, wallets: WalletFailure[]);
|
|
524
517
|
}
|
|
525
518
|
|
|
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,
|
|
519
|
+
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, unseal, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-Dp8bs6uZ.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, t as toLnurl } from './rail-Dp8bs6uZ.js';
|
|
3
3
|
|
|
4
4
|
interface GatewaysOptions extends ThunderBridgeOptions {
|
|
5
5
|
/**
|
|
@@ -372,13 +372,6 @@ declare function qrToSvg(payload: string, options?: QrOptions): string;
|
|
|
372
372
|
/** SVG data URL of a leg's QR, for an `<img>` `src` */
|
|
373
373
|
declare function qrToDataUrl(payload: string, options?: QrOptions): string;
|
|
374
374
|
|
|
375
|
-
/**
|
|
376
|
-
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
377
|
-
* because that is the form it asks a QR to carry. An onion endpoint is http
|
|
378
|
-
* rather than https, which LUD-17 spells out, so both are taken here
|
|
379
|
-
*/
|
|
380
|
-
declare function toLnurl(endpoint: string): string;
|
|
381
|
-
|
|
382
375
|
/** How far the gateway's clock may drift from yours before a webhook is refused */
|
|
383
376
|
type WebhookOptions = {
|
|
384
377
|
toleranceSecs?: number;
|
|
@@ -523,4 +516,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
523
516
|
}, wallets: WalletFailure[]);
|
|
524
517
|
}
|
|
525
518
|
|
|
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,
|
|
519
|
+
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, unseal, verifyWebhookSignature };
|
|
@@ -303,6 +303,20 @@ declare class ThunderBridge {
|
|
|
303
303
|
private checked;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
type Resolved = {
|
|
307
|
+
address: string;
|
|
308
|
+
bolt11: string;
|
|
309
|
+
verifyUrl: string;
|
|
310
|
+
paymentHash: string;
|
|
311
|
+
expiresAt: number;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
315
|
+
* because that is the form it asks a QR to carry. An onion endpoint is http
|
|
316
|
+
* rather than https, which LUD-17 spells out, so both are taken here
|
|
317
|
+
*/
|
|
318
|
+
declare function toLnurl(endpoint: string): string;
|
|
319
|
+
|
|
306
320
|
/** What a shop knows about a sale before any rail exists */
|
|
307
321
|
interface Order {
|
|
308
322
|
/** The bank matches it on the statement, and Lightning keys idempotency on it */
|
|
@@ -420,5 +434,15 @@ declare function lightningRail(config: LightningRailConfig): Rail;
|
|
|
420
434
|
* refusing everyone.
|
|
421
435
|
*/
|
|
422
436
|
declare function blindLightningRail(config: BlindLightningRailConfig): Rail;
|
|
437
|
+
/**
|
|
438
|
+
* A provable invoice from the first address on the list that will issue one, which
|
|
439
|
+
* is what a client mints for itself rather than asking a gateway to. Everything the
|
|
440
|
+
* gateway needs to watch it comes back with everything you need to prove it came
|
|
441
|
+
* from the address you asked for, so you can hand over the first and keep the second.
|
|
442
|
+
*
|
|
443
|
+
* Server side: it resolves hostnames and refuses a private one, which no browser can
|
|
444
|
+
* do. Throws `NoWalletAvailableError` when no address on the list would serve
|
|
445
|
+
*/
|
|
446
|
+
declare function invoiceFrom(lnAddresses: string[], amountMsat: number): Promise<Resolved>;
|
|
423
447
|
|
|
424
|
-
export { type BankRailConfig as B, type CreatePaymentParams as C, type FollowOptions as F, type Leg as L, type Order as O, type Payment as P, type Quote as Q, type Rail as R, type Settlement as S, ThunderBridge as T, type WatchPaymentParams as W, type ThunderBridgeOptions as a, type TriggerEvent as b, type WaitOptions as c, type WalletFailure as d, type CreateOptions as e, type CreateQuoteParams as f, type LightningRailConfig as g, type PaymentKind as h, type PaymentStatus as i, type WalletReason as j, bankRail as k, lightningRail as l, type BlindLightningRailConfig as m,
|
|
448
|
+
export { type BankRailConfig as B, type CreatePaymentParams as C, type FollowOptions as F, type Leg as L, type Order as O, type Payment as P, type Quote as Q, type Rail as R, type Settlement as S, ThunderBridge as T, type WatchPaymentParams as W, type ThunderBridgeOptions as a, type TriggerEvent as b, type WaitOptions as c, type WalletFailure as d, type CreateOptions as e, type CreateQuoteParams as f, type LightningRailConfig as g, type PaymentKind as h, type PaymentStatus as i, type WalletReason as j, bankRail as k, lightningRail as l, type BlindLightningRailConfig as m, type Resolved as n, blindLightningRail as o, invoiceFrom as p, toLnurl as t };
|
|
@@ -303,6 +303,20 @@ declare class ThunderBridge {
|
|
|
303
303
|
private checked;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
type Resolved = {
|
|
307
|
+
address: string;
|
|
308
|
+
bolt11: string;
|
|
309
|
+
verifyUrl: string;
|
|
310
|
+
paymentHash: string;
|
|
311
|
+
expiresAt: number;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
315
|
+
* because that is the form it asks a QR to carry. An onion endpoint is http
|
|
316
|
+
* rather than https, which LUD-17 spells out, so both are taken here
|
|
317
|
+
*/
|
|
318
|
+
declare function toLnurl(endpoint: string): string;
|
|
319
|
+
|
|
306
320
|
/** What a shop knows about a sale before any rail exists */
|
|
307
321
|
interface Order {
|
|
308
322
|
/** The bank matches it on the statement, and Lightning keys idempotency on it */
|
|
@@ -420,5 +434,15 @@ declare function lightningRail(config: LightningRailConfig): Rail;
|
|
|
420
434
|
* refusing everyone.
|
|
421
435
|
*/
|
|
422
436
|
declare function blindLightningRail(config: BlindLightningRailConfig): Rail;
|
|
437
|
+
/**
|
|
438
|
+
* A provable invoice from the first address on the list that will issue one, which
|
|
439
|
+
* is what a client mints for itself rather than asking a gateway to. Everything the
|
|
440
|
+
* gateway needs to watch it comes back with everything you need to prove it came
|
|
441
|
+
* from the address you asked for, so you can hand over the first and keep the second.
|
|
442
|
+
*
|
|
443
|
+
* Server side: it resolves hostnames and refuses a private one, which no browser can
|
|
444
|
+
* do. Throws `NoWalletAvailableError` when no address on the list would serve
|
|
445
|
+
*/
|
|
446
|
+
declare function invoiceFrom(lnAddresses: string[], amountMsat: number): Promise<Resolved>;
|
|
423
447
|
|
|
424
|
-
export { type BankRailConfig as B, type CreatePaymentParams as C, type FollowOptions as F, type Leg as L, type Order as O, type Payment as P, type Quote as Q, type Rail as R, type Settlement as S, ThunderBridge as T, type WatchPaymentParams as W, type ThunderBridgeOptions as a, type TriggerEvent as b, type WaitOptions as c, type WalletFailure as d, type CreateOptions as e, type CreateQuoteParams as f, type LightningRailConfig as g, type PaymentKind as h, type PaymentStatus as i, type WalletReason as j, bankRail as k, lightningRail as l, type BlindLightningRailConfig as m,
|
|
448
|
+
export { type BankRailConfig as B, type CreatePaymentParams as C, type FollowOptions as F, type Leg as L, type Order as O, type Payment as P, type Quote as Q, type Rail as R, type Settlement as S, ThunderBridge as T, type WatchPaymentParams as W, type ThunderBridgeOptions as a, type TriggerEvent as b, type WaitOptions as c, type WalletFailure as d, type CreateOptions as e, type CreateQuoteParams as f, type LightningRailConfig as g, type PaymentKind as h, type PaymentStatus as i, type WalletReason as j, bankRail as k, lightningRail as l, type BlindLightningRailConfig as m, type Resolved as n, blindLightningRail as o, invoiceFrom as p, toLnurl as t };
|
package/dist/server.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var server_exports = {};
|
|
32
32
|
__export(server_exports, {
|
|
33
33
|
blindLightningRail: () => blindLightningRail,
|
|
34
|
+
invoiceFrom: () => invoiceFrom,
|
|
34
35
|
lightningVerifyEndpoint: () => lightningVerifyEndpoint,
|
|
35
36
|
lnurlPayEndpoint: () => lnurlPayEndpoint,
|
|
36
37
|
relayedVerifyUrl: () => relayedVerifyUrl
|
|
@@ -950,6 +951,7 @@ async function invoiceFrom(lnAddresses, amountMsat) {
|
|
|
950
951
|
// Annotate the CommonJS export names for ESM import in node:
|
|
951
952
|
0 && (module.exports = {
|
|
952
953
|
blindLightningRail,
|
|
954
|
+
invoiceFrom,
|
|
953
955
|
lightningVerifyEndpoint,
|
|
954
956
|
lnurlPayEndpoint,
|
|
955
957
|
relayedVerifyUrl
|
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ThunderBridge } from './rail-
|
|
2
|
-
export { m as BlindLightningRailConfig, n as blindLightningRail } from './rail-
|
|
1
|
+
import { T as ThunderBridge } from './rail-Dp8bs6uZ.cjs';
|
|
2
|
+
export { m as BlindLightningRailConfig, n as Resolved, o as blindLightningRail, p as invoiceFrom } from './rail-Dp8bs6uZ.cjs';
|
|
3
3
|
|
|
4
4
|
interface TriggerConfig {
|
|
5
5
|
/** The gateway that quotes the addresses and mints the invoice */
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ThunderBridge } from './rail-
|
|
2
|
-
export { m as BlindLightningRailConfig, n as blindLightningRail } from './rail-
|
|
1
|
+
import { T as ThunderBridge } from './rail-Dp8bs6uZ.js';
|
|
2
|
+
export { m as BlindLightningRailConfig, n as Resolved, o as blindLightningRail, p as invoiceFrom } from './rail-Dp8bs6uZ.js';
|
|
3
3
|
|
|
4
4
|
interface TriggerConfig {
|
|
5
5
|
/** The gateway that quotes the addresses and mints the invoice */
|
package/dist/server.js
CHANGED
package/openapi.yaml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thunder-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Trustless JavaScript client for the Thunder Bridge Lightning payment gateway. Proves the invoice came from your own wallet before the payer sees it.",
|
|
5
5
|
"author": "i-am-fatik",
|
|
6
6
|
"homepage": "https://agora.gripe/en/tools/thunder-bridge",
|