27 lines
766 B
TypeScript
27 lines
766 B
TypeScript
/**
|
|
* Process-local access-token bridge used by the HTTP client.
|
|
*
|
|
* IMPORTANT:
|
|
* - This module must never import Zustand or any API client.
|
|
* - The auth store writes the current access token here.
|
|
* - api/client.ts reads it from here.
|
|
*
|
|
* This deliberately breaks the dependency cycle:
|
|
* auth.store -> api client -> auth.store
|
|
*/
|
|
|
|
let currentAccessToken: string | null = null;
|
|
|
|
export function setApiAccessToken(token: string | null | undefined): void {
|
|
const normalized = typeof token === "string" ? token.trim() : "";
|
|
currentAccessToken = normalized.length > 0 ? normalized : null;
|
|
}
|
|
|
|
export function getApiAccessToken(): string | null {
|
|
return currentAccessToken;
|
|
}
|
|
|
|
export function clearApiAccessToken(): void {
|
|
currentAccessToken = null;
|
|
}
|