@anonympins/fingerprint 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -827,6 +827,25 @@ class RequestUtils
827
827
  $deviceData['ips'][] = $clientIp;
828
828
  }
829
829
 
830
+ // Pruning par fenêtre glissante temporelle
831
+ if (!isset($deviceData['ipTimes'])) {
832
+ $deviceData['ipTimes'] = [];
833
+ }
834
+ $deviceData['ipTimes'][$clientIp] = $now;
835
+
836
+ $slidingWindow = 2 * 3600 * 1000; // 2 heures
837
+ $cutOff = $now - $slidingWindow;
838
+ foreach ($deviceData['ipTimes'] as $ip => $lastSeen) {
839
+ if ($lastSeen < $cutOff) {
840
+ $ipKey = array_search($ip, $deviceData['ips'], true);
841
+ if ($ipKey !== false) {
842
+ unset($deviceData['ips'][$ipKey]);
843
+ }
844
+ unset($deviceData['ipTimes'][$ip]);
845
+ }
846
+ }
847
+ $deviceData['ips'] = array_values($deviceData['ips']);
848
+
830
849
  // Score d'historique basé sur le nombre d'IPs utilisées (rotation de proxy)
831
850
  $maxIpsPerDevice = 15;
832
851
  $freeIpChanges = 3;