mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 08:10:28 +09:00
클라이언트 등록시 검증키도 등록하도록 변경 (WiP)
This commit is contained in:
1 parent
679b223346
commit
4f20d2edbf
6 files changed
+140
-35
No files matched your search
@@ -12,12 +12,18 @@ export const POST: RequestHandler = async ({ request, cookies, getClientAddress
|
||||
|
||||
const zodRes = z
|
||||
.object({
|
||||
pubKey: z.string().base64().nonempty(),
|
||||
encPubKey: z.string().base64().nonempty(),
|
||||
sigPubKey: z.string().base64().nonempty(),
|
||||
})
|
||||
.safeParse(await request.json());
|
||||
if (!zodRes.success) error(400, "Invalid request body");
|
||||
const { pubKey } = zodRes.data;
|
||||
const { encPubKey, sigPubKey } = zodRes.data;
|
||||
|
||||
const challenge = await registerUserClient(userId, getClientAddress(), pubKey.trim());
|
||||
const { challenge } = await registerUserClient(
|
||||
userId,
|
||||
getClientAddress(),
|
||||
encPubKey.trim(),
|
||||
sigPubKey.trim(),
|
||||
);
|
||||
return json({ challenge });
|
||||
};
|
||||
@@ -13,11 +13,12 @@ export const POST: RequestHandler = async ({ request, cookies, getClientAddress
|
||||
const zodRes = z
|
||||
.object({
|
||||
answer: z.string().base64().nonempty(),
|
||||
sigAnswer: z.string().base64().nonempty(),
|
||||
})
|
||||
.safeParse(await request.json());
|
||||
if (!zodRes.success) error(400, "Invalid request body");
|
||||
const { answer } = zodRes.data;
|
||||
const { answer, sigAnswer } = zodRes.data;
|
||||
|
||||
await verifyUserClient(userId, getClientAddress(), answer.trim());
|
||||
await verifyUserClient(userId, getClientAddress(), answer.trim(), sigAnswer.trim());
|
||||
return text("Client verified", { headers: { "Content-Type": "text/plain" } });
|
||||
};
|
||||
Reference in new issue
Block a user