mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-15 10:44:50 -04:00
Add JWT Verify, Decode and Sign
This commit is contained in:
parent
3905c01a0d
commit
8559f5c8ea
5 changed files with 198 additions and 1 deletions
46
src/core/operations/JWTDecode.mjs
Normal file
46
src/core/operations/JWTDecode.mjs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @author gchq77703 []
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
/**
|
||||
* JWT Decode operation
|
||||
*/
|
||||
class JWTDecode extends Operation {
|
||||
|
||||
/**
|
||||
* JWTDecode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
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.inputType = "string";
|
||||
this.outputType = "JSON";
|
||||
this.args = [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {JSON}
|
||||
*/
|
||||
run(input, args) {
|
||||
try {
|
||||
return jwt.decode(input);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default JWTDecode;
|
Loading…
Add table
Add a link
Reference in a new issue