mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
/api/mek/register, /api/mek/share Endpoint 삭제 및 MEK 서명 매커니즘 구현
2025년 첫 커밋! Happy New Year~
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
import { text } from "@sveltejs/kit";
|
||||
import { z } from "zod";
|
||||
import { authorize } from "$lib/server/modules/auth";
|
||||
import { parseSignedRequest } from "$lib/server/modules/crypto";
|
||||
import { registerNewActiveMek } from "$lib/server/services/mek";
|
||||
import type { RequestHandler } from "@sveltejs/kit";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, cookies }) => {
|
||||
const { userId, clientId } = await authorize(cookies, "activeClient");
|
||||
const { meks } = await parseSignedRequest(
|
||||
clientId,
|
||||
await request.json(),
|
||||
z.object({
|
||||
meks: z.array(
|
||||
z.object({
|
||||
clientId: z.number().int().positive(),
|
||||
mek: z.string().base64().nonempty(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await registerNewActiveMek(
|
||||
userId,
|
||||
clientId,
|
||||
meks.map(({ clientId, mek }) => ({
|
||||
clientId,
|
||||
encMek: mek,
|
||||
})),
|
||||
);
|
||||
return text("MEK registered", { headers: { "Content-Type": "text/plain" } });
|
||||
};
|
||||
@@ -11,14 +11,15 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
|
||||
error(403, "Forbidden");
|
||||
}
|
||||
|
||||
const { mek } = await parseSignedRequest(
|
||||
const { mek, mekSig } = await parseSignedRequest(
|
||||
clientId,
|
||||
await request.json(),
|
||||
z.object({
|
||||
mek: z.string().base64().nonempty(),
|
||||
mekSig: z.string().base64().nonempty(),
|
||||
}),
|
||||
);
|
||||
|
||||
await registerInitialActiveMek(userId, clientId, mek);
|
||||
await registerInitialActiveMek(userId, clientId, mek, mekSig);
|
||||
return text("MEK registered", { headers: { "Content-Type": "text/plain" } });
|
||||
};
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import { text } from "@sveltejs/kit";
|
||||
import { z } from "zod";
|
||||
import { authorize } from "$lib/server/modules/auth";
|
||||
import { parseSignedRequest } from "$lib/server/modules/crypto";
|
||||
import { shareMeksForNewClient } from "$lib/server/services/mek";
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, cookies }) => {
|
||||
const { userId, clientId } = await authorize(cookies, "activeClient");
|
||||
const { targetId, meks } = await parseSignedRequest(
|
||||
clientId,
|
||||
await request.json(),
|
||||
z.object({
|
||||
targetId: z.number().int().positive(),
|
||||
meks: z.array(
|
||||
z.object({
|
||||
version: z.number().int().positive(),
|
||||
mek: z.string().base64().nonempty(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await shareMeksForNewClient(
|
||||
userId,
|
||||
targetId,
|
||||
meks.map(({ version, mek }) => ({ version, encMek: mek })),
|
||||
);
|
||||
return text("MEK shared", { headers: { "Content-Type": "text/plain" } });
|
||||
};
|
||||
Reference in New Issue
Block a user