✅ verify-hcaptcha
A fully typed library to verify hCaptcha.com tokens submitted by users when solving captcha challenges.
[!WARNING]
This is an unofficial library; we are not affiliated with hCaptcha.com.
Useful resources
Install
Using npm
:
npm add verify-hcaptcha
Using yarn
:
yarn add verify-hcaptcha
Using pnpm
:
pnpm add verify-hcaptcha
Using bun
:
bun add verify-hcaptcha
Usage Examples
Verify a token submitted by a user:
import { verifyHcaptchaToken } from "verify-hcaptcha";
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");
}
License
MIT
Copyright (c) 2024 Edoardo Scibona
See LICENSE file.
[2.0.0] - 2024-07-03
This package is now a pure ESM package and uses the fetch global function to perform network requests.
Additionally, every response returned by hCaptcha.com is now validated against its expected schema. This means that data can now be safely accessed according to the corresponding TypeScript type definition. Unexpected data will reject with an error; in this case open an issue to propose changes to the schema.
Added
These are the current package's exports:
- Functions:
- TypeScript types:
Changed
- BREAKING CHANGE: This package is now a pure ESM package.
- BREAKING CHANGE: Require Node.js 20 (latest LTS).
- BREAKING CHANGE: Use
fetch
for network requests.