captcha-verifer

Verification your ReCaptcha or HCaptcha is easy

Usage no npm install needed!

<script type="module">
  import captchaVerifer from 'https://cdn.skypack.dev/captcha-verifer';
</script>

README

captcha-verifer

Captcha Verifer

Verification your ReCaptcha or HCaptcha is easy

Advantages

  • Without any dependencies
  • Less than 5 kb
  • ES6
  • Verify two types of captcha (ReCaptcha and HCaptcha)
  • Ease to use

Installation

npm i captcha-verifer

Usage

const Captcha = require('captcha-verifer');
Captcha.verifer({
  type: 'recaptcha', // Required (recaptcha or hcaptcha)
  secretKey: 'superSecret', // Required
  token: 'TOKEN (Captcha response)', // Required
  ip: '47.16.0.0' // Optional
})
.then((captcha) => {
  if (!captcha.success) return; // Captcha not solved

  /* All good. There is your super code! */
})
.catch((e) => console.log(e));

Or

(async () => {
  try {
    const captcha = await Captcha.verifer({
      type: 'hcaptcha', // Required (recaptcha or hcaptcha)
      secretKey: 'superSecret', // Required
      token: 'TOKEN (Captcha response)', // Required
      ip: '47.16.0.0' // Optional
    });

    if (!captcha.success) return; // Captcha not solved

    /* Your perfect code here */
  } catch (e) {
    console.log(e);
  }
})();

You can also verify recaptcha 3

Captcha.verifer({
  type: 'recaptcha', // Required (recaptcha or hcaptcha)
  secretKey: 'superSecret', // Required
  token: 'TOKEN (Captcha response)', // Required
  ip: '47.16.0.0' //Optional
})
.then((captcha) => {
  if (!captcha.success || captcha.score <= 0.3) return; // Captcha not solved

  /* Pefect. Go ahead */
})
.catch((e) => console.log(e));

License

MIT