@fkn/lib/account
Type Aliases
Section titled “Type Aliases”AccountInfo
Section titled “AccountInfo”type AccountInfo = object;Properties
Section titled “Properties”image: string | null;profile image URL, or null if none is set
name: string;the account’s display name (a username, not necessarily a real name)
premium
Section titled “premium”premium: boolean;the account has an active paid subscription
premiumUntil
Section titled “premiumUntil”premiumUntil: number | null;when the current subscription lapses, as a ms epoch, or null when not subscribed
Functions
Section titled “Functions”info()
Section titled “info()”function info(): Promise<AccountInfo | null>;Returns
Section titled “Returns”Promise<AccountInfo | null>
login()
Section titled “login()”function login(): Promise<boolean>;Returns
Section titled “Returns”Promise<boolean>
logout()
Section titled “logout()”function logout(): Promise<void>;Returns
Section titled “Returns”Promise<void>
onChange()
Section titled “onChange()”function onChange(callback): Promise<() => void>;Calls callback whenever the account this page acts as may have changed: a switch, a sign-in or a
sign-out, in this tab or another. It carries no data, so re-read what you need. Works in a window and
in a worker bridged with relayWorker; resolves to a no-op where there is no FKN transport at all.
Storage moves to the new account BEFORE any callback runs. Calls made before this page learned of a
switch never land in the new account (they are refused with StorageAccountChangedError). Work the
app started before the notification and resumes after it is the app’s to check: keep a counter this
callback bumps, and compare it synchronously right before the storage call, which captures the
account in the same synchronous step, so the check and the call are atomic.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Returns
Section titled “Returns”Promise<() => void>