Skip to content

velut/verify-hcaptcha

Repository files navigation

✅ verify-hcaptcha

Build status Coverage jsDocs.io Language npm bundle size npm License

A no dependencies, fully typed library to verify hCaptcha tokens submitted by users when solving CAPTCHA challenges.

⚠️ Note: this is an unofficial library; we are not affiliated with hCaptcha.com

Features

  • No dependencies
  • Fully typed API and response data
  • Well documented and tested

API & Package Info

Install

Using npm:

npm i verify-hcaptcha

Using yarn:

yarn add verify-hcaptcha

Using pnpm:

pnpm i verify-hcaptcha

Usage Examples

Verify a token submitted by a user:

import { verifyHcaptchaToken } from "verify-hcaptcha";

(async () => {
  const result = await verifyHcaptchaToken({
    token: "USER-SUBMITTED-RESPONSE-TOKEN",
    secretKey: "YOUR-SECRET-KEY",
    siteKey: "YOUR-SITE-KEY",
  });

  if (result.success) {
    console.log("User is human");
  } else {
    console.log("User is robot");
  }
})();

Verify a token submitted by a user and get the raw response from hCaptcha:

import { rawVerifyHcaptchaToken } from "verify-hcaptcha";

(async () => {
  const result = await rawVerifyHcaptchaToken({
    token: "USER-SUBMITTED-RESPONSE-TOKEN",
    secretKey: "YOUR-SECRET-KEY",
    siteKey: "YOUR-SITE-KEY",
  });

  if (result.success) {
    console.log("User is human");
  } else {
    console.log("User is robot");
  }
})();

License

MIT

MIT License. See LICENSE file.

Copyright (c) 2023 Edoardo Scibona.

About

A no dependencies, fully typed library to verify hCaptcha.com tokens submitted by users when solving CAPTCHA challenges.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published