mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 20:10:33 +00:00
25 lines
592 B
TypeScript
25 lines
592 B
TypeScript
import { z } from 'zod';
|
|
import { useChallenge } from '~/utils/challenge';
|
|
|
|
const startSchema = z.object({
|
|
captchaToken: z.string().optional(),
|
|
});
|
|
|
|
export default defineEventHandler(async event => {
|
|
const body = await readBody(event);
|
|
|
|
const result = startSchema.safeParse(body);
|
|
if (!result.success) {
|
|
throw createError({
|
|
statusCode: 400,
|
|
message: 'Invalid request body',
|
|
});
|
|
}
|
|
|
|
const challenge = useChallenge();
|
|
const challengeCode = await challenge.createChallengeCode('registration', 'mnemonic');
|
|
|
|
return {
|
|
challenge: challengeCode.code,
|
|
};
|
|
});
|