From 489717492cc402b7d8d682deae0fd8fc0f97f931 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Fri, 20 Sep 2024 17:21:49 -0400 Subject: [PATCH] Add aud to JwtClaims, add Default to JwtClaims --- crates/web5/src/credentials/sign.rs | 1 + crates/web5/src/credentials/verifiable_presentation_1_1.rs | 1 + crates/web5/src/jose.rs | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/web5/src/credentials/sign.rs b/crates/web5/src/credentials/sign.rs index ac134d15..2402f8fe 100644 --- a/crates/web5/src/credentials/sign.rs +++ b/crates/web5/src/credentials/sign.rs @@ -38,6 +38,7 @@ pub fn sign_with_did( additional_properties.insert("vc".to_string(), vc_claim.to_json_value()?); let claims = JwtClaims { + aud: None, iss: Some(vc.issuer.to_string()), jti: Some(vc.id.clone()), sub: Some(vc.credential_subject.id.clone()), diff --git a/crates/web5/src/credentials/verifiable_presentation_1_1.rs b/crates/web5/src/credentials/verifiable_presentation_1_1.rs index 88120b8c..3e83c301 100644 --- a/crates/web5/src/credentials/verifiable_presentation_1_1.rs +++ b/crates/web5/src/credentials/verifiable_presentation_1_1.rs @@ -298,6 +298,7 @@ pub fn sign_presentation_with_did( additional_properties.insert("vp".to_string(), vp_claims.to_json_value()?); let claims = JwtClaims { + aud: None, iss: Some(vp.holder.clone()), jti: Some(vp.id.clone()), sub: None, diff --git a/crates/web5/src/jose.rs b/crates/web5/src/jose.rs index 7181b568..53103804 100644 --- a/crates/web5/src/jose.rs +++ b/crates/web5/src/jose.rs @@ -190,8 +190,10 @@ impl Jws { } } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct JwtClaims { + #[serde(skip_serializing_if = "Option::is_none")] + pub aud: Option, #[serde(skip_serializing_if = "Option::is_none")] pub iss: Option, #[serde(skip_serializing_if = "Option::is_none")]