Skip to content

Commit

Permalink
Merge pull request #181 from felixse/fix-jwt-decode-script
Browse files Browse the repository at this point in the history
fix JWTDecode.js
  • Loading branch information
IvanMathy authored Sep 21, 2020
2 parents 4f45d92 + 1387803 commit ccf8015
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Boop/Boop/scripts/JWTDecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
**/


const { base64decode } = require('@boop/base64')
const { decode } = require('@boop/base64');

function main(input) {
var t = input.text
var jwtParts = t.split(".")
if(jwtParts.length != 3) {
input.postError("Invalid Token")
return
var t = input.text;
var jwtParts = t.split(".");
if (jwtParts.length != 3) {
input.postError("Invalid Token");
return;
}

var header = base64decode(jwtParts[0]);
var payload = base64decode(jwtParts[1]);
var header = decode(jwtParts[0]);
var payload = decode(jwtParts[1]);
var signature = jwtParts[2];

try {
var fullJson = {
"header": JSON.parse(header),
"payload": JSON.parse(payload),
"signature": signature
}
};

// Prettyprint the JSOM
input.text = JSON.stringify(fullJson, null, 2);
} catch(err) {
input.postError("Error while parsing JSON")
input.postError("Error while parsing JSON");
}
}

0 comments on commit ccf8015

Please sign in to comment.