MCPcopy
hub / github.com/AutoMaker-Org/automaker / getCodexAuthIndicators

Function getCodexAuthIndicators

libs/platform/src/system-paths.ts:1210–1240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1208}
1209
1210export async function getCodexAuthIndicators(): Promise<CodexAuthIndicators> {
1211 const result: CodexAuthIndicators = {
1212 hasAuthFile: false,
1213 hasOAuthToken: false,
1214 hasApiKey: false,
1215 };
1216
1217 try {
1218 const authContent = await systemPathReadFile(getCodexAuthPath());
1219 result.hasAuthFile = true;
1220
1221 try {
1222 const authJson = JSON.parse(authContent) as Record<string, unknown>;
1223 result.hasOAuthToken = hasNonEmptyStringField(authJson, CODEX_OAUTH_KEYS);
1224 result.hasApiKey = hasNonEmptyStringField(authJson, CODEX_API_KEY_KEYS);
1225 const nestedTokens = getNestedTokens(authJson);
1226 if (nestedTokens) {
1227 result.hasOAuthToken =
1228 result.hasOAuthToken || hasNonEmptyStringField(nestedTokens, CODEX_OAUTH_KEYS);
1229 result.hasApiKey =
1230 result.hasApiKey || hasNonEmptyStringField(nestedTokens, CODEX_API_KEY_KEYS);
1231 }
1232 } catch {
1233 // Ignore parse errors; file exists but contents are unreadable
1234 }
1235 } catch {
1236 // Auth file not found or inaccessible
1237 }
1238
1239 return result;
1240}
1241
1242// =============================================================================
1243// OpenCode CLI Detection

Callers 5

checkAuthMethod · 0.90
createAuthCodexHandlerFunction · 0.85

Calls 4

systemPathReadFileFunction · 0.85
getCodexAuthPathFunction · 0.85
hasNonEmptyStringFieldFunction · 0.85
getNestedTokensFunction · 0.85

Tested by

no test coverage detected