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

Function checkGcpCredentialsValid

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

Source from the content-addressed store, hash-verified

895 * This uses the same authentication chain that the Vertex SDK uses.
896 */
897export async function checkGcpCredentialsValid(): Promise<boolean> {
898 try {
899 // Dynamically import to avoid loading google-auth-library unnecessarily
900 const { GoogleAuth } = await import('google-auth-library')
901 const auth = new GoogleAuth({
902 scopes: ['https://www.googleapis.com/auth/cloud-platform'],
903 })
904 const probe = (async () => {
905 const client = await auth.getClient()
906 await client.getAccessToken()
907 })()
908 const timeout = sleep(GCP_CREDENTIALS_CHECK_TIMEOUT_MS).then(() => {
909 throw new GcpCredentialsTimeoutError('GCP credentials check timed out')
910 })
911 await Promise.race([probe, timeout])
912 return true
913 } catch {
914 return false
915 }
916}
917
918/** Default GCP credential TTL - 1 hour to match typical ADC token lifetime */
919const DEFAULT_GCP_CREDENTIAL_TTL = 60 * 60 * 1000

Callers 1

runGcpAuthRefreshFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected