Release 2025-05-19

This commit is contained in:
pluja
2025-05-19 10:19:49 +00:00
parent 046c4559e5
commit 2657f936bc
267 changed files with 0 additions and 49432 deletions

View File

@@ -1,29 +0,0 @@
import { z, type RefinementCtx } from 'astro/zod'
import { CAPTCHA_LENGTH, verifyCaptcha } from './captcha'
export const captchaFormSchemaProperties = {
'captcha-value': z
.string()
.length(CAPTCHA_LENGTH, `Captcha must be ${CAPTCHA_LENGTH.toLocaleString()} characters long`)
.regex(/^[A-Za-z0-9]+$/, 'Captcha must contain only uppercase letters and numbers'),
'captcha-solution-hash': z.string().min(1, 'Missing internal captcha data'),
} as const
export const captchaFormSchemaSuperRefine = (
value: z.infer<z.ZodObject<typeof captchaFormSchemaProperties>>,
ctx: RefinementCtx
) => {
const isValidCaptcha = verifyCaptcha(value['captcha-value'], value['captcha-solution-hash'])
if (!isValidCaptcha) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['captcha-value'],
message: 'Incorrect captcha',
})
}
}
export const captchaFormSchema = z
.object(captchaFormSchemaProperties)
.superRefine(captchaFormSchemaSuperRefine)