diff --git a/Cargo.toml b/Cargo.toml index 3f826b761..be4ab72c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0 bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } [workspace.lints.clippy] +unused_async = "deny" unwrap_used = "deny" # Compile all dependencies with some optimizations when building this crate on debug diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 6c18bfc61..1065a01a9 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -26,7 +26,6 @@ impl ClientAuth { .await .auth() .password_strength(password, email, additional_inputs) - .await } /// Evaluate if the provided password satisfies the provided policy @@ -42,7 +41,6 @@ impl ClientAuth { .await .auth() .satisfies_policy(password, strength, &policy) - .await } /// Hash the user password diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 0f877d52e..991ff820f 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -60,15 +60,14 @@ impl ClientCrypto { .write() .await .crypto() - .update_password(new_password) - .await?) + .update_password(new_password)?) } /// Generates a PIN protected user key from the provided PIN. The result can be stored and later /// used to initialize another client instance by using the PIN and the PIN key with /// `initialize_user_crypto`. pub async fn derive_pin_key(&self, pin: String) -> Result { - Ok(self.0 .0.write().await.crypto().derive_pin_key(pin).await?) + Ok(self.0 .0.write().await.crypto().derive_pin_key(pin)?) } /// Derives the pin protected user key from encrypted pin. Used when pin requires master @@ -80,8 +79,7 @@ impl ClientCrypto { .write() .await .crypto() - .derive_pin_user_key(encrypted_pin) - .await?) + .derive_pin_user_key(encrypted_pin)?) } pub async fn enroll_admin_password_reset( diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 3ad4f7f93..78781b263 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -18,26 +18,12 @@ pub struct ClientGenerators(pub(crate) Arc); impl ClientGenerators { /// **API Draft:** Generate Password pub async fn password(&self, settings: PasswordGeneratorRequest) -> Result { - Ok(self - .0 - .0 - .read() - .await - .generator() - .password(settings) - .await?) + Ok(self.0 .0.read().await.generator().password(settings)?) } /// **API Draft:** Generate Passphrase pub async fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result { - Ok(self - .0 - .0 - .read() - .await - .generator() - .passphrase(settings) - .await?) + Ok(self.0 .0.read().await.generator().passphrase(settings)?) } /// **API Draft:** Generate Username @@ -71,8 +57,7 @@ impl ClientExporters { .read() .await .exporters() - .export_vault(folders, ciphers, format) - .await?) + .export_vault(folders, ciphers, format)?) } /// **API Draft:** Export organization vault @@ -88,7 +73,6 @@ impl ClientExporters { .read() .await .exporters() - .export_organization_vault(collections, ciphers, format) - .await?) + .export_organization_vault(collections, ciphers, format)?) } } diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index e6aef3e51..36f174d38 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -11,7 +11,7 @@ pub struct ClientSends(pub Arc); impl ClientSends { /// Encrypt send pub async fn encrypt(&self, send: SendView) -> Result { - Ok(self.0 .0.write().await.sends().encrypt(send).await?) + Ok(self.0 .0.write().await.sends().encrypt(send)?) } /// Encrypt a send file in memory @@ -22,8 +22,7 @@ impl ClientSends { .write() .await .sends() - .encrypt_buffer(send, &buffer) - .await?) + .encrypt_buffer(send, &buffer)?) } /// Encrypt a send file located in the file system @@ -33,28 +32,21 @@ impl ClientSends { decrypted_file_path: String, encrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .encrypt_file( - send, - Path::new(&decrypted_file_path), - Path::new(&encrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.sends().encrypt_file( + send, + Path::new(&decrypted_file_path), + Path::new(&encrypted_file_path), + )?) } /// Decrypt send pub async fn decrypt(&self, send: Send) -> Result { - Ok(self.0 .0.write().await.sends().decrypt(send).await?) + Ok(self.0 .0.write().await.sends().decrypt(send)?) } /// Decrypt send list pub async fn decrypt_list(&self, sends: Vec) -> Result> { - Ok(self.0 .0.write().await.sends().decrypt_list(sends).await?) + Ok(self.0 .0.write().await.sends().decrypt_list(sends)?) } /// Decrypt a send file in memory @@ -65,8 +57,7 @@ impl ClientSends { .write() .await .sends() - .decrypt_buffer(send, &buffer) - .await?) + .decrypt_buffer(send, &buffer)?) } /// Decrypt a send file located in the file system @@ -76,17 +67,10 @@ impl ClientSends { encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .decrypt_file( - send, - Path::new(&encrypted_file_path), - Path::new(&decrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.sends().decrypt_file( + send, + Path::new(&encrypted_file_path), + Path::new(&decrypted_file_path), + )?) } } diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index b844c0318..bdac7c97c 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -23,8 +23,7 @@ impl ClientAttachments { .await .vault() .attachments() - .encrypt_buffer(cipher, attachment, &buffer) - .await?) + .encrypt_buffer(cipher, attachment, &buffer)?) } /// Encrypt an attachment file located in the file system @@ -35,20 +34,12 @@ impl ClientAttachments { decrypted_file_path: String, encrypted_file_path: String, ) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .attachments() - .encrypt_file( - cipher, - attachment, - Path::new(&decrypted_file_path), - Path::new(&encrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.vault().attachments().encrypt_file( + cipher, + attachment, + Path::new(&decrypted_file_path), + Path::new(&encrypted_file_path), + )?) } /// Decrypt an attachment file in memory pub async fn decrypt_buffer( @@ -64,8 +55,7 @@ impl ClientAttachments { .await .vault() .attachments() - .decrypt_buffer(cipher, attachment, &buffer) - .await?) + .decrypt_buffer(cipher, attachment, &buffer)?) } /// Decrypt an attachment file located in the file system @@ -76,19 +66,11 @@ impl ClientAttachments { encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .attachments() - .decrypt_file( - cipher, - attachment, - Path::new(&encrypted_file_path), - Path::new(&decrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.vault().attachments().decrypt_file( + cipher, + attachment, + Path::new(&encrypted_file_path), + Path::new(&decrypted_file_path), + )?) } } diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index 329ca3c17..d637bc5fc 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -19,21 +19,12 @@ impl ClientCiphers { .await .vault() .ciphers() - .encrypt(cipher_view) - .await?) + .encrypt(cipher_view)?) } /// Decrypt cipher pub async fn decrypt(&self, cipher: Cipher) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .ciphers() - .decrypt(cipher) - .await?) + Ok(self.0 .0.write().await.vault().ciphers().decrypt(cipher)?) } /// Decrypt cipher list @@ -45,8 +36,7 @@ impl ClientCiphers { .await .vault() .ciphers() - .decrypt_list(ciphers) - .await?) + .decrypt_list(ciphers)?) } /// Move a cipher to an organization, reencrypting the cipher key if necessary @@ -62,7 +52,6 @@ impl ClientCiphers { .await .vault() .ciphers() - .move_to_organization(cipher, organization_id) - .await?) + .move_to_organization(cipher, organization_id)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index 36315aaea..f6cde84ab 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -18,8 +18,7 @@ impl ClientCollections { .await .vault() .collections() - .decrypt(collection) - .await?) + .decrypt(collection)?) } /// Decrypt collection list @@ -31,7 +30,6 @@ impl ClientCollections { .await .vault() .collections() - .decrypt_list(collections) - .await?) + .decrypt_list(collections)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 8847b9a45..5cceeca8b 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -11,28 +11,12 @@ pub struct ClientFolders(pub Arc); impl ClientFolders { /// Encrypt folder pub async fn encrypt(&self, folder: FolderView) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .folders() - .encrypt(folder) - .await?) + Ok(self.0 .0.write().await.vault().folders().encrypt(folder)?) } /// Decrypt folder pub async fn decrypt(&self, folder: Folder) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .folders() - .decrypt(folder) - .await?) + Ok(self.0 .0.write().await.vault().folders().decrypt(folder)?) } /// Decrypt folder list @@ -44,7 +28,6 @@ impl ClientFolders { .await .vault() .folders() - .decrypt_list(folders) - .await?) + .decrypt_list(folders)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 62c468d4b..863eddbac 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -18,8 +18,7 @@ impl ClientPasswordHistory { .await .vault() .password_history() - .encrypt(password_history) - .await?) + .encrypt(password_history)?) } /// Decrypt password history @@ -34,7 +33,6 @@ impl ClientPasswordHistory { .await .vault() .password_history() - .decrypt_list(list) - .await?) + .decrypt_list(list)?) } } diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 0339c5351..14261efee 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -46,7 +46,7 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] impl<'a> ClientAuth<'a> { - pub async fn password_strength( + pub fn password_strength( &self, password: String, email: String, @@ -55,7 +55,7 @@ impl<'a> ClientAuth<'a> { password_strength(password, email, additional_inputs) } - pub async fn satisfies_policy( + pub fn satisfies_policy( &self, password: String, strength: u8, diff --git a/crates/bitwarden/src/mobile/client_crypto.rs b/crates/bitwarden/src/mobile/client_crypto.rs index 6ef65975d..30e88332a 100644 --- a/crates/bitwarden/src/mobile/client_crypto.rs +++ b/crates/bitwarden/src/mobile/client_crypto.rs @@ -33,20 +33,17 @@ impl<'a> ClientCrypto<'a> { } #[cfg(feature = "internal")] - pub async fn update_password( - &mut self, - new_password: String, - ) -> Result { + pub fn update_password(&mut self, new_password: String) -> Result { update_password(self.client, new_password) } #[cfg(feature = "internal")] - pub async fn derive_pin_key(&mut self, pin: String) -> Result { + pub fn derive_pin_key(&mut self, pin: String) -> Result { derive_pin_key(self.client, pin) } #[cfg(feature = "internal")] - pub async fn derive_pin_user_key(&mut self, encrypted_pin: EncString) -> Result { + pub fn derive_pin_user_key(&mut self, encrypted_pin: EncString) -> Result { derive_pin_user_key(self.client, encrypted_pin) } diff --git a/crates/bitwarden/src/mobile/tool/client_sends.rs b/crates/bitwarden/src/mobile/tool/client_sends.rs index 83652c8c4..9feeec030 100644 --- a/crates/bitwarden/src/mobile/tool/client_sends.rs +++ b/crates/bitwarden/src/mobile/tool/client_sends.rs @@ -14,7 +14,7 @@ pub struct ClientSends<'a> { } impl<'a> ClientSends<'a> { - pub async fn decrypt(&self, send: Send) -> Result { + pub fn decrypt(&self, send: Send) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -23,7 +23,7 @@ impl<'a> ClientSends<'a> { Ok(send_view) } - pub async fn decrypt_list(&self, sends: Vec) -> Result> { + pub fn decrypt_list(&self, sends: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -32,19 +32,19 @@ impl<'a> ClientSends<'a> { Ok(send_views) } - pub async fn decrypt_file( + pub fn decrypt_file( &self, send: Send, encrypted_file_path: &Path, decrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(encrypted_file_path)?; - let decrypted = self.decrypt_buffer(send, &data).await?; + let decrypted = self.decrypt_buffer(send, &data)?; std::fs::write(decrypted_file_path, decrypted)?; Ok(()) } - pub async fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { + pub fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; @@ -53,7 +53,7 @@ impl<'a> ClientSends<'a> { Ok(buf.decrypt_with_key(&key)?) } - pub async fn encrypt(&self, send_view: SendView) -> Result { + pub fn encrypt(&self, send_view: SendView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -62,19 +62,19 @@ impl<'a> ClientSends<'a> { Ok(send) } - pub async fn encrypt_file( + pub fn encrypt_file( &self, send: Send, decrypted_file_path: &Path, encrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(decrypted_file_path)?; - let encrypted = self.encrypt_buffer(send, &data).await?; + let encrypted = self.encrypt_buffer(send, &data)?; std::fs::write(encrypted_file_path, encrypted)?; Ok(()) } - pub async fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { + pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { let key = self .client .get_encryption_settings()? diff --git a/crates/bitwarden/src/mobile/vault/client_attachments.rs b/crates/bitwarden/src/mobile/vault/client_attachments.rs index ce7570fab..2f9edb82b 100644 --- a/crates/bitwarden/src/mobile/vault/client_attachments.rs +++ b/crates/bitwarden/src/mobile/vault/client_attachments.rs @@ -17,7 +17,7 @@ pub struct ClientAttachments<'a> { } impl<'a> ClientAttachments<'a> { - pub async fn encrypt_buffer( + pub fn encrypt_buffer( &self, cipher: Cipher, attachment: AttachmentView, @@ -33,7 +33,7 @@ impl<'a> ClientAttachments<'a> { } .encrypt_with_key(key)?) } - pub async fn encrypt_file( + pub fn encrypt_file( &self, cipher: Cipher, attachment: AttachmentView, @@ -44,12 +44,12 @@ impl<'a> ClientAttachments<'a> { let AttachmentEncryptResult { attachment, contents, - } = self.encrypt_buffer(cipher, attachment, &data).await?; + } = self.encrypt_buffer(cipher, attachment, &data)?; std::fs::write(encrypted_file_path, contents)?; Ok(attachment) } - pub async fn decrypt_buffer( + pub fn decrypt_buffer( &self, cipher: Cipher, attachment: Attachment, @@ -66,7 +66,7 @@ impl<'a> ClientAttachments<'a> { .decrypt_with_key(key) .map_err(Error::Crypto) } - pub async fn decrypt_file( + pub fn decrypt_file( &self, cipher: Cipher, attachment: Attachment, @@ -74,7 +74,7 @@ impl<'a> ClientAttachments<'a> { decrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(encrypted_file_path)?; - let decrypted = self.decrypt_buffer(cipher, attachment, &data).await?; + let decrypted = self.decrypt_buffer(cipher, attachment, &data)?; std::fs::write(decrypted_file_path, decrypted)?; Ok(()) } diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index 63d11766d..e459f4e7c 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -10,7 +10,7 @@ pub struct ClientCiphers<'a> { } impl<'a> ClientCiphers<'a> { - pub async fn encrypt(&self, mut cipher_view: CipherView) -> Result { + pub fn encrypt(&self, mut cipher_view: CipherView) -> Result { let enc = self.client.get_encryption_settings()?; // TODO: Once this flag is removed, the key generation logic should @@ -26,7 +26,7 @@ impl<'a> ClientCiphers<'a> { Ok(cipher) } - pub async fn decrypt(&self, cipher: Cipher) -> Result { + pub fn decrypt(&self, cipher: Cipher) -> Result { let enc = self.client.get_encryption_settings()?; let key = cipher .locate_key(enc, &None) @@ -37,7 +37,7 @@ impl<'a> ClientCiphers<'a> { Ok(cipher_view) } - pub async fn decrypt_list(&self, ciphers: Vec) -> Result> { + pub fn decrypt_list(&self, ciphers: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let cipher_views: Result> = ciphers @@ -51,7 +51,7 @@ impl<'a> ClientCiphers<'a> { cipher_views } - pub async fn move_to_organization( + pub fn move_to_organization( &self, mut cipher_view: CipherView, organization_id: Uuid, @@ -114,7 +114,7 @@ mod tests { deleted_date: None, revision_date: "2024-05-31T09:35:55.12Z".parse().unwrap(), }]) - .await + .unwrap(); assert_eq!(dec[0].name, "Test item"); @@ -186,22 +186,13 @@ mod tests { let mut cipher = test_cipher(); cipher.attachments = Some(vec![test_attachment_legacy()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); // Move cipher to organization - let res = client - .vault() - .ciphers() - .move_to_organization( - view, - "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), - ) - .await; + let res = client.vault().ciphers().move_to_organization( + view, + "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), + ); assert!(res.is_err()); } @@ -214,20 +205,15 @@ mod tests { let attachment = test_attachment_legacy(); cipher.attachments = Some(vec![attachment.clone()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); assert!(cipher.key.is_none()); // Assert the cipher has a key, and the attachment is still readable - let new_cipher = client.vault().ciphers().encrypt(view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(view).unwrap(); assert!(new_cipher.key.is_some()); - let view = client.vault().ciphers().decrypt(new_cipher).await.unwrap(); + let view = client.vault().ciphers().decrypt(new_cipher).unwrap(); let attachments = view.clone().attachments.unwrap(); let attachment_view = attachments.first().unwrap().clone(); assert!(attachment_view.key.is_none()); @@ -245,7 +231,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); @@ -259,20 +244,15 @@ mod tests { let attachment = test_attachment_v2(); cipher.attachments = Some(vec![attachment.clone()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); assert!(cipher.key.is_none()); // Assert the cipher has a key, and the attachment is still readable - let new_cipher = client.vault().ciphers().encrypt(view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(view).unwrap(); assert!(new_cipher.key.is_some()); - let view = client.vault().ciphers().decrypt(new_cipher).await.unwrap(); + let view = client.vault().ciphers().decrypt(new_cipher).unwrap(); let attachments = view.clone().attachments.unwrap(); let attachment_view = attachments.first().unwrap().clone(); assert!(attachment_view.key.is_some()); @@ -296,7 +276,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); @@ -309,9 +288,8 @@ mod tests { view, "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), ) - .await .unwrap(); - let new_cipher = client.vault().ciphers().encrypt(new_view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(new_view).unwrap(); let attachment = new_cipher .clone() @@ -331,7 +309,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(new_cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden/src/mobile/vault/client_collection.rs index 26b660461..0727130df 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden/src/mobile/vault/client_collection.rs @@ -8,7 +8,7 @@ pub struct ClientCollections<'a> { } impl<'a> ClientCollections<'a> { - pub async fn decrypt(&self, collection: Collection) -> Result { + pub fn decrypt(&self, collection: Collection) -> Result { let enc = self.client.get_encryption_settings()?; let key = collection .locate_key(enc, &None) @@ -19,7 +19,7 @@ impl<'a> ClientCollections<'a> { Ok(view) } - pub async fn decrypt_list(&self, collections: Vec) -> Result> { + pub fn decrypt_list(&self, collections: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let views: Result> = collections @@ -59,7 +59,7 @@ mod tests { external_id: None, hide_passwords: false, read_only: false, - }]).await.unwrap(); + }]).unwrap(); assert_eq!(dec[0].name, "Default collection"); } @@ -75,7 +75,7 @@ mod tests { external_id: None, hide_passwords: false, read_only: false, - }).await.unwrap(); + }).unwrap(); assert_eq!(dec.name, "Default collection"); } diff --git a/crates/bitwarden/src/mobile/vault/client_folders.rs b/crates/bitwarden/src/mobile/vault/client_folders.rs index cdbcdcd17..668125da2 100644 --- a/crates/bitwarden/src/mobile/vault/client_folders.rs +++ b/crates/bitwarden/src/mobile/vault/client_folders.rs @@ -8,7 +8,7 @@ pub struct ClientFolders<'a> { } impl<'a> ClientFolders<'a> { - pub async fn encrypt(&self, folder_view: FolderView) -> Result { + pub fn encrypt(&self, folder_view: FolderView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -17,7 +17,7 @@ impl<'a> ClientFolders<'a> { Ok(folder) } - pub async fn decrypt(&self, folder: Folder) -> Result { + pub fn decrypt(&self, folder: Folder) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -26,7 +26,7 @@ impl<'a> ClientFolders<'a> { Ok(folder_view) } - pub async fn decrypt_list(&self, folders: Vec) -> Result> { + pub fn decrypt_list(&self, folders: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; diff --git a/crates/bitwarden/src/mobile/vault/client_password_history.rs b/crates/bitwarden/src/mobile/vault/client_password_history.rs index b8fe0e0c5..db0f5fa53 100644 --- a/crates/bitwarden/src/mobile/vault/client_password_history.rs +++ b/crates/bitwarden/src/mobile/vault/client_password_history.rs @@ -8,7 +8,7 @@ pub struct ClientPasswordHistory<'a> { } impl<'a> ClientPasswordHistory<'a> { - pub async fn encrypt(&self, history_view: PasswordHistoryView) -> Result { + pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -17,10 +17,7 @@ impl<'a> ClientPasswordHistory<'a> { Ok(history) } - pub async fn decrypt_list( - &self, - history: Vec, - ) -> Result> { + pub fn decrypt_list(&self, history: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden/src/tool/client_generator.rs index 16c786f9b..fe5319fc7 100644 --- a/crates/bitwarden/src/tool/client_generator.rs +++ b/crates/bitwarden/src/tool/client_generator.rs @@ -27,12 +27,12 @@ impl<'a> ClientGenerator<'a> { /// length: 20, /// ..Default::default() /// }; - /// let password = Client::new(None).generator().password(input).await.unwrap(); + /// let password = Client::new(None).generator().password(input).unwrap(); /// println!("{}", password); /// Ok(()) /// } /// ``` - pub async fn password(&self, input: PasswordGeneratorRequest) -> Result { + pub fn password(&self, input: PasswordGeneratorRequest) -> Result { Ok(password(input)?) } @@ -52,12 +52,12 @@ impl<'a> ClientGenerator<'a> { /// num_words: 4, /// ..Default::default() /// }; - /// let passphrase = Client::new(None).generator().passphrase(input).await.unwrap(); + /// let passphrase = Client::new(None).generator().passphrase(input).unwrap(); /// println!("{}", passphrase); /// Ok(()) /// } /// ``` - pub async fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { + pub fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { Ok(passphrase(input)?) } diff --git a/crates/bitwarden/src/tool/exporters/client_exporter.rs b/crates/bitwarden/src/tool/exporters/client_exporter.rs index 788ba272e..5257538cd 100644 --- a/crates/bitwarden/src/tool/exporters/client_exporter.rs +++ b/crates/bitwarden/src/tool/exporters/client_exporter.rs @@ -12,7 +12,7 @@ pub struct ClientExporters<'a> { impl<'a> ClientExporters<'a> { /// **Draft:** Export the vault as a CSV, JSON, or encrypted JSON file. - pub async fn export_vault( + pub fn export_vault( &self, folders: Vec, ciphers: Vec, @@ -21,7 +21,7 @@ impl<'a> ClientExporters<'a> { export_vault(self.client, folders, ciphers, format) } - pub async fn export_organization_vault( + pub fn export_organization_vault( &self, collections: Vec, ciphers: Vec, diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index 6674bda1e..6a1918126 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -217,30 +217,24 @@ async fn process_commands() -> Result<()> { Commands::Sync {} => todo!(), Commands::Generate { command } => match command { GeneratorCommands::Password(args) => { - let password = client - .generator() - .password(PasswordGeneratorRequest { - lowercase: args.lowercase, - uppercase: args.uppercase, - numbers: args.numbers, - special: args.special, - length: args.length, - ..Default::default() - }) - .await?; + let password = client.generator().password(PasswordGeneratorRequest { + lowercase: args.lowercase, + uppercase: args.uppercase, + numbers: args.numbers, + special: args.special, + length: args.length, + ..Default::default() + })?; println!("{}", password); } GeneratorCommands::Passphrase(args) => { - let passphrase = client - .generator() - .passphrase(PassphraseGeneratorRequest { - num_words: args.words, - word_separator: args.separator.to_string(), - capitalize: args.capitalize, - include_number: args.include_number, - }) - .await?; + let passphrase = client.generator().passphrase(PassphraseGeneratorRequest { + num_words: args.words, + word_separator: args.separator.to_string(), + capitalize: args.capitalize, + include_number: args.include_number, + })?; println!("{}", passphrase); }