auth-vir - v5.2.0
    Preparing search index...

    Class FrontendAuthClient<AssumedUserParams>

    An auth client for sending and validating client requests to a backend. This should only be used in a frontend environment as it accesses native browser APIs.

    Type Parameters

    • AssumedUserParams extends JsonCompatibleObject = EmptyObject
    Index

    Constructors

    Properties

    removeActivityListener: VoidFunction | undefined

    Used to clean up the activity listener on .destroy().

    userCheckInterval: {} | undefined

    Methods

    • Assume the given user. Pass undefined to wipe the currently assumed user.

      Parameters

      Returns Promise<boolean>

      Whether the assumed user setting or clearing succeeded or not.

    • Use to handle a login response. The CSRF token cookie is automatically stored by the browser from the Set-Cookie response header.

      Parameters

      • response: Readonly<SelectFrom<Response, { ok: true }>>

      Returns Promise<void>

      Error if the login response failed.

    • Use to verify all responses received from the backend. Immediately logs the user out once an unauthorized response is detected.

      Parameters

      • response: Readonly<
            PartialWithUndefined<
                SelectFrom<Response, { headers: true; status: true }>,
            >,
        >

      Returns Promise<boolean>

      true if the auth is okay, false otherwise.