Skip to content

Conversation

@JHubi1
Copy link
Contributor

@JHubi1 JHubi1 commented Feb 2, 2025

I use the JWT.decode method quite often. I believe it is less resource intense (idk), and easier to implement, because you don't have to set all the check parameters.

One thing that's always getting on my nerves is that the function doesn't set the necessary attributes of the JWT object, which makes it harder to work with (arguably not much harder but harder nonetheless).

I'm not sure whether this is a brilliant idea or not. As far as I can tell, nothing should break, but there were no tests and I didn't want to write my own, so I couldn't really test. I added documentation though that lets devs know to use this values with caution as they are not checked.

Set audience, issuer, subject and jwtId when using the JWT.decode function
@JHubi1 JHubi1 requested a review from jonasroussel as a code owner February 2, 2025 08:37
@jonasroussel
Copy link
Owner

You are right, JWT.decode is way faster, because it doesn't have to calculate the RSA/EC.. signature.
The only thing to keep in mind is by consequence the payload (and header) could not be trusted. But works fine if you just want to see what inside the token, and there is no reason to not parse the standard fields, nice add!

I just used you PR to make some refacto to the original code, merge the PR that I created on your fork https://github.com/JHubi1/dart_jsonwebtoken/pull/1 and I can push and publish this one

refactor: simplify decode method
@JHubi1
Copy link
Contributor Author

JHubi1 commented Feb 3, 2025

Merged it

@jonasroussel jonasroussel merged commit c3a908d into jonasroussel:main Feb 3, 2025
2 checks passed
@jonasroussel
Copy link
Owner

Added in the last version: https://pub.dev/packages/dart_jsonwebtoken/versions/2.17.0

@JHubi1
Copy link
Contributor Author

JHubi1 commented Feb 3, 2025

Thank you very much

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

Successfully merging this pull request may close these issues.

2 participants