Initial commit: FPT Financial Planning Tool
Deploy App / deploy (push) Successful in 3m3s

This commit is contained in:
2026-07-08 19:19:39 +02:00
commit 4f990c9686
60 changed files with 12436 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { SignJWT, jwtVerify } from "jose";
const SESSION_COOKIE_NAME = "fpt_session";
const SESSION_DURATION = "30d";
function getSecretKey() {
const secret = process.env.SESSION_SECRET;
if (!secret) {
throw new Error("SESSION_SECRET ist nicht gesetzt.");
}
return new TextEncoder().encode(secret);
}
export async function createSessionToken(): Promise<string> {
return new SignJWT({ auth: true })
.setProtectedHeader({ alg: "HS256" })
.setIssuedAt()
.setExpirationTime(SESSION_DURATION)
.sign(getSecretKey());
}
export async function verifySessionToken(token: string): Promise<boolean> {
try {
const { payload } = await jwtVerify(token, getSecretKey());
return payload.auth === true;
} catch {
return false;
}
}
export { SESSION_COOKIE_NAME };