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

Function refreshAwsAuth

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

Source from the content-addressed store, hash-verified

722const AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000
723
724export 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

Callers 1

runAwsAuthRefreshFunction · 0.85

Calls 10

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

Tested by

no test coverage detected