Skip to content

Add optional vault auto-unlock via system keyring#9

Merged
henricook merged 3 commits into
mainfrom
feat/vault-auto-unlock
Jul 5, 2026
Merged

Add optional vault auto-unlock via system keyring#9
henricook merged 3 commits into
mainfrom
feat/vault-auto-unlock

Conversation

@henricook

Copy link
Copy Markdown
Owner
  • New v2 key-slot vault envelope: a random data key encrypts the payload, wrapped by one or more key slots with all slots bound into the payload AAD.
  • Keyring slot stores its KEK in flutter_secure_storage (VaultKeyringService, read-back verified); startup auto-unlock reads it and silently falls back to the password prompt on any failure.
  • v1 vaults still decrypt and are transparently upgraded to v2 after a successful password unlock.
  • Opt-in toggle in the storage menu with a trade-off confirmation dialog, also offered once after vault migration.
  • Lockout-safe orderings: enable writes the keyring key before adding the slot and rolls back on save failure; disable drops the slot before deleting the key; password change re-wraps only the password slot so auto-unlock survives.
  • Unknown slot types are skipped on unlock and preserved verbatim on save for forward compatibility.

henricook added 2 commits July 5, 2026 14:55
Introduce a v2 key-slot vault envelope so the local vault can be
unlocked without a password on a trusted device.

- v2 envelope wraps a random data key with one or more key slots
  (password + optional keyring), binding all slots into the payload AAD
- keyring slot stores its KEK in flutter_secure_storage with a
  read-back verify; auto-unlock reads it at startup and silently falls
  back to the password prompt on any failure
- v1 vaults still decrypt and are transparently upgraded to v2 after a
  successful password unlock
- opt-in toggle with a trade-off confirmation dialog, offered once after
  vault migration; unknown slot types are preserved for forward compat
- lockout-safe orderings: enable writes the keyring key before adding
  the slot and rolls back on save failure; disable drops the slot before
  deleting the key; password changes re-wrap only the password slot
- Guard all vault write paths (enable/disable auto-unlock, change
  password, migrate) against a concurrent operation, since the busy
  overlay does not cover the storage menu
- Log the primary failure and surface the exception text when enabling
  or disabling auto-unlock, in OtpState and the dashboard
- Drop the cached vault password once a v2 session is established; keep
  it only for the v1 legacy fallback
- Set the macOS keychain accessibility constraint to match iOS
- Remove the unused readVersion helper
- Add tests: v1 to v2 upgrade (success and fallback), enable rollback on
  save failure, concurrent-operation guard, missing keyring entry, and
  toggle guard clauses
- Document the keyring service and the silent auto-unlock step in
  CLAUDE.md
@henricook
henricook marked this pull request as ready for review July 5, 2026 15:49
@henricook
henricook merged commit deed78c into main Jul 5, 2026
1 check passed
@henricook
henricook deleted the feat/vault-auto-unlock branch July 5, 2026 16:10
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