Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = ({ name, secret, duration, cookieOptions = {} }) => {
let current;
const COOKIES = Symbol('cookies');
const alg = 'dir';
const enc = 'A256GCM';
let keystore = new JWKS.KeyStore();
if (!Array.isArray(secret)) {
secret = [secret];
}
secret.forEach((secretString, i) => {
const key = JWK.asKey(deriveKey(secretString));
if (i === 0) {
current = key;
}
keystore.add(key);
});
if (keystore.size === 1) {
keystore = current;
}