Skip to content

Commit 9adf62f

Browse files
authored
Merge pull request #164 from matrix-org/update-matrix-sdk-to-75683d268fc2e
Update matrix-sdk dependency to 75683d268fc2e
2 parents aad3fbc + 0ba524b commit 9adf62f

File tree

6 files changed

+52
-45
lines changed

6 files changed

+52
-45
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# UNRELEASED
22

3+
- Update matrix-rust-sdk to `75683d268fc2e`.
4+
5+
**BREAKING CHANGES**
6+
7+
- Remove `SignedCurve25519` variant of `DeviceKeyAlgorithm`.
8+
39
# matrix-sdk-crypto-wasm v10.1.0
410

511
- Update matrix-rust-sdk to `ce9dc73376b4ee`

Cargo.lock

Lines changed: 23 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/identifiers.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,16 @@ impl DeviceKeyId {
120120
/// Returns device ID of the device key ID.
121121
#[wasm_bindgen(getter, js_name = "deviceId")]
122122
pub fn device_id(&self) -> DeviceId {
123-
self.inner.device_id().to_owned().into()
123+
// TODO: when https://github.com/ruma/ruma/issues/1940 is fixed,
124+
// this should just be:
125+
//self.inner.key_name().to_owned().into()
126+
127+
let key_id = self.inner.to_string();
128+
129+
let colon_pos =
130+
key_id.find(":").expect("Key should not have parsed if it did not contain ':'");
131+
132+
DeviceId::new(&key_id[(colon_pos + 1)..])
124133
}
125134

126135
/// Return the device key ID as a string.
@@ -163,17 +172,14 @@ impl DeviceKeyAlgorithm {
163172
#[derive(Debug)]
164173
pub enum DeviceKeyAlgorithmName {
165174
/// The Ed25519 signature algorithm.
166-
Ed25519,
175+
Ed25519 = 0,
167176

168177
/// The Curve25519 ECDH algorithm.
169-
Curve25519,
170-
171-
/// The Curve25519 ECDH algorithm, but the key also contains
172-
/// signatures.
173-
SignedCurve25519,
178+
Curve25519 = 1,
174179

180+
// SignedCurve25519 = 2 used to exist but was removed from Ruma
175181
/// An unknown device key algorithm.
176-
Unknown,
182+
Unknown = 3,
177183
}
178184

179185
impl TryFrom<DeviceKeyAlgorithmName> for ruma::DeviceKeyAlgorithm {
@@ -185,7 +191,6 @@ impl TryFrom<DeviceKeyAlgorithmName> for ruma::DeviceKeyAlgorithm {
185191
Ok(match value {
186192
Ed25519 => Self::Ed25519,
187193
Curve25519 => Self::Curve25519,
188-
SignedCurve25519 => Self::SignedCurve25519,
189194
Unknown => {
190195
return Err(JsError::new(
191196
"The `DeviceKeyAlgorithmName.Unknown` variant cannot be converted",
@@ -202,7 +207,6 @@ impl From<ruma::DeviceKeyAlgorithm> for DeviceKeyAlgorithmName {
202207
match value {
203208
Ed25519 => Self::Ed25519,
204209
Curve25519 => Self::Curve25519,
205-
SignedCurve25519 => Self::SignedCurve25519,
206210
_ => Self::Unknown,
207211
}
208212
}

src/machine.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use js_sys::{Array, Function, JsString, Map, Promise, Set};
1313
use matrix_sdk_common::{
1414
deserialized_responses::TimelineEvent,
1515
ruma::{
16-
self, events::secret::request::SecretName, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId,
16+
self, events::secret::request::SecretName, serde::Raw, OneTimeKeyAlgorithm, OwnedDeviceId,
1717
OwnedTransactionId, OwnedUserId, UInt,
1818
},
1919
};
@@ -309,28 +309,28 @@ impl OlmMachine {
309309
) -> Result<Promise, JsError> {
310310
let to_device_events = serde_json::from_str(to_device_events)?;
311311
let changed_devices = changed_devices.inner.clone();
312-
let one_time_keys_counts: BTreeMap<DeviceKeyAlgorithm, UInt> = one_time_keys_counts
312+
let one_time_keys_counts: BTreeMap<OneTimeKeyAlgorithm, UInt> = one_time_keys_counts
313313
.entries()
314314
.into_iter()
315315
.filter_map(|js_value| {
316316
let pair = Array::from(&js_value.ok()?);
317317
let (key, value) = (
318-
DeviceKeyAlgorithm::from(pair.at(0).as_string()?),
318+
OneTimeKeyAlgorithm::from(pair.at(0).as_string()?),
319319
UInt::new(pair.at(1).as_f64()? as u64)?,
320320
);
321321

322322
Some((key, value))
323323
})
324324
.collect();
325325

326-
// Convert the unused_fallback_keys JS Set to a `Vec<DeviceKeyAlgorithm>`
327-
let unused_fallback_keys: Option<Vec<DeviceKeyAlgorithm>> =
326+
// Convert the unused_fallback_keys JS Set to a `Vec<OneTimeKeyAlgorithm>`
327+
let unused_fallback_keys: Option<Vec<OneTimeKeyAlgorithm>> =
328328
unused_fallback_keys.map(|fallback_keys| {
329329
fallback_keys
330330
.values()
331331
.into_iter()
332332
.filter_map(|js_value| {
333-
Some(DeviceKeyAlgorithm::from(js_value.ok()?.as_string()?))
333+
Some(OneTimeKeyAlgorithm::from(js_value.ok()?.as_string()?))
334334
})
335335
.collect()
336336
});

src/requests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ pub(crate) mod tests {
712712
claim_keys::v3::Request as OriginalKeysClaimRequest,
713713
upload_keys::v3::Request as OriginalKeysUploadRequest,
714714
},
715-
device_id, user_id, DeviceKeyAlgorithm,
715+
device_id, user_id, OneTimeKeyAlgorithm,
716716
};
717717
use matrix_sdk_crypto::requests::KeysQueryRequest as OriginalKeysQueryRequest;
718718
use serde_json::Value;
@@ -727,7 +727,7 @@ pub(crate) mod tests {
727727
user_id!("@alice:localhost").to_owned(),
728728
BTreeMap::from([(
729729
device_id!("ABCDEFG").to_owned(),
730-
DeviceKeyAlgorithm::SignedCurve25519,
730+
OneTimeKeyAlgorithm::SignedCurve25519,
731731
)]),
732732
)]));
733733
let request = KeysClaimRequest::try_from(("ID".to_string(), &rust_request)).unwrap();
@@ -743,7 +743,7 @@ pub(crate) mod tests {
743743
user_id!("@alice:localhost").to_owned(),
744744
BTreeMap::from([(
745745
device_id!("ABCDEFG").to_owned(),
746-
DeviceKeyAlgorithm::SignedCurve25519,
746+
OneTimeKeyAlgorithm::SignedCurve25519,
747747
)]),
748748
)]));
749749
rust_request.timeout = None;

tests/identifiers.test.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ describe(DeviceKeyId.name, () => {
6161
deviceId: "foobar",
6262
},
6363

64-
{
65-
name: "signed curve25519",
66-
id: "signed_curve25519:foobar",
67-
algorithmName: DeviceKeyAlgorithmName.SignedCurve25519,
68-
algorithm: "signed_curve25519",
69-
deviceId: "foobar",
70-
},
71-
7264
{
7365
name: "unknown",
7466
id: "hello:foobar",
@@ -92,7 +84,6 @@ describe("DeviceKeyAlgorithmName", () => {
9284
test("has the correct variants", () => {
9385
expect(DeviceKeyAlgorithmName.Ed25519).toStrictEqual(0);
9486
expect(DeviceKeyAlgorithmName.Curve25519).toStrictEqual(1);
95-
expect(DeviceKeyAlgorithmName.SignedCurve25519).toStrictEqual(2);
9687
expect(DeviceKeyAlgorithmName.Unknown).toStrictEqual(3);
9788
});
9889
});

0 commit comments

Comments
 (0)