mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
강제 로그인 기능 추가
This commit is contained in:
@@ -11,12 +11,14 @@ export const requestSessionUpgrade = async (
|
||||
decryptKey: CryptoKey,
|
||||
verifyKeyBase64: string,
|
||||
signKey: CryptoKey,
|
||||
force = false,
|
||||
) => {
|
||||
let res = await callPostApi<SessionUpgradeRequest>("/api/auth/upgradeSession", {
|
||||
encPubKey: encryptKeyBase64,
|
||||
sigPubKey: verifyKeyBase64,
|
||||
});
|
||||
if (!res.ok) return false;
|
||||
if (res.status === 403) return [false, "Unregistered client"] as const;
|
||||
else if (!res.ok) return [false] as const;
|
||||
|
||||
const { id, challenge }: SessionUpgradeResponse = await res.json();
|
||||
const answer = await decryptChallenge(challenge, decryptKey);
|
||||
@@ -25,6 +27,13 @@ export const requestSessionUpgrade = async (
|
||||
res = await callPostApi<SessionUpgradeVerifyRequest>("/api/auth/upgradeSession/verify", {
|
||||
id,
|
||||
answerSig: encodeToBase64(answerSig),
|
||||
force,
|
||||
});
|
||||
if (res.status === 409) return [false, "Already logged in"] as const;
|
||||
else return [res.ok] as const;
|
||||
};
|
||||
|
||||
export const requestLogout = async () => {
|
||||
const res = await callPostApi("/api/auth/logout");
|
||||
return res.ok;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user