commit 03b939d03e3e2278b5c3458acde7a58820be2f83
parent 57af1ca39d58b2a5b9d6c8ed949b6dbf9c0e27dc
Author: triesap <triesap@radroots.dev>
Date: Mon, 19 Jan 2026 17:08:35 +0000
app: add keystore config wiring
- add AppKeystoreConfig with nostr store defaults
- include keystore config in AppConfig
- build nostr keystore using configured store
- add unit test for keystore default
Diffstat:
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/app/src/config.rs b/app/src/config.rs
@@ -2,6 +2,8 @@
use std::collections::BTreeMap;
+use radroots_app_core::idb::{RadrootsClientIdbConfig, IDB_CONFIG_KEYSTORE_NOSTR};
+
pub type AppDatastoreKeyParam = fn(&str) -> String;
pub type AppDatastoreKeyMap = BTreeMap<&'static str, &'static str>;
pub type AppDatastoreKeyParamMap = BTreeMap<&'static str, AppDatastoreKeyParam>;
@@ -24,15 +26,30 @@ impl AppKeyMapConfig {
}
}
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct AppKeystoreConfig {
+ pub nostr_store: RadrootsClientIdbConfig,
+}
+
+impl AppKeystoreConfig {
+ pub const fn default_config() -> Self {
+ Self {
+ nostr_store: IDB_CONFIG_KEYSTORE_NOSTR,
+ }
+ }
+}
+
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AppConfig {
pub key_maps: AppKeyMapConfig,
+ pub keystore: AppKeystoreConfig,
}
impl AppConfig {
pub fn empty() -> Self {
Self {
key_maps: AppKeyMapConfig::empty(),
+ keystore: AppKeystoreConfig::default_config(),
}
}
}
@@ -47,7 +64,14 @@ pub fn app_config_from_env() -> AppConfig {
#[cfg(test)]
mod tests {
- use super::{app_config_default, app_config_from_env, AppConfig, AppKeyMapConfig};
+ use super::{
+ app_config_default,
+ app_config_from_env,
+ AppConfig,
+ AppKeyMapConfig,
+ AppKeystoreConfig,
+ };
+ use radroots_app_core::idb::IDB_CONFIG_KEYSTORE_NOSTR;
#[test]
fn key_map_config_defaults_empty() {
@@ -69,4 +93,10 @@ mod tests {
let from_env = app_config_from_env();
assert_eq!(config, from_env);
}
+
+ #[test]
+ fn keystore_config_defaults_to_nostr_store() {
+ let config = AppKeystoreConfig::default_config();
+ assert_eq!(config.nostr_store, IDB_CONFIG_KEYSTORE_NOSTR);
+ }
}
diff --git a/app/src/init.rs b/app/src/init.rs
@@ -159,7 +159,7 @@ pub async fn app_init_backends(config: AppConfig) -> AppInitResult<AppBackends>
.init()
.await
.map_err(AppInitError::Datastore)?;
- let nostr_keystore = RadrootsClientWebKeystoreNostr::new(None);
+ let nostr_keystore = RadrootsClientWebKeystoreNostr::new(Some(config.keystore.nostr_store));
Ok(AppBackends {
config,
datastore,
diff --git a/app/src/lib.rs b/app/src/lib.rs
@@ -16,6 +16,7 @@ pub use config::{
AppDatastoreKeyObjMap,
AppDatastoreKeyParam,
AppDatastoreKeyParamMap,
+ AppKeystoreConfig,
AppKeyMapConfig,
};
pub use init::{