RegistryBasedResolver

Resolver implementation that uses a DidMethodRegistry to resolve DIDs.

This separates resolution concerns from registry management, following the single responsibility principle. The resolver delegates to the appropriate DID method based on the DID's method name.

Architecture:

  • Registry manages DID method instances

  • Resolver handles resolution logic and error conversion

  • Methods implement actual resolution logic

Error Handling:

Performance:

  • O(1) method lookup from registry

  • Delegates actual resolution to the method implementation

  • No caching (methods may implement their own caching)

Example Usage:

val registry = DidMethodRegistry()
registry.register(KeyDidMethod(kms))
registry.register(WebDidMethod())

val resolver = RegistryBasedResolver(registry)

// Resolve a DID
val result = resolver.resolve(Did("did:key:z6Mk..."))
when (result) {
is DidResolutionResult.Success -> {
println("Resolved: ${result.document.id}")
}
is DidResolutionResult.Deactivated -> {
println("Deactivated: ${result.did}")
}
is DidResolutionResult.Failure.MethodNotRegistered -> {
println("Method not available: ${result.method}")
}
// ... handle other cases
}

Parameters

registry

The DID method registry to use for method lookup

See also

for registry operations

for the resolver interface

Constructors

Link copied to clipboard
constructor(registry: DidMethodRegistry)

Functions

Link copied to clipboard
open suspend override fun resolve(did: Did): DidResolutionResult

Resolves a DID to a DID resolution result.

open suspend override fun resolve(did: Did, options: ResolutionOptions): DidResolutionResult

Executes the DID Resolution 1.0 §4.4 algorithm.

Link copied to clipboard

Resolves a DID and returns the document, or null if it could not be resolved.

Link copied to clipboard

Resolves a DID and returns the document, or throws if not found.