thunder-bridge 1.1.0 → 1.4.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 +115 -6
- package/dist/index.cjs +1677 -1301
- package/dist/index.d.cts +217 -166
- package/dist/index.d.ts +217 -166
- package/dist/index.js +1673 -1300
- package/dist/{rail-Dp8bs6uZ.d.cts → rail-CqUfuYXJ.d.cts} +176 -9
- package/dist/{rail-Dp8bs6uZ.d.ts → rail-CqUfuYXJ.d.ts} +176 -9
- package/dist/server.cjs +1003 -381
- package/dist/server.d.cts +79 -37
- package/dist/server.d.ts +79 -37
- package/dist/server.js +991 -380
- package/openapi.yaml +1 -1
- package/package.json +33 -13
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
|
-
import { T as ThunderBridge } from './rail-
|
|
2
|
-
export {
|
|
1
|
+
import { T as ThunderBridge } from './rail-CqUfuYXJ.cjs';
|
|
2
|
+
export { o as BlindLightningRailConfig, N as NwcConnection, p as NwcInvoice, q as NwcRailConfig, r as NwcVerifyConfig, s as Resolved, u as askWallet, v as blindLightningRail, w as invoiceFrom, x as nwcConnection, y as nwcHoldInvoice, z as nwcInvoice, A as nwcPay, D as nwcRail, E as nwcSettlement, G as nwcVerifyEndpoint, H as nwcVerifyUrl } from './rail-CqUfuYXJ.cjs';
|
|
3
|
+
|
|
4
|
+
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
5
|
+
interface Relayed {
|
|
6
|
+
url: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
}
|
|
9
|
+
interface LightningVerifyConfig {
|
|
10
|
+
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
11
|
+
secret: string;
|
|
12
|
+
/**
|
|
13
|
+
* How often you want the gateway to ask, in seconds. It goes out as
|
|
14
|
+
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
15
|
+
* Five by default, which is what a Lightning checkout wants
|
|
16
|
+
*/
|
|
17
|
+
pollEverySecs?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A verify endpoint of your own that asks the recipient's wallet for you, so the
|
|
21
|
+
* gateway polls you and never the wallet.
|
|
22
|
+
*
|
|
23
|
+
* `relayedVerifyUrl` seals the wallet's own LUD-21 URL into the query with your
|
|
24
|
+
* secret, so what the gateway stores and replicates is opaque: not the wallet's
|
|
25
|
+
* host, not which provider the recipient uses, nothing but a blob it cannot read.
|
|
26
|
+
* This handler unseals it, asks the wallet, and answers the same LUD-21 shape.
|
|
27
|
+
*
|
|
28
|
+
* It relays rather than decides. The preimage still comes from the recipient's
|
|
29
|
+
* own server and still has to hash to the payment hash, so standing between the
|
|
30
|
+
* two buys privacy and pacing without becoming something anyone has to trust.
|
|
31
|
+
*
|
|
32
|
+
* A wallet it cannot reach answers `502` rather than "not settled", because those
|
|
33
|
+
* are different claims and only one of them is true. The gateway logs a failed
|
|
34
|
+
* poll and asks again, which is what a broken relay should look like.
|
|
35
|
+
*/
|
|
36
|
+
declare function lightningVerifyEndpoint(config: LightningVerifyConfig): (request: Request) => Promise<Response>;
|
|
37
|
+
/**
|
|
38
|
+
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
39
|
+
* sealed inside it. Point it at wherever `lightningVerifyEndpoint` is mounted
|
|
40
|
+
*/
|
|
41
|
+
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
3
42
|
|
|
4
43
|
interface TriggerConfig {
|
|
5
44
|
/** The gateway that quotes the addresses and mints the invoice */
|
|
@@ -18,6 +57,12 @@ interface TriggerConfig {
|
|
|
18
57
|
secret: string;
|
|
19
58
|
/** Groups every payment here so `followTrigger` can watch the place, keep it off the QR */
|
|
20
59
|
watchSecret?: string;
|
|
60
|
+
/**
|
|
61
|
+
* How many settlements of this place the gateway keeps replayable past the hour
|
|
62
|
+
* it would otherwise forget them in, up to the ceiling its operator set. What a
|
|
63
|
+
* page that opens later still gets to see. Needs `watchSecret`
|
|
64
|
+
*/
|
|
65
|
+
replay?: number;
|
|
21
66
|
/** Override when a proxy hides the public URL from the request, no trailing slash */
|
|
22
67
|
baseUrl?: string;
|
|
23
68
|
/**
|
|
@@ -47,6 +92,23 @@ interface Minted {
|
|
|
47
92
|
verifyUrl: string;
|
|
48
93
|
expiresAt: number;
|
|
49
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* A trigger's live stream is opened with a ticket rather than with the watch
|
|
97
|
+
* secret, so something has to hold the secret and trade it for tickets. That is
|
|
98
|
+
* what these two endpoints are, and they are the only place the gateway's token
|
|
99
|
+
* has to be
|
|
100
|
+
*/
|
|
101
|
+
interface WatchTicketConfig {
|
|
102
|
+
/** The gateway that mints the ticket, holding the token this keeps off the wire */
|
|
103
|
+
gateway: ThunderBridge;
|
|
104
|
+
/** The trigger to open, the same secret `lnurlPayEndpoint` groups its payments under */
|
|
105
|
+
watchSecret: string;
|
|
106
|
+
/**
|
|
107
|
+
* How many of this trigger's settlements the socket replays on connect, so a
|
|
108
|
+
* page opened late still shows what it missed, up to the gateway's ceiling
|
|
109
|
+
*/
|
|
110
|
+
replay?: number;
|
|
111
|
+
}
|
|
50
112
|
/**
|
|
51
113
|
* An LNURL-pay endpoint standing in front of a priority list of addresses, as a
|
|
52
114
|
* Fetch handler so it runs on Deno Deploy, Workers, Hono, Next and Node alike.
|
|
@@ -60,44 +122,24 @@ interface Minted {
|
|
|
60
122
|
* Nothing is stored between the two, so this holds no state of its own.
|
|
61
123
|
*/
|
|
62
124
|
declare function lnurlPayEndpoint(config: TriggerConfig): (request: Request) => Promise<Response>;
|
|
63
|
-
|
|
64
|
-
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
65
|
-
interface Relayed {
|
|
66
|
-
url: string;
|
|
67
|
-
hash: string;
|
|
68
|
-
}
|
|
69
|
-
interface LightningVerifyConfig {
|
|
70
|
-
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
71
|
-
secret: string;
|
|
72
|
-
/**
|
|
73
|
-
* How often you want the gateway to ask, in seconds. It goes out as
|
|
74
|
-
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
75
|
-
* Five by default, which is what a Lightning checkout wants
|
|
76
|
-
*/
|
|
77
|
-
pollEverySecs?: number;
|
|
78
|
-
}
|
|
79
125
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* secret, so what the gateway stores and replicates is opaque: not the wallet's
|
|
85
|
-
* host, not which provider the recipient uses, nothing but a blob it cannot read.
|
|
86
|
-
* This handler unseals it, asks the wallet, and answers the same LUD-21 shape.
|
|
87
|
-
*
|
|
88
|
-
* It relays rather than decides. The preimage still comes from the recipient's
|
|
89
|
-
* own server and still has to hash to the payment hash, so standing between the
|
|
90
|
-
* two buys privacy and pacing without becoming something anyone has to trust.
|
|
126
|
+
* Trades the watch secret for a socket ticket, for a board that is not public.
|
|
127
|
+
* The caller has to know the secret already, so all this adds is that the secret
|
|
128
|
+
* stops travelling in socket URLs, where the gateway, every proxy in front of it
|
|
129
|
+
* and the browser's own history all keep a copy. Anyone without it gets a 403.
|
|
91
130
|
*
|
|
92
|
-
*
|
|
93
|
-
* are different claims and only one of them is true. The gateway logs a failed
|
|
94
|
-
* poll and asks again, which is what a broken relay should look like.
|
|
131
|
+
* POST to it before every connect, because a ticket lives one minute.
|
|
95
132
|
*/
|
|
96
|
-
declare function
|
|
133
|
+
declare function watchTicketEndpoint(config: WatchTicketConfig): (request: Request) => Promise<Response>;
|
|
97
134
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
135
|
+
* Mints a socket ticket for anybody who asks, for a board meant to be read by
|
|
136
|
+
* strangers. It reads no body and refuses nobody, which makes the trigger's
|
|
137
|
+
* whole stream public: every viewer gets each settlement's preimage, verify url
|
|
138
|
+
* and payment hash.
|
|
139
|
+
*
|
|
140
|
+
* Only for a trigger where that is the point. Gate anything on those preimages
|
|
141
|
+
* and a viewer of the board is holding the unlock.
|
|
100
142
|
*/
|
|
101
|
-
declare function
|
|
143
|
+
declare function publicWatchTicketEndpoint(config: WatchTicketConfig): (request: Request) => Promise<Response>;
|
|
102
144
|
|
|
103
|
-
export { type LightningVerifyConfig, type Minted, type Relayed, type TriggerConfig, lightningVerifyEndpoint, lnurlPayEndpoint, relayedVerifyUrl };
|
|
145
|
+
export { type LightningVerifyConfig, type Minted, type Relayed, type TriggerConfig, type WatchTicketConfig, lightningVerifyEndpoint, lnurlPayEndpoint, publicWatchTicketEndpoint, relayedVerifyUrl, watchTicketEndpoint };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
|
-
import { T as ThunderBridge } from './rail-
|
|
2
|
-
export {
|
|
1
|
+
import { T as ThunderBridge } from './rail-CqUfuYXJ.js';
|
|
2
|
+
export { o as BlindLightningRailConfig, N as NwcConnection, p as NwcInvoice, q as NwcRailConfig, r as NwcVerifyConfig, s as Resolved, u as askWallet, v as blindLightningRail, w as invoiceFrom, x as nwcConnection, y as nwcHoldInvoice, z as nwcInvoice, A as nwcPay, D as nwcRail, E as nwcSettlement, G as nwcVerifyEndpoint, H as nwcVerifyUrl } from './rail-CqUfuYXJ.js';
|
|
3
|
+
|
|
4
|
+
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
5
|
+
interface Relayed {
|
|
6
|
+
url: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
}
|
|
9
|
+
interface LightningVerifyConfig {
|
|
10
|
+
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
11
|
+
secret: string;
|
|
12
|
+
/**
|
|
13
|
+
* How often you want the gateway to ask, in seconds. It goes out as
|
|
14
|
+
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
15
|
+
* Five by default, which is what a Lightning checkout wants
|
|
16
|
+
*/
|
|
17
|
+
pollEverySecs?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A verify endpoint of your own that asks the recipient's wallet for you, so the
|
|
21
|
+
* gateway polls you and never the wallet.
|
|
22
|
+
*
|
|
23
|
+
* `relayedVerifyUrl` seals the wallet's own LUD-21 URL into the query with your
|
|
24
|
+
* secret, so what the gateway stores and replicates is opaque: not the wallet's
|
|
25
|
+
* host, not which provider the recipient uses, nothing but a blob it cannot read.
|
|
26
|
+
* This handler unseals it, asks the wallet, and answers the same LUD-21 shape.
|
|
27
|
+
*
|
|
28
|
+
* It relays rather than decides. The preimage still comes from the recipient's
|
|
29
|
+
* own server and still has to hash to the payment hash, so standing between the
|
|
30
|
+
* two buys privacy and pacing without becoming something anyone has to trust.
|
|
31
|
+
*
|
|
32
|
+
* A wallet it cannot reach answers `502` rather than "not settled", because those
|
|
33
|
+
* are different claims and only one of them is true. The gateway logs a failed
|
|
34
|
+
* poll and asks again, which is what a broken relay should look like.
|
|
35
|
+
*/
|
|
36
|
+
declare function lightningVerifyEndpoint(config: LightningVerifyConfig): (request: Request) => Promise<Response>;
|
|
37
|
+
/**
|
|
38
|
+
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
39
|
+
* sealed inside it. Point it at wherever `lightningVerifyEndpoint` is mounted
|
|
40
|
+
*/
|
|
41
|
+
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
3
42
|
|
|
4
43
|
interface TriggerConfig {
|
|
5
44
|
/** The gateway that quotes the addresses and mints the invoice */
|
|
@@ -18,6 +57,12 @@ interface TriggerConfig {
|
|
|
18
57
|
secret: string;
|
|
19
58
|
/** Groups every payment here so `followTrigger` can watch the place, keep it off the QR */
|
|
20
59
|
watchSecret?: string;
|
|
60
|
+
/**
|
|
61
|
+
* How many settlements of this place the gateway keeps replayable past the hour
|
|
62
|
+
* it would otherwise forget them in, up to the ceiling its operator set. What a
|
|
63
|
+
* page that opens later still gets to see. Needs `watchSecret`
|
|
64
|
+
*/
|
|
65
|
+
replay?: number;
|
|
21
66
|
/** Override when a proxy hides the public URL from the request, no trailing slash */
|
|
22
67
|
baseUrl?: string;
|
|
23
68
|
/**
|
|
@@ -47,6 +92,23 @@ interface Minted {
|
|
|
47
92
|
verifyUrl: string;
|
|
48
93
|
expiresAt: number;
|
|
49
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* A trigger's live stream is opened with a ticket rather than with the watch
|
|
97
|
+
* secret, so something has to hold the secret and trade it for tickets. That is
|
|
98
|
+
* what these two endpoints are, and they are the only place the gateway's token
|
|
99
|
+
* has to be
|
|
100
|
+
*/
|
|
101
|
+
interface WatchTicketConfig {
|
|
102
|
+
/** The gateway that mints the ticket, holding the token this keeps off the wire */
|
|
103
|
+
gateway: ThunderBridge;
|
|
104
|
+
/** The trigger to open, the same secret `lnurlPayEndpoint` groups its payments under */
|
|
105
|
+
watchSecret: string;
|
|
106
|
+
/**
|
|
107
|
+
* How many of this trigger's settlements the socket replays on connect, so a
|
|
108
|
+
* page opened late still shows what it missed, up to the gateway's ceiling
|
|
109
|
+
*/
|
|
110
|
+
replay?: number;
|
|
111
|
+
}
|
|
50
112
|
/**
|
|
51
113
|
* An LNURL-pay endpoint standing in front of a priority list of addresses, as a
|
|
52
114
|
* Fetch handler so it runs on Deno Deploy, Workers, Hono, Next and Node alike.
|
|
@@ -60,44 +122,24 @@ interface Minted {
|
|
|
60
122
|
* Nothing is stored between the two, so this holds no state of its own.
|
|
61
123
|
*/
|
|
62
124
|
declare function lnurlPayEndpoint(config: TriggerConfig): (request: Request) => Promise<Response>;
|
|
63
|
-
|
|
64
|
-
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
65
|
-
interface Relayed {
|
|
66
|
-
url: string;
|
|
67
|
-
hash: string;
|
|
68
|
-
}
|
|
69
|
-
interface LightningVerifyConfig {
|
|
70
|
-
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
71
|
-
secret: string;
|
|
72
|
-
/**
|
|
73
|
-
* How often you want the gateway to ask, in seconds. It goes out as
|
|
74
|
-
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
75
|
-
* Five by default, which is what a Lightning checkout wants
|
|
76
|
-
*/
|
|
77
|
-
pollEverySecs?: number;
|
|
78
|
-
}
|
|
79
125
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* secret, so what the gateway stores and replicates is opaque: not the wallet's
|
|
85
|
-
* host, not which provider the recipient uses, nothing but a blob it cannot read.
|
|
86
|
-
* This handler unseals it, asks the wallet, and answers the same LUD-21 shape.
|
|
87
|
-
*
|
|
88
|
-
* It relays rather than decides. The preimage still comes from the recipient's
|
|
89
|
-
* own server and still has to hash to the payment hash, so standing between the
|
|
90
|
-
* two buys privacy and pacing without becoming something anyone has to trust.
|
|
126
|
+
* Trades the watch secret for a socket ticket, for a board that is not public.
|
|
127
|
+
* The caller has to know the secret already, so all this adds is that the secret
|
|
128
|
+
* stops travelling in socket URLs, where the gateway, every proxy in front of it
|
|
129
|
+
* and the browser's own history all keep a copy. Anyone without it gets a 403.
|
|
91
130
|
*
|
|
92
|
-
*
|
|
93
|
-
* are different claims and only one of them is true. The gateway logs a failed
|
|
94
|
-
* poll and asks again, which is what a broken relay should look like.
|
|
131
|
+
* POST to it before every connect, because a ticket lives one minute.
|
|
95
132
|
*/
|
|
96
|
-
declare function
|
|
133
|
+
declare function watchTicketEndpoint(config: WatchTicketConfig): (request: Request) => Promise<Response>;
|
|
97
134
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
135
|
+
* Mints a socket ticket for anybody who asks, for a board meant to be read by
|
|
136
|
+
* strangers. It reads no body and refuses nobody, which makes the trigger's
|
|
137
|
+
* whole stream public: every viewer gets each settlement's preimage, verify url
|
|
138
|
+
* and payment hash.
|
|
139
|
+
*
|
|
140
|
+
* Only for a trigger where that is the point. Gate anything on those preimages
|
|
141
|
+
* and a viewer of the board is holding the unlock.
|
|
100
142
|
*/
|
|
101
|
-
declare function
|
|
143
|
+
declare function publicWatchTicketEndpoint(config: WatchTicketConfig): (request: Request) => Promise<Response>;
|
|
102
144
|
|
|
103
|
-
export { type LightningVerifyConfig, type Minted, type Relayed, type TriggerConfig, lightningVerifyEndpoint, lnurlPayEndpoint, relayedVerifyUrl };
|
|
145
|
+
export { type LightningVerifyConfig, type Minted, type Relayed, type TriggerConfig, type WatchTicketConfig, lightningVerifyEndpoint, lnurlPayEndpoint, publicWatchTicketEndpoint, relayedVerifyUrl, watchTicketEndpoint };
|