bitwarden/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! # Bitwarden
//!
//! A Rust client SDK to interact with the Bitwarden Secrets Manager.
//! This is a beta release and might be missing some functionality.
//!
//! To use this crate, add it to your `Cargo.toml`:
//!
//! ```ini
//! [dependencies]
//! bitwarden = { "*", features = ["secrets"] }
//! ```
//!
//! # Basic setup
//!
//! All operations in this crate are done via a [Client]:
//!
//! ```rust
//! use bitwarden::{
//!     auth::login::AccessTokenLoginRequest,
//!     error::Result,
//!     secrets_manager::{secrets::SecretIdentifiersRequest, ClientSecretsExt},
//!     Client, ClientSettings, DeviceType,
//! };
//! use uuid::Uuid;
//!
//! async fn test() -> Result<()> {
//!     // Use the default values
//!     let mut client = Client::new(None);
//!
//!     // Or set your own values
//!     let settings = ClientSettings {
//!         identity_url: "https://identity.bitwarden.com".to_string(),
//!         api_url: "https://api.bitwarden.com".to_string(),
//!         user_agent: "Bitwarden Rust-SDK".to_string(),
//!         device_type: DeviceType::SDK,
//!     };
//!     let mut client = Client::new(Some(settings));
//!
//!     // Before we operate, we need to authenticate with a token
//!     let token = AccessTokenLoginRequest {
//!         access_token: String::from(""),
//!         state_file: None,
//!     };
//!     client.auth().login_access_token(&token).await.unwrap();
//!
//!     let org_id = SecretIdentifiersRequest {
//!         organization_id: Uuid::parse_str("00000000-0000-0000-0000-000000000000").unwrap(),
//!     };
//!     println!(
//!         "Stored secrets: {:#?}",
//!         client.secrets().list(&org_id).await.unwrap()
//!     );
//!     Ok(())
//! }
//! ```

// Ensure the readme docs compile
#[doc = include_str!("../README.md")]
mod readme {}

pub use bitwarden_core::*;
pub mod error;

#[cfg(feature = "internal")]
pub mod internal {
    pub mod generators {
        pub use bitwarden_generators::*;
    }

    pub mod exporters {
        pub use bitwarden_exporters::*;
    }

    pub mod send {
        pub use bitwarden_send::*;
    }

    pub mod vault {
        pub use bitwarden_vault::*;
    }

    #[cfg(feature = "uniffi")]
    pub mod fido {
        pub use bitwarden_fido::*;
    }
}
#[cfg(feature = "internal")]
pub use internal::*;

// Re-export generators used for secrets-manager, internal flag already exports all generators
#[cfg(all(feature = "secrets", not(feature = "internal")))]
pub mod generators {
    pub use bitwarden_generators::{ClientGeneratorExt, PasswordError, PasswordGeneratorRequest};
}

#[cfg(feature = "secrets")]
pub mod secrets_manager {
    pub use bitwarden_sm::*;
}