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

jws.decode support for encoding option #86

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

joelabrahamsson
Copy link

jws.sign supports specifying encoding but jws.decode doesn't (although the payloadFromJWS function has an unused encoding parameter). This pull request aims to fix this.

@@ -66,7 +66,7 @@ function jwsDecode(jwsSig, opts) {
if (!header)
return null;

var payload = payloadFromJWS(jwsSig);
var payload = payloadFromJWS(jwsSig, opts.encoding);
if (header.typ === 'JWT' || opts.json)
payload = JSON.parse(payload, opts.encoding);
Copy link

@loucadufault loucadufault Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove opts.encoding as a second argument to JSON.parse, as this is an argument for the reviver function, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse:

Non-callable values are ignored.

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.

6 participants