I'm basically doing this:
const secretKey = crypto.createSecretKey(
Buffer.from(process.env.SECRET, "hex")
);
And I get the following error: "The value of "key.byteLength" is out of range. It must be > 0. Received 0"
Replacing the process.env.SECRET with the secret itself works.
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);
};