Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Windows: sign-in works — the session kept in parts where one credential cannot hold it

Yashwanth Kamireddi9de50e120a7c
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 276130f..0171b3c 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -1,7 +1,9 @@
-# Pomander for Windows: the .msi and the per-user .exe installer, built on GitHub's own
-# Windows machines. Run by hand (Actions → Windows build → Run workflow) or by a release tag,
-# never on every push, so it spends minutes only when a build is wanted. Unsigned for now:
-# Windows will warn before the first run until the Store or SignPath signs it.
+# Pomander for Windows, proven on Windows before anyone downloads it:
+# 1. test — the whole test suite on a Windows machine, the real Credential Manager included;
+# 2. build — the .msi and the per-user .exe installer, only if every test passed;
+# 3. smoke — the .exe installed silently, Pomander launched, its window seen on screen, and a
+# screenshot kept, so an installer that cannot even start is never handed over.
+# Run by hand (Actions → Windows build → Run workflow) or by a release tag; never on every push.
name: Windows build
on:
@@ -13,39 +15,49 @@ permissions:
contents: read
jobs:
- build:
+ test:
runs-on: windows-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
-
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
-
- uses: dtolnay/rust-toolchain@stable
+ - uses: Swatinem/rust-cache@v2
+ - run: npm ci
+ # The window's files must exist for the app crate to compile.
+ - run: npm run build
+ - name: Tests, on Windows
+ run: cargo test --workspace --no-fail-fast
+ build:
+ needs: test
+ runs-on: windows-latest
+ timeout-minutes: 60
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: npm
+ - uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: ". -> target"
-
- - name: Install the window's dependencies
- run: npm ci
-
+ - run: npm ci
- name: Build the installers
# The build machine's paths are never written into the program.
env:
RUSTFLAGS: --remap-path-prefix=${{ github.workspace }}=pomander
run: npx tauri build
-
- name: Checksums
shell: pwsh
run: |
$files = Get-ChildItem target/release/bundle -Recurse -Include *.msi,*.exe
$files | ForEach-Object { "{0} {1}" -f (Get-FileHash $_ -Algorithm SHA256).Hash.ToLower(), $_.Name } |
Set-Content target/release/bundle/SHA256SUMS.txt
-
- uses: actions/upload-artifact@v4
with:
name: pomander-windows
@@ -54,3 +66,45 @@ jobs:
target/release/bundle/nsis/*.exe
target/release/bundle/SHA256SUMS.txt
if-no-files-found: error
+
+ smoke:
+ needs: build
+ runs-on: windows-latest
+ timeout-minutes: 20
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ name: pomander-windows
+ path: dist
+ - name: Install, launch, and see the window
+ shell: pwsh
+ run: |
+ $setup = Get-ChildItem dist -Recurse -Filter *-setup.exe | Select-Object -First 1
+ Start-Process $setup.FullName -ArgumentList "/S" -Wait
+ $exe = Get-ChildItem "$env:LOCALAPPDATA\Programs" -Recurse -Filter pomander.exe | Select-Object -First 1
+ if (-not $exe) { $exe = Get-ChildItem "$env:LOCALAPPDATA" -Recurse -Filter pomander.exe -ErrorAction SilentlyContinue | Select-Object -First 1 }
+ if (-not $exe) { throw "Pomander was not installed" }
+ "installed at $($exe.FullName)"
+ $p = Start-Process $exe.FullName -PassThru
+ $title = ""
+ for ($i = 0; $i -lt 30 -and -not $title; $i++) {
+ Start-Sleep -Seconds 2
+ if ($p.HasExited) { throw "Pomander exited on start (code $($p.ExitCode))" }
+ $p.Refresh(); $title = $p.MainWindowTitle
+ }
+ if ($title -ne "Pomander") { throw "no Pomander window after 60 s (title: '$title')" }
+ "window up: $title"
+ Start-Sleep -Seconds 6
+ Add-Type -AssemblyName System.Windows.Forms, System.Drawing
+ $b = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
+ $bmp = New-Object System.Drawing.Bitmap $b.Width, $b.Height
+ [System.Drawing.Graphics]::FromImage($bmp).CopyFromScreen($b.Location, [System.Drawing.Point]::Empty, $b.Size)
+ $bmp.Save("$PWD\pomander-on-windows.png")
+ if ($p.HasExited) { throw "Pomander closed by itself" }
+ Stop-Process -Id $p.Id
+ - uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: pomander-on-windows
+ path: pomander-on-windows.png
+ if-no-files-found: ignore
diff --git a/.uiverify/app-window.mjs b/.uiverify/app-window.mjs
index 1383eaf..378379f 100644
--- a/.uiverify/app-window.mjs
+++ b/.uiverify/app-window.mjs
@@ -1,6 +1,5 @@
-// A window opened as one app (`?app=…`, from its launcher entry or the tray) is that app
-// alone: its own screen, and no list of the others, no account card, no library search.
-// Without it, the window is the whole library as before.
+// A window opened as one app (`?app=…`, from its launcher entry or the tray) opens on that app,
+// with everything else still there: the other apps, search, Settings and the account.
import { engine } from "./engine.mjs";
import { SERVICES, installStub } from "./stub.mjs";
const b = await engine.launch();
@@ -14,8 +13,8 @@ for (const [app, marker] of [["notes", ".note-rows"], ["reminders", ".rx-list"],
await page.goto(`http://localhost:4173/?app=${app}`, { waitUntil: "networkidle" });
await page.waitForTimeout(800);
ok((await page.locator(`main.content[data-screen="${app}"]`).count()) === 1 && (await page.locator(marker).count()) > 0, `${app}: the window is that app`);
- ok(!(await page.locator("nav.sidebar").isVisible()) && !(await page.getByRole("combobox", { name: "Search everything" }).isVisible()),
- `${app}: with no list of the other apps, and no library search`);
+ ok(await page.locator("nav.sidebar").isVisible() && await page.getByRole("combobox", { name: "Search everything" }).isVisible(),
+ `${app}: with the other apps, search and Settings still there`);
await ctx.close();
}
const ctx = await b.newContext({ viewport: { width: 1040, height: 700 } });
diff --git a/crates/quince-auth/src/session.rs b/crates/quince-auth/src/session.rs
index d3c3ad9..5a50ae8 100644
--- a/crates/quince-auth/src/session.rs
+++ b/crates/quince-auth/src/session.rs
@@ -212,6 +212,136 @@ fn entry_name(state_dir: &Path) -> String {
format!("{KEYRING_ENTRY}:{:x}", digest)[..KEYRING_ENTRY.len() + 17].to_string()
}
+/// One secret in the system keyring, split over as many entries as the platform needs.
+///
+/// Windows' Credential Manager keeps at most 2,560 bytes in one credential, and the keyring
+/// crate stores text there as UTF-16 — 1,280 characters. A signed-in session is larger, so on
+/// Windows sign-in failed outright ("longer than platform limit of 2560 chars"). There the
+/// secret is written as parts (`<name>#1`, `<name>#2`, …) and the entry itself holds only
+/// `pomander-parts:<n>`, written last, so a save cut short never leaves a half that reads as
+/// whole. Elsewhere the whole secret stays in the one entry, as it always has; reading takes
+/// either shape on every platform.
+trait Secrets {
+ fn get(&self, name: &str) -> Result<Option<String>, String>;
+ fn set(&self, name: &str, value: &str) -> Result<(), String>;
+ fn delete(&self, name: &str) -> Result<(), String>;
+}
+
+/// The system keyring, under this app's service name.
+struct SystemKeyring;
+
+impl Secrets for SystemKeyring {
+ fn get(&self, name: &str) -> Result<Option<String>, String> {
+ match keyring::Entry::new(KEYRING_SERVICE, name).and_then(|e| e.get_password()) {
+ Ok(v) => Ok(Some(v)),
+ Err(keyring::Error::NoEntry) => Ok(None),
+ Err(e) => Err(e.to_string()),
+ }
+ }
+ fn set(&self, name: &str, value: &str) -> Result<(), String> {
+ keyring::Entry::new(KEYRING_SERVICE, name)
+ .and_then(|e| e.set_password(value))
+ .map_err(|e| e.to_string())
+ }
+ fn delete(&self, name: &str) -> Result<(), String> {
+ match keyring::Entry::new(KEYRING_SERVICE, name).and_then(|e| e.delete_credential()) {
+ Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
+ Err(e) => Err(e.to_string()),
+ }
+ }
+}
+
+const PARTS: &str = "pomander-parts:";
+/// The most parts a secret may take: 32 × 1,000 characters is far past any session.
+const MOST_PARTS: usize = 32;
+
+/// How many characters one entry may hold here: Windows' limit, with room to spare; none
+/// elsewhere.
+fn part_size() -> Option<usize> {
+ if cfg!(windows) {
+ Some(1000)
+ } else {
+ None
+ }
+}
+
+fn part_name(name: &str, i: usize) -> String {
+ format!("{name}#{i}")
+}
+
+/// The secret under `name`, whole or reassembled from its parts.
+fn read_secret(k: &dyn Secrets, name: &str) -> Result<Option<String>, String> {
+ let Some(head) = k.get(name)? else {
+ return Ok(None);
+ };
+ let Some(n) = head.strip_prefix(PARTS) else {
+ return Ok(Some(head));
+ };
+ let n: usize = n
+ .parse()
+ .map_err(|_| "the stored sign-in is damaged".to_string())?;
+ if n == 0 || n > MOST_PARTS {
+ return Err("the stored sign-in is damaged".into());
+ }
+ let mut whole = String::new();
+ for i in 1..=n {
+ let part = k
+ .get(&part_name(name, i))?
+ .ok_or_else(|| "part of the stored sign-in is missing".to_string())?;
+ whole.push_str(&part);
+ }
+ Ok(Some(whole))
+}
+
+/// Keep `value` under `name`, in parts where one entry cannot hold it.
+fn write_secret(
+ k: &dyn Secrets,
+ name: &str,
+ value: &str,
+ size: Option<usize>,
+) -> Result<(), String> {
+ let chars: Vec<char> = value.chars().collect();
+ let parts: Vec<String> = match size {
+ Some(size) if chars.len() > size => {
+ chars.chunks(size).map(|c| c.iter().collect()).collect()
+ }
+ _ => Vec::new(),
+ };
+ if parts.len() > MOST_PARTS {
+ return Err("the sign-in is too large to keep".into());
+ }
+ if parts.is_empty() {
+ k.set(name, value)?;
+ } else {
+ // The parts first, then the entry that says how many: read before it is written, the
+ // old session (or nothing) is what is found, never a mix.
+ for (i, part) in parts.iter().enumerate() {
+ k.set(&part_name(name, i + 1), part)?;
+ }
+ k.set(name, &format!("{PARTS}{}", parts.len()))?;
+ }
+ // Parts left from a longer secret before: let go of.
+ for i in parts.len() + 1..=MOST_PARTS {
+ if k.get(&part_name(name, i))?.is_none() {
+ break;
+ }
+ k.delete(&part_name(name, i))?;
+ }
+ Ok(())
+}
+
+/// Forget the secret under `name`, and every part of it.
+fn delete_secret(k: &dyn Secrets, name: &str) -> Result<(), String> {
+ k.delete(name)?;
+ for i in 1..=MOST_PARTS {
+ if k.get(&part_name(name, i))?.is_none() {
+ break;
+ }
+ k.delete(&part_name(name, i))?;
+ }
+ Ok(())
+}
+
impl Store {
/// Production: secrets in the OS keyring.
pub fn keyring(state_dir: &Path) -> std::io::Result<Self> {
@@ -265,12 +395,11 @@ impl Store {
std::fs::write(&self.cooldown_path, json)
}
- fn entry(&self) -> Result<keyring::Entry, keyring::Error> {
- let name = match &self.backend {
+ fn name(&self) -> &str {
+ match &self.backend {
Backend::Keyring(name) => name.as_str(),
Backend::File(_) => KEYRING_ENTRY,
- };
- keyring::Entry::new(KEYRING_SERVICE, name)
+ }
}
/// Load the stored session. A missing entry is normal (first run), not an error.
@@ -283,10 +412,10 @@ impl Store {
/// the sign-in screen, and signing in then replaced the entry and its trust token.
pub fn try_load(&self) -> Result<Session, crate::Error> {
let json = match &self.backend {
- Backend::Keyring(_) => match self.entry().and_then(|e| e.get_password()) {
- Ok(j) => j,
- Err(keyring::Error::NoEntry) => return Ok(Session::default()),
- Err(e) => return Err(crate::Error::Keyring(e.to_string())),
+ Backend::Keyring(_) => match read_secret(&SystemKeyring, self.name()) {
+ Ok(Some(j)) => j,
+ Ok(None) => return Ok(Session::default()),
+ Err(e) => return Err(crate::Error::Keyring(e)),
},
Backend::File(path) => match std::fs::read_to_string(path) {
Ok(j) => j,
@@ -300,15 +429,14 @@ impl Store {
let json = serde_json::to_string(session)?;
match &self.backend {
Backend::Keyring(_) => {
- self.entry()
- .and_then(|e| e.set_password(&json))
- .map_err(|e| crate::Error::Keyring(e.to_string()))?;
+ write_secret(&SystemKeyring, self.name(), &json, part_size())
+ .map_err(crate::Error::Keyring)?;
// Storing the trust token is the whole reason sign-in survives a restart, so
// prove it landed rather than assume. A keyring that accepts a write and
// loses it looks identical to working until the user reopens the app.
if session.trust_token.is_some() {
- let stored = self.entry().and_then(|e| e.get_password()).ok();
+ let stored = read_secret(&SystemKeyring, self.name()).ok().flatten();
if stored.as_deref() != Some(json.as_str()) {
return Err(crate::Error::Keyring(
"the system keyring accepted the sign-in but did not keep it. \
@@ -328,12 +456,7 @@ impl Store {
pub fn clear(&self) -> Result<(), crate::Error> {
match &self.backend {
Backend::Keyring(_) => {
- if let Ok(entry) = self.entry() {
- match entry.delete_credential() {
- Ok(()) | Err(keyring::Error::NoEntry) => {}
- Err(e) => return Err(crate::Error::Keyring(e.to_string())),
- }
- }
+ delete_secret(&SystemKeyring, self.name()).map_err(crate::Error::Keyring)?;
}
Backend::File(path) => {
if path.exists() {
@@ -551,3 +674,81 @@ mod entry_tests {
assert_eq!(entry_name(probe), entry_name(probe), "stable");
}
}
+
+/// A secret kept in parts where one entry cannot hold it — Windows' Credential Manager — and
+/// read back whole, whichever shape it was written in.
+#[cfg(test)]
+mod parts_tests {
+ use super::*;
+ use std::cell::RefCell;
+ use std::collections::BTreeMap;
+
+ #[derive(Default)]
+ struct Memory(RefCell<BTreeMap<String, String>>, Option<usize>);
+ impl Secrets for Memory {
+ fn get(&self, name: &str) -> Result<Option<String>, String> {
+ Ok(self.0.borrow().get(name).cloned())
+ }
+ fn set(&self, name: &str, value: &str) -> Result<(), String> {
+ // The platform's own limit, as Windows enforces it.
+ if self.1.is_some_and(|most| value.chars().count() > most) {
+ return Err("longer than platform limit".into());
+ }
+ self.0.borrow_mut().insert(name.into(), value.into());
+ Ok(())
+ }
+ fn delete(&self, name: &str) -> Result<(), String> {
+ self.0.borrow_mut().remove(name);
+ Ok(())
+ }
+ }
+
+ #[test]
+ fn a_session_too_large_for_one_entry_is_kept_in_parts() {
+ let k = Memory(RefCell::default(), Some(1280));
+ let session = "x".repeat(3500) + "ü€";
+ write_secret(&k, "s", &session, Some(1000)).unwrap();
+ assert_eq!(
+ k.0.borrow().get("s").map(String::as_str),
+ Some("pomander-parts:4")
+ );
+ assert_eq!(
+ read_secret(&k, "s").unwrap().as_deref(),
+ Some(session.as_str())
+ );
+ // Shorter next time: the old fourth part goes.
+ write_secret(&k, "s", &"y".repeat(1500), Some(1000)).unwrap();
+ assert!(k.0.borrow().get("s#3").is_none() && k.0.borrow().get("s#4").is_none());
+ assert_eq!(read_secret(&k, "s").unwrap(), Some("y".repeat(1500)));
+ delete_secret(&k, "s").unwrap();
+ assert!(k.0.borrow().is_empty());
+ assert_eq!(read_secret(&k, "s").unwrap(), None);
+ }
+
+ #[test]
+ fn where_one_entry_holds_it_the_secret_stays_whole() {
+ let k = Memory::default();
+ let session = "z".repeat(5000);
+ write_secret(&k, "s", &session, None).unwrap();
+ assert_eq!(k.0.borrow().len(), 1);
+ assert_eq!(read_secret(&k, "s").unwrap(), Some(session));
+ }
+
+ #[test]
+ fn a_session_kept_whole_before_is_read_as_it_is() {
+ let k = Memory::default();
+ k.set("s", "{\"dsid\":\"1\"}").unwrap();
+ assert_eq!(
+ read_secret(&k, "s").unwrap().as_deref(),
+ Some("{\"dsid\":\"1\"}")
+ );
+ }
+
+ #[test]
+ fn a_missing_part_is_an_error_not_a_session() {
+ let k = Memory::default();
+ write_secret(&k, "s", &"q".repeat(2500), Some(1000)).unwrap();
+ k.delete("s#2").unwrap();
+ assert!(read_secret(&k, "s").is_err());
+ }
+}
diff --git a/crates/quince-auth/tests/windows_keyring.rs b/crates/quince-auth/tests/windows_keyring.rs
new file mode 100644
index 0000000..56d8c1e
--- /dev/null
+++ b/crates/quince-auth/tests/windows_keyring.rs
@@ -0,0 +1,39 @@
+//! On Windows, against the real Credential Manager: a signed-in session is larger than one
+//! credential can hold (2,560 bytes), and it must still be kept, read back whole, and erased
+//! by signing out. This is the failure that stopped sign-in on Windows outright.
+#![cfg(windows)]
+
+use quince_auth::session::Session;
+use quince_auth::Store;
+
+#[test]
+fn a_full_session_survives_windows_credential_manager() {
+ let dir = tempfile::tempdir().unwrap();
+ let store = Store::keyring(dir.path()).unwrap();
+ let session = Session {
+ client_id: Some("auth-00000000-0000-0000-0000-000000000000".into()),
+ session_token: Some("T".repeat(1104)),
+ trust_token: Some("R".repeat(200)),
+ session_id: Some("S".repeat(80)),
+ scnt: Some("C".repeat(300)),
+ dsid: Some("12345".into()),
+ webservices: Some(serde_json::json!({
+ "ckdatabasews": { "url": "https://p177-ckdatabasews.icloud.com:443", "status": "active" },
+ "calendar": { "url": "https://p177-calendarws.icloud.com:443", "status": "active" },
+ "contacts": { "url": "https://p177-contactsws.icloud.com:443", "status": "active" },
+ "drivews": { "url": "https://p177-drivews.icloud.com:443", "status": "active" },
+ "docws": { "url": "https://p177-docws.icloud.com:443", "status": "active" },
+ })),
+ ..Session::default()
+ };
+ let size = serde_json::to_string(&session).unwrap().len();
+ assert!(size > 1280, "the test session must be past one credential's limit ({size})");
+ store.save(&session).expect("kept, in parts");
+ let back = store.try_load().expect("read back");
+ assert_eq!(back.session_token, session.session_token);
+ assert_eq!(back.trust_token, session.trust_token);
+ assert_eq!(back.webservices, session.webservices);
+ store.clear().expect("signed out");
+ let gone = store.try_load().expect("read after sign-out");
+ assert!(gone.session_token.is_none() && gone.trust_token.is_none());
+}
diff --git a/src/screens/Library.tsx b/src/screens/Library.tsx
index 242bec9..8d2f7f1 100644
--- a/src/screens/Library.tsx
+++ b/src/screens/Library.tsx
@@ -52,8 +52,9 @@ const SCREENS: { key: string; name: string }[] = [
const LAST_KEY = "quince.library.screen";
const RAIL_KEY = "quince.library.rail";
-/** The one app this window is, when it was opened as one (`?app=notes`, from its launcher entry
- * or the tray): that app alone, with no list of the others. Otherwise the whole library. */
+/** The app this window opens on, when it was opened as one (`?app=notes`, from its launcher
+ * entry or the tray). Everything else stays — the other apps, search, Settings, the account —
+ * as in any window: an app's window is where that app is, not a place cut off from the rest. */
const ONLY = new URLSearchParams(window.location.search).get("app");
export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<void> }) {
@@ -247,7 +248,7 @@ export function Library({ onSignOut }: { onSignOut: (keep: boolean) => Promise<v
return (
<SyncProvider>
- <div className={`library enter-library${sidebarOpen ? " is-sidebar-open" : ""}${rail ? " is-rail" : ""}${ONLY ? " is-app" : ""}`}>
+ <div className={`library enter-library${sidebarOpen ? " is-sidebar-open" : ""}${rail ? " is-rail" : ""}`}>
{/* Only in a narrow window, where the sidebar gives its room to the content. */}
<button
className="sidebar-toggle"
diff --git a/src/styles/app.css b/src/styles/app.css
index 3694e6c..692bffe 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -530,9 +530,7 @@
}
.library { --side: 236px; }
.library.is-rail { --side: 84px; }
-/* A window that is one app (Notes, Reminders…): that app alone, no list of the others. */
-.library.is-app { --side: 34px; }
-.library.is-app > .sidebar, .library.is-app > .sidebar-toggle, .library.is-app > .sidebar-scrim { display: none; }
+
.sidebar-toggle, .sidebar-scrim, .compact-back { display: none; }
/*