UNPKG

insomnia-plugin-valorant

Version:
80 lines 3.08 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.infoKeys = void 0; const fs = __importStar(require("node:fs")); const readline = __importStar(require("node:readline")); const path = __importStar(require("path")); exports.infoKeys = ['puuid', 'shard', 'region', 'clientVersion']; const puuidRegex = new RegExp('Logged in user changed: (.+)', 'g'); const regionShardRegex = new RegExp('https://glz-(.+?)-1.(.+?).a.pvp.net', 'g'); const clientVersionRegex = new RegExp('CI server version: (.+)', 'g'); async function sleuth(file) { const info = {}; const fileStream = fs.createReadStream(file); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity, }); for await (const line of rl) { if (info.puuid === undefined) { const match = puuidRegex.exec(line); if (match) { info.puuid = match[1]; } } if (info.shard === undefined || info.region === undefined) { const match = regionShardRegex.exec(line); if (match) { info.region = match[1]; info.shard = match[2]; } } if (info.clientVersion === undefined) { const match = clientVersionRegex.exec(line); if (match) { // Add in "shipping-" to match the client version format info.clientVersion = match[1].replace(/^(release-\d+\.\d+-)/, '$1shipping-'); } } if (exports.infoKeys.every(key => info[key] !== undefined)) break; } rl.close(); fileStream.close(); return info; } async function logSleuth() { // Might expand in the future to include older log files if needed const filePath = path.join(process.env['LOCALAPPDATA'], 'VALORANT\\Saved\\Logs\\ShooterGame.log'); try { return await sleuth(filePath); } catch (e) { return undefined; } } exports.default = logSleuth; //# sourceMappingURL=log-sleuth.js.map