mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Tidied up JWT operations
This commit is contained in:
parent
100b097ace
commit
be14d56eae
9 changed files with 147 additions and 51 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
import Operation from "../Operation";
|
||||
import jwt from "jsonwebtoken";
|
||||
import OperationError from "../errors/OperationError";
|
||||
|
||||
/**
|
||||
* JWT Decode operation
|
||||
|
@ -20,12 +21,11 @@ class JWTDecode extends Operation {
|
|||
|
||||
this.name = "JWT Decode";
|
||||
this.module = "Crypto";
|
||||
this.description = "Decodes a JSON Web Token without checking whether the provided secret / private key is valid.";
|
||||
this.infoURL = "https://jwt.io";
|
||||
this.description = "Decodes a JSON Web Token <b>without</b> checking whether the provided secret / private key is valid. Use 'JWT Verify' to check if the signature is valid as well.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||
this.inputType = "string";
|
||||
this.outputType = "JSON";
|
||||
this.args = [
|
||||
];
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,9 +35,14 @@ class JWTDecode extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
try {
|
||||
return jwt.decode(input);
|
||||
const decoded = jwt.decode(input, {
|
||||
json: true,
|
||||
complete: true
|
||||
});
|
||||
|
||||
return decoded.payload;
|
||||
} catch (err) {
|
||||
return err;
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue