From 470554721c4c270660fd9dfc5d213fde3df495d7 Mon Sep 17 00:00:00 2001 From: Hinton Date: Mon, 11 Dec 2023 11:26:31 +0100 Subject: [PATCH] Tweak feature flags --- crates/bitwarden/src/crypto/enc_string.rs | 14 +++++++++++++- crates/bitwarden/src/lib.rs | 4 ++-- crates/bitwarden/src/mobile/mod.rs | 12 ------------ crates/bitwarden/src/vault/mod.rs | 3 +++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/bitwarden/src/crypto/enc_string.rs b/crates/bitwarden/src/crypto/enc_string.rs index c745473bd..32df6e001 100644 --- a/crates/bitwarden/src/crypto/enc_string.rs +++ b/crates/bitwarden/src/crypto/enc_string.rs @@ -166,7 +166,7 @@ impl FromStr for EncString { impl EncString { /// Synthetic sugar for mapping `Option` to `Result>` - #[cfg(feature = "mobile")] + #[cfg(feature = "internal")] pub(crate) fn try_from(s: Option) -> Result, Error> { s.map(|s| s.parse()).transpose() } @@ -403,6 +403,18 @@ impl KeyDecryptable for EncString { } } +/// Usually we wouldn't want to expose EncStrings in the API or the schemas. +/// But during the transition phase we will expose endpoints using the EncString type. +impl schemars::JsonSchema for crate::crypto::EncString { + fn schema_name() -> String { + "EncString".to_string() + } + + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + gen.subschema_for::() + } +} + #[cfg(test)] mod tests { use crate::crypto::{KeyDecryptable, KeyEncryptable, SymmetricCryptoKey}; diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index d3c7d66d9..0017ecff9 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -51,7 +51,7 @@ #[cfg(feature = "mobile")] uniffi::setup_scaffolding!(); -#[cfg(feature = "mobile")] +#[cfg(feature = "internal")] pub mod admin_console; pub mod auth; pub mod client; @@ -68,7 +68,7 @@ pub mod tool; #[cfg(feature = "mobile")] pub(crate) mod uniffi_support; mod util; -#[cfg(feature = "mobile")] +#[cfg(feature = "internal")] pub mod vault; pub mod wordlist; diff --git a/crates/bitwarden/src/mobile/mod.rs b/crates/bitwarden/src/mobile/mod.rs index fe3083aa8..e0ba50d00 100644 --- a/crates/bitwarden/src/mobile/mod.rs +++ b/crates/bitwarden/src/mobile/mod.rs @@ -8,15 +8,3 @@ mod client_kdf; pub use client_crypto::ClientCrypto; pub use client_kdf::ClientKdf; - -// Usually we wouldn't want to expose EncStrings in the API or the schemas, -// but we need them in the mobile API, so define it here to limit the scope -impl schemars::JsonSchema for crate::crypto::EncString { - fn schema_name() -> String { - "EncString".to_string() - } - - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - gen.subschema_for::() - } -} diff --git a/crates/bitwarden/src/vault/mod.rs b/crates/bitwarden/src/vault/mod.rs index ca9b12c1c..6ac43a4d0 100644 --- a/crates/bitwarden/src/vault/mod.rs +++ b/crates/bitwarden/src/vault/mod.rs @@ -3,6 +3,7 @@ mod collection; mod folder; mod password_history; mod send; +#[cfg(feature = "mobile")] mod totp; pub use cipher::{Cipher, CipherListView, CipherView}; @@ -10,5 +11,7 @@ pub use collection::{Collection, CollectionView}; pub use folder::{Folder, FolderView}; pub use password_history::{PasswordHistory, PasswordHistoryView}; pub use send::{Send, SendListView, SendView}; +#[cfg(feature = "mobile")] pub(crate) use totp::generate_totp; +#[cfg(feature = "mobile")] pub use totp::TotpResponse;