Closed
Description
Description
I expected verify
to throw "jwt malformed" errors when it can't describe the problem more specifically. Instead, it's throwing "invalid token" in the following example:
Reproduction
const { sign, verify } = require('jsonwebtoken')
const secret = `;lkjaslknwineijlk4jlksdf`
const signed = sign({ foo: 'bar' }, secret)
try {
verify(signed.substring(1), secret)
} catch (error) {
// JsonWebTokenError: invalid token
console.error(error)
}
Environment
- Version of this library used: 8.5.1
- Version of the platform or framework used, if applicable: Node 12.16.0