// A provider key left in this phone's Keychain by an old build, and the one // thing left to do about it. // // Provider keys live in `cotton_secrets` — the vault, drawn by Passwords as // "API keys" — and nothing reads the Keychain slots an old build wrote. The AI // settings page ran this forget on every visit; that page folded into // Passwords on 2026-09-14, and the app runs it once at every launch now // (`RootView`), since no settings screen is left to run it. import CottonKit import Foundation /// What 4h's build put in this phone's Keychain, and the one thing left to do /// about it. /// /// Every merge to `main` ships a TestFlight build, so 4h's Keys card was on a /// build that could have been installed and a key pasted into it — into /// `cotton.byok.anthropic` / `cotton.byok.openai`. 4k deleted the code that /// reads and removes those slots. Without this, a live provider credential can /// sit in the Keychain of an installed phone with nothing left that can read /// it, no screen that mentions it and no path that removes it. /// /// This is the one shape of backward compatibility /// [i-m-the-only-cotton-user-the-app-carries-no-backward-compatibili] does not /// argue against, because what is being cleaned up is a SECRET rather than a /// feature: a forget and nothing else. There is no read, no migration into /// `cotton_secrets` (the value would have to cross the boundary again, and the /// person can paste it once), and no slot beyond these two. public enum ByokLegacyKeychain { /// The slots 4h wrote. Spelled out: the enum that named the /// providers went with the AI page, and these two are all there ever were. public static let slots = ["cotton.byok.anthropic", "cotton.byok.openai"] /// Delete them. Idempotent, silent, and safe to call on every visit — /// `SecItemDelete` on a slot that is not there is not an error. /// /// Off the main thread: `SecretStore.swift`'s header refuses a Keychain /// call on it, because a SecurityAgent prompt blocks the whole app. public static func forget(in store: any SecretStore = KeychainSecretStore()) async { await Task.detached(priority: .utility) { for slot in slots { store.forget(slot) } } .value } }