Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static loadSignature(joseSignature: string | Buffer) {
// create and return the DER-formatted signature buffer
return joseToDer(joseSignature, 'ES256')
}
return function verify(thing, signature, publicKey) {
signature = formatEcdsa.joseToDer(signature, 'ES' + bits).toString('base64');
var result = inner(thing, signature, publicKey);
return result;
};
}
return function verify(thing, signature, publicKey) {
signature = formatEcdsa.joseToDer(signature, 'ES' + bits).toString('base64');
var result = inner(thing, signature, publicKey);
return result;
};
}
var verified, digest;
if (cryptoAlgName === 'none') {
verified = true;
} else if (signingType === 'hmac') {
digest = crypto.createHmac(cryptoAlgName, this.signingKey)
.update(digstInput)
.digest('base64');
verified = signature === digest;
} else {
var unescapedSignature;
var signatureType = undefined;
if (helpers.isECDSA(header.alg)) {
try {
unescapedSignature = ecdsaSigFormatter.joseToDer(signature, header.alg);
} catch (err) {
return done(new errors.SignatureMismatchJwtParseError(jwtString, header, body, err));
}
} else {
signatureType = 'base64';
unescapedSignature = helpers.base64urlUnescape(signature);
}
verified = crypto.createVerify(cryptoAlgName)
.update(digstInput)
.verify(this.signingKey, unescapedSignature, signatureType);
}
var newJwt = new Jwt(body, false);
newJwt.toString = function () {