move client code

This commit is contained in:
peintnermax
2024-09-19 16:29:02 +02:00
parent c82363a5c0
commit ce7f53f90d
3 changed files with 15 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
import { timestampDate } from "@zitadel/client";
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
import { GetSessionResponse } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
import { getMostRecentCookieWithLoginname } from "./cookies";
@@ -16,16 +15,3 @@ export async function loadMostRecentSession(sessionParams: {
.getSession({ sessionId: recent.id, sessionToken: recent.token }, {})
.then((resp: GetSessionResponse) => resp.session);
}
export function isSessionValid(session: Partial<Session>) {
const validPassword = session?.factors?.password?.verifiedAt;
const validPasskey = session?.factors?.webAuthN?.verifiedAt;
const stillValid = session.expirationDate
? timestampDate(session.expirationDate) > new Date()
: true;
const verifiedAt = validPassword || validPasskey;
const valid = (validPassword || validPasskey) && stillValid;
return { valid, verifiedAt };
}