1.1 Secure Token Storage Foundation
Sprint Key: 1-1-secure-token-storage-foundation
Epic: 1
PRD: mobile-oidc
Story 1.1: Secure Token Storage Foundation
Status: ready-for-dev
Story
As a mobile app, I want a secure token storage abstraction backed by the platform keystore, so that authentication tokens are encrypted at rest and the auth stack is fully testable without platform dependencies.
Acceptance Criteria
-
AC1 - Dependencies added:
flutter_secure_storage,flutter_appauth,flutter_riverpod, andapp_linksare added topubspec.yamland all packages resolve successfully withflutter pub get.shared_preferencesandcryptoremain inpubspec.yaml(removed later in Epic 6). -
AC2 - SecureTokenStorage saves tokens as JSON blob:
SecureTokenStorage.saveTokens()called with accessToken, idToken, refreshToken, and expiresIn stores all values as a single JSON blob under one key (auth_tokens) in the platform keystore.expiresInis stored as the calculated absolute expiration date (DateTime.now().add(Duration(seconds: expiresIn))). -
AC3 - SecureTokenStorage reads individual tokens:
getAccessToken(),getIdToken(),getRefreshToken(), andgetAccessTokenExpiration()each return the corresponding value from the stored JSON blob. -
AC4 - deleteAll removes stored tokens:
deleteAll()removes theauth_tokenskey from the platform keystore. -
AC5 - InMemoryTokenStorage mirrors SecureTokenStorage:
InMemoryTokenStorageprovides identical behavior toSecureTokenStoragebut without platform dependencies. All unit tests pass without requiring a device emulator. -
AC6 - deleteAll silently handles keystore failure: If
deleteAll()fails due to keystore unavailability, the error is caught and does not propagate.