Skip to main content

Module web

Module web 

Source
Available on crate feature did-web and (crate features did-jwk or did-key or did-web) only.
Expand description

did:web: a DID document served over HTTPS by a web origin.

The did:web method maps a DID to the URL of its document: did:web:example.com is served at https://example.com/.well-known/did.json, and did:web:example.com%3A8443:user:alice at https://example.com:8443/user/alice/did.json (a port is percent-encoded as %3A, path segments are separated by :). document_url implements that mapping and did_from_url its inverse. The document is fetched through an HttpClient the caller injects; ReqwestClient (feature reqwest) is a hardened default that speaks HTTPS only, follows no redirect, refuses non-public addresses and caps the response size.

The method is updated by republishing the document and deactivated by removing it; neither has an API, so DidWeb as a DidProducer builds the document to publish and nothing more.

Structs§

DidWeb
The did:web method: a DidResolver fetching documents through an HttpClient, and a DidProducer building the document to publish.
HttpError
Why an HttpClient could not get a response.
HttpResponse
An HTTP response: the status code, the body and, for a redirect, its target.
LocalNetworklocal-network
The local address ranges a ReqwestClient may reach besides the public internet.
ReqwestClientreqwest
An HttpClient over reqwest hardened for fetching DID documents from the public web.
ReqwestClientBuilderlocal-network
Builds a ReqwestClient that may also reach the local network, for development and tests; see Local development and tests.

Enums§

WebError
Why a URL has no did:web, or a did:web no document URL.

Constants§

CONTEXT
The @context of a document DidWeb produces.
METHOD
The method name, web.

Traits§

HttpClient
What DidWeb needs from HTTP: a GET of a URL.

Functions§

did_from_origin
The did:web of the origin of url: as did_from_url, but the URL must have no path.
did_from_url
The did:web whose document lives under url: https://example.com gives did:web:example.com, https://example.com:8443/user/alice gives did:web:example.com%3A8443:user:alice.
document_url
The URL of the document of did (the Read operation’s URL construction): https://host[:port]/.well-known/did.json for a bare domain, else https://host[:port]/<segments>/did.json.