Skip to content

Repository files navigation

HATCHA

CAPTCHA proves you're human. HATCHA proves you're not.

npmLicenseCI


HATCHA modal in action

HATCHA (Hyperfast Agent Test for Computational Heuristic Assessment) is a reverse CAPTCHA that gates access behind challenges trivial for AI agents but painful for humans — large-number multiplication, string reversal, binary decoding, and more.

  • Server-side verification — answers never reach the client. HMAC-signed tokens, stateless, no database required.
  • 5 built-in challenge types — math, string reversal, character counting, sorting, binary decode.
  • Extensible — register custom challenge generators at runtime.
  • Themeable — dark, light, or auto mode via CSS custom properties.
  • Framework adapters — Next.js App Router and Express middleware out of the box.

Quickstart (Next.js)

1. Install

npm install @mondaycom/hatcha-react @mondaycom/hatcha-server

2. Add the API route

// app/api/hatcha/[...hatcha]/route.tsimport{createHatchaHandler}from"@mondaycom/hatcha-server/nextjs";consthandler=createHatchaHandler({secret: process.env.HATCHA_SECRET!,});exportconstGET=handler;exportconstPOST=handler;

3. Wrap your layout

// app/layout.tsximport{HatchaProvider}from"@mondaycom/hatcha-react";import"@mondaycom/hatcha-react/styles.css";exportdefaultfunctionRootLayout({ children }){return(<htmllang="en"><body><HatchaProvider>{children}</HatchaProvider></body></html>);}

4. Trigger verification

"use client";import{useHatcha}from"@mondaycom/hatcha-react";functionAgentModeButton(){const{ requestVerification }=useHatcha();return(<buttononClick={()=>requestVerification((token)=>{console.log("Agent verified!",token);})}>
Enter Agent Mode
</button>);}

5. Set your secret

# .env.local
HATCHA_SECRET=your-random-secret-here

How it works

Client Server
│ │
│ GET /api/hatcha/challenge │
│────────────────────────────────►│
│ │ Generate challenge
│ │ Hash answer
│ │ HMAC-sign { hash, expiry }
│ { challenge (no answer), token }
│◄────────────────────────────────│
│ │
│ Agent solves the challenge │
│ │
│ POST /api/hatcha/verify │
│ { answer, token } │
│────────────────────────────────►│
│ │ Verify HMAC signature
│ │ Check expiry
│ │ Compare answer hash
│ { success, verificationToken } │
│◄────────────────────────────────│

The answer never reaches the client. The signed token is opaque and contains only a hashed answer + expiry. Verification is stateless — no database needed.

Challenge types

TypeIconWhat it doesTime limit
math×5-digit × 5-digit multiplication30 s
stringReverse a 60–80 character random string30 s
count#Count a specific character in ~250 characters30 s
sortSort 15 numbers, return the k-th smallest30 s
binary01Decode binary octets to ASCII30 s

Custom challenges

import{registerChallenge}from"@mondaycom/hatcha-server";registerChallenge({type: "hex",generate(){constn=Math.floor(Math.random()*0xffffff);return{display: {type: "hex",icon: "0x",title: "Hex Decode",description: "Convert this hex number to decimal.",prompt: `0x${n.toString(16).toUpperCase()}`,timeLimit: 30,answer: String(n),},answer: String(n),};},});

Theming

HATCHA uses CSS custom properties scoped under --hatcha-*. Override them on any parent element:

[data-hatcha-theme] {
--hatcha-accent:#3b82f6;
--hatcha-accent-light:#60a5fa;
--hatcha-bg:#060b18;
--hatcha-fg:#e4eaf6;
--hatcha-success:#22c55e;
--hatcha-danger:#ef4444;
}

Pass theme="dark", theme="light", or theme="auto" to <HatchaProvider> or <Hatcha>.

Express

importexpressfrom"express";import{hatchaRouter}from"@mondaycom/hatcha-server/express";constapp=express();app.use(express.json());app.use("/api/hatcha",hatchaRouter({secret: process.env.HATCHA_SECRET!}));app.listen(3000);

Packages

PackageDescription
@mondaycom/hatcha-coreChallenge generation and cryptographic verification
@mondaycom/hatcha-reactReact component, provider, and styles
@mondaycom/hatcha-serverNext.js and Express server handlers

Development

git clone https://github.com/mondaycom/HATCHA.git
cd HATCHA
pnpm install
pnpm build
cd examples/nextjs-app
pnpm dev

Contributing

Contributions are welcome! See CONTRIBUTING.md for setup instructions and guidelines.

License

MIT

About

CAPTCHA proves you're human. HATCHA proves you're not.

Topics

Resources

Contributing

Stars

100 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages