Skip to content

Move vault impl to a single file #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions crates/bitwarden-vault/src/cipher/attachment_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use thiserror::Error;

use crate::{
Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView,
Cipher, DecryptError, EncryptError, VaultClient,
Cipher, DecryptError, EncryptError,
};

pub struct AttachmentsClient {
Expand Down Expand Up @@ -92,11 +92,3 @@ impl AttachmentsClient {
Ok(())
}
}

impl VaultClient {
pub fn attachments(&self) -> AttachmentsClient {
AttachmentsClient {
client: self.client.clone(),
}
}
}
12 changes: 1 addition & 11 deletions crates/bitwarden-vault/src/cipher/cipher_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use bitwarden_crypto::IdentifyKey;
use wasm_bindgen::prelude::*;

use super::EncryptionContext;
use crate::{
Cipher, CipherError, CipherListView, CipherView, DecryptError, EncryptError, VaultClient,
};
use crate::{Cipher, CipherError, CipherListView, CipherView, DecryptError, EncryptError};

#[cfg_attr(feature = "wasm", wasm_bindgen)]
pub struct CiphersClient {
Expand Down Expand Up @@ -85,14 +83,6 @@ impl CiphersClient {
}
}

impl VaultClient {
pub fn ciphers(&self) -> CiphersClient {
CiphersClient {
client: self.client.clone(),
}
}
}

#[cfg(test)]
mod tests {

Expand Down
10 changes: 1 addition & 9 deletions crates/bitwarden-vault/src/collection_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitwarden_core::Client;

use crate::{error::DecryptError, Collection, CollectionView, VaultClient};
use crate::{error::DecryptError, Collection, CollectionView};

pub struct CollectionsClient {
pub(crate) client: Client,
Expand All @@ -23,14 +23,6 @@ impl CollectionsClient {
}
}

impl VaultClient {
pub fn collections(&self) -> CollectionsClient {
CollectionsClient {
client: self.client.clone(),
}
}
}

#[cfg(test)]
mod tests {
use bitwarden_core::client::test_accounts::test_bitwarden_com_account;
Expand Down
10 changes: 1 addition & 9 deletions crates/bitwarden-vault/src/folder_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use wasm_bindgen::prelude::*;

use crate::{
error::{DecryptError, EncryptError},
Folder, FolderView, VaultClient,
Folder, FolderView,
};

#[cfg_attr(feature = "wasm", wasm_bindgen)]
Expand Down Expand Up @@ -32,11 +32,3 @@ impl FoldersClient {
Ok(views)
}
}

impl VaultClient {
pub fn folders(&self) -> FoldersClient {
FoldersClient {
client: self.client.clone(),
}
}
}
10 changes: 1 addition & 9 deletions crates/bitwarden-vault/src/password_history_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitwarden_core::Client;

use crate::{DecryptError, EncryptError, PasswordHistory, PasswordHistoryView, VaultClient};
use crate::{DecryptError, EncryptError, PasswordHistory, PasswordHistoryView};

pub struct PasswordHistoryClient {
pub(crate) client: Client,
Expand All @@ -25,11 +25,3 @@ impl PasswordHistoryClient {
Ok(history_view)
}
}

impl VaultClient {
pub fn password_history(&self) -> PasswordHistoryClient {
PasswordHistoryClient {
client: self.client.clone(),
}
}
}
36 changes: 36 additions & 0 deletions crates/bitwarden-vault/src/vault_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::{
sync::{sync, SyncError},
AttachmentsClient, CiphersClient, CollectionsClient, FoldersClient, PasswordHistoryClient,
SyncRequest, SyncResponse,
};

Expand All @@ -15,6 +16,41 @@
Self { client }
}

/// Attachment related operations.
pub fn attachments(&self) -> AttachmentsClient {
AttachmentsClient {
client: self.client.clone(),
}
}

/// Cipher related operations.
pub fn ciphers(&self) -> CiphersClient {
CiphersClient {
client: self.client.clone(),
}
}

/// Collection related operations.
pub fn collections(&self) -> CollectionsClient {
CollectionsClient {
client: self.client.clone(),
}
}

/// Folder related operations.
pub fn folders(&self) -> FoldersClient {
FoldersClient {
client: self.client.clone(),
}
}

Check warning on line 45 in crates/bitwarden-vault/src/vault_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-vault/src/vault_client.rs#L41-L45

Added lines #L41 - L45 were not covered by tests

/// Password history related operations.
pub fn password_history(&self) -> PasswordHistoryClient {
PasswordHistoryClient {
client: self.client.clone(),
}
}

Check warning on line 52 in crates/bitwarden-vault/src/vault_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-vault/src/vault_client.rs#L48-L52

Added lines #L48 - L52 were not covered by tests

pub async fn sync(&self, input: &SyncRequest) -> Result<SyncResponse, SyncError> {
sync(&self.client, input).await
}
Expand Down