Files
00821700de chore: remove dead code (59 unused files + ~125 unused exports) (#1835)
* chore: remove dead/unreferenced files across ui, vscode

Remove 59 unused source files (components, hooks, lib utils, stores,
barrels, and orphaned vscode github modules) that are not imported by
any entry-reachable code. Also drop a stale test mock for the removed
execCommands module.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove unused exported symbols (types, functions, consts, hooks)

Remove exported symbols whose identifier is referenced nowhere in the
repository (verified via repo-wide search), across ui types/contracts,
lib utilities, sync layer, stores, and components. Also drop the few
imports/private helpers orphaned by these removals.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove more unused exports (desktop, shortcuts, worktree, vscode)

Continue removing repo-wide unreferenced exported functions, consts and
types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and
vscode gitService, with cascading orphaned helpers/imports cleaned up.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: add dead-code cleanup tooling

* refactor: checkpoint dead-code cleanup

* refactor: remove dead-code suppressions

---------

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-06-26 19:27:53 +03:00

109 lines
3.1 KiB
JavaScript

/**
* Google Provider - Auth
*
* Authentication resolution logic for Google quota providers.
* @module quota/providers/google/auth
*/
import {
ANTIGRAVITY_ACCOUNTS_PATHS,
readJsonFile,
getAuthEntry,
normalizeAuthEntry,
asObject,
asNonEmptyString,
toTimestamp
} from '../../utils/index.js';
import { readAuthFile } from '../../../opencode/auth.js';
import { parseGoogleRefreshToken } from './transforms.js';
const ANTIGRAVITY_GOOGLE_CLIENT_ID =
'1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com';
const ANTIGRAVITY_GOOGLE_CLIENT_SECRET = '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';
const GEMINI_GOOGLE_CLIENT_ID =
'681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com';
const GEMINI_GOOGLE_CLIENT_SECRET = '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';
export const DEFAULT_PROJECT_ID = 'rising-fact-p41fc';
export const resolveGoogleOAuthClient = (sourceId) => {
if (sourceId === 'gemini') {
return {
clientId: GEMINI_GOOGLE_CLIENT_ID,
clientSecret: GEMINI_GOOGLE_CLIENT_SECRET
};
}
return {
clientId: ANTIGRAVITY_GOOGLE_CLIENT_ID,
clientSecret: ANTIGRAVITY_GOOGLE_CLIENT_SECRET
};
};
const resolveGeminiCliAuth = (auth) => {
const entry = normalizeAuthEntry(getAuthEntry(auth, ['google', 'google.oauth']));
const entryObject = asObject(entry);
if (!entryObject) {
return null;
}
const oauthObject = asObject(entryObject.oauth) ?? entryObject;
const accessToken = asNonEmptyString(oauthObject.access) ?? asNonEmptyString(oauthObject.token);
const refreshParts = parseGoogleRefreshToken(oauthObject.refresh);
if (!accessToken && !refreshParts.refreshToken) {
return null;
}
return {
sourceId: 'gemini',
sourceLabel: 'Gemini',
accessToken,
refreshToken: refreshParts.refreshToken,
projectId: refreshParts.projectId ?? refreshParts.managedProjectId,
expires: toTimestamp(oauthObject.expires)
};
};
const resolveAntigravityAuth = () => {
for (const filePath of ANTIGRAVITY_ACCOUNTS_PATHS) {
const data = readJsonFile(filePath);
const accounts = data?.accounts;
if (Array.isArray(accounts) && accounts.length > 0) {
const index = typeof data.activeIndex === 'number' ? data.activeIndex : 0;
const account = accounts[index] ?? accounts[0];
if (account?.refreshToken) {
const refreshParts = parseGoogleRefreshToken(account.refreshToken);
return {
sourceId: 'antigravity',
sourceLabel: 'Antigravity',
refreshToken: refreshParts.refreshToken,
projectId: asNonEmptyString(account.projectId)
?? asNonEmptyString(account.managedProjectId)
?? refreshParts.projectId
?? refreshParts.managedProjectId,
email: account.email
};
}
}
}
return null;
};
export const resolveGoogleAuthSources = () => {
const auth = readAuthFile();
const sources = [];
const geminiAuth = resolveGeminiCliAuth(auth);
if (geminiAuth) {
sources.push(geminiAuth);
}
const antigravityAuth = resolveAntigravityAuth();
if (antigravityAuth) {
sources.push(antigravityAuth);
}
return sources;
};