mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 23:18:48 +00:00
/api/client/[id]/key Endpoint 삭제 및 프론트엔드와의 Zod 스키마 공유 구현
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { Button, TextButton } from "$lib/components/buttons";
|
||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
||||
import { TextInput } from "$lib/components/inputs";
|
||||
import { refreshToken } from "$lib/hooks/callAPI";
|
||||
import { refreshToken } from "$lib/hooks/callApi";
|
||||
import { clientKeyStore, masterKeyStore } from "$lib/stores";
|
||||
import { requestLogin, requestTokenUpgrade, requestMasterKeyDownload } from "./service";
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { exportRSAKeyToBase64 } from "$lib/modules/crypto";
|
||||
import type { LoginRequest } from "$lib/server/schemas";
|
||||
import { requestTokenUpgrade as requestTokenUpgradeInternal } from "$lib/services/auth";
|
||||
import { requestClientRegistration } from "$lib/services/key";
|
||||
import type { ClientKeys } from "$lib/stores";
|
||||
@@ -11,7 +12,7 @@ export const requestLogin = async (email: string, password: string) => {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
body: JSON.stringify({ email, password } satisfies LoginRequest),
|
||||
});
|
||||
return res.ok;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { callAPI } from "$lib/hooks";
|
||||
import { callSignedPostApi } from "$lib/hooks";
|
||||
import { storeClientKey } from "$lib/indexedDB";
|
||||
import { encodeToBase64, signRequest, signMasterKeyWrapped } from "$lib/modules/crypto";
|
||||
import { encodeToBase64, signMasterKeyWrapped } from "$lib/modules/crypto";
|
||||
import type { InitialMasterKeyRegisterRequest } from "$lib/server/schemas";
|
||||
import type { ClientKeys } from "$lib/stores";
|
||||
|
||||
export { requestTokenUpgrade } from "$lib/services/auth";
|
||||
@@ -45,18 +46,13 @@ export const requestInitialMasterKeyRegistration = async (
|
||||
masterKeyWrapped: ArrayBuffer,
|
||||
signKey: CryptoKey,
|
||||
) => {
|
||||
const res = await callAPI("/api/mek/register/initial", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
const res = await callSignedPostApi<InitialMasterKeyRegisterRequest>(
|
||||
"/api/mek/register/initial",
|
||||
{
|
||||
mek: encodeToBase64(masterKeyWrapped),
|
||||
mekSig: await signMasterKeyWrapped(1, masterKeyWrapped, signKey),
|
||||
},
|
||||
body: await signRequest(
|
||||
{
|
||||
mek: encodeToBase64(masterKeyWrapped),
|
||||
mekSig: await signMasterKeyWrapped(1, masterKeyWrapped, signKey),
|
||||
},
|
||||
signKey,
|
||||
),
|
||||
});
|
||||
signKey,
|
||||
);
|
||||
return res.ok || res.status === 409;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user