deriveCodeMieExpiresAt function

int deriveCodeMieExpiresAt(
  1. Map<String, String> cookies
)

The expiry (ms epoch) of the first JWT cookie's exp claim.

CodeMie instances have been observed using codemie_access_token, access_token, and other cookie names, so every cookie value that looks like a JWT is inspected. When no JWT with an exp claim is found, falls back to 24h from now.

Implementation

int deriveCodeMieExpiresAt(Map<String, String> cookies) {
  for (final value in cookies.values) {
    final expiresAt = _codeMieJwtExpMs(value);
    if (expiresAt != null) return expiresAt;
  }
  return DateTime.now().millisecondsSinceEpoch + 24 * 60 * 60 * 1000;
}