IndexedDBStorageAdapter

class IndexedDBStorageAdapter(dbName: String = DEFAULT_DB_NAME) : StorageAdapter

Storage adapter backed by the browser's IndexedDB API.

Recommended for production web applications. Provides structured storage with indexing support, larger storage limits than localStorage, and an async API that does not block the main thread.

Features:

  • Upsert semantics for credential saves (uses IndexedDB put)

  • Efficient contract ID lookups via an IndexedDB index

  • Transactional data integrity for all operations

  • Automatic database schema migration via version management

  • Binary data support without serialization overhead

Schema:

  • Object store credentials: keyPath credentialId, index on contractId

  • Object store sessions: keyPath key

Example:

val storage = IndexedDBStorageAdapter()
storage.save(credential)
val all = storage.getAll()
val byContract = storage.getByContract("CABC...")
storage.close()

Parameters

dbName

Database name. Defaults to stellar_smart_account.

Constructors

Link copied to clipboard
constructor(dbName: String = DEFAULT_DB_NAME)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun clear()

Clears all credentials from storage.

Link copied to clipboard
open suspend override fun clearSession()

Clears the current session.

Link copied to clipboard
suspend fun close()

Closes the database connection and releases resources.

Link copied to clipboard
open suspend override fun delete(credentialId: String)

Deletes a credential by its ID.

Link copied to clipboard
suspend fun deleteDatabase(name: String = dbName)

Deletes the entire IndexedDB database.

Link copied to clipboard
open suspend override fun get(credentialId: String): StoredCredential?

Retrieves a credential by its ID.

Link copied to clipboard
open suspend override fun getAll(): List<StoredCredential>

Retrieves all stored credentials.

Link copied to clipboard
open suspend override fun getByContract(contractId: String): List<StoredCredential>

Retrieves all credentials associated with a contract address.

Link copied to clipboard
open suspend override fun getSession(): StoredSession?

Retrieves the current session.

Link copied to clipboard
open suspend override fun save(credential: StoredCredential)

Saves a credential to storage using upsert semantics.

Link copied to clipboard
open suspend override fun saveSession(session: StoredSession)

Saves a session to storage.

Link copied to clipboard
open suspend override fun update(credentialId: String, updates: StoredCredentialUpdate)

Updates a credential with partial changes.