pub struct LinkedVpClient<C, R, V = DefaultVerifier> { /* private fields */ }linked-vp only.Expand description
Fetches the presentations a DID document links with an HttpClient and validates them
with a LinkedVpValidator.
The URLs come from the document, so the client fetches whatever its controller names:
http must enforce the protections ReqwestClient (feature reqwest) does (HTTPS only,
no redirects, no non-public addresses after name resolution, a body limit and a timeout),
or fetching becomes a request forgery primitive. A DID document can also list any number of
URLs, so validate_document fetches at most
max_urls of them.
Implementations§
Source§impl<C, R, V> LinkedVpClient<C, R, V>
impl<C, R, V> LinkedVpClient<C, R, V>
Sourcepub const DEFAULT_MAX_URLS: usize = 32
pub const DEFAULT_MAX_URLS: usize = 32
The most URLs new fetches for one DID document: 32.
Source§impl<C: HttpClient, R: KeyResolver, V: JwsVerifier> LinkedVpClient<C, R, V>
impl<C: HttpClient, R: KeyResolver, V: JwsVerifier> LinkedVpClient<C, R, V>
Sourcepub fn new(http: C, validator: LinkedVpValidator<R, V>) -> Self
pub fn new(http: C, validator: LinkedVpValidator<R, V>) -> Self
A client fetching with http and validating with validator, fetching at most
DEFAULT_MAX_URLS URLs of a DID document.
Sourcepub fn with_max_urls(self, max_urls: usize) -> Self
pub fn with_max_urls(self, max_urls: usize) -> Self
This client fetching at most max_urls URLs of a DID document.
Sourcepub fn max_urls(&self) -> usize
pub fn max_urls(&self) -> usize
The most URLs validate_document fetches for one document.
Sourcepub fn validator(&self) -> &LinkedVpValidator<R, V>
pub fn validator(&self) -> &LinkedVpValidator<R, V>
The validator.
Sourcepub async fn fetch(&self, url: &Url) -> Result<Jwt, LinkedVpError>
pub async fn fetch(&self, url: &Url) -> Result<Jwt, LinkedVpError>
The presentation JWT at url, unverified: the body, trimmed, must be one compact JWT.
§Errors
LinkedVpError::UnsupportedEndpoint for a URL that is not https, without fetching;
LinkedVpError::Http or LinkedVpError::HttpStatus when there is no 2xx
response; LinkedVpError::UnsupportedFormat for a JSON-LD presentation;
LinkedVpError::InvalidBody for anything else that is not a compact JWT.
Sourcepub async fn validate_url(
&self,
url: &Url,
did: &Did,
options: &LinkedVpValidationOptions,
) -> Result<DecodedPresentation, LinkedVpError>
pub async fn validate_url( &self, url: &Url, did: &Did, options: &LinkedVpValidationOptions, ) -> Result<DecodedPresentation, LinkedVpError>
Fetches and validates url as a presentation linked from the document of did.
§Errors
As fetch and LinkedVpValidator::validate.
Sourcepub async fn validate_document(
&self,
document: &DidDocument,
options: &LinkedVpValidationOptions,
) -> Vec<LinkedPresentationReport>
pub async fn validate_document( &self, document: &DidDocument, options: &LinkedVpValidationOptions, ) -> Vec<LinkedPresentationReport>
Fetches and validates every presentation document links, one report per URL in
document order, and one for each invalid service entry. URLs past the first
max_urls are not fetched and report LinkedVpError::TooManyUrls.
Source§impl<C: HttpClient, V: JwsVerifier> LinkedVpClient<C, Resolver, V>
impl<C: HttpClient, V: JwsVerifier> LinkedVpClient<C, Resolver, V>
Sourcepub async fn validate_did(
&self,
did: &Did,
options: &LinkedVpValidationOptions,
) -> Result<Vec<LinkedPresentationReport>, LinkedVpError>
pub async fn validate_did( &self, did: &Did, options: &LinkedVpValidationOptions, ) -> Result<Vec<LinkedPresentationReport>, LinkedVpError>
Resolves did with the validator’s resolver, then validates every presentation its
document links, as validate_document.
§Errors
LinkedVpError::Resolution when did does not resolve to a document.