@getalby/lightning-tools 8.1.0 → 8.1.1

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.
@@ -6,8 +6,27 @@ interface Wallet {
6
6
  }>;
7
7
  }
8
8
 
9
+ interface X402Requirements {
10
+ scheme: string;
11
+ network: string;
12
+ extra: {
13
+ invoice: string;
14
+ paymentMethod?: string;
15
+ [key: string]: unknown;
16
+ };
17
+ [key: string]: unknown;
18
+ }
19
+
20
+ /**
21
+ * Probe a PAYMENT-REQUIRED header for a lightning-payable offer without
22
+ * throwing. Returns the matching requirements, or null if the header has no
23
+ * lightning entry (e.g. USDC-only endpoints) or is malformed. Used by the
24
+ * top-level fetch402 dispatcher to decide whether to attempt payment or hand
25
+ * the 402 back to the caller.
26
+ */
27
+ declare const findX402LightningRequirements: (x402Header: string) => X402Requirements | null;
9
28
  declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
10
29
  wallet: Wallet;
11
30
  }) => Promise<Response>;
12
31
 
13
- export { fetchWithX402 };
32
+ export { fetchWithX402, findX402LightningRequirements };
@@ -53,6 +53,25 @@ declare function parseL402Authorization(input: string): {
53
53
  preimage: string;
54
54
  } | null;
55
55
 
56
+ interface X402Requirements {
57
+ scheme: string;
58
+ network: string;
59
+ extra: {
60
+ invoice: string;
61
+ paymentMethod?: string;
62
+ [key: string]: unknown;
63
+ };
64
+ [key: string]: unknown;
65
+ }
66
+
67
+ /**
68
+ * Probe a PAYMENT-REQUIRED header for a lightning-payable offer without
69
+ * throwing. Returns the matching requirements, or null if the header has no
70
+ * lightning entry (e.g. USDC-only endpoints) or is malformed. Used by the
71
+ * top-level fetch402 dispatcher to decide whether to attempt payment or hand
72
+ * the 402 back to the caller.
73
+ */
74
+ declare const findX402LightningRequirements: (x402Header: string) => X402Requirements | null;
56
75
  declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
57
76
  wallet: Wallet;
58
77
  }) => Promise<Response>;
@@ -74,5 +93,5 @@ declare const fetchWithMpp: (url: string, fetchArgs: RequestInit, options: {
74
93
  wallet: Wallet;
75
94
  }) => Promise<Response>;
76
95
 
77
- export { createGuardedWallet, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, issueL402Macaroon, makeL402AuthenticateHeader, parseL402, parseL402Authorization, verifyL402Macaroon };
96
+ export { createGuardedWallet, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, findX402LightningRequirements, issueL402Macaroon, makeL402AuthenticateHeader, parseL402, parseL402Authorization, verifyL402Macaroon };
78
97
  export type { MacaroonPayload, Wallet };
@@ -295,6 +295,25 @@ declare function parseL402Authorization(input: string): {
295
295
  preimage: string;
296
296
  } | null;
297
297
 
298
+ interface X402Requirements {
299
+ scheme: string;
300
+ network: string;
301
+ extra: {
302
+ invoice: string;
303
+ paymentMethod?: string;
304
+ [key: string]: unknown;
305
+ };
306
+ [key: string]: unknown;
307
+ }
308
+
309
+ /**
310
+ * Probe a PAYMENT-REQUIRED header for a lightning-payable offer without
311
+ * throwing. Returns the matching requirements, or null if the header has no
312
+ * lightning entry (e.g. USDC-only endpoints) or is malformed. Used by the
313
+ * top-level fetch402 dispatcher to decide whether to attempt payment or hand
314
+ * the 402 back to the caller.
315
+ */
316
+ declare const findX402LightningRequirements: (x402Header: string) => X402Requirements | null;
298
317
  declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
299
318
  wallet: Wallet;
300
319
  }) => Promise<Response>;
@@ -338,5 +357,5 @@ declare const getFormattedFiatValue: ({ satoshi, currency, locale, }: {
338
357
  locale: string;
339
358
  }) => Promise<string>;
340
359
 
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 };
360
+ export { DEFAULT_PROXY, Invoice, LN_ADDRESS_REGEX, LightningAddress, createGuardedWallet, decodeInvoice, fetch402, fetchWithL402, fetchWithMpp, fetchWithX402, findX402LightningRequirements, fromHexString, generateZapEvent, getEventHash, getFiatBtcRate, getFiatCurrencies, getFiatValue, getFormattedFiatValue, getSatoshiValue, isUrl, isValidAmount, issueL402Macaroon, makeL402AuthenticateHeader, parseKeysendResponse, parseL402, parseL402Authorization, parseLnUrlPayResponse, parseNostrResponse, sendBoostagram, serializeEvent, validateEvent, validatePreimage, verifyL402Macaroon };
342
361
  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.1.0",
3
+ "version": "8.1.1",
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",