Skip to content

verify error message is sometimes "invalid token" instead of documented "jwt malformed" #768

Closed
@jedwards1211

Description

@jedwards1211

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions