(awsAuthRefresh: string)
| 698 | const AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000 |
| 699 | |
| 700 | export function refreshAwsAuth(awsAuthRefresh: string): Promise<boolean> { |
| 701 | logForDebugging('Running AWS auth refresh command') |
| 702 | // Start tracking authentication status |
| 703 | const authStatusManager = AwsAuthStatusManager.getInstance() |
| 704 | authStatusManager.startAuthentication() |
| 705 | |
| 706 | return new Promise(resolve => { |
| 707 | const refreshProc = exec(awsAuthRefresh, { |
| 708 | timeout: AWS_AUTH_REFRESH_TIMEOUT_MS, |
| 709 | }) |
| 710 | refreshProc.stdout!.on('data', data => { |
| 711 | const output = data.toString().trim() |
| 712 | if (output) { |
| 713 | // Add output to status manager for UI display |
| 714 | authStatusManager.addOutput(output) |
| 715 | // Also log for debugging |
| 716 | logForDebugging(output, { level: 'debug' }) |
| 717 | } |
| 718 | }) |
| 719 | |
| 720 | refreshProc.stderr!.on('data', data => { |
| 721 | const error = data.toString().trim() |
| 722 | if (error) { |
| 723 | authStatusManager.setError(error) |
| 724 | logForDebugging(error, { level: 'error' }) |
| 725 | } |
| 726 | }) |
| 727 | |
| 728 | refreshProc.on('close', (code, signal) => { |
| 729 | if (code === 0) { |
| 730 | logForDebugging('AWS auth refresh completed successfully') |
| 731 | authStatusManager.endAuthentication(true) |
| 732 | void resolve(true) |
| 733 | } else { |
| 734 | const timedOut = signal === 'SIGTERM' |
| 735 | const message = timedOut |
| 736 | ? chalk.red( |
| 737 | 'AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.', |
| 738 | ) |
| 739 | : chalk.red( |
| 740 | 'Error running awsAuthRefresh (in settings or ~/.claude.json):', |
| 741 | ) |
| 742 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 743 | console.error(message) |
| 744 | authStatusManager.endAuthentication(false) |
| 745 | void resolve(false) |
| 746 | } |
| 747 | }) |
| 748 | }) |
| 749 | } |
| 750 | |
| 751 | /** |
| 752 | * Run awsCredentialExport to get credentials and set environment variables |
no test coverage detected