Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philipjscott/invisible-recaptcha
Simplex express wrapper for Google's invisible recaptcha :white_check_mark:
https://github.com/philipjscott/invisible-recaptcha
Last synced: about 1 month ago
JSON representation
Simplex express wrapper for Google's invisible recaptcha :white_check_mark:
- Host: GitHub
- URL: https://github.com/philipjscott/invisible-recaptcha
- Owner: philipjscott
- Created: 2017-08-11T05:06:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-12T17:43:29.000Z (over 7 years ago)
- Last Synced: 2024-08-08T23:46:04.283Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/invisible-recaptcha
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# invisible-recaptcha
A simple Express wrapper for Google's invisible Recaptcha.
## Installation
```
npm install --save invisible-recaptcha
```## Usage
Requires secret reCaptcha key provided by Google. Returns a router to be used as middleware. Please note that this wrapper does not configure the `body-parser` middleware, so you must do that yourself. Note that you're responsible for getting the client-side data and `POST`ing it to the endpoint.
#### Parameters
```js
recaptchaRouter(secretKey, callbackSuccess, callbackFail, options)
```The request and response of the `POST` is passed to both callbacks, ie:
```js
function callbackSuccess(req, res) {}
function callbackFail(req, res) {}
```#### Examples
```js
const express = require('express');
const recaptchaRouterFactory = require('invisible-recaptcha');
const bodyParser = require('body-parser');
const SECRET_KEY = "SECRET";
const app = express();const recaptchaRouter = recaptchaRouterFactory(SECRET_KEY, captchaSuccess, captchaFail);
function captchaSuccess(req, res) { res.send('reCaptcha success!') }
function captchaFail(req, res) { res.send('reCaptcha failed.') }app.use(bodyParser.urlencoded({ extended });
app.use('/myEndpoint', recaptchaRouter);
```More in-depth examples to come soon.
#### Options
* `options.sendIp` - Boolean. The Google's reCaptcha API doesn't require the client's IP address; it's optional. Defaults to `true`.
* `options.usingProxy` - Boolean. If `options.sendIp` is `true`, then you must specify whether you're using a reverse proxy. Defaults to `false`.## Disclaimer
The creator, nor the project are in any way associated with Google. Also, this is my first public NPM package, so please be gentle ;)If you have any criticisms, questions, suggestions, or simply want to talk, you can email me at [email protected]