@getalby/lightning-tools 5.2.1 → 6.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 +15 -17
- package/dist/cjs/bolt11.cjs +1250 -0
- package/dist/cjs/bolt11.cjs.map +1 -0
- package/dist/cjs/fiat.cjs +36 -0
- package/dist/cjs/fiat.cjs.map +1 -0
- package/dist/cjs/index.cjs +1797 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/l402.cjs +89 -0
- package/dist/cjs/l402.cjs.map +1 -0
- package/dist/cjs/lnurl.cjs +1674 -0
- package/dist/cjs/lnurl.cjs.map +1 -0
- package/dist/cjs/podcasting2.cjs +32 -0
- package/dist/cjs/podcasting2.cjs.map +1 -0
- package/dist/esm/bolt11.js +1246 -0
- package/dist/esm/bolt11.js.map +1 -0
- package/dist/esm/fiat.js +31 -0
- package/dist/esm/fiat.js.map +1 -0
- package/dist/esm/index.js +1772 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/l402.js +84 -0
- package/dist/esm/l402.js.map +1 -0
- package/dist/esm/lnurl.js +1661 -0
- package/dist/esm/lnurl.js.map +1 -0
- package/dist/esm/podcasting2.js +30 -0
- package/dist/esm/podcasting2.js.map +1 -0
- package/dist/lightning-tools.umd.js +5 -0
- package/dist/lightning-tools.umd.js.map +1 -0
- package/dist/types/bolt11.d.ts +46 -0
- package/dist/types/fiat.d.ts +16 -0
- package/dist/types/index.d.ts +277 -0
- package/dist/types/l402.d.ts +27 -0
- package/dist/types/lnurl.d.ts +211 -0
- package/dist/{podcasting2/types.d.ts → types/podcasting2.d.ts} +11 -4
- package/package.json +51 -17
- package/dist/bolt11/Invoice.d.ts +0 -19
- package/dist/bolt11/index.d.ts +0 -3
- package/dist/bolt11/types.d.ts +0 -14
- package/dist/bolt11/utils.d.ts +0 -10
- package/dist/fiat/fiat.d.ts +0 -14
- package/dist/fiat/index.d.ts +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.modern.js +0 -1
- package/dist/index.module.js +0 -1
- package/dist/index.umd.js +0 -1
- package/dist/l402/index.d.ts +0 -2
- package/dist/l402/l402.d.ts +0 -6
- package/dist/l402/utils.d.ts +0 -12
- package/dist/lnurl/LightningAddress.d.ts +0 -44
- package/dist/lnurl/index.d.ts +0 -3
- package/dist/lnurl/types.d.ts +0 -104
- package/dist/lnurl/utils.d.ts +0 -14
- package/dist/podcasting2/boostagrams.d.ts +0 -2
- package/dist/podcasting2/index.d.ts +0 -2
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ or for use without any build tools:
|
|
|
44
44
|
The `LightningAddress` class provides helpers to work with lightning addresses
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
|
-
import { LightningAddress } from "@getalby/lightning-tools";
|
|
47
|
+
import { LightningAddress } from "@getalby/lightning-tools/lnurl";
|
|
48
48
|
|
|
49
49
|
const ln = new LightningAddress("hello@getalby.com");
|
|
50
50
|
|
|
@@ -60,7 +60,7 @@ console.log(ln.keysendData);
|
|
|
60
60
|
#### Get an invoice:
|
|
61
61
|
|
|
62
62
|
```js
|
|
63
|
-
import { LightningAddress } from "@getalby/lightning-tools";
|
|
63
|
+
import { LightningAddress } from "@getalby/lightning-tools/lnurl";
|
|
64
64
|
|
|
65
65
|
const ln = new LightningAddress("hello@getalby.com");
|
|
66
66
|
|
|
@@ -76,7 +76,7 @@ console.log(invoice.paymentHash); // print the payment hash
|
|
|
76
76
|
#### Verify a payment
|
|
77
77
|
|
|
78
78
|
```js
|
|
79
|
-
import { LightningAddress } from "@getalby/lightning-tools";
|
|
79
|
+
import { LightningAddress } from "@getalby/lightning-tools/lnurl";
|
|
80
80
|
const ln = new LightningAddress("hello@getalby.com");
|
|
81
81
|
await ln.fetch();
|
|
82
82
|
|
|
@@ -96,14 +96,14 @@ if (paid) {
|
|
|
96
96
|
console.log("paid");
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// or use the
|
|
99
|
+
// or use the convenient method:
|
|
100
100
|
await invoice.isPaid();
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
It is also possible to manually initialize the `Invoice`
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
|
-
|
|
106
|
+
import { Invoice } from "@getalby/lightning-tools/bolt11";
|
|
107
107
|
|
|
108
108
|
const invoice = new Invoice({ pr: pr, preimage: preimage });
|
|
109
109
|
await invoice.isPaid();
|
|
@@ -114,7 +114,7 @@ await invoice.isPaid();
|
|
|
114
114
|
You can also attach additional metadata information like app name, version, name of the podcast which is boosted etc. to the keysend payment.
|
|
115
115
|
|
|
116
116
|
```js
|
|
117
|
-
import { LightningAddress } from "@getalby/lightning-tools";
|
|
117
|
+
import { LightningAddress } from "@getalby/lightning-tools/lnurl";
|
|
118
118
|
const ln = new LightningAddress("hello@getalby.com");
|
|
119
119
|
await ln.fetch();
|
|
120
120
|
|
|
@@ -141,7 +141,7 @@ Nostr is a simple, open protocol that enables truly censorship-resistant and glo
|
|
|
141
141
|
This librarys provides helpers to create [zaps](https://github.com/nostr-protocol/nips/blob/master/57.md).
|
|
142
142
|
|
|
143
143
|
```js
|
|
144
|
-
import { LightningAddress } from "@getalby/lightning-tools";
|
|
144
|
+
import { LightningAddress } from "@getalby/lightning-tools/lnurl";
|
|
145
145
|
const ln = new LightningAddress("hello@getalby.com");
|
|
146
146
|
await ln.fetch();
|
|
147
147
|
|
|
@@ -182,7 +182,7 @@ This library includes a `fetchWithL402` function to consume L402 protected resou
|
|
|
182
182
|
##### Examples
|
|
183
183
|
|
|
184
184
|
```js
|
|
185
|
-
import { fetchWithL402 } from "@getalby/lightning-tools";
|
|
185
|
+
import { fetchWithL402 } from "@getalby/lightning-tools/l402";
|
|
186
186
|
|
|
187
187
|
// this will fetch the resource and pay the invoice with window.webln.
|
|
188
188
|
// the tokens/preimage data will be stored in the browser's localStorage and used for any following request
|
|
@@ -196,11 +196,11 @@ await fetchWithL402(
|
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
```js
|
|
199
|
-
import { fetchWithL402 } from "@getalby/lightning-tools";
|
|
200
|
-
import {
|
|
199
|
+
import { fetchWithL402 } from "@getalby/lightning-tools/l402";
|
|
200
|
+
import { NostrWebLNProvider } from "@getalby/sdk";
|
|
201
201
|
|
|
202
202
|
// use a NWC WebLN provide to do the payments
|
|
203
|
-
const nwc = new
|
|
203
|
+
const nwc = new NostrWebLNProvider({
|
|
204
204
|
nostrWalletConnectUrl: loadNWCUrl(),
|
|
205
205
|
});
|
|
206
206
|
|
|
@@ -215,14 +215,13 @@ await fetchWithL402(
|
|
|
215
215
|
```
|
|
216
216
|
|
|
217
217
|
```js
|
|
218
|
-
import {
|
|
219
|
-
import { fiat } from "@getalby/lightning-tools";
|
|
218
|
+
import { fetchWithL402, NoStorage } from "@getalby/lightning-tools/l402";
|
|
220
219
|
|
|
221
220
|
// do not store the tokens
|
|
222
|
-
await
|
|
221
|
+
await fetchWithL402(
|
|
223
222
|
"https://lsat-weather-api.getalby.repl.co/kigali",
|
|
224
223
|
{},
|
|
225
|
-
{ store: new
|
|
224
|
+
{ store: new NoStorage() },
|
|
226
225
|
);
|
|
227
226
|
```
|
|
228
227
|
|
|
@@ -231,10 +230,9 @@ await l402.fetchWithL402(
|
|
|
231
230
|
You can initialize an `Invoice` to decode a payment request.
|
|
232
231
|
|
|
233
232
|
```js
|
|
234
|
-
|
|
233
|
+
import { Invoice } from "@getalby/lightning-tools/bolt11";
|
|
235
234
|
|
|
236
235
|
const invoice = new Invoice({ pr });
|
|
237
|
-
|
|
238
236
|
const { paymentHash, satoshi, description, createdDate, expiryDate } = invoice;
|
|
239
237
|
```
|
|
240
238
|
|