Skip to content

fix(ios): recover session from biometric Keychain when cookies are missing#32150

Merged
Jasonnnz merged 1 commit into
Jasonnnz/ios-session-persistfrom
ios-session-persist/pr-2-biometric-recovery
May 26, 2026
Merged

fix(ios): recover session from biometric Keychain when cookies are missing#32150
Jasonnnz merged 1 commit into
Jasonnnz/ios-session-persistfrom
ios-session-persist/pr-2-biometric-recovery

Conversation

@Jasonnnz
Copy link
Copy Markdown
Contributor

Summary

  • Add biometric session recovery fallback to initSession() in auth-store
  • When session cookie is missing on iOS, attempt to restore from Keychain via Face ID/Touch ID
  • Gated behind isNativePlatform() and isBiometricEnabled() — no change on web
  • Add tests for recovery path, skip conditions, and expired token fallthrough

Part of plan: ios-session-persist.md (PR 2 of 4)

…ssing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jasonnnz Jasonnnz merged commit 64ca092 into Jasonnnz/ios-session-persist May 26, 2026
6 checks passed
@Jasonnnz Jasonnnz deleted the ios-session-persist/pr-2-biometric-recovery branch May 26, 2026 19:00
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5eb67a6b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +119 to +121
installSessionCookies(token);
const retryResult = await getSession();
if (retryResult.ok && retryResult.data.user) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wait for cookie flush before probing recovered session

After writing the recovered token with installSessionCookies(token), this immediately calls getSession() once. In WKWebView, cookie writes are asynchronously flushed to the HTTP cookie store, so the first probe can still be unauthenticated even with a valid token; this causes initSession() to incorrectly fall through to logged-out state and makes biometric recovery flaky on iOS cold starts.

Useful? React with 👍 / 👎.


// Biometric recovery: on iOS, the session cookie may have been lost
// when WKWebView was killed. Try to restore from Keychain via Face ID.
if (isNativePlatform() && isBiometricEnabled()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict biometric fallback to auth-cookie failures

The biometric branch runs for every initial session miss, including transient network errors or server 5xx responses from getSession(), not just missing/expired auth cookies. On native devices with biometrics enabled, this can trigger unnecessary Face ID/Touch ID prompts during outages or offline resumes, even though recovery cannot succeed in those conditions.

Useful? React with 👍 / 👎.

Jasonnnz added a commit that referenced this pull request May 26, 2026
…metric recovery (#32153)

* fix(ios): enable CapacitorCookies to persist session cookies across app kills (#32147)

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ios): add WKAppBoundDomains for reliable cookie persistence (#32148)

Co-authored-by: Vellum Assistant <assistant@vellum.ai>

* fix(ios): recover session from biometric Keychain when cookies are missing (#32150)

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ios): clear biometric Keychain token on logout (#32149)

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove stray merge conflict marker from auth-store test

---------

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.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