@junglo/paywall-core
v0.1.0
Published
Charge AI crawlers and QR-paywall humans on any site: pure pricing core (price/gate/license), x402 payment middleware for Hono/Workers, QR paylinks, RSL + Content-Signal feed generation.
Maintainers
Readme
@junglo/paywall-core
Charge AI crawlers and QR-paywall humans on any site — in about 5 lines.
A pure, dependency-light core for the two-lane paywall:
- Bot lane: HTTP 402 challenges per the x402 protocol — verified crawlers pay per crawl in USDC, straight to the creator's wallet. Unverified scrapers get nothing.
- Human lane: QR / payment-link paywalls on the creator's own rail (e.g. Stripe Payment Links) — 100% of content revenue passes through, never touching your platform.
- Licensing lane: RSL feed + Content-Signal robots.txt/headers, generated from the same pricing rules that enforce the paywall — the license never lies.
Runs on Cloudflare Workers, Bun, Node. Pure core has zero dependencies; edges add only uqr (QR) and a hono peer (middleware).
Install
bun add @junglo/paywall-core honoThe 5 lines
import { Hono } from "hono";
import { price, x402Middleware } from "@junglo/paywall-core";
const app = new Hono();
app.use("/article/:id", x402Middleware({
terms: (c) => price(lookup(c.req.param("id")), { kind: "bot", verified: true }, "x402"),
}));
app.get("/article/:id", (c) => c.text("the premium words"));
export default app;Crawlers without payment get 402 + machine-readable terms; with a valid
X-PAYMENT they get content plus an X-PAYMENT-RESPONSE settlement receipt.
The pure core
// What does this class of accessor owe? (policy — no I/O, no session)
price(content, accessor, lane) → Terms
// lanes: "human" | "x402" (bot, 402/USDC) | "ppc" (Cloudflare Pay Per Crawl, settled upstream)
// Terms: allow | blocked | payment-required (paylink/x402) | subscription-required
// Has this visitor already paid? (session resolution)
gate(session, terms) → { allowed, reason, terms }
// Machine-readable licensing derived from the same terms
license(content, terms) → RSLFragmentPricing models per content: humans — free, paid (one-off paylink),
subscription, archive-paywall (free while fresh, paywalled after N days);
bots — blocked, free, per-crawl (x402, USDC to the creator's wallet).
Unverified bots (Web Bot Auth fails) never reach a payment lane.
The edges
x402Middleware({ terms, facilitator?, network?, settle? }) // Hono/Workers middleware
httpFacilitator(url) // adapter for any x402 facilitator (/verify, /settle)
qrPaylink(url) // checkout URL → { url, svg } — Workers-safe QR
rslFeed(catalog, opts) // → { xml, robotsTxt, headers } for the whole site- Defaults target base-sepolia (testnet) via the public
x402.orgfacilitator; setnetwork: "base"(+ your facilitator) for production USDC. - The facilitator is pluggable — a small
verify/settleinterface. Use ours, your own, or wire in the officialx402-honomiddleware instead;price()/gate()don't care. - Settlement happens after the content is served; a failed settle replaces the response with a fresh 402.
First consumer
apps/paywall-demo in this repo: one Hono worker
exposing a paid /article (402 → pay-per-crawl), a /buy page with a QR to
the creator's Stripe Payment Link, /rsl.xml and /robots.txt. Runs locally
with bun run dev, deploys unchanged with wrangler deploy.
Honesty notes
- x402, RSL and Content Signals are young, fast-moving standards (2025–26). The protocol shapes here follow x402 v1 and are covered by tests against a mock facilitator; re-verify against live facilitators before production money flows.
Moneyis integer minor units (cents). The x402 lane is USD/USDC only (6-decimal atomic conversion built in).- This package prices and challenges; it does not store sessions, entitlements or keys — that's your app (or the PUB£¥$H€R platform, its first big consumer).
License
MIT © junglostore
