@@ -166,29 +166,29 @@ impl DecryptedRoomEvent {
166
166
/// unless the `verification_state` is as well trusted.
167
167
#[ wasm_bindgen( getter) ]
168
168
pub fn sender ( & self ) -> Option < identifiers:: UserId > {
169
- Some ( self . encryption_info . as_ref ( ) ?. sender ( ) )
169
+ Some ( self . encryption_info . as_ref ( ) ?. sender . clone ( ) )
170
170
}
171
171
172
172
/// The device ID of the device that sent us the event, note this
173
173
/// is untrusted data unless `verification_state` is as well
174
174
/// trusted.
175
175
#[ wasm_bindgen( getter, js_name = "senderDevice" ) ]
176
176
pub fn sender_device ( & self ) -> Option < identifiers:: DeviceId > {
177
- self . encryption_info . as_ref ( ) ?. sender_device ( )
177
+ self . encryption_info . as_ref ( ) ?. sender_device . clone ( )
178
178
}
179
179
180
180
/// The Curve25519 key of the device that created the megolm
181
181
/// decryption key originally.
182
182
#[ wasm_bindgen( getter, js_name = "senderCurve25519Key" ) ]
183
183
pub fn sender_curve25519_key ( & self ) -> Option < JsString > {
184
- self . encryption_info . as_ref ( ) ?. sender_curve25519_key ( )
184
+ Some ( self . encryption_info . as_ref ( ) ?. sender_curve25519_key_base64 . as_str ( ) . into ( ) )
185
185
}
186
186
187
187
/// The signing Ed25519 key that have created the megolm key that
188
188
/// was used to decrypt this session.
189
189
#[ wasm_bindgen( getter, js_name = "senderClaimedEd25519Key" ) ]
190
190
pub fn sender_claimed_ed25519_key ( & self ) -> Option < JsString > {
191
- self . encryption_info . as_ref ( ) ?. sender_claimed_ed25519_key ( )
191
+ Some ( self . encryption_info . as_ref ( ) ?. sender_claimed_ed25519_key . as_ref ( ) ? . as_str ( ) . into ( ) )
192
192
}
193
193
194
194
/// Returns an empty array
@@ -227,46 +227,35 @@ impl From<matrix_sdk_common::deserialized_responses::TimelineEvent> for Decrypte
227
227
#[ wasm_bindgen( ) ]
228
228
#[ derive( Debug ) ]
229
229
pub struct EncryptionInfo {
230
- inner : Arc < matrix_sdk_common:: deserialized_responses:: EncryptionInfo > ,
231
- }
230
+ /// The user ID of the sender of the event.
231
+ ///
232
+ /// Note this is untrusted data unless {@link shieldState} shows that the
233
+ /// sender is verified.
234
+ #[ wasm_bindgen( getter_with_clone) ]
235
+ pub sender : identifiers:: UserId ,
232
236
233
- #[ wasm_bindgen( ) ]
234
- impl EncryptionInfo {
235
- /// The user ID of the event sender. Note this is untrusted data
236
- /// unless `verification_state` is also trusted.
237
- #[ wasm_bindgen( getter) ]
238
- pub fn sender ( & self ) -> identifiers:: UserId {
239
- identifiers:: UserId :: from ( self . inner . sender . clone ( ) )
240
- }
237
+ /// The device ID of the device that sent us the event.
238
+ ///
239
+ /// Note this is untrusted data unless {@link shieldState} shows that the
240
+ /// sender is verified.
241
+ #[ wasm_bindgen( getter_with_clone, js_name = "senderDevice" ) ]
242
+ pub sender_device : Option < identifiers:: DeviceId > ,
241
243
242
- /// The device ID of the device that sent us the event. Note this
243
- /// is untrusted data unless `verification_state` is also
244
- /// trusted.
245
- #[ wasm_bindgen( getter, js_name = "senderDevice" ) ]
246
- pub fn sender_device ( & self ) -> Option < identifiers:: DeviceId > {
247
- Some ( self . inner . sender_device . as_ref ( ) ?. clone ( ) . into ( ) )
248
- }
249
-
250
- /// The Curve25519 key of the device that created the megolm
251
- /// decryption key originally.
252
- #[ wasm_bindgen( getter, js_name = "senderCurve25519Key" ) ]
253
- pub fn sender_curve25519_key ( & self ) -> Option < JsString > {
254
- Some ( match & self . inner . algorithm_info {
255
- AlgorithmInfo :: MegolmV1AesSha2 { curve25519_key, .. } => curve25519_key. clone ( ) . into ( ) ,
256
- } )
257
- }
244
+ /// The base64-encoded public Curve25519 key of the device that created the
245
+ /// megolm decryption key originally.
246
+ #[ wasm_bindgen( getter_with_clone, js_name = "senderCurve25519Key" ) ]
247
+ pub sender_curve25519_key_base64 : String ,
258
248
259
249
/// The signing Ed25519 key that created the megolm key that
260
250
/// was used to decrypt this session.
261
- #[ wasm_bindgen( getter, js_name = "senderClaimedEd25519Key" ) ]
262
- pub fn sender_claimed_ed25519_key ( & self ) -> Option < JsString > {
263
- match & self . inner . algorithm_info {
264
- AlgorithmInfo :: MegolmV1AesSha2 { sender_claimed_keys, .. } => {
265
- sender_claimed_keys. get ( & ruma:: DeviceKeyAlgorithm :: Ed25519 ) . cloned ( ) . map ( Into :: into)
266
- }
267
- }
268
- }
251
+ #[ wasm_bindgen( getter_with_clone, js_name = "senderClaimedEd25519Key" ) ]
252
+ pub sender_claimed_ed25519_key : Option < String > ,
253
+
254
+ verification_state : matrix_sdk_common:: deserialized_responses:: VerificationState ,
255
+ }
269
256
257
+ #[ wasm_bindgen( ) ]
258
+ impl EncryptionInfo {
270
259
/// The verification state of the device that sent us the event.
271
260
/// Note this is the state of the device at the time of
272
261
/// decryption. It may change in the future if a device gets
@@ -280,7 +269,7 @@ impl EncryptionInfo {
280
269
/// (both get a red shield in strict mode).
281
270
#[ wasm_bindgen( js_name = "shieldState" ) ]
282
271
pub fn shield_state ( & self , strict : bool ) -> encryption:: ShieldState {
283
- let verification_state = & self . inner . verification_state ;
272
+ let verification_state = & self . verification_state ;
284
273
285
274
if strict {
286
275
verification_state. to_shield_state_strict ( )
@@ -293,6 +282,17 @@ impl EncryptionInfo {
293
282
294
283
impl From < Arc < matrix_sdk_common:: deserialized_responses:: EncryptionInfo > > for EncryptionInfo {
295
284
fn from ( value : Arc < matrix_sdk_common:: deserialized_responses:: EncryptionInfo > ) -> Self {
296
- Self { inner : value }
285
+ match & value. algorithm_info {
286
+ AlgorithmInfo :: MegolmV1AesSha2 { curve25519_key, sender_claimed_keys, .. } => Self {
287
+ sender : value. sender . clone ( ) . into ( ) ,
288
+ sender_device : value. sender_device . clone ( ) . map ( Into :: into) ,
289
+ sender_curve25519_key_base64 : curve25519_key. clone ( ) ,
290
+ sender_claimed_ed25519_key : sender_claimed_keys
291
+ . get ( & ruma:: DeviceKeyAlgorithm :: Ed25519 )
292
+ . cloned ( )
293
+ . into ( ) ,
294
+ verification_state : value. verification_state . clone ( ) ,
295
+ } ,
296
+ }
297
297
}
298
298
}
0 commit comments