Básicamente estoy haciendo esto:
const secretKey = crypto.createSecretKey( Buffer.from(process.env.SECRET, "hex") );Y me sale el siguiente error: "El valor de "key.byteLength" está fuera de rango. Debe ser > 0. Recibido 0"
Reemplazar process.env.SECRET con el secreto en sí funciona.
export const createToken = async (id) => { const secretKey = crypto.createSecretKey( Buffer.from(process.env.SECRET, "hex") ); return await new EncryptJWT({ id }) .setProtectedHeader({ alg: "dir", enc: "A256GCM" }) .setIssuedAt() .setExpirationTime("14d") .encrypt(secretKey); };