# KeyStoreInteractor · FT4 TypeScript client · Chromia Docs (concept)

> type KeyStoreInteractor = { login : (loginOptions: LoginOptions ) => Promise< SessionWithLogout >; getAccounts (): Promise< Account []>; getAccountsPaginat

Source: https://docs.chromia.com/pages/ft4-ts-client/types/ft-session.KeyStoreInteractor/

Type Alias

# KeyStoreInteractor

On this page

* [Properties](#properties)
* [login](#login)
* [Methods](#methods)
* [getAccounts](#getaccounts)
* [getAccountsPaginated](#getaccountspaginated)
* [getSession](#getsession)
* [hasActiveLogin](#hasactivelogin)
* [onKeyStoreChanged](#onkeystorechanged)

```signature
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

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

Uses the underlying keystore to sign into the specified account

#### Type Declaration

* ```signature
  (loginOptions: LoginOptions): Promise<SessionWithLogout>
  ```

  + #### Parameters

    - loginOptions: [LoginOptions](https://docs.chromia.com/pages/ft4-ts-client/types/authentication.LoginOptions/)

      the account to sign in to

    #### Returns Promise<[SessionWithLogout](https://docs.chromia.com/pages/ft4-ts-client/types/authentication.SessionWithLogout/)>

    the authenticated temporary session

## Methods

### getAccounts

* ```signature
  getAccounts(): Promise<Account[]>
  ```

  Retrieves a list of Accounts associated with the signer. At most MAX\_PAGE\_SIZE.
  To fetch more Accounts, use [getAccountsPaginated](#getaccountspaginated)

  #### Returns Promise<[Account](https://docs.chromia.com/pages/ft4-ts-client/interfaces/accounts.Account/)[]>

### getAccountsPaginated

* ```signature
  getAccountsPaginated(
      limit: number,
      cursor: OptionalPageCursor,
  ): Promise<PaginatedEntity<Account>>
  ```

  Retrieves a list of Accounts associated with the signer as a paginated entity.

  #### Parameters

  + limit: number

    maximum page size
  + cursor: [OptionalPageCursor](https://docs.chromia.com/pages/ft4-ts-client/types/ft-session.OptionalPageCursor/)

    where the page should start

  #### Returns Promise<[PaginatedEntity](https://docs.chromia.com/pages/ft4-ts-client/types/utils.PaginatedEntity/)<[Account](https://docs.chromia.com/pages/ft4-ts-client/interfaces/accounts.Account/)>>

### getSession

* ```signature
  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](https://docs.chromia.com/pages/ft4-ts-client/interfaces/ft-session.Session/)>

### hasActiveLogin

* ```signature
  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

  + loginOptions: [LoginOptions](https://docs.chromia.com/pages/ft4-ts-client/types/authentication.LoginOptions/)

  #### Returns Promise<boolean>

### onKeyStoreChanged

* ```signature
  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](https://docs.chromia.com/pages/ft4-ts-client/types/ft-session.KeyStoreInteractor/) | null) => void

    the callback function to invoke when keystore changes

  #### Returns void

[View this page on docs.chromia.com](https://docs.chromia.com/pages/ft4-ts-client/types/ft-session.KeyStoreInteractor.html)Generated API reference, mirrored from the live docs
