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

{ canonicalize: true } stringifies the payload twice #171

Closed
yhuard opened this issue May 19, 2021 · 2 comments · Fixed by #172
Closed

{ canonicalize: true } stringifies the payload twice #171

yhuard opened this issue May 19, 2021 · 2 comments · Fixed by #172

Comments

@yhuard
Copy link
Contributor

yhuard commented May 19, 2021

Hi!

When using the new { canonicalize: true } param in createJWT, the JWT generated looks incorrect. It produces something like: IntcImFsZ1wiOlwiRVMyNTZLXCJ9Ig.IntcImFcIjpcImFcIixcInpcIjpcInpcIn0i.aKyOmGo5Dx2VsvDZAAHMxNtgqBeI0-qij4OB2AsISFdGsnNDJNEptZkQjY497mzX1LdMPS84pzykqalPtMwqMQ (extracted from the tests).

image

The issue is that the lib runs JSON.stringify on an already-stringified object:

return encodeBase64url(JSON.stringify(canonicalizeData(data)))
(canonicalizeData returns a string)

I can make a PR to remove the extra JSON.stringify.

Thanks!

@yhuard yhuard changed the title Issue with canonicalize { canonicalize: true } stringifies the payload twice May 19, 2021
@mirceanis
Copy link
Member

great catch!
yes, a PR is welcome.

uport-automation-bot pushed a commit that referenced this issue May 19, 2021
## [5.4.1](5.4.0...5.4.1) (2021-05-19)

### Bug Fixes

* don't run JSON.stringify on canonicalized data ([#172](#172)) ([5480bfc](5480bfc)), closes [#171](#171)
@uport-automation-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 5.4.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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants