@thecryptodonkey/toll-booth 3.6.0 → 3.7.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.
@@ -65,6 +65,19 @@ export function createTollBooth(config) {
65
65
  const challengeHeaders = {};
66
66
  const challengeBody = {};
67
67
  const normalisedPrice = normalisedPricing[req.path] ?? { sats: defaultAmount };
68
+ // HEAD requests return a lightweight price probe without creating
69
+ // invoices or storing state. Useful for lnget --dry-run and indexers.
70
+ if (req.method === 'HEAD') {
71
+ if (normalisedPrice.sats !== undefined) {
72
+ challengeHeaders['X-L402-Price-Sats'] = String(normalisedPrice.sats);
73
+ }
74
+ if (normalisedPrice.usd !== undefined) {
75
+ challengeHeaders['X-L402-Price-Usd'] = String(normalisedPrice.usd);
76
+ }
77
+ challengeHeaders['WWW-Authenticate'] = 'L402 price-only';
78
+ challengeBody.message = 'Payment required.';
79
+ return { action: 'challenge', status: 402, headers: challengeHeaders, body: challengeBody };
80
+ }
68
81
  for (const rail of rails) {
69
82
  if (rail.canChallenge && !rail.canChallenge(normalisedPrice))
70
83
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecryptodonkey/toll-booth",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "type": "module",
5
5
  "description": "Monetise any API with HTTP 402 payments. Payment-rail agnostic middleware for Express, Hono, Deno, Bun, and Workers.",
6
6
  "license": "MIT",