Skip to content

Commit

Permalink
refactor!: Move Base AuthClient Types to authclient.ts (#1774)
Browse files Browse the repository at this point in the history
* refactor!: Move Base AuthClient Types to authclient.ts

* style: Fix lints

* chore: merge conflict

---------

Co-authored-by: d-goog <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2025
1 parent 69be990 commit b0c3a43
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 29 deletions.
10 changes: 9 additions & 1 deletion src/auth/authclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {Gaxios, GaxiosOptions, GaxiosPromise, GaxiosResponse} from 'gaxios';

import {DefaultTransporter, Transporter} from '../transporters';
import {Credentials} from './credentials';
import {GetAccessTokenResponse, Headers} from './oauth2client';
import {OriginalAndCamel, originalOrCamelOptions} from '../util';

/**
Expand Down Expand Up @@ -307,3 +306,12 @@ export abstract class AuthClient
};
}
}

export interface Headers {
[index: string]: string;
}

export interface GetAccessTokenResponse {
token?: string | null;
res?: GaxiosResponse | null;
}
1 change: 1 addition & 0 deletions src/auth/awsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
BaseExternalAccountClientOptions,
ExternalAccountSupplierContext,
} from './baseexternalclient';

import {AuthClientOptions} from './authclient';
import {DefaultAwsSecurityCredentialsSupplier} from './defaultawssecuritycredentialssupplier';
import {originalOrCamelOptions, SnakeToCamelObject} from '../util';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/awsrequestsigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import {GaxiosOptions} from 'gaxios';

import {Headers} from './oauth2client';
import {Headers} from './authclient';
import {Crypto, createCrypto, fromArrayBufferToHex} from '../crypto/crypto';

type HttpMethod =
Expand Down
8 changes: 6 additions & 2 deletions src/auth/baseexternalclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ import {
import * as stream from 'stream';

import {Credentials} from './credentials';
import {AuthClient, AuthClientOptions} from './authclient';
import {
AuthClient,
AuthClientOptions,
GetAccessTokenResponse,
Headers,
} from './authclient';
import {BodyResponseCallback, Transporter} from '../transporters';
import {GetAccessTokenResponse, Headers} from './oauth2client';
import * as sts from './stscredentials';
import {ClientAuthentication} from './oauth2common';
import {SnakeToCamelObject, originalOrCamelOptions} from '../util';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/defaultawssecuritycredentialssupplier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Gaxios, GaxiosOptions} from 'gaxios';
import {Transporter} from '../transporters';
import {AwsSecurityCredentialsSupplier} from './awsclient';
import {AwsSecurityCredentials} from './awsrequestsigner';
import {Headers} from './oauth2client';
import {Headers} from './authclient';

/**
* Interface defining the AWS security-credentials endpoint response.
Expand Down
8 changes: 6 additions & 2 deletions src/auth/downscopedclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ import * as stream from 'stream';

import {BodyResponseCallback} from '../transporters';
import {Credentials} from './credentials';
import {AuthClient, AuthClientOptions} from './authclient';
import {
AuthClient,
AuthClientOptions,
GetAccessTokenResponse,
Headers,
} from './authclient';

import {GetAccessTokenResponse, Headers} from './oauth2client';
import * as sts from './stscredentials';

/**
Expand Down
3 changes: 1 addition & 2 deletions src/auth/externalAccountAuthorizedUserClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {AuthClient, AuthClientOptions} from './authclient';
import {Headers} from './oauth2client';
import {AuthClient, AuthClientOptions, Headers} from './authclient';
import {
ClientAuthentication,
getErrorFromOAuthErrorResponse,
Expand Down
9 changes: 7 additions & 2 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {CredentialBody, ImpersonatedJWTInput, JWTInput} from './credentials';
import {IdTokenClient} from './idtokenclient';
import {GCPEnv, getEnv} from './envDetect';
import {JWT, JWTOptions} from './jwtclient';
import {Headers, OAuth2ClientOptions} from './oauth2client';
import {OAuth2ClientOptions} from './oauth2client';
import {
UserRefreshClient,
UserRefreshClientOptions,
Expand All @@ -47,7 +47,12 @@ import {
EXTERNAL_ACCOUNT_TYPE,
BaseExternalAccountClient,
} from './baseexternalclient';
import {AuthClient, AuthClientOptions, DEFAULT_UNIVERSE} from './authclient';
import {
AuthClient,
AuthClientOptions,
DEFAULT_UNIVERSE,
Headers,
} from './authclient';
import {
EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE,
ExternalAccountAuthorizedUserClient,
Expand Down
2 changes: 1 addition & 1 deletion src/auth/idtokenclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

import {Credentials} from './credentials';
import {Headers} from './authclient';
import {
Headers,
OAuth2Client,
OAuth2ClientOptions,
RequestMetadataResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/auth/jwtaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as jws from 'jws';
import * as stream from 'stream';

import {JWTInput} from './credentials';
import {Headers} from './oauth2client';
import {Headers} from './authclient';
import {LRUCache} from '../util';

const DEFAULT_HEADER: jws.Header = {
Expand Down
16 changes: 6 additions & 10 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ import * as formatEcdsa from 'ecdsa-sig-formatter';
import {createCrypto, JwkCertificate, hasBrowserCrypto} from '../crypto/crypto';
import {BodyResponseCallback} from '../transporters';

import {AuthClient, AuthClientOptions} from './authclient';
import {
AuthClient,
AuthClientOptions,
GetAccessTokenResponse,
Headers,
} from './authclient';
import {CredentialRequest, Credentials} from './credentials';
import {LoginTicket, TokenPayload} from './loginticket';
/**
Expand Down Expand Up @@ -54,10 +59,6 @@ export interface PublicKeys {
[index: string]: string;
}

export interface Headers {
[index: string]: string;
}

export enum CodeChallengeMethod {
Plain = 'plain',
S256 = 'S256',
Expand Down Expand Up @@ -359,11 +360,6 @@ export interface GetAccessTokenCallback {
): void;
}

export interface GetAccessTokenResponse {
token?: string | null;
res?: GaxiosResponse | null;
}

export interface RefreshAccessTokenCallback {
(
err: GaxiosError | null,
Expand Down
3 changes: 1 addition & 2 deletions src/auth/passthrough.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
// limitations under the License.

import {GaxiosOptions} from 'gaxios';
import {AuthClient} from './authclient';
import {GetAccessTokenResponse, Headers} from './oauth2client';
import {AuthClient, GetAccessTokenResponse, Headers} from './authclient';

/**
* An AuthClient without any Authentication information. Useful for:
Expand Down
2 changes: 1 addition & 1 deletion src/auth/stscredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {GaxiosError, GaxiosOptions, GaxiosResponse} from 'gaxios';
import * as querystring from 'querystring';

import {DefaultTransporter, Transporter} from '../transporters';
import {Headers} from './oauth2client';
import {Headers} from './authclient';
import {
ClientAuthentication,
OAuthClientAuthHandler,
Expand Down
2 changes: 1 addition & 1 deletion test/externalclienthelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as assert from 'assert';
import * as nock from 'nock';
import * as qs from 'querystring';
import {GetAccessTokenResponse} from '../src/auth/oauth2client';
import {GetAccessTokenResponse} from '../src/auth/authclient';
import {OAuthErrorResponse} from '../src/auth/oauth2common';
import {StsSuccessfulResponse} from '../src/auth/stscredentials';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/test.downscopedclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
OAuthErrorResponse,
getErrorFromOAuthErrorResponse,
} from '../src/auth/oauth2common';
import {GetAccessTokenResponse, Headers} from '../src/auth/oauth2client';
import {GetAccessTokenResponse, Headers} from '../src/auth/authclient';

nock.disableNetConnect();

Expand Down
2 changes: 1 addition & 1 deletion test/test.oauth2common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {describe, it} from 'mocha';
import * as assert from 'assert';
import * as querystring from 'querystring';

import {Headers} from '../src/auth/oauth2client';
import {Headers} from '../src/auth/authclient';
import {
ClientAuthentication,
OAuthClientAuthHandler,
Expand Down

0 comments on commit b0c3a43

Please sign in to comment.