Skip to content

Commit

Permalink
fix: correct AuthenticatorInterface type (#206)
Browse files Browse the repository at this point in the history
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 does not constitute a breaking update as we
already defined authenticators with the new type in this project.

Resolves #176

Signed-off-by: Dustin Popp <dpopp07@gmail.com>
  • Loading branch information
dpopp07 committed Jul 28, 2022
1 parent 552239b commit 31dc7bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion auth/authenticators/authenticator-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface AuthenticatorInterface {
* @param {object.<string, string>} requestOptions.headers The headers the
* authentication information will be added to.
*/
authenticate(requestOptions: AuthenticateOptions): Promise<void | Error>;
authenticate(requestOptions: AuthenticateOptions): Promise<void>;

/**
* Returns a string that indicates the authentication type.
Expand Down
2 changes: 1 addition & 1 deletion auth/authenticators/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void | Error> {
public authenticate(requestOptions: AuthenticateOptions): Promise<void> {
const error = new Error('Should be implemented by subclass!');
return Promise.reject(error);
}
Expand Down
2 changes: 1 addition & 1 deletion auth/authenticators/basic-authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class BasicAuthenticator extends Authenticator {
* @param {object.<string, string>} requestOptions.headers - The headers the
* authentication information will be added too.
*/
public authenticate(requestOptions: AuthenticateOptions): Promise<void | Error> {
public authenticate(requestOptions: AuthenticateOptions): Promise<void> {
return new Promise((resolve) => {
requestOptions.headers = extend(true, {}, requestOptions.headers, this.authHeader);
resolve();
Expand Down
2 changes: 1 addition & 1 deletion auth/authenticators/token-request-based-authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void | Error> {
public authenticate(requestOptions: AuthenticateOptions): Promise<void> {
return this.tokenManager.getToken().then((token) => {
const authHeader = { Authorization: `Bearer ${token}` };
requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
Expand Down
8 changes: 4 additions & 4 deletions etc/ibm-cloud-sdk-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<void | Error>;
authenticate(requestOptions: AuthenticateOptions): Promise<void>;
authenticationType(): string;
static AUTHTYPE_BASIC: string;
// (undocumented)
Expand All @@ -42,7 +42,7 @@ export class Authenticator implements AuthenticatorInterface {

// @public
export interface AuthenticatorInterface {
authenticate(requestOptions: AuthenticateOptions): Promise<void | Error>;
authenticate(requestOptions: AuthenticateOptions): Promise<void>;
authenticationType(): string;
}

Expand Down Expand Up @@ -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<void | Error>;
authenticate(requestOptions: AuthenticateOptions): Promise<void>;
authenticationType(): string;
// (undocumented)
protected authHeader: {
Expand Down Expand Up @@ -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<void | Error>;
authenticate(requestOptions: AuthenticateOptions): Promise<void>;
// (undocumented)
protected disableSslVerification: boolean;
// (undocumented)
Expand Down

0 comments on commit 31dc7bd

Please sign in to comment.