/**
 * OxyServices - Unified client for Oxy API and Oxy Cloud
 *
 * # Usage Examples
 *
 * ## Browser (ESM/TypeScript)
 *
 * ```typescript
 * import { OxyServices } from './core/OxyServices';
 *
 * const oxy = new OxyServices({
 *   baseURL: 'https://api.oxy.so',
 *   cloudURL: 'https://cloud.oxy.so',
 * });
 *
 * // Authenticate and fetch user
 * await oxy.setTokens('ACCESS_TOKEN');
 * const user = await oxy.getCurrentUser();
 *
 * // Upload a file (browser File API)
 * const fileInput = document.querySelector('input[type=file]');
 * const file = fileInput.files[0];
 * await oxy.uploadFile(file);
 *
 * // Get a file stream URL for <img src>
 * const url = oxy.getFileStreamUrl('fileId');
 * ```
 *
 * ## Node.js (CommonJS/TypeScript)
 *
 * ```typescript
 * import { OxyServices } from './core/OxyServices';
 * import fs from 'fs';
 *
 * const oxy = new OxyServices({
 *   baseURL: 'https://api.oxy.so',
 *   cloudURL: 'https://cloud.oxy.so',
 * });
 *
 * // Authenticate and fetch user
 * await oxy.setTokens('ACCESS_TOKEN');
 * const user = await oxy.getCurrentUser();
 *
 * // Upload a file (Node.js Buffer)
 * const buffer = fs.readFileSync('myfile.png');
 * const blob = new Blob([buffer]);
 * await oxy.uploadRawFile(blob, { filename: 'myfile.png' });
 *
 * // Get a file download URL
 * const url = oxy.getFileDownloadUrl('fileId');
 * ```
 *
 * ## Configuration
 * - `baseURL`: Oxy API endpoint (e.g., https://api.oxy.so)
 * - `cloudURL`: Oxy Cloud/CDN endpoint (e.g., https://cloud.oxy.so)
 *
 * See method JSDoc for more details and options.
 */
import { type AxiosInstance } from 'axios';
import type { OxyConfig as OxyConfigBase, ApiError, User, Notification, AssetInitResponse, AssetUrlResponse, AssetVariant } from '../models/interfaces';
/**
 * OxyConfig - Configuration for OxyServices
 * @property baseURL - The Oxy API base URL (e.g., https://api.oxy.so)
 * @property cloudURL - The Oxy Cloud (file storage/CDN) URL (e.g., https://cloud.oxy.so)
 */
export interface OxyConfig extends OxyConfigBase {
    cloudURL?: string;
}
import type { SessionLoginResponse } from '../models/session';
import { type PaginationParams } from '../utils/apiUtils';
/**
 * Custom error types for better error handling
 */
export declare class OxyAuthenticationError extends Error {
    readonly code: string;
    readonly status: number;
    constructor(message: string, code?: string, status?: number);
}
export declare class OxyAuthenticationTimeoutError extends OxyAuthenticationError {
    constructor(operationName: string, timeoutMs: number);
}
export declare class OxyServices {
    protected client: AxiosInstance;
    private tokenStore;
    private cloudURL;
    /**
     * Creates a new instance of the OxyServices client
     * @param config - Configuration for the client
     */
    /**
     * Creates a new instance of the OxyServices client
     * @param config - Configuration for the client
     *   config.baseURL: Oxy API URL (e.g., https://api.oxy.so)
     *   config.cloudURL: Oxy Cloud URL (e.g., https://cloud.oxy.so)
     */
    constructor(config: OxyConfig);
    static __resetTokensForTests(): void;
    /**
     * Setup axios interceptors for authentication and error handling
     */
    private setupInterceptors;
    /**
     * Get the configured Oxy API base URL
     */
    getBaseURL(): string;
    /**
     * Get the configured Oxy Cloud (file storage/CDN) URL
     */
    getCloudURL(): string;
    /**
     * Set authentication tokens
     */
    setTokens(accessToken: string, refreshToken?: string): void;
    /**
     * Clear stored authentication tokens
     */
    clearTokens(): void;
    /**
     * Get the current user ID from the access token
     */
    getCurrentUserId(): string | null;
    /**
     * Check if the client has a valid access token
     */
    private hasAccessToken;
    /**
     * Check if the client has a valid access token (public method)
     */
    hasValidToken(): boolean;
    /**
     * Get the raw access token (for constructing anchor URLs when needed)
     */
    getAccessToken(): string | null;
    /**
     * Wait for authentication to be ready (public method)
     * Useful for apps that want to ensure authentication is complete before proceeding
     */
    waitForAuth(timeoutMs?: number): Promise<boolean>;
    /**
     * Wait for authentication to be ready with timeout
     */
    private waitForAuthentication;
    /**
     * Execute a function with automatic authentication retry logic
     * This handles the common case where API calls are made before authentication completes
     */
    private withAuthRetry;
    /**
     * Validate the current access token with the server
     */
    validate(): Promise<boolean>;
    /**
     * Get the HTTP client instance (public for external use)
     */
    getClient(): AxiosInstance;
    /**
     * Centralized error handling
     */
    protected handleError(error: any): Error;
    /**
     * Health check endpoint
     */
    healthCheck(): Promise<{
        status: string;
        users?: number;
        timestamp?: string;
        [key: string]: any;
    }>;
    /**
     * Sign up a new user
     */
    signUp(username: string, email: string, password: string): Promise<{
        message: string;
        token: string;
        user: User;
    }>;
    /**
     * Request account recovery (send verification code)
     */
    requestRecovery(identifier: string): Promise<{
        delivery?: string;
        destination?: string;
    }>;
    /**
     * Verify recovery code
     */
    verifyRecoveryCode(identifier: string, code: string): Promise<{
        verified: boolean;
    }>;
    /**
     * Reset password using verified code
     */
    resetPassword(identifier: string, code: string, newPassword: string): Promise<{
        success: boolean;
    }>;
    /**
     * Reset password using TOTP code (recommended recovery)
     */
    resetPasswordWithTotp(identifier: string, code: string, newPassword: string): Promise<{
        success: boolean;
    }>;
    resetPasswordWithBackupCode(identifier: string, backupCode: string, newPassword: string): Promise<{
        success: boolean;
    }>;
    resetPasswordWithRecoveryKey(identifier: string, recoveryKey: string, newPassword: string): Promise<{
        success: boolean;
        nextRecoveryKey?: string;
    }>;
    /**
     * Sign in with device management
     */
    signIn(username: string, password: string, deviceName?: string, deviceFingerprint?: any): Promise<SessionLoginResponse | {
        mfaRequired: true;
        mfaToken: string;
        expiresAt: string;
    }>;
    /**
     * Complete login by verifying TOTP with MFA token
     */
    verifyTotpLogin(mfaToken: string, code: string): Promise<SessionLoginResponse>;
    /**
     * Get user by session ID
     */
    getUserBySession(sessionId: string): Promise<User>;
    /**
     * Get access token by session ID and set it in the token store
     */
    getTokenBySession(sessionId: string): Promise<{
        accessToken: string;
        expiresAt: string;
    }>;
    /**
     * Get sessions by session ID
     */
    getSessionsBySessionId(sessionId: string): Promise<any[]>;
    /**
     * Logout from a specific session
     */
    logoutSession(sessionId: string, targetSessionId?: string): Promise<void>;
    /**
     * Logout from all sessions
     */
    logoutAllSessions(sessionId: string): Promise<void>;
    /**
     * Validate session
     */
    validateSession(sessionId: string, options?: {
        deviceFingerprint?: string;
        useHeaderValidation?: boolean;
    }): Promise<{
        valid: boolean;
        expiresAt: string;
        lastActivity: string;
        user: User;
        sessionId?: string;
        source?: string;
    }>;
    /**
     * Check username availability
     */
    checkUsernameAvailability(username: string): Promise<{
        available: boolean;
        message: string;
    }>;
    /**
     * Check email availability
     */
    checkEmailAvailability(email: string): Promise<{
        available: boolean;
        message: string;
    }>;
    /**
     * Get profile by username
     */
    getProfileByUsername(username: string): Promise<User>;
    startTotpEnrollment(sessionId: string): Promise<{
        secret: string;
        otpauthUrl: string;
        issuer: string;
        label: string;
    }>;
    verifyTotpEnrollment(sessionId: string, code: string): Promise<{
        enabled: boolean;
        backupCodes?: string[];
        recoveryKey?: string;
    }>;
    disableTotp(sessionId: string, code: string): Promise<{
        disabled: boolean;
    }>;
    /**
     * Search user profiles
     */
    searchProfiles(query: string, pagination?: PaginationParams): Promise<User[]>;
    /**
     * Get profile recommendations
     */
    getProfileRecommendations(): Promise<Array<{
        id: string;
        username: string;
        name?: {
            first?: string;
            last?: string;
            full?: string;
        };
        description?: string;
        _count?: {
            followers: number;
            following: number;
        };
        [key: string]: any;
    }>>;
    /**
     * Get user by ID
     */
    getUserById(userId: string): Promise<User>;
    /**
     * Get current user
     */
    getCurrentUser(): Promise<User>;
    /**
     * Update user profile
     */
    updateProfile(updates: Record<string, any>): Promise<User>;
    /**
     * Update user by ID (admin function)
     */
    updateUser(userId: string, updates: Record<string, any>): Promise<User>;
    /**
     * Follow a user
     */
    followUser(userId: string): Promise<{
        success: boolean;
        message: string;
    }>;
    /**
     * Unfollow a user
     */
    unfollowUser(userId: string): Promise<{
        success: boolean;
        message: string;
    }>;
    /**
     * Get follow status
     */
    getFollowStatus(userId: string): Promise<{
        isFollowing: boolean;
    }>;
    /**
     * Get user followers
     */
    getUserFollowers(userId: string, pagination?: PaginationParams): Promise<{
        followers: User[];
        total: number;
        hasMore: boolean;
    }>;
    /**
     * Get user following
     */
    getUserFollowing(userId: string, pagination?: PaginationParams): Promise<{
        following: User[];
        total: number;
        hasMore: boolean;
    }>;
    /**
     * Get notifications
     */
    getNotifications(): Promise<Notification[]>;
    /**
     * Get unread notification count
     */
    getUnreadCount(): Promise<number>;
    /**
     * Create notification
     */
    createNotification(data: Partial<Notification>): Promise<Notification>;
    /**
     * Mark notification as read
     */
    markNotificationAsRead(notificationId: string): Promise<void>;
    /**
     * Mark all notifications as read
     */
    markAllNotificationsAsRead(): Promise<void>;
    /**
     * Delete notification
     */
    deleteNotification(notificationId: string): Promise<void>;
    /**
     * Create a payment
     */
    createPayment(data: any): Promise<any>;
    /**
     * Get payment by ID
     */
    getPayment(paymentId: string): Promise<any>;
    /**
     * Get user payments
     */
    getUserPayments(): Promise<any[]>;
    /**
     * Get user karma
     */
    getUserKarma(userId: string): Promise<any>;
    /**
     * Give karma to user
     */
    giveKarma(userId: string, amount: number, reason?: string): Promise<any>;
    /**
     * Get user karma total
     */
    getUserKarmaTotal(userId: string): Promise<any>;
    /**
     * Get user karma history
     */
    getUserKarmaHistory(userId: string, limit?: number, offset?: number): Promise<any>;
    /**
     * Get karma leaderboard
     */
    getKarmaLeaderboard(): Promise<any>;
    /**
     * Get karma rules
     */
    getKarmaRules(): Promise<any>;
    /**
     * Delete file
     */
    deleteFile(fileId: string): Promise<any>;
    /**
     * Get file download URL (API streaming proxy, attaches token for <img src>)
     */
    getFileDownloadUrl(fileId: string, variant?: string, expiresIn?: number): string;
    /**
     * Get file stream URL (direct Oxy Cloud/CDN URL, no token)
     */
    getFileStreamUrl(fileId: string): string;
    /**
     * List user files
     */
    listUserFiles(limit?: number, offset?: number): Promise<{
        files: any[];
        total: number;
        hasMore: boolean;
    }>;
    /**
     * Get file content as text
     */
    getFileContentAsText(fileId: string, variant?: string): Promise<string>;
    /**
     * Get file content as blob
     */
    getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob>;
    /**
     * Upload raw file data
     */
    uploadRawFile(file: File | Blob, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>): Promise<any>;
    /**
     * Calculate SHA256 hash of file content
     */
    calculateSHA256(file: File | Blob): Promise<string>;
    /**
     * Initialize asset upload - returns pre-signed URL and file ID
     */
    assetInit(sha256: string, size: number, mime: string): Promise<AssetInitResponse>;
    /**
     * Complete asset upload - commit metadata and trigger variant generation
     */
    assetComplete(fileId: string, originalName: string, size: number, mime: string, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>): Promise<any>;
    /**
     * Upload file using Central Asset Service
     */
    assetUpload(file: File, visibility?: 'private' | 'public' | 'unlisted', metadata?: Record<string, any>, onProgress?: (progress: number) => void): Promise<any>;
    /**
     * Upload file to pre-signed URL
     */
    private uploadToPresignedUrl;
    /**
     * Link asset to an entity
     */
    assetLink(fileId: string, app: string, entityType: string, entityId: string, visibility?: 'private' | 'public' | 'unlisted', webhookUrl?: string): Promise<any>;
    /**
     * Unlink asset from an entity
     */
    assetUnlink(fileId: string, app: string, entityType: string, entityId: string): Promise<any>;
    /**
     * Get asset metadata
     */
    assetGet(fileId: string): Promise<any>;
    /**
     * Get asset URL (CDN or signed URL)
     */
    assetGetUrl(fileId: string, variant?: string, expiresIn?: number): Promise<AssetUrlResponse>;
    /**
     * Restore asset from trash
     */
    assetRestore(fileId: string): Promise<any>;
    /**
     * Delete asset with optional force
     */
    assetDelete(fileId: string, force?: boolean): Promise<any>;
    /**
     * Get list of available variants for an asset
     */
    assetGetVariants(fileId: string): Promise<AssetVariant[]>;
    /**
     * Update asset visibility
     * @param fileId - The file ID
     * @param visibility - New visibility level ('private', 'public', or 'unlisted')
     * @returns Updated asset information
     */
    assetUpdateVisibility(fileId: string, visibility: 'private' | 'public' | 'unlisted'): Promise<any>;
    /**
     * Helper: Upload and link avatar with automatic public visibility
     * @param file - The avatar file
     * @param userId - User ID to link to
     * @param app - App name (defaults to 'profiles')
     * @returns The uploaded and linked asset
     */
    uploadAvatar(file: File, userId: string, app?: string): Promise<any>;
    /**
     * Helper: Upload and link profile banner with automatic public visibility
     * @param file - The banner file
     * @param userId - User ID to link to
     * @param app - App name (defaults to 'profiles')
     * @returns The uploaded and linked asset
     */
    uploadProfileBanner(file: File, userId: string, app?: string): Promise<any>;
    /**
     * Get developer apps for the current user
     */
    getDeveloperApps(): Promise<any[]>;
    /**
     * Create a new developer app
     */
    createDeveloperApp(data: {
        name: string;
        description?: string;
        webhookUrl?: string;
        scopes?: string[];
    }): Promise<any>;
    /**
     * Get a specific developer app
     */
    getDeveloperApp(appId: string): Promise<any>;
    /**
     * Update a developer app
     */
    updateDeveloperApp(appId: string, data: {
        name?: string;
        description?: string;
        webhookUrl?: string;
        scopes?: string[];
    }): Promise<any>;
    /**
     * Regenerate API secret for a developer app
     */
    regenerateDeveloperAppSecret(appId: string): Promise<any>;
    /**
     * Delete a developer app
     */
    deleteDeveloperApp(appId: string): Promise<any>;
    /**
     * Update user location
     */
    updateLocation(latitude: number, longitude: number): Promise<any>;
    /**
     * Get nearby users
     */
    getNearbyUsers(radius?: number): Promise<any[]>;
    /**
     * Track event
     */
    trackEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
    /**
     * Get analytics data
     */
    getAnalytics(startDate?: string, endDate?: string): Promise<any>;
    /**
     * Register device
     */
    registerDevice(deviceData: any): Promise<any>;
    /**
     * Get user devices
     */
    getUserDevices(): Promise<any[]>;
    /**
     * Remove device
     */
    removeDevice(deviceId: string): Promise<void>;
    /**
     * Get device sessions
     */
    getDeviceSessions(sessionId: string): Promise<any[]>;
    /**
     * Logout all device sessions
     */
    logoutAllDeviceSessions(sessionId: string, deviceId?: string, excludeCurrent?: boolean): Promise<any>;
    /**
     * Update device name
     */
    updateDeviceName(sessionId: string, deviceName: string): Promise<any>;
    /**
     * Fetch link metadata
     */
    fetchLinkMetadata(url: string): Promise<{
        url: string;
        title: string;
        description: string;
        image?: string;
    }>;
    /**
     * Simple Express.js authentication middleware
     *
     * Built-in authentication middleware that validates JWT tokens and adds user data to requests.
     *
     * @example
     * ```typescript
     * // Basic usage - just add it to your routes
     * app.use('/api/protected', oxyServices.auth());
     *
     * // With debug logging
     * app.use('/api/protected', oxyServices.auth({ debug: true }));
     *
     * // With custom error handling
     * app.use('/api/protected', oxyServices.auth({
     *   onError: (error) => console.error('Auth failed:', error)
     * }));
     *
     * // Load full user data
     * app.use('/api/protected', oxyServices.auth({ loadUser: true }));
     * ```
     *
     * @param options Optional configuration
     * @param options.debug Enable debug logging (default: false)
     * @param options.onError Custom error handler
     * @param options.loadUser Load full user data (default: false for performance)
     * @param options.session Use session-based validation (default: false)
     * @returns Express middleware function
     */
    auth(options?: {
        debug?: boolean;
        onError?: (error: ApiError) => any;
        loadUser?: boolean;
        session?: boolean;
    }): (req: any, res: any, next: any) => any;
}
/**
 * Export the default Oxy Cloud URL (for backward compatibility)
 */
export declare const OXY_CLOUD_URL = "https://cloud.oxy.so";
/**
 * Export the default Oxy API URL (for documentation)
 */
export declare const OXY_API_URL: string;
/**
 * Pre-configured client instance for easy import
 * Uses OXY_API_URL as baseURL and OXY_CLOUD_URL as cloudURL
 */
export declare const oxyClient: OxyServices;
//# sourceMappingURL=OxyServices.d.ts.map