Skip to content

Commit

Permalink
[PM-13166] Rename Client* to *Client (#27)
Browse files Browse the repository at this point in the history
## 🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-13166

## 📔 Objective

Use more intuitive naming by updating `Client<_>` to `<_>Client`.

## ⏰ 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
  • Loading branch information
tangowithfoxtrot authored Dec 18, 2024
1 parent fe2b4f3 commit 2c22c4f
Show file tree
Hide file tree
Showing 41 changed files with 141 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ use crate::auth::{
};
use crate::{auth::renew::renew_token, error::Result, Client};

pub struct ClientAuth<'a> {
pub struct AuthClient<'a> {
pub(crate) client: &'a crate::Client,
}

impl<'a> ClientAuth<'a> {
impl<'a> AuthClient<'a> {
pub async fn renew_token(&self) -> Result<()> {
renew_token(&self.client.internal).await
}
Expand All @@ -44,7 +44,7 @@ impl<'a> ClientAuth<'a> {
}

#[cfg(feature = "internal")]
impl<'a> ClientAuth<'a> {
impl<'a> AuthClient<'a> {
pub fn password_strength(
&self,
password: String,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<'a> ClientAuth<'a> {
}

#[cfg(feature = "internal")]
impl<'a> ClientAuth<'a> {
impl<'a> AuthClient<'a> {
pub async fn login_device(
&self,
email: String,
Expand Down Expand Up @@ -170,8 +170,8 @@ fn trust_device(client: &Client) -> Result<TrustDeviceResponse> {
}

impl<'a> Client {
pub fn auth(&'a self) -> ClientAuth<'a> {
ClientAuth { client: self }
pub fn auth(&'a self) -> AuthClient<'a> {
AuthClient { client: self }
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-core/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bitwarden_crypto::{HashPurpose, Kdf, MasterKey};

mod access_token;
pub(super) mod api;
pub mod client_auth;
pub mod auth_client;
mod jwt_token;
pub mod login;
#[cfg(feature = "internal")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use crate::{
},
};

pub struct ClientCrypto<'a> {
pub struct CryptoClient<'a> {
pub(crate) client: &'a crate::Client,
}

impl<'a> ClientCrypto<'a> {
impl<'a> CryptoClient<'a> {
pub async fn initialize_user_crypto(
&self,
req: InitUserCryptoRequest,
Expand Down Expand Up @@ -73,7 +73,7 @@ impl<'a> ClientCrypto<'a> {
}

impl<'a> Client {
pub fn crypto(&'a self) -> ClientCrypto<'a> {
ClientCrypto { client: self }
pub fn crypto(&'a self) -> CryptoClient<'a> {
CryptoClient { client: self }
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden-core/src/mobile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod crypto;
pub mod kdf;

mod client_crypto;
mod client_kdf;
mod crypto_client;

pub use client_crypto::ClientCrypto;
pub use client_kdf::ClientKdf;
pub use crypto_client::CryptoClient;
2 changes: 1 addition & 1 deletion crates/bitwarden-core/src/platform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod client_platform;
mod generate_fingerprint;
mod get_user_api_key;
pub mod platform_client;
mod secret_verification_request;

pub use generate_fingerprint::{FingerprintRequest, FingerprintResponse};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use super::{
};
use crate::{error::Result, Client};

pub struct ClientPlatform<'a> {
pub struct PlatformClient<'a> {
pub(crate) client: &'a Client,
}

impl<'a> ClientPlatform<'a> {
impl<'a> PlatformClient<'a> {
pub fn fingerprint(&self, input: &FingerprintRequest) -> Result<FingerprintResponse> {
generate_fingerprint(input)
}
Expand All @@ -27,7 +27,7 @@ impl<'a> ClientPlatform<'a> {
}

impl<'a> Client {
pub fn platform(&'a self) -> ClientPlatform<'a> {
ClientPlatform { client: self }
pub fn platform(&'a self) -> PlatformClient<'a> {
PlatformClient { client: self }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use crate::{
Account, ExportError, ExportFormat,
};

pub struct ClientExporters<'a> {
pub struct ExporterClient<'a> {
client: &'a Client,
}

impl<'a> ClientExporters<'a> {
impl<'a> ExporterClient<'a> {
fn new(client: &'a Client) -> Self {
Self { client }
}
Expand Down Expand Up @@ -58,12 +58,12 @@ impl<'a> ClientExporters<'a> {
}
}

pub trait ClientExportersExt<'a> {
fn exporters(&'a self) -> ClientExporters<'a>;
pub trait ExporterClientExt<'a> {
fn exporters(&'a self) -> ExporterClient<'a>;
}

impl<'a> ClientExportersExt<'a> for Client {
fn exporters(&'a self) -> ClientExporters<'a> {
ClientExporters::new(self)
impl<'a> ExporterClientExt<'a> for Client {
fn exporters(&'a self) -> ExporterClient<'a> {
ExporterClient::new(self)
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden-exporters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ uniffi::setup_scaffolding!();
#[cfg(feature = "uniffi")]
mod uniffi_support;

mod client_exporter;
mod csv;
mod cxp;
pub use cxp::Account;
mod encrypted_json;
mod exporter_client;
mod json;
mod models;
pub use client_exporter::{ClientExporters, ClientExportersExt};
pub use exporter_client::{ExporterClient, ExporterClientExt};
mod error;
mod export;
pub use error::ExportError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use crate::{
UsernameGeneratorRequest,
};

pub struct ClientGenerator<'a> {
pub struct GeneratorClient<'a> {
client: &'a Client,
}

impl<'a> ClientGenerator<'a> {
impl<'a> GeneratorClient<'a> {
fn new(client: &'a Client) -> Self {
Self { client }
}
Expand All @@ -23,7 +23,7 @@ impl<'a> ClientGenerator<'a> {
///
/// ```
/// use bitwarden_core::Client;
/// use bitwarden_generators::{ClientGeneratorExt, PassphraseError, PasswordGeneratorRequest};
/// use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
///
/// async fn test() -> Result<(), PassphraseError> {
/// let input = PasswordGeneratorRequest {
Expand Down Expand Up @@ -53,7 +53,7 @@ impl<'a> ClientGenerator<'a> {
///
/// ```
/// use bitwarden_core::Client;
/// use bitwarden_generators::{ClientGeneratorExt, PassphraseError, PassphraseGeneratorRequest};
/// use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
///
/// async fn test() -> Result<(), PassphraseError> {
/// let input = PassphraseGeneratorRequest {
Expand All @@ -78,7 +78,7 @@ impl<'a> ClientGenerator<'a> {
///
/// ```
/// use bitwarden_core::Client;
/// use bitwarden_generators::{ClientGeneratorExt, UsernameError, UsernameGeneratorRequest};
/// use bitwarden_generators::{GeneratorClientsExt, UsernameError, UsernameGeneratorRequest};
///
/// async fn test() -> Result<(), UsernameError> {
/// let input = UsernameGeneratorRequest::Word {
Expand All @@ -95,12 +95,12 @@ impl<'a> ClientGenerator<'a> {
}
}

pub trait ClientGeneratorExt<'a> {
fn generator(&'a self) -> ClientGenerator<'a>;
pub trait GeneratorClientsExt<'a> {
fn generator(&'a self) -> GeneratorClient<'a>;
}

impl<'a> ClientGeneratorExt<'a> for Client {
fn generator(&'a self) -> ClientGenerator<'a> {
ClientGenerator::new(self)
impl<'a> GeneratorClientsExt<'a> for Client {
fn generator(&'a self) -> GeneratorClient<'a> {
GeneratorClient::new(self)
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden-generators/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod client_generator;
mod generator_client;
mod username_forwarders;
pub use client_generator::{ClientGenerator, ClientGeneratorExt};
pub use generator_client::{GeneratorClient, GeneratorClientsExt};
pub(crate) mod passphrase;
pub use passphrase::{PassphraseError, PassphraseGeneratorRequest};
pub(crate) mod password;
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden-send/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod uniffi_support;

mod error;
pub use error::SendParseError;
mod client_sends;
pub use client_sends::{ClientSends, ClientSendsExt};
mod send_client;
pub use send_client::{SendClient, SendClientExt};
mod send;
pub use send::{Send, SendListView, SendView};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable};

use crate::{Send, SendListView, SendView};

pub struct ClientSends<'a> {
pub struct SendClient<'a> {
client: &'a Client,
}

impl<'a> ClientSends<'a> {
impl<'a> SendClient<'a> {
fn new(client: &'a Client) -> Self {
Self { client }
}
Expand Down Expand Up @@ -84,12 +84,12 @@ impl<'a> ClientSends<'a> {
}
}

pub trait ClientSendsExt<'a> {
fn sends(&'a self) -> ClientSends<'a>;
pub trait SendClientExt<'a> {
fn sends(&'a self) -> SendClient<'a>;
}

impl<'a> ClientSendsExt<'a> for Client {
fn sends(&'a self) -> ClientSends<'a> {
ClientSends::new(self)
impl<'a> SendClientExt<'a> for Client {
fn sends(&'a self) -> SendClient<'a> {
SendClient::new(self)
}
}
6 changes: 3 additions & 3 deletions crates/bitwarden-uniffi/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use bitwarden_crypto::{AsymmetricEncString, EncString, HashPurpose, Kdf, TrustDe
use crate::{error::Result, Client};

#[derive(uniffi::Object)]
pub struct ClientAuth(pub(crate) Arc<Client>);
pub struct AuthClient(pub(crate) Arc<Client>);

#[uniffi::export(async_runtime = "tokio")]
impl ClientAuth {
impl AuthClient {
/// **API Draft:** Calculate Password Strength
pub fn password_strength(
&self,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl ClientAuth {

/// Validate the user password
///
/// To retrieve the user's password hash, use [`ClientAuth::hash_password`] with
/// To retrieve the user's password hash, use [`AuthClient::hash_password`] with
/// `HashPurpose::LocalAuthentication` during login and persist it. If the login method has no
/// password, use the email OTP.
pub fn validate_password(&self, password: String, password_hash: String) -> Result<bool> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden-uniffi/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use bitwarden_crypto::{AsymmetricEncString, EncString};
use crate::{error::Result, Client};

#[derive(uniffi::Object)]
pub struct ClientCrypto(pub(crate) Arc<Client>);
pub struct CryptoClient(pub(crate) Arc<Client>);

#[uniffi::export(async_runtime = "tokio")]
impl ClientCrypto {
impl CryptoClient {
/// Initialization method for the user crypto. Needs to be called before any other crypto
/// operations.
pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> {
Expand Down
38 changes: 19 additions & 19 deletions crates/bitwarden-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uniffi::setup_scaffolding!();

use std::sync::Arc;

use auth::ClientAuth;
use auth::AuthClient;
use bitwarden_core::ClientSettings;

pub mod auth;
Expand All @@ -16,11 +16,11 @@ pub mod vault;
#[cfg(target_os = "android")]
mod android_support;

use crypto::ClientCrypto;
use crypto::CryptoClient;
use error::Result;
use platform::ClientPlatform;
use tool::{ClientExporters, ClientGenerators, ClientSends};
use vault::ClientVault;
use platform::PlatformClient;
use tool::{ExporterClient, GeneratorClients, SendClient};
use vault::VaultClient;

#[derive(uniffi::Object)]
pub struct Client(bitwarden_core::Client);
Expand All @@ -39,37 +39,37 @@ impl Client {
}

/// Crypto operations
pub fn crypto(self: Arc<Self>) -> Arc<ClientCrypto> {
Arc::new(ClientCrypto(self))
pub fn crypto(self: Arc<Self>) -> Arc<CryptoClient> {
Arc::new(CryptoClient(self))
}

/// Vault item operations
pub fn vault(self: Arc<Self>) -> Arc<ClientVault> {
Arc::new(ClientVault(self))
pub fn vault(self: Arc<Self>) -> Arc<VaultClient> {
Arc::new(VaultClient(self))
}

pub fn platform(self: Arc<Self>) -> Arc<ClientPlatform> {
Arc::new(ClientPlatform(self))
pub fn platform(self: Arc<Self>) -> Arc<PlatformClient> {
Arc::new(PlatformClient(self))
}

/// Generator operations
pub fn generators(self: Arc<Self>) -> Arc<ClientGenerators> {
Arc::new(ClientGenerators(self))
pub fn generators(self: Arc<Self>) -> Arc<GeneratorClients> {
Arc::new(GeneratorClients(self))
}

/// Exporters
pub fn exporters(self: Arc<Self>) -> Arc<ClientExporters> {
Arc::new(ClientExporters(self))
pub fn exporters(self: Arc<Self>) -> Arc<ExporterClient> {
Arc::new(ExporterClient(self))
}

/// Sends operations
pub fn sends(self: Arc<Self>) -> Arc<ClientSends> {
Arc::new(ClientSends(self))
pub fn sends(self: Arc<Self>) -> Arc<SendClient> {
Arc::new(SendClient(self))
}

/// Auth operations
pub fn auth(self: Arc<Self>) -> Arc<ClientAuth> {
Arc::new(ClientAuth(self))
pub fn auth(self: Arc<Self>) -> Arc<AuthClient> {
Arc::new(AuthClient(self))
}

/// Test method, echoes back the input
Expand Down
Loading

0 comments on commit 2c22c4f

Please sign in to comment.