This commit is contained in:
104
frontend/dist-electron/services/backend.js
Normal file
104
frontend/dist-electron/services/backend.js
Normal file
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BackendService = void 0;
|
||||
const axios_1 = __importDefault(require("axios"));
|
||||
class BackendService {
|
||||
url;
|
||||
token;
|
||||
constructor(url, token) {
|
||||
this.url = url;
|
||||
this.token = token;
|
||||
}
|
||||
get headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.token}`,
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
}
|
||||
async getSharedAccounts() {
|
||||
if (!this.token)
|
||||
return [];
|
||||
try {
|
||||
const response = await axios_1.default.get(`${this.url}/api/sync`, { headers: this.headers });
|
||||
return response.data;
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[Backend] Failed to fetch shared accounts');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
async getCommunityAccounts() {
|
||||
if (!this.token)
|
||||
return [];
|
||||
try {
|
||||
const response = await axios_1.default.get(`${this.url}/api/sync/community`, { headers: this.headers });
|
||||
return response.data;
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[Backend] Failed to fetch community accounts');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
async getServerUsers() {
|
||||
if (!this.token)
|
||||
return [];
|
||||
try {
|
||||
const response = await axios_1.default.get(`${this.url}/api/sync/users`, { headers: this.headers });
|
||||
return response.data;
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[Backend] Failed to fetch server users');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
async shareAccount(account) {
|
||||
if (!this.token)
|
||||
return;
|
||||
try {
|
||||
await axios_1.default.post(`${this.url}/api/sync`, {
|
||||
steamId: account.steamId,
|
||||
personaName: account.personaName,
|
||||
avatar: account.avatar,
|
||||
profileUrl: account.profileUrl,
|
||||
vacBanned: account.vacBanned,
|
||||
gameBans: account.gameBans,
|
||||
loginName: account.loginName,
|
||||
steamLoginSecure: account.steamLoginSecure,
|
||||
loginConfig: account.loginConfig
|
||||
}, { headers: this.headers });
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[Backend] Failed to share account');
|
||||
}
|
||||
}
|
||||
async pushCooldown(steamId, cooldownExpiresAt) {
|
||||
if (!this.token)
|
||||
return;
|
||||
try {
|
||||
await axios_1.default.patch(`${this.url}/api/sync/${steamId}/cooldown`, {
|
||||
cooldownExpiresAt
|
||||
}, { headers: this.headers });
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Backend] Failed to push cooldown for ${steamId}`);
|
||||
}
|
||||
}
|
||||
async shareWithUser(steamId, targetSteamId) {
|
||||
if (!this.token)
|
||||
return;
|
||||
try {
|
||||
const response = await axios_1.default.post(`${this.url}/api/sync/${steamId}/share`, {
|
||||
targetSteamId
|
||||
}, { headers: this.headers });
|
||||
return response.data;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Backend] Failed to share account ${steamId} with ${targetSteamId}`);
|
||||
throw new Error(e.response?.data?.message || 'Failed to share account');
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.BackendService = BackendService;
|
||||
91
frontend/dist-electron/services/scraper.js
Normal file
91
frontend/dist-electron/services/scraper.js
Normal file
@@ -0,0 +1,91 @@
|
||||
"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 () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.scrapeCooldown = void 0;
|
||||
const axios_1 = __importDefault(require("axios"));
|
||||
const cheerio = __importStar(require("cheerio"));
|
||||
const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
||||
const url = `https://steamcommunity.com/profiles/${steamId}/gcpd/730?tab=matchmaking`;
|
||||
try {
|
||||
const response = await axios_1.default.get(url, {
|
||||
headers: {
|
||||
'Cookie': steamLoginSecure,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
||||
},
|
||||
timeout: 10000
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
if (response.data.includes('Sign In') || !response.data.includes('Personal Game Data')) {
|
||||
throw new Error('Invalid or expired steamLoginSecure cookie');
|
||||
}
|
||||
// 1. Locate the specific table containing cooldown info
|
||||
let expirationDate = undefined;
|
||||
$('table').each((_, table) => {
|
||||
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
||||
const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration'));
|
||||
if (expirationIndex !== -1) {
|
||||
const firstRow = $(table).find('tr').not(':has(th)').first();
|
||||
const dateText = firstRow.find('td').eq(expirationIndex).text().trim();
|
||||
if (dateText && dateText !== '') {
|
||||
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
||||
const parsed = new Date(cleanDateText);
|
||||
if (!isNaN(parsed.getTime())) {
|
||||
expirationDate = parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (expirationDate && expirationDate.getTime() > Date.now()) {
|
||||
console.log(`[Scraper] Found active cooldown until: ${expirationDate.toISOString()}`);
|
||||
return {
|
||||
isActive: true,
|
||||
expiresAt: expirationDate
|
||||
};
|
||||
}
|
||||
const content = $('#personal_game_data_content').text();
|
||||
if (content.includes('Competitive Cooldown') || content.includes('Your account is currently')) {
|
||||
return { isActive: true };
|
||||
}
|
||||
return { isActive: false };
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`[Scraper] Error for ${steamId}:`, error.message);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
exports.scrapeCooldown = scrapeCooldown;
|
||||
1
frontend/dist-electron/services/scraper.js.map
Normal file
1
frontend/dist-electron/services/scraper.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scraper.js","sourceRoot":"","sources":["../../electron/services/scraper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AAO5B,MAAM,cAAc,GAAG,KAAK,EAAE,OAAe,EAAE,gBAAwB,EAAyB,EAAE;IACvG,MAAM,GAAG,GAAG,uCAAuC,OAAO,2BAA2B,CAAC;IAEtF,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACpC,OAAO,EAAE;gBACP,QAAQ,EAAE,oBAAoB,gBAAgB,EAAE;gBAChD,YAAY,EAAE,iHAAiH;aAChI;YACD,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAEH,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,CAAC,6BAA6B,CAAC,CAAC,IAAI,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC;QAE9G,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC7B,CAAC;QAED,MAAM,WAAW,GAAG,CAAC,CAAC,mEAAmE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAEzG,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,WAAW,IAAI,iBAAiB;SACzC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,uBAAuB,OAAO,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAnCW,QAAA,cAAc,kBAmCzB"}
|
||||
239
frontend/dist-electron/services/steam-client.js
Normal file
239
frontend/dist-electron/services/steam-client.js
Normal file
@@ -0,0 +1,239 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.steamClient = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const simple_vdf_1 = require("simple-vdf");
|
||||
const chokidar_1 = __importDefault(require("chokidar"));
|
||||
class SteamClientService {
|
||||
steamPath = null;
|
||||
onAccountsChanged = null;
|
||||
constructor() {
|
||||
this.detectSteamPath();
|
||||
}
|
||||
detectSteamPath() {
|
||||
const platform = os_1.default.platform();
|
||||
const home = os_1.default.homedir();
|
||||
if (platform === 'win32') {
|
||||
const possiblePaths = [
|
||||
'C:\\Program Files (x86)\\Steam',
|
||||
'C:\\Program Files\\Steam'
|
||||
];
|
||||
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
||||
}
|
||||
else if (platform === 'linux') {
|
||||
const possiblePaths = [
|
||||
path_1.default.join(home, '.steam/steam'),
|
||||
path_1.default.join(home, '.local/share/Steam'),
|
||||
path_1.default.join(home, '.var/app/com.valvesoftware.Steam/.steam/steam')
|
||||
];
|
||||
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
||||
}
|
||||
if (this.steamPath) {
|
||||
console.log(`[SteamClient] Detected Steam path: ${this.steamPath}`);
|
||||
}
|
||||
}
|
||||
getLoginUsersPath() {
|
||||
if (!this.steamPath)
|
||||
return null;
|
||||
return path_1.default.join(this.steamPath, 'config', 'loginusers.vdf');
|
||||
}
|
||||
getConfigVdfPath() {
|
||||
if (!this.steamPath)
|
||||
return null;
|
||||
return path_1.default.join(this.steamPath, 'config', 'config.vdf');
|
||||
}
|
||||
startWatching(callback) {
|
||||
this.onAccountsChanged = callback;
|
||||
const loginUsersPath = this.getLoginUsersPath();
|
||||
if (loginUsersPath && fs_1.default.existsSync(loginUsersPath)) {
|
||||
this.readLocalAccounts();
|
||||
chokidar_1.default.watch(loginUsersPath, { persistent: true }).on('change', () => {
|
||||
this.readLocalAccounts();
|
||||
});
|
||||
}
|
||||
}
|
||||
readLocalAccounts() {
|
||||
const filePath = this.getLoginUsersPath();
|
||||
if (!filePath || !fs_1.default.existsSync(filePath))
|
||||
return;
|
||||
try {
|
||||
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
||||
const data = (0, simple_vdf_1.parse)(content);
|
||||
if (!data || !data.users)
|
||||
return;
|
||||
const accounts = [];
|
||||
for (const [steamId64, userData] of Object.entries(data.users)) {
|
||||
const user = userData;
|
||||
accounts.push({
|
||||
steamId: steamId64,
|
||||
accountName: user.AccountName,
|
||||
personaName: user.PersonaName,
|
||||
timestamp: parseInt(user.Timestamp) || 0
|
||||
});
|
||||
}
|
||||
if (this.onAccountsChanged)
|
||||
this.onAccountsChanged(accounts);
|
||||
}
|
||||
catch (error) {
|
||||
console.error('[SteamClient] Error parsing loginusers.vdf:', error);
|
||||
}
|
||||
}
|
||||
extractAccountConfig(accountName) {
|
||||
const configPath = this.getConfigVdfPath();
|
||||
if (!configPath || !fs_1.default.existsSync(configPath))
|
||||
return null;
|
||||
try {
|
||||
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
||||
const data = (0, simple_vdf_1.parse)(content);
|
||||
const accounts = data?.InstallConfigStore?.Software?.Valve?.Steam?.Accounts;
|
||||
if (accounts && accounts[accountName]) {
|
||||
return accounts[accountName];
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[SteamClient] Failed to extract config.vdf data');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
injectAccountConfig(accountName, accountData) {
|
||||
const configPath = this.getConfigVdfPath();
|
||||
if (!configPath)
|
||||
return;
|
||||
// Create directory if it doesn't exist
|
||||
const configDir = path_1.default.dirname(configPath);
|
||||
if (!fs_1.default.existsSync(configDir))
|
||||
fs_1.default.mkdirSync(configDir, { recursive: true });
|
||||
let data = { InstallConfigStore: { Software: { Valve: { Steam: { Accounts: {} } } } } };
|
||||
if (fs_1.default.existsSync(configPath)) {
|
||||
try {
|
||||
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
||||
data = (0, simple_vdf_1.parse)(content);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
// Ensure structure exists
|
||||
if (!data.InstallConfigStore)
|
||||
data.InstallConfigStore = {};
|
||||
if (!data.InstallConfigStore.Software)
|
||||
data.InstallConfigStore.Software = {};
|
||||
if (!data.InstallConfigStore.Software.Valve)
|
||||
data.InstallConfigStore.Software.Valve = {};
|
||||
if (!data.InstallConfigStore.Software.Valve.Steam)
|
||||
data.InstallConfigStore.Software.Valve.Steam = {};
|
||||
if (!data.InstallConfigStore.Software.Valve.Steam.Accounts)
|
||||
data.InstallConfigStore.Software.Valve.Steam.Accounts = {};
|
||||
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
||||
try {
|
||||
fs_1.default.writeFileSync(configPath, (0, simple_vdf_1.stringify)(data));
|
||||
console.log(`[SteamClient] Injected login config for ${accountName} into config.vdf`);
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[SteamClient] Failed to write config.vdf');
|
||||
}
|
||||
}
|
||||
async setAutoLoginUser(accountName, accountConfig, steamId) {
|
||||
const platform = os_1.default.platform();
|
||||
const loginUsersPath = this.getLoginUsersPath();
|
||||
if (loginUsersPath) {
|
||||
const configDir = path_1.default.dirname(loginUsersPath);
|
||||
if (!fs_1.default.existsSync(configDir))
|
||||
fs_1.default.mkdirSync(configDir, { recursive: true });
|
||||
let data = { users: {} };
|
||||
if (fs_1.default.existsSync(loginUsersPath)) {
|
||||
try {
|
||||
const content = fs_1.default.readFileSync(loginUsersPath, 'utf-8');
|
||||
data = (0, simple_vdf_1.parse)(content);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (!data.users)
|
||||
data.users = {};
|
||||
let found = false;
|
||||
for (const [id, user] of Object.entries(data.users)) {
|
||||
const u = user;
|
||||
if (u.AccountName.toLowerCase() === accountName.toLowerCase()) {
|
||||
u.mostrecent = "1";
|
||||
u.RememberPassword = "1";
|
||||
u.AllowAutoLogin = "1";
|
||||
u.WantsOfflineMode = "0";
|
||||
u.SkipOfflineModeWarning = "1";
|
||||
u.WasNonInteractive = "0";
|
||||
found = true;
|
||||
}
|
||||
else {
|
||||
u.mostrecent = "0";
|
||||
}
|
||||
}
|
||||
if (!found && steamId) {
|
||||
console.log(`[SteamClient] Provisioning user ${accountName} into loginusers.vdf`);
|
||||
data.users[steamId] = {
|
||||
AccountName: accountName,
|
||||
PersonaName: accountName,
|
||||
RememberPassword: "1",
|
||||
mostrecent: "1",
|
||||
AllowAutoLogin: "1",
|
||||
WantsOfflineMode: "0",
|
||||
SkipOfflineModeWarning: "1",
|
||||
WasNonInteractive: "0",
|
||||
Timestamp: Math.floor(Date.now() / 1000).toString()
|
||||
};
|
||||
}
|
||||
try {
|
||||
fs_1.default.writeFileSync(loginUsersPath, (0, simple_vdf_1.stringify)(data));
|
||||
}
|
||||
catch (e) {
|
||||
console.error('[SteamClient] Failed to write loginusers.vdf');
|
||||
}
|
||||
}
|
||||
if (accountConfig) {
|
||||
this.injectAccountConfig(accountName, accountConfig);
|
||||
}
|
||||
if (platform === 'linux') {
|
||||
const regLocations = [
|
||||
path_1.default.join(os_1.default.homedir(), '.steam', 'registry.vdf'),
|
||||
path_1.default.join(os_1.default.homedir(), '.steam', 'steam', 'registry.vdf')
|
||||
];
|
||||
for (const regPath of regLocations) {
|
||||
let regData = { Registry: { HKCU: { Software: { Valve: { Steam: {} } } } } };
|
||||
if (fs_1.default.existsSync(regPath)) {
|
||||
try {
|
||||
const content = fs_1.default.readFileSync(regPath, 'utf-8');
|
||||
regData = (0, simple_vdf_1.parse)(content);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
else {
|
||||
const regDir = path_1.default.dirname(regPath);
|
||||
if (!fs_1.default.existsSync(regDir))
|
||||
fs_1.default.mkdirSync(regDir, { recursive: true });
|
||||
}
|
||||
const setPath = (obj, keys, val) => {
|
||||
let curr = obj;
|
||||
for (let i = 0; i < keys.length - 1; i++) {
|
||||
if (!curr[keys[i]])
|
||||
curr[keys[i]] = {};
|
||||
curr = curr[keys[i]];
|
||||
}
|
||||
curr[keys[keys.length - 1]] = val;
|
||||
};
|
||||
const steamReg = ['Registry', 'HKCU', 'Software', 'Valve', 'Steam'];
|
||||
setPath(regData, [...steamReg, 'AutoLoginUser'], accountName);
|
||||
setPath(regData, [...steamReg, 'RememberPassword'], "1");
|
||||
setPath(regData, [...steamReg, 'AlreadyLoggedIn'], "1");
|
||||
setPath(regData, [...steamReg, 'WantsOfflineMode'], "0");
|
||||
try {
|
||||
fs_1.default.writeFileSync(regPath, (0, simple_vdf_1.stringify)(regData));
|
||||
console.log(`[SteamClient] Registry updated: ${regPath}`);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.steamClient = new SteamClientService();
|
||||
111
frontend/dist-electron/services/steam-web.js
Normal file
111
frontend/dist-electron/services/steam-web.js
Normal file
@@ -0,0 +1,111 @@
|
||||
"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 () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.scrapeBanStatus = exports.fetchProfileData = void 0;
|
||||
const axios_1 = __importDefault(require("axios"));
|
||||
const cheerio = __importStar(require("cheerio"));
|
||||
const AXIOS_CONFIG = {
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
||||
}
|
||||
};
|
||||
const fetchProfileData = async (identifier, steamLoginSecure) => {
|
||||
let url = '';
|
||||
// Clean identifier
|
||||
const cleanId = identifier.replace(/https?:\/\/steamcommunity\.com\/(profiles|id)\//, '').replace(/\/$/, '');
|
||||
if (cleanId.match(/^\d+$/)) {
|
||||
url = `https://steamcommunity.com/profiles/${cleanId}?xml=1`;
|
||||
}
|
||||
else {
|
||||
url = `https://steamcommunity.com/id/${cleanId}?xml=1`;
|
||||
}
|
||||
const headers = { ...AXIOS_CONFIG.headers };
|
||||
if (steamLoginSecure) {
|
||||
headers['Cookie'] = steamLoginSecure;
|
||||
}
|
||||
try {
|
||||
const response = await axios_1.default.get(url, { ...AXIOS_CONFIG, headers });
|
||||
const $ = cheerio.load(response.data, { xmlMode: true });
|
||||
const steamId = $('steamID64').first().text().trim();
|
||||
const personaName = $('steamID').first().text().trim();
|
||||
const avatarRaw = $('avatarFull').first().text().trim();
|
||||
// Robustly extract the first URL if concatenated
|
||||
let avatar = avatarRaw;
|
||||
const urls = avatarRaw.match(/https?:\/\/[^\s"'<>]+/g);
|
||||
if (urls && urls.length > 0) {
|
||||
avatar = urls[0];
|
||||
}
|
||||
// Ensure https
|
||||
if (avatar && avatar.startsWith('http:')) {
|
||||
avatar = avatar.replace('http:', 'https:');
|
||||
}
|
||||
const profileUrl = steamId
|
||||
? `https://steamcommunity.com/profiles/${steamId}`
|
||||
: (cleanId.match(/^\d+$/) ? `https://steamcommunity.com/profiles/${cleanId}` : `https://steamcommunity.com/id/${cleanId}`);
|
||||
return {
|
||||
steamId: steamId || cleanId,
|
||||
personaName: personaName || 'Unknown',
|
||||
avatar: avatar || 'https://avatars.akamai.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg',
|
||||
profileUrl
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Failed to fetch profile: ${error.message}`);
|
||||
}
|
||||
};
|
||||
exports.fetchProfileData = fetchProfileData;
|
||||
const scrapeBanStatus = async (profileUrl, steamLoginSecure) => {
|
||||
try {
|
||||
const headers = { ...AXIOS_CONFIG.headers };
|
||||
if (steamLoginSecure) {
|
||||
headers['Cookie'] = steamLoginSecure;
|
||||
}
|
||||
const response = await axios_1.default.get(profileUrl, { ...AXIOS_CONFIG, headers });
|
||||
const $ = cheerio.load(response.data);
|
||||
const banText = $('.profile_ban').text().toLowerCase();
|
||||
const vacBanned = banText.includes('vac ban');
|
||||
const gameBansMatch = banText.match(/(\d+)\s+game\s+ban/);
|
||||
const gameBans = gameBansMatch ? parseInt(gameBansMatch[1]) : 0;
|
||||
return { vacBanned, gameBans };
|
||||
}
|
||||
catch (error) {
|
||||
return { vacBanned: false, gameBans: 0 };
|
||||
}
|
||||
};
|
||||
exports.scrapeBanStatus = scrapeBanStatus;
|
||||
47
frontend/dist-electron/services/steam.js
Normal file
47
frontend/dist-electron/services/steam.js
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveVanityURL = exports.getPlayerBans = exports.getPlayerSummaries = void 0;
|
||||
const axios_1 = __importDefault(require("axios"));
|
||||
const BASE_URL = 'https://api.steampowered.com';
|
||||
const getPlayerSummaries = async (apiKey, steamIds) => {
|
||||
if (!apiKey)
|
||||
throw new Error('STEAM_API_KEY is not defined');
|
||||
const response = await axios_1.default.get(`${BASE_URL}/ISteamUser/GetPlayerSummaries/v2/`, {
|
||||
params: {
|
||||
key: apiKey,
|
||||
steamids: steamIds.join(',')
|
||||
}
|
||||
});
|
||||
return response.data.response.players;
|
||||
};
|
||||
exports.getPlayerSummaries = getPlayerSummaries;
|
||||
const getPlayerBans = async (apiKey, steamIds) => {
|
||||
if (!apiKey)
|
||||
throw new Error('STEAM_API_KEY is not defined');
|
||||
const response = await axios_1.default.get(`${BASE_URL}/ISteamUser/GetPlayerBans/v1/`, {
|
||||
params: {
|
||||
key: apiKey,
|
||||
steamids: steamIds.join(',')
|
||||
}
|
||||
});
|
||||
return response.data.players;
|
||||
};
|
||||
exports.getPlayerBans = getPlayerBans;
|
||||
const resolveVanityURL = async (apiKey, vanityUrl) => {
|
||||
if (!apiKey)
|
||||
throw new Error('STEAM_API_KEY is not defined');
|
||||
const response = await axios_1.default.get(`${BASE_URL}/ISteamUser/ResolveVanityURL/v1/`, {
|
||||
params: {
|
||||
key: apiKey,
|
||||
vanityurl: vanityUrl
|
||||
}
|
||||
});
|
||||
if (response.data.response.success === 1) {
|
||||
return response.data.response.steamid;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
exports.resolveVanityURL = resolveVanityURL;
|
||||
1
frontend/dist-electron/services/steam.js.map
Normal file
1
frontend/dist-electron/services/steam.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"steam.js","sourceRoot":"","sources":["../../electron/services/steam.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AAqBzC,MAAM,kBAAkB,GAAG,KAAK,EAAE,MAAc,EAAE,QAAkB,EAAiC,EAAE;IAC5G,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,oCAAoC,EAAE;QAChF,MAAM,EAAE;YACN,GAAG,EAAE,MAAM;YACX,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC7B;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;AACxC,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B;AAEK,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAE,QAAkB,EAA6B,EAAE;IACnG,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,+BAA+B,EAAE;QAC3E,MAAM,EAAE;YACN,GAAG,EAAE,MAAM;YACX,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC7B;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AATW,QAAA,aAAa,iBASxB;AAEK,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,SAAiB,EAA0B,EAAE;IAClG,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,kCAAkC,EAAE;QAC9E,MAAM,EAAE;YACN,GAAG,EAAE,MAAM;YACX,SAAS,EAAE,SAAS;SACrB;KACF,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACxC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B"}
|
||||
Reference in New Issue
Block a user