1
0
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:
neuronull
2025-10-17 14:09:25 -06:00
parent 9b1cba4652
commit eebd91f9c9
2 changed files with 11 additions and 9 deletions

View File

@@ -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(),
},
);
}

View File

@@ -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(())
}