#[cfg(target_os = "macos")]
pub fn install_default_store() -> keyring_core::Result<()> {
let store = apple_native_keyring_store::keychain::Store::new()?;
keyring_core::set_default_store(store);
Ok(())
}
#[cfg(target_os = "linux")]
pub fn install_default_store() -> keyring_core::Result<()> {
let store = dbus_secret_service_keyring_store::Store::new()?;
keyring_core::set_default_store(store);
Ok(())
}
#[cfg(target_os = "windows")]
pub fn install_default_store() -> keyring_core::Result<()> {
let store = windows_native_keyring_store::Store::new()?;
keyring_core::set_default_store(store);
Ok(())
}
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
compile_error!(
"vta-sdk `keyring` feature requires target_os in (macos, linux, windows). \
Disable the feature or build for a supported OS."
);
pub fn install_default_store_or_exit(tool: &str) {
use crate::secure_store::{self, SecureStore};
let selected = match secure_store::override_from_env() {
Ok(v) => v,
Err(msg) => {
eprintln!("error: {msg}");
std::process::exit(1);
}
};
if selected == Some(SecureStore::File) {
return;
}
if let Err(e) = install_default_store() {
eprintln!("{}", secure_store::unavailable_message(tool, &e));
std::process::exit(1);
}
}
pub fn warn_store_unavailable(tool: &str) {
if let Err(e) = install_default_store() {
eprintln!(
"warning: the OS credential store is unavailable: {e}\n\
\n\
{tool} will still start. This is fatal only if `[secrets] backend` \
resolves to the keyring — that path fails closed and will refuse to \
read or write the master seed rather than report it missing. Any \
other backend (aws, gcp, azure, vault, k8s, tee-kms) is unaffected."
);
}
}