Merge pull request 't_2fb507c6: F8 rotate prekey (Node::rotate_prekey + invite re-encode)' (#101) from wt/t_2fb507c6 into main
Reviewed-on: #101
This commit is contained in:
commit
24b5c93c43
7 changed files with 177 additions and 2 deletions
63
src/tui.rs
63
src/tui.rs
|
|
@ -491,6 +491,17 @@ Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
|||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
|
||||
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
|
||||
/// invite re-syncs a friend.
|
||||
pub fn prekey_screen_text() -> &'static str {
|
||||
"Rotate prekey?\n\
|
||||
Your identity and onion stay the same.\n\
|
||||
Every friend must F3-paste your new invite to pick up the new prekey,\n\
|
||||
or you cannot reach them and they cannot reach you.\n\
|
||||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
pub fn quit_screen_text() -> &'static str {
|
||||
"Quit OnionWire?\n\
|
||||
Message history can be cleared; identity and friends stay.\n\
|
||||
|
|
@ -535,6 +546,7 @@ OnionWire keys\n\
|
|||
F4 rotate onion locator\n\
|
||||
F5 selected friend's profile (/who)\n\
|
||||
F6 wallet (receive QR, create/import)\n\
|
||||
F8 rotate prekey\n\
|
||||
/profile edit name, bio, Monero address\n\
|
||||
/pay <xmr> [memo] invoice to receive\n\
|
||||
/tip <xmr> [memo] pay selected friend\n\
|
||||
|
|
@ -1185,6 +1197,9 @@ enum Screen {
|
|||
Rotate {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
RotatePrekey {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
Wipe {
|
||||
kind: WipeKind,
|
||||
prompt: WipePrompt,
|
||||
|
|
@ -1324,6 +1339,11 @@ impl App {
|
|||
}
|
||||
KeyCode::F(5) => self.who_open = true,
|
||||
KeyCode::F(6) => self.open_wallet()?,
|
||||
KeyCode::F(8) => {
|
||||
self.screen = Screen::RotatePrekey {
|
||||
prompt: RotatePrompt::new(),
|
||||
};
|
||||
}
|
||||
KeyCode::Esc => self.composer.clear(),
|
||||
KeyCode::Backspace => {
|
||||
if self.focus == Pane::Composer {
|
||||
|
|
@ -1443,6 +1463,18 @@ impl App {
|
|||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::RotatePrekey { prompt } => match key.code {
|
||||
KeyCode::Esc => self.screen = Screen::Main,
|
||||
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
if prompt.on_char(c) == RotateDecision::Confirm {
|
||||
self.confirm_rotate_prekey()?;
|
||||
}
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
prompt.on_char('\u{8}');
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::Wipe { kind, prompt } => {
|
||||
let kind = *kind;
|
||||
match key.code {
|
||||
|
|
@ -1715,6 +1747,24 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
|
||||
/// only travels inside a fresh signed invite — so the screen goes straight
|
||||
/// to that invite (the F2 share path) for the user to hand out.
|
||||
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
|
||||
match self.node.rotate_prekey() {
|
||||
Ok(_) => {
|
||||
self.status_note =
|
||||
Some("prekey rotated · friends must F3-paste your new invite".into());
|
||||
self.open_share()
|
||||
}
|
||||
Err(e) => {
|
||||
self.alert = Some(e);
|
||||
self.screen = Screen::Main;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn open_share(&mut self) -> Result<(), String> {
|
||||
let payload = self.node.qr_payload()?;
|
||||
self.screen = Screen::Share { payload };
|
||||
|
|
@ -2092,6 +2142,7 @@ impl App {
|
|||
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
||||
Screen::Approve { payload } => draw_approve(f, payload),
|
||||
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
||||
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
|
||||
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
||||
Screen::Profile { editor } => draw_profile(f, editor),
|
||||
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
||||
|
|
@ -2410,6 +2461,7 @@ match screen {
|
|||
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
||||
Screen::Approve { .. } => "y accept n reject ? help",
|
||||
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::Wipe { kind, .. } => match kind {
|
||||
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
||||
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
||||
|
|
@ -2510,6 +2562,17 @@ fn draw_rotate(f: &mut Frame, typed: &str) {
|
|||
);
|
||||
}
|
||||
|
||||
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
|
||||
let body = format!("{}\n\n{typed}", prekey_screen_text());
|
||||
f.render_widget(
|
||||
Paragraph::new(body)
|
||||
.style(style_text())
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(themed_block("(o) rotate prekey")),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
||||
let title = match kind {
|
||||
WipeKind::Messages => "(o) wipe",
|
||||
|
|
|
|||
Loading…
Reference in a new issue