New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

captcha-kit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

captcha-kit

Advanced front-end captcha library with graphic, slider, puzzle, invisible modes

latest
npmnpm
Version
1.2.2
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Smart Captcha - Smart Verification Code Library

A powerful and easy-to-use front-end captcha library that supports multiple captcha types, including graphic captcha, slider captcha, and puzzle captcha.

Features

  • 🎨 Graphic Captcha: Support custom character set, interference lines, interference points, fonts, etc.
  • 🎯 Slider Captcha: Simple and intuitive sliding verification, support custom styles and thresholds.
  • 🧩 Puzzle Captcha: Multiple shapes of puzzle verification, support custom background images.
  • 📱 Responsive Design: Adapt to different screen sizes.
  • 🎨 Highly Customizable: Support custom colors, sizes, texts, etc.
  • 🔧 Easy to Integrate: Simple API, quickly integrate into existing projects.
  • 📦 Lightweight: No external dependencies, small size.

Installation

npm install smart-captcha

Quick Start

Import Library

import { createCaptcha } from 'smart-captcha';

1. Graphic Captcha

Create a graphic captcha instance, supporting custom character length, interference lines, interference points, etc. Verify user input by calling the verify() method, and refresh the captcha using the refresh() method.

2. Slider Captcha

Create a slider captcha instance, where users complete verification by sliding the slider. Supports custom slider styles, track colors, and hint text.

3. Puzzle Captcha

Create a puzzle captcha instance, where users need to drag the slider to move the puzzle piece to the correct position. Supports custom background images, puzzle shapes, and sizes.

API Documentation

createCaptcha(options)

Factory function to create captcha instances.

Parameters

ParameterTypeDescription
optionsCaptchaOptionsCaptcha configuration options

Returns

Captcha instance.

CaptchaOptions

Unified interface for captcha configuration options, specific options vary depending on mode.

Common Events

EventTypeDescription
onSuccessFunctionVerification success callback
onFailFunctionVerification failure callback
onRefreshFunctionCaptcha refresh callback
onTimeoutFunctionCaptcha timeout callback

Graphic Captcha Options (GraphicCaptchaOptions)

OptionTypeDefaultDescription
containerHTMLElement-Captcha container element
lengthnumber4Captcha character length
lineCountnumber6Number of interference lines
dotCountnumber20Number of interference points
fontSizenumber20Font size
charsstring'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'Optional character set
strictCasebooleanfalseWhether to strictly check case
refreshOnFailbooleanfalseWhether to refresh when verification fails
fontsstring[]-Optional font list
timeoutnumber60000Captcha expiration time (milliseconds)

Slider Captcha Options (SliderCaptchaOptions)

OptionTypeDefaultDescription
containerHTMLElement-Captcha container element
thresholdnumber0.95Success threshold (percentage)
resetOnFailbooleantrueWhether to reset after verification failure
timeoutnumber60000Timeout time (milliseconds)
sliderColorstring'#409eff'Slider color
trackColorstring'#f5f7fa'Track color
textColorstring'#606266'Text color
hintTextstring'Slide to the right to complete verification'Default hint text
successColorstring'#67c23a'Success color
failColorstring'#f35445'Failure color
successTextstring'Verification passed'Success text
failTextstring'Verification failed, please try again'Failure text

Puzzle Captcha Options (PuzzleCaptchaOptions)

OptionTypeDefaultDescription
containerHTMLElement-Captcha container element
widthnumber300Container width
heightnumber200Container height
puzzleWidthnumber50Puzzle block width
puzzleHeightnumber50Puzzle block height
backgroundImagestringstring[]-
shape'triangle''square''hexagon'
thresholdnumber5Success threshold
resetOnFailbooleantrueWhether to reset after failure
showAsPopupbooleanfalseWhether to show as popup
textColorstring'#606266'Text color
successColorstring'#67c23a'Success color
sliderColorstring'#409eff'Slider initial color
mismatchColorstring'#f35248'Slider mismatch color
hintTextstring'Drag the slider to complete the puzzle'Default hint text
failTextstring'Verification failed, please try again'Failure text
successTextstring'Verification passed'Success text

Captcha Instance Methods

Graphic Captcha Instance

MethodDescription
verify(input: stringnumber): Promise
refresh(): PromiseRefresh captcha
destroy(): voidDestroy captcha instance

Slider Captcha Instance

MethodDescription
refresh(): voidRefresh captcha
destroy(): voidDestroy captcha instance
getVerified(): booleanGet verification status

Puzzle Captcha Instance

MethodDescription
refresh(): voidRefresh captcha
destroy(): voidDestroy captcha instance

Browser Compatibility

  • Chrome (Recommended)
  • Firefox
  • Safari
  • Edge

Development

Install Dependencies

npm install

Build

npm run build

Run Examples

npm start

This will open the test page in the browser, showing usage examples of various captchas.

Examples

Check the example files in the test directory:

  • graphic.html - Graphic captcha example
  • slider.html - Slider captcha example
  • puzzle.html - Puzzle captcha example

License

MIT License

Changelog

1.0.0

  • Initial release
  • Support graphic captcha, slider captcha and puzzle captcha
  • Support responsive design
  • Support high customization

Contribution

Welcome to submit Issues and Pull Requests!

Keywords

captcha

FAQs

Package last updated on 23 Dec 2025

Did you know?

Socket

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