MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / refreshGcpAuth

Function refreshGcpAuth

src/utils/auth.ts:967–1017  ·  view source on GitHub ↗
(gcpAuthRefresh: string)

Source from the content-addressed store, hash-verified

965const GCP_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000
966
967export function refreshGcpAuth(gcpAuthRefresh: string): Promise<boolean> {
968 logForDebugging('Running GCP auth refresh command')
969 // Start tracking authentication status. AwsAuthStatusManager is cloud-provider-agnostic
970 // despite the name — print.ts emits its updates as generic SDK 'auth_status' messages.
971 const authStatusManager = AwsAuthStatusManager.getInstance()
972 authStatusManager.startAuthentication()
973
974 return new Promise(resolve => {
975 const refreshProc = exec(gcpAuthRefresh, {
976 timeout: GCP_AUTH_REFRESH_TIMEOUT_MS,
977 })
978 refreshProc.stdout!.on('data', data => {
979 const output = data.toString().trim()
980 if (output) {
981 // Add output to status manager for UI display
982 authStatusManager.addOutput(output)
983 // Also log for debugging
984 logForDebugging(output, { level: 'debug' })
985 }
986 })
987
988 refreshProc.stderr!.on('data', data => {
989 const error = data.toString().trim()
990 if (error) {
991 authStatusManager.setError(error)
992 logForDebugging(error, { level: 'error' })
993 }
994 })
995
996 refreshProc.on('close', (code, signal) => {
997 if (code === 0) {
998 logForDebugging('GCP auth refresh completed successfully')
999 authStatusManager.endAuthentication(true)
1000 void resolve(true)
1001 } else {
1002 const timedOut = signal === 'SIGTERM'
1003 const message = timedOut
1004 ? chalk.red(
1005 'GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.',
1006 )
1007 : chalk.red(
1008 'Error running gcpAuthRefresh (in settings or ~/.claude.json):',
1009 )
1010 // biome-ignore lint/suspicious/noConsole:: intentional console output
1011 console.error(message)
1012 authStatusManager.endAuthentication(false)
1013 void resolve(false)
1014 }
1015 })
1016 })
1017}
1018
1019/**
1020 * Refresh GCP authentication if needed.

Callers 1

runGcpAuthRefreshFunction · 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