IBM/node-sdk-core

Authenticator returns `Promise<void | Error>`

CarstenLeue opened this issue ยท 2 comments

The authenticator interface has the following syntax:

public authenticate(requestOptions: AuthenticateOptions): Promise<void | Error>

https://github.com/IBM/node-sdk-core/blob/main/auth/authenticators/authenticator.ts

Normally a Promise handles errors via its exception channel and regular values via its data channel. The type parameter identifies the data channel, promises do not have a way to specify the type of the exceptional channel.

Is it indeed intended to pass an error on the data channel? If so, why?
If not, the signature should be:

public authenticate(requestOptions: AuthenticateOptions): Promise<void>

@CarstenLeue Thanks for this issue. You're right and it is not intended for an error to sent over a Promise's data channel. That will not happen and the incorrect type was an oversight. We will correct this but as it stands, it will be a breaking change and therefore will require a new major release.

This interface is in place to allow users to write their own, custom authenticator implementations. If we change the interface, their authenticators will no longer be compatible with our code. I believe your issue #174 will also require a major release to resolve so for now I'll plan on doing them together at some point (hopefully, in the near future).

๐ŸŽ‰ This issue has been resolved in version 3.0.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€