Skip to content

Commit

Permalink
refactor!: Move Base AuthClient Types to authclient.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
HubertJan committed Mar 12, 2024
1 parent f45f975 commit 6232a14
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 30 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 @@ -260,3 +259,12 @@ export abstract class AuthClient
return headers;
}
}

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

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

Check failure on line 270 in src/auth/authclient.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`

Check failure on line 270 in src/auth/authclient.ts

View workflow job for this annotation

GitHub Actions / lint

Newline required at end of file but not found
3 changes: 1 addition & 2 deletions src/auth/awsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
BaseExternalAccountClient,
BaseExternalAccountClientOptions,
} from './baseexternalclient';
import {Headers} from './oauth2client';
import {AuthClientOptions} from './authclient';
import {Headers, AuthClientOptions} from './authclient';

/**
* AWS credentials JSON interface. This is used for AWS workloads.
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
3 changes: 1 addition & 2 deletions src/auth/baseexternalclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import {
import * as stream from 'stream';

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

Check failure on line 24 in src/auth/baseexternalclient.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `AuthClient,·AuthClientOptions,·GetAccessTokenResponse,·Headers` with `⏎··AuthClient,⏎··AuthClientOptions,⏎··GetAccessTokenResponse,⏎··Headers,⏎`
import {BodyResponseCallback} from '../transporters';
import {GetAccessTokenResponse, Headers} from './oauth2client';
import * as sts from './stscredentials';
import {ClientAuthentication} from './oauth2common';
import {SnakeToCamelObject, originalOrCamelOptions} from '../util';
Expand Down
3 changes: 1 addition & 2 deletions src/auth/downscopedclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ 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';

Check failure on line 25 in src/auth/downscopedclient.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `AuthClient,·AuthClientOptions,·GetAccessTokenResponse,·Headers` with `⏎··AuthClient,⏎··AuthClientOptions,⏎··GetAccessTokenResponse,⏎··Headers,⏎`

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
4 changes: 2 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,7 @@ import {
EXTERNAL_ACCOUNT_TYPE,
BaseExternalAccountClient,
} from './baseexternalclient';
import {AuthClient, AuthClientOptions, DEFAULT_UNIVERSE} from './authclient';
import {AuthClient, AuthClientOptions, DEFAULT_UNIVERSE, Headers} from './authclient';

Check failure on line 50 in src/auth/googleauth.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `AuthClient,·AuthClientOptions,·DEFAULT_UNIVERSE,·Headers` with `⏎··AuthClient,⏎··AuthClientOptions,⏎··DEFAULT_UNIVERSE,⏎··Headers,⏎`
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
11 changes: 1 addition & 10 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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';

Check failure on line 28 in src/auth/oauth2client.ts

View workflow job for this annotation

GitHub Actions / lint

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

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

export enum CodeChallengeMethod {
Plain = 'plain',
S256 = 'S256',
Expand Down Expand Up @@ -336,11 +332,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 6232a14

Please sign in to comment.