From 96b22661e4ee342897014b28aae8901b78b2db99 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Thu, 30 Nov 2023 20:22:46 -0800 Subject: [PATCH 1/3] fix: Support 404 When GaxiosError != GaxiosError --- 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..19440d86 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 as GaxiosError).status === 404) { universeDomain = DEFAULT_UNIVERSE; } else { throw e; From 604e823e245c95a6984d3e47f049d2e821c24247 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Thu, 30 Nov 2023 20:23:24 -0800 Subject: [PATCH 2/3] fix: optionalize --- src/auth/googleauth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/googleauth.ts b/src/auth/googleauth.ts index 19440d86..f223c4a1 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 as GaxiosError).status === 404) { + if (e && (e as GaxiosError)?.status === 404) { universeDomain = DEFAULT_UNIVERSE; } else { throw e; From b93c18f75e388505029c26234e3e2471d092cd93 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Thu, 30 Nov 2023 20:35:59 -0800 Subject: [PATCH 3/3] refactor: Even more robust for `GaxiosError` != `GaxiosError` Older versions of gaxios may not have `.status`, but only `.response.status` --- src/auth/googleauth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/googleauth.ts b/src/auth/googleauth.ts index f223c4a1..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 && (e as GaxiosError)?.status === 404) { + if (e && (e as GaxiosError)?.response?.status === 404) { universeDomain = DEFAULT_UNIVERSE; } else { throw e;