Replies: 2 comments 3 replies
-
On one hand, I can definetly see the benefit. On the other hand, it has always worked like this and the intention of this new major version was not to reinvent the library, but merely modernize things abit in terms of setup, drop polyfills and ESM/CJS. Even more so, the intention was not to change the public API, but we eventually did for the sake of ESM/CJS. Personally, I like what you propose over what we currently have. However, no one has ever asked for anything like that so I am more keen to keeping things as is. On top of that, even though the difference is minimal, it's slightly easier to migrate if we keep it as is. |
Beta Was this translation helpful? Give feedback.
-
Having discussed this internally with the team, we believe we want to leave the API as is. The current codebase is only a couple of lines and exports a single function and we would like to keep it like that to leave the public API as stable as possible. We understand adding these two functions wouldn't break anything, but we also feel like it's not something we want to add at the moment, especially given the little value it adds compared to the documentation/blogposts/stack overflow being out there about jwt-decode. |
Beta Was this translation helpful? Give feedback.
-
I was thinking, since we're changing the public API for v4 anyways, would it perhaps make more sense to have a separate function to decode the header? If would make our types less complex, as the decode function would no longer have a polymorphic return type.
For example, the following code:
Would become:
This would also allow further expansion quite easily, for example if we wanted to add support to read the signature:
Or perhaps we could even add a convenience method to do all of the above all at once:
Beta Was this translation helpful? Give feedback.
All reactions