TokenRefresher typedef

TokenRefresher = Future<Result<Token>> Function(Token current)

A function that exchanges the current token for a fresh one.

Implementations MUST NOT throw — return Error(Failure.unauthorized(...)) or Error(Failure.network(...)) instead. Use Failure.unauthorized (or any 401-coded failure) to indicate that the refresh token is no longer valid: this triggers TokenKeeper to clear storage and emit a TokenClearedEvent. Other failures are surfaced via RefreshFailedEvent without clearing storage so the caller can retry later.

Implementation

typedef TokenRefresher = Future<Result<Token>> Function(Token current);