#[non_exhaustive]pub struct LinkedPresentationBuilder {
pub holder: Did,
pub id: Option<Uri>,
pub credentials: Vec<Jwt>,
pub issued_at: DateTime<Utc>,
pub expiration: Option<DateTime<Utc>>,
}linked-vp only.Expand description
Builds a linked presentation in the JSON Web Token form: a VCDM 1.1 presentation of
credential JWTs held by holder, with iss, sub and holder the holder, jti the
presentation’s id, iat and nbf the issuance time, exp when an expiration is set,
and neither aud nor nonce.
§Examples
use chrono::{TimeZone as _, Utc};
use identity_kit::did::{Did, Uri};
use identity_kit::linked_vp::LinkedPresentationBuilder;
let holder = Did::parse("did:example:123")?;
let claims = LinkedPresentationBuilder::new(holder)
.with_id(Uri::parse("https://bar.example.com/verifiable-presentation.jwt")?)
.with_issued_at(Utc.with_ymd_and_hms(2024, 2, 8, 17, 38, 46).unwrap())
.with_expiration(Utc.with_ymd_and_hms(2029, 2, 8, 17, 38, 46).unwrap())
.jwt_claims()?;
assert_eq!(claims.iss.as_deref(), Some("did:example:123"));
assert_eq!(claims.sub, claims.iss);
assert_eq!((claims.iat, claims.nbf, claims.exp), (Some(1707413926), Some(1707413926), Some(1865266726)));
assert_eq!(claims.jti.as_deref(), Some("https://bar.example.com/verifiable-presentation.jwt"));
assert!(claims.aud.is_none() && !claims.additional.contains_key("nonce"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.holder: DidThe holder: the DID whose document links the presentation.
id: Option<Uri>The presentation’s id, usually the URL it is published at.
credentials: Vec<Jwt>The credential JWTs.
issued_at: DateTime<Utc>iat and nbf.
expiration: Option<DateTime<Utc>>exp, if the presentation expires.
Implementations§
Source§impl LinkedPresentationBuilder
impl LinkedPresentationBuilder
Sourcepub fn new(holder: Did) -> Self
pub fn new(holder: Did) -> Self
A presentation by holder of no credentials, issued now, without id or expiration.
Sourcepub fn with_credential(self, credential: Jwt) -> Self
pub fn with_credential(self, credential: Jwt) -> Self
This presentation with credential added.
Sourcepub fn with_issued_at(self, issued_at: DateTime<Utc>) -> Self
pub fn with_issued_at(self, issued_at: DateTime<Utc>) -> Self
This presentation issued at issued_at.
Sourcepub fn with_expiration(self, expiration: DateTime<Utc>) -> Self
pub fn with_expiration(self, expiration: DateTime<Utc>) -> Self
This presentation expiring at expiration, which the specification recommends to limit
how long a published presentation stays valid.
Sourcepub fn presentation(&self) -> Presentation
pub fn presentation(&self) -> Presentation
The presentation.
Sourcepub fn jwt_claims(&self) -> Result<JwtClaims, CredentialError>
pub fn jwt_claims(&self) -> Result<JwtClaims, CredentialError>
The JWT claims: the presentation’s (iss, jti, vp) with sub, iat, nbf and
exp.
§Errors
A CredentialError when the presentation does not map to claims; one built here
always does.
Sourcepub async fn sign(
&self,
kid: &DidUrl,
signer: &dyn Signer,
) -> Result<Jwt, LinkedVpError>
pub async fn sign( &self, kid: &DidUrl, signer: &dyn Signer, ) -> Result<Jwt, LinkedVpError>
The presentation signed with signer under a header of alg, typ JWT and kid,
kid naming a verification method of the holder, which a verifier resolves under
authentication.
§Errors
LinkedVpError::Validation with ValidationError::HolderMismatch when kid is not
a key of the holder, or with ValidationError::Jws when signing fails.
Trait Implementations§
Source§impl Clone for LinkedPresentationBuilder
impl Clone for LinkedPresentationBuilder
Source§impl Debug for LinkedPresentationBuilder
impl Debug for LinkedPresentationBuilder
impl Eq for LinkedPresentationBuilder
impl StructuralPartialEq for LinkedPresentationBuilder
Auto Trait Implementations§
impl Freeze for LinkedPresentationBuilder
impl RefUnwindSafe for LinkedPresentationBuilder
impl Send for LinkedPresentationBuilder
impl Sync for LinkedPresentationBuilder
impl Unpin for LinkedPresentationBuilder
impl UnsafeUnpin for LinkedPresentationBuilder
impl UnwindSafe for LinkedPresentationBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.