# recaptcha-validator

> a simple google recaptcha api library to validate recaptchas

Latest version **2.0.0** (published 2017-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install recaptcha-validator
pnpm add recaptcha-validator
yarn add recaptcha-validator
bun add recaptcha-validator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-11-09 |
| First published | 2015-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dan Neumann |
| Maintainers | danneu, ohomer |

## Links

- npm: https://www.npmjs.com/package/recaptcha-validator
- Repository: https://github.com/danneu/recaptcha-validator
- Homepage: https://github.com/danneu/recaptcha-validator#readme
- Issues: https://github.com/danneu/recaptcha-validator/issues
- npm.io page: https://npm.io/package/recaptcha-validator

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^2.2.0

## Recent versions

- 2.0.0 (latest) — 2017-11-09
- 1.0.11 — 2016-09-11
- 1.0.10 — 2016-08-22
- 1.0.9 — 2016-08-18
- 1.0.7 — 2016-06-06
- 1.0.6 — 2016-05-22
- 1.0.5 — 2016-05-22
- 1.0.4444 — 2016-05-22
- 1.0.3 — 2016-05-22
- 1.0.2 — 2016-05-22
- 1.0.1 — 2016-01-17
- 1.0.0 — 2015-07-20

## README

# recaptcha-validator

A simple library that makes API requests to Google's Recaptcha
service to confirm Recaptcha tokens.

<https://developers.google.com/recaptcha/intro>

Supports Recaptcha v2 / Invisible.

```javascript
const recaptcha = require('recaptcha-validator')

recaptcha(sitesecret, gRecaptchaResponse, clientIpAddress)
  .then(reply => console.log(reply))
  .catch(err => console.error('recaptcha confirmation failed:', err))
```

## Usage

Check out the `example/` folder for a complete but minimal example.

`recaptcha()` returns a promise that resolves with google's reply
if the request was successful.

It fails with `typeof err === 'string'` if the recaptcha api
reports a problem with the request.

- missing-input-secret: The secret parameter is missing.
- invalid-input-secret: The secret parameter is invalid or malformed.
- missing-input-response: The response parameter is missing.
- invalid-input-response: The response parameter is invalid or malformed.
- bad-request: The request is invalid or malformed.
- unspecified-error

Else the error will be an `Error` object representing network error.

Here's an example response upon success:

```json
{ success: true,
  challenge_ts: '2017-11-09T23:12:08Z',
  hostname: 'localhost' }
```

`hostname` only appears on successful requests and you can use it to
ensure recaptcha submissions are originating from your domain.

More info: https://developers.google.com/recaptcha/docs/domain_validation

---
_Source: https://npm.io/package/recaptcha-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
