mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 11:13:44 +00:00
fix set_keys callsite
This commit is contained in:
@@ -208,7 +208,10 @@ impl BitwardenDesktopAgent<BitwardenSshKey> {
|
||||
///
|
||||
/// This function panics if the underlying `RwLock` is poisoned or
|
||||
/// if the cipher's public key is not serializable to bytes.
|
||||
pub fn set_keys(&mut self, new_keys: &[(String, String, String)]) -> Result<(), anyhow::Error> {
|
||||
pub fn set_keys(
|
||||
&mut self,
|
||||
new_keys: &[(&String, &String, &String)],
|
||||
) -> Result<(), anyhow::Error> {
|
||||
if !self.is_running() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"[BitwardenDesktopAgent] Tried to set keys while agent is not running"
|
||||
@@ -232,8 +235,8 @@ impl BitwardenDesktopAgent<BitwardenSshKey> {
|
||||
public_key_bytes,
|
||||
BitwardenSshKey {
|
||||
private_key: Some(private_key),
|
||||
name: name.clone(),
|
||||
cipher_uuid: cipher_id.clone(),
|
||||
name: (*name).to_string(),
|
||||
cipher_uuid: (*cipher_id).to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -291,14 +291,13 @@ pub mod sshagent {
|
||||
agent_state: &mut SshAgentState,
|
||||
new_keys: Vec<PrivateKey>,
|
||||
) -> napi::Result<()> {
|
||||
let keys: Vec<_> = new_keys
|
||||
.iter()
|
||||
.map(|k| (&k.private_key, &k.name, &k.cipher_id))
|
||||
.collect();
|
||||
let bitwarden_agent_state = &mut agent_state.state;
|
||||
bitwarden_agent_state
|
||||
.set_keys(
|
||||
new_keys
|
||||
.iter()
|
||||
.map(|k| (k.private_key.clone(), k.name.clone(), k.cipher_id.clone()))
|
||||
.collect(),
|
||||
)
|
||||
.set_keys(&keys)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user