MCPcopy
hub / github.com/codeaashu/claude-code / refreshGcpAuth

Function refreshGcpAuth

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

Source from the content-addressed store, hash-verified

915const GCP_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000
916
917export function refreshGcpAuth(gcpAuthRefresh: string): Promise<boolean> {
918 logForDebugging('Running GCP auth refresh command')
919 // Start tracking authentication status. AwsAuthStatusManager is cloud-provider-agnostic
920 // despite the name — print.ts emits its updates as generic SDK 'auth_status' messages.
921 const authStatusManager = AwsAuthStatusManager.getInstance()
922 authStatusManager.startAuthentication()
923
924 return new Promise(resolve => {
925 const refreshProc = exec(gcpAuthRefresh, {
926 timeout: GCP_AUTH_REFRESH_TIMEOUT_MS,
927 })
928 refreshProc.stdout!.on('data', data => {
929 const output = data.toString().trim()
930 if (output) {
931 // Add output to status manager for UI display
932 authStatusManager.addOutput(output)
933 // Also log for debugging
934 logForDebugging(output, { level: 'debug' })
935 }
936 })
937
938 refreshProc.stderr!.on('data', data => {
939 const error = data.toString().trim()
940 if (error) {
941 authStatusManager.setError(error)
942 logForDebugging(error, { level: 'error' })
943 }
944 })
945
946 refreshProc.on('close', (code, signal) => {
947 if (code === 0) {
948 logForDebugging('GCP auth refresh completed successfully')
949 authStatusManager.endAuthentication(true)
950 void resolve(true)
951 } else {
952 const timedOut = signal === 'SIGTERM'
953 const message = timedOut
954 ? chalk.red(
955 'GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.',
956 )
957 : chalk.red(
958 'Error running gcpAuthRefresh (in settings or ~/.claude.json):',
959 )
960 // biome-ignore lint/suspicious/noConsole:: intentional console output
961 console.error(message)
962 authStatusManager.endAuthentication(false)
963 void resolve(false)
964 }
965 })
966 })
967}
968
969/**
970 * Refresh GCP authentication if needed.

Callers 1

runGcpAuthRefreshFunction · 0.85

Calls 11

logForDebuggingFunction · 0.85
execFunction · 0.85
startAuthenticationMethod · 0.80
onMethod · 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