"use strict"; /** * Builds a human-readable client label for security emails and audit logs. * Prefers an explicit User-Agent unless it is the Dart/Dio default, in which * case X-Tloto-* mobile headers are used. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveClientUserAgent = resolveClientUserAgent; function platformLabel(raw) { const p = (raw || '').trim().toLowerCase(); if (p === 'android') return 'Android'; if (p === 'ios') return 'iOS'; if (p) return p; return 'Mobile'; } /** * @param req Express request (User-Agent + optional X-Tloto-* headers from the app) * @returns Device string suitable for "New sign-in" emails, or undefined if nothing useful */ function resolveClientUserAgent(req) { const ua = (req.get('user-agent') || '').trim(); const isDartDefault = !ua || /^Dart\//i.test(ua); if (ua && !isDartDefault) return ua; const platform = req.get('x-tloto-platform') || undefined; const versionName = req.get('x-tloto-app-version-name') || undefined; const versionCode = req.get('x-tloto-app-version-code') || undefined; if (platform || versionName || versionCode) { const os = platformLabel(platform); const ver = versionName?.trim() || 'app'; const build = versionCode?.trim(); return build ? `Tloto/${ver} (${os}; build ${build})` : `Tloto/${ver} (${os})`; } return ua || undefined; } //# sourceMappingURL=clientDevice.js.map