Add Oudelaa dashboard API integration
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled

هذا الالتزام موجود في:
boutmoun123
2026-05-25 20:36:52 +03:00
الأصل 367fce6557
التزام 8863f61d00
90 ملفات معدلة مع 16694 إضافات و1 حذوفات

عرض الملف

@@ -0,0 +1,23 @@
export function parseJwtPayload(token: string): Record<string, unknown> | null {
const parts = token.split(".");
if (parts.length < 2) return null;
try {
const normalized = parts[1].replace(/-/g, "+").replace(/_/g, "/");
const decoded =
typeof window !== "undefined"
? window.atob(normalized)
: Buffer.from(normalized, "base64").toString("utf8");
return JSON.parse(decoded) as Record<string, unknown>;
} catch {
return null;
}
}
export function isJwtExpired(token: string, skewSeconds = 15): boolean {
const payload = parseJwtPayload(token);
const exp = typeof payload?.exp === "number" ? payload.exp : null;
if (!exp) return false;
const now = Math.floor(Date.now() / 1000);
return exp <= now + skewSeconds;
}