From 704674fe14750d31e7d3a58d6f9b2387c89fb184 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Thu, 30 Nov 2023 23:18:00 -0800 Subject: [PATCH] fix: Support 404 When `GaxiosError` != `GaxiosError` (#1707) * fix: Support 404 When GaxiosError != GaxiosError * fix: optionalize * refactor: Even more robust for `GaxiosError` != `GaxiosError` Older versions of gaxios may not have `.status`, but only `.response.status` --- package.json | 2 +- src/auth/googleauth.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index eadee9c0..7e4036df 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", - "gaxios": "^6.0.0", + "gaxios": "^6.1.1", "gcp-metadata": "^6.1.0", "gtoken": "^7.0.0", "jws": "^4.0.0" diff --git a/src/auth/googleauth.ts b/src/auth/googleauth.ts index e20ecf47..b5d66c70 100644 --- a/src/auth/googleauth.ts +++ b/src/auth/googleauth.ts @@ -311,7 +311,7 @@ export class GoogleAuth { universeDomain = await gcpMetadata.universe('universe_domain'); universeDomain ||= DEFAULT_UNIVERSE; } catch (e) { - if (e instanceof GaxiosError && e.status === 404) { + if (e && (e as GaxiosError)?.response?.status === 404) { universeDomain = DEFAULT_UNIVERSE; } else { throw e;