(gcpAuthRefresh: string)
| 965 | const GCP_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000 |
| 966 | |
| 967 | export function refreshGcpAuth(gcpAuthRefresh: string): Promise<boolean> { |
| 968 | logForDebugging('Running GCP auth refresh command') |
| 969 | // Start tracking authentication status. AwsAuthStatusManager is cloud-provider-agnostic |
| 970 | // despite the name — print.ts emits its updates as generic SDK 'auth_status' messages. |
| 971 | const authStatusManager = AwsAuthStatusManager.getInstance() |
| 972 | authStatusManager.startAuthentication() |
| 973 | |
| 974 | return new Promise(resolve => { |
| 975 | const refreshProc = exec(gcpAuthRefresh, { |
| 976 | timeout: GCP_AUTH_REFRESH_TIMEOUT_MS, |
| 977 | }) |
| 978 | refreshProc.stdout!.on('data', data => { |
| 979 | const output = data.toString().trim() |
| 980 | if (output) { |
| 981 | // Add output to status manager for UI display |
| 982 | authStatusManager.addOutput(output) |
| 983 | // Also log for debugging |
| 984 | logForDebugging(output, { level: 'debug' }) |
| 985 | } |
| 986 | }) |
| 987 | |
| 988 | refreshProc.stderr!.on('data', data => { |
| 989 | const error = data.toString().trim() |
| 990 | if (error) { |
| 991 | authStatusManager.setError(error) |
| 992 | logForDebugging(error, { level: 'error' }) |
| 993 | } |
| 994 | }) |
| 995 | |
| 996 | refreshProc.on('close', (code, signal) => { |
| 997 | if (code === 0) { |
| 998 | logForDebugging('GCP auth refresh completed successfully') |
| 999 | authStatusManager.endAuthentication(true) |
| 1000 | void resolve(true) |
| 1001 | } else { |
| 1002 | const timedOut = signal === 'SIGTERM' |
| 1003 | const message = timedOut |
| 1004 | ? chalk.red( |
| 1005 | 'GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.', |
| 1006 | ) |
| 1007 | : chalk.red( |
| 1008 | 'Error running gcpAuthRefresh (in settings or ~/.claude.json):', |
| 1009 | ) |
| 1010 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 1011 | console.error(message) |
| 1012 | authStatusManager.endAuthentication(false) |
| 1013 | void resolve(false) |
| 1014 | } |
| 1015 | }) |
| 1016 | }) |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * Refresh GCP authentication if needed. |
no test coverage detected