Giter Site home page Giter Site logo

legallygeek / google-recaptcha-async Goto Github PK

View Code? Open in Web Editor NEW

This project forked from athletesgg/google-recaptcha

0.0 2.0 0.0 40 KB

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

License: MIT License

JavaScript 91.15% Shell 8.85%

google-recaptcha-async's Introduction

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)

google-recaptcha-async's People

Contributors

legallygeek avatar umamialex avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.