Skip to content

Adscore/uncaptcha-client-libs-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnCaptcha Node Lib

A simple and free CAPTCHA solution easy to integrate and use by developers and non-developers alike.

How to install

Requires NodeJS >=8.0

npm i @adscore/uncaptcha

How to use

  1. Go to uncaptcha https://uncaptcha.com/
  2. Generate private and public seed.
  3. Follow instructions on https://uncaptcha.com/ to implement captcha in the frontend
  4. In NodeJs:
const { UnCaptchaService } = require("@adscore/uncaptcha");

try {
  // UnCaptcha will add hidden input to the form with name 'uncaptcha-token'
  const captcha = "<UNCAPTCHA_TOKEN_FROM_REQUEST>";
  const visitorUserAgent = "<OPTIONAL_VISITOR_USER_AGENT>";
  const visitorIp = "<OPTIONAL_VISITOR_IP>";
  const unCaptchaService = new UnCaptchaService("<PRIVATE_SEED>");

  await unCaptchaService.verify(captcha, visitorUserAgent, visitorIp);
} catch (error) {
  /**
   * Throws object:
   * {
   *   statusCode: 400,
   *   message: "Invalid Request"
   * }
   */
  console.log(error);
}

Possible errors:

Request Failed

Something went wrong on our side, please create an issue in GitHub.

{
  statusCode: 503,
  message: "Request Failed"
}

Invalid Request

Something is wrong with the data, check if you sending captcha without additional characters and if visitor IP and User Agent are correct.

It is also possible that visitor is trying to forge the request, this error will be returned for this situation.

{
  statusCode: 400,
  message: "Invalid Request"
}

Expired Request

Captcha Expired, user need to use captcha again.

{
  statusCode: 410,
  message: "Expired Request"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published