fix: usar Web Crypto global (crypto.randomUUID) en auth.ts - node:crypto rompe el middleware de Edge Runtime
This commit is contained in:
+3
-2
@@ -1,11 +1,12 @@
|
|||||||
import { SignJWT, jwtVerify } from "jose"
|
import { SignJWT, jwtVerify } from "jose"
|
||||||
import crypto from "crypto"
|
|
||||||
|
|
||||||
// Secreto de firma: JWT_SECRET explícito > WEB_PASSWORD > secreto efímero
|
// Secreto de firma: JWT_SECRET explícito > WEB_PASSWORD > secreto efímero
|
||||||
// aleatorio (modo dev sin contraseña — las sesiones no sobreviven restart,
|
// aleatorio (modo dev sin contraseña — las sesiones no sobreviven restart,
|
||||||
// pero no hay nada hardcodeado ni predecible en el código).
|
// pero no hay nada hardcodeado ni predecible en el código).
|
||||||
|
// NOTA: usa Web Crypto global (crypto.randomUUID) porque auth.ts corre
|
||||||
|
// también en el middleware de Edge Runtime, donde node:crypto NO existe.
|
||||||
const SECRET = new TextEncoder().encode(
|
const SECRET = new TextEncoder().encode(
|
||||||
process.env.JWT_SECRET || process.env.WEB_PASSWORD || crypto.randomBytes(32).toString("hex"),
|
process.env.JWT_SECRET || process.env.WEB_PASSWORD || `${crypto.randomUUID()}${crypto.randomUUID()}`,
|
||||||
)
|
)
|
||||||
|
|
||||||
const COOKIE_NAME = "session"
|
const COOKIE_NAME = "session"
|
||||||
|
|||||||
Reference in New Issue
Block a user