@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.
- package/dist/core/toll-booth.js +13 -0
- package/package.json +1 -1
package/dist/core/toll-booth.js
CHANGED
|
@@ -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