refactor(web): share creds json reader

This commit is contained in:
Peter Steinberger
2026-02-15 13:07:44 +00:00
parent 8a4f9f168b
commit 428b6e0dee
2 changed files with 2 additions and 16 deletions

View File

@@ -33,7 +33,7 @@ export function hasWebCredsSync(authDir: string): boolean {
} }
} }
function readCredsJsonRaw(filePath: string): string | null { export function readCredsJsonRaw(filePath: string): string | null {
try { try {
if (!fsSync.existsSync(filePath)) { if (!fsSync.existsSync(filePath)) {
return null; return null;

View File

@@ -15,6 +15,7 @@ import { ensureDir, resolveUserPath } from "../utils.js";
import { VERSION } from "../version.js"; import { VERSION } from "../version.js";
import { import {
maybeRestoreCredsFromBackup, maybeRestoreCredsFromBackup,
readCredsJsonRaw,
resolveDefaultWebAuthDir, resolveDefaultWebAuthDir,
resolveWebCredsBackupPath, resolveWebCredsBackupPath,
resolveWebCredsPath, 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( async function safeSaveCreds(
authDir: string, authDir: string,
saveCreds: () => Promise<void> | void, saveCreds: () => Promise<void> | void,