@devries-cameron20 / composio Mirror · read-only / commits / ac6a6c11d
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 03:15 UTC

feat(cli): stop exposing API keys in whoami command (#2896)

## Summary Stop exposing API keys in the `composio whoami` command for security. ## Changes - **Remove API key from output**: No longer display or include API key in whoami output (neither in the note nor in JSON) - **Add helpful hints**: Show next-step hints with descriptions: - To switch orgs: `composio orgs switch` - To get API keys: `composio init` (in your project) - **Update tests**: Assert that API key is never present in output ## Testing ```bash pnpm test ``` All tests pass. Made with [Cursor](https://cursor.com)

Musthaq Ahamad committed Mar 13, 2026 at 11:08 UTC ac6a6c11d335618a4e0cedba80470063b4bdcf80
2 files changed +13 -10
ts/packages/cli/src/commands/whoami.cmd.ts
+9 -6
@@ -2,14 +2,14 @@ import { Command } from '@effect/cli';
2 import { Effect, Option } from 'effect';
3 import { ComposioUserContext } from 'src/services/user-context';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 -import { redact } from 'src/ui/redact';
5
6 /**
7 * CLI command to display your account information.
8 + * Never prints or exposes API keys.
9 *
10 * @example
11 * ```bash
12 - * composio whoami <command>
12 + * composio whoami
13 * ```
14 */
15 export const whoamiCmd = Command.make('whoami', {}).pipe(
@@ -22,25 +22,28 @@ export const whoamiCmd = Command.make('whoami', {}).pipe(
22 yield* ctx.data.apiKey.pipe(
23 Option.match({
24 onNone: () => ui.log.warn('You are not logged in yet. Please run `composio login`.'),
25 - onSome: apiKey =>
25 + onSome: () =>
26 Effect.gen(function* () {
27 - const redactedApiKey = redact({ value: apiKey, prefix: 'ak_' });
27 const defaultOrgId = Option.getOrUndefined(ctx.data.orgId);
28 const defaultProjectId = Option.getOrUndefined(ctx.data.projectId);
29 const testUserId = Option.getOrUndefined(ctx.data.testUserId);
30
31 yield* ui.note(
32 [
34 - `Global User API Key: ${redactedApiKey}`,
33 `Default Org ID: ${defaultOrgId ?? 'not set'}`,
34 `Default Project ID: ${defaultProjectId ?? 'not set'}`,
35 `Test User ID: ${testUserId ?? 'not set'}`,
36 ].join('\n'),
37 'Global User Context'
38 );
39 + yield* ui.log.step(
40 + [
41 + 'To switch orgs:\n> composio orgs switch',
42 + 'To get API keys:\n> composio init (in your project)',
43 + ].join('\n\n')
44 + );
45 yield* ui.output(
46 JSON.stringify({
43 - global_user_api_key: apiKey,
47 default_org_id: defaultOrgId ?? null,
48 default_project_id: defaultProjectId ?? null,
49 test_user_id: testUserId ?? null,
ts/packages/cli/test/src/commands/whoami.cmd.test.ts
+4 -4
@@ -16,8 +16,8 @@ describe('CLI: composio whoami', () => {
16
17 const lines = yield* MockConsole.getLines();
18 const output = lines.join('\n');
19 - expect(output).toContain(`api_key_from_test_config_provider`);
20 - expect(output).toContain(`"global_user_api_key":"api_key_from_test_config_provider"`);
19 + expect(output).not.toContain(`api_key_from_test_config_provider`);
20 + expect(output).not.toContain(`global_user_api_key`);
21 expect(output).toContain(`"default_org_id":null`);
22 expect(output).toContain(`"default_project_id":null`);
23 expect(output).toContain(`"test_user_id":null`);
@@ -33,8 +33,8 @@ describe('CLI: composio whoami', () => {
33
34 const lines = yield* MockConsole.getLines();
35 const output = lines.join('\n');
36 - expect(output).toContain(`api_key_from_test_fixture`);
37 - expect(output).toContain(`"global_user_api_key":"api_key_from_test_fixture"`);
36 + expect(output).not.toContain(`api_key_from_test_fixture`);
37 + expect(output).not.toContain(`global_user_api_key`);
38 expect(output).toContain(`"default_org_id":null`);
39 expect(output).toContain(`"default_project_id":null`);
40 expect(output).toContain(`"test_user_id":null`);