From 65ec81b4138c41f06d3a573a1587da6bb361ee51 Mon Sep 17 00:00:00 2001 From: Dustin Popp Date: Thu, 28 Jul 2022 10:21:01 -0500 Subject: [PATCH] fix: correct AuthenticatorInterface type The interface incorrectly defined the data channel as "void or Error" when it should only be "void", as Errors are sent in a different channel. This updates the type to be correct. It should not constitute a breaking update as we already defined authenticators with the new type in this project. Signed-off-by: Dustin Popp --- auth/authenticators/authenticator-interface.ts | 2 +- auth/authenticators/authenticator.ts | 2 +- auth/authenticators/basic-authenticator.ts | 2 +- auth/authenticators/token-request-based-authenticator.ts | 2 +- etc/ibm-cloud-sdk-core.api.md | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/auth/authenticators/authenticator-interface.ts b/auth/authenticators/authenticator-interface.ts index 92a741c51..551f84f2d 100644 --- a/auth/authenticators/authenticator-interface.ts +++ b/auth/authenticators/authenticator-interface.ts @@ -44,7 +44,7 @@ export interface AuthenticatorInterface { * @param {object.} requestOptions.headers The headers the * authentication information will be added to. */ - authenticate(requestOptions: AuthenticateOptions): Promise; + authenticate(requestOptions: AuthenticateOptions): Promise; /** * Returns a string that indicates the authentication type. diff --git a/auth/authenticators/authenticator.ts b/auth/authenticators/authenticator.ts index 95b6a751e..9979388fb 100644 --- a/auth/authenticators/authenticator.ts +++ b/auth/authenticators/authenticator.ts @@ -63,7 +63,7 @@ export class Authenticator implements AuthenticatorInterface { * @throws {Error} - The authenticate method was not implemented by a * subclass. */ - public authenticate(requestOptions: AuthenticateOptions): Promise { + public authenticate(requestOptions: AuthenticateOptions): Promise { const error = new Error('Should be implemented by subclass!'); return Promise.reject(error); } diff --git a/auth/authenticators/basic-authenticator.ts b/auth/authenticators/basic-authenticator.ts index cfbce9c2f..20bd83699 100644 --- a/auth/authenticators/basic-authenticator.ts +++ b/auth/authenticators/basic-authenticator.ts @@ -69,7 +69,7 @@ export class BasicAuthenticator extends Authenticator { * @param {object.} requestOptions.headers - The headers the * authentication information will be added too. */ - public authenticate(requestOptions: AuthenticateOptions): Promise { + public authenticate(requestOptions: AuthenticateOptions): Promise { return new Promise((resolve) => { requestOptions.headers = extend(true, {}, requestOptions.headers, this.authHeader); resolve(); diff --git a/auth/authenticators/token-request-based-authenticator.ts b/auth/authenticators/token-request-based-authenticator.ts index 831346e03..358f72fd9 100644 --- a/auth/authenticators/token-request-based-authenticator.ts +++ b/auth/authenticators/token-request-based-authenticator.ts @@ -119,7 +119,7 @@ export class TokenRequestBasedAuthenticator extends Authenticator { * authentication information will be added too. Overrides default headers * where there's conflict. */ - public authenticate(requestOptions: AuthenticateOptions): Promise { + public authenticate(requestOptions: AuthenticateOptions): Promise { return this.tokenManager.getToken().then((token) => { const authHeader = { Authorization: `Bearer ${token}` }; requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader); diff --git a/etc/ibm-cloud-sdk-core.api.md b/etc/ibm-cloud-sdk-core.api.md index c4d5f4346..d50be9732 100644 --- a/etc/ibm-cloud-sdk-core.api.md +++ b/etc/ibm-cloud-sdk-core.api.md @@ -21,7 +21,7 @@ export function atMostOne(a: any, b: any): boolean; export class Authenticator implements AuthenticatorInterface { constructor(); // Warning: (ae-forgotten-export) The symbol "AuthenticateOptions" needs to be exported by the entry point index.d.ts - authenticate(requestOptions: AuthenticateOptions): Promise; + authenticate(requestOptions: AuthenticateOptions): Promise; authenticationType(): string; static AUTHTYPE_BASIC: string; // (undocumented) @@ -42,7 +42,7 @@ export class Authenticator implements AuthenticatorInterface { // @public export interface AuthenticatorInterface { - authenticate(requestOptions: AuthenticateOptions): Promise; + authenticate(requestOptions: AuthenticateOptions): Promise; authenticationType(): string; } @@ -72,7 +72,7 @@ export class BaseService { export class BasicAuthenticator extends Authenticator { // Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts constructor(options: Options); - authenticate(requestOptions: AuthenticateOptions): Promise; + authenticate(requestOptions: AuthenticateOptions): Promise; authenticationType(): string; // (undocumented) protected authHeader: { @@ -390,7 +390,7 @@ export type TokenManagerOptions = { export class TokenRequestBasedAuthenticator extends Authenticator { // Warning: (ae-forgotten-export) The symbol "BaseOptions" needs to be exported by the entry point index.d.ts constructor(options: BaseOptions); - authenticate(requestOptions: AuthenticateOptions): Promise; + authenticate(requestOptions: AuthenticateOptions): Promise; // (undocumented) protected disableSslVerification: boolean; // (undocumented)