Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!signature) {
debug('verify.error.emptySig');
return false;
}
if (!header.alg) {
debug('verify.error.emptyAlg');
return false;
}
const signerDid = body[signerKey];
if (!signerDid) {
debug('verify.error.emptySignerDid');
return false;
}
if (isFromPublicKey(signerDid, signerPk) === false) {
debug('verify.error.signerDidAndPkNotMatch');
return false;
}
if (enforceTimestamp) {
const now = Math.ceil(Date.now() / 1000);
const exp = Number(body.exp) || 0;
const iat = Number(body.iat) || 0;
const nbf = Number(body.nbf) || 0;
debug('verify.enforceTimestamp', { now, exp, iat, nbf });
if (exp && exp + tolerance < now) {
debug('verify.error.expired');
return false;
}
if (iat && iat > now && iat - now > tolerance) {
debug('verify.error.issuedAt');