Add rustfmt.toml (same as core and server) and apply cargo fmt
Formatting only. CI now runs cargo fmt --check here as in the other Rust repos. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
max_width = 120
|
||||||
|
use_small_heuristics = "Max"
|
||||||
@@ -135,7 +135,9 @@ mod platform {
|
|||||||
mod platform {
|
mod platform {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use windows_sys::Win32::System::StationsAndDesktops::{CloseDesktop, OpenInputDesktop, SwitchDesktop, DESKTOP_SWITCHDESKTOP};
|
use windows_sys::Win32::System::StationsAndDesktops::{
|
||||||
|
CloseDesktop, OpenInputDesktop, SwitchDesktop, DESKTOP_SWITCHDESKTOP,
|
||||||
|
};
|
||||||
use windows_sys::Win32::System::SystemInformation::GetTickCount;
|
use windows_sys::Win32::System::SystemInformation::GetTickCount;
|
||||||
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{GetLastInputInfo, LASTINPUTINFO};
|
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{GetLastInputInfo, LASTINPUTINFO};
|
||||||
|
|
||||||
|
|||||||
+21
-8
@@ -230,7 +230,8 @@ impl Broker {
|
|||||||
Some("ping") => json!({ "t": "pong", "version": env!("CARGO_PKG_VERSION") }),
|
Some("ping") => json!({ "t": "pong", "version": env!("CARGO_PKG_VERSION") }),
|
||||||
Some("pair_init") => {
|
Some("pair_init") => {
|
||||||
let Some(ext_pub) = v.get("pub").and_then(b64_array::<32>) else { return outer_err("bad_request") };
|
let Some(ext_pub) = v.get("pub").and_then(b64_array::<32>) else { return outer_err("bad_request") };
|
||||||
let name: String = v.get("name").and_then(Value::as_str).unwrap_or("Browser").chars().take(80).collect();
|
let name: String =
|
||||||
|
v.get("name").and_then(Value::as_str).unwrap_or("Browser").chars().take(80).collect();
|
||||||
self.pair_init(conn, &ext_pub, name).unwrap_or_else(|| outer_err("bad_request"))
|
self.pair_init(conn, &ext_pub, name).unwrap_or_else(|| outer_err("bad_request"))
|
||||||
}
|
}
|
||||||
Some("pair_confirm") => {
|
Some("pair_confirm") => {
|
||||||
@@ -268,7 +269,9 @@ impl Broker {
|
|||||||
let parsed: Option<Value> = serde_json::from_slice(&pt).ok();
|
let parsed: Option<Value> = serde_json::from_slice(&pt).ok();
|
||||||
drop(pt);
|
drop(pt);
|
||||||
let (rid, body) = match &parsed {
|
let (rid, body) = match &parsed {
|
||||||
Some(p) => (p.get("rid").cloned().unwrap_or(Value::Null), p.get("body").cloned().unwrap_or(Value::Null)),
|
Some(p) => {
|
||||||
|
(p.get("rid").cloned().unwrap_or(Value::Null), p.get("body").cloned().unwrap_or(Value::Null))
|
||||||
|
}
|
||||||
None => (Value::Null, Value::Null),
|
None => (Value::Null, Value::Null),
|
||||||
};
|
};
|
||||||
let reply = Zeroizing::new(
|
let reply = Zeroizing::new(
|
||||||
@@ -397,7 +400,9 @@ impl Broker {
|
|||||||
self.ui.activity();
|
self.ui.activity();
|
||||||
match self.matching_item(&origin, id) {
|
match self.matching_item(&origin, id) {
|
||||||
Ok(d) => match d.totp.as_deref().map(|t| kv_ffi::totp_code(t.to_string(), now_secs())) {
|
Ok(d) => match d.totp.as_deref().map(|t| kv_ffi::totp_code(t.to_string(), now_secs())) {
|
||||||
Some(Ok(c)) => json!({ "type": "totp", "code": c.code, "secondsRemaining": c.seconds_remaining }),
|
Some(Ok(c)) => {
|
||||||
|
json!({ "type": "totp", "code": c.code, "secondsRemaining": c.seconds_remaining })
|
||||||
|
}
|
||||||
_ => err("bad_request"),
|
_ => err("bad_request"),
|
||||||
},
|
},
|
||||||
Err(v) => v,
|
Err(v) => v,
|
||||||
@@ -622,7 +627,8 @@ mod tests {
|
|||||||
fn unpaired_and_revoked_extensions_are_refused() {
|
fn unpaired_and_revoked_extensions_are_refused() {
|
||||||
let (b, _) = broker_with_item();
|
let (b, _) = broker_with_item();
|
||||||
let mut conn = Conn { caller: String::new(), session: None };
|
let mut conn = Conn { caller: String::new(), session: None };
|
||||||
let r = b.handle_frame(&mut conn, &json!({ "t": "open", "pairing_id": "nope", "nonce": B64.encode([0u8; 16]) }));
|
let r =
|
||||||
|
b.handle_frame(&mut conn, &json!({ "t": "open", "pairing_id": "nope", "nonce": B64.encode([0u8; 16]) }));
|
||||||
assert_eq!(r["code"], "not_paired");
|
assert_eq!(r["code"], "not_paired");
|
||||||
let r = b.handle_frame(&mut conn, &json!({ "t": "msg", "n": 0, "c": "AAAA" }));
|
let r = b.handle_frame(&mut conn, &json!({ "t": "msg", "n": 0, "c": "AAAA" }));
|
||||||
assert_eq!(r["code"], "bad_session");
|
assert_eq!(r["code"], "bad_session");
|
||||||
@@ -641,7 +647,8 @@ mod tests {
|
|||||||
let ext = Ephemeral::generate();
|
let ext = Ephemeral::generate();
|
||||||
let r = b.handle_frame(&mut conn, &json!({ "t": "pair_init", "pub": B64.encode(ext.public) }));
|
let r = b.handle_frame(&mut conn, &json!({ "t": "pair_init", "pub": B64.encode(ext.public) }));
|
||||||
let id = r["pairing_id"].as_str().unwrap().to_string();
|
let id = r["pairing_id"].as_str().unwrap().to_string();
|
||||||
let r = b.handle_frame(&mut conn, &json!({ "t": "pair_confirm", "pairing_id": id, "proof": B64.encode([0u8; 40]) }));
|
let r = b
|
||||||
|
.handle_frame(&mut conn, &json!({ "t": "pair_confirm", "pairing_id": id, "proof": B64.encode([0u8; 40]) }));
|
||||||
assert_eq!(r["code"], "not_paired");
|
assert_eq!(r["code"], "not_paired");
|
||||||
b.core().lock();
|
b.core().lock();
|
||||||
assert!(b.resolve_pairing(&id, true).is_err());
|
assert!(b.resolve_pairing(&id, true).is_err());
|
||||||
@@ -652,16 +659,22 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn save_prompts_then_creates_or_updates() {
|
fn save_prompts_then_creates_or_updates() {
|
||||||
let (b, id) = broker_with_item();
|
let (b, id) = broker_with_item();
|
||||||
let r = b.handle_request(&json!({ "type": "save", "origin": "https://example.com", "username": "alice", "password": "s3cret" }));
|
let r = b.handle_request(
|
||||||
|
&json!({ "type": "save", "origin": "https://example.com", "username": "alice", "password": "s3cret" }),
|
||||||
|
);
|
||||||
assert_eq!(r["type"], "saved"); // identical: nothing to ask
|
assert_eq!(r["type"], "saved"); // identical: nothing to ask
|
||||||
let r = b.handle_request(&json!({ "type": "save", "origin": "https://example.com/login", "username": "alice", "password": "new" }));
|
let r = b.handle_request(
|
||||||
|
&json!({ "type": "save", "origin": "https://example.com/login", "username": "alice", "password": "new" }),
|
||||||
|
);
|
||||||
assert_eq!(r["type"], "save_prompted");
|
assert_eq!(r["type"], "save_prompted");
|
||||||
let views = b.pending_saves();
|
let views = b.pending_saves();
|
||||||
assert_eq!((views.len(), views[0].update, views[0].origin.as_str()), (1, true, "https://example.com"));
|
assert_eq!((views.len(), views[0].update, views[0].origin.as_str()), (1, true, "https://example.com"));
|
||||||
assert_eq!(b.resolve_save(&views[0].id, true).unwrap().as_deref(), Some(id.as_str()));
|
assert_eq!(b.resolve_save(&views[0].id, true).unwrap().as_deref(), Some(id.as_str()));
|
||||||
assert_eq!(b.core().get_item(id).unwrap().password.as_deref(), Some("new"));
|
assert_eq!(b.core().get_item(id).unwrap().password.as_deref(), Some("new"));
|
||||||
|
|
||||||
b.handle_request(&json!({ "type": "save", "origin": "https://new.example.org", "username": "bob", "password": "pw" }));
|
b.handle_request(
|
||||||
|
&json!({ "type": "save", "origin": "https://new.example.org", "username": "bob", "password": "pw" }),
|
||||||
|
);
|
||||||
let v = b.pending_saves().pop().unwrap();
|
let v = b.pending_saves().pop().unwrap();
|
||||||
assert!(!v.update);
|
assert!(!v.update);
|
||||||
let new_id = b.resolve_save(&v.id, true).unwrap().unwrap();
|
let new_id = b.resolve_save(&v.id, true).unwrap().unwrap();
|
||||||
|
|||||||
@@ -77,11 +77,8 @@ pub struct Pairing {
|
|||||||
|
|
||||||
impl Pairing {
|
impl Pairing {
|
||||||
pub fn derive(shared: &[u8; 32], ext_pub: &[u8; 32], app_pub: &[u8; 32]) -> Self {
|
pub fn derive(shared: &[u8; 32], ext_pub: &[u8; 32], app_pub: &[u8; 32]) -> Self {
|
||||||
let salt = Sha256::new()
|
let salt =
|
||||||
.chain_update(b"kestrove/v1/pair")
|
Sha256::new().chain_update(b"kestrove/v1/pair").chain_update(ext_pub).chain_update(app_pub).finalize();
|
||||||
.chain_update(ext_pub)
|
|
||||||
.chain_update(app_pub)
|
|
||||||
.finalize();
|
|
||||||
let hk = Hkdf::<Sha256>::new(Some(&salt), shared);
|
let hk = Hkdf::<Sha256>::new(Some(&salt), shared);
|
||||||
let mut key = Zeroizing::new([0u8; 32]);
|
let mut key = Zeroizing::new([0u8; 32]);
|
||||||
hk.expand(b"kestrove/v1/pair/key", key.as_mut()).expect("32 bytes is a valid HKDF length");
|
hk.expand(b"kestrove/v1/pair/key", key.as_mut()).expect("32 bytes is a valid HKDF length");
|
||||||
|
|||||||
@@ -389,15 +389,7 @@ mod imp {
|
|||||||
let name = wide(&pipe_name());
|
let name = wide(&pipe_name());
|
||||||
// SAFETY: name is NUL-terminated; the handle is owned by File on success.
|
// SAFETY: name is NUL-terminated; the handle is owned by File on success.
|
||||||
let h = unsafe {
|
let h = unsafe {
|
||||||
CreateFileW(
|
CreateFileW(name.as_ptr(), GENERIC_READ | GENERIC_WRITE, 0, ptr::null(), OPEN_EXISTING, 0, ptr::null_mut())
|
||||||
name.as_ptr(),
|
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
|
||||||
0,
|
|
||||||
ptr::null(),
|
|
||||||
OPEN_EXISTING,
|
|
||||||
0,
|
|
||||||
ptr::null_mut(),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
if h == INVALID_HANDLE_VALUE {
|
if h == INVALID_HANDLE_VALUE {
|
||||||
return Err(io::Error::last_os_error());
|
return Err(io::Error::last_os_error());
|
||||||
|
|||||||
+10
-5
@@ -223,7 +223,15 @@ fn list_items(app: State<'_, App>) -> CmdResult<Vec<Summary>> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn get_item(app: State<'_, App>, id: String) -> CmdResult<Detail> {
|
fn get_item(app: State<'_, App>, id: String) -> CmdResult<Detail> {
|
||||||
let d = app.core.get_item(id).map_err(err)?;
|
let d = app.core.get_item(id).map_err(err)?;
|
||||||
Ok(Detail { id: d.id, title: d.title, username: d.username, password: d.password, urls: d.urls, totp: d.totp, notes: d.notes })
|
Ok(Detail {
|
||||||
|
id: d.id,
|
||||||
|
title: d.title,
|
||||||
|
username: d.username,
|
||||||
|
password: d.password,
|
||||||
|
urls: d.urls,
|
||||||
|
totp: d.totp,
|
||||||
|
notes: d.notes,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -282,10 +290,7 @@ fn copy_secret(app: State<'_, App>, id: String, field: Option<String>) -> CmdRes
|
|||||||
cb.set().exclude_from_monitoring().exclude_from_cloud().exclude_from_history().text(secret.to_string())
|
cb.set().exclude_from_monitoring().exclude_from_cloud().exclude_from_history().text(secret.to_string())
|
||||||
}
|
}
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{ cb.set_text(secret.to_string()) }.map_err(|e| e.to_string())?;
|
||||||
cb.set_text(secret.to_string())
|
|
||||||
}
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
thread::sleep(CLIPBOARD_CLEAR);
|
thread::sleep(CLIPBOARD_CLEAR);
|
||||||
|
|||||||
+22
-32
@@ -2,38 +2,28 @@
|
|||||||
//! The same list, in the same order, is in kestrove-browser/src/words.ts.
|
//! The same list, in the same order, is in kestrove-browser/src/words.ts.
|
||||||
|
|
||||||
pub const WORDS: [&str; 256] = [
|
pub const WORDS: [&str; 256] = [
|
||||||
"acid", "acorn", "actor", "adult", "agent", "alarm", "album", "alley",
|
"acid", "acorn", "actor", "adult", "agent", "alarm", "album", "alley", "amber", "angle", "ankle", "apple", "april",
|
||||||
"amber", "angle", "ankle", "apple", "april", "apron", "arena", "armor",
|
"apron", "arena", "armor", "arrow", "atlas", "attic", "audio", "aunt", "autumn", "award", "bacon", "badge",
|
||||||
"arrow", "atlas", "attic", "audio", "aunt", "autumn", "award", "bacon",
|
"bagel", "baker", "bamboo", "banjo", "barn", "basil", "basket", "beach", "beard", "beetle", "bell", "bench",
|
||||||
"badge", "bagel", "baker", "bamboo", "banjo", "barn", "basil", "basket",
|
"berry", "bike", "birch", "bison", "blade", "blanket", "blimp", "bloom", "boat", "bonus", "boot", "bottle",
|
||||||
"beach", "beard", "beetle", "bell", "bench", "berry", "bike", "birch",
|
"boxer", "brain", "brick", "bridge", "broom", "brush", "bucket", "bugle", "cabin", "cable", "cactus", "camel",
|
||||||
"bison", "blade", "blanket", "blimp", "bloom", "boat", "bonus", "boot",
|
"camera", "canal", "candle", "canoe", "canyon", "carbon", "cargo", "carpet", "castle", "cedar", "cello", "chalk",
|
||||||
"bottle", "boxer", "brain", "brick", "bridge", "broom", "brush", "bucket",
|
"cherry", "chess", "chief", "cider", "cinema", "circus", "clay", "cliff", "clock", "cloud", "clover", "cobra",
|
||||||
"bugle", "cabin", "cable", "cactus", "camel", "camera", "canal", "candle",
|
"cocoa", "comet", "coral", "cotton", "cousin", "coyote", "crane", "crayon", "cricket", "crown", "cup", "daisy",
|
||||||
"canoe", "canyon", "carbon", "cargo", "carpet", "castle", "cedar", "cello",
|
"dancer", "delta", "denim", "desert", "diary", "diesel", "dingo", "disco", "doctor", "dolphin", "donkey", "dragon",
|
||||||
"chalk", "cherry", "chess", "chief", "cider", "cinema", "circus", "clay",
|
"drum", "duck", "eagle", "earth", "easel", "echo", "eclipse", "elbow", "elder", "ember", "emerald", "engine",
|
||||||
"cliff", "clock", "cloud", "clover", "cobra", "cocoa", "comet", "coral",
|
"falcon", "fang", "farmer", "feather", "fence", "ferry", "fiddle", "finch", "flag", "flute", "forest", "fossil",
|
||||||
"cotton", "cousin", "coyote", "crane", "crayon", "cricket", "crown", "cup",
|
"fox", "frost", "galaxy", "garden", "garlic", "gecko", "ghost", "ginger", "giraffe", "glacier", "globe", "goat",
|
||||||
"daisy", "dancer", "delta", "denim", "desert", "diary", "diesel", "dingo",
|
"gold", "gorilla", "grape", "gravel", "guitar", "hammer", "harbor", "harp", "hawk", "hazel", "helmet", "heron",
|
||||||
"disco", "doctor", "dolphin", "donkey", "dragon", "drum", "duck", "eagle",
|
"hiker", "honey", "hornet", "hotel", "igloo", "index", "iris", "island", "ivory", "jacket", "jaguar", "jelly",
|
||||||
"earth", "easel", "echo", "eclipse", "elbow", "elder", "ember", "emerald",
|
"jewel", "jungle", "kayak", "kettle", "kitten", "koala", "ladder", "lagoon", "lake", "lantern", "laser", "lemon",
|
||||||
"engine", "falcon", "fang", "farmer", "feather", "fence", "ferry", "fiddle",
|
"lentil", "lily", "lion", "lizard", "lobster", "locket", "lotus", "magnet", "mango", "maple", "marble", "meadow",
|
||||||
"finch", "flag", "flute", "forest", "fossil", "fox", "frost", "galaxy",
|
"melon", "mint", "mirror", "monkey", "moose", "mosaic", "motor", "mountain", "mulberry", "museum", "napkin",
|
||||||
"garden", "garlic", "gecko", "ghost", "ginger", "giraffe", "glacier", "globe",
|
"nectar", "needle", "nickel", "noodle", "novel", "nugget", "oasis", "ocean", "olive", "onion", "orange", "orbit",
|
||||||
"goat", "gold", "gorilla", "grape", "gravel", "guitar", "hammer", "harbor",
|
"orchid", "otter", "owl", "oyster", "paddle", "palace", "panda", "paper", "parrot", "peach", "pebble", "pepper",
|
||||||
"harp", "hawk", "hazel", "helmet", "heron", "hiker", "honey", "hornet",
|
"piano", "pickle", "pilot", "pine", "planet", "plum", "poem", "pony", "puzzle", "quartz", "quill", "rabbit",
|
||||||
"hotel", "igloo", "index", "iris", "island", "ivory", "jacket", "jaguar",
|
"radar", "radio", "raven", "ribbon", "river", "robin", "rocket", "rose", "ruby", "saddle", "salmon", "sandal",
|
||||||
"jelly", "jewel", "jungle", "kayak", "kettle", "kitten", "koala", "ladder",
|
"satin", "scarf", "scout", "sugar",
|
||||||
"lagoon", "lake", "lantern", "laser", "lemon", "lentil", "lily", "lion",
|
|
||||||
"lizard", "lobster", "locket", "lotus", "magnet", "mango", "maple", "marble",
|
|
||||||
"meadow", "melon", "mint", "mirror", "monkey", "moose", "mosaic", "motor",
|
|
||||||
"mountain", "mulberry", "museum", "napkin", "nectar", "needle", "nickel", "noodle",
|
|
||||||
"novel", "nugget", "oasis", "ocean", "olive", "onion", "orange", "orbit",
|
|
||||||
"orchid", "otter", "owl", "oyster", "paddle", "palace", "panda", "paper",
|
|
||||||
"parrot", "peach", "pebble", "pepper", "piano", "pickle", "pilot", "pine",
|
|
||||||
"planet", "plum", "poem", "pony", "puzzle", "quartz", "quill", "rabbit",
|
|
||||||
"radar", "radio", "raven", "ribbon", "river", "robin", "rocket", "rose",
|
|
||||||
"ruby", "saddle", "salmon", "sandal", "satin", "scarf", "scout", "sugar",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user