Skip to content

Commit 7ea7fd0

Browse files
committed
feat: Normalize to GoogleAuth<AuthClient>
1 parent f23e807 commit 7ea7fd0

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Diff for: src/auth/googleauth.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
ExternalAccountAuthorizedUserClientOptions,
5353
} from './externalAccountAuthorizedUserClient';
5454
import {originalOrCamelOptions} from '../util';
55-
import {AnyAuthClient} from '..';
55+
import {AnyAuthClient, AnyAuthClientConstructor} from '..';
5656

5757
/**
5858
* Defines all types of explicit clients that are determined via ADC JSON
@@ -82,7 +82,7 @@ export interface ADCResponse {
8282
projectId: string | null;
8383
}
8484

85-
export interface GoogleAuthOptions<T extends AuthClient = JSONClient> {
85+
export interface GoogleAuthOptions<T extends AuthClient = AnyAuthClient> {
8686
/**
8787
* An API key to use, optional. Cannot be used with {@link GoogleAuthOptions.credentials `credentials`}.
8888
*/
@@ -114,13 +114,12 @@ export interface GoogleAuthOptions<T extends AuthClient = JSONClient> {
114114
credentials?: JWTInput | ExternalAccountClientOptions;
115115

116116
/**
117-
* Options object passed to the constructor of the client
117+
* `AuthClientOptions` object passed to the constructor of the client
118118
*/
119-
clientOptions?:
120-
| JWTOptions
121-
| OAuth2ClientOptions
122-
| UserRefreshClientOptions
123-
| ImpersonatedOptions;
119+
clientOptions?: Extract<
120+
ConstructorParameters<AnyAuthClientConstructor>[0],
121+
AuthClientOptions
122+
>;
124123

125124
/**
126125
* Required scopes for the desired API request
@@ -163,7 +162,7 @@ export const GoogleAuthExceptionMessages = {
163162
'https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys',
164163
} as const;
165164

166-
export class GoogleAuth<T extends AuthClient = JSONClient> {
165+
export class GoogleAuth<T extends AuthClient = AuthClient> {
167166
/**
168167
* Caches a value indicating whether the auth layer is running on Google
169168
* Compute Engine.

Diff for: src/index.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ export {PassThroughClient} from './auth/passthrough';
9191
type ALL_EXPORTS = (typeof import('./'))[keyof typeof import('./')];
9292

9393
/**
94-
* A union type for all {@link AuthClient `AuthClient`}s.
94+
* A union type for all {@link AuthClient `AuthClient`} constructors.
9595
*/
96-
export type AnyAuthClient = InstanceType<
96+
export type AnyAuthClientConstructor =
9797
// Extract All `AuthClient`s from exports
98-
Extract<ALL_EXPORTS, typeof AuthClient>
99-
>;
98+
Extract<ALL_EXPORTS, typeof AuthClient>;
99+
100+
/**
101+
* A union type for all {@link AuthClient `AuthClient`}s.
102+
*/
103+
export type AnyAuthClient = InstanceType<AnyAuthClientConstructor>;
100104

101105
const auth = new GoogleAuth();
102106
export {auth, GoogleAuth};

0 commit comments

Comments
 (0)