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