/**
 * Authentication and Authorization Utilities
 *
 * This module provides utility functions for handling authentication flows,
 * including redirects to auth SPA, cookie management, and session handling.
 */
/**
 * Check if the current window is inside an iframe
 * @returns {boolean} True if running in an iframe, false otherwise
 */
declare function isInIframe(): boolean;
/**
 * Send a message to the parent website (when in iframe)
 * @param payload - The data to send to parent window
 */
declare function sendMessageToParentWebsite(payload: unknown): void;
/**
 * Delete a cookie with specific name, path, and domain
 * @param name - Cookie name
 * @param path - Cookie path
 * @param domain - Cookie domain
 */
declare function deleteCookie(name: string, path: string, domain: string): void;
/**
 * Get all possible domain parts for cookie deletion
 * @param domain - The domain to split
 * @returns Array of domain parts
 * @example
 * getDomainParts('app.example.com') // returns ['app.example.com', 'example.com', 'com']
 */
declare function getDomainParts(domain: string): string[];
/**
 * Delete a cookie across all possible domain variations
 * @param name - Cookie name to delete
 * @param childDomain - The current domain
 */
declare function deleteCookieOnAllDomains(name: string, childDomain: string): void;
/**
 * Get the parent domain from a given domain
 * @param domain - The domain to process
 * @returns The parent domain (e.g., 'app.example.com' → '.example.com')
 */
declare function getParentDomain(domain?: string): string;
/**
 * Set a cookie for authentication with cross-domain support
 * @param name - Cookie name
 * @param value - Cookie value
 * @param days - Number of days until expiration (default: 365)
 */
declare function setCookieForAuth(name: string, value: string, days?: number): void;
/**
 * Clear all cookies for the current domain
 */
declare function clearCookies(): void;
/**
 * Get the value of a cookie by name
 * @param name - Cookie name
 * @returns The cookie value or null if not found
 */
declare function getCookieValue(name: string): string | null;
/**
 * Check if user is currently logged in
 * @param tokenKey - The localStorage key for the auth token (default: 'axd_token')
 * @returns True if logged in, false otherwise
 */
declare function isLoggedIn(tokenKey?: string): boolean;
/**
 * Extract platform/tenant key from URL
 * @param url - The URL to parse
 * @param pattern - RegExp pattern to match platform key (default matches /platform/[key]/...)
 * @returns The platform key or null if not found
 */
declare function getPlatformKey(url: string, pattern?: RegExp): string | null;
interface RedirectToAuthSpaOptions {
    /** URL to redirect to after auth (defaults to current path + search) */
    redirectTo?: string;
    /** Platform/tenant key */
    platformKey?: string;
    /** Whether this is a logout action */
    logout?: boolean;
    /** Whether to save redirect path to localStorage (default: true) */
    saveRedirect?: boolean;
    /** Auth SPA base URL */
    authUrl: string;
    /** Current app/platform identifier (e.g., 'mentor', 'skills') */
    appName: string;
    /** Query param names */
    queryParams?: {
        app?: string;
        redirectTo?: string;
        tenant?: string;
    };
    /** localStorage key for saving redirect path */
    redirectPathStorageKey?: string;
    /** Cookie names for cross-SPA sync */
    cookieNames?: {
        currentTenant?: string;
        userData?: string;
        tenant?: string;
        logoutTimestamp?: string;
        loginTimestamp?: string;
        tenantSwitching?: string;
    };
    /** Function to check if auth token is valid and non-expired. Used to skip redirect when a recent login occurred. */
    hasNonExpiredAuthToken?: () => boolean;
    /** Function to check if the app is in offline mode (e.g., Tauri offline). Skips redirect when true. */
    isOffline?: () => boolean;
    /** localStorage key for a token to preserve before clearing storage (e.g., 'edx_jwt_token') */
    preserveTokenKey?: string;
    /** Path to an auth redirect proxy endpoint (e.g., '/api/auth-redirect'). When set, redirects via this proxy in browser. */
    authRedirectProxy?: string;
    /** Function to check if the app is running as a native app (e.g., Tauri). Affects redirect behavior. */
    isNativeApp?: () => boolean;
    forceRedirect?: boolean;
}
/**
 * Redirect to authentication SPA for login/logout
 *
 * This function handles the complete authentication flow:
 * - Clears localStorage and cookies on logout
 * - Saves redirect path for post-auth return
 * - Handles iframe scenarios
 * - Syncs logout across multiple SPAs via cookies
 *
 * @param options - Configuration options for the redirect
 *
 * @example
 * ```tsx
 * // Basic usage
 * redirectToAuthSpa({
 *   authUrl: 'https://auth.example.com',
 *   appName: 'mentor',
 * });
 *
 * // With logout
 * redirectToAuthSpa({
 *   authUrl: 'https://auth.example.com',
 *   appName: 'mentor',
 *   logout: true,
 *   platformKey: 'my-tenant',
 * });
 *
 * // With custom redirect
 * redirectToAuthSpa({
 *   authUrl: 'https://auth.example.com',
 *   appName: 'mentor',
 *   redirectTo: '/dashboard',
 *   platformKey: 'my-tenant',
 * });
 * ```
 */
declare function redirectToAuthSpa(options: RedirectToAuthSpaOptions): Promise<void>;
/**
 * Get the URL for joining a tenant (sign up flow)
 * @param authUrl - Auth SPA base URL
 * @param tenantKey - Tenant to join
 * @param redirectUrl - URL to redirect to after joining (defaults to current URL)
 * @returns The join URL
 */
declare function getAuthSpaJoinUrl(authUrl: string, tenantKey?: string, redirectUrl?: string): string;
/**
 * Redirect to auth SPA's join/signup page for a specific tenant
 * @param authUrl - Auth SPA base URL
 * @param tenantKey - Tenant to join
 * @param redirectUrl - URL to redirect to after joining (defaults to current URL)
 */
declare function redirectToAuthSpaJoinTenant(authUrl: string, tenantKey?: string, redirectUrl?: string): void;
interface HandleLogoutOptions {
    /** URL to redirect to after logout (defaults to current origin) */
    redirectUrl?: string;
    /** Auth SPA base URL */
    authUrl: string;
    /** localStorage key for tenant */
    tenantStorageKey?: string;
    /** Cookie name for logout timestamp */
    logoutTimestampCookie?: string;
    /** Callback to execute before logout */
    callback?: () => void;
}
/**
 * Handle user logout
 *
 * This function:
 * - Clears localStorage (preserving tenant)
 * - Sets logout timestamp cookie for cross-SPA sync
 * - Clears all cookies
 * - Redirects to auth SPA logout endpoint
 *
 * @param options - Logout configuration options
 *
 * @example
 * ```tsx
 * handleLogout({
 *   authUrl: 'https://auth.example.com',
 *   redirectUrl: 'https://app.example.com',
 * });
 * ```
 */
declare function handleLogout(options: HandleLogoutOptions): void;

export { clearCookies, deleteCookie, deleteCookieOnAllDomains, getAuthSpaJoinUrl, getCookieValue, getDomainParts, getParentDomain, getPlatformKey, handleLogout, isInIframe, isLoggedIn, redirectToAuthSpa, redirectToAuthSpaJoinTenant, sendMessageToParentWebsite, setCookieForAuth };
export type { HandleLogoutOptions, RedirectToAuthSpaOptions };
