Skip to content

Commit 8b0352e

Browse files
authored
Merge branch 'main' into km/pm-10941/ssh-import
2 parents 184a009 + 2c22c4f commit 8b0352e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+198
-176
lines changed

.github/workflows/check-powerset.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Check Rust feature-powerset
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
build:
11+
name: Building for ${{ matrix.os }}
12+
13+
runs-on: ${{ matrix.os || 'ubuntu-24.04' }}
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- macos-14
20+
- ubuntu-24.04
21+
- windows-2022
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
27+
- name: Install rust
28+
uses: dtolnay/rust-toolchain@315e265cd78dad1e1dcf3a5074f6d6c47029d5aa # stable
29+
with:
30+
toolchain: stable
31+
32+
- name: Cache cargo registry
33+
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
34+
35+
- name: Install cargo-hack
36+
run: cargo install cargo-hack --version 0.6.33 --locked
37+
38+
- name: Build
39+
run: cargo hack check --workspace --feature-powerset --no-dev-deps
40+
env:
41+
RUSTFLAGS: "-D warnings"

Cargo.lock

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bitwarden-core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ zxcvbn = { version = ">=3.0.1, <4.0", optional = true }
5959
# By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates
6060
# The only exception is WASM, as it just uses the browsers/node fetch
6161
reqwest = { workspace = true, features = ["rustls-tls-manual-roots"] }
62-
rustls-platform-verifier = "0.3.4"
62+
rustls = { version = "0.23.19", default-features = false }
63+
rustls-platform-verifier = "0.4.0"
6364

6465
[dev-dependencies]
6566
bitwarden-crypto = { workspace = true }

crates/bitwarden-core/src/auth/client_auth.rs renamed to crates/bitwarden-core/src/auth/auth_client.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ use crate::auth::{
2525
};
2626
use crate::{auth::renew::renew_token, error::Result, Client};
2727

28-
pub struct ClientAuth<'a> {
28+
pub struct AuthClient<'a> {
2929
pub(crate) client: &'a crate::Client,
3030
}
3131

32-
impl<'a> ClientAuth<'a> {
32+
impl<'a> AuthClient<'a> {
3333
pub async fn renew_token(&self) -> Result<()> {
3434
renew_token(&self.client.internal).await
3535
}
@@ -44,7 +44,7 @@ impl<'a> ClientAuth<'a> {
4444
}
4545

4646
#[cfg(feature = "internal")]
47-
impl<'a> ClientAuth<'a> {
47+
impl<'a> AuthClient<'a> {
4848
pub fn password_strength(
4949
&self,
5050
password: String,
@@ -142,7 +142,7 @@ impl<'a> ClientAuth<'a> {
142142
}
143143

144144
#[cfg(feature = "internal")]
145-
impl<'a> ClientAuth<'a> {
145+
impl<'a> AuthClient<'a> {
146146
pub async fn login_device(
147147
&self,
148148
email: String,
@@ -170,8 +170,8 @@ fn trust_device(client: &Client) -> Result<TrustDeviceResponse> {
170170
}
171171

172172
impl<'a> Client {
173-
pub fn auth(&'a self) -> ClientAuth<'a> {
174-
ClientAuth { client: self }
173+
pub fn auth(&'a self) -> AuthClient<'a> {
174+
AuthClient { client: self }
175175
}
176176
}
177177

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use bitwarden_crypto::{HashPurpose, Kdf, MasterKey};
33

44
mod access_token;
55
pub(super) mod api;
6-
pub mod client_auth;
6+
pub mod auth_client;
77
mod jwt_token;
88
pub mod login;
99
#[cfg(feature = "internal")]

crates/bitwarden-core/src/client/client.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ impl Client {
2727

2828
#[cfg(not(target_arch = "wasm32"))]
2929
{
30+
use rustls::ClientConfig;
31+
use rustls_platform_verifier::ConfigVerifierExt;
3032
client_builder =
31-
client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config());
33+
client_builder.use_preconfigured_tls(ClientConfig::with_platform_verifier());
3234
}
3335

3436
client_builder
@@ -83,24 +85,3 @@ impl Client {
8385
}
8486
}
8587
}
86-
87-
#[cfg(test)]
88-
mod tests {
89-
#[cfg(not(target_arch = "wasm32"))]
90-
#[test]
91-
fn test_reqwest_rustls_platform_verifier_are_compatible() {
92-
// rustls-platform-verifier is generating a rustls::ClientConfig,
93-
// which reqwest accepts as a &dyn Any and then downcasts it to a
94-
// rustls::ClientConfig.
95-
96-
// This means that if the rustls version of the two crates don't match,
97-
// the downcast will fail and we will get a runtime error.
98-
99-
// This tests is added to ensure that it doesn't happen.
100-
101-
let _ = reqwest::ClientBuilder::new()
102-
.use_preconfigured_tls(rustls_platform_verifier::tls_config())
103-
.build()
104-
.unwrap();
105-
}
106-
}

crates/bitwarden-core/src/error.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use reqwest::StatusCode;
1010
use thiserror::Error;
1111
use validator::ValidationErrors;
1212

13-
#[cfg(feature = "internal")]
1413
use crate::client::encryption_settings::EncryptionSettingsError;
1514

1615
#[bitwarden_error(flat, export_as = "CoreError")]
@@ -62,7 +61,6 @@ pub enum Error {
6261
#[error("Internal error: {0}")]
6362
Internal(Cow<'static, str>),
6463

65-
#[cfg(feature = "internal")]
6664
#[error(transparent)]
6765
EncryptionSettings(#[from] EncryptionSettingsError),
6866
}

crates/bitwarden-core/src/mobile/client_crypto.rs renamed to crates/bitwarden-core/src/mobile/crypto_client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use crate::{
1616
},
1717
};
1818

19-
pub struct ClientCrypto<'a> {
19+
pub struct CryptoClient<'a> {
2020
pub(crate) client: &'a crate::Client,
2121
}
2222

23-
impl<'a> ClientCrypto<'a> {
23+
impl<'a> CryptoClient<'a> {
2424
pub async fn initialize_user_crypto(
2525
&self,
2626
req: InitUserCryptoRequest,
@@ -73,7 +73,7 @@ impl<'a> ClientCrypto<'a> {
7373
}
7474

7575
impl<'a> Client {
76-
pub fn crypto(&'a self) -> ClientCrypto<'a> {
77-
ClientCrypto { client: self }
76+
pub fn crypto(&'a self) -> CryptoClient<'a> {
77+
CryptoClient { client: self }
7878
}
7979
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub mod crypto;
22
pub mod kdf;
33

4-
mod client_crypto;
54
mod client_kdf;
5+
mod crypto_client;
66

7-
pub use client_crypto::ClientCrypto;
87
pub use client_kdf::ClientKdf;
8+
pub use crypto_client::CryptoClient;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pub mod client_platform;
21
mod generate_fingerprint;
32
mod get_user_api_key;
3+
pub mod platform_client;
44
mod secret_verification_request;
55

66
pub use generate_fingerprint::{FingerprintRequest, FingerprintResponse};

crates/bitwarden-core/src/platform/client_platform.rs renamed to crates/bitwarden-core/src/platform/platform_client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use super::{
55
};
66
use crate::{error::Result, Client};
77

8-
pub struct ClientPlatform<'a> {
8+
pub struct PlatformClient<'a> {
99
pub(crate) client: &'a Client,
1010
}
1111

12-
impl<'a> ClientPlatform<'a> {
12+
impl<'a> PlatformClient<'a> {
1313
pub fn fingerprint(&self, input: &FingerprintRequest) -> Result<FingerprintResponse> {
1414
generate_fingerprint(input)
1515
}
@@ -27,7 +27,7 @@ impl<'a> ClientPlatform<'a> {
2727
}
2828

2929
impl<'a> Client {
30-
pub fn platform(&'a self) -> ClientPlatform<'a> {
31-
ClientPlatform { client: self }
30+
pub fn platform(&'a self) -> PlatformClient<'a> {
31+
PlatformClient { client: self }
3232
}
3333
}

crates/bitwarden-error-macro/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license-file.workspace = true
1010
keywords.workspace = true
1111

1212
[features]
13-
wasm = ["bitwarden-error/wasm"]
13+
wasm = []
1414

1515
[dependencies]
1616
darling = "0.20.10"
@@ -25,7 +25,7 @@ workspace = true
2525
proc-macro = true
2626

2727
[dev-dependencies]
28-
bitwarden-error.workspace = true
28+
bitwarden-error = { workspace = true, features = ["wasm"] }
2929
js-sys.workspace = true
3030
serde.workspace = true
3131
thiserror.workspace = true

crates/bitwarden-exporters/src/client_exporter.rs renamed to crates/bitwarden-exporters/src/exporter_client.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use crate::{
66
Account, ExportError, ExportFormat,
77
};
88

9-
pub struct ClientExporters<'a> {
9+
pub struct ExporterClient<'a> {
1010
client: &'a Client,
1111
}
1212

13-
impl<'a> ClientExporters<'a> {
13+
impl<'a> ExporterClient<'a> {
1414
fn new(client: &'a Client) -> Self {
1515
Self { client }
1616
}
@@ -58,12 +58,12 @@ impl<'a> ClientExporters<'a> {
5858
}
5959
}
6060

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

65-
impl<'a> ClientExportersExt<'a> for Client {
66-
fn exporters(&'a self) -> ClientExporters<'a> {
67-
ClientExporters::new(self)
65+
impl<'a> ExporterClientExt<'a> for Client {
66+
fn exporters(&'a self) -> ExporterClient<'a> {
67+
ExporterClient::new(self)
6868
}
6969
}

crates/bitwarden-exporters/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ uniffi::setup_scaffolding!();
1212
#[cfg(feature = "uniffi")]
1313
mod uniffi_support;
1414

15-
mod client_exporter;
1615
mod csv;
1716
mod cxp;
1817
pub use cxp::Account;
1918
mod encrypted_json;
19+
mod exporter_client;
2020
mod json;
2121
mod models;
22-
pub use client_exporter::{ClientExporters, ClientExportersExt};
22+
pub use exporter_client::{ExporterClient, ExporterClientExt};
2323
mod error;
2424
mod export;
2525
pub use error::ExportError;

0 commit comments

Comments
 (0)