Skip to content

Releases: lnbotdev/typescript-l402

v1.0.0

05 Mar 18:52

Choose a tag to compare

v1.0.0

Migrate to wallet-scoped L402 API (@lnbot/sdk v1.0.0).

Breaking Changes

  • paywall() options now require walletId field
  • client() options now require walletId field
  • Minimum @lnbot/sdk peer dependency is now >=1.0.0

Migration

// Before (v0.x)
l402.paywall(ln, { price: 10 });
l402.client(ln);

// After (v1.0.0)
l402.paywall(ln, { walletId: "wal_xxx", price: 10 });
l402.client(ln, { walletId: "wal_xxx" });

v0.2.0

27 Feb 20:27

Choose a tag to compare

What's Changed

  • Fix: maxPrice check now throws L402BudgetExceededError instead of generic L402Error, so all spending-limit violations can be caught with a single instanceof
  • Fix: Budget tracker now records the actual amount paid via SDK (payment.amount) instead of the server's self-reported price
  • Safety: Client throws L402PaymentFailedError if server still returns 402 after a successful payment (prevents infinite retry loops)
  • Feature: Added put(), patch(), and delete() convenience methods to L402Client

v0.1.0

27 Feb 19:34

Choose a tag to compare

Initial release of @lnbot/l402 — L402 Lightning payment middleware for Express.js.

Features

  • Server middlewarel402.paywall() protects Express routes behind an L402 paywall with fixed or dynamic pricing
  • Client wrapperl402.client() auto-pays L402-protected APIs with token caching and budget controls
  • Header utilities — parse and format L402 Authorization and WWW-Authenticate headers
  • Zero crypto dependencies — all L402 logic (macaroons, verification, payment) delegated to @lnbot/sdk

Quick start

import express from "express";
import { l402, LnBot } from "@lnbot/l402";

const app = express();
const ln = new LnBot({ apiKey: "key_..." });

app.use("/api/premium", l402.paywall(ln, { price: 10 }));

See the README for full documentation.