Skip to content

Commit

Permalink
feat: Improve gaxios exposure (#1794)
Browse files Browse the repository at this point in the history
* feat: Improve `gaxios` exposure

* docs: clarify
  • Loading branch information
d-goog authored Apr 12, 2024
1 parent 9b69a31 commit 5058726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/auth/authclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// limitations under the License.
import {GoogleAuth} from './auth/googleauth';

// 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';

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

0 comments on commit 5058726

Please sign in to comment.