import crypto from 'crypto';

export const generateDeviceFingerprint = (input: {
  userAgent: string | null | undefined;
  ipAddress: string;
  acceptLanguage: string | null | undefined;
}): string => {
  const normalized = [
    (input.userAgent ?? '').trim().toLowerCase(),
    input.ipAddress.trim(),
    (input.acceptLanguage ?? '').trim().toLowerCase(),
  ].join('|');

  return crypto.createHash('sha256').update(normalized).digest('hex');
};
