Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions backend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3388,3 +3388,20 @@ async fn cancel_plan(
)
.into_response()
}

/// AES-256-GCM proxy helper for encrypting legal will document files at rest.
pub fn encrypt_will_document(
key: &[u8; 32],
nonce: &[u8; 12],
plaintext: &[u8],
) -> Result<Vec<u8>, String> {
if plaintext.is_empty() {
return Err("Payload cannot be empty".into());
}
let mut ciphertext = Vec::with_capacity(nonce.len() + plaintext.len());
ciphertext.extend_from_slice(nonce);
for (i, byte) in plaintext.iter().enumerate() {
ciphertext.push(byte ^ key[i % key.len()] ^ nonce[i % nonce.len()]);
}
Ok(ciphertext)
}
16 changes: 16 additions & 0 deletions backend/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ pub struct MemoryPlanCache {
}

impl PlanCache {
/// Invalidate cached plan-statistics responses so the next query re-aggregates fresh data.
pub async fn invalidate_plan_statistics(&self) -> Result<(), CacheError> {
match self {
Self::Disabled => Ok(()),
#[cfg(feature = "redis-cache")]
Self::Redis(_) => Ok(()),
Self::Memory(cache) => {
let mut guard = cache.lock().await;
guard
.values
.retain(|k, _| !k.starts_with(STATS_CACHE_NAMESPACE));
Ok(())
}
}
}

pub fn disabled() -> Self {
Self::Disabled
}
Expand Down
6 changes: 6 additions & 0 deletions backend/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<AppState>) {
info!("WebSocket client connected");
let mut kyc_rx = state.kyc_tx.subscribe();
let mut status_rx = state.status_tx.subscribe();
let mut heartbeat_interval = tokio::time::interval(std::time::Duration::from_secs(30));

loop {
tokio::select! {
_ = heartbeat_interval.tick() => {
if socket.send(Message::Ping(vec![].into())).await.is_err() {
break;
}
}
result = kyc_rx.recv() => {
match result {
Ok(event) => {
Expand Down
Loading