MCPcopy Index your code
hub / github.com/liuup/claude-code-analysis / checkGcpCredentialsValid

Function checkGcpCredentialsValid

src/utils/auth.ts:847–866  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

845 * This uses the same authentication chain that the Vertex SDK uses.
846 */
847export async function checkGcpCredentialsValid(): Promise<boolean> {
848 try {
849 // Dynamically import to avoid loading google-auth-library unnecessarily
850 const { GoogleAuth } = await import('google-auth-library')
851 const auth = new GoogleAuth({
852 scopes: ['https://www.googleapis.com/auth/cloud-platform'],
853 })
854 const probe = (async () => {
855 const client = await auth.getClient()
856 await client.getAccessToken()
857 })()
858 const timeout = sleep(GCP_CREDENTIALS_CHECK_TIMEOUT_MS).then(() => {
859 throw new GcpCredentialsTimeoutError('GCP credentials check timed out')
860 })
861 await Promise.race([probe, timeout])
862 return true
863 } catch {
864 return false
865 }
866}
867
868/** Default GCP credential TTL - 1 hour to match typical ADC token lifetime */
869const DEFAULT_GCP_CREDENTIAL_TTL = 60 * 60 * 1000

Callers 1

runGcpAuthRefreshFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected