From 09d800eee9d4e3b4d4d152da631bb2201533cc7d Mon Sep 17 00:00:00 2001 From: art Date: Fri, 30 Jan 2026 15:37:32 +0900 Subject: [PATCH] Add session request and lookup type definitions. Updated requestSessionId and getSessionIdForUser functions to include return type annotations for improved type safety and clarity in session management logic. --- src/main/main.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 09f28f6..1d4f6ee 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -79,6 +79,14 @@ type SessionRecord = { updatedAt: number; }; +type SessionRequestResult = + | { ok: true; sessionId: string; url: string } + | { ok: false; error: string; url: string }; + +type SessionLookupResult = + | { ok: true; sessionId: string; url: string; source: "cache" | "login" } + | { ok: false; error: string; url: string }; + type InstallStep = { name: string; result: CommandRunResult; @@ -936,7 +944,7 @@ const postText = async (path: string, body: unknown) => { }); }; -const requestSessionId = async (username: string) => { +const requestSessionId = async (username: string): Promise => { const loginResult = await postText("/launcher/profile/login", { username }); if (!loginResult.ok) { return { ok: false, error: loginResult.error ?? "login_failed", url: loginResult.url }; @@ -952,7 +960,7 @@ const requestSessionId = async (username: string) => { const isSessionInvalidStatus = (status?: number) => status === 401 || status === 403; -const getSessionIdForUser = async (username: string) => { +const getSessionIdForUser = async (username: string): Promise => { const cached = await readSessionRecord(); if (cached && cached.username === username && !isSessionExpired(cached)) { await refreshSessionRecord({ username: cached.username, sessionId: cached.sessionId });