use crate::error::AppError;
use crate::secrets::SecretsManager;

#[tauri::command]
pub fn secrets_store(key: String, value: String) -> Result<(), AppError> {
    SecretsManager::store_secret(&key, &value).map_err(AppError::auth)
}

#[tauri::command]
pub fn secrets_get(key: String) -> Result<Option<String>, AppError> {
    SecretsManager::get_secret(&key).map_err(AppError::auth)
}

#[tauri::command]
pub fn secrets_delete(key: String) -> Result<(), AppError> {
    SecretsManager::delete_secret(&key).map_err(AppError::auth)
}

#[tauri::command]
pub fn secrets_list() -> Result<Vec<String>, AppError> {
    SecretsManager::list_keys().map_err(AppError::auth)
}

#[tauri::command]
pub fn secrets_has_keyring() -> bool {
    SecretsManager::has_keyring()
}

#[tauri::command]
pub fn secrets_known_keys() -> Vec<String> {
    crate::secrets::KNOWN_KEYS
        .iter()
        .map(|s| s.to_string())
        .collect()
}
