How to use the jws.verify function in jws

To help you get started, we’ve selected a few jws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github didinj / node-express-mongoose-passport-jwt-rest-api-auth / node_modules / jsonwebtoken / .history / verify_20170327175443.js View on Github external
}

  if (!decodedToken) {
    return done(new JsonWebTokenError('invalid token'));
  }

  var header = decodedToken.header;
console.log({header});
  // if (!~options.algorithms.indexOf(header.alg)) {
  //   return done(new JsonWebTokenError('invalid algorithm'));
  // }

  var valid;

  try {
    valid = jws.verify(jwtString, header.alg, secretOrPublicKey);
  } catch (e) {
    return done(e);
  }

  if (!valid)
    return done(new JsonWebTokenError('invalid signature'));

  var payload;

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

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
github didinj / node-express-mongoose-passport-jwt-rest-api-auth / node_modules / jsonwebtoken / .history / verify_20170327175706.js View on Github external
}

  if (!decodedToken) {
    return done(new JsonWebTokenError('invalid token'));
  }

  var header = decodedToken.header;
console.log({header});
  if (!~options.algorithms.indexOf(header.alg)) {
    return done(new JsonWebTokenError('invalid algorithm'));
  }

  var valid;

  try {
    valid = jws.verify(jwtString, header.alg, secretOrPublicKey);
  } catch (e) {
    return done(e);
  }

  if (!valid)
    return done(new JsonWebTokenError('invalid signature'));

  var payload;

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

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
github didinj / node-express-mongoose-passport-jwt-rest-api-auth / node_modules / jsonwebtoken / .history / verify_20170327175426.js View on Github external
}

  if (!decodedToken) {
    return done(new JsonWebTokenError('invalid token'));
  }

  var header = decodedToken.header;
console.log({header});
  if (!~options.algorithms.indexOf(header.alg)) {
    return done(new JsonWebTokenError('invalid algorithm'));
  }

  var valid;

  try {
    valid = jws.verify(jwtString, header.alg, secretOrPublicKey);
  } catch (e) {
    return done(e);
  }

  if (!valid)
    return done(new JsonWebTokenError('invalid signature'));

  var payload;

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

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
github didinj / node-express-mongoose-passport-jwt-rest-api-auth / node_modules / jsonwebtoken / .history / verify_20170327175344.js View on Github external
}

  if (!decodedToken) {
    return done(new JsonWebTokenError('invalid token'));
  }

  var header = decodedToken.header;
console.log({decodedToken});
  if (!~options.algorithms.indexOf(header.alg)) {
    return done(new JsonWebTokenError('invalid algorithm'));
  }

  var valid;

  try {
    valid = jws.verify(jwtString, header.alg, secretOrPublicKey);
  } catch (e) {
    return done(e);
  }

  if (!valid)
    return done(new JsonWebTokenError('invalid signature'));

  var payload;

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

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
github openstf / stf / lib / util / jwtutil.js View on Github external
module.exports.decode = function(payload, secret) {
  if (!jws.verify(payload, 'HS256', secret)) {
    return null
  }

  var decoded = jws.decode(payload, {
        json: true
      })
    , exp = decoded.header.exp

  if (exp && exp <= Date.now()) {
    return null
  }

  return decoded.payload
}
github didinj / node-express-mongoose-passport-jwt-rest-api-auth / node_modules / jsonwebtoken / verify.js View on Github external
~secretOrPublicKey.toString().indexOf('BEGIN PUBLIC KEY') ?
        ['RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512'] :
        ~secretOrPublicKey.toString().indexOf('BEGIN RSA PUBLIC KEY') ?
          ['RS256', 'RS384', 'RS512'] :
          ['HS256', 'HS384', 'HS512'];

    }

    if (!~options.algorithms.indexOf(decodedToken.header.alg)) {
      return done(new JsonWebTokenError('invalid algorithm'));
    }

    var valid;

    try {
      valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey);
    } catch (e) {
      return done(e);
    }

    if (!valid) {
      return done(new JsonWebTokenError('invalid signature'));
    }

    var payload = decodedToken.payload;

    if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
      if (typeof payload.nbf !== 'number') {
        return done(new JsonWebTokenError('invalid nbf value'));
      }
      if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) {
        return done(new NotBeforeError('jwt not active', new Date(payload.nbf * 1000)));
github onmyway133 / PushNotifications / node_modules / jsonwebtoken / verify.js View on Github external
}

  if (!decodedToken) {
    return done(new JsonWebTokenError('invalid token'));
  }

  var header = decodedToken.header;

  if (!~options.algorithms.indexOf(header.alg)) {
    return done(new JsonWebTokenError('invalid algorithm'));
  }

  var valid;

  try {
    valid = jws.verify(jwtString, header.alg, secretOrPublicKey);
  } catch (e) {
    return done(e);
  }

  if (!valid)
    return done(new JsonWebTokenError('invalid signature'));

  var payload;

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

  if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
github irislib / identifi-daemon / message.js View on Github external
verify: function(msg, pubKey) {
    this.decode(msg);
    return jws.verify(msg.jws, msg.jwsHeader.alg, pubKey); 
  },
github mozilla / openbadges-validator / index.js View on Github external
function taskVerifySignature (next, data) {
  if (data.parse.type != 'signed') {
    return next(null, 'Only required for signed verification');
  }
  var algorithm = data.assertion.header.alg;
  const publicKey = data.resources['assertion.verify.url'];
  if (!jws.verify(data.raw.input, algorithm, publicKey))
    return next(makeError('verify-signature'));
  return next(null, true);
}

jws

Implementation of JSON Web Signatures

MIT
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis