sourcewizard
Version:
SourceWizard - AI-powered setup wizard for dev tools and libraries with MCP integration
70 lines (69 loc) • 1.75 kB
TypeScript
import { SupabaseAuthClient } from "@supabase/supabase-js/src/lib/SupabaseAuthClient.js";
export interface StoredTokens {
accessToken: string;
refreshToken: string;
expiresAt: number;
user: {
id: string;
email: string;
};
}
export declare class TokenStorage {
private configDir;
private tokenFilePath;
private logsDir;
private auth?;
private refreshPromise?;
constructor(configDir: string, authClient?: SupabaseAuthClient);
/**
* Set the auth client for token refresh operations
*/
setAuthClient(authClient: SupabaseAuthClient): void;
/**
* Ensure the config directory exists
*/
private ensureConfigDir;
/**
* Ensure the logs directory exists
*/
private ensureLogsDir;
/**
* Log error to file in logs directory
*/
private logError;
/**
* Store authentication tokens
*/
storeTokens(tokens: StoredTokens): Promise<void>;
/**
* Refresh tokens using the stored refresh token
*/
private refreshTokens;
/**
* Perform the actual token refresh
*/
private performRefresh;
/**
* Attempt to refresh tokens on startup - doesn't clear tokens on failure
*/
attemptStartupRefresh(): Promise<boolean>;
/**
* Retrieve stored authentication tokens with automatic refresh
*/
getTokens(): Promise<StoredTokens | null>;
/**
* Clear stored authentication tokens
*/
clearTokens(): Promise<void>;
/**
* Check if valid tokens exist
*/
hasValidTokens(): Promise<boolean>;
/**
* Get the stored user information
*/
getStoredUser(): Promise<{
id: string;
email: string;
} | null>;
}