crewly 1.38.0
Uploads collected AI-agent authentication artifacts in an HTTP bodyAppleScript creates macOS Login Item
SHA-256f835061d7dd203a57a897f283e651859a55c2edf7fc368f0ddf8dec10e929872
Evidence
1/**
2 * Gemini CLI Workspace Credential Helper
3 *
4 * Piggybacks on the Google Workspace extension for Gemini CLI
5 * (https://github.com/gemini-cli-extensions/workspace) for Google OAuth
6 * credential acquisition and refresh.
7 *
8 * **Capture** reads the extension's file-storage token file (written when
9 * the user runs the extension with `GEMINI_CLI_WORKSPACE_FORCE_FILE_STORAGE=true`)
10 * and imports the tokens into Crewly's own encrypted store.
11 *
12 * **Refresh** POSTs the stored `refresh_token` to the extension's Cloud
13 * Function `/refreshToken` endpoint — no client_secret needed on our side.
14 *
15 * After capture, Crewly owns the tokens; the extension's own state is not
16 * depended on for day-to-day …
30:48… ================================
31const DEFAULT_EXTENSION_PATH = path.join(os.homedir(), '.gemini', 'extensions', 'google-workspace');
32const TOKEN_FILENAME = 'gemini-cli-workspace-token.json';
33const MASTER_KEY_FILENAME = '.gemini-cli-workspace-master-key';
34const MAIN_ACCOUNT_KEY = 'main-account';
35const SALT_SUFFIX = '-gemini-cli-workspace';
36/** Refresh if the current access token expires within this window. */
37const DEFAULT_EXPIRY_BUFFER_MS = 60_000;
38/** Minimum gap between refresh attempts fo …
72:12… s.fetchFn =
73 config?.fetch ??
74 ((url, init) => fetch(url, init));
75 }
76 // ------------------------------------------------------------------
77 // Capture
78 // ---------------------- …
103:52… n first login.`);
104 }
105 const encryptedText = await fs.readFile(tokenPath, 'utf8');
106 const masterKey = await fs.readFile(masterKeyPath);
107 // Derive the extension's encryption key (scrypt with hostname-username salt).
108 // Must match `file-token-storage.ts` exactly.
109 const salt = `${os.hostname()}-${os.userInfo().username}${SALT_SUFFIX}`;
110 const encryptionKey = crypto.scryptSync(masterKey, salt, 32);
111 const decrypted = this.decryptExtensionFormat(encryptedText, encryptionKey);
112 const parsed = JSON.parse(decrypted);
113 const entry = parsed[MAIN_ACCOUNT_KEY];
114 if (!entry) {
115 throw new Error(`Extension token file does not contain a '${ …
184:31… se;
185 }
186 finally {
187 this.refreshInFlight.delete(entry.id);
188 }
189 }
190 async doRefresh(entry, payload) {
191 const url = this.cloudFunctionUrl.replace(/\/$/, '') + this.refreshPath;
192 const response = await this.fetchFn(url, {
193 method: 'POST',
194 headers: { 'Content-Type': 'application/json' },
195 body: JSON.stringify({ refresh_token: payload.refreshToken }),
196 });
197 if (!response.ok) {
198 const body = await response.text().catch(() => '');
199 // Google responds 400 with body containing "invalid_grant" when the
200 // refresh token is revoked/expired beyond recovery.
201 if (response.status === 400 &&
202 /invalid_grant/i.test(body)) {
203 await this.store.updateCredential(entry.id, { status: 'revoke …
Showing the top 5 files — 13 more files (516 regions) not shown.
No evidence locations were recorded for this file. Raw result