RefreshCoordinator

class RefreshCoordinator(sessionStorage: SessionStorage)

The app runs two independent Ktor HttpClients against SessionStorage — the general one in networkModule and the dedicated one in authModule — each with its own Auth plugin, so each only single-flights refreshes against itself. The server's refresh token is single-use, so without cross-client coordination, concurrent 401s on both clients can each present the same stored refresh token; the second submission gets flagged as replay and the whole session is revoked. This mutex serializes refresh attempts across every client sharing it (wire the same Koin-provided instance into both), and a caller that loses the race is handed whatever the winner already stored instead of replaying a token that's already been consumed.

Constructors

Link copied to clipboard
constructor(sessionStorage: SessionStorage)

Functions

Link copied to clipboard
suspend fun refresh(presentedRefreshToken: String, rotate: suspend (String) -> Pair<String, String>?): Pair<String, String>?