feat: implement local caching for vCon data
Persist clients, storage stats, and file lists in local cache to improve initial load performance. Added breadcrumb navigation to the AdminPageHeader.
This commit is contained in:
1 parent
b42029f67d
commit
1a1c19d7bb
25 files changed
+892
-342
No files matched your search
@@ -46,9 +46,12 @@ export async function createAdminSessionToken(
|
||||
return `${payload}.${encodeBase64Url(new Uint8Array(signature))}`;
|
||||
}
|
||||
|
||||
export async function verifyAdminSessionToken(token: string, secret: string) {
|
||||
export async function getAdminSessionPayload(
|
||||
token: string,
|
||||
secret: string,
|
||||
): Promise<AdminSessionPayload | null> {
|
||||
const [payload, signature, extra] = token.split(".");
|
||||
if (!payload || !signature || extra) return false;
|
||||
if (!payload || !signature || extra) return null;
|
||||
|
||||
try {
|
||||
const valid = await crypto.subtle.verify(
|
||||
@@ -57,21 +60,29 @@ export async function verifyAdminSessionToken(token: string, secret: string) {
|
||||
decodeBase64Url(signature),
|
||||
encoder.encode(payload),
|
||||
);
|
||||
if (!valid) return false;
|
||||
if (!valid) return null;
|
||||
|
||||
const session = JSON.parse(
|
||||
new TextDecoder().decode(decodeBase64Url(payload)),
|
||||
) as AdminSessionPayload;
|
||||
return (
|
||||
if (
|
||||
typeof session.email === "string" &&
|
||||
typeof session.expiresAt === "number" &&
|
||||
session.expiresAt > Date.now()
|
||||
);
|
||||
) {
|
||||
return session;
|
||||
}
|
||||
return null;
|
||||
} catch {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function verifyAdminSessionToken(token: string, secret: string) {
|
||||
const session = await getAdminSessionPayload(token, secret);
|
||||
return Boolean(session);
|
||||
}
|
||||
|
||||
export function getSessionCookieOptions(request: Request, maxAge: number) {
|
||||
const forwardedProto = request.headers
|
||||
.get("x-forwarded-proto")
|
||||
|
||||
Reference in new issue
Block a user