From 00ca302c448ed0d655e700b2264cec1e0498dc20 Mon Sep 17 00:00:00 2001 From: kaghni Date: Mon, 13 Apr 2026 16:43:03 -0700 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20add=20logout=20command=20=E2=80=94?= =?UTF-8?q?=20removes=20credentials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- claude-code/bundle/commands/auth-login.js | 15 ++++++++++++++- src/commands/auth-login.ts | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/claude-code/bundle/commands/auth-login.js b/claude-code/bundle/commands/auth-login.js index 0b2edef..6bd095a 100755 --- a/claude-code/bundle/commands/auth-login.js +++ b/claude-code/bundle/commands/auth-login.js @@ -722,8 +722,21 @@ async function main() { } break; } + case "logout": { + const { existsSync: existsSync3, unlinkSync } = await import("node:fs"); + const { join: join4 } = await import("node:path"); + const { homedir: homedir4 } = await import("node:os"); + const credFile = join4(homedir4(), ".deeplake", "credentials.json"); + if (existsSync3(credFile)) { + unlinkSync(credFile); + console.log("Logged out. Credentials removed."); + } else { + console.log("Not logged in."); + } + break; + } default: - console.log("Commands: login, whoami, org list, org switch, workspaces, workspace, sessions prune, invite, members, remove, autoupdate"); + console.log("Commands: login, logout, whoami, org list, org switch, workspaces, workspace, sessions prune, invite, members, remove, autoupdate"); } } main().catch((e) => { diff --git a/src/commands/auth-login.ts b/src/commands/auth-login.ts index 29bc677..db26ee1 100644 --- a/src/commands/auth-login.ts +++ b/src/commands/auth-login.ts @@ -5,6 +5,7 @@ * * Usage: * node auth-login.js login — device flow login + * node auth-login.js logout — remove credentials * node auth-login.js org list — list orgs * node auth-login.js org switch — switch org * node auth-login.js workspaces — list workspaces @@ -134,8 +135,22 @@ async function main(): Promise { break; } + case "logout": { + const { existsSync, unlinkSync } = await import("node:fs"); + const { join } = await import("node:path"); + const { homedir } = await import("node:os"); + const credFile = join(homedir(), ".deeplake", "credentials.json"); + if (existsSync(credFile)) { + unlinkSync(credFile); + console.log("Logged out. Credentials removed."); + } else { + console.log("Not logged in."); + } + break; + } + default: - console.log("Commands: login, whoami, org list, org switch, workspaces, workspace, sessions prune, invite, members, remove, autoupdate"); + console.log("Commands: login, logout, whoami, org list, org switch, workspaces, workspace, sessions prune, invite, members, remove, autoupdate"); } } From b3a7a5812c04dc6d32c52333799e8229d92186e7 Mon Sep 17 00:00:00 2001 From: kaghni Date: Mon, 13 Apr 2026 17:08:05 -0700 Subject: [PATCH 2/3] refactor: use deleteCredentials() from auth.ts instead of dynamic imports --- claude-code/bundle/commands/auth-login.js | 16 +++++++++------- src/commands/auth-login.ts | 9 ++------- src/commands/auth.ts | 10 +++++++++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/claude-code/bundle/commands/auth-login.js b/claude-code/bundle/commands/auth-login.js index 6bd095a..ba08f32 100755 --- a/claude-code/bundle/commands/auth-login.js +++ b/claude-code/bundle/commands/auth-login.js @@ -1,7 +1,7 @@ #!/usr/bin/env node // dist/src/commands/auth.js -import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs"; +import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs"; import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; @@ -22,6 +22,13 @@ function saveCredentials(creds) { mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 }); writeFileSync(CREDS_PATH, JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 }); } +function deleteCredentials() { + if (existsSync(CREDS_PATH)) { + unlinkSync(CREDS_PATH); + return true; + } + return false; +} async function apiGet(path, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, @@ -723,12 +730,7 @@ async function main() { break; } case "logout": { - const { existsSync: existsSync3, unlinkSync } = await import("node:fs"); - const { join: join4 } = await import("node:path"); - const { homedir: homedir4 } = await import("node:os"); - const credFile = join4(homedir4(), ".deeplake", "credentials.json"); - if (existsSync3(credFile)) { - unlinkSync(credFile); + if (deleteCredentials()) { console.log("Logged out. Credentials removed."); } else { console.log("Not logged in."); diff --git a/src/commands/auth-login.ts b/src/commands/auth-login.ts index db26ee1..e024af7 100644 --- a/src/commands/auth-login.ts +++ b/src/commands/auth-login.ts @@ -19,7 +19,7 @@ */ import { - login, loadCredentials, saveCredentials, listOrgs, switchOrg, + login, loadCredentials, saveCredentials, deleteCredentials, listOrgs, switchOrg, listWorkspaces, switchWorkspace, inviteMember, listMembers, removeMember, } from "./auth.js"; @@ -136,12 +136,7 @@ async function main(): Promise { } case "logout": { - const { existsSync, unlinkSync } = await import("node:fs"); - const { join } = await import("node:path"); - const { homedir } = await import("node:os"); - const credFile = join(homedir(), ".deeplake", "credentials.json"); - if (existsSync(credFile)) { - unlinkSync(credFile); + if (deleteCredentials()) { console.log("Logged out. Credentials removed."); } else { console.log("Not logged in."); diff --git a/src/commands/auth.ts b/src/commands/auth.ts index d07ca4a..1519f58 100644 --- a/src/commands/auth.ts +++ b/src/commands/auth.ts @@ -3,7 +3,7 @@ * and org/workspace management. */ -import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs"; +import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs"; import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; @@ -60,6 +60,14 @@ export function saveCredentials(creds: Credentials): void { writeFileSync(CREDS_PATH, JSON.stringify({ ...creds, savedAt: new Date().toISOString() }, null, 2), { mode: 0o600 }); } +export function deleteCredentials(): boolean { + if (existsSync(CREDS_PATH)) { + unlinkSync(CREDS_PATH); + return true; + } + return false; +} + // ── JWT Helpers ────────────────────────────────────────────────────────────── export function decodeJwtPayload(token: string): Record | null { From e909d538c71943b8acfca726409f79554e312ba7 Mon Sep 17 00:00:00 2001 From: kaghni Date: Tue, 14 Apr 2026 13:23:11 -0700 Subject: [PATCH 3/3] fix: rebuild bundles (unlinkSync added to auth.ts) --- claude-code/bundle/session-start.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claude-code/bundle/session-start.js b/claude-code/bundle/session-start.js index e022424..600faa9 100755 --- a/claude-code/bundle/session-start.js +++ b/claude-code/bundle/session-start.js @@ -8,7 +8,7 @@ import { execSync as execSync2 } from "node:child_process"; import { homedir as homedir4 } from "node:os"; // dist/src/commands/auth.js -import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs"; +import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs"; import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process";