MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / checkGcpCredentialsValid

Function checkGcpCredentialsValid

source code/utils/auth.ts:849–868  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

runGcpAuthRefreshFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected