@coolgk/captcha
v2.1.3
Published
recapcha wrapper
Downloads
28
Readme
@coolgk/captcha
a javascript / typescript module
npm install @coolgk/captcha
recapcha wrapper
Report bugs here: https://github.com/coolgk/node-utils/issues
Examples
const { verify } = require('@coolgk/captcha');
const secret = '-------';
verify(secret, captchaResponse).then((response) => {
console.log(response); // { success: true, challenge_ts: '2017-12-03T08:19:48Z', hostname: 'www.google.com' }
// { success: false, 'error-codes': [ 'invalid-input-response' ] }
});
// OR
import { Captcha } from '@coolgk/captcha';
// OR
// const { Captcha } = require('@coolgk/captcha');
const captcha = new Captcha({ secret });
const captchaResponse = '---------';
captcha.verify(captchaResponse).then((response) => {
console.log(response); // { success: true, challenge_ts: '2017-12-03T08:19:48Z', hostname: 'www.google.com' }
// { success: false, 'error-codes': [ 'invalid-input-response' ] }
});
Captcha
Kind: global class
new Captcha(options)
| Param | Type | Description | | --- | --- | --- | | options | object | | | options.secret | object | google captcha secret https://www.google.com/recaptcha/admin#site/337294176 |
captcha.verify(response, [remoteip])
Kind: instance method of Captcha
| Param | Type | Description | | --- | --- | --- | | response | string | repsonse from recaptcha | | [remoteip] | string | ip address | | | promise | |