Skip to content

Commit

Permalink
Tweak feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Dec 11, 2023
1 parent f35eca5 commit 4705547
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
14 changes: 13 additions & 1 deletion crates/bitwarden/src/crypto/enc_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl FromStr for EncString {

impl EncString {
/// Synthetic sugar for mapping `Option<String>` to `Result<Option<EncString>>`
#[cfg(feature = "mobile")]
#[cfg(feature = "internal")]
pub(crate) fn try_from(s: Option<String>) -> Result<Option<EncString>, Error> {
s.map(|s| s.parse()).transpose()
}
Expand Down Expand Up @@ -403,6 +403,18 @@ impl KeyDecryptable<String> 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::<String>()
}
}

#[cfg(test)]
mod tests {
use crate::crypto::{KeyDecryptable, KeyEncryptable, SymmetricCryptoKey};
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
12 changes: 0 additions & 12 deletions crates/bitwarden/src/mobile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>()
}
}
3 changes: 3 additions & 0 deletions crates/bitwarden/src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ mod collection;
mod folder;
mod password_history;
mod send;
#[cfg(feature = "mobile")]
mod totp;

pub use cipher::{Cipher, CipherListView, CipherView};
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;

0 comments on commit 4705547

Please sign in to comment.