Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve gaxios exposure #1794

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading