affinidi-did-resolver-cache-sdk
SDK for resolving Decentralised Identifiers (DIDs) with built-in local caching. Operates in local mode (resolving happens in your process) or network mode (requests are forwarded to a remote cache server).
Installation
[]
= "0.8"
Supported DID Methods
| Method | Default | Feature Flag |
|---|---|---|
did:key |
Yes | — |
did:peer |
Yes | — |
did:web |
Yes | — |
did:ethr |
Yes | — |
did:pkh |
Yes | — |
did:webvh |
Yes | did-methods |
did:cheqd |
Yes | did-methods |
did:scid |
Yes | did-methods |
did:ebsi |
No | did-ebsi (EBSI DID Registry API) |
did:example |
No | did_example (must be manually loaded) |
Feature Flags
| Feature | Default | Description |
|---|---|---|
local |
Yes | Reserved for future local-only features |
did-methods |
Yes | Includes did-webvh, did-cheqd, did-scid |
did-ebsi |
No | EBSI DID method (requires network access to EU API) |
network |
No | Enable network mode for remote cache server |
did-webvh |
— | WebVH DID method support |
did-cheqd |
— | Cheqd blockchain DID method support |
did-scid |
— | Self-Certifying Identifier DID method |
did_example |
— | Example DID method for testing |
Usage
Local Mode (default)
use ;
let config = default.build;
let resolver = new.await?;
match resolver.resolve.await
Network Mode
Enable the network feature, then point to a running cache server:
let config = default
.with_network_mode
.with_cache_ttl // Cache TTL in seconds
.with_network_timeout // Timeout in milliseconds
.build;
let resolver = new.await?;
Network mode still caches locally to reduce remote calls.
Caching Strategy
The cache uses per-method TTL to avoid unnecessary re-resolution:
| Category | Methods | TTL | Rationale |
|---|---|---|---|
| Immutable | did:key, did:peer, did:jwk, did:ethr, did:pkh |
None (capacity-evicted only) | Document is derived deterministically from the DID string |
| Mutable | did:web, did:webvh, did:cheqd, did:scid |
Configurable (cache_ttl, default 300s) |
Document is fetched from external infrastructure and can change |
The cache_ttl configuration option only applies to mutable DID methods.
Immutable DIDs stay cached until evicted by capacity pressure, since their
documents can never change.
Benchmarks
Running Tests
Integration tests require the network feature:
Related Crates
affinidi-did-resolver-cache-server— Remote cache serveraffinidi-did-common— DID Document types (dependency)affinidi-did-resolver-traits— Pluggable resolver traits (dependency)