MCPcopy Create free account
hub / github.com/freecodexyz/free-code / refreshAwsAuth

Function refreshAwsAuth

src/utils/auth.ts:651–700  ·  view source on GitHub ↗
(awsAuthRefresh: string)

Source from the content-addressed store, hash-verified

649const AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000
650
651export 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

Callers 1

runAwsAuthRefreshFunction · 0.85

Calls 10

logForDebuggingFunction · 0.85
execFunction · 0.85
startAuthenticationMethod · 0.80
addOutputMethod · 0.80
setErrorMethod · 0.80
endAuthenticationMethod · 0.80
resolveFunction · 0.70
toStringMethod · 0.65
getInstanceMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected