Docs
chromia.com

Type Alias

KeyStoreInteractor

On this page
type KeyStoreInteractor = {
    login: (loginOptions: LoginOptions) => Promise<SessionWithLogout>;
    getAccounts(): Promise<Account[]>;
    getAccountsPaginated(
        limit: number,
        cursor: OptionalPageCursor,
    ): Promise<PaginatedEntity<Account>>;
    getSession(accountId: BufferId): Promise<Session>;
    hasActiveLogin(loginOptions: LoginOptions): Promise<boolean>;
    onKeyStoreChanged(
        callback: (newKeyStore: KeyStoreInteractor | null) => void,
    ): void;
}

Properties

login

login: (loginOptions: LoginOptions) => Promise<SessionWithLogout>

Uses the underlying keystore to sign into the specified account

Type Declaration

Methods

getAccounts

  • getAccounts(): Promise<Account[]>

    Retrieves a list of Accounts associated with the signer. At most MAX_PAGE_SIZE. To fetch more Accounts, use getAccountsPaginated

    Returns Promise<Account[]>

getAccountsPaginated

getSession

  • getSession(accountId: BufferId): Promise<Session>

    Creates a session object for the provided account id.

    Parameters

    • accountId: BufferId

      account id to create a session for

    Returns Promise<Session>

hasActiveLogin

  • hasActiveLogin(loginOptions: LoginOptions): Promise<boolean>

    Allows checking whether calling login will result in an authentication request for the user or an old login key and auth descriptor will be reused.

    If an active session is found, calling login will not prompt the user to login again.

    rules field will NOT be validated against, except checking whether the auth descriptor has expired. This means that if the loginOptions ask for 5 minutes expiration, an auth descriptor expiring in 2 seconds will be deemed valid and reused by login

    Parameters

    Returns Promise<boolean>

onKeyStoreChanged

  • onKeyStoreChanged(
        callback: (newKeyStore: KeyStoreInteractor | null) => void,
    ): void

    Register a callback that is invoked when the underlying keystore is changed. This could e.g., happen if the user switches account in MetaMask.

    Parameters

    • callback: (newKeyStore: KeyStoreInteractor | null) => void

      the callback function to invoke when keystore changes

    Returns void