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 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-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';
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, toLnurl, unseal, verifyWebhookSignature };
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-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';
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, toLnurl, unseal, verifyWebhookSignature };
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, blindLightningRail as n };
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, blindLightningRail as n };
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-CL9QkiHo.cjs';
2
- export { m as BlindLightningRailConfig, n as blindLightningRail } from './rail-CL9QkiHo.cjs';
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-CL9QkiHo.js';
2
- export { m as BlindLightningRailConfig, n as blindLightningRail } from './rail-CL9QkiHo.js';
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
@@ -910,6 +910,7 @@ async function invoiceFrom(lnAddresses, amountMsat) {
910
910
  }
911
911
  export {
912
912
  blindLightningRail,
913
+ invoiceFrom,
913
914
  lightningVerifyEndpoint,
914
915
  lnurlPayEndpoint,
915
916
  relayedVerifyUrl
package/openapi.yaml CHANGED
@@ -2,7 +2,7 @@ openapi: 3.1.0
2
2
 
3
3
  info:
4
4
  title: thunder-bridge, the endpoint your own service serves
5
- version: 1.0.0
5
+ version: 1.1.0
6
6
  license:
7
7
  name: MIT
8
8
  identifier: MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thunder-bridge",
3
- "version": "1.0.0",
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",