Skip to content

Commit

Permalink
Merge branch 'main' into km/pm-10941/ssh-import
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten authored Dec 19, 2024
2 parents 184a009 + 2c22c4f commit 8b0352e
Show file tree
Hide file tree
Showing 48 changed files with 198 additions and 176 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/check-powerset.yml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/bitwarden-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
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
25 changes: 3 additions & 22 deletions crates/bitwarden-core/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
2 changes: 0 additions & 2 deletions crates/bitwarden-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -62,7 +61,6 @@ pub enum Error {
#[error("Internal error: {0}")]
Internal(Cow<'static, str>),

#[cfg(feature = "internal")]
#[error(transparent)]
EncryptionSettings(#[from] EncryptionSettingsError),
}
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 }
}
}
4 changes: 2 additions & 2 deletions crates/bitwarden-error-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license-file.workspace = true
keywords.workspace = true

[features]
wasm = ["bitwarden-error/wasm"]
wasm = []

[dependencies]
darling = "0.20.10"
Expand All @@ -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
Expand Down
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
Loading

0 comments on commit 8b0352e

Please sign in to comment.