From dd440baa7797dcf90175ac6bf0e7ad26f15cf6fb Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 14 Mar 2024 12:55:22 +0100 Subject: [PATCH] Mark exporters and generators as internal dependencies (#660) We accidentally exposed exporters and generators without feature flagging them. This PR properly puts them under the internal feature flag. --- crates/bitwarden-crypto/Cargo.toml | 2 +- crates/bitwarden-generators/Cargo.toml | 2 +- crates/bitwarden/Cargo.toml | 11 +++++++---- crates/bitwarden/src/error.rs | 6 ++++++ crates/bitwarden/src/lib.rs | 1 + 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index 54a9f760e..c1104faba 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -15,7 +15,7 @@ rust-version = "1.71" [features] default = [] -mobile = ["uniffi"] +mobile = ["dep:uniffi"] # Mobile-specific features [dependencies] aes = { version = ">=0.8.2, <0.9", features = ["zeroize"] } diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index 8f06de664..8ee2806a0 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.71" [features] -mobile = ["uniffi"] # Mobile-specific features +mobile = ["dep:uniffi"] # Mobile-specific features [dependencies] bitwarden-crypto = { path = "../bitwarden-crypto", version = "=0.1.0" } diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 9950a788a..37dbe28c3 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -16,10 +16,13 @@ rust-version = "1.71" default = ["secrets"] secrets = [] # Secrets manager API -internal = [] # Internal testing methods +internal = [ + "dep:bitwarden-exporters", + "dep:bitwarden-generators", +] # Internal testing methods mobile = [ - "uniffi", "internal", + "dep:uniffi", "bitwarden-crypto/mobile", "bitwarden-generators/mobile", ] # Mobile-specific features @@ -31,8 +34,8 @@ base64 = ">=0.21.2, <0.22" bitwarden-api-api = { path = "../bitwarden-api-api", version = "=0.2.3" } bitwarden-api-identity = { path = "../bitwarden-api-identity", version = "=0.2.3" } bitwarden-crypto = { path = "../bitwarden-crypto", version = "=0.1.0" } -bitwarden-exporters = { path = "../bitwarden-exporters", version = "0.1.0" } -bitwarden-generators = { path = "../bitwarden-generators", version = "0.1.0" } +bitwarden-exporters = { path = "../bitwarden-exporters", version = "0.1.0", optional = true } +bitwarden-generators = { path = "../bitwarden-generators", version = "0.1.0", optional = true } chrono = { version = ">=0.4.26, <0.5", features = [ "clock", "serde", diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index ed5d27c3e..bd040e51b 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -4,7 +4,9 @@ use std::{borrow::Cow, fmt::Debug}; use bitwarden_api_api::apis::Error as ApiError; use bitwarden_api_identity::apis::Error as IdentityError; +#[cfg(feature = "internal")] use bitwarden_exporters::ExportError; +#[cfg(feature = "internal")] use bitwarden_generators::{PassphraseError, PasswordError, UsernameError}; use reqwest::StatusCode; use thiserror::Error; @@ -52,13 +54,17 @@ pub enum Error { InvalidStateFile, // Generators + #[cfg(feature = "internal")] #[error(transparent)] UsernameError(#[from] UsernameError), + #[cfg(feature = "internal")] #[error(transparent)] PassphraseError(#[from] PassphraseError), + #[cfg(feature = "internal")] #[error(transparent)] PasswordError(#[from] PasswordError), + #[cfg(feature = "internal")] #[error(transparent)] ExportError(#[from] ExportError), diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index 28eb521de..17774b002 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -75,6 +75,7 @@ pub use client::Client; #[doc = include_str!("../README.md")] mod readme {} +#[cfg(feature = "internal")] pub mod generators { pub use bitwarden_generators::{ PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest,