fix(desktop): batch keychain reads to reduce macOS password prompts

Add get_all_secrets command that reads all 18 keys in a single IPC call.
This triggers one Keychain prompt instead of 18 on fresh installs.
This commit is contained in:
Elie Habib
2026-02-17 00:24:44 +04:00
parent 631a5e2112
commit 65dea2e4f9
2 changed files with 27 additions and 10 deletions

View File

@@ -113,6 +113,21 @@ fn get_secret(key: String) -> Result<Option<String>, String> {
}
}
#[tauri::command]
fn get_all_secrets() -> std::collections::HashMap<String, String> {
let mut result = std::collections::HashMap::new();
for key in SUPPORTED_SECRET_KEYS.iter() {
if let Ok(entry) = Entry::new(KEYRING_SERVICE, key) {
if let Ok(value) = entry.get_password() {
if !value.trim().is_empty() {
result.insert((*key).to_string(), value.trim().to_string());
}
}
}
}
result
}
#[tauri::command]
fn set_secret(key: String, value: String) -> Result<(), String> {
let entry = secret_entry(&key)?;
@@ -682,6 +697,7 @@ fn main() {
.invoke_handler(tauri::generate_handler![
list_supported_secret_keys,
get_secret,
get_all_secrets,
set_secret,
delete_secret,
get_local_api_token,