Socket
Socket
Sign inDemoInstall

@tokensuite/react-slider-captcha-v2-core

Package Overview
Dependencies
47
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tokensuite/react-slider-captcha-v2-core

## Installation Backend:


Version published
Weekly downloads
27
decreased by-50%
Maintainers
4
Created
Weekly downloads
 

Readme

Source

@tokensuite/react-slider-captcha-v2-core

Installation

Backend:

npm i @tokensuite/react-slider-captcha-v2-core

Usage

Express:

import {createCaptcha, verifyCaptcha} from '@tokensuite/react-slider-captcha-v2-core'; // or @tokensuite/react-slider-captcha-v2-core/lib/esm

app.get('/captcha/create', function (req, res) {
  sliderCaptcha.create()
    .then(function ({data, solution}) {
      req.session.captcha = solution;
      req.session.save();
      res.status(200).send(data);
    });
});

app.post('/captcha/verify', function (req, res) {
  sliderCaptcha.verify(req.session.captcha, req.body)
    .then(function (verification) {
      if (verification.result === 'success') {
        req.session.token = verification.token;
        req.session.save();
      }
      res.status(200).send(verification);
    });
});

For quick tryout in Next.js api:

import {createCaptcha, verifyCaptcha} from '@tokensuite/react-slider-captcha-v2-core'; // or @tokensuite/react-slider-captcha-v2-core/lib/esm
export let solution: number;

export default async function handler(req: any, res: any) {
  createCaptcha()
    .then((resp: any) => {
      solution = resp.solution;
      res.status(200).send(resp.data);
    })
    .catch((err: any) => {
      res.status(500).send(err);
    });
}

export default async function handler(req: any, res: any) {
  verifyCaptcha(solution, req.body).then(function (verification: any) {
    res.status(200).send(verification);
  });
}

Create captcha options

sliderCaptcha.create({option: value})

NameTypeDefaultDescription
imagebufferrandomly generated patternBackground image used for captcha - resized to 250x150
fillstring#000Color used in overlay of puzzle piece on background
strokestring#fffColor for outline of puzzle piece
strokeWidthstring0.4Puzzle piece outline width
opacitystring0.5Opacity of puzzle piece overlay on background
distortboolfalseApply distortion to the puzzle piece
rotateboolfalseApply a random rotation to the puzzle piece

Verify captcha options

sliderCaptcha.verify(captcha, {response, trail: {x, y}}, {option: value})

NameTypeDefaultDescription
tolerancenumber7Allowed deviation from true captcha value

Inspiration

Slider Captcha - A captcha library for web applications from adrsch (MIT License)

Keywords

FAQs

Last updated on 30 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc