const minisrv_service_file = true; let BoxId = request_headers.query.BoxId; if (Array.isArray(BoxId)) BoxId = BoxId[0]; let clientIp = socket.remoteAddress; let banned = false; let sessionId = null; // Use the shared MSNTV2 helper injected by WTV-MSNTV2 VM context. if (BoxId) { if (!BoxId || BoxId.length != 20 || !/^\d+$/.test(BoxId)) { console.warn("Invalid BoxId format "+BoxId+" from "+clientIp); banned = true; } else { sessionId = encodeSessionID(BoxId); } } else if (request_headers.cookie.SessionID) { BoxID = decodeSessionID(request_headers.cookie.SessionID); sessionId = request_headers.cookie.SessionID; } else { console.warn("No BoxId provided by client "+clientIp); banned = true; } if (!sessionId && !banned) { banned = true; } // Current UTC time const now = new Date(); // Time data object const timeData = { hh: now.getUTCHours(), mm: now.getUTCMinutes(), ss: now.getUTCSeconds(), mo: now.getUTCMonth() + 1, // JS months are 0-based dd: now.getUTCDate(), yyyy: now.getUTCFullYear() }; // Timezone mapping (C# tuple → JS array or object) const timezoneMap = { "UTC": { standardName: "UTC", standardOffset: 0, daylightName: "UTC", daylightOffset: 0 } }; // Destructure like the C# tuple deconstruction const { standardName, standardOffset, daylightName, daylightOffset } = timezoneMap["UTC"]; ssid_sessions[socket.ssid] = new WTVClientSessionData(minisrv_config, socket.ssid); ssid_sessions[socket.ssid].set('SessionID', sessionId); // Set session cookie on the client setCookie('SessionID', sessionId, { path: '/' }); headers = `200 OK Content-type: text/html` data = `