mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
hook, store 리네이밍
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { callAPI } from "$lib/hooks";
|
||||
import { accessToken } from "$lib/stores/auth";
|
||||
import { accessTokenStore } from "$lib/stores";
|
||||
|
||||
export const requestLogin = async (email: string, password: string) => {
|
||||
const res = await callAPI("/api/auth/login", {
|
||||
@@ -16,6 +16,6 @@ export const requestLogin = async (email: string, password: string) => {
|
||||
const data = await res.json();
|
||||
const token = data.accessToken as string;
|
||||
|
||||
accessToken.set(token);
|
||||
accessTokenStore.set(token);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { get } from "svelte/store";
|
||||
import { keyExportState } from "$lib/hooks/goto";
|
||||
import { keyExportState } from "$lib/hooks/gotoStateful";
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
const state = get(keyExportState);
|
||||
const state = keyExportState.get();
|
||||
if (!state) {
|
||||
error(403, "Forbidden");
|
||||
}
|
||||
|
||||
keyExportState.set(null);
|
||||
return state;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Button, TextButton } from "$lib/components/buttons";
|
||||
import { TitleDiv, BottomDiv } from "$lib/components/divs";
|
||||
import { goto } from "$lib/hooks";
|
||||
import { gotoStateful } from "$lib/hooks";
|
||||
import Order from "./Order.svelte";
|
||||
import { generateKeyPair } from "./service";
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
];
|
||||
|
||||
const generate = async () => {
|
||||
await goto("/key/export", await generateKeyPair());
|
||||
// TODO
|
||||
await gotoStateful("/key/export", await generateKeyPair());
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { storeKeyPairIntoIndexedDB } from "$lib/indexedDB";
|
||||
import { pubKey, privKey } from "$lib/stores/key";
|
||||
import { pubKeyStore, privKeyStore } from "$lib/stores";
|
||||
|
||||
type KeyType = "public" | "private";
|
||||
|
||||
@@ -44,8 +44,8 @@ export const generateKeyPair = async () => {
|
||||
const keyPair = await generateRSAKeyPair();
|
||||
const privKeySecure = await makeRSAKeyNonextractable(keyPair.privateKey, "private");
|
||||
|
||||
pubKey.set(keyPair.publicKey);
|
||||
privKey.set(privKeySecure);
|
||||
pubKeyStore.set(keyPair.publicKey);
|
||||
privKeyStore.set(privKeySecure);
|
||||
|
||||
await storeKeyPairIntoIndexedDB(keyPair.publicKey, privKeySecure);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user