Skip to content

Commit 8dec390

Browse files
committed
Upgrade Ruma
1 parent 6baffc4 commit 8dec390

File tree

43 files changed

+447
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+447
-417
lines changed

crates/matrix-qrcode/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ thiserror = "1.0.25"
2929

3030
[dependencies.ruma-identifiers]
3131
git = "https://github.com/ruma/ruma/"
32-
rev = "fdbc4d6d1dd273c8a6ac95b329943ed8c68df70d"
32+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
33+
34+
[dependencies.ruma-serde]
35+
git = "https://github.com/ruma/ruma/"
36+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"

crates/matrix-qrcode/src/types.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use byteorder::{BigEndian, ReadBytesExt};
2222
use image::{DynamicImage, GenericImage, GenericImageView, ImageBuffer, Luma};
2323
use qrcode::QrCode;
2424
use ruma_identifiers::EventId;
25+
use ruma_serde::Base64;
2526

2627
#[cfg(feature = "decode_image")]
2728
use crate::utils::decode_qr;
@@ -312,7 +313,7 @@ impl QrVerificationData {
312313
let first_key = base_64_encode(&first_key);
313314
let second_key = base_64_encode(&second_key);
314315
let flow_id = String::from_utf8(flow_id)?;
315-
let shared_secret = base_64_encode(&shared_secret);
316+
let shared_secret = Base64::new(shared_secret);
316317

317318
match mode {
318319
VerificationData::QR_MODE => {
@@ -360,7 +361,7 @@ impl QrVerificationData {
360361
}
361362

362363
/// Get the secret of this `QrVerificationData`.
363-
pub fn secret(&self) -> &str {
364+
pub fn secret(&self) -> &Base64 {
364365
match self {
365366
QrVerificationData::Verification(v) => &v.shared_secret,
366367
QrVerificationData::SelfVerification(v) => &v.shared_secret,
@@ -378,7 +379,7 @@ pub struct VerificationData {
378379
event_id: Box<EventId>,
379380
first_master_key: String,
380381
second_master_key: String,
381-
shared_secret: String,
382+
shared_secret: Base64,
382383
}
383384

384385
impl VerificationData {
@@ -401,7 +402,7 @@ impl VerificationData {
401402
event_id: Box<EventId>,
402403
first_key: String,
403404
second_key: String,
404-
shared_secret: String,
405+
shared_secret: Base64,
405406
) -> Self {
406407
Self { event_id, first_master_key: first_key, second_master_key: second_key, shared_secret }
407408
}
@@ -477,7 +478,7 @@ pub struct SelfVerificationData {
477478
transaction_id: String,
478479
master_key: String,
479480
device_key: String,
480-
shared_secret: String,
481+
shared_secret: Base64,
481482
}
482483

483484
impl SelfVerificationData {
@@ -504,7 +505,7 @@ impl SelfVerificationData {
504505
transaction_id: String,
505506
master_key: String,
506507
device_key: String,
507-
shared_secret: String,
508+
shared_secret: Base64,
508509
) -> Self {
509510
Self { transaction_id, master_key, device_key, shared_secret }
510511
}
@@ -580,7 +581,7 @@ pub struct SelfVerificationNoMasterKey {
580581
transaction_id: String,
581582
device_key: String,
582583
master_key: String,
583-
shared_secret: String,
584+
shared_secret: Base64,
584585
}
585586

586587
impl SelfVerificationNoMasterKey {
@@ -607,7 +608,7 @@ impl SelfVerificationNoMasterKey {
607608
transaction_id: String,
608609
device_key: String,
609610
master_key: String,
610-
shared_secret: String,
611+
shared_secret: Base64,
611612
) -> Self {
612613
Self { transaction_id, device_key, master_key, shared_secret }
613614
}

crates/matrix-qrcode/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use base64::{decode_config, encode_config, STANDARD_NO_PAD};
1818
#[cfg(feature = "decode_image")]
1919
use image::{GenericImage, GenericImageView, Luma};
2020
use qrcode::{bits::Bits, EcLevel, QrCode, Version};
21+
use ruma_serde::Base64;
2122

2223
#[cfg(feature = "decode_image")]
2324
use crate::error::DecodingError;
@@ -41,14 +42,13 @@ pub(crate) fn to_bytes(
4142
flow_id: &str,
4243
first_key: &str,
4344
second_key: &str,
44-
shared_secret: &str,
45+
shared_secret: &Base64,
4546
) -> Result<Vec<u8>, EncodingError> {
4647
let flow_id_len: u16 = flow_id.len().try_into()?;
4748
let flow_id_len = flow_id_len.to_be_bytes();
4849

4950
let first_key = base64_decode(first_key)?;
5051
let second_key = base64_decode(second_key)?;
51-
let shared_secret = base64_decode(shared_secret)?;
5252

5353
let data = [
5454
HEADER,
@@ -58,7 +58,7 @@ pub(crate) fn to_bytes(
5858
flow_id.as_bytes(),
5959
&first_key,
6060
&second_key,
61-
&shared_secret,
61+
shared_secret.as_bytes(),
6262
]
6363
.concat();
6464

@@ -70,7 +70,7 @@ pub(crate) fn to_qr_code(
7070
flow_id: &str,
7171
first_key: &str,
7272
second_key: &str,
73-
shared_secret: &str,
73+
shared_secret: &Base64,
7474
) -> Result<QrCode, EncodingError> {
7575
let data = to_bytes(mode, flow_id, first_key, second_key, shared_secret)?;
7676

crates/matrix-sdk-appservice/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ warp = { version = "0.3.1", optional = true, default-features = false }
3838

3939
[dependencies.ruma]
4040
git = "https://github.com/ruma/ruma/"
41-
rev = "fdbc4d6d1dd273c8a6ac95b329943ed8c68df70d"
41+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
4242
features = ["client-api-c", "appservice-api-s", "unstable-pre-spec"]
4343

4444
[dev-dependencies]

crates/matrix-sdk-base/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
5050

5151
[dependencies.ruma]
5252
git = "https://github.com/ruma/ruma/"
53-
rev = "fdbc4d6d1dd273c8a6ac95b329943ed8c68df70d"
53+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
5454
features = ["client-api-c", "unstable-pre-spec"]
5555

5656
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]

crates/matrix-sdk-base/src/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use std::{
2424
sync::Arc,
2525
};
2626

27+
#[cfg(feature = "encryption")]
28+
use matrix_sdk_common::locks::Mutex;
2729
use matrix_sdk_common::{
2830
deserialized_responses::{
2931
AmbiguityChanges, JoinedRoom, LeftRoom, MemberEvent, MembersResponse, Rooms,
@@ -33,8 +35,6 @@ use matrix_sdk_common::{
3335
locks::RwLock,
3436
};
3537
#[cfg(feature = "encryption")]
36-
use matrix_sdk_common::{locks::Mutex, uuid::Uuid};
37-
#[cfg(feature = "encryption")]
3838
use matrix_sdk_crypto::{
3939
store::{CryptoStore, CryptoStoreError},
4040
Device, EncryptionSettings, IncomingResponse, MegolmError, OlmError, OlmMachine,
@@ -47,7 +47,7 @@ use ruma::{
4747
room::{encrypted::RoomEncryptedEventContent, history_visibility::HistoryVisibility},
4848
AnySyncMessageEvent, MessageEventContent,
4949
},
50-
DeviceId,
50+
DeviceId, TransactionId,
5151
};
5252
use ruma::{
5353
api::client::r0::{self as api, push::get_notifications::Notification},
@@ -1038,7 +1038,7 @@ impl BaseClient {
10381038
#[cfg(feature = "encryption")]
10391039
pub async fn mark_request_as_sent<'a>(
10401040
&self,
1041-
request_id: &Uuid,
1041+
request_id: &TransactionId,
10421042
response: impl Into<IncomingResponse<'a>>,
10431043
) -> Result<()> {
10441044
let olm = self.olm.lock().await;
@@ -1056,7 +1056,7 @@ impl BaseClient {
10561056
pub async fn get_missing_sessions(
10571057
&self,
10581058
users: impl Iterator<Item = &UserId>,
1059-
) -> Result<Option<(Uuid, KeysClaimRequest)>> {
1059+
) -> Result<Option<(Box<TransactionId>, KeysClaimRequest)>> {
10601060
let olm = self.olm.lock().await;
10611061

10621062
match &*olm {

crates/matrix-sdk-common/Cargo.toml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ serde = "1.0.126"
1717

1818
[dependencies.ruma]
1919
git = "https://github.com/ruma/ruma/"
20-
rev = "fdbc4d6d1dd273c8a6ac95b329943ed8c68df70d"
20+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
2121
features = ["client-api-c"]
2222

23-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
24-
uuid = { version = "0.8.2", default-features = false, features = [
25-
"v4",
26-
"serde",
27-
] }
28-
2923
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
3024
version = "1.7.1"
3125
default-features = false
@@ -43,8 +37,3 @@ features = ["now"]
4337
async-lock = "2.4.0"
4438
futures-util = { version = "0.3.15", default-features = false, features = ["channel"] }
4539
wasm-bindgen-futures = "0.4.24"
46-
uuid = { version = "0.8.2", default-features = false, features = [
47-
"v4",
48-
"wasm-bindgen",
49-
"serde",
50-
] }

crates/matrix-sdk-common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
pub use async_trait::async_trait;
1212
pub use instant;
13-
pub use uuid;
1413

1514
pub mod deserialized_responses;
1615
pub mod executor;

crates/matrix-sdk-crypto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
4848

4949
[dependencies.ruma]
5050
git = "https://github.com/ruma/ruma/"
51-
rev = "fdbc4d6d1dd273c8a6ac95b329943ed8c68df70d"
51+
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
5252
features = ["client-api-c", "unstable-pre-spec"]
5353

5454
[dev-dependencies]

crates/matrix-sdk-crypto/benches/crypto_bench.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use std::{ops::Deref, sync::Arc};
1+
use std::ops::Deref;
22

33
use criterion::*;
4-
use matrix_sdk_common::uuid::Uuid;
54
use matrix_sdk_crypto::{EncryptionSettings, OlmMachine};
65
use matrix_sdk_test::response_from_file;
76
use ruma::{
@@ -12,7 +11,7 @@ use ruma::{
1211
},
1312
IncomingResponse,
1413
},
15-
device_id, room_id, user_id, DeviceId, UserId,
14+
device_id, room_id, user_id, DeviceId, TransactionId, UserId,
1615
};
1716
use serde_json::Value;
1817
use tokio::runtime::Builder;
@@ -51,7 +50,7 @@ pub fn keys_query(c: &mut Criterion) {
5150
let runtime = Builder::new_multi_thread().build().expect("Can't create runtime");
5251
let machine = OlmMachine::new(alice_id(), alice_device_id());
5352
let response = keys_query_response();
54-
let uuid = Uuid::new_v4();
53+
let txn_id = TransactionId::new();
5554

5655
let count = response.device_keys.values().fold(0, |acc, d| acc + d.len())
5756
+ response.master_keys.len()
@@ -65,7 +64,7 @@ pub fn keys_query(c: &mut Criterion) {
6564

6665
group.bench_with_input(BenchmarkId::new("memory store", &name), &response, |b, response| {
6766
b.to_async(&runtime)
68-
.iter(|| async { machine.mark_request_as_sent(&uuid, response).await.unwrap() })
67+
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
6968
});
7069

7170
let dir = tempfile::tempdir().unwrap();
@@ -80,17 +79,17 @@ pub fn keys_query(c: &mut Criterion) {
8079

8180
group.bench_with_input(BenchmarkId::new("sled store", &name), &response, |b, response| {
8281
b.to_async(&runtime)
83-
.iter(|| async { machine.mark_request_as_sent(&uuid, response).await.unwrap() })
82+
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
8483
});
8584

8685
group.finish()
8786
}
8887

8988
pub fn keys_claiming(c: &mut Criterion) {
90-
let runtime = Arc::new(Builder::new_multi_thread().build().expect("Can't create runtime"));
89+
let runtime = Builder::new_multi_thread().build().expect("Can't create runtime");
9190

9291
let keys_query_response = keys_query_response();
93-
let uuid = Uuid::new_v4();
92+
let txn_id = TransactionId::new();
9493

9594
let response = keys_claim_response();
9695

@@ -106,12 +105,12 @@ pub fn keys_claiming(c: &mut Criterion) {
106105
|| {
107106
let machine = OlmMachine::new(alice_id(), alice_device_id());
108107
runtime
109-
.block_on(machine.mark_request_as_sent(&uuid, &keys_query_response))
108+
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
110109
.unwrap();
111-
(machine, runtime.clone())
110+
(machine, &runtime, &txn_id)
112111
},
113-
move |(machine, runtime)| {
114-
runtime.block_on(machine.mark_request_as_sent(&uuid, response)).unwrap()
112+
move |(machine, runtime, txn_id)| {
113+
runtime.block_on(machine.mark_request_as_sent(txn_id, response)).unwrap()
115114
},
116115
BatchSize::SmallInput,
117116
)
@@ -130,12 +129,12 @@ pub fn keys_claiming(c: &mut Criterion) {
130129
))
131130
.unwrap();
132131
runtime
133-
.block_on(machine.mark_request_as_sent(&uuid, &keys_query_response))
132+
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
134133
.unwrap();
135-
(machine, runtime.clone())
134+
(machine, &runtime, &txn_id)
136135
},
137-
move |(machine, runtime)| {
138-
runtime.block_on(machine.mark_request_as_sent(&uuid, response)).unwrap()
136+
move |(machine, runtime, txn_id)| {
137+
runtime.block_on(machine.mark_request_as_sent(txn_id, response)).unwrap()
139138
},
140139
BatchSize::SmallInput,
141140
)
@@ -148,7 +147,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
148147
let runtime = Builder::new_multi_thread().build().expect("Can't create runtime");
149148

150149
let keys_query_response = keys_query_response();
151-
let uuid = Uuid::new_v4();
150+
let txn_id = TransactionId::new();
152151
let response = keys_claim_response();
153152
let room_id = room_id!("!test:localhost");
154153

@@ -158,8 +157,8 @@ pub fn room_key_sharing(c: &mut Criterion) {
158157
let count = response.one_time_keys.values().fold(0, |acc, d| acc + d.len());
159158

160159
let machine = OlmMachine::new(alice_id(), alice_device_id());
161-
runtime.block_on(machine.mark_request_as_sent(&uuid, &keys_query_response)).unwrap();
162-
runtime.block_on(machine.mark_request_as_sent(&uuid, &response)).unwrap();
160+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response)).unwrap();
161+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
163162

164163
let mut group = c.benchmark_group("Room key sharing");
165164
group.throughput(Throughput::Elements(count as u64));
@@ -195,8 +194,8 @@ pub fn room_key_sharing(c: &mut Criterion) {
195194
None,
196195
))
197196
.unwrap();
198-
runtime.block_on(machine.mark_request_as_sent(&uuid, &keys_query_response)).unwrap();
199-
runtime.block_on(machine.mark_request_as_sent(&uuid, &response)).unwrap();
197+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response)).unwrap();
198+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
200199

201200
group.bench_function(BenchmarkId::new("sled store", &name), |b| {
202201
b.to_async(&runtime).iter(|| async {
@@ -227,7 +226,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
227226

228227
let machine = OlmMachine::new(alice_id(), alice_device_id());
229228
let response = huge_keys_query_response();
230-
let uuid = Uuid::new_v4();
229+
let txn_id = TransactionId::new();
231230
let users: Vec<Box<UserId>> = response.device_keys.keys().cloned().collect();
232231

233232
let count = response.device_keys.values().fold(0, |acc, d| acc + d.len());
@@ -237,7 +236,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
237236

238237
let name = format!("{} devices", count);
239238

240-
runtime.block_on(machine.mark_request_as_sent(&uuid, &response)).unwrap();
239+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
241240

242241
group.bench_function(BenchmarkId::new("memory store", &name), |b| {
243242
b.to_async(&runtime).iter_with_large_drop(|| async {
@@ -255,7 +254,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
255254
))
256255
.unwrap();
257256

258-
runtime.block_on(machine.mark_request_as_sent(&uuid, &response)).unwrap();
257+
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
259258

260259
group.bench_function(BenchmarkId::new("sled store", &name), |b| {
261260
b.to_async(&runtime).iter(|| async {

0 commit comments

Comments
 (0)