mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 14:11:02 +01:00
Tidied up JWT ops
This commit is contained in:
parent
5bc523aeff
commit
9fdd55c5c6
@ -21,4 +21,4 @@ export const JWT_ALGORITHMS = [
|
||||
"ES384",
|
||||
"ES512",
|
||||
"None"
|
||||
];
|
||||
];
|
||||
|
@ -3,11 +3,9 @@
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import jwt from "jsonwebtoken";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
import {JWT_ALGORITHMS} from "../lib/JWT.mjs";
|
||||
|
||||
|
||||
|
@ -3,14 +3,12 @@
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import jwt from "jsonwebtoken";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
|
||||
import {JWT_ALGORITHMS} from "../lib/JWT.mjs";
|
||||
|
||||
|
||||
/**
|
||||
* JWT Verify operation
|
||||
*/
|
||||
@ -46,8 +44,7 @@ class JWTVerify extends Operation {
|
||||
const [key] = args;
|
||||
|
||||
try {
|
||||
const verified = jwt.verify(input, key, { algorithms: JWT_ALGORITHMS});
|
||||
|
||||
const verified = jwt.verify(input, key, { algorithms: JWT_ALGORITHMS });
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(verified, "name") && verified.name === "JsonWebTokenError") {
|
||||
throw new OperationError(verified.message);
|
||||
|
Loading…
Reference in New Issue
Block a user