Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

iPhone privacy: the advert no longer names the computer, audio copies and share exports are better protected and cleared, a reinstall starts unpaired, and a fake advert can't hide the real computer

christianmatcc2f2b361873
diff --git a/app/scripts/companion-peer.mjs b/app/scripts/companion-peer.mjs
index cb2f934a..d65aa3ba 100644
--- a/app/scripts/companion-peer.mjs
+++ b/app/scripts/companion-peer.mjs
@@ -78,7 +78,7 @@ async function pair(f) {
const sid = concat(desktopSession, phoneSession)
const ci = concat(enc('yogurt-pair-v1'), desktopSession, phoneSession)
const { ya, secret } = cpaceStart(code, ci, sid)
- sendJson(f, { type: 'pairStart', v: 1, desktopSession: b64(desktopSession), desktopId, desktopName: 'Test Mac', ya: b64(ya) })
+ sendJson(f, { type: 'pairStart', v: 1, desktopSession: b64(desktopSession), desktopId, ya: b64(ya) })
const reply = await json(f)
const isk = cpaceFinish(secret, unb64(reply.yb))
const keys = pairKeys(isk)
diff --git a/app/src/main/companion/index.ts b/app/src/main/companion/index.ts
index 97fd7fa9..c966571a 100644
--- a/app/src/main/companion/index.ts
+++ b/app/src/main/companion/index.ts
@@ -1,6 +1,7 @@
// The iPhone companion on the desktop: off until the person starts pairing or a phone is paired. Then it listens on
// every interface (a fixed port once picked, so the phone can try the last host:port) and advertises _yogurt._tcp
-// with TXT v=1, id, name, pairing=0|1. One phone at a time: pairing another replaces it.
+// with TXT v=1, id, pairing=0|1 (no computer name: that goes sealed in pairing, then in hello). One phone at a time:
+// pairing another replaces it.
import { createHash, randomUUID } from 'node:crypto'
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
@@ -274,7 +275,8 @@ export async function createCompanion(d: CompanionDeps) {
await s?.close()
return
}
- advertiser.publish({ name: `Yogurt ${saved.id.slice(0, 8)}`, port: saved.port!, txt: { v: '1', id: saved.id, name: d.deviceName(), pairing: pairing ? '1' : '0' } })
+ // no computer name in the open: anyone on the Wi-Fi sees the advert. The phone gets it sealed when pairing, then in hello
+ advertiser.publish({ name: `Yogurt ${saved.id.slice(0, 8)}`, port: saved.port!, txt: { v: '1', id: saved.id, pairing: pairing ? '1' : '0' } })
}
await refresh()
diff --git a/app/src/main/companion/pairing.ts b/app/src/main/companion/pairing.ts
index 0a402b8e..be178d1e 100644
--- a/app/src/main/companion/pairing.ts
+++ b/app/src/main/companion/pairing.ts
@@ -1,5 +1,5 @@
// Pairing over one connection, before any Noise session (the desktop is CPace initiator A):
-// pairHello {v:1, phoneSession, phoneName} → pairStart {v:1, desktopSession, desktopId, desktopName, ya}
+// pairHello {v:1, phoneSession, phoneName} → pairStart {v:1, desktopSession, desktopId, ya}
// → pairReply {yb} → pairConfirm {box} → pairDone {box} → pairOk {} | pairFail {reason: code | expired | tooMany | busy}
// sid = desktopSession ‖ phoneSession, CI = "yogurt-pair-v1" ‖ desktopSession ‖ phoneSession, no AD. The boxes are
// XChaCha20-Poly1305 under pairKeys(ISK) (toPhone, AD "pairConfirm"; toDesktop, AD "pairDone") holding JSON
@@ -78,7 +78,8 @@ export async function pair(io: PairIo, hello: Record<string, unknown>, ctx: Pair
const sid = new Uint8Array([...desktopSession, ...phoneSession])
const ci = new Uint8Array([...enc.encode('yogurt-pair-v1'), ...desktopSession, ...phoneSession])
const { ya, secret } = cpaceStart(code, ci, sid)
- io.send({ type: 'pairStart', v: 1, desktopSession: b64(desktopSession), desktopId: ctx.desktop.id, desktopName: ctx.desktop.name, ya: b64(ya) })
+ // the computer's name goes only in the sealed pairConfirm box, never in the clear
+ io.send({ type: 'pairStart', v: 1, desktopSession: b64(desktopSession), desktopId: ctx.desktop.id, ya: b64(ya) })
let yb: Uint8Array
try { yb = bytes((await message(io, 'pairReply')).yb, 32) } catch (err) { secret.scalar.fill(0); ctx.stalled(); throw err }
// from here the phone can test its one guess against pairConfirm, so it counts whatever happens next
diff --git a/app/test/companionPairing.test.ts b/app/test/companionPairing.test.ts
index 8a573b1c..60531dd5 100644
--- a/app/test/companionPairing.test.ts
+++ b/app/test/companionPairing.test.ts
@@ -67,10 +67,14 @@ describe('companion pairing', () => {
const { c, store, adverts } = await make()
const { code } = await c.startPairing()
expect(code).toMatch(/^\d{6}$/)
- expect(adverts.at(-1)).toMatchObject({ txt: { v: '1', id: c.desktopId, name: 'Test Mac', pairing: '1' } })
+ // the advert names no one: the computer's name goes only inside the sealed pairing box and the hello
+ expect(adverts.at(-1)?.txt).toEqual({ v: '1', id: c.desktopId, pairing: '1' })
const phone = generateKeyPair()
const r = await pairAsPhone(c.port()!, code, phone)
expect(r.result).toEqual({ type: 'pairOk' })
+ expect(r.start).not.toHaveProperty('desktopName')
+ expect(JSON.stringify(r.start)).not.toContain('Test Mac')
+ expect(r.desktop!.name).toBe('Test Mac')
expect(Buffer.from(r.desktop!.key)).toEqual(Buffer.from(c.publicKey))
expect(r.desktop!.id).toBe(c.desktopId)
expect(devices(store)).toEqual([expect.objectContaining({ name: 'Test iPhone', public_key: Buffer.from(phone.publicKey).toString('base64') })])
diff --git a/app/test/helpers/companionClient.ts b/app/test/helpers/companionClient.ts
index fe595d39..64dd8113 100644
--- a/app/test/helpers/companionClient.ts
+++ b/app/test/helpers/companionClient.ts
@@ -51,7 +51,7 @@ export async function raw(port: number): Promise<Raw> {
return r
}
-export type PairResult = { result: Record<string, unknown>; desktop?: { key: Uint8Array; name: string; id: string } }
+export type PairResult = { result: Record<string, unknown>; desktop?: { key: Uint8Array; name: string; id: string }; start?: Record<string, unknown> }
/** The phone's side of pairing with this code; a wrong code still sends pairDone (sealed under its own key). */
export async function pairAsPhone(port: number, code: string, phone: KeyPair, name = 'Test iPhone', o: { beforeDone?: () => Promise<void> } = {}): Promise<PairResult> {
@@ -76,7 +76,7 @@ export async function pairAsPhone(port: number, code: string, phone: KeyPair, na
await o.beforeDone?.()
const mine = enc.encode(JSON.stringify({ key: b64(phone.publicKey), name, id: 'phone-' + b64(phone.publicKey).slice(0, 8).replace(/[^\w]/g, 'x') }))
c.sendJson({ type: 'pairDone', box: b64(sealBox(keys.toDesktop, mine, enc.encode('pairDone'))) })
- return { result: await c.json(), desktop }
+ return { result: await c.json(), desktop, start }
} finally {
c.socket.destroy()
}
diff --git a/ios/Yogurt/Localizable.xcstrings b/ios/Yogurt/Localizable.xcstrings
index f74b70df..33c4b325 100644
--- a/ios/Yogurt/Localizable.xcstrings
+++ b/ios/Yogurt/Localizable.xcstrings
@@ -42110,6 +42110,202 @@
}
}
},
+ "Type the code shown on your computer" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Type the code shown on your computer"
+ }
+ },
+ "ar" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "اكتب الرمز الظاهر على الكمبيوتر"
+ }
+ },
+ "bn" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "আপনার কম্পিউটারে দেখানো কোডটি লিখুন"
+ }
+ },
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zadejte kód zobrazený na počítači"
+ }
+ },
+ "da" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Skriv koden, der vises på din computer"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Gib den Code ein, der auf deinem Computer angezeigt wird"
+ }
+ },
+ "el" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Πληκτρολογήστε τον κωδικό που εμφανίζεται στον υπολογιστή σας"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Escribe el código que aparece en tu ordenador"
+ }
+ },
+ "fi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kirjoita koodi, joka näkyy tietokoneellasi"
+ }
+ },
+ "fil" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "I-type ang code na nasa computer mo"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Saisissez le code affiché sur votre ordinateur"
+ }
+ },
+ "he" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "יש להקליד את הקוד שמוצג במחשב"
+ }
+ },
+ "hi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "अपने कंप्यूटर पर दिख रहा कोड लिखें"
+ }
+ },
+ "hu" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Írd be a számítógépeden látható kódot"
+ }
+ },
+ "id" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ketik kode yang tampil di komputer Anda"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inserisci il codice mostrato sul tuo computer"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "コンピュータに表示されたコードを入力"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "컴퓨터에 표시된 코드를 입력하세요"
+ }
+ },
+ "ms" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Taip kod yang ditunjukkan pada komputer anda"
+ }
+ },
+ "nb" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Skriv inn koden som vises på datamaskinen din"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Typ de code die op je computer staat"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wpisz kod widoczny na komputerze"
+ }
+ },
+ "pt-BR" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Digite o código que aparece no seu computador"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Introduceți codul afișat pe computer"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Введите код, показанный на компьютере"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Skriv koden som visas på din dator"
+ }
+ },
+ "th" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "พิมพ์รหัสที่แสดงบนคอมพิวเตอร์ของคุณ"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bilgisayarınızda görünen kodu yazın"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Введіть код, показаний на комп’ютері"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nhập mã hiển thị trên máy tính của bạn"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "输入电脑上显示的配对码"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "輸入電腦上顯示的配對碼"
+ }
+ }
+ }
+ },
"Type your notes here." : {
"localizations" : {
"en" : {
@@ -46815,6 +47011,202 @@
}
}
},
+ "Yogurt on this Wi-Fi" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt on this Wi-Fi"
+ }
+ },
+ "ar" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt على شبكة Wi-Fi هذه"
+ }
+ },
+ "bn" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "এই Wi-Fi-তে Yogurt"
+ }
+ },
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt na této Wi-Fi"
+ }
+ },
+ "da" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt på dette wi-fi"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt in diesem WLAN"
+ }
+ },
+ "el" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt σε αυτό το Wi-Fi"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt en esta Wi-Fi"
+ }
+ },
+ "fi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt tässä Wi-Fi-verkossa"
+ }
+ },
+ "fil" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt sa Wi-Fi na ito"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt sur ce Wi-Fi"
+ }
+ },
+ "he" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt ברשת ה-Wi-Fi הזו"
+ }
+ },
+ "hi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "इस Wi-Fi पर Yogurt"
+ }
+ },
+ "hu" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt ezen a Wi-Fin"
+ }
+ },
+ "id" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt di Wi-Fi ini"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt su questa Wi-Fi"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "このWi-FiのYogurt"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 Wi-Fi의 Yogurt"
+ }
+ },
+ "ms" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt pada Wi-Fi ini"
+ }
+ },
+ "nb" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt på dette wifi-nettet"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt op dit wifi"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt w tej sieci Wi-Fi"
+ }
+ },
+ "pt-BR" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt nesta Wi-Fi"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt în această rețea Wi-Fi"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt в этой сети Wi-Fi"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt på det här wifi-nätverket"
+ }
+ },
+ "th" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt ใน Wi-Fi นี้"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bu Wi-Fi’daki Yogurt"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt у цій мережі Wi-Fi"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yogurt trên Wi-Fi này"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "这个 Wi-Fi 上的 Yogurt"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "這個 Wi-Fi 上的 Yogurt"
+ }
+ }
+ }
+ },
"Yogurt uses these to record and transcribe on this iPhone." : {
"localizations" : {
"en" : {
diff --git a/ios/Yogurt/Strings.swift b/ios/Yogurt/Strings.swift
index 597df0fe..92964442 100644
--- a/ios/Yogurt/Strings.swift
+++ b/ios/Yogurt/Strings.swift
@@ -53,7 +53,12 @@ enum S {
static let pairFound = String(localized: "Pick your computer")
static let pairReady = String(localized: "Ready to pair")
static let pairNotReady = String(localized: "Not showing a pairing code yet")
- static func codeTitle(_ name: String) -> String { String(localized: "Type the code shown on \(name)") }
+ static func codeTitle(_ name: String) -> String {
+ name.isEmpty ? String(localized: "Type the code shown on your computer") : String(localized: "Type the code shown on \(name)")
+ }
+ /// a computer on the Wi-Fi before pairing: its advert carries no name
+ static let unnamedComputer = String(localized: "Yogurt on this Wi-Fi")
+ static func computerName(_ name: String) -> String { name.isEmpty ? unnamedComputer : name }
static let codeHelp = String(localized: "It's the 6-digit code in Yogurt's Settings, under Phone.")
static let codeField = String(localized: "Pairing code")
static let pairing = String(localized: "Pairing…")
diff --git a/ios/Yogurt/Views/PairingView.swift b/ios/Yogurt/Views/PairingView.swift
index 5894e3ca..ce3dba08 100644
--- a/ios/Yogurt/Views/PairingView.swift
+++ b/ios/Yogurt/Views/PairingView.swift
@@ -135,7 +135,7 @@ struct ConnectSheet: View {
.frame(width: 38, height: 38)
.background(Theme.control, in: RoundedRectangle(cornerRadius: 9, style: .continuous))
VStack(alignment: .leading, spacing: 2) {
- Text(d.name).font(.body.weight(.medium)).foregroundStyle(Theme.ink)
+ Text(S.computerName(d.name)).font(.body.weight(.medium)).foregroundStyle(Theme.ink)
Text(d.pairing ? S.pairReady : S.pairNotReady)
.font(.footnote)
.foregroundStyle(d.pairing ? Theme.live : Theme.muted)
diff --git a/ios/Yogurt/Views/ShareFiles.swift b/ios/Yogurt/Views/ShareFiles.swift
index c8a88aff..8e95b5a9 100644
--- a/ios/Yogurt/Views/ShareFiles.swift
+++ b/ios/Yogurt/Views/ShareFiles.swift
@@ -2,19 +2,25 @@ import AVFoundation
import UIKit
import YogurtKit
-/// The files Share hands to the share sheet: written to the caches folder, each in a folder of its own so the file
-/// keeps its plain name, and cleared out an hour later (the share sheet may still be reading a recent one).
+/// The files Share hands to the share sheet: written to the caches folder with complete protection (unreadable while
+/// the phone is locked), each in a folder of its own so the file keeps its plain name. Cleared out ten minutes later
+/// (the share sheet may still be reading a recent one), when Yogurt goes to the background, and at launch.
enum ShareFiles {
static var root: URL { URL.cachesDirectory.appending(path: "Exports", directoryHint: .isDirectory) }
- static let keepFor: TimeInterval = 3600
+ static let keepFor: TimeInterval = 600
static func write(_ text: String, name: String) throws -> URL {
let url = try freshFolder().appending(path: name)
- try Data(text.utf8).write(to: url, options: .atomic)
+ try Data(text.utf8).write(to: url, options: [.atomic, .completeFileProtection])
return url
}
+ /// Removes the exports older than `keepFor`; at launch all of them, since no share sheet is open any more.
+ static func clearOld(all: Bool = false) {
+ PrivateFolder.prune(root, unusedFor: all ? -1 : keepFor)
+ }
+
/// One recording as it is; a call's two sides (theirs and the mic) mixed into one m4a, as the player plays them.
static func audio(_ files: [URL], name: String) async throws -> URL {
guard let first = files.first else { throw CocoaError(.fileNoSuchFile) }
@@ -22,6 +28,8 @@ enum ShareFiles {
if files.count == 1 {
let url = folder.appending(path: "\(name).\(first.pathExtension.isEmpty ? "m4a" : first.pathExtension)")
try FileManager.default.copyItem(at: first, to: url)
+ // a copy keeps the recording's own protection; an export gets complete
+ try FileManager.default.setAttributes([.protectionKey: FileProtectionType.complete], ofItemAtPath: url.path)
return url
}
let mix = AVMutableComposition()
@@ -34,19 +42,16 @@ enum ShareFiles {
guard let export = AVAssetExportSession(asset: mix, presetName: AVAssetExportPresetAppleM4A) else { throw CocoaError(.fileWriteUnknown) }
let url = folder.appending(path: "\(name).m4a")
try await export.export(to: url, as: .m4a)
+ try FileManager.default.setAttributes([.protectionKey: FileProtectionType.complete], ofItemAtPath: url.path)
return url
}
/// A new folder for one share, after clearing out the old ones.
private static func freshFolder() throws -> URL {
- let fm = FileManager.default
- let old = (try? fm.contentsOfDirectory(at: root, includingPropertiesForKeys: [.creationDateKey])) ?? []
- for url in old {
- let made = (try? url.resourceValues(forKeys: [.creationDateKey]).creationDate) ?? .distantPast
- if Date().timeIntervalSince(made) > keepFor { try? fm.removeItem(at: url) }
- }
+ clearOld()
let folder = root.appending(path: UUID().uuidString, directoryHint: .isDirectory)
- try fm.createDirectory(at: folder, withIntermediateDirectories: true)
+ // what's written inside takes the folder's protection
+ try PrivateFolder.make(folder, protection: .complete)
return folder
}
diff --git a/ios/Yogurt/YogurtApp.swift b/ios/Yogurt/YogurtApp.swift
index ea2b2eb1..f80cfed2 100644
--- a/ios/Yogurt/YogurtApp.swift
+++ b/ios/Yogurt/YogurtApp.swift
@@ -127,11 +127,16 @@ final class AppModel {
static func open() -> AppModel? {
let support = URL.applicationSupportDirectory
+ // nothing can still be sharing an export from before this launch
+ ShareFiles.clearOld(all: true)
+ let vault = KeychainVault()
+ // the Keychain outlives deleting the app: a fresh install starts unpaired
+ LeftoverPairing.forget(vault: vault, protectedDataAvailable: UIApplication.shared.isProtectedDataAvailable)
guard let library = try? Library(folder: support.appending(path: "Yogurt", directoryHint: .isDirectory)) else { return nil }
var config = SyncConfig()
config.appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0"
config.phoneName = UIDevice.current.name
- let sync = SyncEngine(store: library.store, vault: KeychainVault(), network: LiveNetwork(), config: config)
+ let sync = SyncEngine(store: library.store, vault: vault, network: LiveNetwork(), config: config)
// a recording goes once its draft notes and title are written, so the computer gets them with it
sync.holdsUpload = { PhoneDrafts.shared.isWriting($0) }
#if DEBUG
@@ -204,7 +209,7 @@ struct RootView: View {
lock.phaseChanged(now)
// sync runs only while Yogurt is on screen; a brief inactive (Control Centre) keeps the connection
if now == .active { model.sync.setForeground(true) }
- if now == .background { model.sync.setForeground(false) }
+ if now == .background { model.sync.setForeground(false); ShareFiles.clearOld() }
}
}
}
diff --git a/ios/YogurtKit/Sources/YogurtKit/Recording/PhoneAudio.swift b/ios/YogurtKit/Sources/YogurtKit/Recording/PhoneAudio.swift
index c3e10b2a..1ef78dcd 100644
--- a/ios/YogurtKit/Sources/YogurtKit/Recording/PhoneAudio.swift
+++ b/ios/YogurtKit/Sources/YogurtKit/Recording/PhoneAudio.swift
@@ -14,7 +14,13 @@ public enum PhoneAudio {
guard let to = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: true),
let converter = AVAudioConverter(from: from, to: to) else { throw ExportError.convert }
+ // a meeting's audio: readable while locked only once opened, like the recordings it's made from
+ #if os(iOS)
+ FileManager.default.createFile(atPath: target.path, contents: header(dataBytes: 0),
+ attributes: [.protectionKey: FileProtectionType.completeUnlessOpen])
+ #else
FileManager.default.createFile(atPath: target.path, contents: header(dataBytes: 0))
+ #endif
let out = try FileHandle(forWritingTo: target)
defer { try? out.close() }
try out.seekToEnd()
diff --git a/ios/YogurtKit/Sources/YogurtKit/Store/PrivateFolder.swift b/ios/YogurtKit/Sources/YogurtKit/Store/PrivateFolder.swift
new file mode 100644
index 00000000..211191c3
--- /dev/null
+++ b/ios/YogurtKit/Sources/YogurtKit/Store/PrivateFolder.swift
@@ -0,0 +1,46 @@
+import Foundation
+
+/// Folders that hold copies of a meeting's audio: readable while the phone is locked only once a file was opened
+/// before (a meeting goes on in a pocket), like the Recordings folder.
+public enum PrivateFolder {
+ /// Creates the folder, or fixes one an earlier install made. Safe to call at every launch.
+ public static func make(_ url: URL, protection: FileProtectionType = .completeUnlessOpen) throws {
+ let fm = FileManager.default
+ try fm.createDirectory(at: url, withIntermediateDirectories: true, attributes: protected(protection))
+ // new files take the folder's protection; an older folder gets it now
+ try? fm.setAttributes(protected(protection), ofItemAtPath: url.path)
+ }
+
+ /// Removes what's in the folder that hasn't been written or used for this long.
+ public static func prune(_ url: URL, unusedFor: TimeInterval, now: Date = Date()) {
+ let fm = FileManager.default
+ let items = (try? fm.contentsOfDirectory(at: url, includingPropertiesForKeys: [.contentModificationDateKey])) ?? []
+ for item in items {
+ let used = (try? item.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast
+ if now.timeIntervalSince(used) > unusedFor { try? fm.removeItem(at: item) }
+ }
+ }
+
+ /// Marks a file as just used, so `prune` keeps it.
+ public static func touch(_ url: URL) {
+ try? FileManager.default.setAttributes([.modificationDate: Date()], ofItemAtPath: url.path)
+ }
+
+ private static func protected(_ p: FileProtectionType) -> [FileAttributeKey: Any] {
+ #if os(iOS)
+ [.protectionKey: p]
+ #else
+ [:]
+ #endif
+ }
+}
+
+/// The Keychain keeps a pairing after Yogurt is deleted. A fresh install (never onboarded) starts unpaired, so a
+/// reinstalled app never syncs with a computer nobody paired it with this time.
+public enum LeftoverPairing {
+ public static func forget(defaults: UserDefaults = .standard, vault: PairingVault, protectedDataAvailable: Bool) {
+ // before the first unlock the settings read as empty, which would look like a fresh install
+ guard protectedDataAvailable, !defaults.bool(forKey: "onboarded") else { return }
+ vault.delete()
+ }
+}
diff --git a/ios/YogurtKit/Sources/YogurtKit/Sync/Discovery.swift b/ios/YogurtKit/Sources/YogurtKit/Sync/Discovery.swift
index 8d1982a6..700d2581 100644
--- a/ios/YogurtKit/Sources/YogurtKit/Sync/Discovery.swift
+++ b/ios/YogurtKit/Sources/YogurtKit/Sync/Discovery.swift
@@ -1,11 +1,28 @@
import Foundation
import Network
-/// A computer seen on the network, with where to reach it.
+/// A computer seen on the network, with every place an advert for its id said to reach it: one per network
+/// interface, and maybe a fake one from someone else on the Wi-Fi, so each is tried in turn.
public struct FoundDesktop: Sendable, Hashable {
public var desktop: DiscoveredDesktop
- public var endpoint: NWEndpoint
- public init(desktop: DiscoveredDesktop, endpoint: NWEndpoint) { self.desktop = desktop; self.endpoint = endpoint }
+ public var endpoints: [NWEndpoint]
+ public init(desktop: DiscoveredDesktop, endpoints: [NWEndpoint]) { self.desktop = desktop; self.endpoints = endpoints }
+ public init(desktop: DiscoveredDesktop, endpoint: NWEndpoint) { self.init(desktop: desktop, endpoints: [endpoint]) }
+}
+
+/// Tries `attempt` on each endpoint in turn and returns the first that works. A `soft` failure (a refused key, a
+/// wrong code) is thrown only when every endpoint failed that way, so a fake advert for the same id can't make the
+/// real computer look like it refused. A denied local network stops at once: every endpoint would say the same.
+func eachEndpoint<E: Sendable, T>(_ endpoints: [E], isolation: isolated (any Actor)? = #isolation, soft: (Error) -> Bool,
+ _ attempt: (E) async throws -> T) async throws -> T {
+ var errors: [Error] = []
+ for e in endpoints {
+ do { return try await attempt(e) } catch {
+ if error as? SyncError == .localNetworkDenied || error is CancellationError { throw error }
+ errors.append(error)
+ }
+ }
+ throw errors.first { !soft($0) } ?? errors.first ?? SyncError.closed
}
/// Finds computers running Yogurt. The real one browses Bonjour; tests hand in a fixed list.
@@ -15,7 +32,8 @@ public protocol DesktopBrowser: AnyObject {
func stop()
}
-/// Bonjour `_yogurt._tcp`, TXT v=1, id, name, pairing=0|1 (app/src/main/companion/index.ts). The first browse is
+/// Bonjour `_yogurt._tcp`, TXT v=1, id, pairing=0|1 (app/src/main/companion/index.ts). No name: anyone on the Wi-Fi
+/// can read an advert, so the computer's name comes sealed in pairing, then in hello. The first browse is
/// what makes iOS ask for the local network permission.
@MainActor
public final class BonjourBrowser: DesktopBrowser {
@@ -34,7 +52,9 @@ public final class BonjourBrowser: DesktopBrowser {
stop()
let b = NWBrowser(for: .bonjourWithTXTRecord(type: "_yogurt._tcp", domain: nil), using: NWParameters())
b.browseResultsChangedHandler = { results, _ in
- let found = Self.desktops(results)
+ let found = Self.desktops(results.compactMap { r in
+ if case .bonjour(let txt) = r.metadata { (txt.dictionary, r.endpoint) } else { nil }
+ })
Task { @MainActor in update(found) }
}
b.stateUpdateHandler = { [weak self] state in
@@ -67,15 +87,21 @@ public final class BonjourBrowser: DesktopBrowser {
browser = nil
}
- nonisolated static func desktops(_ results: Set<NWBrowser.Result>) -> [FoundDesktop] {
- var seen = Set<String>()
- return results.compactMap { r -> FoundDesktop? in
- guard case .bonjour(let txt) = r.metadata, txt["v"] == "1", let id = txt["id"], !id.isEmpty else { return nil }
- // one computer can show up once per network interface
- guard seen.insert(id).inserted else { return nil }
- return FoundDesktop(desktop: DiscoveredDesktop(id: id, name: txt["name"] ?? "Computer", pairing: txt["pairing"] == "1"), endpoint: r.endpoint)
+ /// One entry per computer id, with every endpoint its adverts gave, in the order they came. The name stays empty
+ /// until pairing tells it (the screens show a plain label meanwhile).
+ nonisolated static func desktops(_ adverts: [(txt: [String: String], endpoint: NWEndpoint)]) -> [FoundDesktop] {
+ var out: [FoundDesktop] = []
+ for (txt, endpoint) in adverts {
+ guard txt["v"] == "1", let id = txt["id"], !id.isEmpty else { continue }
+ let pairing = txt["pairing"] == "1"
+ if let i = out.firstIndex(where: { $0.desktop.id == id }) {
+ if !out[i].endpoints.contains(endpoint) { out[i].endpoints.append(endpoint) }
+ out[i].desktop.pairing = out[i].desktop.pairing || pairing
+ } else {
+ out.append(FoundDesktop(desktop: DiscoveredDesktop(id: id, name: "", pairing: pairing), endpoint: endpoint))
+ }
}
- .sorted { $0.desktop.name.localizedStandardCompare($1.desktop.name) == .orderedAscending }
+ return out.sorted { $0.desktop.id < $1.desktop.id }
}
}
diff --git a/ios/YogurtKit/Sources/YogurtKit/Sync/SyncEngine.swift b/ios/YogurtKit/Sources/YogurtKit/Sync/SyncEngine.swift
index a8efe3fb..8660474c 100644
--- a/ios/YogurtKit/Sources/YogurtKit/Sync/SyncEngine.swift
+++ b/ios/YogurtKit/Sources/YogurtKit/Sync/SyncEngine.swift
@@ -38,28 +38,34 @@ public final class LiveNetwork: SyncNetwork {
public func pair(_ at: FoundDesktop, code: String, phoneName: String, phoneKey: Data, phoneId: String) async throws -> PairedDesktop {
// busy: another phone is mid-exchange, or a wrong guess was just made; the desktop asks for a second's pause
- for attempt in 0..<4 {
- let t: NWTransport
- do { t = try await NWTransport.connect(to: at.endpoint) } catch SyncError.localNetworkDenied { throw SyncError.localNetworkDenied } catch { throw PairingError.unreachable }
- defer { t.close() }
- do {
- return try await pairExchange(t, code: code, phoneName: phoneName, phoneKey: phoneKey, phoneId: phoneId)
- } catch SyncError.remote("busy") where attempt < 3 {
- try await Task.sleep(for: .milliseconds(1200))
- } catch let e as PairingError {
- throw e
- } catch {
- throw PairingError.unreachable
+ // a code that didn't work at one endpoint may have gone to a fake advert: the others are tried too
+ try await eachEndpoint(at.endpoints, soft: { $0 as? PairingError == .unreachable }) { endpoint in
+ for attempt in 0..<4 {
+ let t: NWTransport
+ do { t = try await NWTransport.connect(to: endpoint) } catch SyncError.localNetworkDenied { throw SyncError.localNetworkDenied } catch { throw PairingError.unreachable }
+ defer { t.close() }
+ do {
+ return try await pairExchange(t, code: code, phoneName: phoneName, phoneKey: phoneKey, phoneId: phoneId)
+ } catch SyncError.remote("busy") where attempt < 3 {
+ try await Task.sleep(for: .milliseconds(1200))
+ } catch let e as PairingError {
+ throw e
+ } catch {
+ throw PairingError.unreachable
+ }
}
+ throw PairingError.unreachable
}
- throw PairingError.unreachable
}
public func open(_ at: FoundDesktop, phone: KeyPair, desktopKey: Data, appVersion: String) async throws -> DesktopSession {
- let t = try await NWTransport.connect(to: at.endpoint)
- do { return try await NoiseSession.open(t, phone: phone, desktopKey: desktopKey, appVersion: appVersion) } catch {
- t.close()
- throw error
+ // a refused key counts only if every endpoint refused it
+ try await eachEndpoint(at.endpoints, soft: { $0 as? SyncError == .unrecognised }) { endpoint in
+ let t = try await NWTransport.connect(to: endpoint)
+ do { return try await NoiseSession.open(t, phone: phone, desktopKey: desktopKey, appVersion: appVersion) } catch {
+ t.close()
+ throw error
+ }
}
}
}
@@ -78,7 +84,9 @@ public struct SyncConfig: Sendable {
public var pullLimit = 200
/// raw bytes per uploadAudio: base64 of 44000 bytes keeps each message under the 60000-byte chunking limit
public var audioChunk = 44000
+ /// the computer's audio fetched to play here; what isn't played for `keepAudioFor` is removed at launch
public var audioFolder = URL.cachesDirectory.appending(path: "Yogurt audio", directoryHint: .isDirectory)
+ public var keepAudioFor: TimeInterval = 7 * 86400
/// a recording's WAV while it goes to the computer; emptied at launch
public var uploadFolder = FileManager.default.temporaryDirectory.appending(path: "Yogurt uploads", directoryHint: .isDirectory)
/// bytes free where the WAV is made (nil when iOS won't say)
@@ -160,6 +168,7 @@ public final class SyncEngine: SyncEngineProtocol {
roundBackoff = config.retryFrom
// WAVs a killed or crashed run left behind
try? FileManager.default.removeItem(at: config.uploadFolder)
+ PrivateFolder.prune(config.audioFolder, unusedFor: config.keepAudioFor)
pairing = vault.load()
status = .notPaired
if let pairing { status = .offline(pairing.desktopName, lastSync: lastSync) }
@@ -263,7 +272,12 @@ public final class SyncEngine: SyncEngineProtocol {
private func foundChanged(_ list: [FoundDesktop]) {
let before = Set(found.map(\.desktop.id))
found = list
- discovered = list.map(\.desktop)
+ // the advert names no one; the paired computer is known by the name it gave in pairing
+ discovered = list.map { f in
+ var d = f.desktop
+ if d.name.isEmpty, let pairing, d.id == pairing.desktopId { d.name = pairing.desktopName }
+ return d
+ }
guard let pairing, session == nil else { return }
// the computer just showed up: no reason to wait out the backoff
if !before.contains(pairing.desktopId), list.contains(where: { $0.desktop.id == pairing.desktopId }) {
@@ -662,7 +676,7 @@ public final class SyncEngine: SyncEngineProtocol {
let source = rec.audioURL, part = wav.appendingPathExtension("part")
// made off the main actor, under another name until it's whole
let made = await Task.detached(priority: .utility) { () -> Bool in
- try? FileManager.default.createDirectory(at: wav.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try? PrivateFolder.make(wav.deletingLastPathComponent())
do {
try PhoneAudio.wav(from: source, to: part)
try FileManager.default.moveItem(at: part, to: wav)
@@ -712,8 +726,12 @@ public final class SyncEngine: SyncEngineProtocol {
/// A track fetched before, if it's still in the caches folder.
public func cachedAudio(meetingId: String, track: String = "them") -> URL? {
let names = (try? FileManager.default.contentsOfDirectory(atPath: config.audioFolder.path)) ?? []
- return names.first { $0.hasPrefix("\(meetingId)-\(track).") && PlayerLogic.canPlay(ext: ($0 as NSString).pathExtension) }
- .map { config.audioFolder.appending(path: $0) }
+ guard let name = names.first(where: { $0.hasPrefix("\(meetingId)-\(track).") && PlayerLogic.canPlay(ext: ($0 as NSString).pathExtension) })
+ else { return nil }
+ let file = config.audioFolder.appending(path: name)
+ // played again: kept another `keepAudioFor`
+ PrivateFolder.touch(file)
+ return file
}
/// One track of a desktop meeting's audio ("me" is the mic, "them" the call; a phone recording is "them"),
@@ -721,7 +739,7 @@ public final class SyncEngine: SyncEngineProtocol {
public func audioURL(meetingId: String, track: String = "them", progress: (@MainActor (Double) -> Void)? = nil) async throws -> URL {
if let file = cachedAudio(meetingId: meetingId, track: track) { return file }
guard let s = session else { throw SyncError.notConnected }
- try FileManager.default.createDirectory(at: config.audioFolder, withIntermediateDirectories: true)
+ try PrivateFolder.make(config.audioFolder)
// its own name, so two fetches of the same track can't write into one file
let part = config.audioFolder.appending(path: "\(UUID().uuidString).part")
FileManager.default.createFile(atPath: part.path, contents: nil)
diff --git a/ios/YogurtKit/Tests/YogurtKitTests/PrivacyTests.swift b/ios/YogurtKit/Tests/YogurtKitTests/PrivacyTests.swift
new file mode 100644
index 00000000..67e81ee6
--- /dev/null
+++ b/ios/YogurtKit/Tests/YogurtKitTests/PrivacyTests.swift
@@ -0,0 +1,144 @@
+import Foundation
+import Network
+import Testing
+@testable import YogurtKit
+
+private func tempFolder(_ name: String = "yogurt-privacy") -> URL {
+ FileManager.default.temporaryDirectory.appendingPathComponent("\(name)-\(UUID().uuidString)", isDirectory: true)
+}
+
+private func age(_ url: URL, days: Double) throws {
+ try FileManager.default.setAttributes([.modificationDate: Date().addingTimeInterval(-days * 86400)], ofItemAtPath: url.path)
+}
+
+@Suite struct PrivateFolderTests {
+ @Test func pruningRemovesWhatWasNotUsedForAWhileAndKeepsTheRest() throws {
+ let url = tempFolder()
+ defer { try? FileManager.default.removeItem(at: url) }
+ try PrivateFolder.make(url)
+ let old = url.appendingPathComponent("m1-them.m4a"), fresh = url.appendingPathComponent("m2-them.m4a")
+ try Data("old".utf8).write(to: old)
+ try Data("fresh".utf8).write(to: fresh)
+ try age(old, days: 8)
+ try age(fresh, days: 6)
+ PrivateFolder.prune(url, unusedFor: 7 * 86400)
+ #expect(!FileManager.default.fileExists(atPath: old.path))
+ #expect(FileManager.default.fileExists(atPath: fresh.path))
+ // a folder that isn't there is nothing to do
+ PrivateFolder.prune(tempFolder(), unusedFor: 1)
+ }
+}
+
+@MainActor @Suite struct CachedAudioTests {
+ @Test func audioFetchedLongAgoAndNotPlayedSinceIsGoneAtLaunch() async throws {
+ var config = testConfig()
+ try PrivateFolder.make(config.audioFolder)
+ let old = config.audioFolder.appendingPathComponent("m1-them.m4a"), fresh = config.audioFolder.appendingPathComponent("m2-them.m4a")
+ try Data("old".utf8).write(to: old)
+ try Data("fresh".utf8).write(to: fresh)
+ try age(old, days: 8)
+ try age(fresh, days: 1)
+ config.keepAudioFor = 7 * 86400
+ let rig = try Rig(config: config)
+ #expect(!FileManager.default.fileExists(atPath: old.path))
+ #expect(rig.engine.cachedAudio(meetingId: "m2") == fresh)
+ }
+
+ @Test func playingCachedAudioCountsAsUsingIt() async throws {
+ let config = testConfig()
+ try PrivateFolder.make(config.audioFolder)
+ let file = config.audioFolder.appendingPathComponent("m1-them.m4a")
+ try Data("audio".utf8).write(to: file)
+ try age(file, days: 6)
+ let rig = try Rig(config: config)
+ #expect(rig.engine.cachedAudio(meetingId: "m1") == file)
+ let used = try #require(try file.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate)
+ #expect(Date().timeIntervalSince(used) < 60)
+ }
+}
+
+@Suite struct LeftoverPairingTests {
+ @Test func aFreshInstallForgetsAPairingTheKeychainKeptFromBefore() {
+ let defaults = UserDefaults(suiteName: "yogurt-tests-\(UUID().uuidString)")!
+ let vault = MemoryVault(testPairing())
+ LeftoverPairing.forget(defaults: defaults, vault: vault, protectedDataAvailable: true)
+ #expect(vault.load() == nil)
+ }
+
+ @Test func anInstallThatWasSetUpKeepsItsPairing() {
+ let defaults = UserDefaults(suiteName: "yogurt-tests-\(UUID().uuidString)")!
+ defaults.set(true, forKey: "onboarded")
+ let vault = MemoryVault(testPairing())
+ LeftoverPairing.forget(defaults: defaults, vault: vault, protectedDataAvailable: true)
+ #expect(vault.load() != nil)
+ }
+
+ @Test func beforeTheFirstUnlockNothingIsForgotten() {
+ // the settings can't be read yet, so "not onboarded" can't be trusted
+ let defaults = UserDefaults(suiteName: "yogurt-tests-\(UUID().uuidString)")!
+ let vault = MemoryVault(testPairing())
+ LeftoverPairing.forget(defaults: defaults, vault: vault, protectedDataAvailable: false)
+ #expect(vault.load() != nil)
+ }
+}
+
+@Suite struct DiscoveryTests {
+ private let real = NWEndpoint.hostPort(host: "192.168.1.20", port: 7000)
+ private let fake = NWEndpoint.hostPort(host: "192.168.1.66", port: 7000)
+
+ @Test func everyAdvertForOneComputerIsKeptSoAFakeOneCanNotHideTheRealOne() {
+ let found = BonjourBrowser.desktops([
+ (["v": "1", "id": "desk-1", "pairing": "0"], fake),
+ (["v": "1", "id": "desk-1", "pairing": "0"], real),
+ (["v": "1", "id": "desk-2", "pairing": "1"], real),
+ (["v": "2", "id": "desk-3"], real),
+ (["v": "1", "id": ""], real),
+ ])
+ #expect(found.map(\.desktop.id).sorted() == ["desk-1", "desk-2"])
+ let one = try! #require(found.first { $0.desktop.id == "desk-1" })
+ #expect(one.endpoints == [fake, real])
+ }
+
+ @Test func theAdvertNamesNoComputer() {
+ let found = BonjourBrowser.desktops([(["v": "1", "id": "desk-1", "pairing": "1", "name": "Someone's MacBook"], real)])
+ // a name in an old advert is ignored too: the real one comes sealed in pairing
+ #expect(found.first?.desktop.name == "")
+ #expect(found.first?.desktop.pairing == true)
+ }
+
+ @Test func eachEndpointIsTriedAndARefusalCountsOnlyWhenAllRefused() async throws {
+ // the fake refuses the key, the real one answers
+ let r = try await eachEndpoint([1, 2], soft: { $0 as? SyncError == .unrecognised }) { n -> String in
+ if n == 1 { throw SyncError.unrecognised }
+ return "real"
+ }
+ #expect(r == "real")
+ await #expect(throws: SyncError.unrecognised) {
+ try await eachEndpoint([1, 2], soft: { $0 as? SyncError == .unrecognised }) { _ -> String in throw SyncError.unrecognised }
+ }
+ // one refused and one couldn't be reached: not a refusal, so it doesn't count towards "pair again"
+ await #expect(throws: SyncError.timeout) {
+ try await eachEndpoint([1, 2], soft: { $0 as? SyncError == .unrecognised }) { n -> String in
+ throw n == 1 ? SyncError.unrecognised : SyncError.timeout
+ }
+ }
+ // iOS refusing the local network stops at once: every endpoint would say the same
+ var tried: [Int] = []
+ await #expect(throws: SyncError.localNetworkDenied) {
+ try await eachEndpoint([1, 2], soft: { _ in true }) { n -> String in tried.append(n); throw SyncError.localNetworkDenied }
+ }
+ #expect(tried == [1])
+ }
+}
+
+@MainActor @Suite struct DiscoveredNameTests {
+ @Test func thePairedComputerIsListedByTheNameItGaveWhenPairing() async throws {
+ let rig = try Rig()
+ rig.network.shown = [FoundDesktop(desktop: DiscoveredDesktop(id: "desk-1", name: "", pairing: false), endpoint: .hostPort(host: "127.0.0.1", port: 1)),
+ FoundDesktop(desktop: DiscoveredDesktop(id: "other", name: "", pairing: true), endpoint: .hostPort(host: "127.0.0.1", port: 2))]
+ rig.engine.setForeground(true)
+ #expect(await eventually { rig.engine.discovered.count == 2 })
+ #expect(rig.engine.discovered.first { $0.id == "desk-1" }?.name == "Test Mac")
+ #expect(rig.engine.discovered.first { $0.id == "other" }?.name == "")
+ }
+}