iya-sts
    Preparing search index...

    A browser's account set: the stores, the cookie and the operations on a row. A static utility class.

    Index
    COOKIE: "sts_accounts" = COOKIE
    TICKET_PARAM: "sts_account" = TICKET_PARAM
    • Adds a session to a set. A remembered entry for the same account is replaced by it; a set at its cap first drops the account that signed out longest ago, and refuses only when every place is a session.

      Parameters

      • row: any

        the set, edited in place

      • sid: string

        the session

      • account: any

        { sub, username, displayName }

      Returns any

      { ok, dropped }, or { ok: false, full: true }

    • A set by its id, with no cookie check: for a session's own set when it ends, which knows the id and has no browser in front of it.

      Parameters

      • id: string

        the set's id

      Returns any

      the row (a copy), or null

    • The Set-Cookie line for a set's cookie value; an empty value clears it.

      Parameters

      • value: string

        <setId>.<handle>, or '' to clear

      Returns string

      the header line

    • The cookie that names the ambient realm's account set.

      Returns string

      sts_accounts, or sts_accounts_<realm> outside the default

    • Whether several signed-in accounts are on in the ambient realm.

      Returns boolean

      authn.multipleAccounts

    • Takes a session out of a set, remembering its account as signed out.

      Parameters

      • row: any

        the set, edited in place

      • sid: string

        the session

      • Optionalat: number

        when it ended, epoch ms; now by default

      Returns any

      the account it remembered, or null when the sid was not there

    • Forgets a remembered account. A live one is not touched.

      Parameters

      • row: any

        the set, edited in place

      • key: string

        the account's key

      Returns boolean

      true when it was forgotten

    • A new, empty set, not yet saved.

      Returns any

      the row

    • Whether a set has room for one more session without refusing: a free place, or a remembered account to drop.

      Parameters

      • row: any

        the set

      • liveCount: number

        how many of its sessions are live

      Returns boolean

      true when a sign-in may add one

    • How long after its last write a set can still matter (#820 part 2): a signed-out account's remembering, and twice the session lifetime for a session listed in it. A hot path (every row a flush writes): no Entering/Leaving pair.

      Returns number

      milliseconds

    • The key an account goes by in the picker and the API: its subject, or its name where it has none. Never a sid.

      Parameters

      • account: any

        { sub, username }

      Returns string

      the key

    • The most accounts a set holds, live and remembered together.

      Returns number

      authn.maxBrowserAccounts

    • Merges two nodes' copies of one account set.

      Parameters

      • mine: any

        this process's copy

      • theirs: any

        the stored copy

      Returns any

      the merged row

    • Mints a single-use ticket that resumes one flow as one session.

      Parameters

      • setId: string

        the browser's set

      • sid: string

        the chosen session

      • path: string

        the path (no query) the ticket may be spent on

      • pendingId: string

        the pending sign-in it was chosen in, for the record

      Returns string

      the ticket

    • Brings a row up to date: every session isLive says has ended moves to remembered, and every remembered account older than authn.rememberedAccountDays is dropped.

      Parameters

      • row: any

        the set, edited in place

      • isLive: (sid: string) => boolean

        sid → whether its session is live

      • OptionalnowMs: number

        now

      Returns any

      { ended, expired }, the counts

    • How long a signed-out account is remembered, in milliseconds.

      Returns number

      authn.rememberedAccountDays in milliseconds

    • Deletes a row (an empty set, at the expiry job).

      Parameters

      • id: string

        the set's id

      Returns void

    • Gives a row a fresh handle and answers the cookie value. The caller saves the row and writes the cookie.

      Parameters

      • row: any

        the set

      Returns string

      <setId>.<handle>

    • Writes a row back to the store.

      Parameters

      • row: any

        the set

      Returns void

    • The set a request's cookie names, if the cookie carries its current handle.

      Parameters

      • cookies: any

        the request's cookies, name → value

      Returns any

      the row (a copy), or null

    • How many places a row holds: its sessions and its remembered accounts.

      Parameters

      • row: any

        the set

      Returns number

      the count

    • Spends a ticket: it is deleted whatever it held, and its row is answered only while it has not expired.

      Parameters

      • ticket: string

        the ticket

      Returns any

      { setId, sid, path, pendingId, username }, or null

    • Takes the ticket parameter off a request's address — url, originalUrl and the parsed query — so no protocol module ever sees it, and answers its value.

      Parameters

      • req: any

        the request

      Returns string

      the ticket, or '' where it carried none

    • The body of authn.account-set-expiry for the ambient realm: every set pruned, and every set left with nothing in it deleted.

      Parameters

      • isLive: (sid: string) => boolean

        sid → whether its session is live

      Returns any

      { sets, ended, expired, deleted }

    • Sweeps for at most SWEEP_RUN_BUDGET_MS from where the last run stopped, yielding between slices (#784). The scheduler job's body.

      Parameters

      • isLive: (sid: string) => boolean

        says whether a set should keep listing a session

      • OptionalbudgetMs: number

        the run's budget; SWEEP_RUN_BUDGET_MS when absent

      Returns Promise<any>

      a promise of the run's counts, with at and of for the pass

    • Sweeps as sweep() does, yielding the event loop between slices of SWEEP_SLICE_MS (#780). The scheduler job's body.

      Parameters

      • isLive: (sid: string) => boolean

        says whether a set should keep listing a session

      Returns Promise<any>

      a promise of { sets, ended, expired, deleted }

    • An address with a ticket added to its query.

      Parameters

      • target: string

        the address, a path on this service

      • ticket: string

        the ticket

      Returns string

      the address with sts_account= on it

    • Appends a set's cookie to a response, beside any cookie already on it.

      Parameters

      • res: any

        the response

      • value: string

        the cookie value, or '' to clear it

      Returns boolean

      whether it was written