From c5d01a97ae4fda0871c8fd49777be325376ba5df Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 25 Jul 2020 03:08:53 -0400 Subject: add totp, uris, and custom fields to --full output --- src/api.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/api.rs') diff --git a/src/api.rs b/src/api.rs index 6ee77ca..aca87b0 100644 --- a/src/api.rs +++ b/src/api.rs @@ -139,6 +139,8 @@ struct SyncResCipher { notes: Option, #[serde(rename = "PasswordHistory")] password_history: Option>, + #[serde(rename = "Fields")] + fields: Option>, } impl SyncResCipher { @@ -172,6 +174,7 @@ impl SyncResCipher { crate::db::EntryData::Login { username: login.username.clone(), password: login.password.clone(), + totp: login.totp.clone(), uris: login.uris.as_ref().map_or_else( std::vec::Vec::new, |uris| { @@ -215,6 +218,17 @@ impl SyncResCipher { } else { return None; }; + let fields = if let Some(fields) = &self.fields { + fields + .iter() + .map(|field| crate::db::Field { + name: field.name.clone(), + value: field.value.clone(), + }) + .collect() + } else { + vec![] + }; Some(crate::db::Entry { id: self.id.clone(), org_id: self.organization_id.clone(), @@ -222,6 +236,7 @@ impl SyncResCipher { folder_id: folder_id.map(std::string::ToString::to_string), name: self.name.clone(), data, + fields, notes: self.notes.clone(), history, }) @@ -260,6 +275,8 @@ struct CipherLogin { username: Option, #[serde(rename = "Password")] password: Option, + #[serde(rename = "Totp")] + totp: Option, #[serde(rename = "Uris")] uris: Option>, } @@ -337,6 +354,16 @@ struct SyncResPasswordHistory { password: String, } +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +struct SyncResField { + #[serde(rename = "Type")] + ty: u32, + #[serde(rename = "Name")] + name: Option, + #[serde(rename = "Value")] + value: Option, +} + #[derive(serde::Serialize, Debug)] struct CiphersPostReq { #[serde(rename = "type")] @@ -546,6 +573,7 @@ impl Client { crate::db::EntryData::Login { username, password, + totp, uris, } => { let uris = if uris.is_empty() { @@ -562,6 +590,7 @@ impl Client { req.login = Some(CipherLogin { username: username.clone(), password: password.clone(), + totp: totp.clone(), uris, }) } @@ -676,6 +705,7 @@ impl Client { crate::db::EntryData::Login { username, password, + totp, uris, } => { let uris = if uris.is_empty() { @@ -692,6 +722,7 @@ impl Client { req.login = Some(CipherLogin { username: username.clone(), password: password.clone(), + totp: totp.clone(), uris, }); } -- cgit v1.2.3-54-g00ecf