{"version":3,"file":"session_expiry-CQgFVf0N.js","names":["WRAPPED","observer","setResponseObserver","fn","report","build","requestUrlOf","input","installFetchObserver","current","wrapped","args","result","response","headerOf","value","observeAxios","config","requestUrl","request","installAxiosObserver","instance","error","SIGN_IN_URL","STATUS_URL","KEEP_ALIVE_URL","OTP_GATE_PREFIXES","GATE_PREFIXES","AUTH_PREFIXES","isSignInPath","pathname","isOtpGatePath","prefix","isGatePath","isAuthPage","OK","parse","url","origin","classifyResponse","status","final","finalUrl","readExpiry","time","WARNING_LEAD_MS","STATUS_RETRY_MS","STATUS_FIRST_RETRY_MS","EXPIRY_GRACE_MS","isLater","next","SessionExpiry","deps","initial","expiry","options","verdict","otp","message","cleanup","confirmation","remaining","checkWhenLate","retryMs","delay","location","broadcast","CHANNEL_NAME","NO_OP_CHANNEL","openTabChannel","channel","onMessage","event","DIALOG_SELECTOR","metaContent","doc","name","fetchStatus","body","postKeepAlive","isCountedInput","target","announceSignedOut","observeResponses","session","listenForInput","controller","onInput","startSessionExpiry","stopSessionExpiry","syncSessionExpiry","reloadIfRestored","sync"],"sources":["../../../app/frontend/session_expiry/observer.ts","../../../app/frontend/session_expiry/paths.ts","../../../app/frontend/session_expiry/response.ts","../../../app/frontend/session_expiry/session.ts","../../../app/frontend/session_expiry/tab_channel.ts","../../../app/frontend/session_expiry/start.ts","../../../app/frontend/entrypoints/session_expiry.ts"],"sourcesContent":["import type { AxiosInstance, AxiosResponse } from 'axios'\n\nexport type ObservedResponse = {\n requestUrl: string\n status: number\n finalUrl: string\n expiresHeader: string | null\n}\n\nconst EXPIRES_HEADER = 'X-Session-Expires-At'\nconst WRAPPED = Symbol('sessionExpiryFetchObserver')\n\nlet observer: ((r: ObservedResponse) => void) | null = null\n\nexport const setResponseObserver = (fn: ((r: ObservedResponse) => void) | null): void => {\n observer = fn\n}\n\nconst report = (build: () => ObservedResponse): void => {\n if (!observer) return\n try {\n observer(build())\n } catch {\n // an observer failure must never break the request that was observed\n }\n}\n\nconst requestUrlOf = (input: RequestInfo | URL): string => {\n if (typeof input === 'string') return input\n if (input instanceof URL) return input.href\n return input.url\n}\n\nexport const installFetchObserver = (): void => {\n const current = window.fetch as typeof fetch & { [WRAPPED]?: boolean }\n if (current[WRAPPED]) return\n\n const wrapped = function (this: unknown, ...args: Parameters) {\n const result = current.apply(this, args)\n result.then((response) => {\n report(() => ({\n requestUrl: requestUrlOf(args[0]),\n status: response.status,\n finalUrl: response.url || requestUrlOf(args[0]),\n expiresHeader: response.headers.get(EXPIRES_HEADER)\n }))\n }, () => undefined)\n return result\n } as typeof fetch & { [WRAPPED]?: boolean }\n wrapped[WRAPPED] = true\n window.fetch = wrapped\n}\n\nconst headerOf = (response: AxiosResponse): string | null => {\n const value = response.headers?.[EXPIRES_HEADER.toLowerCase()]\n return typeof value === 'string' ? value : null\n}\n\nconst observeAxios = (response: AxiosResponse): void => {\n report(() => {\n const config = response.config\n const requestUrl = `${config?.baseURL ?? ''}${config?.url ?? ''}`\n const request = response.request as { responseURL?: string } | undefined\n return {\n requestUrl,\n status: response.status,\n finalUrl: request?.responseURL || requestUrl,\n expiresHeader: headerOf(response)\n }\n })\n}\n\nexport const installAxiosObserver = (instance: AxiosInstance): void => {\n instance.interceptors.response.use(\n (response) => {\n observeAxios(response)\n return response\n },\n (error) => {\n if (error?.response) observeAxios(error.response)\n return Promise.reject(error)\n }\n )\n}\n","export const SIGN_IN_URL = '/users/sign_in'\nexport const STATUS_URL = '/session/status'\nexport const KEEP_ALIVE_URL = '/session/keep_alive'\n\nconst OTP_GATE_PREFIXES = ['/users/otp/challenge', '/users/otp/setup']\nconst GATE_PREFIXES = [...OTP_GATE_PREFIXES, '/terms_acceptance']\nconst AUTH_PREFIXES = ['/users/password', '/users/unlock', '/users/confirmation']\n\nexport const isSignInPath = (pathname: string): boolean => pathname === '/login' || pathname === SIGN_IN_URL\n\nexport const isOtpGatePath = (pathname: string): boolean =>\n OTP_GATE_PREFIXES.some((prefix) => pathname.startsWith(prefix))\n\nexport const isGatePath = (pathname: string): boolean => GATE_PREFIXES.some((prefix) => pathname.startsWith(prefix))\n\nexport const isAuthPage = (pathname: string): boolean =>\n isSignInPath(pathname) || isGatePath(pathname) || AUTH_PREFIXES.some((prefix) => pathname.startsWith(prefix))\n","import { isAuthPage, isGatePath, isSignInPath, SIGN_IN_URL, STATUS_URL } from './paths'\n\nexport type Expiry = number | 'remembered'\n\nexport type Verdict =\n | { kind: 'ok' }\n | { kind: 'signed_out'; location: string }\n | { kind: 'gate'; location: string }\n\nconst OK: Verdict = { kind: 'ok' }\n\nconst parse = (url: string, origin: string): URL | null => {\n try {\n return new URL(url, origin)\n } catch {\n return null\n }\n}\n\nexport const classifyResponse = (requestUrl: string, status: number, finalUrl: string, origin: string): Verdict => {\n const request = parse(requestUrl, origin)\n if (!request || request.origin !== origin) return OK\n if (request.pathname === STATUS_URL || isAuthPage(request.pathname)) return OK\n if (status === 401) return { kind: 'signed_out', location: SIGN_IN_URL }\n\n const final = parse(finalUrl, origin)\n if (!final || final.origin !== origin) return OK\n if (isSignInPath(final.pathname)) return { kind: 'signed_out', location: final.pathname }\n if (isGatePath(final.pathname)) return { kind: 'gate', location: final.pathname + final.search }\n return OK\n}\n\nexport const readExpiry = (value: string | null | undefined): Expiry | null => {\n if (!value) return null\n if (value === 'remembered') return 'remembered'\n const time = Date.parse(value)\n return Number.isNaN(time) ? null : time\n}\n","import { isOtpGatePath, SIGN_IN_URL } from './paths'\nimport type { Expiry, Verdict } from './response'\nimport type { TabChannel, TabMessage } from './tab_channel'\n\nexport const WARNING_LEAD_MS = 120_000\nexport const INPUT_KEEP_ALIVE_INTERVAL_MS = 300_000\nexport const STATUS_RETRY_MS = 60_000\nexport const STATUS_FIRST_RETRY_MS = 5_000\nexport const EXPIRY_GRACE_MS = 2_000\n\nexport type SessionDeps = {\n now: () => number\n navigate: (url: string) => void\n fetchStatus: () => Promise<{ status: number; expiresAt: Expiry | null }>\n postKeepAlive: () => Promise\n channel: TabChannel\n events: EventTarget\n}\n\ntype StatusResult = Awaited>\n\nconst isLater = (next: Expiry, current: Expiry | null): boolean => {\n if (current === null) return true\n if (typeof next === 'number' && typeof current === 'number') return next > current\n return next !== current\n}\n\nexport class SessionExpiry {\n private readonly deps: SessionDeps\n private expiry: Expiry | null = null\n private lastExtensionAt = 0\n private warnTimer: ReturnType | null = null\n private expireTimer: ReturnType | null = null\n private warning = false\n private staleRetried = false\n private navigated = false\n private stopped = false\n private channelClosed = false\n private keepAliveInFlight = false\n private statusInFlight: Promise | null = null\n private readonly cleanups: Array<() => void> = []\n private readonly confirmations = new Set>()\n private readonly onKeepAliveEvent = () => void this.keepAlive()\n\n constructor(deps: SessionDeps) {\n this.deps = deps\n }\n\n start(initial: Expiry): void {\n this.deps.events.addEventListener('session-expiry:keep-alive', this.onKeepAliveEvent)\n this.expiry = initial\n this.lastExtensionAt = this.deps.now()\n this.arm(true)\n }\n\n extend(expiry: Expiry, options: { broadcast: boolean }): void {\n if (this.stopped || !isLater(expiry, this.expiry)) return\n this.expiry = expiry\n this.lastExtensionAt = this.deps.now()\n this.warning = false\n this.staleRetried = false\n if (options.broadcast) this.deps.channel.post({ type: 'expires_at', value: expiry })\n this.deps.events.dispatchEvent(new CustomEvent('session-expiry:extended', { detail: { expiresAt: expiry } }))\n this.arm(true)\n }\n\n handleVerdict(verdict: Verdict): void {\n if (this.stopped) return\n if (verdict.kind === 'signed_out') {\n this.track(this.confirmSignedOut(verdict.location, true))\n } else if (verdict.kind === 'gate') {\n const otp = isOtpGatePath(new URL(verdict.location, 'http://gate.invalid').pathname)\n this.leave(verdict.location, otp)\n }\n }\n\n handleTabMessage(message: TabMessage): void {\n if (this.stopped) return\n if (message.type === 'expires_at') {\n this.extend(message.value, { broadcast: false })\n } else {\n this.track(this.confirmSignedOut(SIGN_IN_URL, false))\n }\n }\n\n noteInput(): void {\n if (this.stopped || this.warning || this.keepAliveInFlight || this.expiry === 'remembered') return\n if (this.deps.now() - this.lastExtensionAt < INPUT_KEEP_ALIVE_INTERVAL_MS) return\n void this.keepAlive()\n }\n\n async keepAlive(): Promise {\n if (this.stopped) return\n this.keepAliveInFlight = true\n try {\n const expiry = await this.deps.postKeepAlive()\n if (expiry !== null) this.extend(expiry, { broadcast: true })\n } catch {\n // a failed keep-alive keeps the current expiry; the confirm at expiry decides\n } finally {\n this.keepAliveInFlight = false\n }\n }\n\n repeatWarning(): void {\n if (this.stopped || !this.warning || typeof this.expiry !== 'number' || this.expiry <= this.deps.now()) return\n this.dispatchWarning(this.expiry)\n }\n\n onStop(cleanup: () => void): void {\n this.cleanups.push(cleanup)\n }\n\n stop(): void {\n if (this.stopped) return\n this.stopped = true\n this.clearTimers()\n this.deps.events.removeEventListener('session-expiry:keep-alive', this.onKeepAliveEvent)\n this.cleanups.splice(0).forEach((cleanup) => cleanup())\n this.closeChannelWhenIdle()\n }\n\n private track(confirmation: Promise): void {\n this.confirmations.add(confirmation)\n void confirmation.finally(() => {\n this.confirmations.delete(confirmation)\n if (this.stopped) this.closeChannelWhenIdle()\n }).catch(() => undefined)\n }\n\n private closeChannelWhenIdle(): void {\n if (this.channelClosed || this.confirmations.size > 0) return\n this.channelClosed = true\n this.deps.channel.close()\n }\n\n private arm(checkWhenLate: boolean, retryMs = STATUS_RETRY_MS): void {\n this.clearTimers()\n if (this.stopped || this.expiry === null || this.expiry === 'remembered') return\n const remaining = this.expiry - this.deps.now()\n if (remaining > WARNING_LEAD_MS) {\n this.warnTimer = setTimeout(() => this.warn(), remaining - WARNING_LEAD_MS)\n this.scheduleCheck(remaining + EXPIRY_GRACE_MS)\n } else if (checkWhenLate) {\n this.track(this.confirmAtExpiry())\n } else if (remaining > 0) {\n this.warn()\n this.scheduleCheck(remaining + EXPIRY_GRACE_MS)\n } else {\n this.scheduleCheck(retryMs)\n }\n }\n\n private scheduleCheck(delay: number): void {\n this.expireTimer = setTimeout(() => this.track(this.confirmAtExpiry()), delay)\n }\n\n private retryAfterStaleStatus(): void {\n const retryMs = this.staleRetried ? STATUS_RETRY_MS : STATUS_FIRST_RETRY_MS\n if (typeof this.expiry === 'number' && this.expiry <= this.deps.now()) this.staleRetried = true\n this.arm(false, retryMs)\n }\n\n private warn(): void {\n if (this.warning || typeof this.expiry !== 'number' || this.expiry <= this.deps.now()) return\n this.warning = true\n this.dispatchWarning(this.expiry)\n }\n\n private dispatchWarning(expiresAt: number): void {\n this.deps.events.dispatchEvent(new CustomEvent('session-expiry:warn', { detail: { expiresAt } }))\n }\n\n private async confirmAtExpiry(): Promise {\n const result = await this.checkStatus()\n if (result === null) {\n this.arm(false)\n } else if (result.status === 401) {\n this.leave(SIGN_IN_URL, true)\n } else if (result.expiresAt !== null && isLater(result.expiresAt, this.expiry)) {\n this.extend(result.expiresAt, { broadcast: true })\n } else {\n this.retryAfterStaleStatus()\n }\n }\n\n private async confirmSignedOut(location: string, broadcast: boolean): Promise {\n const result = await this.checkStatus()\n if (result === null) return\n if (result.status === 401) {\n this.leave(location, broadcast)\n } else if (result.expiresAt !== null) {\n this.extend(result.expiresAt, { broadcast: true })\n }\n }\n\n private async checkStatus(): Promise {\n if (this.stopped || this.navigated) return null\n this.statusInFlight ??= this.deps.fetchStatus().finally(() => {\n this.statusInFlight = null\n })\n try {\n return await this.statusInFlight\n } catch {\n return null\n }\n }\n\n private leave(url: string, broadcast: boolean): void {\n if (this.navigated) return\n this.navigated = true\n this.clearTimers()\n if (broadcast) this.deps.channel.post({ type: 'signed_out' })\n this.deps.navigate(url)\n }\n\n private clearTimers(): void {\n if (this.warnTimer) clearTimeout(this.warnTimer)\n if (this.expireTimer) clearTimeout(this.expireTimer)\n this.warnTimer = null\n this.expireTimer = null\n }\n}\n","import type { Expiry } from './response'\n\nexport type TabMessage = { type: 'expires_at'; value: Expiry } | { type: 'signed_out' }\n\nexport interface TabChannel {\n post(message: TabMessage): void\n close(): void\n}\n\nconst CHANNEL_NAME = 'session-expiry'\n\nconst NO_OP_CHANNEL: TabChannel = { post: () => undefined, close: () => undefined }\n\nexport const openTabChannel = (onMessage: (m: TabMessage) => void): TabChannel => {\n if (typeof BroadcastChannel === 'undefined') return NO_OP_CHANNEL\n const channel = new BroadcastChannel(CHANNEL_NAME)\n channel.onmessage = (event: MessageEvent) => onMessage(event.data)\n return {\n post: (message) => channel.postMessage(message),\n close: () => channel.close()\n }\n}\n","import { installFetchObserver, setResponseObserver } from './observer'\nimport type { ObservedResponse } from './observer'\nimport { isAuthPage, isSignInPath, KEEP_ALIVE_URL, STATUS_URL } from './paths'\nimport { classifyResponse, readExpiry } from './response'\nimport type { Expiry } from './response'\nimport { SessionExpiry } from './session'\nimport { openTabChannel } from './tab_channel'\n\nconst DIALOG_SELECTOR = '[data-session-expiry-dialog]'\n\nconst metaContent = (doc: Document, name: string): string | null =>\n doc.querySelector(`meta[name=\"${name}\"]`)?.content ?? null\n\nconst fetchStatus = async (): Promise<{ status: number; expiresAt: Expiry | null }> => {\n const response = await window.fetch(STATUS_URL, { headers: { Accept: 'application/json' }, credentials: 'same-origin' })\n if (!response.ok) return { status: response.status, expiresAt: null }\n const body = (await response.json()) as { expires_at?: string }\n return { status: response.status, expiresAt: readExpiry(body.expires_at) }\n}\n\nconst postKeepAlive = (doc: Document) => async (): Promise => {\n const response = await window.fetch(KEEP_ALIVE_URL, {\n method: 'POST',\n credentials: 'same-origin',\n headers: { Accept: 'application/json', 'X-CSRF-Token': metaContent(doc, 'csrf-token') ?? '' }\n })\n if (!response.ok) throw new Error(`keep-alive failed with ${response.status}`)\n const body = (await response.json()) as { expires_at?: string }\n return readExpiry(body.expires_at)\n}\n\nconst isCountedInput = (doc: Document, event: Event): boolean => {\n if (doc.visibilityState !== 'visible') return false\n const target = event.target\n return !(target instanceof Element && target.closest(DIALOG_SELECTOR))\n}\n\nconst announceSignedOut = (): void => {\n const channel = openTabChannel(() => undefined)\n channel.post({ type: 'signed_out' })\n channel.close()\n}\n\nconst observeResponses = (session: SessionExpiry) => (response: ObservedResponse): void => {\n const expiry = readExpiry(response.expiresHeader)\n if (expiry !== null) session.extend(expiry, { broadcast: true })\n session.handleVerdict(classifyResponse(response.requestUrl, response.status, response.finalUrl, window.location.origin))\n}\n\nconst listenForInput = (doc: Document, session: SessionExpiry): void => {\n const controller = new AbortController()\n const onInput = (event: Event) => {\n if (isCountedInput(doc, event)) session.noteInput()\n }\n const options = { capture: true, passive: true, signal: controller.signal }\n doc.addEventListener('keydown', onInput, options)\n doc.addEventListener('pointerdown', onInput, options)\n session.onStop(() => controller.abort())\n}\n\nexport const startSessionExpiry = (doc: Document = document): SessionExpiry | null => {\n const pathname = window.location.pathname\n if (isSignInPath(pathname)) {\n announceSignedOut()\n return null\n }\n const initial = readExpiry(metaContent(doc, 'session-expires-at'))\n if (initial === null || isAuthPage(pathname)) return null\n\n let session: SessionExpiry | null = null\n const channel = openTabChannel((message) => session?.handleTabMessage(message))\n session = new SessionExpiry({\n now: () => Date.now(),\n navigate: (url) => { window.location.href = url },\n fetchStatus,\n postKeepAlive: postKeepAlive(doc),\n channel,\n events: doc\n })\n\n installFetchObserver()\n setResponseObserver(observeResponses(session))\n session.onStop(() => setResponseObserver(null))\n listenForInput(doc, session)\n session.start(initial)\n return session\n}\n\nlet current: SessionExpiry | null = null\n\nexport const stopSessionExpiry = (): void => {\n current?.stop()\n current = null\n}\n\nexport const syncSessionExpiry = (doc: Document = document): SessionExpiry | null => {\n const expiry = readExpiry(metaContent(doc, 'session-expires-at'))\n if (current && expiry !== null && !isAuthPage(window.location.pathname)) {\n current.extend(expiry, { broadcast: false })\n current.repeatWarning()\n return current\n }\n stopSessionExpiry()\n current = startSessionExpiry(doc)\n return current\n}\n\nexport const reloadIfRestored = (event: PageTransitionEvent): void => {\n if (event.persisted && (current !== null || isSignInPath(window.location.pathname))) window.location.reload()\n}\n","import { reloadIfRestored, syncSessionExpiry } from '../session_expiry/start'\n\nconst sync = () => { syncSessionExpiry() }\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', sync, { once: true })\n} else {\n sync()\n}\ndocument.addEventListener('turbo:load', sync)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