FallbackDidResolver

Composite resolver that delegates to fallback when the primary resolver does not support the DID's method.

Fallback trigger — DidResolutionResult.Failure.MethodNotRegistered only. This is the one failure that means "the primary resolver cannot answer for this method at all", e.g. a local RegistryBasedResolver without a driver for did:ion.

Failures that deliberately do NOT trigger fallback:

  • DidResolutionResult.Failure.NotFound: the method IS registered locally and that method authoritatively reported the DID as absent. Silently consulting another source could resurrect deleted/never-existing DIDs and produce trust decisions that diverge from the authoritative method driver.

  • DidResolutionResult.Failure.InvalidFormat: a malformed DID is malformed for every resolver; retrying elsewhere only wastes a network round-trip.

  • DidResolutionResult.Failure.ResolutionError: the method is registered but errored (network/driver failure). Falling back would mask operational problems and may return a different view of the DID than the configured driver. If you want try-everything redundancy semantics, use ResolutionFallbackStrategy instead.

Example Usage:

val registry: DidResolver = RegistryBasedResolver(didMethodRegistry)   // local methods
val universal: DidResolver = DefaultUniversalResolver("https://dev.uniresolver.io")
.asDidResolver() // remote fallback

// Locally registered methods are authoritative; anything else goes to the
// universal resolver. Wrap in a cache for production use:
val resolver = CachingDidResolver(FallbackDidResolver(registry, universal))

val local = resolver.resolve(Did("did:key:z6Mk...")) // resolved by the registry
val remote = resolver.resolve(Did("did:ion:EiD...")) // not registered → universal

Parameters

primary

The authoritative resolver tried first (e.g. local registry/methods)

fallback

The resolver consulted only when primary does not know the method

Constructors

Link copied to clipboard
constructor(primary: DidResolver, fallback: DidResolver)

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

Resolves with DID Resolution 1.0 §4.1 options, forwarded unchanged to whichever of primary / fallback ends up handling the DID — same trigger rule as the single-argument resolve.

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.