Skip to main content

WebResolver

Struct WebResolver 

Source
pub struct WebResolver { /* private fields */ }
Expand description

Resolves did:web:… DIDs to DID documents via HTTPS.

Caches resolved documents for 5–24 hours per §5.11 guidance, evicting the least-recently-used entry once the cache reaches the configured capacity (default 1000).

Every resolution URL passes the SsrfPolicy gate before any socket activity: a producer-controlled did:web authority is an SSRF vector identical to a cross-registry reference (RFC-ACDP-0008 §4.8). The default policy refuses IP-literal authorities and non-HTTPS schemes, so did:web:127.0.0.1 / did:web:169.254.169.254 cannot turn a registry verifying a publish — or a consumer verifying a retrieved context — into an SSRF proxy against process-internal listeners.

Implementations§

Source§

impl WebResolver

Source

pub fn new() -> Self

Build a resolver with the default LRU capacity (1000 entries).

§Panics

Panics if the underlying HTTP client cannot be built (e.g. the TLS backend fails to initialize). Use Self::try_new to handle that failure as a Result instead.

Source

pub fn try_new() -> Result<Self, AcdpError>

Fallible variant of Self::new: builds a resolver with the default LRU capacity (1000 entries), returning an error instead of panicking if the underlying HTTP client cannot be built.

Source

pub fn with_capacity(capacity: usize) -> Self

Build a resolver with a custom LRU capacity.

§Panics

Panics if capacity == 0 — use a positive capacity; the LRU model has no semantically valid empty configuration — or if the underlying HTTP client cannot be built. Use Self::try_with_capacity to handle the HTTP-client failure as a Result instead.

Source

pub fn try_with_capacity(capacity: usize) -> Result<Self, AcdpError>

Fallible variant of Self::with_capacity: returns an error instead of panicking if the underlying HTTP client cannot be built.

§Panics

Still panics if capacity == 0; that is a programmer error, not a runtime condition.

Source

pub fn with_root_cert_pem(pem: &[u8]) -> Result<Self, AcdpError>

Build a resolver that trusts the given PEM-encoded root certificate in addition to the system roots.

Primary use is the in-process self-signed HTTPS server in the crate’s tests/helpers/tls_did_server.rs harness, so the spec fixtures pub-001 / pub-006 / fed-001..006 can drive the resolver end-to-end without going over the network. Production callers on corporate intranets MAY also use this to trust a private CA.

Source

pub fn with_capacity_and_root_cert_pem( capacity: usize, pem: &[u8], ) -> Result<Self, AcdpError>

Build a resolver with a custom LRU capacity AND a custom root cert.

Source

pub fn with_ssrf_policy(self, policy: SsrfPolicy) -> Self

Override the SsrfPolicy applied to did:web resolution.

The policy gates both the URL stage (refusing IP-literal authorities and non-HTTPS schemes — fixtures did-ssrf-001/002/003) and the DNS resolution stage (filtering hostnames that resolve into forbidden ranges — RFC-ACDP-0008 §4.8 DNS-rebinding protection). Calling this rebuilds the underlying HTTP client so the DNS resolver hook reflects the new policy.

Relax the policy only in a test harness that resolves did:web:localhost… against an in-process loopback server. Production callers MUST keep the default.

§Panics

Panics if the underlying HTTP client cannot be rebuilt. Use Self::try_with_ssrf_policy to handle that failure as a Result instead.

Source

pub fn try_with_ssrf_policy(self, policy: SsrfPolicy) -> Result<Self, AcdpError>

Fallible variant of Self::with_ssrf_policy: returns an error instead of panicking if the underlying HTTP client cannot be rebuilt.

Source

pub async fn resolve(&self, did: &str) -> Result<DidDocument, AcdpError>

Resolve a did:web:… DID to a DID document.

Hits the cache on repeated calls for the same DID. Refreshes on any downstream verification failure if needed.

Source

pub fn invalidate(&self, did: &str)

Invalidate a specific DID’s cache entry, forcing a fresh fetch.

Trait Implementations§

Source§

impl Default for WebResolver

Available on crate feature client only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more