TokenRepository
Component Detail
Data Layer
medium complexity
mobilefrontend
0
Dependencies
0
Dependents
0
Entities
0
Integrations
Description
A local persistence layer responsible for securely storing, retrieving, and invalidating JWT access and refresh tokens on the device or browser. It abstracts the underlying storage mechanism (secure keychain on mobile, httpOnly cookie or localStorage on web) so that AuthService and screens never deal directly with raw storage APIs. It also handles token expiry checks and clearing tokens on logout.
token-repository
Sources & reasoning
Lines 42 and 319 both explicitly mark email/password as the MVP authentication method while deferring BankID and Vipps to Phase 2. Phase 1 = MVP by ordinal mapping. The feature is foundational - no other platform capability works without authenticated sessions.
-
docs/source/likeperson.md · line 42MVP leveres med e-post/passord-innlogging; BankID og Vipps ruller ut i Fase 2
-
docs/source/likeperson.md · line 319E-post/passord innlogging (BankID/Vipps i fase 2)
Responsibilities
- Persist JWT access and refresh tokens to secure platform-appropriate storage
- Retrieve stored tokens for use in authenticated API requests
- Check token expiry and flag when a refresh is required
- Clear all stored tokens on logout or session invalidation
Interfaces
saveTokens(accessToken: string, refreshToken: string): Promise<void>
getAccessToken(): Promise<string | null>
getRefreshToken(): Promise<string | null>
clearTokens(): Promise<void>
isTokenExpired(token: string): boolean