{"_id":"@bsvkey/x402-paywall","name":"@bsvkey/x402-paywall","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@bsvkey/x402-paywall","version":"0.1.0","description":"Put a BSV (x402) paywall in front of any HTTP API — charge per call, no accounts. Middleware or reverse proxy. Settlement-agnostic.","type":"module","main":"index.js","publishConfig":{"access":"public"},"exports":{".":"./index.js"},"author":{"name":"Embryo Space Inc.","url":"DBA BSVKey"},"homepage":"https://inference.bsvkey.com/#x402","engines":{"node":">=18"},"keywords":["x402","bsv","paywall","micropayments","api-monetization","402","pay-per-call","ai-agents","reverse-proxy","middleware"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/BSVKey/x402-paywall.git"},"gitHead":"1ed895fa2a58e49f2e4f8491508aeca7637844d4","_id":"@bsvkey/x402-paywall@0.1.0","bugs":{"url":"https://github.com/BSVKey/x402-paywall/issues"},"_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-AoKVBwY40HulviPrEvdh2shVKcB2PMHRz2msBw/hKySQ+v6hGy8L8wGHv6WDAuzjqrP8ItAyJOl6hM3u0HnRRA==","shasum":"7c26e9dbc3c53935fea5766f79ba3c7752e46066","tarball":"https://registry.npmjs.org/@bsvkey/x402-paywall/-/x402-paywall-0.1.0.tgz","fileCount":5,"unpackedSize":12995,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCai/F0Z9skMNq8FooX1dk0JKWNfjD+I7HyAadg+LODigIgZmPmLRkuYONi7ltaOmnY1Y8umcCkD95IYjBe7QwT9iM="}]},"_npmUser":{"name":"interence","email":"support@embryospace.com"},"directories":{},"maintainers":[{"name":"interence","email":"support@embryospace.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402-paywall_0.1.0_1788622199017_0.41175336922829286"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-05T15:29:58.882Z","0.1.0":"2026-09-05T15:29:59.156Z","modified":"2026-09-05T15:29:59.395Z"},"maintainers":[{"name":"interence","email":"support@embryospace.com"}],"description":"Put a BSV (x402) paywall in front of any HTTP API — charge per call, no accounts. Middleware or reverse proxy. Settlement-agnostic.","homepage":"https://inference.bsvkey.com/#x402","keywords":["x402","bsv","paywall","micropayments","api-monetization","402","pay-per-call","ai-agents","reverse-proxy","middleware"],"repository":{"type":"git","url":"git+https://github.com/BSVKey/x402-paywall.git"},"author":{"name":"Embryo Space Inc.","url":"DBA BSVKey"},"bugs":{"url":"https://github.com/BSVKey/x402-paywall/issues"},"license":"MIT","readme":"# @bsvkey/x402-paywall\n\nPut a **BSV [x402](https://x402.org) paywall in front of any HTTP API.** Charge per\ncall in BSV — no accounts, no cards, no code in your handler. Agents pay each request\nand get an on-chain settlement txid back.\n\n```bash\nnpm i @bsvkey/x402-paywall\n```\n\n## Two ways to use it\n\n**1. Reverse proxy** — gate an existing API with zero changes to it:\n\n```js\nimport { createPaywallServer } from '@bsvkey/x402-paywall';\n\ncreatePaywallServer({\n  origin: 'http://localhost:9000',      // your existing API\n  payTo: '1YourBsvAddress…',            // where the money lands\n  priceSats: 500,                        // or: priceUsd: 0.002\n  free: (req) => req.url.startsWith('/health'),  // exempt some routes\n}).listen(8080);\n// now http://localhost:8080/* is your API, paywalled in BSV.\n```\n\n**2. Middleware** — gate your own routes:\n\n```js\nimport http from 'node:http';\nimport { paywall } from '@bsvkey/x402-paywall';\n\nconst gate = paywall({ payTo: '1YourBsvAddress…', priceUsd: 0.002 });\nhttp.createServer((req, res) => gate(req, res, () => {\n  // only runs after the caller has paid\n  res.writeHead(200, { 'content-type': 'application/json' });\n  res.end(JSON.stringify({ data: 'your paid response' }));\n})).listen(8080);\n```\n\n## How it works\n\n1. Request with no `X-PAYMENT` header → **402** with an x402 quote (`accepts`).\n2. The caller pays (e.g. with [`@bsvkey/x402-bsv-client`](https://www.npmjs.com/package/@bsvkey/x402-bsv-client)) and retries with `X-PAYMENT`.\n3. The gate **settles the payment through a facilitator** (defaults to BSVKey's, which broadcasts on BSV), then serves/forwards the resource and returns `X-PAYMENT-RESPONSE` (the settlement txid).\n\nYou run a facilitator or use the hosted one — the gate just needs a `/settle` endpoint.\n\n## Config\n\n| Option | Meaning |\n|---|---|\n| `payTo` **(required)** | Address the payment pays. |\n| `priceSats` / `priceUsd` | Flat price per call (USD is pinned, settled in the sats equivalent). |\n| `facilitatorUrl` | Defaults to `https://inference.bsvkey.com/v1/x402`. Point at your own to keep 100%. |\n| `origin` | Upstream API URL (reverse-proxy mode). |\n| `free(req)` | Predicate to exempt routes (health, docs, free tier). |\n| `asset` / `scheme` / `network` | Default BSV (`bsv-p2pkh` / `bsv`). |\n\n## Other rails (XRP, USDC, …)\n\nThe gate is **settlement-agnostic** — it just proxies `/settle` to whatever facilitator\nhandles the `scheme` you configure. So a different asset (XRP on XRPL, USDC on an EVM\nchain) works the moment a facilitator for that scheme exists; set `asset`/`scheme`/\n`network`/`facilitatorUrl` and the gate logic is unchanged. Only BSV has a live facilitator\ntoday ([the BSVKey one](https://inference.bsvkey.com/v1/x402)).\n\nMIT.\n","readmeFilename":"README.md","_rev":"1-2e9f28f912e498990e1fd6226b2cc009"}