import { CreateEventInput, CreateSessionInput, UpdateSessionInput, UpdateEventStatusInput, Event, Session, EventSource, DeviceKey, GrantSessionKeyInput } from '../types';
/**
 * Download URL response
 */
export interface DownloadUrlResponse {
    downloadUrl: string;
    expiresAt: string;
}
/**
 * AppSync GraphQL client with WebSocket subscriptions
 */
export declare class AppSyncClient {
    private authenticated;
    private currentUserId;
    private currentEmail;
    private tokens;
    private activeSubscriptions;
    private deviceKeyWatcher;
    private environment;
    constructor();
    /**
     * Get the current authenticated user ID
     */
    getCurrentUserId(): string;
    /**
     * Get the current authenticated user email
     */
    getCurrentUserEmail(): string | null;
    /**
     * Authenticate using stored OAuth tokens from keychain
     */
    authenticateWithStoredTokens(): Promise<boolean>;
    /**
     * Refresh expired tokens
     */
    private refreshTokens;
    /**
     * Check if authenticated
     */
    isAuthenticated(): boolean;
    /**
     * Sign out
     */
    signOut(): void;
    /**
     * Make a GraphQL request
     */
    private graphqlRequest;
    /**
     * Create a session
     */
    createSession(input: CreateSessionInput): Promise<Session>;
    /**
     * Update a session
     */
    updateSession(input: UpdateSessionInput): Promise<Session>;
    /**
     * Get a session
     */
    getSession(sessionId: string): Promise<Session | null>;
    /**
     * Create an event
     */
    createEvent(input: CreateEventInput): Promise<Event>;
    /**
     * Update event status
     */
    updateEventStatus(input: UpdateEventStatusInput): Promise<Event>;
    /**
     * List events for a session
     */
    listEvents(sessionId: string, source?: EventSource, limit?: number): Promise<Event[]>;
    /**
     * List user device keys
     */
    listUserDeviceKeys(): Promise<DeviceKey[]>;
    /**
     * Register device key
     */
    registerDeviceKey(deviceId: string, publicKey: string, platform: string, deviceName: string): Promise<void>;
    /**
     * Grant a session key to an additional device by appending a new
     * per-device wrapped key blob to the session's encryptedKeys array.
     *
     * This is the client-side entry point for the session re-key flow:
     * when a new device (typically a mobile app) registers for a user who
     * already has active sessions, an already-enrolled device (typically
     * the desktop plugin) wraps the session key for the new device's
     * public key and calls this mutation to append it. The backend VTL
     * resolver enforces that the caller owns the session.
     */
    grantSessionKey(input: GrantSessionKeyInput): Promise<void>;
    /**
     * Get attachment download URL
     */
    getAttachmentDownloadUrl(s3Key: string): Promise<DownloadUrlResponse>;
    /**
     * Subscribe to events for a session
     */
    subscribeToEvents(sessionId: string, onEvent: (event: Event) => void, onError?: (error: Error) => void): () => void;
    /**
     * Build WebSocket URL
     */
    private buildRealtimeUrl;
    /**
     * Create WebSocket subscription
     */
    private createSubscription;
    /**
     * Send subscription start message
     */
    private sendSubscriptionStart;
    /**
     * Reset keep-alive timer
     */
    private resetKeepAliveTimer;
    /**
     * Handle subscription error with two-phase reconnection:
     * Phase 1 (urgent): Exponential backoff for first N attempts
     * Phase 2 (persistent): Fixed interval retry indefinitely
     */
    private handleSubscriptionError;
    /**
     * Cleanup subscription state
     */
    private cleanupSubscriptionState;
    /**
     * Subscribe to device key registrations for the caller's own userId.
     * Returns a cleanup function that stops the subscription.
     */
    subscribeToDeviceKeyRegistered(userId: string, onNewDevice: (device: DeviceKey) => void, onReconnect?: () => void, onError?: (error: Error) => void): () => void;
    /**
     * Public method to stop the device key watcher. Used at plugin shutdown.
     */
    stopDeviceKeyWatcher(): void;
    private stopDeviceKeyWatcherInternal;
    private createDeviceKeyWatcherConnection;
    private sendDeviceKeyWatcherStart;
    private resetDeviceKeyWatcherKeepAlive;
    private handleDeviceKeyWatcherError;
    private heartbeatTimers;
    /**
     * Start periodic heartbeat for a session.
     * Updates lastHeartbeatAt on the session every intervalMs (default 2 minutes).
     */
    startHeartbeat(sessionId: string, intervalMs?: number): void;
    /**
     * Stop heartbeat for a session.
     */
    stopHeartbeat(sessionId: string): void;
    /**
     * Send a single heartbeat update.
     */
    private sendHeartbeat;
    /**
     * Cleanup all subscriptions and heartbeats
     */
    cleanupSubscriptions(): void;
}
