Skip to content

[MOO-2540]: Make device-bound iOS keychain - #76

Open
MxKevinBeqo wants to merge 2 commits into
mx/11.12.xfrom
moo/MOO-2540-device-bound-ios-keychain
Open

MxKevinBeqo wants to merge 2 commits into
mx/11.12.xfrom
moo/MOO-2540-device-bound-ios-keychain

Conversation

@MxKevinBeqo

Copy link
Copy Markdown
Contributor

This PR makes the below changes:

  • Set kSecAttrAccessible: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly in both EncryptedStorage.setItem and SessionCookieStore.set.

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.

MxKevinBeqo and others added 2 commits November 11, 2026 10:49
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant