Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(storage): update document storage dependencies

Steven Enamakel315d4c6a2402
diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs
index d13164c95e..ae3569f03b 100644
--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs
+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs
@@ -16,6 +16,22 @@ pub const MASTER_KEY_ENV: &str = "OPENHUMAN_KEYRING_MASTER_KEY";
pub const MASTER_KEY_FILE_ENV: &str = "OPENHUMAN_KEYRING_MASTER_KEY_FILE";
const KEY_LEN: usize = 32;
+/// Decode the same operator-supplied master-key form as the enabled backend.
+fn parse_master_key_hex(hex: &str) -> Result<[u8; KEY_LEN], String> {
+ let expected = 2 * KEY_LEN;
+ let got = hex.chars().count();
+ if got != expected {
+ return Err(format!("expected {expected} hex characters, got {got}"));
+ }
+ if !hex.is_ascii() {
+ return Err("value is not valid hex".to_string());
+ }
+ let bytes = crypto::hex_decode(hex).map_err(|_| "value is not valid hex".to_string())?;
+ let mut key = [0u8; KEY_LEN];
+ key.copy_from_slice(&bytes);
+ Ok(key)
+}
+
#[path = "encrypted_file_backend/key_source.rs"]
pub mod key_source;
pub use key_source::{
diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rs
index 0283b1b345..a96d0fa28e 100644
--- a/crates/openhuman-core/src/storage/documents.rs
+++ b/crates/openhuman-core/src/storage/documents.rs
@@ -14,7 +14,7 @@ use std::sync::{Arc, LazyLock, Mutex, PoisonError, Weak};
use anyhow::{anyhow, Context, Result};
use serde_json::Value;
-use tinystoragedrivers::{CollectionSpec, ErrorKind, Versioned};
+use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition, Versioned};
use super::{
block_on, current_scope, installed, DocumentStore, Scope, Storage, StorageBackend, StorageError,