mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-15 22:38:47 +00:00
RSA 키 페어 생성 구현
This commit is contained in:
@@ -1 +0,0 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
||||
30
src/lib/indexedDB.ts
Normal file
30
src/lib/indexedDB.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Dexie, type EntityTable } from "dexie";
|
||||
|
||||
interface ClientKeyPair {
|
||||
type: "publicKey" | "privateKey";
|
||||
key: CryptoKey;
|
||||
}
|
||||
|
||||
const keyStore = new Dexie("keyStore") as Dexie & {
|
||||
clientKeyPairs: EntityTable<ClientKeyPair, "type">;
|
||||
};
|
||||
|
||||
keyStore.version(1).stores({
|
||||
clientKeyPairs: "type",
|
||||
});
|
||||
|
||||
export const getKeyPairFromIndexedDB = async () => {
|
||||
const pubKey = await keyStore.clientKeyPairs.get("publicKey");
|
||||
const privKey = await keyStore.clientKeyPairs.get("privateKey");
|
||||
return {
|
||||
pubKey: pubKey?.key ?? null,
|
||||
privKey: privKey?.key ?? null,
|
||||
};
|
||||
};
|
||||
|
||||
export const storeKeyPairIntoIndexedDB = async (pubKey: CryptoKey, privKey: CryptoKey) => {
|
||||
await keyStore.clientKeyPairs.bulkPut([
|
||||
{ type: "publicKey", key: pubKey },
|
||||
{ type: "privateKey", key: privKey },
|
||||
]);
|
||||
};
|
||||
Reference in New Issue
Block a user