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:
Converts DidException to DidResolutionResult.Failure
Provides detailed error metadata for debugging
Never throws exceptions (always returns result)
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
The DID method registry to use for method lookup
See also
for registry operations
for the resolver interface
Functions
Resolves a DID to a DID resolution result.
Executes the DID Resolution 1.0 §4.4 algorithm.
Resolves a DID and returns the document, or null if it could not be resolved.
Resolves a DID and returns the document, or throws if not found.