behavioral-captcha
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

node-behavioral-captcha npm GitHub

This is a simple behavioral captcha for node.js. (Based on @napi-rs/canvas)

Screenshots

Selection Captcha

selection

Calculation Captcha

calculation

Installation

npm install behavioral-captcha

Usage

import { createSelectionCaptchaGenerator } from 'behavioral-captcha'

/*
const config = {
  size: { width: 300, height: 240 },
  thumbSize: { width: 150, height: 40 },
  textColors: ['#000', '#333', '#666', '#999', '#ccc', '#fff'],
  thumbTextColors: ['#000', '#333', '#666', '#999', '#ccc', '#fff'],
  fontSize: [30, 38],
  thumbFontSize: [24, 30],
  length: [5, 7],
  checkLength: [2, 4],
  thumbBackgroundColor: '#fff',
  chars: defaultcChars,
  fonts: ['Arial', { path: 'SomeFont.ttf', name: 'SomeFont' }],
  backgroundImages: ['image1.jpg', 'image2.jpg'],
  angles: [[0, 15]],
  quality: 80
}
*/
const generator = await createSelectionCaptchaGenerator()

const captcha = await generator.generate()
/*
{
  image: Buffer,
  thumb: Buffer,
  dots: Array<{ x: number, y: number }>,
}
*/

console.log(captcha)

console.log(await generator.verify([[13, 67], [78, 143]], captcha.dots)) // true

Author

Shirasawa

License

MIT

Package Sidebar

Install

npm i behavioral-captcha

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

5.72 MB

Total Files

30

Last publish

Collaborators

  • ncbql