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

Authenticator returns Promise<void | Error> #176

Closed
CarstenLeue opened this issue Nov 5, 2021 · 2 comments · Fixed by #206
Closed

Authenticator returns Promise<void | Error> #176

CarstenLeue opened this issue Nov 5, 2021 · 2 comments · Fixed by #206
Labels

Comments

@CarstenLeue
Copy link
Contributor

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>
@dpopp07
Copy link
Member

dpopp07 commented Nov 11, 2021

@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).

dpopp07 added a commit that referenced this issue Jul 28, 2022
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>
ibm-devx-sdk pushed a commit that referenced this issue Jul 28, 2022
## [3.0.1](v3.0.0...v3.0.1) (2022-07-28)

### Bug Fixes

* correct AuthenticatorInterface type ([#206](#206)) ([31dc7bd](31dc7bd)), closes [#176](#176)
@ibm-devx-sdk
Copy link

🎉 This issue has been resolved in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants