diff --git a/.github/workflows/check-powerset.yml b/.github/workflows/check-powerset.yml new file mode 100644 index 00000000..e8901cb6 --- /dev/null +++ b/.github/workflows/check-powerset.yml @@ -0,0 +1,41 @@ +name: Check Rust feature-powerset + +on: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Building for ${{ matrix.os }} + + runs-on: ${{ matrix.os || 'ubuntu-24.04' }} + + strategy: + fail-fast: false + matrix: + os: + - macos-14 + - ubuntu-24.04 + - windows-2022 + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install rust + uses: dtolnay/rust-toolchain@315e265cd78dad1e1dcf3a5074f6d6c47029d5aa # stable + with: + toolchain: stable + + - name: Cache cargo registry + uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 + + - name: Install cargo-hack + run: cargo install cargo-hack --version 0.6.33 --locked + + - name: Build + run: cargo hack check --workspace --feature-powerset --no-dev-deps + env: + RUSTFLAGS: "-D warnings" diff --git a/Cargo.lock b/Cargo.lock index 8b51c85b..7f03988d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,7 @@ dependencies = [ "rand", "rand_chacha", "reqwest", + "rustls", "rustls-platform-verifier", "schemars", "serde", @@ -2305,7 +2306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -3203,9 +3204,9 @@ dependencies = [ [[package]] name = "rustls-platform-verifier" -version = "0.3.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" +checksum = "a4c7dc240fec5517e6c4eab3310438636cfe6391dfc345ba013109909a90d136" dependencies = [ "core-foundation", "core-foundation-sys", @@ -3218,8 +3219,8 @@ dependencies = [ "rustls-webpki", "security-framework", "security-framework-sys", - "webpki-roots", - "winapi", + "webpki-root-certs", + "windows-sys 0.52.0", ] [[package]] @@ -4579,10 +4580,10 @@ dependencies = [ ] [[package]] -name = "webpki-roots" +name = "webpki-root-certs" version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +checksum = "9cd5da49bdf1f30054cfe0b8ce2958b8fbeb67c4d82c8967a598af481bef255c" dependencies = [ "rustls-pki-types", ] diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 8f6338ad..e4e629c8 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -59,7 +59,8 @@ zxcvbn = { version = ">=3.0.1, <4.0", optional = true } # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates # The only exception is WASM, as it just uses the browsers/node fetch reqwest = { workspace = true, features = ["rustls-tls-manual-roots"] } -rustls-platform-verifier = "0.3.4" +rustls = { version = "0.23.19", default-features = false } +rustls-platform-verifier = "0.4.0" [dev-dependencies] bitwarden-crypto = { workspace = true } diff --git a/crates/bitwarden-core/src/auth/client_auth.rs b/crates/bitwarden-core/src/auth/auth_client.rs similarity index 98% rename from crates/bitwarden-core/src/auth/client_auth.rs rename to crates/bitwarden-core/src/auth/auth_client.rs index 82986855..d31737df 100644 --- a/crates/bitwarden-core/src/auth/client_auth.rs +++ b/crates/bitwarden-core/src/auth/auth_client.rs @@ -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 } @@ -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, @@ -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, @@ -170,8 +170,8 @@ fn trust_device(client: &Client) -> Result { } impl<'a> Client { - pub fn auth(&'a self) -> ClientAuth<'a> { - ClientAuth { client: self } + pub fn auth(&'a self) -> AuthClient<'a> { + AuthClient { client: self } } } diff --git a/crates/bitwarden-core/src/auth/mod.rs b/crates/bitwarden-core/src/auth/mod.rs index 30babdc7..82d57c41 100644 --- a/crates/bitwarden-core/src/auth/mod.rs +++ b/crates/bitwarden-core/src/auth/mod.rs @@ -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")] diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs index b9bf4c51..8b8182cd 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -27,8 +27,10 @@ impl Client { #[cfg(not(target_arch = "wasm32"))] { + use rustls::ClientConfig; + use rustls_platform_verifier::ConfigVerifierExt; client_builder = - client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); + client_builder.use_preconfigured_tls(ClientConfig::with_platform_verifier()); } client_builder @@ -83,24 +85,3 @@ impl Client { } } } - -#[cfg(test)] -mod tests { - #[cfg(not(target_arch = "wasm32"))] - #[test] - fn test_reqwest_rustls_platform_verifier_are_compatible() { - // rustls-platform-verifier is generating a rustls::ClientConfig, - // which reqwest accepts as a &dyn Any and then downcasts it to a - // rustls::ClientConfig. - - // This means that if the rustls version of the two crates don't match, - // the downcast will fail and we will get a runtime error. - - // This tests is added to ensure that it doesn't happen. - - let _ = reqwest::ClientBuilder::new() - .use_preconfigured_tls(rustls_platform_verifier::tls_config()) - .build() - .unwrap(); - } -} diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs index c627f374..a4e782db 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -10,7 +10,6 @@ use reqwest::StatusCode; use thiserror::Error; use validator::ValidationErrors; -#[cfg(feature = "internal")] use crate::client::encryption_settings::EncryptionSettingsError; #[bitwarden_error(flat, export_as = "CoreError")] @@ -62,7 +61,6 @@ pub enum Error { #[error("Internal error: {0}")] Internal(Cow<'static, str>), - #[cfg(feature = "internal")] #[error(transparent)] EncryptionSettings(#[from] EncryptionSettingsError), } diff --git a/crates/bitwarden-core/src/mobile/client_crypto.rs b/crates/bitwarden-core/src/mobile/crypto_client.rs similarity index 94% rename from crates/bitwarden-core/src/mobile/client_crypto.rs rename to crates/bitwarden-core/src/mobile/crypto_client.rs index f4ac3cd6..dd3e48c9 100644 --- a/crates/bitwarden-core/src/mobile/client_crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto_client.rs @@ -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, @@ -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 } } } diff --git a/crates/bitwarden-core/src/mobile/mod.rs b/crates/bitwarden-core/src/mobile/mod.rs index 7c6a916a..7a7c06a7 100644 --- a/crates/bitwarden-core/src/mobile/mod.rs +++ b/crates/bitwarden-core/src/mobile/mod.rs @@ -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; diff --git a/crates/bitwarden-core/src/platform/mod.rs b/crates/bitwarden-core/src/platform/mod.rs index 031554be..765ca2dc 100644 --- a/crates/bitwarden-core/src/platform/mod.rs +++ b/crates/bitwarden-core/src/platform/mod.rs @@ -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}; diff --git a/crates/bitwarden-core/src/platform/client_platform.rs b/crates/bitwarden-core/src/platform/platform_client.rs similarity index 83% rename from crates/bitwarden-core/src/platform/client_platform.rs rename to crates/bitwarden-core/src/platform/platform_client.rs index 1f117d5f..7c362291 100644 --- a/crates/bitwarden-core/src/platform/client_platform.rs +++ b/crates/bitwarden-core/src/platform/platform_client.rs @@ -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 { generate_fingerprint(input) } @@ -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 } } } diff --git a/crates/bitwarden-error-macro/Cargo.toml b/crates/bitwarden-error-macro/Cargo.toml index c458ee1b..77dbd6fa 100644 --- a/crates/bitwarden-error-macro/Cargo.toml +++ b/crates/bitwarden-error-macro/Cargo.toml @@ -10,7 +10,7 @@ license-file.workspace = true keywords.workspace = true [features] -wasm = ["bitwarden-error/wasm"] +wasm = [] [dependencies] darling = "0.20.10" @@ -25,7 +25,7 @@ workspace = true proc-macro = true [dev-dependencies] -bitwarden-error.workspace = true +bitwarden-error = { workspace = true, features = ["wasm"] } js-sys.workspace = true serde.workspace = true thiserror.workspace = true diff --git a/crates/bitwarden-exporters/src/client_exporter.rs b/crates/bitwarden-exporters/src/exporter_client.rs similarity index 88% rename from crates/bitwarden-exporters/src/client_exporter.rs rename to crates/bitwarden-exporters/src/exporter_client.rs index 345b62fe..14a676e6 100644 --- a/crates/bitwarden-exporters/src/client_exporter.rs +++ b/crates/bitwarden-exporters/src/exporter_client.rs @@ -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 } } @@ -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) } } diff --git a/crates/bitwarden-exporters/src/lib.rs b/crates/bitwarden-exporters/src/lib.rs index 302ee9d8..df78d881 100644 --- a/crates/bitwarden-exporters/src/lib.rs +++ b/crates/bitwarden-exporters/src/lib.rs @@ -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; diff --git a/crates/bitwarden-generators/src/client_generator.rs b/crates/bitwarden-generators/src/generator_client.rs similarity index 84% rename from crates/bitwarden-generators/src/client_generator.rs rename to crates/bitwarden-generators/src/generator_client.rs index d2e2b748..62c9e17d 100644 --- a/crates/bitwarden-generators/src/client_generator.rs +++ b/crates/bitwarden-generators/src/generator_client.rs @@ -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 } } @@ -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 { @@ -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 { @@ -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 { @@ -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) } } diff --git a/crates/bitwarden-generators/src/lib.rs b/crates/bitwarden-generators/src/lib.rs index 6455a759..845d7f16 100644 --- a/crates/bitwarden-generators/src/lib.rs +++ b/crates/bitwarden-generators/src/lib.rs @@ -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; diff --git a/crates/bitwarden-send/src/lib.rs b/crates/bitwarden-send/src/lib.rs index e29d7305..f67aedde 100644 --- a/crates/bitwarden-send/src/lib.rs +++ b/crates/bitwarden-send/src/lib.rs @@ -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}; diff --git a/crates/bitwarden-send/src/client_sends.rs b/crates/bitwarden-send/src/send_client.rs similarity index 91% rename from crates/bitwarden-send/src/client_sends.rs rename to crates/bitwarden-send/src/send_client.rs index bf496e01..5c3c4e81 100644 --- a/crates/bitwarden-send/src/client_sends.rs +++ b/crates/bitwarden-send/src/send_client.rs @@ -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 } } @@ -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) } } diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 2e57e23b..6575e6ad 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -39,7 +39,7 @@ android_logger = "0.14" # The use of rustls-platform-verifier requires some extra support to communicate with the Android platform jni = ">=0.19, <0.20" libloading = ">=0.8.1, <0.9" -rustls-platform-verifier = "0.3.4" +rustls-platform-verifier = "0.4.0" [target.'cfg(target_os = "ios")'.dependencies] oslog = "0.2.0" diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 43496080..4d04ad7f 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -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); +pub struct AuthClient(pub(crate) Arc); #[uniffi::export(async_runtime = "tokio")] -impl ClientAuth { +impl AuthClient { /// **API Draft:** Calculate Password Strength pub fn password_strength( &self, @@ -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 { diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 6404d62f..7f961983 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -12,10 +12,10 @@ use bitwarden_crypto::{AsymmetricEncString, EncString}; use crate::{error::Result, Client}; #[derive(uniffi::Object)] -pub struct ClientCrypto(pub(crate) Arc); +pub struct CryptoClient(pub(crate) Arc); #[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<()> { diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index aae35c37..074d3992 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -2,7 +2,7 @@ uniffi::setup_scaffolding!(); use std::sync::Arc; -use auth::ClientAuth; +use auth::AuthClient; use bitwarden_core::ClientSettings; pub mod auth; @@ -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); @@ -39,37 +39,37 @@ impl Client { } /// Crypto operations - pub fn crypto(self: Arc) -> Arc { - Arc::new(ClientCrypto(self)) + pub fn crypto(self: Arc) -> Arc { + Arc::new(CryptoClient(self)) } /// Vault item operations - pub fn vault(self: Arc) -> Arc { - Arc::new(ClientVault(self)) + pub fn vault(self: Arc) -> Arc { + Arc::new(VaultClient(self)) } - pub fn platform(self: Arc) -> Arc { - Arc::new(ClientPlatform(self)) + pub fn platform(self: Arc) -> Arc { + Arc::new(PlatformClient(self)) } /// Generator operations - pub fn generators(self: Arc) -> Arc { - Arc::new(ClientGenerators(self)) + pub fn generators(self: Arc) -> Arc { + Arc::new(GeneratorClients(self)) } /// Exporters - pub fn exporters(self: Arc) -> Arc { - Arc::new(ClientExporters(self)) + pub fn exporters(self: Arc) -> Arc { + Arc::new(ExporterClient(self)) } /// Sends operations - pub fn sends(self: Arc) -> Arc { - Arc::new(ClientSends(self)) + pub fn sends(self: Arc) -> Arc { + Arc::new(SendClient(self)) } /// Auth operations - pub fn auth(self: Arc) -> Arc { - Arc::new(ClientAuth(self)) + pub fn auth(self: Arc) -> Arc { + Arc::new(AuthClient(self)) } /// Test method, echoes back the input diff --git a/crates/bitwarden-uniffi/src/platform/mod.rs b/crates/bitwarden-uniffi/src/platform/mod.rs index b5d94415..7ae74f41 100644 --- a/crates/bitwarden-uniffi/src/platform/mod.rs +++ b/crates/bitwarden-uniffi/src/platform/mod.rs @@ -7,10 +7,10 @@ use crate::{error::Result, Client}; mod fido2; #[derive(uniffi::Object)] -pub struct ClientPlatform(pub(crate) Arc); +pub struct PlatformClient(pub(crate) Arc); #[uniffi::export] -impl ClientPlatform { +impl PlatformClient { /// Fingerprint (public key) pub fn fingerprint(&self, req: FingerprintRequest) -> Result { Ok(self.0 .0.platform().fingerprint(&req)?.fingerprint) diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 04476006..c8f788b8 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use bitwarden_exporters::{Account, ClientExportersExt, ExportFormat}; +use bitwarden_exporters::{Account, ExportFormat, ExporterClientExt}; use bitwarden_generators::{ - ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, + GeneratorClientsExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest, }; use bitwarden_vault::{Cipher, Collection, Folder}; @@ -13,13 +13,13 @@ use crate::{ }; mod sends; -pub use sends::ClientSends; +pub use sends::SendClient; #[derive(uniffi::Object)] -pub struct ClientGenerators(pub(crate) Arc); +pub struct GeneratorClients(pub(crate) Arc); #[uniffi::export(async_runtime = "tokio")] -impl ClientGenerators { +impl GeneratorClients { /// Generate Password pub fn password(&self, settings: PasswordGeneratorRequest) -> Result { Ok(self @@ -53,10 +53,10 @@ impl ClientGenerators { } #[derive(uniffi::Object)] -pub struct ClientExporters(pub(crate) Arc); +pub struct ExporterClient(pub(crate) Arc); #[uniffi::export] -impl ClientExporters { +impl ExporterClient { /// Export user vault pub fn export_vault( &self, diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index 18732f57..b10d7fea 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -1,14 +1,14 @@ use std::{path::Path, sync::Arc}; -use bitwarden_send::{ClientSendsExt, Send, SendListView, SendView}; +use bitwarden_send::{Send, SendClientExt, SendListView, SendView}; use crate::{Client, Result}; #[derive(uniffi::Object)] -pub struct ClientSends(pub Arc); +pub struct SendClient(pub Arc); #[uniffi::export] -impl ClientSends { +impl SendClient { /// Encrypt send pub fn encrypt(&self, send: SendView) -> Result { Ok(self.0 .0.sends().encrypt(send)?) diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index cb2a011a..547fcfcf 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -1,7 +1,7 @@ use std::{path::Path, sync::Arc}; use bitwarden_vault::{ - Attachment, AttachmentEncryptResult, AttachmentView, Cipher, ClientVaultExt, + Attachment, AttachmentEncryptResult, AttachmentView, Cipher, VaultClientExt, }; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index 64751b37..45c347c1 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden_vault::{Cipher, CipherListView, CipherView, ClientVaultExt, Fido2CredentialView}; +use bitwarden_vault::{Cipher, CipherListView, CipherView, Fido2CredentialView, VaultClientExt}; use uuid::Uuid; use crate::{error::Error, Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index 250588e8..fbf4419f 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden_vault::{ClientVaultExt, Collection, CollectionView}; +use bitwarden_vault::{Collection, CollectionView, VaultClientExt}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 758d0917..98dd2174 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden_vault::{ClientVaultExt, Folder, FolderView}; +use bitwarden_vault::{Folder, FolderView, VaultClientExt}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index cec625e3..c0e1dfcd 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden_vault::{CipherListView, ClientVaultExt, TotpResponse}; +use bitwarden_vault::{CipherListView, TotpResponse, VaultClientExt}; use chrono::{DateTime, Utc}; use crate::{ @@ -15,10 +15,10 @@ pub mod folders; pub mod password_history; #[derive(uniffi::Object)] -pub struct ClientVault(pub(crate) Arc); +pub struct VaultClient(pub(crate) Arc); #[uniffi::export] -impl ClientVault { +impl VaultClient { /// Folder operations pub fn folders(self: Arc) -> Arc { Arc::new(folders::ClientFolders(self.0.clone())) diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 330e9121..a0c67d8f 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden_vault::{ClientVaultExt, PasswordHistory, PasswordHistoryView}; +use bitwarden_vault::{PasswordHistory, PasswordHistoryView, VaultClientExt}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/swift/iOS/App/ContentView.swift b/crates/bitwarden-uniffi/swift/iOS/App/ContentView.swift index 3700a32d..3188b065 100644 --- a/crates/bitwarden-uniffi/swift/iOS/App/ContentView.swift +++ b/crates/bitwarden-uniffi/swift/iOS/App/ContentView.swift @@ -114,7 +114,7 @@ struct ContentView: View { .padding() } - func clientExamplePassword(clientAuth: ClientAuthProtocol, clientCrypto: ClientCryptoProtocol, setupBiometrics: Bool, setupPin: Bool) async throws { + func clientExamplePassword(clientAuth: AuthClientProtocol, clientCrypto: CryptoClientProtocol, setupBiometrics: Bool, setupPin: Bool) async throws { ////////////////////////////// Get master password hash ////////////////////////////// struct PreloginRequest: Codable { let email: String } @@ -230,7 +230,7 @@ struct ContentView: View { } } - func clientExampleBiometrics(clientCrypto: ClientCryptoProtocol) async throws { + func clientExampleBiometrics(clientCrypto: CryptoClientProtocol) async throws { let defaults = UserDefaults.standard let privateKey = defaults.string(forKey: "privateKey")! let kdf = if defaults.integer(forKey: "kdfType") == 0 { @@ -255,7 +255,7 @@ struct ContentView: View { )) } - func clientExamplePin(clientCrypto: ClientCryptoProtocol) async throws { + func clientExamplePin(clientCrypto: CryptoClientProtocol) async throws { let defaults = UserDefaults.standard let privateKey = defaults.string(forKey: "privateKey")! let kdf = if defaults.integer(forKey: "kdfType") == 0 { @@ -279,7 +279,7 @@ struct ContentView: View { )) } - func decryptVault(clientCrypto: ClientCryptoProtocol, clientVault: ClientVaultProtocol) async throws { + func decryptVault(clientCrypto: CryptoClientProtocol, clientVault: VaultClientProtocol) async throws { ///////////////////////////// Sync ///////////////////////////// struct SyncOrganization: Codable { diff --git a/crates/bitwarden-vault/src/lib.rs b/crates/bitwarden-vault/src/lib.rs index 9f1d4a18..658dc321 100644 --- a/crates/bitwarden-vault/src/lib.rs +++ b/crates/bitwarden-vault/src/lib.rs @@ -19,9 +19,9 @@ pub use totp::{ }; mod error; pub use error::VaultParseError; -mod client_vault; -pub use client_vault::{ClientVault, ClientVaultExt}; -mod client_totp; +mod vault_client; +pub use vault_client::{VaultClient, VaultClientExt}; mod mobile; mod sync; +mod totp_client; pub use sync::{SyncRequest, SyncResponse}; diff --git a/crates/bitwarden-vault/src/mobile/client_attachments.rs b/crates/bitwarden-vault/src/mobile/attachment_client.rs similarity index 97% rename from crates/bitwarden-vault/src/mobile/client_attachments.rs rename to crates/bitwarden-vault/src/mobile/attachment_client.rs index ee37b383..0a7e8fd8 100644 --- a/crates/bitwarden-vault/src/mobile/client_attachments.rs +++ b/crates/bitwarden-vault/src/mobile/attachment_client.rs @@ -5,7 +5,7 @@ use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable, LocateKey}; use crate::{ Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, - Cipher, ClientVault, + Cipher, VaultClient, }; pub struct ClientAttachments<'a> { @@ -76,7 +76,7 @@ impl ClientAttachments<'_> { } } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn attachments(&'a self) -> ClientAttachments<'a> { ClientAttachments { client: self.client, diff --git a/crates/bitwarden-vault/src/mobile/client_ciphers.rs b/crates/bitwarden-vault/src/mobile/cipher_client.rs similarity index 98% rename from crates/bitwarden-vault/src/mobile/client_ciphers.rs rename to crates/bitwarden-vault/src/mobile/cipher_client.rs index ad973df8..f15608d7 100644 --- a/crates/bitwarden-vault/src/mobile/client_ciphers.rs +++ b/crates/bitwarden-vault/src/mobile/cipher_client.rs @@ -2,7 +2,7 @@ use bitwarden_core::{Client, Error}; use bitwarden_crypto::{KeyDecryptable, KeyEncryptable, LocateKey}; use uuid::Uuid; -use crate::{Cipher, CipherError, CipherListView, CipherView, ClientVault}; +use crate::{Cipher, CipherError, CipherListView, CipherView, VaultClient}; pub struct ClientCiphers<'a> { pub(crate) client: &'a Client, @@ -79,7 +79,7 @@ impl ClientCiphers<'_> { } } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn ciphers(&'a self) -> ClientCiphers<'a> { ClientCiphers { client: self.client, @@ -93,7 +93,7 @@ mod tests { use bitwarden_core::client::test_accounts::test_bitwarden_com_account; use super::*; - use crate::{Attachment, CipherRepromptType, CipherType, ClientVaultExt, Login}; + use crate::{Attachment, CipherRepromptType, CipherType, Login, VaultClientExt}; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden-vault/src/mobile/client_collection.rs b/crates/bitwarden-vault/src/mobile/collection_client.rs similarity index 95% rename from crates/bitwarden-vault/src/mobile/client_collection.rs rename to crates/bitwarden-vault/src/mobile/collection_client.rs index 77b2cbc1..51026959 100644 --- a/crates/bitwarden-vault/src/mobile/client_collection.rs +++ b/crates/bitwarden-vault/src/mobile/collection_client.rs @@ -1,7 +1,7 @@ use bitwarden_core::{Client, Error}; use bitwarden_crypto::{KeyDecryptable, LocateKey}; -use crate::{ClientVault, Collection, CollectionView}; +use crate::{Collection, CollectionView, VaultClient}; pub struct ClientCollections<'a> { pub(crate) client: &'a Client, @@ -32,7 +32,7 @@ impl ClientCollections<'_> { } } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn collections(&'a self) -> ClientCollections<'a> { ClientCollections { client: self.client, @@ -45,7 +45,7 @@ mod tests { use bitwarden_core::client::test_accounts::test_bitwarden_com_account; use super::*; - use crate::ClientVaultExt; + use crate::VaultClientExt; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden-vault/src/mobile/client_folders.rs b/crates/bitwarden-vault/src/mobile/folder_client.rs similarity index 93% rename from crates/bitwarden-vault/src/mobile/client_folders.rs rename to crates/bitwarden-vault/src/mobile/folder_client.rs index 5730cf90..0c8cd8f7 100644 --- a/crates/bitwarden-vault/src/mobile/client_folders.rs +++ b/crates/bitwarden-vault/src/mobile/folder_client.rs @@ -1,7 +1,7 @@ use bitwarden_core::{Client, Error}; use bitwarden_crypto::{KeyDecryptable, KeyEncryptable}; -use crate::{ClientVault, Folder, FolderView}; +use crate::{Folder, FolderView, VaultClient}; pub struct ClientFolders<'a> { pub(crate) client: &'a Client, @@ -36,7 +36,7 @@ impl ClientFolders<'_> { } } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn folders(&'a self) -> ClientFolders<'a> { ClientFolders { client: self.client, diff --git a/crates/bitwarden-vault/src/mobile/mod.rs b/crates/bitwarden-vault/src/mobile/mod.rs index 59e28b6e..1815af59 100644 --- a/crates/bitwarden-vault/src/mobile/mod.rs +++ b/crates/bitwarden-vault/src/mobile/mod.rs @@ -1,5 +1,5 @@ -mod client_attachments; -mod client_ciphers; -mod client_collection; -mod client_folders; -mod client_password_history; +mod attachment_client; +mod cipher_client; +mod collection_client; +mod folder_client; +mod password_history_client; diff --git a/crates/bitwarden-vault/src/mobile/client_password_history.rs b/crates/bitwarden-vault/src/mobile/password_history_client.rs similarity index 91% rename from crates/bitwarden-vault/src/mobile/client_password_history.rs rename to crates/bitwarden-vault/src/mobile/password_history_client.rs index 7900b208..574819bb 100644 --- a/crates/bitwarden-vault/src/mobile/client_password_history.rs +++ b/crates/bitwarden-vault/src/mobile/password_history_client.rs @@ -1,7 +1,7 @@ use bitwarden_core::{Client, Error}; use bitwarden_crypto::{KeyDecryptable, KeyEncryptable}; -use crate::{ClientVault, PasswordHistory, PasswordHistoryView}; +use crate::{PasswordHistory, PasswordHistoryView, VaultClient}; pub struct ClientPasswordHistory<'a> { pub(crate) client: &'a Client, @@ -30,7 +30,7 @@ impl ClientPasswordHistory<'_> { } } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn password_history(&'a self) -> ClientPasswordHistory<'a> { ClientPasswordHistory { client: self.client, diff --git a/crates/bitwarden-vault/src/client_totp.rs b/crates/bitwarden-vault/src/totp_client.rs similarity index 85% rename from crates/bitwarden-vault/src/client_totp.rs rename to crates/bitwarden-vault/src/totp_client.rs index 6425b72e..77c43082 100644 --- a/crates/bitwarden-vault/src/client_totp.rs +++ b/crates/bitwarden-vault/src/totp_client.rs @@ -1,10 +1,10 @@ use chrono::{DateTime, Utc}; use crate::{ - generate_totp, generate_totp_cipher_view, CipherListView, ClientVault, TotpError, TotpResponse, + generate_totp, generate_totp_cipher_view, CipherListView, TotpError, TotpResponse, VaultClient, }; -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { /// Generate a TOTP code from a provided key. /// /// Key can be either: diff --git a/crates/bitwarden-vault/src/client_vault.rs b/crates/bitwarden-vault/src/vault_client.rs similarity index 59% rename from crates/bitwarden-vault/src/client_vault.rs rename to crates/bitwarden-vault/src/vault_client.rs index 67f6792b..b5722368 100644 --- a/crates/bitwarden-vault/src/client_vault.rs +++ b/crates/bitwarden-vault/src/vault_client.rs @@ -5,11 +5,11 @@ use crate::{ SyncRequest, SyncResponse, }; -pub struct ClientVault<'a> { +pub struct VaultClient<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientVault<'a> { +impl<'a> VaultClient<'a> { pub fn new(client: &'a Client) -> Self { Self { client } } @@ -19,12 +19,12 @@ impl<'a> ClientVault<'a> { } } -pub trait ClientVaultExt<'a> { - fn vault(&'a self) -> ClientVault<'a>; +pub trait VaultClientExt<'a> { + fn vault(&'a self) -> VaultClient<'a>; } -impl<'a> ClientVaultExt<'a> for Client { - fn vault(&'a self) -> ClientVault<'a> { - ClientVault::new(self) +impl<'a> VaultClientExt<'a> for Client { + fn vault(&'a self) -> VaultClient<'a> { + VaultClient::new(self) } } diff --git a/crates/bitwarden-wasm-internal/src/client.rs b/crates/bitwarden-wasm-internal/src/client.rs index 4049be56..851ffbdb 100644 --- a/crates/bitwarden-wasm-internal/src/client.rs +++ b/crates/bitwarden-wasm-internal/src/client.rs @@ -6,7 +6,7 @@ use bitwarden_error::prelude::*; use log::{set_max_level, Level}; use wasm_bindgen::prelude::*; -use crate::{vault::ClientVault, ClientCrypto}; +use crate::{vault::VaultClient, CryptoClient}; #[wasm_bindgen] pub enum LogLevel { @@ -66,12 +66,12 @@ impl BitwardenClient { res.text().await.map_err(|e| e.to_string()) } - pub fn crypto(&self) -> ClientCrypto { - ClientCrypto::new(self.0.clone()) + pub fn crypto(&self) -> CryptoClient { + CryptoClient::new(self.0.clone()) } - pub fn vault(&self) -> ClientVault { - ClientVault::new(self.0.clone()) + pub fn vault(&self) -> VaultClient { + VaultClient::new(self.0.clone()) } } diff --git a/crates/bitwarden-wasm-internal/src/crypto.rs b/crates/bitwarden-wasm-internal/src/crypto.rs index 1f9a3b48..ec8afcf3 100644 --- a/crates/bitwarden-wasm-internal/src/crypto.rs +++ b/crates/bitwarden-wasm-internal/src/crypto.rs @@ -11,16 +11,16 @@ use bitwarden_core::{ use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct ClientCrypto(Rc); +pub struct CryptoClient(Rc); -impl ClientCrypto { +impl CryptoClient { pub fn new(client: Rc) -> Self { Self(client) } } #[wasm_bindgen] -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( diff --git a/crates/bitwarden-wasm-internal/src/lib.rs b/crates/bitwarden-wasm-internal/src/lib.rs index fc61d4c2..1866538a 100644 --- a/crates/bitwarden-wasm-internal/src/lib.rs +++ b/crates/bitwarden-wasm-internal/src/lib.rs @@ -5,5 +5,5 @@ mod ssh; mod vault; pub use client::BitwardenClient; -pub use crypto::ClientCrypto; -pub use vault::{folders::ClientFolders, ClientVault}; +pub use crypto::CryptoClient; +pub use vault::{folders::ClientFolders, VaultClient}; diff --git a/crates/bitwarden-wasm-internal/src/vault/folders.rs b/crates/bitwarden-wasm-internal/src/vault/folders.rs index 8cb110a6..41a640d6 100644 --- a/crates/bitwarden-wasm-internal/src/vault/folders.rs +++ b/crates/bitwarden-wasm-internal/src/vault/folders.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use bitwarden_core::Client; -use bitwarden_vault::{ClientVaultExt, Folder, FolderView}; +use bitwarden_vault::{Folder, FolderView, VaultClientExt}; use wasm_bindgen::prelude::*; #[wasm_bindgen] diff --git a/crates/bitwarden-wasm-internal/src/vault/mod.rs b/crates/bitwarden-wasm-internal/src/vault/mod.rs index 11db0e13..b84aaad2 100644 --- a/crates/bitwarden-wasm-internal/src/vault/mod.rs +++ b/crates/bitwarden-wasm-internal/src/vault/mod.rs @@ -8,16 +8,16 @@ use wasm_bindgen::prelude::*; use crate::ClientFolders; #[wasm_bindgen] -pub struct ClientVault(Rc); +pub struct VaultClient(Rc); -impl ClientVault { +impl VaultClient { pub fn new(client: Rc) -> Self { Self(client) } } #[wasm_bindgen] -impl ClientVault { +impl VaultClient { pub fn folders(&self) -> ClientFolders { ClientFolders::new(self.0.clone()) } diff --git a/crates/bw/src/auth/login.rs b/crates/bw/src/auth/login.rs index 131d39f0..35a8498b 100644 --- a/crates/bw/src/auth/login.rs +++ b/crates/bw/src/auth/login.rs @@ -6,7 +6,7 @@ use bitwarden_core::{ }, Client, }; -use bitwarden_vault::{ClientVaultExt, SyncRequest}; +use bitwarden_vault::{SyncRequest, VaultClientExt}; use color_eyre::eyre::{bail, Result}; use inquire::{Password, Text}; use log::{debug, error, info}; diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index 06d5d0bd..6c4488ad 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -1,7 +1,7 @@ use bitwarden_cli::{install_color_eyre, text_prompt_when_none, Color}; use bitwarden_core::{auth::RegisterRequest, ClientSettings}; use bitwarden_generators::{ - ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, + GeneratorClientsExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, }; use clap::{command, Args, CommandFactory, Parser, Subcommand}; use color_eyre::eyre::Result;