auth-vir - v3.1.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. Automatically stores the CSRF token.

      Parameters

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

      Returns Promise<void>

      Error if the login response failed.

      Error if the login response has an invalid CSRF token.

    • 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.