| 325 | } |
| 326 | |
| 327 | async function loadClaudeAuth(): Promise<Info | null> { |
| 328 | const authFile = await readJsonFile<ClaudeOauthFile>(path.join(os.homedir(), ".claude", ".credentials.json")) |
| 329 | if (!authFile?.claudeAiOauth) return null |
| 330 | |
| 331 | const { accessToken, refreshToken, expiresAt } = authFile.claudeAiOauth |
| 332 | if (!accessToken || !refreshToken) return null |
| 333 | |
| 334 | const expires = typeof expiresAt === "number" && Number.isFinite(expiresAt) ? expiresAt : Date.now() + 3600 * 1000 |
| 335 | |
| 336 | return { |
| 337 | type: "oauth", |
| 338 | access: accessToken, |
| 339 | refresh: refreshToken, |
| 340 | expires, |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | async function loadExternalAuth(): Promise<Record<string, Info>> { |
| 345 | const entries: Record<string, Info> = {} |