@captcha-pro/core
v2.2.0
Published
Core library for captcha-pro - framework agnostic behavioral captcha
Maintainers
Readme
@captcha-pro/core
Core package for Captcha Pro - A lightweight, framework-agnostic behavioral captcha library.
Installation
pnpm add @captcha-pro/coreUsage
Slider Captcha
import { SliderCaptcha } from '@captcha-pro/core'
const captcha = new SliderCaptcha({
el: '#captcha',
width: 300,
height: 170,
precision: 5,
onSuccess: () => console.log('Passed!'),
onFail: () => console.log('Failed!')
})
// API
captcha.refresh()
captcha.reset()
captcha.destroy()
captcha.getData()
captcha.getStatistics()Click Captcha
import { ClickCaptcha } from '@captcha-pro/core'
const captcha = new ClickCaptcha({
el: '#captcha',
width: 300,
height: 170,
count: 3,
onSuccess: () => console.log('Passed!')
})Popup Captcha
import { PopupCaptcha } from '@captcha-pro/core'
const popup = new PopupCaptcha({
trigger: '#submit-btn',
type: 'slider',
onSuccess: () => console.log('Passed!')
})
popup.show()
popup.hide()Invisible Captcha
import { InvisibleCaptcha } from '@captcha-pro/core'
const captcha = new InvisibleCaptcha({
el: '#submit-btn',
trigger: 'click',
riskAssessment: { threshold: 0.7 },
onSuccess: () => form.submit()
})Security
import { aesEncrypt, aesDecrypt, decryptCaptchaData, validateTimestamp } from '@captcha-pro/core'
// Encryption
const encrypted = await aesEncrypt(data, secretKey)
const decrypted = await aesDecrypt(encrypted, secretKey)
// Timestamp validation
if (validateTimestamp(timestamp, 60000)) {
// Valid
}API Reference
See main README for complete API documentation.
License
MIT
