hook, store 리네이밍

This commit is contained in:
static
2024-12-27 21:50:04 +09:00
parent 400438c395
commit 1aafe126d6
11 changed files with 61 additions and 48 deletions

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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>

View File

@@ -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);