captcha plugin adds bot protection to any KavachOS endpoint. It validates a client-side token before the request is processed, blocking automated sign-ups and credential stuffing without extra middleware.
Supported providers
| Provider | Value |
|---|---|
| Cloudflare Turnstile | 'turnstile' |
| hCaptcha | 'hcaptcha' |
| Google reCAPTCHA v2 | 'recaptcha-v2' |
| Google reCAPTCHA v3 | 'recaptcha-v3' |
Setup
lib/kavach.ts
Client-side token
Add the provider’s widget to your form. When the user completes the challenge, include the token in the request body ascaptchaToken.
Sign up with captcha token (client)
captchaToken field is stripped from the request before it reaches other plugins. Other plugin handlers never see it.
Error codes
| Code | Status | Meaning |
|---|---|---|
CAPTCHA_MISSING | 400 | Request did not include a token |
CAPTCHA_INVALID | 403 | Provider rejected the token |
reCAPTCHA v3 score threshold
For reCAPTCHA v3, set a minimum score (0.0–1.0). Requests below the threshold are rejected:lib/kavach.ts
Configuration reference
Captcha provider to use.
Server-side secret key from the provider dashboard.
List of endpoint paths where captcha validation is enforced. Defaults to sign-up and sign-in.
Minimum score for reCAPTCHA v3. Ignored for other providers.
Request body field that contains the captcha token.