
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
turnstile-validator
Advanced tools
A TypeScript validator for Cloudflare Turnstile tokens.
npm install turnstile-validator
import TurnstileValidator from "turnstile-validator";
const validator = new TurnstileValidator("your_secret_key");
async function validateToken(token: string, clientIp?: string) {
try {
const result = await validator.validate(token, clientIp);
console.log(result);
// { success: true, challenge_ts: '2023-01-01T00:00:00Z', hostname: 'example.com', ... }
} catch (error) {
console.error("Validation failed:", error.message);
}
}
validateToken("user_response_token", "127.0.0.1");
new TurnstileValidator(secretKey: string)Creates a new validator instance.
secretKey: Your Cloudflare Turnstile secret keyvalidator.validate(token: string, clientIp?: string): Promise<TurnstileResponse>Validates a Turnstile token.
token: The user response token from the Turnstile widgetclientIp: (Optional) The IP address of the userReturns a Promise that resolves to the Cloudflare API response.
interface TurnstileResponse {
success: boolean;
challenge_ts: string;
hostname: string;
error_codes?: string[];
action?: string;
cdata?: string;
}
npm installnpm testnpm run buildThis project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A validator for Cloudflare Turnstile tokens
We found that turnstile-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.