Tidied up JWT ops

This commit is contained in:
n1474335 2021-02-09 14:14:59 +00:00
parent 5bc523aeff
commit 9fdd55c5c6
3 changed files with 3 additions and 8 deletions

View File

@ -21,4 +21,4 @@ export const JWT_ALGORITHMS = [
"ES384",
"ES512",
"None"
];
];

View File

@ -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";

View File

@ -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);