<?php
namespace WPUltimateSecurity\UltimateSecurity\Modules\Authentication\TwoFactor\Helpers;

use WPUltimateSecurity\UltimateSecurity\Support\Helpers\IpHelper;

/**
 * Device Fingerprinting Helper
 *
 * Generates device fingerprints and extracts client information
 */
class DeviceFingerprint
{
	/**
	 * Get device fingerprint
	 *
	 * @return string SHA-256 hash of device characteristics
	 */
	public static function generate()
	{
		$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '';
		$accept_language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT_LANGUAGE'])) : '';
		return hash('sha256', $user_agent . $accept_language);
	}

	/**
	 * Get client IP address using IpHelper
	 *
	 * @return string Client IP address
	 */
	public static function get_client_ip()
	{
		return IpHelper::getRealClientIp();
	}

	/**
	 * Get user agent
	 *
	 * @return string User agent string
	 */
	public static function get_user_agent()
	{
		return isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '';
	}
}
