mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-15 22:38:47 +00:00
로그인 및 암호 키 등록 이후 클라이언트 승인 대기 페이지로의 자동 리다이렉션 구현
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
import { callAPI } from "$lib/hooks";
|
||||
import { storeMasterKeys } from "$lib/indexedDB";
|
||||
import {
|
||||
decodeFromBase64,
|
||||
exportRSAKey,
|
||||
makeAESKeyNonextractable,
|
||||
unwrapAESKeyUsingRSA,
|
||||
digestSHA256,
|
||||
} from "$lib/modules/crypto";
|
||||
import { masterKeyStore } from "$lib/stores";
|
||||
import { exportRSAKey, digestSHA256 } from "$lib/modules/crypto";
|
||||
|
||||
export { requestMasterKeyDownload } from "$lib/services/key";
|
||||
|
||||
export const generateEncryptKeyFingerprint = async (encryptKey: CryptoKey) => {
|
||||
const { key } = await exportRSAKey(encryptKey);
|
||||
@@ -19,35 +12,3 @@ export const generateEncryptKeyFingerprint = async (encryptKey: CryptoKey) => {
|
||||
.match(/.{1,4}/g)!
|
||||
.join(" ");
|
||||
};
|
||||
|
||||
export const requestMasterKeyDownload = async (decryptKey: CryptoKey) => {
|
||||
const res = await callAPI("/api/mek/list", { method: "GET" });
|
||||
if (!res.ok) return false;
|
||||
|
||||
const data = await res.json();
|
||||
const { meks: masterKeysWrapped } = data as {
|
||||
meks: {
|
||||
version: number;
|
||||
state: "active" | "retired";
|
||||
mek: string;
|
||||
}[];
|
||||
};
|
||||
const masterKeys = await Promise.all(
|
||||
masterKeysWrapped.map(async ({ version, state, mek: masterKeyWrapped }) => ({
|
||||
version,
|
||||
state,
|
||||
masterKey: await makeAESKeyNonextractable(
|
||||
await unwrapAESKeyUsingRSA(decodeFromBase64(masterKeyWrapped), decryptKey),
|
||||
),
|
||||
})),
|
||||
);
|
||||
|
||||
await storeMasterKeys(
|
||||
masterKeys.map(({ version, state, masterKey }) => ({ version, state, key: masterKey })),
|
||||
);
|
||||
masterKeyStore.set(
|
||||
new Map(masterKeys.map(({ version, state, masterKey }) => [version, { state, masterKey }])),
|
||||
);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user