Skip to content

Commit 3d2e4b5

Browse files
authored
Move vault impl to a single file (#295)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> Per request in #294 we want to avoid having multiple impl of VaultClient. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent 5ba7b3e commit 3d2e4b5

File tree

6 files changed

+41
-47
lines changed

6 files changed

+41
-47
lines changed

crates/bitwarden-vault/src/cipher/attachment_client.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use thiserror::Error;
77

88
use crate::{
99
Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView,
10-
Cipher, DecryptError, EncryptError, VaultClient,
10+
Cipher, DecryptError, EncryptError,
1111
};
1212

1313
pub struct AttachmentsClient {
@@ -92,11 +92,3 @@ impl AttachmentsClient {
9292
Ok(())
9393
}
9494
}
95-
96-
impl VaultClient {
97-
pub fn attachments(&self) -> AttachmentsClient {
98-
AttachmentsClient {
99-
client: self.client.clone(),
100-
}
101-
}
102-
}

crates/bitwarden-vault/src/cipher/cipher_client.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use bitwarden_crypto::IdentifyKey;
44
use wasm_bindgen::prelude::*;
55

66
use super::EncryptionContext;
7-
use crate::{
8-
Cipher, CipherError, CipherListView, CipherView, DecryptError, EncryptError, VaultClient,
9-
};
7+
use crate::{Cipher, CipherError, CipherListView, CipherView, DecryptError, EncryptError};
108

119
#[cfg_attr(feature = "wasm", wasm_bindgen)]
1210
pub struct CiphersClient {
@@ -85,14 +83,6 @@ impl CiphersClient {
8583
}
8684
}
8785

88-
impl VaultClient {
89-
pub fn ciphers(&self) -> CiphersClient {
90-
CiphersClient {
91-
client: self.client.clone(),
92-
}
93-
}
94-
}
95-
9686
#[cfg(test)]
9787
mod tests {
9888

crates/bitwarden-vault/src/collection_client.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bitwarden_core::Client;
22

3-
use crate::{error::DecryptError, Collection, CollectionView, VaultClient};
3+
use crate::{error::DecryptError, Collection, CollectionView};
44

55
pub struct CollectionsClient {
66
pub(crate) client: Client,
@@ -23,14 +23,6 @@ impl CollectionsClient {
2323
}
2424
}
2525

26-
impl VaultClient {
27-
pub fn collections(&self) -> CollectionsClient {
28-
CollectionsClient {
29-
client: self.client.clone(),
30-
}
31-
}
32-
}
33-
3426
#[cfg(test)]
3527
mod tests {
3628
use bitwarden_core::client::test_accounts::test_bitwarden_com_account;

crates/bitwarden-vault/src/folder_client.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use wasm_bindgen::prelude::*;
44

55
use crate::{
66
error::{DecryptError, EncryptError},
7-
Folder, FolderView, VaultClient,
7+
Folder, FolderView,
88
};
99

1010
#[cfg_attr(feature = "wasm", wasm_bindgen)]
@@ -32,11 +32,3 @@ impl FoldersClient {
3232
Ok(views)
3333
}
3434
}
35-
36-
impl VaultClient {
37-
pub fn folders(&self) -> FoldersClient {
38-
FoldersClient {
39-
client: self.client.clone(),
40-
}
41-
}
42-
}

crates/bitwarden-vault/src/password_history_client.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bitwarden_core::Client;
22

3-
use crate::{DecryptError, EncryptError, PasswordHistory, PasswordHistoryView, VaultClient};
3+
use crate::{DecryptError, EncryptError, PasswordHistory, PasswordHistoryView};
44

55
pub struct PasswordHistoryClient {
66
pub(crate) client: Client,
@@ -25,11 +25,3 @@ impl PasswordHistoryClient {
2525
Ok(history_view)
2626
}
2727
}
28-
29-
impl VaultClient {
30-
pub fn password_history(&self) -> PasswordHistoryClient {
31-
PasswordHistoryClient {
32-
client: self.client.clone(),
33-
}
34-
}
35-
}

crates/bitwarden-vault/src/vault_client.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use bitwarden_core::Client;
22

33
use crate::{
44
sync::{sync, SyncError},
5+
AttachmentsClient, CiphersClient, CollectionsClient, FoldersClient, PasswordHistoryClient,
56
SyncRequest, SyncResponse,
67
};
78

@@ -15,6 +16,41 @@ impl VaultClient {
1516
Self { client }
1617
}
1718

19+
/// Attachment related operations.
20+
pub fn attachments(&self) -> AttachmentsClient {
21+
AttachmentsClient {
22+
client: self.client.clone(),
23+
}
24+
}
25+
26+
/// Cipher related operations.
27+
pub fn ciphers(&self) -> CiphersClient {
28+
CiphersClient {
29+
client: self.client.clone(),
30+
}
31+
}
32+
33+
/// Collection related operations.
34+
pub fn collections(&self) -> CollectionsClient {
35+
CollectionsClient {
36+
client: self.client.clone(),
37+
}
38+
}
39+
40+
/// Folder related operations.
41+
pub fn folders(&self) -> FoldersClient {
42+
FoldersClient {
43+
client: self.client.clone(),
44+
}
45+
}
46+
47+
/// Password history related operations.
48+
pub fn password_history(&self) -> PasswordHistoryClient {
49+
PasswordHistoryClient {
50+
client: self.client.clone(),
51+
}
52+
}
53+
1854
pub async fn sync(&self, input: &SyncRequest) -> Result<SyncResponse, SyncError> {
1955
sync(&self.client, input).await
2056
}

0 commit comments

Comments
 (0)