Tidied up JWT ops

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

No files matched your search

+1 -1
View File
@@ -21,4 +21,4 @@ export const JWT_ALGORITHMS = [
"ES384",
"ES512",
"None"
];
];
-2
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";
+2 -5
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);