Code Monkey home page Code Monkey logo

recaptcha-promise's Introduction

recaptcha-promise

CI Test Coverage

This Node module aims to provide simple, asynchronous, promise-based ReCAPTCHA response verification. TypeScript type definitions are included.

This software is in no way affiliated with or endorsed by Google.

Installation

Add to your project's dependencies:

npm install recaptcha-promise

Usage

Creating an instance

This is the recommended way. First, an instance is created with your secret key. It can then be used to verify as many challenges as needed.

const recaptcha = require('recaptcha-promise').create({
  secret: 'YOUR_SECRET_KEY'
})

// In an HTTP handler:

// ... with Promises:
recaptcha.verify(userResponse).then(function (success) {
  console.log(success ? 'Response valid' : 'Response invalid')
})

// ... or in an async context:
async function handleRequest (userResponse) {
  const success = await recaptcha.verify(userResponse)
  console.log(success ? 'Response valid' : 'Response invalid')
}
handleRequest(/* ... */)

The global instance

This exists mostly for legacy reasons. If you do not want to dependency-inject a custom object, you can configure this package with your secret key globally:

// note the missing .create(...) call
const recaptcha = require('recaptcha-promise')

recaptcha.init({
  secret: 'YOUR_SECRET_KEY' // secret_key and secretKey are also valid
})

You can then use recaptcha exactly the same as above. You can also require it elsewhere and it will still have the secret key ready.

Passing a remote address

If you have the client's remote address available, you can pass it as a second parameter to the verify function.

recaptcha-promise's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar meyfa avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

recaptcha-promise's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • paambaati/codeclimate-action v5.0.0
.github/workflows/release-please.yml
  • google-github-actions/release-please-action v4
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • axios ^1.6.2
  • @meyfa/eslint-config 5.1.0
  • @types/mocha 10.0.6
  • @types/node 20.11.0
  • axios-mock-adapter 1.21.5
  • c8 9.0.0
  • eslint 8.56.0
  • mocha 10.2.0
  • ts-node 10.9.2
  • typescript 5.3.3
  • node >=18.16.1

  • Check this box to trigger a request for Renovate to run again on this repository

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.