mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-15 18:54:56 -04:00
Adding in tests and changing formatting
This commit is contained in:
parent
2058f8a1eb
commit
7adb820c40
3 changed files with 98 additions and 9 deletions
|
@ -25,7 +25,13 @@ class JWTDecode extends Operation {
|
|||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||
this.inputType = "string";
|
||||
this.outputType = "JSON";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Include header",
|
||||
type: "boolean",
|
||||
value: false
|
||||
}
|
||||
];
|
||||
this.checks = [
|
||||
{
|
||||
pattern: "^ey([A-Za-z0-9_-]+)\\.ey([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)$",
|
||||
|
@ -42,12 +48,20 @@ class JWTDecode extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
try {
|
||||
const headerInclude = args[0];
|
||||
|
||||
const decoded = jwt.decode(input, {
|
||||
json: true,
|
||||
complete: true
|
||||
});
|
||||
|
||||
return {header: decoded.header, payload: decoded.payload};
|
||||
if (headerInclude)
|
||||
{
|
||||
return {header: decoded.header, payload: decoded.payload};
|
||||
}
|
||||
else
|
||||
{
|
||||
return decoded.payload;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue