Last active
July 30, 2020 15:11
-
-
Save JohnMarkT/c5dbc393e8af92feb453be372129309a to your computer and use it in GitHub Desktop.
Only performs basic validation, not verification. Returns object original JWT, unencrypted and parsed payload, and valid boolean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateJWT(jwt) { | |
let payload = {}, valid = false | |
try { | |
[, payload] = jwt.split('.').slice(0,2).map(p => JSON.parse(atob(p))) | |
valid = true | |
} catch (error) {} | |
return { jwt, payload, valid } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment