Skip to content

Conversation

@gaku-sei
Copy link
Owner

Unregistered claims will now get inserted at the top level, and not under the "unregistered" attribute anymore. I had to handle the flatten/normalize logic in JS, and since object spread is not yet supported in PureScript's JavaScript (quintenkasteel/language-javascript#118) the code is a bit verbose. Once the above pr is merged, the code should be way cleaner.

<> (Options.jwtid := jti)
<> (Options.subject := sub)
<> (Options.keyid := kid)
<> (Options.header := signHeaderOptions)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Cleaned up the options as well

verify (Secret secret) s = (note (singleton "Couldn't verify token") $ runFn4 _verify Just Nothing s secret) >>= foreignToToken

verify' :: Secret -> String -> Either (NonEmptyList String) (Token () Unverified)
verify' = verify
Copy link
Owner Author

Choose a reason for hiding this comment

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

decode' and verify' are useful when dealing with token that have no unregistered claims, or when the unregistered claims don't matter.

@gaku-sei gaku-sei force-pushed the flatten-unregistered branch from a8415d4 to eaa5333 Compare July 31, 2020 04:27
exports._decode = function decode(just, nothing, token) {
const registeredClaimsKeys = ["iss", "sub", "aud", "exp", "nbf", "iat", "jti"];

// TODO: Remove this when https://github.com/erikd/language-javascript/pull/118 is merged
Copy link
Owner Author

Choose a reason for hiding this comment

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

Hopefully merged soon, the partitionClaims function is unsafe, dirty, and verbose 😕

@gaku-sei gaku-sei merged commit d3d2a2c into master Jul 31, 2020
@gaku-sei gaku-sei deleted the flatten-unregistered branch July 31, 2020 04:28
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