Skip to content

Commit 5058726

Browse files
authored
feat: Improve gaxios exposure (#1794)
* feat: Improve `gaxios` exposure * docs: clarify
1 parent 9b69a31 commit 5058726

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/auth/authclient.ts

+20
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ export abstract class AuthClient
207207
this.forceRefreshOnFailure = opts.forceRefreshOnFailure ?? false;
208208
}
209209

210+
/**
211+
* Return the {@link Gaxios `Gaxios`} instance from the {@link AuthClient.transporter}.
212+
*
213+
* @expiremental
214+
*/
215+
get gaxios(): Gaxios | null {
216+
if (this.transporter instanceof Gaxios) {
217+
return this.transporter;
218+
} else if (this.transporter instanceof DefaultTransporter) {
219+
return this.transporter.instance;
220+
} else if (
221+
'instance' in this.transporter &&
222+
this.transporter.instance instanceof Gaxios
223+
) {
224+
return this.transporter.instance;
225+
}
226+
227+
return null;
228+
}
229+
210230
/**
211231
* Provides an alternative Gaxios request implementation with auth credentials
212232
*/

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
// limitations under the License.
1414
import {GoogleAuth} from './auth/googleauth';
1515

16+
// Export common deps to ensure types/instances are the exact match. Useful
17+
// for consistently configuring the library across versions.
1618
export * as gcpMetadata from 'gcp-metadata';
19+
export * as gaxios from 'gaxios';
1720

1821
export {AuthClient, DEFAULT_UNIVERSE} from './auth/authclient';
1922
export {Compute, ComputeOptions} from './auth/computeclient';

0 commit comments

Comments
 (0)