Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions claude-code/bundle/commands/auth-login.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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}`,
Expand Down Expand Up @@ -722,8 +729,16 @@ async function main() {
}
break;
}
case "logout": {
if (deleteCredentials()) {
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) => {
Expand Down
2 changes: 1 addition & 1 deletion claude-code/bundle/session-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
14 changes: 12 additions & 2 deletions src/commands/auth-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <id> — switch org
* node auth-login.js workspaces — list workspaces
Expand All @@ -18,7 +19,7 @@
*/

import {
login, loadCredentials, saveCredentials, listOrgs, switchOrg,
login, loadCredentials, saveCredentials, deleteCredentials, listOrgs, switchOrg,
listWorkspaces, switchWorkspace,
inviteMember, listMembers, removeMember,
} from "./auth.js";
Expand Down Expand Up @@ -134,8 +135,17 @@ async function main(): Promise<void> {
break;
}

case "logout": {
if (deleteCredentials()) {
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");
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<string, unknown> | null {
Expand Down
Loading