Skip to content

Commit

Permalink
Create basic credentials directly
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Mar 30, 2024
1 parent 4d04bf6 commit 0ae9060
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mls_validation_service/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ mod tests {
async fn test_validate_key_packages_happy_path() {
let (identity, keypair, account_address) = generate_identity();

let credential = OpenMlsCredential::new(CredentialType::Basic, identity);
let credential: OpenMlsCredential = BasicCredential::new(identity).unwrap().into();
let credential_with_key = CredentialWithKey {
credential,
signature_key: keypair.to_public_vec().into(),
Expand Down
11 changes: 8 additions & 3 deletions xmtp_mls/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::sync::RwLock;

use log::info;
use openmls::{
credentials::errors::CredentialError,
credentials::{
errors::{BasicCredentialError, CredentialError},
BasicCredential,
},
extensions::{errors::InvalidExtensionError, ApplicationIdExtension, LastResortExtension},
prelude::{
tls_codec::{Error as TlsCodecError, Serialize},
Expand Down Expand Up @@ -58,6 +61,8 @@ pub enum IdentityError {
ApiError(#[from] xmtp_proto::api_client::Error),
#[error("OpenMLS credential error: {0}")]
OpenMlsCredentialError(#[from] CredentialError),
#[error("Basic Credential error: {0}")]
BasicCredential(#[from] BasicCredentialError),
}

#[derive(Debug)]
Expand Down Expand Up @@ -136,8 +141,8 @@ impl Identity {
recoverable_wallet_signature.unwrap(),
)?
.into();
let credential =
OpenMlsCredential::new(CredentialType::Basic, credential_proto.encode_to_vec());
let credential: OpenMlsCredential =
BasicCredential::new(credential_proto.encode_to_vec())?.into();
self.set_credential(credential)?;
}

Expand Down

0 comments on commit 0ae9060

Please sign in to comment.