()
| 1031 | } |
| 1032 | |
| 1033 | export async function getClaudeAuthIndicators(): Promise<ClaudeAuthIndicators> { |
| 1034 | const settingsPath = getClaudeSettingsPath(); |
| 1035 | const statsCachePath = getClaudeStatsCachePath(); |
| 1036 | const projectsDir = getClaudeProjectsDir(); |
| 1037 | const credentialPaths = getClaudeCredentialPaths(); |
| 1038 | |
| 1039 | // Initialize checks with paths |
| 1040 | const settingsFileCheck: FileCheckResult = { |
| 1041 | path: settingsPath, |
| 1042 | exists: false, |
| 1043 | readable: false, |
| 1044 | }; |
| 1045 | |
| 1046 | const statsCacheCheck: FileCheckResult & { hasDailyActivity?: boolean } = { |
| 1047 | path: statsCachePath, |
| 1048 | exists: false, |
| 1049 | readable: false, |
| 1050 | }; |
| 1051 | |
| 1052 | const projectsDirCheck: DirectoryCheckResult = { |
| 1053 | path: projectsDir, |
| 1054 | exists: false, |
| 1055 | readable: false, |
| 1056 | entryCount: 0, |
| 1057 | }; |
| 1058 | |
| 1059 | const credentialFileChecks: FileCheckResult[] = credentialPaths.map((p) => ({ |
| 1060 | path: p, |
| 1061 | exists: false, |
| 1062 | readable: false, |
| 1063 | })); |
| 1064 | |
| 1065 | const result: ClaudeAuthIndicators = { |
| 1066 | hasCredentialsFile: false, |
| 1067 | hasSettingsFile: false, |
| 1068 | hasStatsCacheWithActivity: false, |
| 1069 | hasProjectsSessions: false, |
| 1070 | credentials: null, |
| 1071 | checks: { |
| 1072 | settingsFile: settingsFileCheck, |
| 1073 | statsCache: statsCacheCheck, |
| 1074 | projectsDir: projectsDirCheck, |
| 1075 | credentialFiles: credentialFileChecks, |
| 1076 | }, |
| 1077 | }; |
| 1078 | |
| 1079 | // Check settings file |
| 1080 | // First check existence, then try to read to confirm it's actually readable |
| 1081 | try { |
| 1082 | if (await systemPathAccess(settingsPath)) { |
| 1083 | settingsFileCheck.exists = true; |
| 1084 | // Try to actually read the file to confirm read permissions |
| 1085 | try { |
| 1086 | await systemPathReadFile(settingsPath); |
| 1087 | settingsFileCheck.readable = true; |
| 1088 | result.hasSettingsFile = true; |
| 1089 | } catch (readErr) { |
| 1090 | // File exists but cannot be read (permission denied, etc.) |
no test coverage detected