You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
594 B
18 lines
594 B
import svgCaptcha from "svg-captcha";
|
|
import { captchaCreate } from "./store";
|
|
|
|
/** 易混淆字符已剔除,长度 5 */
|
|
const CHAR_PRESET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
|
|
export function createCaptchaChallenge(): { captchaId: string; imageSvg: string } {
|
|
const { data: imageSvg, text } = svgCaptcha.create({
|
|
size: 5,
|
|
noise: 2,
|
|
color: true,
|
|
charPreset: CHAR_PRESET,
|
|
background: "#f4f4f5",
|
|
});
|
|
const answerNormalized = text.toLowerCase();
|
|
const { captchaId } = captchaCreate(answerNormalized);
|
|
return { captchaId, imageSvg };
|
|
}
|
|
|