syncAuthSessionRefresh function
void
syncAuthSessionRefresh({})
Applies issued-at refresh semantics through write and touch callbacks.
Returns without invoking a callback when updateAge is null. Initialization
and refresh write the current UTC time; refresh also invokes touchSession
when supplied.
Implementation
void syncAuthSessionRefresh({
required String? issuedAtValue,
required Duration? updateAge,
required void Function(DateTime issuedAtUtc) writeIssuedAt,
DateTime? now,
void Function()? touchSession,
}) {
final age = updateAge;
if (age == null) {
return;
}
final current = (now ?? DateTime.now()).toUtc();
final action = authSessionRefreshAction(
issuedAtValue: issuedAtValue,
updateAge: age,
now: current,
);
switch (action) {
case AuthSessionRefreshAction.initialize:
writeIssuedAt(current);
return;
case AuthSessionRefreshAction.refresh:
writeIssuedAt(current);
touchSession?.call();
return;
case AuthSessionRefreshAction.keep:
return;
}
}