rust: Fix the build and update our deps
This commit is contained in:
parent
f110bf34fa
commit
a144b1f7b5
@ -933,17 +933,20 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||||
val requestPair = olmMachine!!.requestRoomKey(event)
|
val requestPair = olmMachine!!.requestRoomKey(event)
|
||||||
|
|
||||||
if (requestPair.cancellation != null) {
|
val cancellation = requestPair.cancellation
|
||||||
when (requestPair.cancellation) {
|
val request = requestPair.keyRequest
|
||||||
|
|
||||||
|
if (cancellation != null) {
|
||||||
|
when (cancellation) {
|
||||||
is Request.ToDevice -> {
|
is Request.ToDevice -> {
|
||||||
sendToDevice(requestPair.cancellation)
|
sendToDevice(cancellation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when(requestPair.keyRequest) {
|
when(request) {
|
||||||
is Request.ToDevice -> {
|
is Request.ToDevice -> {
|
||||||
sendToDevice(requestPair.keyRequest)
|
sendToDevice(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ http = "0.2.4"
|
|||||||
thiserror = "1.0.25"
|
thiserror = "1.0.25"
|
||||||
tracing = "0.1.26"
|
tracing = "0.1.26"
|
||||||
tracing-subscriber = "0.2.18"
|
tracing-subscriber = "0.2.18"
|
||||||
uniffi = "0.9.0"
|
uniffi = "0.12.0"
|
||||||
|
|
||||||
[dependencies.js_int]
|
[dependencies.js_int]
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -24,11 +24,11 @@ features = ["lax_deserialize"]
|
|||||||
|
|
||||||
[dependencies.matrix-sdk-common]
|
[dependencies.matrix-sdk-common]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "e058191b992f261a1a848b7ec521badf173881d6"
|
branch = "verification-qr"
|
||||||
|
|
||||||
[dependencies.matrix-sdk-crypto]
|
[dependencies.matrix-sdk-crypto]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "e058191b992f261a1a848b7ec521badf173881d6"
|
branch = "verification-qr"
|
||||||
features = ["sled_cryptostore"]
|
features = ["sled_cryptostore"]
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
@ -36,5 +36,9 @@ version = "1.6.0"
|
|||||||
default_features = false
|
default_features = false
|
||||||
features = ["rt-multi-thread"]
|
features = ["rt-multi-thread"]
|
||||||
|
|
||||||
|
[dependencies.ruma]
|
||||||
|
version = "*"
|
||||||
|
features = ["client-api"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
uniffi_build = "0.9.0"
|
uniffi_build = "0.12.0"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use matrix_sdk_common::identifiers::Error as RumaIdentifierError;
|
use ruma::identifiers::Error as RumaIdentifierError;
|
||||||
use matrix_sdk_crypto::{
|
use matrix_sdk_crypto::{
|
||||||
store::CryptoStoreError as InnerStoreError, KeyExportError, MegolmError, OlmError,
|
store::CryptoStoreError as InnerStoreError, KeyExportError, MegolmError, OlmError,
|
||||||
};
|
};
|
||||||
|
@ -4,31 +4,33 @@ use std::{
|
|||||||
io::Cursor,
|
io::Cursor,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use js_int::UInt;
|
||||||
use serde_json::value::RawValue;
|
use ruma::{
|
||||||
use tokio::runtime::Runtime;
|
api::{
|
||||||
|
client::r0::{
|
||||||
use matrix_sdk_common::{
|
keys::{
|
||||||
api::r0::{
|
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
||||||
keys::{
|
upload_keys::Response as KeysUploadResponse,
|
||||||
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
},
|
||||||
upload_keys::Response as KeysUploadResponse,
|
sync::sync_events::{DeviceLists as RumaDeviceLists, ToDevice},
|
||||||
|
to_device::send_event_to_device::Response as ToDeviceResponse,
|
||||||
},
|
},
|
||||||
sync::sync_events::{DeviceLists as RumaDeviceLists, ToDevice},
|
IncomingResponse,
|
||||||
to_device::send_event_to_device::Response as ToDeviceResponse,
|
|
||||||
},
|
},
|
||||||
deserialized_responses::AlgorithmInfo,
|
|
||||||
events::{
|
events::{
|
||||||
room::encrypted::EncryptedEventContent, AnyMessageEventContent, EventContent,
|
room::encrypted::EncryptedEventContent, AnyMessageEventContent, EventContent,
|
||||||
SyncMessageEvent,
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
identifiers::{DeviceKeyAlgorithm, RoomId, UserId},
|
DeviceKeyAlgorithm, RoomId, UserId,
|
||||||
uuid::Uuid,
|
|
||||||
IncomingResponse, UInt,
|
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::value::RawValue;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
use matrix_sdk_common::{deserialized_responses::AlgorithmInfo, uuid::Uuid};
|
||||||
use matrix_sdk_crypto::{
|
use matrix_sdk_crypto::{
|
||||||
decrypt_key_export, encrypt_key_export, EncryptionSettings, OlmMachine as InnerMachine,
|
decrypt_key_export, encrypt_key_export, EncryptionSettings, OlmMachine as InnerMachine,
|
||||||
|
OutgoingVerificationRequest, Sas as InnerSas,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -48,7 +50,24 @@ pub struct Sas {
|
|||||||
pub other_user_id: String,
|
pub other_user_id: String,
|
||||||
pub other_device_id: String,
|
pub other_device_id: String,
|
||||||
pub flow_id: String,
|
pub flow_id: String,
|
||||||
pub request: Request,
|
pub is_cancelled: bool,
|
||||||
|
pub is_done: bool,
|
||||||
|
pub can_be_presented: bool,
|
||||||
|
pub timed_out: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<InnerSas> for Sas {
|
||||||
|
fn from(sas: InnerSas) -> Self {
|
||||||
|
Self {
|
||||||
|
other_user_id: sas.other_user_id().to_string(),
|
||||||
|
other_device_id: sas.other_device_id().to_string(),
|
||||||
|
flow_id: sas.flow_id().as_str().to_owned(),
|
||||||
|
is_cancelled: sas.is_cancelled(),
|
||||||
|
is_done: sas.is_done(),
|
||||||
|
can_be_presented: sas.can_be_presented(),
|
||||||
|
timed_out: sas.timed_out(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A pair of outgoing room key requests, both of those are sendToDevice
|
/// A pair of outgoing room key requests, both of those are sendToDevice
|
||||||
@ -207,7 +226,7 @@ impl OlmMachine {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `events` - A serialized array of to-device events we received in the
|
/// * `events` - A serialized array of to-device events we received in the
|
||||||
/// current sync resposne.
|
/// current sync response.
|
||||||
///
|
///
|
||||||
/// * `device_changes` - The list of devices that have changed in some way
|
/// * `device_changes` - The list of devices that have changed in some way
|
||||||
/// since the previous sync.
|
/// since the previous sync.
|
||||||
@ -350,7 +369,7 @@ impl OlmMachine {
|
|||||||
/// **Note**: A room key needs to be shared with the group of users that are
|
/// **Note**: A room key needs to be shared with the group of users that are
|
||||||
/// members in the given room. If this is not done this method will panic.
|
/// members in the given room. If this is not done this method will panic.
|
||||||
///
|
///
|
||||||
/// The usual flow to encrypt an evnet using this state machine is as
|
/// The usual flow to encrypt an event using this state machine is as
|
||||||
/// follows:
|
/// follows:
|
||||||
///
|
///
|
||||||
/// 1. Get the one-time key claim request to establish 1:1 Olm sessions for
|
/// 1. Get the one-time key claim request to establish 1:1 Olm sessions for
|
||||||
@ -539,6 +558,15 @@ impl OlmMachine {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_verification(&self, flow_id: &str) -> Option<Sas> {
|
||||||
|
todo!()
|
||||||
|
// self.inner.get_verification(flow_id).map(|s| s.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn request_verification(&self) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn start_verification(&self, device: &Device) -> Result<Sas, CryptoStoreError> {
|
pub fn start_verification(&self, device: &Device) -> Result<Sas, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(device.user_id.clone())?;
|
let user_id = UserId::try_from(device.user_id.clone())?;
|
||||||
let device_id = device.device_id.as_str().into();
|
let device_id = device.device_id.as_str().into();
|
||||||
@ -547,13 +575,54 @@ impl OlmMachine {
|
|||||||
.block_on(self.inner.get_device(&user_id, device_id))?
|
.block_on(self.inner.get_device(&user_id, device_id))?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let (sas, request) = self.runtime.block_on(device.start_verification())?;
|
// TODO we need to return the request as well.
|
||||||
|
let (sas, _) = self.runtime.block_on(device.start_verification())?;
|
||||||
|
|
||||||
Ok(Sas {
|
Ok(sas.into())
|
||||||
other_user_id: sas.other_user_id().to_string(),
|
}
|
||||||
other_device_id: sas.other_device_id().to_string(),
|
|
||||||
flow_id: sas.flow_id().as_str().to_owned(),
|
pub fn accept_verification(&self, flow_id: &str) -> Option<OutgoingVerificationRequest> {
|
||||||
request: request.into(),
|
todo!()
|
||||||
})
|
// self.inner
|
||||||
|
// .get_verification(flow_id)
|
||||||
|
// .and_then(|s| s.accept().map(|r| r.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cancel_verification(&self, flow_id: &str) -> Option<OutgoingVerificationRequest> {
|
||||||
|
todo!()
|
||||||
|
// self.inner
|
||||||
|
// .get_verification(flow_id)
|
||||||
|
// .and_then(|s| s.cancel().map(|r| r.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn confirm_verification(
|
||||||
|
&self,
|
||||||
|
flow_id: &str,
|
||||||
|
) -> Result<Option<OutgoingVerificationRequest>, CryptoStoreError> {
|
||||||
|
todo!()
|
||||||
|
// let sas = self.inner.get_verification(flow_id);
|
||||||
|
|
||||||
|
// if let Some(sas) = sas {
|
||||||
|
// let (request, _) = self.runtime.block_on(sas.confirm())?;
|
||||||
|
// Ok(request.map(|r| r.into()))
|
||||||
|
// } else {
|
||||||
|
// Ok(None)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_emoji_index(&self, flow_id: &str) -> Option<Vec<i32>> {
|
||||||
|
todo!()
|
||||||
|
// self.inner.get_verification(flow_id).and_then(|s| {
|
||||||
|
// s.emoji_index()
|
||||||
|
// .map(|v| v.iter().map(|i| (*i).into()).collect())
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_decimals(&self, flow_id: &str) -> Option<Vec<i32>> {
|
||||||
|
todo!()
|
||||||
|
// self.inner.get_verification(flow_id).and_then(|s| {
|
||||||
|
// s.decimals()
|
||||||
|
// .map(|v| [v.0.into(), v.1.into(), v.2.into()].to_vec())
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,10 @@ dictionary Sas {
|
|||||||
string other_user_id;
|
string other_user_id;
|
||||||
string other_device_id;
|
string other_device_id;
|
||||||
string flow_id;
|
string flow_id;
|
||||||
Request request;
|
boolean is_done;
|
||||||
|
boolean is_cancelled;
|
||||||
|
boolean can_be_presented;
|
||||||
|
boolean timed_out;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary KeyRequestPair {
|
dictionary KeyRequestPair {
|
||||||
@ -90,7 +93,6 @@ enum RequestType {
|
|||||||
"ToDevice",
|
"ToDevice",
|
||||||
};
|
};
|
||||||
|
|
||||||
[Threadsafe]
|
|
||||||
interface OlmMachine {
|
interface OlmMachine {
|
||||||
[Throws=MachineCreationError]
|
[Throws=MachineCreationError]
|
||||||
constructor([ByRef] string user_id, [ByRef] string device_id, [ByRef] string path);
|
constructor([ByRef] string user_id, [ByRef] string device_id, [ByRef] string path);
|
||||||
|
@ -3,8 +3,8 @@ use std::{collections::HashMap, convert::TryFrom};
|
|||||||
use http::Response;
|
use http::Response;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use ruma::{
|
||||||
api::r0::{
|
api::client::r0::{
|
||||||
keys::{
|
keys::{
|
||||||
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
|
||||||
upload_keys::Response as KeysUploadResponse,
|
upload_keys::Response as KeysUploadResponse,
|
||||||
|
Loading…
Reference in New Issue
Block a user