Open
Description
This was an issue found during the work I did for #497.
What
When passing an empty string to "notBefore". it throws a val is not a non-empty string or a valid number. val=""
from the ms
library. I would expect this to throw '"notBefore" should be a number of seconds or string representing a timespan'
which is the same error as other invalid inputs.
Test Case
const jwt = require('jsonwebtoken');
jwt.sign({}, undefined, {
algorithm: 'none',
notBefore: ''
});
Expected Output
/home/mitmaro/jwt-test/node_modules/jsonwebtoken/sign.js:98
throw err;
^
Error: "notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60
at Object.module.exports [as sign] (/home/mitmaro/jwt-test/node_modules/jsonwebtoken/sign.js:153:22)
at Object.<anonymous> (/home/mitmaro/jwt-test/test.js:2:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
Actual Output
/home/mitmaro/test/node_modules/jsonwebtoken/node_modules/ms/index.js:34
throw new Error(
^
Error: val is not a non-empty string or a valid number. val=""
at module.exports (/home/mitmaro/jwt-test/node_modules/jsonwebtoken/node_modules/ms/index.js:34:9)
at module.exports (/home/mitmaro/jwt-test/node_modules/jsonwebtoken/lib/timespan.js:7:24)
at Object.module.exports [as sign] (/home/mitmaro/jwt-test/node_modules/jsonwebtoken/sign.js:151:19)
at Object.<anonymous> (/home/mitmaro/jwt-test/test.js:2:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
Metadata
Metadata
Assignees
Labels
No labels