|
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | 15 | use std::{ |
| 16 | + collections::HashMap, |
16 | 17 | env, |
17 | 18 | fmt::Debug, |
18 | 19 | ops::Add, |
@@ -146,6 +147,7 @@ pub struct Claims { |
146 | 147 | pub sip: SIPGrants, |
147 | 148 | pub sha256: String, // Used to verify the integrity of the message body |
148 | 149 | pub metadata: String, |
| 150 | + pub attributes: HashMap<String, String>, |
149 | 151 | pub room_config: Option<livekit_protocol::RoomConfiguration>, |
150 | 152 | } |
151 | 153 |
|
@@ -182,6 +184,7 @@ impl AccessToken { |
182 | 184 | sip: SIPGrants::default(), |
183 | 185 | sha256: Default::default(), |
184 | 186 | metadata: Default::default(), |
| 187 | + attributes: HashMap::new(), |
185 | 188 | room_config: Default::default(), |
186 | 189 | }, |
187 | 190 | } |
@@ -229,6 +232,17 @@ impl AccessToken { |
229 | 232 | self |
230 | 233 | } |
231 | 234 |
|
| 235 | + pub fn with_attributes<I, K, V>(mut self, attributes: I) -> Self |
| 236 | + where |
| 237 | + I: IntoIterator<Item = (K, V)>, |
| 238 | + K: Into<String>, |
| 239 | + V: Into<String>, |
| 240 | + { |
| 241 | + self.claims.attributes = |
| 242 | + attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect::<HashMap<_, _>>(); |
| 243 | + self |
| 244 | + } |
| 245 | + |
232 | 246 | pub fn with_sha256(mut self, sha256: &str) -> Self { |
233 | 247 | self.claims.sha256 = sha256.to_owned(); |
234 | 248 | self |
|
0 commit comments