fix(auth): point account-store and token-store directly to ~/.config/hose-use

This commit is contained in:
gitea committed 2026-09-18 11:22:41 +08:00
1 parent c72f07f582
commit 8c444efc85
3 files changed
+14 -19

No files matched your search

+11 -5
View File
@@ -1,12 +1,12 @@
import { readFileSync, writeFileSync, mkdirSync } from "fs";
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import { join, dirname } from "path";
import { homedir } from "os";
import { z } from "zod";
const ACCOUNT_CACHE_PATH = join(
export const ACCOUNT_CACHE_PATH = join(
homedir(),
".cache",
"ekb-mcp",
".config",
"hose-use",
"accounts.json"
);
@@ -38,7 +38,13 @@ export type AccountEntry = z.infer<typeof AccountEntrySchema>;
export type AccountStore = z.infer<typeof AccountStoreSchema>;
function ensureDir(path: string): void {
mkdirSync(dirname(path), { recursive: true });
const dir = dirname(path);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true, mode: 0o700 });
}
try {
chmodSync(dir, 0o700);
} catch {}
}
export function loadAccountStore(): AccountStore {
+1 -12
View File
@@ -10,20 +10,9 @@ export const PRIMARY_TOKEN_CACHE_PATH = join(
"tokens.json"
);
export const LEGACY_TOKEN_CACHE_PATH = join(
homedir(),
".cache",
"ekb-mcp",
"tokens.json"
);
export const TOKEN_CACHE_PATH = PRIMARY_TOKEN_CACHE_PATH;
function resolveTokenCachePath(): string {
if (existsSync(PRIMARY_TOKEN_CACHE_PATH)) {
return PRIMARY_TOKEN_CACHE_PATH;
}
if (existsSync(LEGACY_TOKEN_CACHE_PATH)) {
return LEGACY_TOKEN_CACHE_PATH;
}
return PRIMARY_TOKEN_CACHE_PATH;
}