@orchagent/cli 0.3.75 → 0.3.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/index.js +2 -0
- package/dist/commands/logout.js +47 -0
- package/package.json +1 -1
package/dist/commands/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerCommands = registerCommands;
|
|
4
4
|
const login_1 = require("./login");
|
|
5
|
+
const logout_1 = require("./logout");
|
|
5
6
|
const call_1 = require("./call");
|
|
6
7
|
const agents_1 = require("./agents");
|
|
7
8
|
const init_1 = require("./init");
|
|
@@ -37,6 +38,7 @@ const logs_1 = require("./logs");
|
|
|
37
38
|
const secrets_1 = require("./secrets");
|
|
38
39
|
function registerCommands(program) {
|
|
39
40
|
(0, login_1.registerLoginCommand)(program);
|
|
41
|
+
(0, logout_1.registerLogoutCommand)(program);
|
|
40
42
|
(0, whoami_1.registerWhoamiCommand)(program);
|
|
41
43
|
(0, init_1.registerInitCommand)(program);
|
|
42
44
|
(0, publish_1.registerPublishCommand)(program);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLogoutCommand = registerLogoutCommand;
|
|
4
|
+
const config_1 = require("../lib/config");
|
|
5
|
+
const api_1 = require("../lib/api");
|
|
6
|
+
const analytics_1 = require("../lib/analytics");
|
|
7
|
+
function registerLogoutCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('logout')
|
|
10
|
+
.description('Log out of orchagent (revokes API key and clears local credentials)')
|
|
11
|
+
.action(async () => {
|
|
12
|
+
const config = await (0, config_1.loadConfig)();
|
|
13
|
+
// Check if already logged out
|
|
14
|
+
if (!config.api_key && !process.env.ORCHAGENT_API_KEY) {
|
|
15
|
+
process.stdout.write('Not logged in.\n');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const resolved = await (0, config_1.getResolvedConfig)();
|
|
19
|
+
// Best-effort server-side key revocation (Vercel/Fly pattern)
|
|
20
|
+
if (resolved.apiKey) {
|
|
21
|
+
try {
|
|
22
|
+
await (0, api_1.safeFetch)(`${resolved.apiUrl}/auth/cli-logout`, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${resolved.apiKey}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Network errors, server down, etc. — proceed with local cleanup
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Clear auth fields but preserve user preferences
|
|
34
|
+
delete config.api_key;
|
|
35
|
+
delete config.default_org;
|
|
36
|
+
delete config.workspace;
|
|
37
|
+
await (0, config_1.saveConfig)(config);
|
|
38
|
+
await (0, analytics_1.track)('cli_logout', {});
|
|
39
|
+
process.stdout.write('Logged out.\n');
|
|
40
|
+
// Warn if env var is still set (GitHub CLI / Fly.io pattern)
|
|
41
|
+
if (process.env.ORCHAGENT_API_KEY) {
|
|
42
|
+
process.stderr.write('\nWarning: ORCHAGENT_API_KEY is set in your environment.\n' +
|
|
43
|
+
'The env var will still authenticate requests. Unset it with:\n' +
|
|
44
|
+
' unset ORCHAGENT_API_KEY\n');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
package/package.json
CHANGED