Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (header.enc !== expectedEnc) {
throw new RPError({
printf: ['unexpected JWE enc received, expected %s, got: %s', expectedEnc, header.enc],
jwt: jwe,
});
}
let keyOrStore;
if (expectedAlg.match(/^(?:RSA|ECDH)/)) {
keyOrStore = instance(this).get('keystore');
} else {
keyOrStore = await this.joseSecret(expectedAlg === 'dir' ? expectedEnc : expectedAlg);
}
const payload = jose.JWE.decrypt(jwe, keyOrStore);
return payload.toString('utf8');
}