Skip to content
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

[PM-13166] Rename Client* to *Client #27

Merged
merged 9 commits into from
Dec 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
};
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 @@
}

#[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 @@
}

#[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 @@
}

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

Check warning on line 174 in crates/bitwarden-core/src/auth/auth_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-core/src/auth/auth_client.rs#L173-L174

Added lines #L173 - L174 were not covered by tests
}
}

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 @@ -13,11 +13,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 @@ -59,7 +59,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 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> Client {
pub fn platform(&'a self) -> ClientPlatform<'a> {
ClientPlatform { client: self }
pub fn platform(&'a self) -> PlatformClient<'a> {
PlatformClient { client: self }

Check warning on line 31 in crates/bitwarden-core/src/platform/platform_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-core/src/platform/platform_client.rs#L30-L31

Added lines #L30 - L31 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
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 All @@ -34,12 +34,12 @@
}
}

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)

Check warning on line 43 in crates/bitwarden-exporters/src/exporter_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-exporters/src/exporter_client.rs#L42-L43

Added lines #L42 - L43 were not covered by tests
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden-exporters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use uuid::Uuid;
#[cfg(feature = "uniffi")]
uniffi::setup_scaffolding!();

mod client_exporter;
mod csv;
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 @@
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 @@
///
/// ```
/// 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 @@
///
/// ```
/// 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 @@
///
/// ```
/// 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 @@
}
}

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)

Check warning on line 104 in crates/bitwarden-generators/src/generator_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-generators/src/generator_client.rs#L103-L104

Added lines #L103 - L104 were not covered by tests
}
}
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 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 @@
}
}

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)

Check warning on line 93 in crates/bitwarden-send/src/send_client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-send/src/send_client.rs#L92-L93

Added lines #L92 - L93 were not covered by tests
}
}
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 @@

use std::sync::Arc;

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

pub mod auth;
Expand All @@ -16,11 +16,11 @@
#[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 @@
}

/// 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))

Check warning on line 43 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L42-L43

Added lines #L42 - L43 were not covered by tests
}

/// 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))

Check warning on line 48 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L47-L48

Added lines #L47 - L48 were not covered by tests
}

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

Check warning on line 52 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L51-L52

Added lines #L51 - L52 were not covered by tests
}

/// 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))

Check warning on line 57 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L56-L57

Added lines #L56 - L57 were not covered by tests
}

/// 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))

Check warning on line 62 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L61-L62

Added lines #L61 - L62 were not covered by tests
}

/// 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))

Check warning on line 67 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L66-L67

Added lines #L66 - L67 were not covered by tests
}

/// 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))

Check warning on line 72 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L71-L72

Added lines #L71 - L72 were not covered by tests
}

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