Socket
Socket
Sign inDemoInstall

google-recaptcha-api

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-recaptcha-api

A simple library of captcha based on Google reCAPTCHA Server API that supports Node.js.


Version published
Maintainers
1
Weekly downloads
3

Weekly downloads

Readme

Source

google-recaptcha-api

A simple library of captcha based on Google reCAPTCHA Server API that supports Node.js.

Install

Using npm

npm install google-recaptcha-api --save

Usage

Node.js usage

You can use google-recaptcha-v2 in browser.

const GoogleReCaptcha = require('google-recaptcha-api');
const captcha = new GoogleReCaptcha('your_server_captcha_key');
try {
    const res = await captcha.validate('captcha_token', 'user_ip');
    if (res.success) {
        //The response token is valid.
    } else {
        //The response token is invalid.
    }
} catch(e) {
    //Some exception, such as network error => request timeout.
}

You can get server_captcha_key from Google reCAPTCHA Admin Console.

Method

new GoogleReCaptcha(secret, host) => Create an instance of google-recaptcha-api.

  • secret => required, the shared key between your site and reCAPTCHA.
  • host => optional, API hostname, default value is www.google.com. Specially, some areas require network proxying, such as China, just set www.recaptcha.net.

instance.validate(response, remoteip) => Using the following API to ensure the response token is valid. Return value is a promise, you can use async-await synchronizing code.

  • response => required, the user response token provided by the reCAPTCHA client-side integration on your site.
  • remoteip => required, the user's IP address.

License

google-recaptcha-api is MIT licensed.

Keywords

FAQs

Last updated on 10 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc