Skip to content

Commit 8014451

Browse files
authored
Rename all clients to follow Domain Client (#224)
Renames all clients except for Fido2Client since it has an internal conflict. SM clients and traits have aliases to maintain backwards compatibility.
1 parent 9e581da commit 8014451

File tree

24 files changed

+114
-86
lines changed

24 files changed

+114
-86
lines changed

bitwarden_license/bitwarden-sm/src/client_projects.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ use crate::{
99
},
1010
};
1111

12-
pub struct ClientProjects {
12+
/// Aliases to maintain backward compatibility
13+
pub type ClientProjects = ProjectsClient;
14+
15+
pub struct ProjectsClient {
1316
pub client: Client,
1417
}
1518

16-
impl ClientProjects {
19+
impl ProjectsClient {
1720
pub fn new(client: Client) -> Self {
1821
Self { client }
1922
}
@@ -54,12 +57,23 @@ impl ClientProjects {
5457
}
5558
}
5659

60+
/// This trait is for backward compatibility
5761
pub trait ClientProjectsExt {
5862
fn projects(&self) -> ClientProjects;
5963
}
6064

6165
impl ClientProjectsExt for Client {
6266
fn projects(&self) -> ClientProjects {
63-
ClientProjects::new(self.clone())
67+
ProjectsClient::new(self.clone())
68+
}
69+
}
70+
71+
pub trait ProjectsClientExt {
72+
fn projects(&self) -> ProjectsClient;
73+
}
74+
75+
impl ProjectsClientExt for Client {
76+
fn projects(&self) -> ProjectsClient {
77+
ProjectsClient::new(self.clone())
6478
}
6579
}

bitwarden_license/bitwarden-sm/src/client_secrets.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ use crate::{
1212
},
1313
};
1414

15-
pub struct ClientSecrets {
15+
/// Aliases to maintain backward compatibility
16+
pub type ClientSecrets = SecretsClient;
17+
18+
pub struct SecretsClient {
1619
client: Client,
1720
}
1821

19-
impl ClientSecrets {
22+
impl SecretsClient {
2023
pub fn new(client: Client) -> Self {
2124
Self { client }
2225
}
@@ -78,12 +81,23 @@ impl ClientSecrets {
7881
}
7982
}
8083

84+
/// This trait is for backward compatibility
8185
pub trait ClientSecretsExt {
8286
fn secrets(&self) -> ClientSecrets;
8387
}
8488

8589
impl ClientSecretsExt for Client {
8690
fn secrets(&self) -> ClientSecrets {
87-
ClientSecrets::new(self.clone())
91+
SecretsClient::new(self.clone())
92+
}
93+
}
94+
95+
pub trait SecretsClientExt {
96+
fn secrets(&self) -> SecretsClient;
97+
}
98+
99+
impl SecretsClientExt for Client {
100+
fn secrets(&self) -> SecretsClient {
101+
SecretsClient::new(self.clone())
88102
}
89103
}

bitwarden_license/bitwarden-sm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ mod error;
44
pub mod projects;
55
pub mod secrets;
66

7-
pub use client_projects::{ClientProjects, ClientProjectsExt};
8-
pub use client_secrets::{ClientSecrets, ClientSecretsExt};
7+
pub use client_projects::{ClientProjects, ClientProjectsExt, ProjectsClient, ProjectsClientExt};
8+
pub use client_secrets::{ClientSecrets, ClientSecretsExt, SecretsClient, SecretsClientExt};

crates/bitwarden-core/src/mobile/client_kdf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use bitwarden_crypto::{CryptoError, HashPurpose, Kdf};
33
use crate::{mobile::kdf::hash_password, Client};
44

55
/// A client for the KDF operations.
6-
pub struct ClientKdf {
6+
pub struct KdfClient {
77
pub(crate) _client: crate::Client,
88
}
99

10-
impl ClientKdf {
10+
impl KdfClient {
1111
/// Hashes the password using the provided KDF parameters and purpose.
1212
pub async fn hash_password(
1313
&self,
@@ -22,8 +22,8 @@ impl ClientKdf {
2222

2323
impl Client {
2424
/// Access to KDF functionality.
25-
pub fn kdf(&self) -> ClientKdf {
26-
ClientKdf {
25+
pub fn kdf(&self) -> KdfClient {
26+
KdfClient {
2727
_client: self.clone(),
2828
}
2929
}

crates/bitwarden-core/src/mobile/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ mod kdf;
99
mod client_kdf;
1010
mod crypto_client;
1111

12-
pub use client_kdf::ClientKdf;
12+
pub use client_kdf::KdfClient;
1313
pub use crypto_client::CryptoClient;

crates/bitwarden-uniffi/src/vault/attachments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use bitwarden_vault::{Attachment, AttachmentEncryptResult, AttachmentView, Ciphe
55
use crate::{error::Error, Result};
66

77
#[derive(uniffi::Object)]
8-
pub struct ClientAttachments(pub(crate) bitwarden_vault::ClientAttachments);
8+
pub struct AttachmentsClient(pub(crate) bitwarden_vault::AttachmentsClient);
99

1010
#[uniffi::export]
11-
impl ClientAttachments {
11+
impl AttachmentsClient {
1212
/// Encrypt an attachment file in memory
1313
pub fn encrypt_buffer(
1414
&self,

crates/bitwarden-uniffi/src/vault/ciphers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use uuid::Uuid;
44
use crate::{error::Error, Result};
55

66
#[derive(uniffi::Object)]
7-
pub struct ClientCiphers(pub(crate) bitwarden_vault::ClientCiphers);
7+
pub struct CiphersClient(pub(crate) bitwarden_vault::CiphersClient);
88

99
#[uniffi::export]
10-
impl ClientCiphers {
10+
impl CiphersClient {
1111
/// Encrypt cipher
1212
pub fn encrypt(&self, cipher_view: CipherView) -> Result<Cipher> {
1313
Ok(self.0.encrypt(cipher_view).map_err(Error::Encrypt)?)

crates/bitwarden-uniffi/src/vault/collections.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use bitwarden_vault::{Collection, CollectionView};
33
use crate::{error::Error, Result};
44

55
#[derive(uniffi::Object)]
6-
pub struct ClientCollections(pub(crate) bitwarden_vault::ClientCollections);
6+
pub struct CollectionsClient(pub(crate) bitwarden_vault::CollectionsClient);
77

88
#[uniffi::export]
9-
impl ClientCollections {
9+
impl CollectionsClient {
1010
/// Decrypt collection
1111
pub fn decrypt(&self, collection: Collection) -> Result<CollectionView> {
1212
Ok(self.0.decrypt(collection).map_err(Error::Decrypt)?)

crates/bitwarden-uniffi/src/vault/folders.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use bitwarden_vault::{Folder, FolderView};
33
use crate::{error::Error, Result};
44

55
#[derive(uniffi::Object)]
6-
pub struct ClientFolders(pub(crate) bitwarden_vault::ClientFolders);
6+
pub struct FoldersClient(pub(crate) bitwarden_vault::FoldersClient);
77

88
#[uniffi::export]
9-
impl ClientFolders {
9+
impl FoldersClient {
1010
/// Encrypt folder
1111
pub fn encrypt(&self, folder: FolderView) -> Result<Folder> {
1212
Ok(self.0.encrypt(folder).map_err(Error::Encrypt)?)

crates/bitwarden-uniffi/src/vault/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ pub struct VaultClient(pub(crate) bitwarden_vault::VaultClient);
1515
#[uniffi::export]
1616
impl VaultClient {
1717
/// Folder operations
18-
pub fn folders(&self) -> folders::ClientFolders {
19-
folders::ClientFolders(self.0.folders())
18+
pub fn folders(&self) -> folders::FoldersClient {
19+
folders::FoldersClient(self.0.folders())
2020
}
2121

2222
/// Collections operations
23-
pub fn collections(&self) -> collections::ClientCollections {
24-
collections::ClientCollections(self.0.collections())
23+
pub fn collections(&self) -> collections::CollectionsClient {
24+
collections::CollectionsClient(self.0.collections())
2525
}
2626

2727
/// Ciphers operations
28-
pub fn ciphers(&self) -> ciphers::ClientCiphers {
29-
ciphers::ClientCiphers(self.0.ciphers())
28+
pub fn ciphers(&self) -> ciphers::CiphersClient {
29+
ciphers::CiphersClient(self.0.ciphers())
3030
}
3131

3232
/// Password history operations
33-
pub fn password_history(&self) -> password_history::ClientPasswordHistory {
34-
password_history::ClientPasswordHistory(self.0.password_history())
33+
pub fn password_history(&self) -> password_history::PasswordHistoryClient {
34+
password_history::PasswordHistoryClient(self.0.password_history())
3535
}
3636

3737
/// Attachment file operations
38-
pub fn attachments(&self) -> attachments::ClientAttachments {
39-
attachments::ClientAttachments(self.0.attachments())
38+
pub fn attachments(&self) -> attachments::AttachmentsClient {
39+
attachments::AttachmentsClient(self.0.attachments())
4040
}
4141

4242
/// Generate a TOTP code from a provided key.

0 commit comments

Comments
 (0)