DidDocumentStorage

Interface for DID document storage backends.

Provides abstraction for document persistence, allowing different storage implementations (in-memory, database, Redis, S3, IPFS, blockchain, etc.).

Storage Backend Types:

  • In-Memory: Fast, ephemeral (for testing)

  • Database: Persistent, queryable (PostgreSQL, MySQL)

  • Redis: Fast, cache-like (for high-performance scenarios)

  • S3/Cloud Storage: Scalable, versioned (for large-scale deployments)

  • IPFS: Decentralized, content-addressed (for decentralized storage)

  • Blockchain: Immutable, tamper-proof (for anchoring)

Example Usage:

val storage: DidDocumentStorage = DatabaseDocumentStorage(dataSource)

// Store a document
storage.store(
did = Did("did:web:example.com"),
document = didDocument,
metadata = DidDocumentMetadata(created = Clock.System.now())
)

// Retrieve a document
val (document, metadata) = storage.get(Did("did:web:example.com"))
?: throw Exception("DID not found")

Inheritors

Properties

Link copied to clipboard
abstract val backend: StorageBackend

The storage backend type identifier.

Functions

Link copied to clipboard
abstract suspend fun deactivate(did: Did, deactivatedDocument: DidDocument)

Marks a DID document as deactivated.

Link copied to clipboard
abstract suspend fun delete(did: Did): Boolean

Deletes a DID document (for cleanup).

Link copied to clipboard
abstract suspend fun exists(did: Did): Boolean

Checks if a DID document exists.

Link copied to clipboard
abstract suspend fun get(did: Did): Pair<DidDocument, DidDocumentMetadata>?

Retrieves a DID document by DID.

Link copied to clipboard
abstract suspend fun store(did: Did, document: DidDocument, metadata: DidDocumentMetadata? = null)

Stores a DID document.

Link copied to clipboard
abstract suspend fun update(did: Did, updater: (DidDocument) -> DidDocument): DidDocument

Updates an existing DID document.