(awsAuthRefresh: string)
| 722 | const AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000 |
| 723 | |
| 724 | export function refreshAwsAuth(awsAuthRefresh: string): Promise<boolean> { |
| 725 | logForDebugging('Running AWS auth refresh command') |
| 726 | // Start tracking authentication status |
| 727 | const authStatusManager = AwsAuthStatusManager.getInstance() |
| 728 | authStatusManager.startAuthentication() |
| 729 | |
| 730 | return new Promise(resolve => { |
| 731 | const refreshProc = exec(awsAuthRefresh, { |
| 732 | timeout: AWS_AUTH_REFRESH_TIMEOUT_MS, |
| 733 | }) |
| 734 | refreshProc.stdout!.on('data', data => { |
| 735 | const output = data.toString().trim() |
| 736 | if (output) { |
| 737 | // Add output to status manager for UI display |
| 738 | authStatusManager.addOutput(output) |
| 739 | // Also log for debugging |
| 740 | logForDebugging(output, { level: 'debug' }) |
| 741 | } |
| 742 | }) |
| 743 | |
| 744 | refreshProc.stderr!.on('data', data => { |
| 745 | const error = data.toString().trim() |
| 746 | if (error) { |
| 747 | authStatusManager.setError(error) |
| 748 | logForDebugging(error, { level: 'error' }) |
| 749 | } |
| 750 | }) |
| 751 | |
| 752 | refreshProc.on('close', (code, signal) => { |
| 753 | if (code === 0) { |
| 754 | logForDebugging('AWS auth refresh completed successfully') |
| 755 | authStatusManager.endAuthentication(true) |
| 756 | void resolve(true) |
| 757 | } else { |
| 758 | const timedOut = signal === 'SIGTERM' |
| 759 | const message = timedOut |
| 760 | ? chalk.red( |
| 761 | 'AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.', |
| 762 | ) |
| 763 | : chalk.red( |
| 764 | 'Error running awsAuthRefresh (in settings or global config, typically ~/.ncode/.config.json):', |
| 765 | ) |
| 766 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 767 | console.error(message) |
| 768 | authStatusManager.endAuthentication(false) |
| 769 | void resolve(false) |
| 770 | } |
| 771 | }) |
| 772 | }) |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * Run awsCredentialExport to get credentials and set environment variables |
no test coverage detected