DefaultUniversalResolver

class DefaultUniversalResolver(val baseUrl: String, timeout: Int = 30, apiKey: String? = null, protocolAdapter: UniversalResolverProtocolAdapter = StandardUniversalResolverAdapter(), retryConfig: RetryConfig = RetryConfig.default().copy( nonRetryableExceptions = listOf( org.trustweave.did.exception.DidException.InvalidDidFormat::class, // Any DidException subtype is a domain-level error, not a transient network condition, // and must never be retried. org.trustweave.did.exception.DidException::class, ), ), httpClient: HttpClient? = null) : UniversalResolver

Default implementation of UniversalResolver using Java's built-in HTTP client.

This implementation works with any Universal Resolver instance through a pluggable protocol adapter pattern. Different providers can use different endpoint patterns, authentication mechanisms, and response formats.

Example Usage:

// Use public dev.uniresolver.io instance with standard adapter (default)
val resolver = DefaultUniversalResolver("https://dev.uniresolver.io")

// Use self-hosted instance with standard adapter
val resolver = DefaultUniversalResolver(
baseUrl = "https://resolver.example.com",
protocolAdapter = StandardUniversalResolverAdapter()
)

// Use GoDiddy with custom adapter
val resolver = DefaultUniversalResolver(
baseUrl = "https://api.godiddy.com",
protocolAdapter = GodiddyProtocolAdapter()
)

val result = resolver.resolveDid("did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK")

Parameters

baseUrl

Base URL of the Universal Resolver instance (e.g., "https://dev.uniresolver.io")

timeout

Request timeout in seconds (default: 30). Ignored when httpClient is provided.

apiKey

Optional API key for authentication (if required by the resolver)

protocolAdapter

Protocol adapter for the specific Universal Resolver implementation (defaults to StandardUniversalResolverAdapter)

httpClient

Optional pre-configured HttpClient to use for HTTP requests. When null a default client with timeout-based connect timeout is created. Inject a shared client in production to allow connection-pool reuse and easier testing.

Constructors

Link copied to clipboard
constructor(baseUrl: String, timeout: Int = 30, apiKey: String? = null, protocolAdapter: UniversalResolverProtocolAdapter = StandardUniversalResolverAdapter(), retryConfig: RetryConfig = RetryConfig.default().copy( nonRetryableExceptions = listOf( org.trustweave.did.exception.DidException.InvalidDidFormat::class, // Any DidException subtype is a domain-level error, not a transient network condition, // and must never be retried. org.trustweave.did.exception.DidException::class, ), ), httpClient: HttpClient? = null)

Properties

Link copied to clipboard
open override val baseUrl: String

Functions

Link copied to clipboard

Adapts a UniversalResolver (string-based, exception-throwing HTTP client interface) to the DidResolver contract (typed, always returns a DidResolutionResult).

Link copied to clipboard
open suspend override fun getSupportedMethods(): List<String>?

Gets the list of supported DID methods (if available).

Link copied to clipboard
open suspend override fun resolveDid(did: String): DidResolutionResult

Resolves a DID using Universal Resolver standard API.