Skip to main content

LinkedVpClient

Struct LinkedVpClient 

Source
pub struct LinkedVpClient<C, R, V = DefaultVerifier> { /* private fields */ }
Available on crate feature 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>

Source

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>

Source

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.

Source

pub fn with_max_urls(self, max_urls: usize) -> Self

This client fetching at most max_urls URLs of a DID document.

Source

pub fn max_urls(&self) -> usize

The most URLs validate_document fetches for one document.

Source

pub fn http(&self) -> &C

The HTTP client.

Source

pub fn validator(&self) -> &LinkedVpValidator<R, V>

The validator.

Source

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.

Source

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.

Source

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>

Source

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.

Trait Implementations§

Source§

impl<C: Debug, R: Debug, V: Debug> Debug for LinkedVpClient<C, R, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C, R, V = DefaultVerifier> !RefUnwindSafe for LinkedVpClient<C, R, V>

§

impl<C, R, V = DefaultVerifier> !UnwindSafe for LinkedVpClient<C, R, V>

§

impl<C, R, V> Freeze for LinkedVpClient<C, R, V>
where C: Freeze, LinkedVpValidator<R, V>: Freeze,

§

impl<C, R, V> Send for LinkedVpClient<C, R, V>
where C: Send, LinkedVpValidator<R, V>: Send,

§

impl<C, R, V> Sync for LinkedVpClient<C, R, V>
where C: Sync, LinkedVpValidator<R, V>: Sync,

§

impl<C, R, V> Unpin for LinkedVpClient<C, R, V>
where C: Unpin, LinkedVpValidator<R, V>: Unpin,

§

impl<C, R, V> UnsafeUnpin for LinkedVpClient<C, R, V>

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