import { GetClientInfoResponseDTO, GetIpAddressResponseDTO, GetUserAgentResponseDTO, GetDeviceTokenResponseDTO, GetSessionIdResponseDTO } from '../dto'; /** * Client Info Service * * Provides transparent access to client information (IP address, user agent, device info) * from the current request context using async local storage. * * This service eliminates the need to pass IP addresses and user agents as parameters * to authentication methods. The library handles this automatically, just like AWS Cognito. * * **Key Features:** * - Transparent access to client metadata * - No parameters needed in service methods * - Works across async boundaries * - Type-safe with TypeScript * - Thread-safe with async local storage * - Platform-agnostic (no framework dependencies) * * **Usage:** * ```typescript * export class AuthService { * constructor(private clientInfoService: ClientInfoService) {} * * async login(dto: LoginDTO) { * // Get client info from context (no parameters needed!) * const clientInfo = this.clientInfoService.get(); * * // Use it * logger.debug('IP Address:', clientInfo.ipAddress); * logger.debug('User Agent:', clientInfo.userAgent); * } * } * ``` * * **Note:** * This service must be called within the context of an HTTP request. * If called outside a request context (e.g., cron jobs, CLI), it will * return a default ClientInfo object with 'unknown' values. */ export declare class ClientInfoService { constructor(); /** * Get client information from the current request context * * This method retrieves client metadata that was automatically extracted * by ClientInfoInterceptor and stored in async local storage. * * @returns Response DTO with client information * * @example * ```typescript * const result = this.clientInfoService.get(); * logger.debug('IP Address:', result.ipAddress); // 192.168.1.100 * logger.debug('User Agent:', result.userAgent); // Mozilla/5.0 ... * ``` * * @example * ```typescript * // If called outside request context (e.g., cron job) * const result = this.clientInfoService.get(); * logger.debug('IP Address:', result.ipAddress); // 'unknown' * ``` */ get(): GetClientInfoResponseDTO; /** * Get IP address from the current request context * * Convenience method to get just the IP address without the full ClientInfo object. * * @returns Response DTO with IP address * * @example * ```typescript * const result = this.clientInfoService.getIpAddress(); * logger.debug('IP Address:', result.ipAddress); // 192.168.1.100 * ``` */ getIpAddress(): GetIpAddressResponseDTO; /** * Get user agent from the current request context * * Convenience method to get just the user agent without the full ClientInfo object. * * @returns Response DTO with user agent * * @example * ```typescript * const result = this.clientInfoService.getUserAgent(); * logger.debug('User Agent:', result.userAgent); // Mozilla/5.0 (Windows NT 10.0; Win64; x64)... * ``` */ getUserAgent(): GetUserAgentResponseDTO; /** * Get device token from the current request context * * Convenience method to get just the device token (for trusted device feature). * * @returns Response DTO with device token * * @example * ```typescript * const result = this.clientInfoService.getDeviceToken(); * if (result.deviceToken) { * logger.debug('Device token:', result.deviceToken); * } * ``` */ getDeviceToken(): GetDeviceTokenResponseDTO; /** * Get session ID from the current request context * * Convenience method to get just the session ID (extracted from JWT token after authentication). * * @returns Response DTO with session ID * * @example * ```typescript * const result = this.clientInfoService.getSessionId(); * if (result.sessionId) { * logger.debug('Session ID:', result.sessionId); * } * ``` */ getSessionId(): GetSessionIdResponseDTO; /** * Get response object from the current request context * * Returns the HTTP response object that was stored by the framework interceptor. * Used internally by services to perform response operations like clearing cookies. * * @returns Response object with cookie manipulation methods, or null if not available * @internal - Used by core services, not by application code * * @example * ```typescript * const response = this.clientInfoService.getResponse(); * if (response?.clearCookie) { * response.clearCookie('my_cookie'); * } * ``` */ getResponse(): { clearCookie?: (name: string, options?: unknown) => void; } | null; /** * Parse user-agent string to extract browser, platform, and device information * * This method is used internally by interceptors to populate ClientInfo. * Services should use ClientInfoService.get() to access parsed information. * * @param userAgent - User-agent string from HTTP request * @returns Parsed user-agent information * @internal - Used by interceptors, not by application code */ parseUserAgent(userAgent?: string | null): { browser: string | null; platform: string | null; deviceType: 'desktop' | 'mobile' | 'tablet' | null; deviceName: string | null; }; } //# sourceMappingURL=client-info.service.d.ts.map