|
|
|
@ -1,9 +1,14 @@ |
|
|
|
import { SignJWT, jwtVerify, decodeJwt } from "jose"; |
|
|
|
import type { JWTPayload } from "jose"; |
|
|
|
|
|
|
|
const JWT_SECRET = new TextEncoder().encode( |
|
|
|
process.env.JWT_SECRET || "dev-secret-change-in-production" |
|
|
|
); |
|
|
|
const rawSecret = process.env.JWT_SECRET; |
|
|
|
if (!rawSecret) { |
|
|
|
if (process.env.NODE_ENV === "production") { |
|
|
|
throw new Error("JWT_SECRET environment variable is required in production"); |
|
|
|
} |
|
|
|
rawSecret = "dev-secret-change-in-production"; |
|
|
|
} |
|
|
|
const JWT_SECRET = new TextEncoder().encode(rawSecret); |
|
|
|
const ACCESS_TOKEN_EXPIRY = "15m"; |
|
|
|
|
|
|
|
export interface AccessTokenPayload extends JWTPayload { |
|
|
|
|