Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

auth: unlink auth.json on logout instead of truncating

Raine Virta36157fd5f5b5
diff --git a/src/auth/token-store.ts b/src/auth/token-store.ts
index 900bd67..83c8527 100644
--- a/src/auth/token-store.ts
+++ b/src/auth/token-store.ts
@@ -1,4 +1,4 @@
-import { mkdir, readFile, writeFile, chmod } from "node:fs/promises"
+import { mkdir, readFile, writeFile, chmod, unlink } from "node:fs/promises"
import { dirname, join } from "node:path"
import { homedir } from "node:os"
@@ -34,9 +34,9 @@ export async function saveAuth(auth: StoredAuth): Promise<void> {
export async function clearAuth(): Promise<void> {
try {
- await writeFile(FILE, "", "utf8")
- } catch {
- // noop
+ await unlink(FILE)
+ } catch (err: any) {
+ if (err?.code !== "ENOENT") throw err
}
}