0.0.3 • Published 2 months ago

behavioral-captcha v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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

0.0.3

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago

0.0.0

2 months ago