사소한 리팩토링 2

This commit is contained in:
static
2025-12-26 15:45:03 +09:00
parent d94d14cf83
commit c9d4b10356
16 changed files with 54 additions and 84 deletions

View File

@@ -1,6 +1,6 @@
import { TRPCClientError } from "@trpc/client";
import { encodeToBase64, decryptChallenge, signMessageRSA } from "$lib/modules/crypto";
import { useTRPC } from "$trpc/client";
import { trpc } from "$trpc/client";
export const requestSessionUpgrade = async (
encryptKeyBase64: string,
@@ -9,10 +9,9 @@ export const requestSessionUpgrade = async (
signKey: CryptoKey,
force = false,
) => {
const trpc = useTRPC();
let id, challenge;
try {
({ id, challenge } = await trpc.auth.upgrade.mutate({
({ id, challenge } = await trpc().auth.upgrade.mutate({
encPubKey: encryptKeyBase64,
sigPubKey: verifyKeyBase64,
}));
@@ -26,7 +25,7 @@ export const requestSessionUpgrade = async (
const answerSig = await signMessageRSA(answer, signKey);
try {
await trpc.auth.verifyUpgrade.mutate({
await trpc().auth.verifyUpgrade.mutate({
id,
answerSig: encodeToBase64(answerSig),
force,
@@ -42,9 +41,8 @@ export const requestSessionUpgrade = async (
};
export const requestLogout = async () => {
const trpc = useTRPC();
try {
await trpc.auth.logout.mutate();
await trpc().auth.logout.mutate();
return true;
} catch {
// TODO: Error Handling