Skip to content

fix(security): persist lockout state across app relaunch - #63

Merged
EmeditWeb merged 1 commit into
mainfrom
fix/security-store-persist
Sep 28, 2026
Merged

EmeditWeb merged 1 commit into
mainfrom
fix/security-store-persist

Conversation

@EmeditWeb

Copy link
Copy Markdown
Member

Summary

Closes #39

The security store held isLocked and failedAttempts in memory only, so killing and relaunching the app reset the failed-attempt count to zero — a user could bypass the 3-attempt lockout by relaunching between guesses. This persists both fields to SecureStore (localStorage on web), restores them on launch before the app renders, and clears them on sign-out. The attempt-count/lockout policy is extracted into a pure, unit-tested src/security/lockout.ts and reused by the biometric gate.

This repo is for the React Native mobile app only

  • My changes are React Native components or Expo code
  • I have NOT added web-only APIs (window, document, localStorage)
  • I have NOT hardcoded hex color values (use constants/colors.ts only)
  • All icons are from lucide-react-native only
  • No API calls made directly in screen files (use services/ layer only)
  • Every screen has loading, error, and empty states

Note: localStorage is used only inside the SecureStore adapter's Platform.OS === 'web' branch, mirroring the existing stores/auth.store.ts pattern — not in a screen or component.

Type of change

  • Bug fix
  • Service or store change

Testing

  • npx expo export --platform web passes
  • No TypeScript errors
  • No hardcoded hex colors
  • No console errors

New src/security/lockout.test.ts covers the count-up, threshold, past-threshold, and malformed-input cases. hydrate() is wired into app/_layout.tsx alongside the existing auth/user hydration and the render is gated on it so a locked session is never briefly shown unlocked; the auto-lock effect now waits for security hydration to avoid a rehydrate race. npm run typecheck, npm test, npm run lint, and npx expo export --platform web all pass.

Context files reviewed

  • context/architecture-context.md
  • context/code-standards.md

@EmeditWeb
EmeditWeb merged commit ecd7624 into main Sep 28, 2026
4 checks passed
@EmeditWeb
EmeditWeb deleted the fix/security-store-persist branch September 28, 2026 12:41
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.

fix: persist security store state to prevent lockout bypass

1 participant