Skip to content

@fkn/lib/account

type AccountInfo = object;
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: boolean;

the account has an active paid subscription

premiumUntil: number | null;

when the current subscription lapses, as a ms epoch, or null when not subscribed

function info(): Promise<AccountInfo | null>;

Promise<AccountInfo | null>


function login(): Promise<boolean>;

Promise<boolean>


function logout(): Promise<void>;

Promise<void>


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.

() => void

Promise<() => void>