Skip to content

IvanAdmaers/captcha-verifer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Verification your HCaptcha or ReCaptcha is easy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published