bitwarden_core/client/
client_settings.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// Basic client behavior settings. These settings specify the various targets and behavior of the
5/// Bitwarden Client. They are optional and uneditable once the client is initialized.
6///
7/// Defaults to
8///
9/// ```
10/// # use bitwarden_core::{ClientSettings, DeviceType};
11/// let settings = ClientSettings {
12///     identity_url: "https://identity.bitwarden.com".to_string(),
13///     api_url: "https://api.bitwarden.com".to_string(),
14///     user_agent: "Bitwarden Rust-SDK".to_string(),
15///     device_type: DeviceType::SDK,
16/// };
17/// let default = ClientSettings::default();
18/// ```
19#[derive(Serialize, Deserialize, Debug, JsonSchema)]
20#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
21#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
22#[cfg_attr(
23    feature = "wasm",
24    derive(tsify_next::Tsify),
25    tsify(into_wasm_abi, from_wasm_abi)
26)]
27pub struct ClientSettings {
28    /// The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
29    pub identity_url: String,
30    /// The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
31    pub api_url: String,
32    /// The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
33    pub user_agent: String,
34    /// Device type to send to Bitwarden. Defaults to SDK
35    pub device_type: DeviceType,
36}
37
38impl Default for ClientSettings {
39    fn default() -> Self {
40        Self {
41            identity_url: "https://identity.bitwarden.com".into(),
42            api_url: "https://api.bitwarden.com".into(),
43            user_agent: "Bitwarden Rust-SDK".into(),
44            device_type: DeviceType::SDK,
45        }
46    }
47}
48
49#[allow(non_camel_case_types)]
50#[derive(Serialize, Deserialize, Copy, Clone, Debug, JsonSchema)]
51#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
52#[cfg_attr(
53    feature = "wasm",
54    derive(tsify_next::Tsify),
55    tsify(into_wasm_abi, from_wasm_abi)
56)]
57pub enum DeviceType {
58    Android = 0,
59    iOS = 1,
60    ChromeExtension = 2,
61    FirefoxExtension = 3,
62    OperaExtension = 4,
63    EdgeExtension = 5,
64    WindowsDesktop = 6,
65    MacOsDesktop = 7,
66    LinuxDesktop = 8,
67    ChromeBrowser = 9,
68    FirefoxBrowser = 10,
69    OperaBrowser = 11,
70    EdgeBrowser = 12,
71    IEBrowser = 13,
72    UnknownBrowser = 14,
73    AndroidAmazon = 15,
74    UWP = 16,
75    SafariBrowser = 17,
76    VivaldiBrowser = 18,
77    VivaldiExtension = 19,
78    SafariExtension = 20,
79    SDK = 21,
80    Server = 22,
81    WindowsCLI = 23,
82    MacOsCLI = 24,
83    LinuxCLI = 25,
84}