CopilotTokenManager class final
In-memory cache of the short-lived Copilot API token for one GitHub token: single-flight exchange, proactive refresh refreshLead before expiry, and at most one exchange per minSpacing (proxy semantics: ~30 min tokens, refresh ~2 min early, never more often than 30 s).
Constructors
- CopilotTokenManager({required String githubToken, Client? client, DateTime now()?, Duration refreshLead = const Duration(minutes: 2), Duration minSpacing = const Duration(seconds: 30)})
-
Creates a manager.
nowis injectable for tests;clientfor mock transports.
Properties
- client → Client?
-
The HTTP transport (injectable for tests; the shared provider client
when null).
final
- githubToken → String
-
The GitHub token exchanged for Copilot API tokens.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- minSpacing → Duration
-
Lower bound between two token exchanges.
final
- refreshLead → Duration
-
Refresh this long before CopilotApiToken.expiresAt.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
) → Future< String> - A Copilot API token valid at call time, exchanging/refreshing as needed. Concurrent callers share one exchange (single-flight).
-
invalidate(
) → void - Drops the cached token and the spacing guard: the next get exchanges immediately (used after a 401/403 from the Copilot API).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
forGithubToken(
String githubToken, {Client? client}) → CopilotTokenManager -
The shared manager for
githubToken, creating it on first use.