Skip to content

Check payload before trying to get nbf #430

@Gp2mv3

Description

@Gp2mv3

In verify.js, I think there is an issue with the payload decoding. Or at least with robustness.
I receive some errors (TypeError: Cannot read property 'nbf' of null) with the following lines (Around line 110 of verify.js):

  var payload;

  try {
    payload = decode(jwtString);
  } catch(err) {
    return done(err);
  }

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
//...

The function decode sometimes (if the jwtString is malformed ?) returns null, isn't a good idea to check the payload before trying to use the nbf ?
It's a simple if in the try-catch, I can do a PR if needed.

Regards,

Gp2mv3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions