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

Allow type hinting on JwtHelperService.decodeToken method #678

Closed
patricio-ezequiel-hondagneu-roig opened this issue Sep 20, 2020 · 0 comments

Comments

@patricio-ezequiel-hondagneu-roig
Copy link
Contributor

Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.

Thank you in advance for helping us to improve this library! Your attention to detail here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.

By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

At the moment of this issue, the JwtHelperService.decodeToken method has a return type of any and the user cannot hint the type of the returned value, even if it is known beforehand.

Describe the ideal solution

The user should be able to tell the type of the returned value if it's known beforehand, and have a return type of any only when the user doesn't specify it. With only the addition of a generic type parameter to the method (that defaults to any), it could allow for the consumer to hint the type of the returned value, with no breaking changes at all.

Alternatives and current work-arounds

The current workaround is to always use a type assertion on the returned value, like <MyToken> jwtHelperService.decodeToken( 'token string' ) to override the type of the expression.

Additional context

I have downloaded the repository and tried the proposed solution and it works. The screenshots are published here: Imgur album.

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

No branches or pull requests

1 participant