Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
18 lines
584 B
TypeScript
18 lines
584 B
TypeScript
/** Refresh-session TTL metadata when the server expiry is unavailable. */
|
|
export const REFRESH_COOKIE_DAYS = 30
|
|
|
|
/**
|
|
* Resolves the refresh-token cookie's absolute expiry timestamp (ms epoch).
|
|
* Prefers the server-provided `expiresAt` (ISO string); falls back to
|
|
* `REFRESH_COOKIE_DAYS` from now when it's missing or unparsable.
|
|
*/
|
|
export const parseRefreshExpiry = (expiresAt?: string): number => {
|
|
if (expiresAt) {
|
|
const parsed = Date.parse(expiresAt)
|
|
|
|
if (Number.isFinite(parsed)) return parsed
|
|
}
|
|
|
|
return Date.now() + REFRESH_COOKIE_DAYS * 24 * 60 * 60 * 1000
|
|
}
|