Skip to main content

Built and signed on GitHub Actions

@result/cf-turnstile is Cloudflare Turnstile API Wrapper

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
a month ago (0.1.0)

@result/cf-turnstile

JSR JSR

@tsutoringo/cf-turnstile is Cloudflare Turnstile API Wrapper

Example

// This is the demo secret key. In production, we recommend
// you store your secret key(s) safely.
const SECRET_KEY = '1x0000000000000000000000000000000AA';

async function handlePost(request) {
  const body = await request.formData();
  // Turnstile injects a token in "cf-turnstile-response".
  const token = body.get('cf-turnstile-response');
  const ip = request.headers.get('CF-Connecting-IP');

  const result = await new CfTurnstile(SECRET_KEY).validate(token, ip):

  result.match(
    (response) => {
      // Your code...
    },
    (error) => {
      // Error handling...
    }
  );

  // Or unwrap

  const response = result.unwrap();
}
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@result/cf-turnstile

Import symbol

import * as mod from "@result/cf-turnstile";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@result/cf-turnstile";

Add Package

npx jsr add @result/cf-turnstile

Import symbol

import * as mod from "@result/cf-turnstile";

Add Package

yarn dlx jsr add @result/cf-turnstile

Import symbol

import * as mod from "@result/cf-turnstile";

Add Package

pnpm dlx jsr add @result/cf-turnstile

Import symbol

import * as mod from "@result/cf-turnstile";

Add Package

bunx jsr add @result/cf-turnstile

Import symbol

import * as mod from "@result/cf-turnstile";