Skip to content

Commit

Permalink
refactor: fix usage sites of types implementing Conversation
Browse files Browse the repository at this point in the history
I.e., import the new trait.
  • Loading branch information
SimonThormeyer committed Mar 3, 2025
1 parent a216dc6 commit 7a5a503
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 19 deletions.
1 change: 1 addition & 0 deletions crypto-ffi/src/generic/context/e2ei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
E2eiEnrollment, MlsCredentialType, WireIdentity, context::CoreCryptoContext,
},
};
use core_crypto::mls::conversation::Conversation;
use core_crypto::{RecursiveError, prelude::VerifiableGroupInfo};
use tls_codec::Deserialize;

Expand Down
1 change: 1 addition & 0 deletions crypto-ffi/src/generic/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::{
};
use crate::NewCrlDistributionPoints;
use async_lock::{Mutex, OnceCell};
use core_crypto::mls::conversation::Conversation;
use core_crypto::{
RecursiveError,
context::CentralContext,
Expand Down
11 changes: 9 additions & 2 deletions crypto-ffi/src/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use tls_codec::Deserialize;

use self::context::CoreCryptoContext;
use crate::{UniffiCustomTypeConverter, proteus_impl};
use core_crypto::mls::conversation::Conversation;
pub use core_crypto::prelude::ConversationId;
use core_crypto::{
InnermostErrorMessage, RecursiveError,
Expand Down Expand Up @@ -1184,12 +1185,18 @@ impl CoreCrypto {

/// See [core_crypto::mls::conversation::ImmutableConversation::epoch]
pub async fn conversation_epoch(&self, conversation_id: Vec<u8>) -> CoreCryptoResult<u64> {
Ok(self.central.get_raw_conversation(&conversation_id).await?.epoch())
let conversation = self.central.get_raw_conversation(&conversation_id).await?;
Ok(conversation.epoch().await)
}

/// See [core_crypto::mls::conversation::ImmutableConversation::ciphersuite]
pub async fn conversation_ciphersuite(&self, conversation_id: &ConversationId) -> CoreCryptoResult<Ciphersuite> {
let cs = self.central.get_raw_conversation(conversation_id).await?.ciphersuite();
let cs = self
.central
.get_raw_conversation(conversation_id)
.await?
.ciphersuite()
.await;
Ok(Ciphersuite::from(core_crypto::prelude::CiphersuiteName::from(cs)))
}

Expand Down
12 changes: 6 additions & 6 deletions crypto-ffi/src/wasm/context/e2ei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ use std::{
ops::{Deref, DerefMut},
};

use crate::{
Ciphersuite, CoreCryptoError, CredentialType, CrlRegistration, E2eiDumpedPkiEnv, E2eiEnrollment, InternalError,
WasmCryptoResult, WireIdentity,
wasm::{E2eiConversationState, context::CoreCryptoContext},
};
use core_crypto::mls::conversation::Conversation;
use core_crypto::{
RecursiveError,
prelude::{CiphersuiteName, ClientId, ConversationId, MlsCiphersuite, VerifiableGroupInfo},
Expand All @@ -13,12 +19,6 @@ use tls_codec::Deserialize;
use wasm_bindgen::{JsValue, prelude::wasm_bindgen};
use wasm_bindgen_futures::future_to_promise;

use crate::{
Ciphersuite, CoreCryptoError, CredentialType, CrlRegistration, E2eiDumpedPkiEnv, E2eiEnrollment, InternalError,
WasmCryptoResult, WireIdentity,
wasm::{E2eiConversationState, context::CoreCryptoContext},
};

#[wasm_bindgen]
impl CoreCryptoContext {
/// Returns: [`WasmCryptoResult<E2eiEnrollment>`]
Expand Down
1 change: 1 addition & 0 deletions crypto-ffi/src/wasm/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
Ciphersuite, ConversationConfiguration, CoreCrypto, CoreCryptoError, CoreCryptoResult, CredentialType,
CustomConfiguration, DecryptedMessage, FfiClientId, WasmCryptoResult, WelcomeBundle,
};
use core_crypto::mls::conversation::Conversation;
use core_crypto::{
RecursiveError,
context::CentralContext,
Expand Down
24 changes: 19 additions & 5 deletions crypto-ffi/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{
};

use crate::proteus_impl;
use core_crypto::mls::conversation::Conversation;
use core_crypto::{InnermostErrorMessage, MlsTransportResponse, prelude::*};
use futures_util::future::TryFutureExt;
use js_sys::{Promise, Uint8Array};
Expand Down Expand Up @@ -1582,8 +1583,17 @@ impl CoreCrypto {
pub fn conversation_epoch(&self, conversation_id: ConversationId) -> Promise {
let central = self.inner.clone();
future_to_promise(
async move { WasmCryptoResult::Ok(central.get_raw_conversation(&conversation_id).await?.epoch().into()) }
.err_into(),
async move {
WasmCryptoResult::Ok(
central
.get_raw_conversation(&conversation_id)
.await?
.epoch()
.await
.into(),
)
}
.err_into(),
)
}

Expand All @@ -1594,9 +1604,13 @@ impl CoreCrypto {
let central = self.inner.clone();
future_to_promise(
async move {
WasmCryptoResult::Ok(
Ciphersuite::from(central.get_raw_conversation(&conversation_id).await?.ciphersuite()).into(),
)
let ciphersuite = central
.get_raw_conversation(&conversation_id)
.await?
.ciphersuite()
.await
.into::<Ciphersuite>();

Check failure on line 1612 in crypto-ffi/src/wasm/mod.rs

View workflow job for this annotation

GitHub Actions / web benchmarks with bencher

method takes 0 generic arguments but 1 generic argument was supplied

Check failure on line 1612 in crypto-ffi/src/wasm/mod.rs

View workflow job for this annotation

GitHub Actions / check (check --locked, --tests, --target wasm32-unknown-unknown)

method takes 0 generic arguments but 1 generic argument was supplied

Check failure on line 1612 in crypto-ffi/src/wasm/mod.rs

View workflow job for this annotation

GitHub Actions / check (clippy --locked, -- -D warnings, --target wasm32-unknown-unknown)

method takes 0 generic arguments but 1 generic argument was supplied

Check failure on line 1612 in crypto-ffi/src/wasm/mod.rs

View workflow job for this annotation

GitHub Actions / build-and-test-wasm

method takes 0 generic arguments but 1 generic argument was supplied

Check failure on line 1612 in crypto-ffi/src/wasm/mod.rs

View workflow job for this annotation

GitHub Actions / typescript

method takes 0 generic arguments but 1 generic argument was supplied
WasmCryptoResult::Ok(ciphersuite.into())
}
.err_into(),
)
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/e2e_identity/conversation_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ mod tests {
use crate::e2e_identity::rotate::tests::all::failsafe_ctx;
use wasm_bindgen_test::*;

use super::*;
use crate::mls::conversation::Conversation;
use crate::{
prelude::{CertificateBundle, Client, MlsCredentialType},
test_utils::*,
};

use super::*;

wasm_bindgen_test_configure!(run_in_browser);

// testing the case where both Bob & Alice have the same Credential type
Expand Down
1 change: 1 addition & 0 deletions crypto/src/e2e_identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ pub(crate) mod tests {
use serde_json::json;
use wasm_bindgen_test::*;

use crate::mls::conversation::Conversation;
#[cfg(not(target_family = "wasm"))]
use crate::{
RecursiveError,
Expand Down
1 change: 1 addition & 0 deletions crypto/src/e2e_identity/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ pub(crate) mod tests {

mod one {
use super::*;
use crate::mls::conversation::Conversation;

#[apply(all_cred_cipher)]
#[wasm_bindgen_test]
Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/buffer_external_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl CentralContext {

#[cfg(test)]
mod tests {
use crate::mls::conversation::Conversation;
use crate::prelude::MlsConversationDecryptMessage;
use crate::test_utils::*;
use wasm_bindgen_test::*;
Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/conversation/buffer_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl MlsConversation {
#[cfg(test)]
mod tests {
use super::super::error::Error;
use crate::mls::conversation::Conversation;
use crate::prelude::MlsConversationDecryptMessage;
use crate::test_utils::*;
use wasm_bindgen_test::*;
Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/conversation/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ mod tests {

mod commit {
use super::*;
use crate::mls::conversation::Conversation;

#[apply(all_cred_cipher)]
#[wasm_bindgen_test]
Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/conversation/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl MlsConversation {
#[cfg(test)]
mod tests {
use super::super::error::Error;
use crate::mls::conversation::Conversation;
use crate::test_utils::*;
use wasm_bindgen_test::*;

Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/conversation/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ mod tests {

mod export_secret {
use super::*;
use crate::mls::conversation::Conversation;

#[apply(all_cred_cipher)]
#[wasm_bindgen_test]
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/mls/conversation/external_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ impl MlsConversation {

#[cfg(test)]
mod tests {
use wasm_bindgen_test::*;

use crate::mls::conversation::Conversation;
use crate::test_utils::*;
use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);

Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/conversation/own_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ mod tests {
use super::super::error::Error;
use crate::prelude::MlsError;

use crate::mls::conversation::Conversation;
use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/mls/credential/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ mod tests {
use std::sync::Arc;
use wasm_bindgen_test::*;

use super::*;
use crate::mls::conversation::Conversation;
use crate::{
CoreCrypto, RecursiveError,
mls::credential::x509::CertificatePrivateKey,
Expand All @@ -165,8 +167,6 @@ mod tests {
},
};

use super::*;

wasm_bindgen_test_configure!(run_in_browser);

#[apply(all_cred_cipher)]
Expand Down
1 change: 1 addition & 0 deletions crypto/src/mls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ mod tests {

mod conversation_epoch {
use super::*;
use crate::mls::conversation::Conversation;

#[apply(all_cred_cipher)]
#[wasm_bindgen_test]
Expand Down
1 change: 1 addition & 0 deletions crypto/src/test_utils/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use super::Result;
use crate::group_store::GroupStore;
use crate::mls::conversation::Conversation;
use crate::prelude::{MlsCommitBundle, MlsGroupInfoBundle, WelcomeBundle};
use crate::test_utils::{ClientContext, TestError};
use crate::{
Expand Down

0 comments on commit 7a5a503

Please sign in to comment.