bitwarden_importers/importers/onepassword/access/credentials.rs
1//! The credentials a password login needs.
2
3use zeroize::Zeroize;
4
5use super::sign_in::SignInAddress;
6
7/// The credentials for a password + Secret Key login.
8///
9/// Deliberately neither `Debug` nor `Serialize`: it holds the master password and Secret Key.
10#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
11#[cfg_attr(
12 feature = "wasm",
13 derive(serde::Deserialize, tsify::Tsify),
14 tsify(from_wasm_abi)
15)]
16#[derive(Clone)]
17pub struct Credentials {
18 /// The account's email address.
19 pub username: String,
20 /// The account's master password.
21 pub password: String,
22 /// The account's Secret Key (Account Key), such as `A3-XXXXXX-...`.
23 pub account_key: String,
24 /// Where the account signs in, such as `my.1password.com`.
25 pub sign_in_address: SignInAddress,
26}
27
28impl Zeroize for Credentials {
29 fn zeroize(&mut self) {
30 self.password.zeroize();
31 self.account_key.zeroize();
32 }
33}
34
35// UniFFI records are lowered by moving out their fields, which Rust does not allow for a type that
36// implements `Drop`. The access client owns the lowered record in a zeroizing guard instead.
37#[cfg(not(feature = "uniffi"))]
38impl Drop for Credentials {
39 fn drop(&mut self) {
40 self.zeroize();
41 }
42}