From ead95bb605c830b567a80eea0d1943f4a815ad7e Mon Sep 17 00:00:00 2001 From: samialabri Date: Fri, 23 Oct 2026 23:17:22 +0700 Subject: [PATCH] server_url / server_pins: the configured sync server, for the apps' Settings Co-Authored-By: Claude Opus 5.5 --- crates/kv-ffi/src/lib.rs | 11 +++++++++++ crates/kv-ffi/src/tests.rs | 3 +++ 2 files changed, 14 insertions(+) diff --git a/crates/kv-ffi/src/lib.rs b/crates/kv-ffi/src/lib.rs index bee23d4..62b3b75 100644 --- a/crates/kv-ffi/src/lib.rs +++ b/crates/kv-ffi/src/lib.rs @@ -977,6 +977,17 @@ impl VaultCore { self.store.get_meta(META_SESSION).ok().flatten().is_some() } + /// The sync server this vault is configured with (`configure_server`, onboarding, sign-in), if any. The apps + /// show it in Settings; the core's copy is the one that counts. + pub fn server_url(&self) -> Option { + self.lock_inner().server.as_ref().map(|s| s.url.clone()) + } + + /// The SPKI pins configured with [`Self::server_url`]. + pub fn server_pins(&self) -> Vec { + self.lock_inner().server.as_ref().map(|s| s.pins.clone()).unwrap_or_default() + } + /// Deletes the account (docs/03 "Deleting the account"; required by the App Store and Google Play): on the /// sync server first when one is configured, then everything on this device. The master password is checked /// again, so an unlocked but unattended device can't do it. A server that can't be reached fails the whole diff --git a/crates/kv-ffi/src/tests.rs b/crates/kv-ffi/src/tests.rs index e43b055..b2085b0 100644 --- a/crates/kv-ffi/src/tests.rs +++ b/crates/kv-ffi/src/tests.rs @@ -679,11 +679,14 @@ async fn sign_out_device_keeps_the_account_on_the_server() { let a = VaultCore::open(path.clone()).unwrap(); let sk = a.create_account(PW.into()).unwrap(); + assert_eq!(a.server_url(), None); connect(&a, &server); + assert_eq!(a.server_url(), Some(server.url())); a.register_account(SETUP_TOKEN.into()).await.unwrap(); let id = a.save_item(login_item("Bank", "pw-a")).unwrap(); // not synced yet: sign-out syncs it first a.sign_out_device(false).await.unwrap(); assert!(!a.has_account() && !a.is_logged_in()); + assert_eq!(a.server_url(), None); // Same device, signed in again: the item came back from the server. connect(&a, &server);