Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 0 ๐Ÿ“– 1 min read

Barstile: Self-hosted non-interactive bot protection for JS/TS

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/barst

I built Barstile a self-hosted, zero-dependency alternative to visual CAPTCHAs and third-party widgets for JavaScript and TypeScript apps.

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 With and a stateless HMAC-SHA256 challenge (salt.difficulty.expiresAt.signature).
  • barstileFetch() (or <barstile-widget> / BarstileWidget) solves SHA-256(salt + ":" + nonce) inside an inline Web Worker and retries automatically.
  • Server verifies in a single SHA-256 hash, blocks replays (ReplayCache or RedisReplayStore), 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.js for 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!

๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.