UNPKG

auth-vir

Version:

Auth made easy and secure via JWT cookies, CSRF tokens, and password hashing helpers.

22 lines (21 loc) 779 B
import { calculateRelativeDate, getNowInUtcTimezone, isDateAfter, } from 'date-vir'; /** * Determines if enough time has passed since the JWT was issued to start refreshing the session. * * Visually, this check looks like this: * * I====R===========E * * - I = JWT issued time (from the JWT's `iat` claim) * - R = session refreshing is available now (I + sessionRefreshStartTime) * - E = JWT expiration * - `=` between R and E = the time frame in which the return value is `true`. * * @category Auth : Host */ export function isSessionRefreshReady({ now = getNowInUtcTimezone(), jwtIssuedAt, sessionRefreshStartTime, }) { return isDateAfter({ fullDate: now, relativeTo: calculateRelativeDate(jwtIssuedAt, sessionRefreshStartTime), }); }