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
Parameters
- loginOptions: LoginOptions
the account to sign in to
Returns Promise<SessionWithLogout>
the authenticated temporary session
- loginOptions: LoginOptions
(loginOptions: LoginOptions): Promise<SessionWithLogout>
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
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
where the page should start
Returns Promise<PaginatedEntity<Account>>
- limit: number
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>
- accountId: BufferId
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
loginwill not prompt the user to login again.rulesfield will NOT be validated against, except checking whether the auth descriptor has expired. This means that if theloginOptionsask for 5 minutes expiration, an auth descriptor expiring in 2 seconds will be deemed valid and reused byloginParameters
- loginOptions: LoginOptions
Returns Promise<boolean>
onKeyStoreChanged
onKeyStoreChanged( callback: (newKeyStore: KeyStoreInteractor | null) => void, ): voidRegister 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
- callback: (newKeyStore: KeyStoreInteractor | null) => void