Socket
Socket
Sign inDemoInstall

google-recaptcha

Package Overview
Dependencies
49
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-recaptcha

A simple and framework agnostic way to verify Google Recaptcha data.


Version published
Weekly downloads
735
increased by25%
Maintainers
1
Install size
3.94 MB
Created
Weekly downloads
 

Readme

Source

Google Recaptcha

Build Status Codacy Badge Codacy Badge

A simple and framework agnostic way to verify Google Recaptcha data. This package currently supports Google Recaptcha V2.

Installation

$ yarn add google-recaptcha

Usage

const GoogleRecaptcha = require('google-recaptcha')

const googleRecaptcha = new GoogleRecaptcha({secret: 'RECAPTCHA_SECRET_KEY'})

// Some pseudo server code:

http.on('POST', (request, response) => {
  const recaptchaResponse = request.body['g-recaptcha-response']

  googleRecaptcha.verify({response: recaptchaResponse}, (error) => {
    if (error) {
      return response.send({isHuman: false})
    }

    return response.send({isHuman: true})
  })
})

Methods and Variables

constructor(Object options)

Creates an instance of the Google Recaptcha verifier. Here are the options:

  • String secret (required): Your Google Recaptcha secret key.
  • String apiUrl: The API URL to verify with. This option defaults to GoogleRecaptcha.DEFAULT_API_URL.
  • Object logger: Any console.log compatible logger. Defaults to using the debug package. The debug namespace is recaptcha.
googleRecaptcha.verify(Object options, Function callback)

Runs a verification of the Recaptcha response. Here are the options:

  • String response (required): The Recaptcha response token.
  • String remoteIp: The user's IP address.

The callback can take an Error error as its first parameter and a Object body as its second parameter. The body is a raw response from the Recaptcha verification. Specific details can be found here.

Static String GoogleRecaptcha.DEFAULT_API_URL

The default API URL to verify with. The value is https://www.google.com/recaptcha/api/siteverify.

License

Copyright (c) 2016 Martin Experiments LLC

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

FAQs

Last updated on 26 Mar 2017

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