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

refactor!: Move Base AuthClient Types to authclient.ts #1774

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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 {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 @@
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 * 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 {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 {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 @@
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 {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 @@
[index: string]: string;
}

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

export enum CodeChallengeMethod {
Plain = 'plain',
S256 = 'S256',
Expand Down Expand Up @@ -336,11 +332,6 @@
): 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 @@
OAuthErrorResponse,
getErrorFromOAuthErrorResponse,
} from '../src/auth/oauth2common';
import {GetAccessTokenResponse, Headers} from '../src/auth/oauth2client';
import {GetAccessTokenResponse, Headers} from '../src/auth/authclient';

nock.disableNetConnect();

Expand All @@ -54,11 +54,11 @@
this.credentials.expiry_date = expirationTime;
}

async getRequestHeaders(url?: string): Promise<Headers> {

Check warning on line 57 in test/test.downscopedclient.ts

View workflow job for this annotation

GitHub Actions / lint

'url' is defined but never used
throw new Error('Not implemented.');
}

request<T>(opts: GaxiosOptions): GaxiosPromise<T> {

Check warning on line 61 in test/test.downscopedclient.ts

View workflow job for this annotation

GitHub Actions / lint

'opts' is defined but never used
throw new Error('Not implemented.');
}
}
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
Loading