import type { ClioRegion } from "../utils/clioRegion.js"; export interface ClioTokens { access_token: string; refresh_token: string; /** Unix timestamp in milliseconds. */ expires_at: number; clio_user_id?: string; /** true when who_am_i returned 403; stops further retries. */ user_id_unavailable?: boolean; } export interface ClioOAuthClient { clientId: string; clientSecret: string; /** Picks the regional endpoints. When omitted and no explicit URL is given, the process env decides (CLIO_REGION and overrides). */ region?: ClioRegion; authorizeUrl?: string; tokenUrl?: string; apiBaseUrl?: string; } export interface ClioWhoAmI { id: string; name?: string; email?: string; accountId?: string; accountName?: string; } /** A non-2xx answer from Clio's OAuth or who_am_i endpoints. `code` is the OAuth error code when Clio sent one (e.g. invalid_grant). */ export declare class ClioOAuthError extends Error { readonly status: number; readonly body: string; readonly code?: string | undefined; constructor(status: number, body: string, code?: string | undefined); } /** RFC 7636 code verifier: 43 base64url characters from 32 random bytes. */ export declare function generateCodeVerifier(): string; /** RFC 7636 S256 challenge for a verifier. */ export declare function deriveCodeChallenge(verifier: string): string; type EndpointSource = { region?: ClioRegion; authorizeUrl?: string; tokenUrl?: string; apiBaseUrl?: string; }; export declare function buildClioAuthorizeUrl(p: { clientId: string; redirectUri: string; state: string; region?: ClioRegion; authorizeUrl?: string; codeChallenge?: string; scope?: string; }): string; export declare function exchangeClioCode(p: ClioOAuthClient & { redirectUri: string; code: string; codeVerifier?: string; }): Promise; /** Refresh. Clio's refresh tokens do not expire and are not documented as rotating; the old one is kept when the response has none. */ export declare function refreshClioTokens(p: ClioOAuthClient & { refreshToken: string; }): Promise; /** * GET /users/who_am_i.json. `fields` defaults to id,name,email; pass * "id,name,email,account{id,name}" once your Clio app is confirmed to have the * permission for it (Clio answers 400 to unknown fields). */ export declare function fetchClioWhoAmI(accessToken: string, opts?: EndpointSource & { fields?: string; }): Promise; export {}; //# sourceMappingURL=clioOAuth.d.ts.map