@better-geetest/gt4-client
v0.1.0
Published
社区维护的极验行为验证第四代的客户端 SDK
Readme
@better-geetest/gt4-client

社区维护的 极验行为验证第四代 的客户端 SDK。匹配官方 SDK v4.2.1。
安装
npm install @better-geetest/gt4-client # 或其他包管理器使用
import { createCaptcha } from '@better-geetest/gt4-client';
const captcha = await createCaptcha({
captchaId: 'your-captcha-id',
product: 'bind',
riskType: 'slide',
});
captcha.onSuccess(async () => {
const credentials = captcha.getValidate();
if (!credentials)
return;
const result = await fetch('/api/verify', {
body: JSON.stringify(credentials),
headers: { 'content-type': 'application/json' },
method: 'POST',
});
// ...
});
document.querySelector('#verify')?.addEventListener('click', () => captcha.showBox());[!IMPORTANT]
注意:一个页面只能初始化一个 GeeTest CAPTCHA 实例!
同一页面多次调用
createCaptcha()会导致竞态条件和安全风险。如果确实需要多个验证场景,请使用reset()重置现有实例或复用验证码控制器。SSR/SSG 环境下请确保只在客户端浏览器中初始化。
