Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233// What to do with the outcome of a session restore. Pure so the policy can be// tested without a browser, and separate from the alarm that runs it so the// decision reads the same at every caller.
/** The three answers `restoreSession` can give (see src/lib/oauth.ts). */export type RestoreStatus = 'ok' | 'expired' | 'unreachable'
export type RefreshDecision = /** The session works (and was just refreshed): drop any stale expiry note. */ | 'clear-expiry' /** The client deleted the session: keep the expiry marker and warn. */ | 'mark-expired' /** Nothing was proved (offline, PDS down): leave the session exactly as is. */ | 'retry-later'
/** * A restore that could not reach the PDS is not evidence about the session. * Treating it as expired would sign a user out for being on a train, and the * client has already had the chance to delete the session itself when the * server really refused it. */export function decideRefresh(outcome: RestoreStatus, online: boolean): RefreshDecision { if (!online) return 'retry-later' switch (outcome) { case 'ok': return 'clear-expiry' case 'expired': return 'mark-expired' case 'unreachable': return 'retry-later' }}