verify-recaptcha

agent for the verification of recaptcha tokens

Usage no npm install needed!

<script type="module">
  import verifyRecaptcha from 'https://cdn.skypack.dev/verify-recaptcha';
</script>

README

verify-recaptcha

verify-recaptcha is a little library that handles the connection to the google verification backend. Features a optional proxy configuration and a promise backend.

Installation

npm i verify-recaptcha

Usage

const VerifyRecaptcha = require('verify-recaptcha')

let mySecret = '8673cad02e2af7ff5afc00a0b7d2b3a4951ffea74bc245bb0ee8cc7dd03f657'
let myVerification = new VerifyRecaptcha(mySecret)

myVerification.validate('1234545')
    .then(result => console.log('token verified!')
    .catch(error => {
        console.log('verification failed: ' + error.errorCodes.join(',')
    })

With Proxy

The constructor also accepts a proxy configuration in the following form:

{
    "host": "host",
    "port": 1337,                 //optional, defaults to 80
    "username": "myUsername",     //optional
    "password": "myPassword",     //optional, required of username has been set
    "protocol": "https"           //optional, defaults to 'http'
}
const VerifyRecaptcha = require('verify-recaptcha')

let mySecret = '8673cad02e2af7ff5afc00a0b7d2b3a4951ffea74bc245bb0ee8cc7dd03f657'
let myProxyConfig = {host: 'proxyHost'}
let myVerification = new VerifyRecaptcha(mySecret, myProxyConfig)

myVerification.validate('1234545')
    .then(result => console.log('token verified!')
    .catch(error => {
        console.log('verification failed: ' + error.errorCodes.join(',')
    })