File tree 1 file changed +16
-1
lines changed 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2020-2024 IOTA Stiftung
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
+ use std:: borrow:: Cow ;
5
+
4
6
use anyhow:: Context as _;
5
7
use itertools:: Itertools ;
6
8
use serde:: Serialize ;
@@ -84,7 +86,7 @@ impl<H: Hasher> SdJwtBuilder<H> {
84
86
/// .make_concealable("/claim1/abc").unwrap() //"abc": true
85
87
/// .make_concealable("/claim2/0").unwrap(); //conceals "val_1"
86
88
/// ```
87
- ///
89
+ ///
88
90
/// ## Error
89
91
/// * [`Error::InvalidPath`] if pointer is invalid.
90
92
/// * [`Error::DataTypeMismatch`] if existing SD format is invalid.
@@ -105,6 +107,19 @@ impl<H: Hasher> SdJwtBuilder<H> {
105
107
self
106
108
}
107
109
110
+ /// Adds a new claim to the underlying object.
111
+ pub fn insert_claim < K , V > ( mut self , key : K , value : V ) -> Self
112
+ where
113
+ K : for < ' a > Into < Cow < ' a , str > > ,
114
+ V : Serialize ,
115
+ {
116
+ let key = key. into ( ) . into_owned ( ) ;
117
+ let value = serde_json:: to_value ( value) . unwrap ( ) ;
118
+ self . encoder . object . as_object_mut ( ) . unwrap ( ) . insert ( key, value) ;
119
+
120
+ self
121
+ }
122
+
108
123
/// Adds a decoy digest to the specified path.
109
124
///
110
125
/// `path` indicates the pointer to the value that will be concealed using the syntax of
You can’t perform that action at this time.
0 commit comments