TokenStorage

interface TokenStorage

Interface used to customize the way tokens are stored, updated, and removed throughout the lifecycle of an application.

A default implementation is provided, but for advanced use-cases, you may implement this protocol yourself and pass an instance to AuthFoundationDefaults.tokenStorageFactory.

Warning: When implementing a custom TokenStorage class, it's vitally important that you do not directly invoke any of these methods yourself. These methods are intended to be called on-demand by the other AuthFoundation classes, and the behavior is undefined if these methods are called directly by the developer.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun add(token: Token, metadata: Token.Metadata, security: Credential.Security = Credential.Security.standard)

Add Token and its Token.Metadata to storage. Encrypt Token with specified security.

Link copied to clipboard
abstract suspend fun allIds(): List<String>
Link copied to clipboard
abstract suspend fun getToken(id: String, promptInfo: BiometricPrompt.PromptInfo? = Credential.Security.promptInfo): Token

Get Token from storage with associated id.

Link copied to clipboard
abstract suspend fun metadata(id: String): Token.Metadata?
Link copied to clipboard
abstract suspend fun remove(id: String)

Remove Token with given id from the storage. Does nothing if the provided id does not exist in storage.

Link copied to clipboard
abstract suspend fun replace(token: Token)

Replace Token with Token.id with the given token. If no such Token with the given Token.id exists, NoSuchElementException is thrown.

Link copied to clipboard
abstract suspend fun setMetadata(metadata: Token.Metadata)

Set Token.Metadata for the token with Token.Metadata.id