I built Barstile a self-hosted, zero-dependency alternative to visual CAPTCHAs and third-party widgets for JavaScript and TypeScript apps.
- Website: https://barstile.pages.dev/
- GitHub: https://github.com/gozajpeg/barstile
- npm: https://www.npmjs.com/package/barstile
Instead of making real users click crosswalks or sending visitor data to Cloudflare/Google, Barstile sits in front of your routes or forms and makes automated clients pay a small CPU cost (SHA-256 Proof-of-Work) in the background so humans never see a puzzle and no third party ever tracks your traffic.
No third-party services, no analytics, no dependencies, no tracking cookies, and completely open-source.
How it works
- Server returns
449 Retry Withand a stateless HMAC-SHA256 challenge (salt.difficulty.expiresAt.signature). -
barstileFetch()(or<barstile-widget>/BarstileWidget) solvesSHA-256(salt + ":" + nonce)inside an inline Web Worker and retries automatically. - Server verifies in a single SHA-256 hash, blocks replays (
ReplayCacheorRedisReplayStore), and issues a time-limited clearance token with a request quota (AllowanceCache) + sliding-window IP tarpit (TarpitTracker). - Runs on Node 18+, Cloudflare Workers, Vercel Edge, Deno, Bun, and browsers (
dist/barstile.min.jsfor plain HTML).
Honest tradeoffs
- JS/TS-only right now (no Python/Go/PHP SDKs yet).
- PoW adds compute cost to mass scraping and form spam, not L3/L4 DDoS or slow human-paced bots.
Would love any technical feedback or edge cases I missed!
