Compare commits
5 Commits
2124845848
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4021e3cc42 | |||
| 1d4fb03104 | |||
| d6d87107f5 | |||
| 2ef8dd06e7 | |||
| 559c7bfdef |
@@ -219,9 +219,13 @@ const scrapeAccountData = async (account) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e.message.includes('cookie') || e.message.includes('Sign In'))
|
if (e instanceof scraper_1.SteamAuthError) {
|
||||||
account.authError = true;
|
account.authError = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
console.error(`[Scraper] Temporary error for ${account.personaName}: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (backend && !account._id.startsWith('shared_')) {
|
if (backend && !account._id.startsWith('shared_')) {
|
||||||
await backend.shareAccount(account);
|
await backend.shareAccount(account);
|
||||||
@@ -259,7 +263,16 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
else {
|
else {
|
||||||
const sDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
const sDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
||||||
const lDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
const lDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
||||||
if (sDate > lDate) {
|
// 1. SENSITIVE DATA SYNC (Credentials)
|
||||||
|
const sSessionDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
||||||
|
const lSessionDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
||||||
|
const isLocalAccount = !exists._id.startsWith('shared_');
|
||||||
|
const isLocalSessionHealthy = exists.steamLoginSecure && !exists.authError;
|
||||||
|
// SMART OVERWRITE LOGIC:
|
||||||
|
// - If it's a remote shared account: Newest wins.
|
||||||
|
// - If it's a LOCAL account: Only overwrite if our local session is broken/missing.
|
||||||
|
const shouldOverwriteCredentials = !isLocalAccount ? (sSessionDate > lSessionDate) : (!isLocalSessionHealthy && sSessionDate > lSessionDate);
|
||||||
|
if (shouldOverwriteCredentials) {
|
||||||
if (s.loginName)
|
if (s.loginName)
|
||||||
exists.loginName = s.loginName;
|
exists.loginName = s.loginName;
|
||||||
if (s.loginConfig)
|
if (s.loginConfig)
|
||||||
@@ -272,7 +285,7 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
exists.sessionUpdatedAt = s.sessionUpdatedAt;
|
exists.sessionUpdatedAt = s.sessionUpdatedAt;
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
// Metadata Sync (Pull)
|
// 2. Metadata Sync (Pull) - Always "Newest Wins"
|
||||||
const sMetaDate = s.lastMetadataCheck ? new Date(s.lastMetadataCheck) : new Date(0);
|
const sMetaDate = s.lastMetadataCheck ? new Date(s.lastMetadataCheck) : new Date(0);
|
||||||
const lMetaDate = exists.lastBanCheck ? new Date(exists.lastBanCheck) : new Date(0);
|
const lMetaDate = exists.lastBanCheck ? new Date(exists.lastBanCheck) : new Date(0);
|
||||||
if (sMetaDate > lMetaDate) {
|
if (sMetaDate > lMetaDate) {
|
||||||
|
|||||||
@@ -36,9 +36,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.scrapeCooldown = void 0;
|
exports.scrapeCooldown = exports.SteamAuthError = void 0;
|
||||||
const axios_1 = __importDefault(require("axios"));
|
const axios_1 = __importDefault(require("axios"));
|
||||||
const cheerio = __importStar(require("cheerio"));
|
const cheerio = __importStar(require("cheerio"));
|
||||||
|
// Custom error to identify session death
|
||||||
|
class SteamAuthError extends Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.name = "SteamAuthError";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.SteamAuthError = SteamAuthError;
|
||||||
const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
||||||
const url = `https://steamcommunity.com/profiles/${steamId}/gcpd/730?tab=matchmaking`;
|
const url = `https://steamcommunity.com/profiles/${steamId}/gcpd/730?tab=matchmaking`;
|
||||||
try {
|
try {
|
||||||
@@ -47,13 +55,17 @@ const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
|||||||
'Cookie': steamLoginSecure,
|
'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'
|
'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
|
timeout: 10000,
|
||||||
|
validateStatus: (status) => status < 500 // Allow redirects to handle them manually
|
||||||
});
|
});
|
||||||
const $ = cheerio.load(response.data);
|
// If Steam redirects us to the login page, the cookie is dead
|
||||||
if (response.data.includes('Sign In') || !response.data.includes('Personal Game Data')) {
|
if (response.data.includes('Sign In') || response.request.path.includes('/login')) {
|
||||||
throw new Error('Invalid or expired steamLoginSecure cookie');
|
throw new SteamAuthError('Invalid or expired steamLoginSecure cookie');
|
||||||
|
}
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
if (!response.data.includes('Personal Game Data')) {
|
||||||
|
throw new SteamAuthError('Session invalid: Personal Game Data not accessible');
|
||||||
}
|
}
|
||||||
// 1. Locate the specific table containing cooldown info
|
|
||||||
let expirationDate = undefined;
|
let expirationDate = undefined;
|
||||||
$('table').each((_, table) => {
|
$('table').each((_, table) => {
|
||||||
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
||||||
@@ -63,25 +75,18 @@ const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
|||||||
rows.each((_, row) => {
|
rows.each((_, row) => {
|
||||||
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
||||||
if (dateText && dateText !== '') {
|
if (dateText && dateText !== '') {
|
||||||
// Steam uses 'GMT' which some JS engines don't parse well, replace with 'UTC'
|
|
||||||
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
||||||
const parsed = new Date(cleanDateText);
|
const parsed = new Date(cleanDateText);
|
||||||
if (!isNaN(parsed.getTime())) {
|
if (!isNaN(parsed.getTime())) {
|
||||||
// We want the newest expiration date found
|
if (!expirationDate || parsed > expirationDate)
|
||||||
if (!expirationDate || parsed > expirationDate) {
|
|
||||||
expirationDate = parsed;
|
expirationDate = parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (expirationDate && expirationDate.getTime() > Date.now()) {
|
if (expirationDate && expirationDate.getTime() > Date.now()) {
|
||||||
console.log(`[Scraper] Found active cooldown until: ${expirationDate.toISOString()}`);
|
return { isActive: true, expiresAt: expirationDate };
|
||||||
return {
|
|
||||||
isActive: true,
|
|
||||||
expiresAt: expirationDate
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
const content = $('#personal_game_data_content').text();
|
const content = $('#personal_game_data_content').text();
|
||||||
if (content.includes('Competitive Cooldown') || content.includes('Your account is currently')) {
|
if (content.includes('Competitive Cooldown') || content.includes('Your account is currently')) {
|
||||||
@@ -90,8 +95,10 @@ const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
|||||||
return { isActive: false };
|
return { isActive: false };
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(`[Scraper] Error for ${steamId}:`, error.message);
|
if (error instanceof SteamAuthError)
|
||||||
throw error;
|
throw error;
|
||||||
|
console.error(`[Scraper] Network/Internal Error for ${steamId}:`, error.message);
|
||||||
|
throw error; // Generic errors don't trigger re-auth
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.scrapeCooldown = scrapeCooldown;
|
exports.scrapeCooldown = scrapeCooldown;
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ class SteamClientService {
|
|||||||
return null;
|
return null;
|
||||||
return path_1.default.join(this.steamPath, 'config', 'config.vdf');
|
return path_1.default.join(this.steamPath, 'config', 'config.vdf');
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Safe Atomic Write: Writes to a temp file and renames it.
|
|
||||||
* This prevents file corruption if the app crashes during write.
|
|
||||||
*/
|
|
||||||
safeWriteVdf(filePath, data) {
|
safeWriteVdf(filePath, data) {
|
||||||
const tempPath = `${filePath}.tmp_${Date.now()}`;
|
const tempPath = `${filePath}.tmp_${Date.now()}`;
|
||||||
const dir = path_1.default.dirname(filePath);
|
const dir = path_1.default.dirname(filePath);
|
||||||
@@ -61,7 +57,6 @@ class SteamClientService {
|
|||||||
fs_1.default.mkdirSync(dir, { recursive: true });
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
||||||
const vdfContent = (0, simple_vdf_1.stringify)(data);
|
const vdfContent = (0, simple_vdf_1.stringify)(data);
|
||||||
fs_1.default.writeFileSync(tempPath, vdfContent, 'utf-8');
|
fs_1.default.writeFileSync(tempPath, vdfContent, 'utf-8');
|
||||||
// Atomic rename
|
|
||||||
fs_1.default.renameSync(tempPath, filePath);
|
fs_1.default.renameSync(tempPath, filePath);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -77,7 +72,6 @@ class SteamClientService {
|
|||||||
if (loginUsersPath && fs_1.default.existsSync(loginUsersPath)) {
|
if (loginUsersPath && fs_1.default.existsSync(loginUsersPath)) {
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
chokidar_1.default.watch(loginUsersPath, { persistent: true, ignoreInitial: true }).on('change', () => {
|
chokidar_1.default.watch(loginUsersPath, { persistent: true, ignoreInitial: true }).on('change', () => {
|
||||||
console.log(`[SteamClient] loginusers.vdf changed, re-scanning...`);
|
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,7 +83,7 @@ class SteamClientService {
|
|||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
||||||
if (!content.trim())
|
if (!content.trim())
|
||||||
return; // Empty file
|
return;
|
||||||
const data = (0, simple_vdf_1.parse)(content);
|
const data = (0, simple_vdf_1.parse)(content);
|
||||||
if (!data || !data.users)
|
if (!data || !data.users)
|
||||||
return;
|
return;
|
||||||
@@ -99,8 +93,7 @@ class SteamClientService {
|
|||||||
if (!user || !user.AccountName)
|
if (!user || !user.AccountName)
|
||||||
continue;
|
continue;
|
||||||
accounts.push({
|
accounts.push({
|
||||||
steamId: steamId64,
|
steamId: steamId64, accountName: user.AccountName,
|
||||||
accountName: user.AccountName,
|
|
||||||
personaName: user.PersonaName || user.AccountName,
|
personaName: user.PersonaName || user.AccountName,
|
||||||
timestamp: parseInt(user.Timestamp) || 0
|
timestamp: parseInt(user.Timestamp) || 0
|
||||||
});
|
});
|
||||||
@@ -108,9 +101,7 @@ class SteamClientService {
|
|||||||
if (this.onAccountsChanged)
|
if (this.onAccountsChanged)
|
||||||
this.onAccountsChanged(accounts);
|
this.onAccountsChanged(accounts);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) { }
|
||||||
console.error('[SteamClient] Error parsing loginusers.vdf:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
extractAccountConfig(accountName) {
|
extractAccountConfig(accountName) {
|
||||||
const configPath = this.getConfigVdfPath();
|
const configPath = this.getConfigVdfPath();
|
||||||
@@ -123,7 +114,6 @@ class SteamClientService {
|
|||||||
return (accounts && accounts[accountName]) ? accounts[accountName] : null;
|
return (accounts && accounts[accountName]) ? accounts[accountName] : null;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('[SteamClient] Failed to extract config.vdf data');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,17 +121,7 @@ class SteamClientService {
|
|||||||
const configPath = this.getConfigVdfPath();
|
const configPath = this.getConfigVdfPath();
|
||||||
if (!configPath)
|
if (!configPath)
|
||||||
return;
|
return;
|
||||||
let data = {
|
let data = { InstallConfigStore: { Software: { Valve: { Steam: { Accounts: {} } } } } };
|
||||||
InstallConfigStore: {
|
|
||||||
Software: {
|
|
||||||
Valve: {
|
|
||||||
Steam: {
|
|
||||||
Accounts: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (fs_1.default.existsSync(configPath)) {
|
if (fs_1.default.existsSync(configPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
||||||
@@ -151,18 +131,23 @@ class SteamClientService {
|
|||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
// Ensure safe nesting
|
const ensurePath = (obj, keys) => {
|
||||||
if (!data.InstallConfigStore)
|
let curr = obj;
|
||||||
data.InstallConfigStore = {};
|
for (const key of keys) {
|
||||||
if (!data.InstallConfigStore.Software)
|
if (!curr[key] || typeof curr[key] !== 'object')
|
||||||
data.InstallConfigStore.Software = {};
|
curr[key] = {};
|
||||||
if (!data.InstallConfigStore.Software.Valve)
|
curr = curr[key];
|
||||||
data.InstallConfigStore.Software.Valve = {};
|
}
|
||||||
if (!data.InstallConfigStore.Software.Valve.Steam)
|
return curr;
|
||||||
data.InstallConfigStore.Software.Valve.Steam = {};
|
};
|
||||||
if (!data.InstallConfigStore.Software.Valve.Steam.Accounts)
|
const steamAccounts = ensurePath(data, ['InstallConfigStore', 'Software', 'Valve', 'Steam', 'Accounts']);
|
||||||
data.InstallConfigStore.Software.Valve.Steam.Accounts = {};
|
// FAILPROOF: Force crucial flags that Steam uses to decide session validity
|
||||||
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
steamAccounts[accountName] = {
|
||||||
|
...accountData,
|
||||||
|
RememberPassword: "1",
|
||||||
|
AllowAutoLogin: "1",
|
||||||
|
Timestamp: Math.floor(Date.now() / 1000).toString()
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
this.safeWriteVdf(configPath, data);
|
this.safeWriteVdf(configPath, data);
|
||||||
console.log(`[SteamClient] Safely injected session for ${accountName}`);
|
console.log(`[SteamClient] Safely injected session for ${accountName}`);
|
||||||
@@ -220,6 +205,7 @@ class SteamClientService {
|
|||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
|
// Injection of the actual authentication blob
|
||||||
if (accountConfig && accountName) {
|
if (accountConfig && accountName) {
|
||||||
this.injectAccountConfig(accountName, accountConfig);
|
this.injectAccountConfig(accountName, accountConfig);
|
||||||
}
|
}
|
||||||
@@ -232,11 +218,7 @@ class SteamClientService {
|
|||||||
for (const regPath of regLocations) {
|
for (const regPath of regLocations) {
|
||||||
if (!fs_1.default.existsSync(path_1.default.dirname(regPath)))
|
if (!fs_1.default.existsSync(path_1.default.dirname(regPath)))
|
||||||
continue;
|
continue;
|
||||||
let regData = { Registry: { HKCU: { Software: { Valve: { Steam: {
|
let regData = { Registry: { HKCU: { Software: { Valve: { Steam: { AutoLoginUser: "", RememberPassword: "1", AlreadyLoggedIn: "1" } } } } } };
|
||||||
AutoLoginUser: "",
|
|
||||||
RememberPassword: "1",
|
|
||||||
AlreadyLoggedIn: "1"
|
|
||||||
} } } } } };
|
|
||||||
if (fs_1.default.existsSync(regPath)) {
|
if (fs_1.default.existsSync(regPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(regPath, 'utf-8');
|
const content = fs_1.default.readFileSync(regPath, 'utf-8');
|
||||||
@@ -246,7 +228,6 @@ class SteamClientService {
|
|||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
// Deep merge helper
|
|
||||||
const ensurePath = (obj, keys) => {
|
const ensurePath = (obj, keys) => {
|
||||||
let curr = obj;
|
let curr = obj;
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import axios from 'axios';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import { fetchProfileData, scrapeBanStatus } from './services/steam-web';
|
import { fetchProfileData, scrapeBanStatus } from './services/steam-web';
|
||||||
import { scrapeCooldown } from './services/scraper';
|
import { scrapeCooldown, SteamAuthError } from './services/scraper';
|
||||||
import { steamClient, LocalSteamAccount } from './services/steam-client';
|
import { steamClient, LocalSteamAccount } from './services/steam-client';
|
||||||
import { BackendService } from './services/backend';
|
import { BackendService } from './services/backend';
|
||||||
|
|
||||||
@@ -247,7 +247,11 @@ const scrapeAccountData = async (account: Account) => {
|
|||||||
if (backend) await backend.pushCooldown(account.steamId, undefined, now.toISOString());
|
if (backend) await backend.pushCooldown(account.steamId, undefined, now.toISOString());
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (e.message.includes('cookie') || e.message.includes('Sign In')) account.authError = true;
|
if (e instanceof SteamAuthError) {
|
||||||
|
account.authError = true;
|
||||||
|
} else {
|
||||||
|
console.error(`[Scraper] Temporary error for ${account.personaName}: ${e.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (backend && !account._id.startsWith('shared_')) {
|
if (backend && !account._id.startsWith('shared_')) {
|
||||||
@@ -286,15 +290,31 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
} else {
|
} else {
|
||||||
const sDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
const sDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
||||||
const lDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
const lDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
||||||
if (sDate > lDate) {
|
// 1. SENSITIVE DATA SYNC (Credentials)
|
||||||
|
const sSessionDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
||||||
|
const lSessionDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
||||||
|
|
||||||
|
const isLocalAccount = !exists._id.startsWith('shared_');
|
||||||
|
const isLocalSessionHealthy = exists.steamLoginSecure && !exists.authError;
|
||||||
|
|
||||||
|
// SMART OVERWRITE LOGIC:
|
||||||
|
// - If it's a remote shared account: Newest wins.
|
||||||
|
// - If it's a LOCAL account: Only overwrite if our local session is broken/missing.
|
||||||
|
const shouldOverwriteCredentials = !isLocalAccount ? (sSessionDate > lSessionDate) : (!isLocalSessionHealthy && sSessionDate > lSessionDate);
|
||||||
|
|
||||||
|
if (shouldOverwriteCredentials) {
|
||||||
if (s.loginName) exists.loginName = s.loginName;
|
if (s.loginName) exists.loginName = s.loginName;
|
||||||
if (s.loginConfig) exists.loginConfig = s.loginConfig;
|
if (s.loginConfig) exists.loginConfig = s.loginConfig;
|
||||||
if (s.steamLoginSecure) { exists.steamLoginSecure = s.steamLoginSecure; exists.autoCheckCooldown = true; exists.authError = false; }
|
if (s.steamLoginSecure) {
|
||||||
|
exists.steamLoginSecure = s.steamLoginSecure;
|
||||||
|
exists.autoCheckCooldown = true;
|
||||||
|
exists.authError = false;
|
||||||
|
}
|
||||||
exists.sessionUpdatedAt = s.sessionUpdatedAt;
|
exists.sessionUpdatedAt = s.sessionUpdatedAt;
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metadata Sync (Pull)
|
// 2. Metadata Sync (Pull) - Always "Newest Wins"
|
||||||
const sMetaDate = s.lastMetadataCheck ? new Date(s.lastMetadataCheck) : new Date(0);
|
const sMetaDate = s.lastMetadataCheck ? new Date(s.lastMetadataCheck) : new Date(0);
|
||||||
const lMetaDate = exists.lastBanCheck ? new Date(exists.lastBanCheck) : new Date(0);
|
const lMetaDate = exists.lastBanCheck ? new Date(exists.lastBanCheck) : new Date(0);
|
||||||
if (sMetaDate > lMetaDate) {
|
if (sMetaDate > lMetaDate) {
|
||||||
|
|||||||
@@ -6,6 +6,14 @@ export interface CooldownData {
|
|||||||
expiresAt?: Date;
|
expiresAt?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom error to identify session death
|
||||||
|
export class SteamAuthError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message);
|
||||||
|
this.name = "SteamAuthError";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const scrapeCooldown = async (steamId: string, steamLoginSecure: string): Promise<CooldownData> => {
|
export const scrapeCooldown = async (steamId: string, steamLoginSecure: string): Promise<CooldownData> => {
|
||||||
const url = `https://steamcommunity.com/profiles/${steamId}/gcpd/730?tab=matchmaking`;
|
const url = `https://steamcommunity.com/profiles/${steamId}/gcpd/730?tab=matchmaking`;
|
||||||
|
|
||||||
@@ -15,16 +23,21 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
|
|||||||
'Cookie': steamLoginSecure,
|
'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'
|
'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
|
timeout: 10000,
|
||||||
|
validateStatus: (status) => status < 500 // Allow redirects to handle them manually
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If Steam redirects us to the login page, the cookie is dead
|
||||||
|
if (response.data.includes('Sign In') || response.request.path.includes('/login')) {
|
||||||
|
throw new SteamAuthError('Invalid or expired steamLoginSecure cookie');
|
||||||
|
}
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
if (response.data.includes('Sign In') || !response.data.includes('Personal Game Data')) {
|
if (!response.data.includes('Personal Game Data')) {
|
||||||
throw new Error('Invalid or expired steamLoginSecure cookie');
|
throw new SteamAuthError('Session invalid: Personal Game Data not accessible');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Locate the specific table containing cooldown info
|
|
||||||
let expirationDate: Date | undefined = undefined;
|
let expirationDate: Date | undefined = undefined;
|
||||||
|
|
||||||
$('table').each((_, table) => {
|
$('table').each((_, table) => {
|
||||||
@@ -36,15 +49,10 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
|
|||||||
rows.each((_, row) => {
|
rows.each((_, row) => {
|
||||||
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
||||||
if (dateText && dateText !== '') {
|
if (dateText && dateText !== '') {
|
||||||
// Steam uses 'GMT' which some JS engines don't parse well, replace with 'UTC'
|
|
||||||
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
||||||
const parsed = new Date(cleanDateText);
|
const parsed = new Date(cleanDateText);
|
||||||
|
|
||||||
if (!isNaN(parsed.getTime())) {
|
if (!isNaN(parsed.getTime())) {
|
||||||
// We want the newest expiration date found
|
if (!expirationDate || parsed > (expirationDate as Date)) expirationDate = parsed;
|
||||||
if (!expirationDate || parsed > (expirationDate as Date)) {
|
|
||||||
expirationDate = parsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -52,11 +60,7 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (expirationDate && (expirationDate as Date).getTime() > Date.now()) {
|
if (expirationDate && (expirationDate as Date).getTime() > Date.now()) {
|
||||||
console.log(`[Scraper] Found active cooldown until: ${(expirationDate as Date).toISOString()}`);
|
return { isActive: true, expiresAt: expirationDate };
|
||||||
return {
|
|
||||||
isActive: true,
|
|
||||||
expiresAt: expirationDate
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = $('#personal_game_data_content').text();
|
const content = $('#personal_game_data_content').text();
|
||||||
@@ -66,7 +70,8 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
|
|||||||
|
|
||||||
return { isActive: false };
|
return { isActive: false };
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(`[Scraper] Error for ${steamId}:`, error.message);
|
if (error instanceof SteamAuthError) throw error;
|
||||||
throw error;
|
console.error(`[Scraper] Network/Internal Error for ${steamId}:`, error.message);
|
||||||
|
throw error; // Generic errors don't trigger re-auth
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ultimate-ban-tracker-desktop",
|
"name": "ultimate-ban-tracker-desktop",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ultimate-ban-tracker-desktop",
|
"name": "ultimate-ban-tracker-desktop",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ultimate-ban-tracker-desktop",
|
"name": "ultimate-ban-tracker-desktop",
|
||||||
"description": "Professional Steam Account Manager & Ban Tracker",
|
"description": "Professional Steam Account Manager & Ban Tracker",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"author": "Nils Pukropp <nils@narl.io>",
|
"author": "Nils Pukropp <nils@narl.io>",
|
||||||
"homepage": "https://narl.io",
|
"homepage": "https://narl.io",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
|
|||||||
Reference in New Issue
Block a user