import type { RefreshableAccount, RefreshResult, TokenPersistTarget } from "../types/index.js";
/**
 * An upstream refresh error body is logged for diagnosis, never verbatim: a
 * token endpoint can echo the grant it rejected, and anything that looks like
 * a credential is masked before the line is written.
 */
export declare function redactRefreshErrorBody(body: string): string;
export declare function needsRefresh(account: RefreshableAccount): boolean;
export declare function needsBackgroundRefresh(account: RefreshableAccount): boolean;
export declare function needsInlineRefresh(account: RefreshableAccount): boolean;
export declare function isPermanentRefreshFailure(result: RefreshResult): boolean;
/**
 * Serialize refreshes by refresh-token value. OAuth refresh tokens may rotate,
 * so concurrent refreshes with the same old token can make all but the first
 * request fail with invalid_grant. A short success cache covers callers that
 * loaded either the old token or the newly rotated token around persistence.
 */
export declare function refreshToken(account: RefreshableAccount): Promise<RefreshResult>;
/**
 * Refreshes against the latest persisted credential generation. Queued
 * requests can otherwise reject a rotated refresh token and disable a newer
 * login that was saved while they were waiting.
 */
export declare function refreshTokenFromLatest(account: RefreshableAccount, target?: TokenPersistTarget): Promise<RefreshResult>;
export declare function clearRefreshStateForTests(): void;
export declare function persistTokens(target: TokenPersistTarget, account: RefreshableAccount): Promise<void>;
