@getalby/lightning-tools 8.0.0 → 8.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/dist/cjs/402/l402.cjs +102 -0
- package/dist/cjs/402/l402.cjs.map +1 -1
- package/dist/cjs/402/x402.cjs +525 -518
- package/dist/cjs/402/x402.cjs.map +1 -1
- package/dist/cjs/402.cjs +116 -7
- package/dist/cjs/402.cjs.map +1 -1
- package/dist/cjs/bolt11.cjs +526 -518
- package/dist/cjs/bolt11.cjs.map +1 -1
- package/dist/cjs/index.cjs +597 -487
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lnurl.cjs +14 -7
- package/dist/cjs/lnurl.cjs.map +1 -1
- package/dist/esm/402/l402.js +98 -1
- package/dist/esm/402/l402.js.map +1 -1
- package/dist/esm/402/x402.js +525 -518
- package/dist/esm/402/x402.js.map +1 -1
- package/dist/esm/402.js +112 -8
- package/dist/esm/402.js.map +1 -1
- package/dist/esm/bolt11.js +526 -519
- package/dist/esm/bolt11.js.map +1 -1
- package/dist/esm/index.js +592 -488
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lnurl.js +14 -7
- package/dist/esm/lnurl.js.map +1 -1
- package/dist/lightning-tools.umd.js +3 -3
- package/dist/lightning-tools.umd.js.map +1 -1
- package/dist/types/402/l402.d.ts +39 -1
- package/dist/types/402.d.ts +39 -2
- package/dist/types/bolt11.d.ts +2 -1
- package/dist/types/index.d.ts +40 -2
- package/package.json +1 -1
package/dist/types/402/l402.d.ts
CHANGED
|
@@ -10,4 +10,42 @@ declare const fetchWithL402: (url: string, fetchArgs: RequestInit, options: {
|
|
|
10
10
|
wallet: Wallet;
|
|
11
11
|
}) => Promise<Response>;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
interface WwwAuthenticatePayload {
|
|
14
|
+
token: string;
|
|
15
|
+
invoice: string;
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Client: parse "www-authenticate" header from server response
|
|
20
|
+
* @param input
|
|
21
|
+
* @returns details from the header value (token or macaroon, invoice)
|
|
22
|
+
*/
|
|
23
|
+
declare const parseL402: (input: string) => WwwAuthenticatePayload;
|
|
24
|
+
|
|
25
|
+
type MacaroonPayload<T> = T & {
|
|
26
|
+
paymentHash: string;
|
|
27
|
+
};
|
|
28
|
+
declare function issueL402Macaroon<T extends Record<string, unknown>>(secret: string, paymentHash: string, params?: T): Promise<string>;
|
|
29
|
+
declare function verifyL402Macaroon<T = unknown>(secret: string, token: string): Promise<MacaroonPayload<T>>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Server: create a WWW-Authenticate header for a given macaroon and invoice
|
|
33
|
+
* @param args the macaroon/token and invoice generated for the client's request
|
|
34
|
+
* @returns the header value
|
|
35
|
+
*/
|
|
36
|
+
declare const makeL402AuthenticateHeader: (args: {
|
|
37
|
+
token?: string;
|
|
38
|
+
invoice: string;
|
|
39
|
+
}) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Server: parse "authorization" header sent from client
|
|
42
|
+
* @param input value from authorization header
|
|
43
|
+
* @returns the macaroon and preimage
|
|
44
|
+
*/
|
|
45
|
+
declare function parseL402Authorization(input: string): {
|
|
46
|
+
token: string;
|
|
47
|
+
preimage: string;
|
|
48
|
+
} | null;
|
|
49
|
+
|
|
50
|
+
export { fetchWithL402, issueL402Macaroon, makeL402AuthenticateHeader, parseL402, parseL402Authorization, verifyL402Macaroon };
|
|
51
|
+
export type { MacaroonPayload };
|
package/dist/types/402.d.ts
CHANGED
|
@@ -16,6 +16,43 @@ declare const fetchWithL402: (url: string, fetchArgs: RequestInit, options: {
|
|
|
16
16
|
wallet: Wallet;
|
|
17
17
|
}) => Promise<Response>;
|
|
18
18
|
|
|
19
|
+
interface WwwAuthenticatePayload {
|
|
20
|
+
token: string;
|
|
21
|
+
invoice: string;
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Client: parse "www-authenticate" header from server response
|
|
26
|
+
* @param input
|
|
27
|
+
* @returns details from the header value (token or macaroon, invoice)
|
|
28
|
+
*/
|
|
29
|
+
declare const parseL402: (input: string) => WwwAuthenticatePayload;
|
|
30
|
+
|
|
31
|
+
type MacaroonPayload<T> = T & {
|
|
32
|
+
paymentHash: string;
|
|
33
|
+
};
|
|
34
|
+
declare function issueL402Macaroon<T extends Record<string, unknown>>(secret: string, paymentHash: string, params?: T): Promise<string>;
|
|
35
|
+
declare function verifyL402Macaroon<T = unknown>(secret: string, token: string): Promise<MacaroonPayload<T>>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Server: create a WWW-Authenticate header for a given macaroon and invoice
|
|
39
|
+
* @param args the macaroon/token and invoice generated for the client's request
|
|
40
|
+
* @returns the header value
|
|
41
|
+
*/
|
|
42
|
+
declare const makeL402AuthenticateHeader: (args: {
|
|
43
|
+
token?: string;
|
|
44
|
+
invoice: string;
|
|
45
|
+
}) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Server: parse "authorization" header sent from client
|
|
48
|
+
* @param input value from authorization header
|
|
49
|
+
* @returns the macaroon and preimage
|
|
50
|
+
*/
|
|
51
|
+
declare function parseL402Authorization(input: string): {
|
|
52
|
+
token: string;
|
|
53
|
+
preimage: string;
|
|
54
|
+
} | null;
|
|
55
|
+
|
|
19
56
|
declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
|
|
20
57
|
wallet: Wallet;
|
|
21
58
|
}) => Promise<Response>;
|
|
@@ -37,5 +74,5 @@ declare const fetchWithMpp: (url: string, fetchArgs: RequestInit, options: {
|
|
|
37
74
|
wallet: Wallet;
|
|
38
75
|
}) => Promise<Response>;
|
|
39
76
|
|
|
40
|
-
export { createGuardedWallet, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402 };
|
|
41
|
-
export type { Wallet };
|
|
77
|
+
export { createGuardedWallet, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, issueL402Macaroon, makeL402AuthenticateHeader, parseL402, parseL402Authorization, verifyL402Macaroon };
|
|
78
|
+
export type { MacaroonPayload, Wallet };
|
package/dist/types/bolt11.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ type DecodedInvoice = {
|
|
|
24
24
|
description: string | undefined;
|
|
25
25
|
};
|
|
26
26
|
declare const decodeInvoice: (paymentRequest: string) => DecodedInvoice | null;
|
|
27
|
+
declare function validatePreimage(preimage: string, paymentHash: string): boolean;
|
|
27
28
|
|
|
28
29
|
declare class Invoice {
|
|
29
30
|
paymentRequest: string;
|
|
@@ -46,5 +47,5 @@ declare class Invoice {
|
|
|
46
47
|
hasExpired(): boolean;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
export { Invoice, decodeInvoice, fromHexString };
|
|
50
|
+
export { Invoice, decodeInvoice, fromHexString, validatePreimage };
|
|
50
51
|
export type { InvoiceArgs, SuccessAction };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ type DecodedInvoice = {
|
|
|
27
27
|
description: string | undefined;
|
|
28
28
|
};
|
|
29
29
|
declare const decodeInvoice: (paymentRequest: string) => DecodedInvoice | null;
|
|
30
|
+
declare function validatePreimage(preimage: string, paymentHash: string): boolean;
|
|
30
31
|
|
|
31
32
|
declare class Invoice {
|
|
32
33
|
paymentRequest: string;
|
|
@@ -257,6 +258,43 @@ declare const fetchWithL402: (url: string, fetchArgs: RequestInit, options: {
|
|
|
257
258
|
wallet: Wallet;
|
|
258
259
|
}) => Promise<Response>;
|
|
259
260
|
|
|
261
|
+
interface WwwAuthenticatePayload {
|
|
262
|
+
token: string;
|
|
263
|
+
invoice: string;
|
|
264
|
+
[key: string]: string;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Client: parse "www-authenticate" header from server response
|
|
268
|
+
* @param input
|
|
269
|
+
* @returns details from the header value (token or macaroon, invoice)
|
|
270
|
+
*/
|
|
271
|
+
declare const parseL402: (input: string) => WwwAuthenticatePayload;
|
|
272
|
+
|
|
273
|
+
type MacaroonPayload<T> = T & {
|
|
274
|
+
paymentHash: string;
|
|
275
|
+
};
|
|
276
|
+
declare function issueL402Macaroon<T extends Record<string, unknown>>(secret: string, paymentHash: string, params?: T): Promise<string>;
|
|
277
|
+
declare function verifyL402Macaroon<T = unknown>(secret: string, token: string): Promise<MacaroonPayload<T>>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Server: create a WWW-Authenticate header for a given macaroon and invoice
|
|
281
|
+
* @param args the macaroon/token and invoice generated for the client's request
|
|
282
|
+
* @returns the header value
|
|
283
|
+
*/
|
|
284
|
+
declare const makeL402AuthenticateHeader: (args: {
|
|
285
|
+
token?: string;
|
|
286
|
+
invoice: string;
|
|
287
|
+
}) => string;
|
|
288
|
+
/**
|
|
289
|
+
* Server: parse "authorization" header sent from client
|
|
290
|
+
* @param input value from authorization header
|
|
291
|
+
* @returns the macaroon and preimage
|
|
292
|
+
*/
|
|
293
|
+
declare function parseL402Authorization(input: string): {
|
|
294
|
+
token: string;
|
|
295
|
+
preimage: string;
|
|
296
|
+
} | null;
|
|
297
|
+
|
|
260
298
|
declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
|
|
261
299
|
wallet: Wallet;
|
|
262
300
|
}) => Promise<Response>;
|
|
@@ -300,5 +338,5 @@ declare const getFormattedFiatValue: ({ satoshi, currency, locale, }: {
|
|
|
300
338
|
locale: string;
|
|
301
339
|
}) => Promise<string>;
|
|
302
340
|
|
|
303
|
-
export { DEFAULT_PROXY, Invoice, LN_ADDRESS_REGEX, LightningAddress, createGuardedWallet, decodeInvoice, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, fromHexString, generateZapEvent, getEventHash, getFiatBtcRate, getFiatCurrencies, getFiatValue, getFormattedFiatValue, getSatoshiValue, isUrl, isValidAmount, parseKeysendResponse, parseLnUrlPayResponse, parseNostrResponse, sendBoostagram, serializeEvent, validateEvent };
|
|
304
|
-
export type { Boost, BoostArguments, BoostOptions, Event, FiatCurrency, InvoiceArgs, KeySendRawData, KeysendResponse, LUD18PayerData, LUD18ServicePayerData, LnUrlPayResponse, LnUrlRawData, NostrProvider, NostrResponse, RequestInvoiceArgs, SuccessAction, Wallet, WeblnBoostParams, ZapArgs, ZapOptions };
|
|
341
|
+
export { DEFAULT_PROXY, Invoice, LN_ADDRESS_REGEX, LightningAddress, createGuardedWallet, decodeInvoice, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, fromHexString, generateZapEvent, getEventHash, getFiatBtcRate, getFiatCurrencies, getFiatValue, getFormattedFiatValue, getSatoshiValue, isUrl, isValidAmount, issueL402Macaroon, makeL402AuthenticateHeader, parseKeysendResponse, parseL402, parseL402Authorization, parseLnUrlPayResponse, parseNostrResponse, sendBoostagram, serializeEvent, validateEvent, validatePreimage, verifyL402Macaroon };
|
|
342
|
+
export type { Boost, BoostArguments, BoostOptions, Event, FiatCurrency, InvoiceArgs, KeySendRawData, KeysendResponse, LUD18PayerData, LUD18ServicePayerData, LnUrlPayResponse, LnUrlRawData, MacaroonPayload, NostrProvider, NostrResponse, RequestInvoiceArgs, SuccessAction, Wallet, WeblnBoostParams, ZapArgs, ZapOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getalby/lightning-tools",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/getAlby/js-lightning-tools.git",
|