From 31a8e0433e2b43e8cb1586cd77723fe61d9a54e6 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Fri, 12 Apr 2024 12:15:19 -0700 Subject: [PATCH 1/2] feat: Improve `gaxios` exposure --- src/auth/authclient.ts | 20 ++++++++++++++++++++ src/index.ts | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/auth/authclient.ts b/src/auth/authclient.ts index 29e1602a..82521a92 100644 --- a/src/auth/authclient.ts +++ b/src/auth/authclient.ts @@ -207,6 +207,26 @@ export abstract class AuthClient this.forceRefreshOnFailure = opts.forceRefreshOnFailure ?? false; } + /** + * Return the {@link Gaxios `Gaxios`} instance from the {@link AuthClient.transporter}. + * + * @expiremental + */ + get gaxios(): Gaxios | null { + if (this.transporter instanceof Gaxios) { + return this.transporter; + } else if (this.transporter instanceof DefaultTransporter) { + return this.transporter.instance; + } else if ( + 'instance' in this.transporter && + this.transporter.instance instanceof Gaxios + ) { + return this.transporter.instance; + } + + return null; + } + /** * Provides an alternative Gaxios request implementation with auth credentials */ diff --git a/src/index.ts b/src/index.ts index 77ad950a..caab2428 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,10 @@ // limitations under the License. import {GoogleAuth} from './auth/googleauth'; +// Export common deps to ensure the instances are the exact match +// if used for configuring the library. export * as gcpMetadata from 'gcp-metadata'; +export * as gaxios from 'gaxios'; export {AuthClient, DEFAULT_UNIVERSE} from './auth/authclient'; export {Compute, ComputeOptions} from './auth/computeclient'; From 3397e9726eede776767171fc8686f45f113ea56f Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Fri, 12 Apr 2024 12:16:32 -0700 Subject: [PATCH 2/2] docs: clarify --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index caab2428..1ab32948 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,8 +13,8 @@ // limitations under the License. import {GoogleAuth} from './auth/googleauth'; -// Export common deps to ensure the instances are the exact match -// if used for configuring the library. +// Export common deps to ensure types/instances are the exact match. Useful +// for consistently configuring the library across versions. export * as gcpMetadata from 'gcp-metadata'; export * as gaxios from 'gaxios';