From 9fdd55c5c67f197712a681625d2278e36c510d3c Mon Sep 17 00:00:00 2001 From: n1474335 Date: Tue, 9 Feb 2021 14:14:59 +0000 Subject: [PATCH] Tidied up JWT ops --- src/core/lib/JWT.mjs | 2 +- src/core/operations/JWTSign.mjs | 2 -- src/core/operations/JWTVerify.mjs | 7 ++----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/lib/JWT.mjs b/src/core/lib/JWT.mjs index 2edd0110..fee7fec5 100644 --- a/src/core/lib/JWT.mjs +++ b/src/core/lib/JWT.mjs @@ -21,4 +21,4 @@ export const JWT_ALGORITHMS = [ "ES384", "ES512", "None" -]; \ No newline at end of file +]; diff --git a/src/core/operations/JWTSign.mjs b/src/core/operations/JWTSign.mjs index 1d220cf8..af46908e 100644 --- a/src/core/operations/JWTSign.mjs +++ b/src/core/operations/JWTSign.mjs @@ -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"; diff --git a/src/core/operations/JWTVerify.mjs b/src/core/operations/JWTVerify.mjs index 9ee90a4a..6d334f5b 100644 --- a/src/core/operations/JWTVerify.mjs +++ b/src/core/operations/JWTVerify.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);