From 428b6e0dee28d58db9bf1b8cbced024b7f0de49f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 13:07:44 +0000 Subject: [PATCH] refactor(web): share creds json reader --- src/web/auth-store.ts | 2 +- src/web/session.ts | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/web/auth-store.ts b/src/web/auth-store.ts index e98e48b67..53af4469c 100644 --- a/src/web/auth-store.ts +++ b/src/web/auth-store.ts @@ -33,7 +33,7 @@ export function hasWebCredsSync(authDir: string): boolean { } } -function readCredsJsonRaw(filePath: string): string | null { +export function readCredsJsonRaw(filePath: string): string | null { try { if (!fsSync.existsSync(filePath)) { return null; diff --git a/src/web/session.ts b/src/web/session.ts index c02f59388..a9129626f 100644 --- a/src/web/session.ts +++ b/src/web/session.ts @@ -15,6 +15,7 @@ import { ensureDir, resolveUserPath } from "../utils.js"; import { VERSION } from "../version.js"; import { maybeRestoreCredsFromBackup, + readCredsJsonRaw, resolveDefaultWebAuthDir, resolveWebCredsBackupPath, resolveWebCredsPath, @@ -43,21 +44,6 @@ function enqueueSaveCreds( }); } -function readCredsJsonRaw(filePath: string): string | null { - try { - if (!fsSync.existsSync(filePath)) { - return null; - } - const stats = fsSync.statSync(filePath); - if (!stats.isFile() || stats.size <= 1) { - return null; - } - return fsSync.readFileSync(filePath, "utf-8"); - } catch { - return null; - } -} - async function safeSaveCreds( authDir: string, saveCreds: () => Promise | void,