(awsAuthRefresh: string)
| 649 | const AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000 |
| 650 | |
| 651 | export function refreshAwsAuth(awsAuthRefresh: string): Promise<boolean> { |
| 652 | logForDebugging('Running AWS auth refresh command') |
| 653 | // Start tracking authentication status |
| 654 | const authStatusManager = AwsAuthStatusManager.getInstance() |
| 655 | authStatusManager.startAuthentication() |
| 656 | |
| 657 | return new Promise(resolve => { |
| 658 | const refreshProc = exec(awsAuthRefresh, { |
| 659 | timeout: AWS_AUTH_REFRESH_TIMEOUT_MS, |
| 660 | }) |
| 661 | refreshProc.stdout!.on('data', data => { |
| 662 | const output = data.toString().trim() |
| 663 | if (output) { |
| 664 | // Add output to status manager for UI display |
| 665 | authStatusManager.addOutput(output) |
| 666 | // Also log for debugging |
| 667 | logForDebugging(output, { level: 'debug' }) |
| 668 | } |
| 669 | }) |
| 670 | |
| 671 | refreshProc.stderr!.on('data', data => { |
| 672 | const error = data.toString().trim() |
| 673 | if (error) { |
| 674 | authStatusManager.setError(error) |
| 675 | logForDebugging(error, { level: 'error' }) |
| 676 | } |
| 677 | }) |
| 678 | |
| 679 | refreshProc.on('close', (code, signal) => { |
| 680 | if (code === 0) { |
| 681 | logForDebugging('AWS auth refresh completed successfully') |
| 682 | authStatusManager.endAuthentication(true) |
| 683 | void resolve(true) |
| 684 | } else { |
| 685 | const timedOut = signal === 'SIGTERM' |
| 686 | const message = timedOut |
| 687 | ? chalk.red( |
| 688 | 'AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.', |
| 689 | ) |
| 690 | : chalk.red( |
| 691 | 'Error running awsAuthRefresh (in settings or ~/.claude.json):', |
| 692 | ) |
| 693 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 694 | console.error(message) |
| 695 | authStatusManager.endAuthentication(false) |
| 696 | void resolve(false) |
| 697 | } |
| 698 | }) |
| 699 | }) |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Run awsCredentialExport to get credentials and set environment variables |
no test coverage detected