Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matrix-sdk dependency to 75683d268fc2e #164

Merged
merged 5 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# UNRELEASED

- Update matrix-rust-sdk to `75683d268fc2e`.

**BREAKING CHANGES**

- Remove `SignedCurve25519` variant of `DeviceKeyAlgorithm`.

# matrix-sdk-crypto-wasm v10.1.0

- Update matrix-rust-sdk to `ce9dc73376b4ee`
Expand Down
40 changes: 23 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions src/identifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ impl DeviceKeyId {
/// Returns device ID of the device key ID.
#[wasm_bindgen(getter, js_name = "deviceId")]
pub fn device_id(&self) -> DeviceId {
self.inner.device_id().to_owned().into()
// TODO: when https://github.com/ruma/ruma/issues/1940 is fixed,
// this should just be:
//self.inner.key_name().to_owned().into()

let key_id = self.inner.to_string();

let colon_pos =
key_id.find(":").expect("Key should not have parsed if it did not contain ':'");

DeviceId::new(&key_id[(colon_pos + 1)..])
}

/// Return the device key ID as a string.
Expand Down Expand Up @@ -163,17 +172,14 @@ impl DeviceKeyAlgorithm {
#[derive(Debug)]
pub enum DeviceKeyAlgorithmName {
/// The Ed25519 signature algorithm.
Ed25519,
Ed25519 = 0,

/// The Curve25519 ECDH algorithm.
Curve25519,

/// The Curve25519 ECDH algorithm, but the key also contains
/// signatures.
SignedCurve25519,
Curve25519 = 1,

// SignedCurve25519 = 2 used to exist but was removed from Ruma
/// An unknown device key algorithm.
Unknown,
Unknown = 3,
}

impl TryFrom<DeviceKeyAlgorithmName> for ruma::DeviceKeyAlgorithm {
Expand All @@ -185,7 +191,6 @@ impl TryFrom<DeviceKeyAlgorithmName> for ruma::DeviceKeyAlgorithm {
Ok(match value {
Ed25519 => Self::Ed25519,
Curve25519 => Self::Curve25519,
SignedCurve25519 => Self::SignedCurve25519,
Unknown => {
return Err(JsError::new(
"The `DeviceKeyAlgorithmName.Unknown` variant cannot be converted",
Expand All @@ -202,7 +207,6 @@ impl From<ruma::DeviceKeyAlgorithm> for DeviceKeyAlgorithmName {
match value {
Ed25519 => Self::Ed25519,
Curve25519 => Self::Curve25519,
SignedCurve25519 => Self::SignedCurve25519,
_ => Self::Unknown,
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use js_sys::{Array, Function, JsString, Map, Promise, Set};
use matrix_sdk_common::{
deserialized_responses::TimelineEvent,
ruma::{
self, events::secret::request::SecretName, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId,
self, events::secret::request::SecretName, serde::Raw, OneTimeKeyAlgorithm, OwnedDeviceId,
OwnedTransactionId, OwnedUserId, UInt,
},
};
Expand Down Expand Up @@ -309,28 +309,28 @@ impl OlmMachine {
) -> Result<Promise, JsError> {
let to_device_events = serde_json::from_str(to_device_events)?;
let changed_devices = changed_devices.inner.clone();
let one_time_keys_counts: BTreeMap<DeviceKeyAlgorithm, UInt> = one_time_keys_counts
let one_time_keys_counts: BTreeMap<OneTimeKeyAlgorithm, UInt> = one_time_keys_counts
.entries()
.into_iter()
.filter_map(|js_value| {
let pair = Array::from(&js_value.ok()?);
let (key, value) = (
DeviceKeyAlgorithm::from(pair.at(0).as_string()?),
OneTimeKeyAlgorithm::from(pair.at(0).as_string()?),
UInt::new(pair.at(1).as_f64()? as u64)?,
);

Some((key, value))
})
.collect();

// Convert the unused_fallback_keys JS Set to a `Vec<DeviceKeyAlgorithm>`
let unused_fallback_keys: Option<Vec<DeviceKeyAlgorithm>> =
// Convert the unused_fallback_keys JS Set to a `Vec<OneTimeKeyAlgorithm>`
let unused_fallback_keys: Option<Vec<OneTimeKeyAlgorithm>> =
unused_fallback_keys.map(|fallback_keys| {
fallback_keys
.values()
.into_iter()
.filter_map(|js_value| {
Some(DeviceKeyAlgorithm::from(js_value.ok()?.as_string()?))
Some(OneTimeKeyAlgorithm::from(js_value.ok()?.as_string()?))
})
.collect()
});
Expand Down
6 changes: 3 additions & 3 deletions src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ pub(crate) mod tests {
claim_keys::v3::Request as OriginalKeysClaimRequest,
upload_keys::v3::Request as OriginalKeysUploadRequest,
},
device_id, user_id, DeviceKeyAlgorithm,
device_id, user_id, OneTimeKeyAlgorithm,
};
use matrix_sdk_crypto::requests::KeysQueryRequest as OriginalKeysQueryRequest;
use serde_json::Value;
Expand All @@ -727,7 +727,7 @@ pub(crate) mod tests {
user_id!("@alice:localhost").to_owned(),
BTreeMap::from([(
device_id!("ABCDEFG").to_owned(),
DeviceKeyAlgorithm::SignedCurve25519,
OneTimeKeyAlgorithm::SignedCurve25519,
)]),
)]));
let request = KeysClaimRequest::try_from(("ID".to_string(), &rust_request)).unwrap();
Expand All @@ -743,7 +743,7 @@ pub(crate) mod tests {
user_id!("@alice:localhost").to_owned(),
BTreeMap::from([(
device_id!("ABCDEFG").to_owned(),
DeviceKeyAlgorithm::SignedCurve25519,
OneTimeKeyAlgorithm::SignedCurve25519,
)]),
)]));
rust_request.timeout = None;
Expand Down
9 changes: 0 additions & 9 deletions tests/identifiers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ describe(DeviceKeyId.name, () => {
deviceId: "foobar",
},

{
name: "signed curve25519",
id: "signed_curve25519:foobar",
algorithmName: DeviceKeyAlgorithmName.SignedCurve25519,
algorithm: "signed_curve25519",
deviceId: "foobar",
},

{
name: "unknown",
id: "hello:foobar",
Expand All @@ -92,7 +84,6 @@ describe("DeviceKeyAlgorithmName", () => {
test("has the correct variants", () => {
expect(DeviceKeyAlgorithmName.Ed25519).toStrictEqual(0);
expect(DeviceKeyAlgorithmName.Curve25519).toStrictEqual(1);
expect(DeviceKeyAlgorithmName.SignedCurve25519).toStrictEqual(2);
expect(DeviceKeyAlgorithmName.Unknown).toStrictEqual(3);
});
});
Expand Down
Loading