Updated algorithm selection

This commit is contained in:
Michael Rowley 2022-03-21 20:50:43 +00:00
parent 8332e39b6b
commit d23d98d2a0
3 changed files with 6 additions and 19 deletions

View file

@ -19,6 +19,5 @@ export const JWT_ALGORITHMS = [
"RS512",
"ES256",
"ES384",
"ES512",
"None"
"ES512"
];

View file

@ -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
}
];
}

View file

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