From c2a0f3daf8753262541629148029fad9b3a9bcef Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 14:44:37 -0400 Subject: [PATCH 1/6] bindings --- bindings_ffi/src/lib.rs | 2 + bindings_ffi/src/mls.rs | 46 ++++++++++++--- xmtp_mls/src/groups/device_sync.rs | 32 ++++++++++- .../src/groups/device_sync/consent_sync.rs | 47 ++-------------- .../src/groups/device_sync/message_sync.rs | 56 ++++--------------- 5 files changed, 83 insertions(+), 100 deletions(-) diff --git a/bindings_ffi/src/lib.rs b/bindings_ffi/src/lib.rs index 16eb30e75..a7e04c29a 100755 --- a/bindings_ffi/src/lib.rs +++ b/bindings_ffi/src/lib.rs @@ -44,6 +44,8 @@ pub enum GenericError { Verifier(#[from] xmtp_id::scw_verifier::VerifierError), #[error("Failed to convert to u32")] FailedToConvertToU32, + #[error(transparent)] + DeviceSync(#[from] xmtp_mls::groups::device_sync::DeviceSyncError), } #[derive(uniffi::Error, thiserror::Error, Debug)] diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 78df78ad3..51c8617dd 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -44,6 +44,7 @@ use xmtp_mls::{ }, AbortHandle, GenericStreamHandle, StreamHandle, }; +use xmtp_proto::xmtp::mls::message_contents::DeviceSyncKind; pub type RustXmtpClient = MlsClient; /// It returns a new client of the specified `inbox_id`. @@ -399,15 +400,29 @@ impl FfiXmtpClient { Ok(()) } - pub async fn request_history_sync(&self) -> Result<(), GenericError> { - let provider = self - .inner_client - .mls_provider() - .map_err(GenericError::from_error)?; + pub async fn send_sync_request(&self, kind: FfiDeviceSyncKind) -> Result<(), GenericError> { + let provider = self.inner_client.mls_provider()?; self.inner_client - .send_history_sync_request(&provider) - .await - .map_err(GenericError::from_error)?; + .send_sync_request(&provider, kind.into()) + .await?; + + Ok(()) + } + + pub async fn reply_to_sync_request(&self, kind: FfiDeviceSyncKind) -> Result<(), GenericError> { + let provider = self.inner_client.mls_provider()?; + self.inner_client + .reply_to_sync_request(&provider, kind.into()) + .await?; + + Ok(()) + } + + pub async fn process_sync_reply(&self, kind: FfiDeviceSyncKind) -> Result<(), GenericError> { + let provider = self.inner_client.mls_provider()?; + self.inner_client + .process_sync_reply(&provider, kind.into()) + .await?; Ok(()) } @@ -1054,6 +1069,21 @@ impl From for ConsentState { } } +#[derive(uniffi::Enum)] +pub enum FfiDeviceSyncKind { + Messages, + Consent, +} + +impl From for DeviceSyncKind { + fn from(value: FfiDeviceSyncKind) -> Self { + match value { + FfiDeviceSyncKind::Consent => DeviceSyncKind::Consent, + FfiDeviceSyncKind::Messages => DeviceSyncKind::MessageHistory, + } + } +} + #[derive(uniffi::Enum)] pub enum FfiConsentEntityType { ConversationId, diff --git a/xmtp_mls/src/groups/device_sync.rs b/xmtp_mls/src/groups/device_sync.rs index d5426b1d7..b00c22edb 100644 --- a/xmtp_mls/src/groups/device_sync.rs +++ b/xmtp_mls/src/groups/device_sync.rs @@ -108,6 +108,30 @@ where ApiClient: XmtpApi, V: SmartContractSignatureVerifier, { + pub async fn reply_to_sync_request( + &self, + provider: &XmtpOpenMlsProvider, + kind: DeviceSyncKind, + ) -> Result { + let conn = provider.conn_ref(); + + let (_msg, request) = self.pending_sync_request(provider, kind).await?; + let records = match kind { + DeviceSyncKind::Consent => vec![self.syncable_consent_records(conn)?], + DeviceSyncKind::MessageHistory => { + vec![self.syncable_groups(conn)?, self.syncable_messages(conn)?] + } + DeviceSyncKind::Unspecified => return Err(DeviceSyncError::UnspecifiedDeviceSyncKind), + }; + + let reply = self + .create_sync_reply(&request.request_id, &records, kind) + .await?; + self.send_sync_reply(provider, reply.clone()).await?; + + Ok(reply) + } + pub async fn enable_sync(&self, provider: &XmtpOpenMlsProvider) -> Result<(), GroupError> { let sync_group = match self.get_sync_group() { Ok(group) => group, @@ -123,11 +147,13 @@ where Ok(()) } - async fn send_sync_request( + pub async fn send_sync_request( &self, provider: &XmtpOpenMlsProvider, - request: DeviceSyncRequest, + kind: DeviceSyncKind, ) -> Result<(String, String), DeviceSyncError> { + let request = DeviceSyncRequest::new(kind); + // find the sync group let sync_group = self.get_sync_group()?; @@ -267,7 +293,7 @@ where Err(DeviceSyncError::NoReplyToProcess) } - async fn process_sync_reply( + pub async fn process_sync_reply( &self, provider: &XmtpOpenMlsProvider, kind: DeviceSyncKind, diff --git a/xmtp_mls/src/groups/device_sync/consent_sync.rs b/xmtp_mls/src/groups/device_sync/consent_sync.rs index b8f4e4a89..d1bfdf9a5 100644 --- a/xmtp_mls/src/groups/device_sync/consent_sync.rs +++ b/xmtp_mls/src/groups/device_sync/consent_sync.rs @@ -7,46 +7,7 @@ where ApiClient: XmtpApi, V: SmartContractSignatureVerifier, { - pub async fn send_consent_sync_request( - &self, - provider: &XmtpOpenMlsProvider, - ) -> Result<(String, String), DeviceSyncError> { - let request = DeviceSyncRequest::new(DeviceSyncKind::Consent); - self.send_sync_request(provider, request).await - } - - pub async fn reply_to_consent_sync_request( - &self, - provider: &XmtpOpenMlsProvider, - ) -> Result { - let conn = provider.conn_ref(); - let (_msg, request) = self - .pending_sync_request(provider, DeviceSyncKind::Consent) - .await?; - - let consent_records = self.syncable_consent_records(conn)?; - - let reply = self - .create_sync_reply( - &request.request_id, - &[consent_records], - DeviceSyncKind::Consent, - ) - .await?; - self.send_sync_reply(provider, reply.clone()).await?; - - Ok(reply) - } - - pub async fn process_consent_sync_reply( - &self, - provider: &XmtpOpenMlsProvider, - ) -> Result<(), DeviceSyncError> { - self.process_sync_reply(provider, DeviceSyncKind::Consent) - .await - } - - fn syncable_consent_records( + pub(super) fn syncable_consent_records( &self, conn: &DbConnection, ) -> Result, DeviceSyncError> { @@ -128,7 +89,7 @@ pub(crate) mod tests { // Have the second installation request for a consent sync. let (_group_id, _pin_code) = amal_b - .send_consent_sync_request(&amal_b_provider) + .send_sync_request(&amal_b_provider, DeviceSyncKind::Consent) .await .expect("history request"); @@ -142,7 +103,7 @@ pub(crate) mod tests { // has no problem packaging the consent records, // and sends a reply message to the first installation. let reply = amal_a - .reply_to_consent_sync_request(&amal_a_provider) + .reply_to_sync_request(&amal_a_provider, DeviceSyncKind::Consent) .await .unwrap(); @@ -167,7 +128,7 @@ pub(crate) mod tests { // Have the second installation process the reply. amal_b - .process_consent_sync_reply(&amal_b_provider) + .process_sync_reply(&amal_b_provider, DeviceSyncKind::Consent) .await .unwrap(); diff --git a/xmtp_mls/src/groups/device_sync/message_sync.rs b/xmtp_mls/src/groups/device_sync/message_sync.rs index 95d88ef31..7e16e355a 100644 --- a/xmtp_mls/src/groups/device_sync/message_sync.rs +++ b/xmtp_mls/src/groups/device_sync/message_sync.rs @@ -10,49 +10,10 @@ where ApiClient: XmtpApi, V: SmartContractSignatureVerifier, { - // returns (request_id, pin_code) - pub async fn send_history_sync_request( + pub(super) fn syncable_groups( &self, - provider: &XmtpOpenMlsProvider, - ) -> Result<(String, String), DeviceSyncError> { - let request = DeviceSyncRequest::new(DeviceSyncKind::MessageHistory); - - self.send_sync_request(provider, request).await - } - - pub async fn reply_to_history_sync_request( - &self, - provider: &XmtpOpenMlsProvider, - ) -> Result { - let conn = provider.conn_ref(); - let (_msg, request) = self - .pending_sync_request(provider, DeviceSyncKind::MessageHistory) - .await?; - - let groups = self.syncable_groups(conn)?; - let messages = self.syncable_messages(conn)?; - - let reply = self - .create_sync_reply( - &request.request_id, - &[groups, messages], - DeviceSyncKind::MessageHistory, - ) - .await?; - self.send_sync_reply(provider, reply.clone()).await?; - - Ok(reply) - } - - pub async fn process_history_sync_reply( - &self, - provider: &XmtpOpenMlsProvider, - ) -> Result<(), DeviceSyncError> { - self.process_sync_reply(provider, DeviceSyncKind::MessageHistory) - .await - } - - fn syncable_groups(&self, conn: &DbConnection) -> Result, DeviceSyncError> { + conn: &DbConnection, + ) -> Result, DeviceSyncError> { let groups = conn .find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))? .into_iter() @@ -61,7 +22,10 @@ where Ok(groups) } - fn syncable_messages(&self, conn: &DbConnection) -> Result, DeviceSyncError> { + pub(super) fn syncable_messages( + &self, + conn: &DbConnection, + ) -> Result, DeviceSyncError> { let groups = conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; @@ -153,7 +117,7 @@ pub(crate) mod tests { .expect("sync_welcomes"); // Have the second installation request for a consent sync. let (_group_id, _pin_code) = amal_b - .send_history_sync_request(&amal_b_provider) + .send_sync_request(&amal_b_provider, DeviceSyncKind::MessageHistory) .await .expect("history request"); @@ -167,7 +131,7 @@ pub(crate) mod tests { // has no problem packaging the consent records, // and sends a reply message to the first installation. let reply = amal_a - .reply_to_history_sync_request(&amal_a_provider) + .reply_to_sync_request(&amal_a_provider, DeviceSyncKind::MessageHistory) .await .unwrap(); @@ -195,7 +159,7 @@ pub(crate) mod tests { // Have the second installation process the reply. amal_b - .process_history_sync_reply(&amal_b_provider) + .process_sync_reply(&amal_b_provider, DeviceSyncKind::MessageHistory) .await .unwrap(); From 83cfac3eea07264532bd041c5d32261cbd278b56 Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 14:50:34 -0400 Subject: [PATCH 2/6] node bindings --- bindings_node/src/mls_client.rs | 66 ++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/bindings_node/src/mls_client.rs b/bindings_node/src/mls_client.rs index 12eb9dec9..311dab6f9 100644 --- a/bindings_node/src/mls_client.rs +++ b/bindings_node/src/mls_client.rs @@ -17,6 +17,7 @@ use xmtp_mls::groups::scoped_client::LocalScopedGroupClient; use xmtp_mls::identity::IdentityStrategy; use xmtp_mls::storage::{EncryptedMessageStore, EncryptionKey, StorageOption}; use xmtp_mls::Client as MlsClient; +use xmtp_proto::xmtp::mls::message_contents::DeviceSyncKind; pub type RustXmtpClient = MlsClient; static LOGGER_INIT: Once = Once::new(); @@ -179,14 +180,75 @@ impl NapiClient { } #[napi] - pub async fn request_history_sync(&self) -> Result<()> { + pub async fn send_history_sync_request(&self) -> Result<()> { + self.send_sync_request(DeviceSyncKind::MessageHistory).await + } + + #[napi] + pub async fn send_consent_sync_request(&self) -> Result<()> { + self.send_sync_request(DeviceSyncKind::Consent).await + } + + async fn send_sync_request(&self, kind: DeviceSyncKind) -> Result<()> { + let provider = self + .inner_client + .mls_provider() + .map_err(ErrorWrapper::from)?; + let _ = self + .inner_client + .send_sync_request(&provider, kind) + .await + .map_err(ErrorWrapper::from)?; + + Ok(()) + } + + #[napi] + pub async fn reply_to_history_sync_request(&self) -> Result<()> { + self + .reply_to_sync_request(DeviceSyncKind::MessageHistory) + .await + } + + #[napi] + pub async fn reply_to_consent_sync_request(&self) -> Result<()> { + self.reply_to_sync_request(DeviceSyncKind::Consent).await + } + + async fn reply_to_sync_request(&self, kind: DeviceSyncKind) -> Result<()> { + let provider = self + .inner_client + .mls_provider() + .map_err(ErrorWrapper::from)?; + let _ = self + .inner_client + .reply_to_sync_request(&provider, kind) + .await + .map_err(ErrorWrapper::from)?; + + Ok(()) + } + + #[napi] + pub async fn process_history_sync_reply(&self) -> Result<()> { + self + .process_sync_reply(DeviceSyncKind::MessageHistory) + .await + } + + #[napi] + pub async fn process_consent_sync_reply(&self) -> Result<()> { + self.process_sync_reply(DeviceSyncKind::Consent).await + } + + async fn process_sync_reply(&self, kind: DeviceSyncKind) -> Result<()> { let provider = self .inner_client .mls_provider() .map_err(ErrorWrapper::from)?; let _ = self .inner_client - .send_history_sync_request(&provider) + .process_sync_reply(&provider, kind) .await .map_err(ErrorWrapper::from)?; From f2dc04383d1d015de7b6c52ba1fe387a356b8ee2 Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 14:54:31 -0400 Subject: [PATCH 3/6] wasm bindings --- bindings_wasm/src/mls_client.rs | 68 +++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/bindings_wasm/src/mls_client.rs b/bindings_wasm/src/mls_client.rs index 1287c4601..da61b04d7 100644 --- a/bindings_wasm/src/mls_client.rs +++ b/bindings_wasm/src/mls_client.rs @@ -12,6 +12,7 @@ use xmtp_mls::groups::scoped_client::LocalScopedGroupClient; use xmtp_mls::identity::IdentityStrategy; use xmtp_mls::storage::{EncryptedMessageStore, EncryptionKey, StorageOption}; use xmtp_mls::Client as MlsClient; +use xmtp_proto::xmtp::mls::message_contents::DeviceSyncKind; use crate::conversations::WasmConversations; use crate::signatures::WasmSignatureRequestType; @@ -155,15 +156,76 @@ impl WasmClient { Ok(()) } - #[wasm_bindgen(js_name = requestHistorySync)] - pub async fn request_history_sync(&self) -> Result<(), JsError> { + #[wasm_bindgen(js_name = sendHistorySyncRequest)] + pub async fn send_history_sync_request(&self) -> Result<(), JsError> { + self.send_sync_request(DeviceSyncKind::MessageHistory).await + } + + #[wasm_bindgen(js_name = sendConsentSyncRequest)] + pub async fn send_consent_sync_request(&self) -> Result<(), JsError> { + self.send_sync_request(DeviceSyncKind::Consent).await + } + + async fn send_sync_request(&self, kind: DeviceSyncKind) -> Result<(), JsError> { + let provider = self + .inner_client + .mls_provider() + .map_err(|e| JsError::new(format!("{}", e).as_str()))?; + let _ = self + .inner_client + .send_sync_request(&provider, kind) + .await + .map_err(|e| JsError::new(format!("{}", e).as_str()))?; + + Ok(()) + } + + #[wasm_bindgen(js_name = replyToHistorySyncRequest)] + pub async fn reply_to_history_sync_request(&self) -> Result<(), JsError> { + self + .reply_to_sync_request(DeviceSyncKind::MessageHistory) + .await + } + + #[wasm_bindgen(js_name = replyToConsentSyncRequest)] + pub async fn reply_to_consent_sync_request(&self) -> Result<(), JsError> { + self.reply_to_sync_request(DeviceSyncKind::Consent).await + } + + async fn reply_to_sync_request(&self, kind: DeviceSyncKind) -> Result<(), JsError> { + let provider = self + .inner_client + .mls_provider() + .map_err(|e| JsError::new(format!("{}", e).as_str()))?; + let _ = self + .inner_client + .reply_to_sync_request(&provider, kind) + .await + .map_err(|e| JsError::new(format!("{}", e).as_str()))?; + + Ok(()) + } + + #[wasm_bindgen(js_name = processHistorySyncReply)] + pub async fn process_history_sync_reply(&self) -> Result<(), JsError> { + self + .process_sync_reply(DeviceSyncKind::MessageHistory) + .await + } + + #[wasm_bindgen(js_name = processConsentSyncReply)] + pub async fn process_consent_sync_reply(&self) -> Result<(), JsError> { + self.process_sync_reply(DeviceSyncKind::Consent).await + } + + async fn process_sync_reply(&self, kind: DeviceSyncKind) -> Result<(), JsError> { let provider = self .inner_client .mls_provider() .map_err(|e| JsError::new(format!("{}", e).as_str()))?; let _ = self .inner_client - .send_history_sync_request(&provider) + .process_sync_reply(&provider, kind) .await .map_err(|e| JsError::new(format!("{}", e).as_str()))?; From 9b31a2e3b6e27e09784ca6b1b3965d919cf04bdf Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 14:59:20 -0400 Subject: [PATCH 4/6] cli --- examples/cli/cli-client.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/cli/cli-client.rs b/examples/cli/cli-client.rs index 09b6dca56..9526be1d8 100755 --- a/examples/cli/cli-client.rs +++ b/examples/cli/cli-client.rs @@ -24,6 +24,7 @@ use xmtp_mls::groups::device_sync::DeviceSyncContent; use xmtp_mls::storage::group::GroupQueryArgs; use xmtp_mls::storage::group_message::{GroupMessageKind, MsgQueryArgs}; use xmtp_mls::XmtpApi; +use xmtp_proto::xmtp::mls::message_contents::DeviceSyncKind; use crate::{ json_logger::make_value, @@ -355,7 +356,10 @@ async fn main() { let provider = client.mls_provider().unwrap(); client.sync_welcomes(&conn).await.unwrap(); client.enable_sync(&provider).await.unwrap(); - let (group_id, _) = client.send_history_sync_request(&provider).await.unwrap(); + let (group_id, _) = client + .send_sync_request(&provider, DeviceSyncKind::MessageHistory) + .await + .unwrap(); let group_id_str = hex::encode(group_id); info!("Sent history sync request in sync group {group_id_str}", { group_id: group_id_str}) } @@ -364,7 +368,7 @@ async fn main() { let group = client.get_sync_group().unwrap(); let group_id_str = hex::encode(group.group_id); let reply = client - .reply_to_history_sync_request(&provider) + .reply_to_sync_request(&provider, DeviceSyncKind::MessageHistory) .await .unwrap(); @@ -376,7 +380,10 @@ async fn main() { let provider = client.mls_provider().unwrap(); client.sync_welcomes(&conn).await.unwrap(); client.enable_sync(&provider).await.unwrap(); - client.process_history_sync_reply(&provider).await.unwrap(); + client + .process_sync_reply(&provider, DeviceSyncKind::MessageHistory) + .await + .unwrap(); info!("History bundle downloaded and inserted into user DB", {}) } @@ -385,7 +392,10 @@ async fn main() { let provider = client.mls_provider().unwrap(); client.sync_welcomes(&conn).await.unwrap(); client.enable_sync(&provider).await.unwrap(); - client.process_consent_sync_reply(&provider).await.unwrap(); + client + .process_sync_reply(&provider, DeviceSyncKind::Consent) + .await + .unwrap(); info!("Consent bundle downloaded and inserted into user DB", {}) } From d4fcc0839035e644c09c0569e21ade9c10fb2f6a Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 15:03:36 -0400 Subject: [PATCH 5/6] lint --- bindings_node/src/mls_client.rs | 6 +++--- bindings_wasm/src/mls_client.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings_node/src/mls_client.rs b/bindings_node/src/mls_client.rs index 311dab6f9..a798cbfff 100644 --- a/bindings_node/src/mls_client.rs +++ b/bindings_node/src/mls_client.rs @@ -194,7 +194,7 @@ impl NapiClient { .inner_client .mls_provider() .map_err(ErrorWrapper::from)?; - let _ = self + self .inner_client .send_sync_request(&provider, kind) .await @@ -220,7 +220,7 @@ impl NapiClient { .inner_client .mls_provider() .map_err(ErrorWrapper::from)?; - let _ = self + self .inner_client .reply_to_sync_request(&provider, kind) .await @@ -246,7 +246,7 @@ impl NapiClient { .inner_client .mls_provider() .map_err(ErrorWrapper::from)?; - let _ = self + self .inner_client .process_sync_reply(&provider, kind) .await diff --git a/bindings_wasm/src/mls_client.rs b/bindings_wasm/src/mls_client.rs index da61b04d7..bf5307196 100644 --- a/bindings_wasm/src/mls_client.rs +++ b/bindings_wasm/src/mls_client.rs @@ -171,7 +171,7 @@ impl WasmClient { .inner_client .mls_provider() .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - let _ = self + self .inner_client .send_sync_request(&provider, kind) .await @@ -197,7 +197,7 @@ impl WasmClient { .inner_client .mls_provider() .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - let _ = self + self .inner_client .reply_to_sync_request(&provider, kind) .await @@ -223,7 +223,7 @@ impl WasmClient { .inner_client .mls_provider() .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - let _ = self + self .inner_client .process_sync_reply(&provider, kind) .await From 8d9063dc9aea96de7e4f5ee1034426abe2d68479 Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Thu, 31 Oct 2024 15:11:40 -0400 Subject: [PATCH 6/6] cleanup --- bindings_ffi/src/mls.rs | 18 ------------ bindings_node/src/mls_client.rs | 52 --------------------------------- bindings_wasm/src/mls_client.rs | 52 --------------------------------- 3 files changed, 122 deletions(-) diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 51c8617dd..6f3399411 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -409,24 +409,6 @@ impl FfiXmtpClient { Ok(()) } - pub async fn reply_to_sync_request(&self, kind: FfiDeviceSyncKind) -> Result<(), GenericError> { - let provider = self.inner_client.mls_provider()?; - self.inner_client - .reply_to_sync_request(&provider, kind.into()) - .await?; - - Ok(()) - } - - pub async fn process_sync_reply(&self, kind: FfiDeviceSyncKind) -> Result<(), GenericError> { - let provider = self.inner_client.mls_provider()?; - self.inner_client - .process_sync_reply(&provider, kind.into()) - .await?; - - Ok(()) - } - /// Adds an identity - really a wallet address - to the existing client pub async fn add_wallet( &self, diff --git a/bindings_node/src/mls_client.rs b/bindings_node/src/mls_client.rs index a798cbfff..f6709cbaf 100644 --- a/bindings_node/src/mls_client.rs +++ b/bindings_node/src/mls_client.rs @@ -203,58 +203,6 @@ impl NapiClient { Ok(()) } - #[napi] - pub async fn reply_to_history_sync_request(&self) -> Result<()> { - self - .reply_to_sync_request(DeviceSyncKind::MessageHistory) - .await - } - - #[napi] - pub async fn reply_to_consent_sync_request(&self) -> Result<()> { - self.reply_to_sync_request(DeviceSyncKind::Consent).await - } - - async fn reply_to_sync_request(&self, kind: DeviceSyncKind) -> Result<()> { - let provider = self - .inner_client - .mls_provider() - .map_err(ErrorWrapper::from)?; - self - .inner_client - .reply_to_sync_request(&provider, kind) - .await - .map_err(ErrorWrapper::from)?; - - Ok(()) - } - - #[napi] - pub async fn process_history_sync_reply(&self) -> Result<()> { - self - .process_sync_reply(DeviceSyncKind::MessageHistory) - .await - } - - #[napi] - pub async fn process_consent_sync_reply(&self) -> Result<()> { - self.process_sync_reply(DeviceSyncKind::Consent).await - } - - async fn process_sync_reply(&self, kind: DeviceSyncKind) -> Result<()> { - let provider = self - .inner_client - .mls_provider() - .map_err(ErrorWrapper::from)?; - self - .inner_client - .process_sync_reply(&provider, kind) - .await - .map_err(ErrorWrapper::from)?; - - Ok(()) - } - #[napi] pub async fn find_inbox_id_by_address(&self, address: String) -> Result> { let inbox_id = self diff --git a/bindings_wasm/src/mls_client.rs b/bindings_wasm/src/mls_client.rs index bf5307196..5bad88d45 100644 --- a/bindings_wasm/src/mls_client.rs +++ b/bindings_wasm/src/mls_client.rs @@ -180,58 +180,6 @@ impl WasmClient { Ok(()) } - #[wasm_bindgen(js_name = replyToHistorySyncRequest)] - pub async fn reply_to_history_sync_request(&self) -> Result<(), JsError> { - self - .reply_to_sync_request(DeviceSyncKind::MessageHistory) - .await - } - - #[wasm_bindgen(js_name = replyToConsentSyncRequest)] - pub async fn reply_to_consent_sync_request(&self) -> Result<(), JsError> { - self.reply_to_sync_request(DeviceSyncKind::Consent).await - } - - async fn reply_to_sync_request(&self, kind: DeviceSyncKind) -> Result<(), JsError> { - let provider = self - .inner_client - .mls_provider() - .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - self - .inner_client - .reply_to_sync_request(&provider, kind) - .await - .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - - Ok(()) - } - - #[wasm_bindgen(js_name = processHistorySyncReply)] - pub async fn process_history_sync_reply(&self) -> Result<(), JsError> { - self - .process_sync_reply(DeviceSyncKind::MessageHistory) - .await - } - - #[wasm_bindgen(js_name = processConsentSyncReply)] - pub async fn process_consent_sync_reply(&self) -> Result<(), JsError> { - self.process_sync_reply(DeviceSyncKind::Consent).await - } - - async fn process_sync_reply(&self, kind: DeviceSyncKind) -> Result<(), JsError> { - let provider = self - .inner_client - .mls_provider() - .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - self - .inner_client - .process_sync_reply(&provider, kind) - .await - .map_err(|e| JsError::new(format!("{}", e).as_str()))?; - - Ok(()) - } - #[wasm_bindgen(js_name = findInboxIdByAddress)] pub async fn find_inbox_id_by_address(&self, address: String) -> Result, JsError> { let inbox_id = self