diff --git a/src/core/lib/JWT.mjs b/src/core/lib/JWT.mjs index fee7fec5..57a82d21 100644 --- a/src/core/lib/JWT.mjs +++ b/src/core/lib/JWT.mjs @@ -19,6 +19,5 @@ export const JWT_ALGORITHMS = [ "RS512", "ES256", "ES384", - "ES512", - "None" + "ES512" ]; diff --git a/src/core/operations/JWTSign.mjs b/src/core/operations/JWTSign.mjs index af46908e..813b8b26 100644 --- a/src/core/operations/JWTSign.mjs +++ b/src/core/operations/JWTSign.mjs @@ -26,6 +26,7 @@ class JWTSign extends Operation { this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token"; this.inputType = "JSON"; this.outputType = "string"; + const algorithmList = JWT_ALGORITHMS.concat(["None"]); this.args = [ { name: "Private/Secret Key", @@ -35,7 +36,7 @@ class JWTSign extends Operation { { name: "Signing algorithm", type: "option", - value: JWT_ALGORITHMS + value: algorithmList } ]; } diff --git a/src/core/operations/JWTVerify.mjs b/src/core/operations/JWTVerify.mjs index 6b06d914..3d86ec31 100644 --- a/src/core/operations/JWTVerify.mjs +++ b/src/core/operations/JWTVerify.mjs @@ -26,8 +26,7 @@ class JWTVerify extends Operation { this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token"; this.inputType = "string"; this.outputType = "JSON"; - const algOptions = JWT_ALGORITHMS; - algOptions.push("Any"); + const algorithmList = JWT_ALGORITHMS.concat(["Any"]); this.args = [ { name: "Public/Secret Key", @@ -37,7 +36,7 @@ class JWTVerify extends Operation { { name: "Signing algorithm", type: "option", - value: algOptions + value: algorithmList } ]; } @@ -49,19 +48,7 @@ class JWTVerify extends Operation { */ run(input, args) { const [key, alg] = args; - let algos = []; - switch (alg) { - case "Any": - algos = JWT_ALGORITHMS; - break; - case "None": - algos.push("none"); - break; - default: - algos.push(alg); - break; - } - + let algos = (alg == "Any" ? JWT_ALGORITHMS : alg); try { const verified = jwt.verify(input, key, { algorithms: algos });