Skip to content

Commit b4d69e6

Browse files
committed
SdJwtClaims: Default, SdJwt::claims_mut
1 parent cc13221 commit b4d69e6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sd_jwt.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use serde::Deserialize;
2525
use serde::Serialize;
2626
use serde_json::Value;
2727

28-
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
28+
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Default)]
2929
pub struct SdJwtClaims {
3030
#[serde(skip_serializing_if = "Vec::is_empty", default)]
3131
pub _sd: Vec<String>,
@@ -84,6 +84,14 @@ impl SdJwt {
8484
&self.jwt.claims
8585
}
8686

87+
/// Returns a mutable reference to this SD-JWT's claims.
88+
/// ## Warning
89+
/// Modifying the claims might invalidate the signature.
90+
/// Use this method carefully.
91+
pub fn claims_mut(&mut self) -> &mut SdJwtClaims {
92+
&mut self.jwt.claims
93+
}
94+
8795
pub fn disclosures(&self) -> &[Disclosure] {
8896
&self.disclosures
8997
}

0 commit comments

Comments
 (0)