Repository navigation
[MOO-2540]: Make device-bound iOS keychain - #76
MxKevinBeqo wants to merge 2 commits into
Conversation
Set after-first-unlock device-only accessibility for encrypted values and session cookies. Migrate legacy items in place and preserve readable data on migration failure. Add an opt-in strict getter for authoritative missing-key detection. Decode existing cookie archives using their NSCoding format so sessions remain restorable. Keep legacy getter behavior and Android storage policy unchanged. Refs: MOO-2540 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add native coverage for accessibility migration, failure retries, strict reads, and session-cookie persistence and restoration. Extend the iOS example harness with a Debug-only attribute inspector and legacy fixtures. Wire the CocoaPods test spec, package its sources, and document native test execution. Refs: MOO-2540 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
stelselim
left a comment
There was a problem hiding this comment.
Some LLM's findings for the changes, if you think these already covered we can proceed!
-
The MR calls a cookie method the pinned PR build doesn't have. The MR's recovery code uses MxCookie.clearForUrl, but PR #76's head (8a45ec7, which the MR pins) only
has clearAll. Recovery writes a "cleaning" marker before it checks for that method. So any restored iOS install would throw at startup on every launch and never start.
The Jest test mocks clearForUrl, which hides this. Fix: add clearForUrl to the PR, or fall back to clearAll() in the MR, and do the check before writing the marker. -
Cookie copy left behind. If keychain migration fails, SessionCookieStore.restore() no longer deletes the stored cookie copy. That item can still travel in backups,
which is the exact case the PR is meant to close.
This PR makes the below changes:
The recommendation is using AfterFirstUnlock over WhenUnlocked so reads from the background (sync, push and background fetch handlers) keep working. The existing errSecInteractionNotAllowed handling stays as it is.
Migrate existing items: on first read, or once at startup, upgrade items already on devices with SecItemUpdate, using a query on kSecClass + kSecAttrAccount and attributes { kSecAttrAccessible: … }. If the update fails, log it and leave the item unchanged; never delete it.
Handle a restored backup (critical): after a restore to a new device, the encrypted SQLite file comes back but dbpassword no longer does. Today getOrCreateDbPassword() (client, client/native/nativeDatabaseHelpers.ts:139) would generate a new key and fail to open the existing DB. The client needs a recovery path for "DB file exists but key is missing": delete the DB, clear the session and force a resync/login. This needs coordination with the client/Offline team; open a linked ticket if it lives in appdev.