/** * Auth store — manages the ~/.go-easy/ token store. * * Responsibilities: * - Read/write accounts.json (v1 schema, atomic writes) * - File permissions (0o700 dir, 0o600 files) * - Provide typed account/token resolution * * Does NOT handle OAuth flows — that's auth-flow.ts (Phase 2). */ export type GoogleService = 'gmail' | 'drive' | 'calendar' | 'tasks'; export interface OAuthToken { refreshToken: string; scopes: string[]; grantedAt: string; } export interface GoEasyAccount { email: string; tokens: { combined?: OAuthToken; gmail?: OAuthToken; drive?: OAuthToken; calendar?: OAuthToken; tasks?: OAuthToken; }; addedAt: string; } export interface AccountStore { version: 1; accounts: GoEasyAccount[]; } export interface OAuthCredentials { clientId: string; clientSecret: string; } /** Get the go-easy config directory path */ export declare function getConfigDir(): string; /** Get the pending auth directory path */ export declare function getPendingDir(): string; /** * Read the account store. Returns null if it doesn't exist. */ export declare function readAccountStore(): Promise; /** * Write the account store atomically. * Creates ~/.go-easy/ if needed with correct permissions. */ export declare function writeAccountStore(store: AccountStore): Promise; /** * Read OAuth credentials (clientId + clientSecret). * Returns null if credentials.json doesn't exist. */ export declare function readCredentials(): Promise; /** * Write OAuth credentials. */ export declare function writeCredentials(creds: OAuthCredentials): Promise; /** * Find an account in the store by email (case-insensitive). * If no email given, returns the first account. */ export declare function findAccount(store: AccountStore, email?: string): GoEasyAccount | undefined; /** * Resolve the token for a specific service from an account. * * Priority: combined (if it has the scope) > per-service token. */ export declare function resolveToken(account: GoEasyAccount, service: GoogleService): { refreshToken: string; scopes: string[]; } | null; /** * Upsert an account in the store. Merges tokens if account exists. */ export declare function upsertAccount(store: AccountStore, account: GoEasyAccount): AccountStore; /** * Remove an account from the store by email. * Returns true if found and removed. */ export declare function removeAccount(store: AccountStore, email: string): boolean; //# sourceMappingURL=auth-store.d.ts.map