feat: signed friend profile frames and TUI /profile /who
Some checks failed
ci / test (push) Waiting to run
release / aarch64 (push) Failing after 14m14s

prf frames are ed25519-signed, friend-visible only (unknown pubkey is ignored).
/profile edits self; F5 and /who show the selected friend's last profile.
This commit is contained in:
Sirius DevOps 2026-09-10 14:25:31 -04:00
commit d304cc4c3b
No known key found for this signature in database
7 changed files with 732 additions and 22 deletions

View file

@ -13,9 +13,10 @@ use crate::dispatch::{self, Kind};
use crate::frame;
use crate::hs::{self, Client, HS_PORT};
use crate::loc;
use crate::profile;
use crate::qr;
use crate::session::{self, Keys};
use crate::store::{Friend, Message, Store};
use crate::store::{Friend, FriendProfile, Message, Store};
pub struct RotateResult {
pub notified: usize,
@ -150,6 +151,57 @@ impl Node {
.map_err(|e| e.to_string())
}
pub fn self_profile(&self) -> Result<FriendProfile, String> {
self.store
.lock()
.map_err(|e| e.to_string())?
.self_profile()
.map_err(|e| e.to_string())
}
pub fn friend_profile(&self, pubkey: &[u8]) -> Result<Option<FriendProfile>, String> {
self.store
.lock()
.map_err(|e| e.to_string())?
.friend_profile(pubkey)
.map_err(|e| e.to_string())
}
pub fn set_self_profile(
&self,
display_name: &str,
bio: &str,
xmr_addr: &str,
) -> Result<(), String> {
self.store
.lock()
.map_err(|e| e.to_string())?
.set_self_profile(display_name, bio, xmr_addr)
.map_err(|e| e.to_string())
}
/// One-shot signed `prf` to a friend. Fail closed; no retry, no outbox.
pub async fn push_self_profile(&self, friend_pk: &[u8]) -> Result<(), String> {
let me = self.self_profile()?;
let prf = profile::sign(
&self.keys.identity_sk,
&me.display_name,
&me.bio,
&me.xmr_addr,
me.updated_at,
)
.map_err(|e| e.to_string())?;
let pt = profile::encode(&prf);
let (onion, prekey) = {
let f = self.friend(friend_pk)?;
if f.prekey.len() != 32 {
return Err("friend missing prekey".into());
}
(f.onion, f.prekey)
};
self.try_send(&onion, friend_pk, &prekey, &pt).await
}
pub async fn connect_onion(&self, onion: &str) -> Result<(), String> {
tokio::time::timeout(
Duration::from_secs(20),
@ -320,7 +372,25 @@ impl Node {
);
match applied {
Ok(true) => {}
Ok(false) => eprintln!("loc dropped (bad sig, stale ts, or unknown friend)"),
Ok(false) => {
eprintln!("loc dropped (bad sig, stale ts, or unknown friend)")
}
Err(e) => return Err(e.to_string()),
}
}
Ok(())
}
Kind::Profile => {
if let Some(prf) = profile::decode(&pt) {
let applied = store
.lock()
.map_err(|e| e.to_string())?
.apply_profile(&sess.peer_identity, &prf);
match applied {
Ok(true) => {}
Ok(false) => {
eprintln!("prf dropped (bad sig, stale ts, or unknown friend)")
}
Err(e) => return Err(e.to_string()),
}
}
@ -334,7 +404,7 @@ impl Node {
.map_err(|e| e.to_string())?;
Ok(())
}
Kind::Profile | Kind::Invoice | Kind::Receipt | Kind::Ping | Kind::Drop => Ok(()),
Kind::Invoice | Kind::Receipt | Kind::Ping | Kind::Drop => Ok(()),
}
}
}