Compare commits
1 Commits
60b3dd1ca1
...
feat/revok
| Author | SHA1 | Date | |
|---|---|---|---|
| f3bc59e6d0 |
@@ -70,19 +70,27 @@ const createTray = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!iconPath)
|
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
||||||
|
if (!iconPath) {
|
||||||
|
console.warn(`[Tray] FAILED: No valid icon found in ${assetsDir}`);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const icon = electron_1.nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
const icon = electron_1.nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||||
tray = new electron_1.Tray(icon);
|
tray = new electron_1.Tray(icon);
|
||||||
tray.setToolTip('Ultimate Ban Tracker');
|
tray.setToolTip('Ultimate Ban Tracker');
|
||||||
tray.on('click', () => { if (mainWindow) {
|
tray.on('click', () => {
|
||||||
|
if (mainWindow) {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
} });
|
|
||||||
updateTrayMenu();
|
|
||||||
}
|
}
|
||||||
catch (e) { }
|
});
|
||||||
|
updateTrayMenu();
|
||||||
|
console.log(`[Tray] Successfully initialized`);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(`[Tray] Critical error during initialization: ${e.message}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const updateTrayMenu = () => {
|
const updateTrayMenu = () => {
|
||||||
if (!tray)
|
if (!tray)
|
||||||
@@ -100,7 +108,11 @@ const updateTrayMenu = () => {
|
|||||||
click: () => handleSwitchAccount(acc.loginName)
|
click: () => handleSwitchAccount(acc.loginName)
|
||||||
})) : [{ label: 'No accounts found', enabled: false }]
|
})) : [{ label: 'No accounts found', enabled: false }]
|
||||||
},
|
},
|
||||||
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
{
|
||||||
|
label: 'Sync Now',
|
||||||
|
enabled: !!config?.enabled,
|
||||||
|
click: () => syncAccounts()
|
||||||
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'Show Dashboard', click: () => { if (mainWindow)
|
{ label: 'Show Dashboard', click: () => { if (mainWindow)
|
||||||
mainWindow.show(); } },
|
mainWindow.show(); } },
|
||||||
@@ -143,58 +155,8 @@ const handleSwitchAccount = async (loginName) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// --- Scraper Helper ---
|
|
||||||
const scrapeAccountData = async (account) => {
|
|
||||||
const now = new Date();
|
|
||||||
try {
|
|
||||||
const profile = await (0, steam_web_1.fetchProfileData)(account.steamId, account.steamLoginSecure);
|
|
||||||
const bans = await (0, steam_web_1.scrapeBanStatus)(profile.profileUrl, account.steamLoginSecure);
|
|
||||||
account.personaName = profile.personaName;
|
|
||||||
account.profileUrl = profile.profileUrl;
|
|
||||||
account.vacBanned = bans.vacBanned;
|
|
||||||
account.gameBans = bans.gameBans;
|
|
||||||
account.status = (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none';
|
|
||||||
account.lastBanCheck = now.toISOString();
|
|
||||||
if (profile.avatar && (!account.localAvatar || profile.avatar !== account.avatar)) {
|
|
||||||
account.avatar = profile.avatar;
|
|
||||||
const localPath = await downloadAvatar(account.steamId, profile.avatar);
|
|
||||||
if (localPath)
|
|
||||||
account.localAvatar = localPath;
|
|
||||||
}
|
|
||||||
if (account.steamLoginSecure) {
|
|
||||||
try {
|
|
||||||
const result = await (0, scraper_1.scrapeCooldown)(account.steamId, account.steamLoginSecure);
|
|
||||||
account.authError = false;
|
|
||||||
account.lastScrapeTime = now.toISOString();
|
|
||||||
if (result.isActive) {
|
|
||||||
account.cooldownExpiresAt = result.expiresAt ? result.expiresAt.toISOString() : new Date(Date.now() + 86400000).toISOString();
|
|
||||||
if (backend)
|
|
||||||
await backend.pushCooldown(account.steamId, account.cooldownExpiresAt);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
account.cooldownExpiresAt = undefined;
|
|
||||||
if (backend)
|
|
||||||
await backend.pushCooldown(account.steamId, undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (e.message.includes('cookie') || e.message.includes('Sign In'))
|
|
||||||
account.authError = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (backend && !account._id.startsWith('shared_')) {
|
|
||||||
await backend.shareAccount(account);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error(`[Scraper] Failed to scrape ${account.personaName}:`, e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// --- Sync Worker ---
|
// --- Sync Worker ---
|
||||||
const syncAccounts = async (isManual = false) => {
|
const syncAccounts = async () => {
|
||||||
console.log(`[Sync] Phase 1: Pulling from server...`);
|
|
||||||
initBackend();
|
initBackend();
|
||||||
let accounts = store.get('accounts');
|
let accounts = store.get('accounts');
|
||||||
let hasChanges = false;
|
let hasChanges = false;
|
||||||
@@ -205,13 +167,12 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
const exists = accounts.find(a => a.steamId === s.steamId);
|
const exists = accounts.find(a => a.steamId === s.steamId);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
accounts.push({
|
accounts.push({
|
||||||
_id: `shared_${s.steamId}`, steamId: s.steamId, personaName: s.personaName,
|
_id: `shared_${s.steamId}`,
|
||||||
avatar: s.avatar, profileUrl: s.profileUrl, vacBanned: s.vacBanned,
|
steamId: s.steamId, personaName: s.personaName, avatar: s.avatar, profileUrl: s.profileUrl,
|
||||||
gameBans: s.gameBans, cooldownExpiresAt: s.cooldownExpiresAt,
|
vacBanned: s.vacBanned, gameBans: s.gameBans, cooldownExpiresAt: s.cooldownExpiresAt,
|
||||||
loginName: s.loginName || '', steamLoginSecure: s.steamLoginSecure,
|
loginName: s.loginName || '', steamLoginSecure: s.steamLoginSecure, loginConfig: s.loginConfig,
|
||||||
loginConfig: s.loginConfig, sessionUpdatedAt: s.sessionUpdatedAt,
|
sessionUpdatedAt: s.sessionUpdatedAt, autoCheckCooldown: !!s.steamLoginSecure,
|
||||||
autoCheckCooldown: !!s.steamLoginSecure, status: (s.vacBanned || s.gameBans > 0) ? 'banned' : 'none',
|
status: (s.vacBanned || s.gameBans > 0) ? 'banned' : 'none', lastBanCheck: new Date().toISOString()
|
||||||
lastBanCheck: new Date().toISOString(), sharedWith: s.sharedWith
|
|
||||||
});
|
});
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
@@ -235,10 +196,6 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
exists.cooldownExpiresAt = s.cooldownExpiresAt;
|
exists.cooldownExpiresAt = s.cooldownExpiresAt;
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
if (JSON.stringify(exists.sharedWith) !== JSON.stringify(s.sharedWith)) {
|
|
||||||
exists.sharedWith = s.sharedWith;
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,44 +207,82 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
mainWindow.webContents.send('accounts-updated', accounts);
|
mainWindow.webContents.send('accounts-updated', accounts);
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
// Phase 2: Background Scrapes
|
if (accounts.length === 0)
|
||||||
const runScrapes = async () => {
|
return;
|
||||||
console.log(`[Sync] Phase 2: Starting background checks for ${accounts.length} accounts...`);
|
const updatedAccounts = [...accounts];
|
||||||
const currentAccounts = [...store.get('accounts')];
|
|
||||||
let scrapeChanges = false;
|
let scrapeChanges = false;
|
||||||
for (const account of currentAccounts) {
|
for (const account of updatedAccounts) {
|
||||||
try {
|
try {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (backend && !account._id.startsWith('shared_'))
|
|
||||||
await backend.shareAccount(account);
|
|
||||||
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
|
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
|
||||||
const lastScrape = account.lastScrapeTime ? new Date(account.lastScrapeTime) : new Date(0);
|
if ((now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName) {
|
||||||
const needsMetadata = (now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName;
|
const profile = await (0, steam_web_1.fetchProfileData)(account.steamId, account.steamLoginSecure);
|
||||||
const needsCooldown = account.autoCheckCooldown && account.steamLoginSecure && (now.getTime() - lastScrape.getTime()) / 3600000 > 8;
|
const bans = await (0, steam_web_1.scrapeBanStatus)(profile.profileUrl, account.steamLoginSecure);
|
||||||
if (needsMetadata || needsCooldown || isManual) {
|
account.personaName = profile.personaName;
|
||||||
if (!isManual && needsCooldown)
|
account.profileUrl = profile.profileUrl;
|
||||||
await new Promise(r => setTimeout(r, Math.floor(Math.random() * 30000) + 5000));
|
account.vacBanned = bans.vacBanned;
|
||||||
if (await scrapeAccountData(account))
|
account.gameBans = bans.gameBans;
|
||||||
|
account.status = (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none';
|
||||||
|
account.lastBanCheck = now.toISOString();
|
||||||
|
if (profile.avatar && (!account.localAvatar || profile.avatar !== account.avatar)) {
|
||||||
|
account.avatar = profile.avatar;
|
||||||
|
const localPath = await downloadAvatar(account.steamId, profile.avatar);
|
||||||
|
if (localPath)
|
||||||
|
account.localAvatar = localPath;
|
||||||
|
}
|
||||||
|
if (account.loginName) {
|
||||||
|
const config = steam_client_1.steamClient.extractAccountConfig(account.loginName);
|
||||||
|
if (config) {
|
||||||
|
account.loginConfig = config;
|
||||||
|
account.sessionUpdatedAt = new Date().toISOString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (backend)
|
||||||
|
await backend.shareAccount(account);
|
||||||
scrapeChanges = true;
|
scrapeChanges = true;
|
||||||
}
|
}
|
||||||
|
if (account.autoCheckCooldown && account.steamLoginSecure) {
|
||||||
|
if (account.cooldownExpiresAt && new Date(account.cooldownExpiresAt) > now)
|
||||||
|
continue;
|
||||||
|
const lastScrape = account.lastScrapeTime ? new Date(account.lastScrapeTime) : new Date(0);
|
||||||
|
if ((now.getTime() - lastScrape.getTime()) / 3600000 > 8) {
|
||||||
|
await new Promise(r => setTimeout(r, Math.floor(Math.random() * 60000) + 5000));
|
||||||
|
try {
|
||||||
|
const result = await (0, scraper_1.scrapeCooldown)(account.steamId, account.steamLoginSecure);
|
||||||
|
account.authError = false;
|
||||||
|
account.lastScrapeTime = new Date().toISOString();
|
||||||
|
if (result.isActive) {
|
||||||
|
account.cooldownExpiresAt = result.expiresAt ? result.expiresAt.toISOString() : new Date(Date.now() + 86400000).toISOString();
|
||||||
|
if (backend)
|
||||||
|
await backend.pushCooldown(account.steamId, account.cooldownExpiresAt);
|
||||||
|
}
|
||||||
|
else if (account.cooldownExpiresAt) {
|
||||||
|
account.cooldownExpiresAt = undefined;
|
||||||
|
if (backend)
|
||||||
|
await backend.pushCooldown(account.steamId, undefined);
|
||||||
|
}
|
||||||
|
scrapeChanges = true;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e.message.includes('cookie') || e.message.includes('Sign In')) {
|
||||||
|
account.authError = true;
|
||||||
|
scrapeChanges = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
}
|
}
|
||||||
if (scrapeChanges) {
|
if (scrapeChanges) {
|
||||||
store.set('accounts', currentAccounts);
|
store.set('accounts', updatedAccounts);
|
||||||
if (mainWindow)
|
if (mainWindow)
|
||||||
mainWindow.webContents.send('accounts-updated', currentAccounts);
|
mainWindow.webContents.send('accounts-updated', updatedAccounts);
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
console.log('[Sync] Sync cycle finished.');
|
|
||||||
};
|
|
||||||
if (isManual)
|
|
||||||
await runScrapes();
|
|
||||||
else
|
|
||||||
runScrapes();
|
|
||||||
};
|
};
|
||||||
const scheduleNextSync = () => {
|
const scheduleNextSync = () => {
|
||||||
setTimeout(async () => { await syncAccounts(false); scheduleNextSync(); }, isDev ? 300000 : 1800000);
|
setTimeout(async () => { await syncAccounts(); scheduleNextSync(); }, isDev ? 120000 : 1800000);
|
||||||
};
|
};
|
||||||
// --- Discovery ---
|
// --- Discovery ---
|
||||||
const addingAccounts = new Set();
|
const addingAccounts = new Set();
|
||||||
@@ -331,7 +326,7 @@ const handleLocalAccountsFound = async (localAccounts) => {
|
|||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// --- Main Window ---
|
// --- Main Window Creation ---
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new electron_1.BrowserWindow({
|
mainWindow = new electron_1.BrowserWindow({
|
||||||
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
||||||
@@ -350,6 +345,7 @@ function createWindow() {
|
|||||||
else
|
else
|
||||||
mainWindow.loadFile(path_1.default.join(__dirname, '..', 'dist', 'index.html'));
|
mainWindow.loadFile(path_1.default.join(__dirname, '..', 'dist', 'index.html'));
|
||||||
}
|
}
|
||||||
|
// --- App Lifecycle ---
|
||||||
electron_1.app.whenReady().then(() => {
|
electron_1.app.whenReady().then(() => {
|
||||||
electron_1.protocol.handle('steam-resource', (request) => {
|
electron_1.protocol.handle('steam-resource', (request) => {
|
||||||
let rawPath = decodeURIComponent(request.url.replace('steam-resource://', ''));
|
let rawPath = decodeURIComponent(request.url.replace('steam-resource://', ''));
|
||||||
@@ -368,7 +364,7 @@ electron_1.app.whenReady().then(() => {
|
|||||||
createWindow();
|
createWindow();
|
||||||
createTray();
|
createTray();
|
||||||
initBackend();
|
initBackend();
|
||||||
setTimeout(() => syncAccounts(false), 5000);
|
setTimeout(syncAccounts, 5000);
|
||||||
scheduleNextSync();
|
scheduleNextSync();
|
||||||
steam_client_1.steamClient.startWatching(handleLocalAccountsFound);
|
steam_client_1.steamClient.startWatching(handleLocalAccountsFound);
|
||||||
});
|
});
|
||||||
@@ -395,7 +391,7 @@ electron_1.ipcMain.handle('login-to-server', async () => {
|
|||||||
return false;
|
return false;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const authWindow = new electron_1.BrowserWindow({
|
const authWindow = new electron_1.BrowserWindow({
|
||||||
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Server',
|
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Ban Tracker Server',
|
||||||
webPreferences: { nodeIntegration: false, contextIsolation: true }
|
webPreferences: { nodeIntegration: false, contextIsolation: true }
|
||||||
});
|
});
|
||||||
authWindow.loadURL(`${config.url}/auth/steam`);
|
authWindow.loadURL(`${config.url}/auth/steam`);
|
||||||
@@ -405,15 +401,13 @@ electron_1.ipcMain.handle('login-to-server', async () => {
|
|||||||
return;
|
return;
|
||||||
captured = true;
|
captured = true;
|
||||||
let serverSteamId = undefined;
|
let serverSteamId = undefined;
|
||||||
let isAdmin = false;
|
|
||||||
try {
|
try {
|
||||||
const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
|
const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
|
||||||
serverSteamId = payload.steamId;
|
serverSteamId = payload.steamId;
|
||||||
isAdmin = !!payload.isAdmin;
|
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
const current = store.get('serverConfig');
|
const current = store.get('serverConfig');
|
||||||
store.set('serverConfig', { ...current, token, serverSteamId, isAdmin, enabled: true });
|
store.set('serverConfig', { ...current, token, serverSteamId, enabled: true });
|
||||||
initBackend();
|
initBackend();
|
||||||
authWindow.close();
|
authWindow.close();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@@ -437,21 +431,7 @@ electron_1.ipcMain.handle('login-to-server', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
electron_1.ipcMain.handle('get-server-user-info', () => ({ steamId: store.get('serverConfig').serverSteamId }));
|
electron_1.ipcMain.handle('get-server-user-info', () => ({ steamId: store.get('serverConfig').serverSteamId }));
|
||||||
electron_1.ipcMain.handle('sync-now', async () => { await syncAccounts(true); return true; });
|
electron_1.ipcMain.handle('sync-now', async () => { await syncAccounts(); return true; });
|
||||||
electron_1.ipcMain.handle('scrape-account', async (event, steamId) => {
|
|
||||||
const accounts = store.get('accounts');
|
|
||||||
const account = accounts.find(a => a.steamId === steamId);
|
|
||||||
if (!account)
|
|
||||||
return false;
|
|
||||||
const success = await scrapeAccountData(account);
|
|
||||||
if (success) {
|
|
||||||
store.set('accounts', accounts);
|
|
||||||
if (mainWindow)
|
|
||||||
mainWindow.webContents.send('accounts-updated', accounts);
|
|
||||||
updateTrayMenu();
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
});
|
|
||||||
electron_1.ipcMain.handle('add-account', async (event, { identifier }) => {
|
electron_1.ipcMain.handle('add-account', async (event, { identifier }) => {
|
||||||
try {
|
try {
|
||||||
initBackend();
|
initBackend();
|
||||||
@@ -469,7 +449,7 @@ electron_1.ipcMain.handle('add-account', async (event, { identifier }) => {
|
|||||||
loginName: existing.loginName || '', steamLoginSecure: existing.steamLoginSecure,
|
loginName: existing.loginName || '', steamLoginSecure: existing.steamLoginSecure,
|
||||||
loginConfig: existing.loginConfig, sessionUpdatedAt: existing.sessionUpdatedAt,
|
loginConfig: existing.loginConfig, sessionUpdatedAt: existing.sessionUpdatedAt,
|
||||||
autoCheckCooldown: !!existing.steamLoginSecure, status: (existing.vacBanned || existing.gameBans > 0) ? 'banned' : 'none',
|
autoCheckCooldown: !!existing.steamLoginSecure, status: (existing.vacBanned || existing.gameBans > 0) ? 'banned' : 'none',
|
||||||
lastBanCheck: new Date().toISOString(), sharedWith: existing.sharedWith
|
lastBanCheck: new Date().toISOString()
|
||||||
};
|
};
|
||||||
store.set('accounts', [...accounts, newAccount]);
|
store.set('accounts', [...accounts, newAccount]);
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
@@ -536,23 +516,18 @@ electron_1.ipcMain.handle('revoke-all-account-access', async (event, steamId) =>
|
|||||||
});
|
});
|
||||||
electron_1.ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
|
electron_1.ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
|
||||||
electron_1.ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
|
electron_1.ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
|
||||||
// --- Admin IPC ---
|
|
||||||
electron_1.ipcMain.handle('admin-get-stats', async () => { initBackend(); return backend ? await backend.getAdminStats() : null; });
|
|
||||||
electron_1.ipcMain.handle('admin-get-users', async () => { initBackend(); return backend ? await backend.getAdminUsers() : []; });
|
|
||||||
electron_1.ipcMain.handle('admin-delete-user', async (event, userId) => { initBackend(); if (backend)
|
|
||||||
await backend.deleteUser(userId); return true; });
|
|
||||||
electron_1.ipcMain.handle('admin-get-accounts', async () => { initBackend(); return backend ? await backend.getAdminAccounts() : []; });
|
|
||||||
electron_1.ipcMain.handle('admin-remove-account', async (event, steamId) => { initBackend(); if (backend)
|
|
||||||
await backend.forceRemoveAccount(steamId); return true; });
|
|
||||||
electron_1.ipcMain.handle('switch-account', async (event, loginName) => await handleSwitchAccount(loginName));
|
electron_1.ipcMain.handle('switch-account', async (event, loginName) => await handleSwitchAccount(loginName));
|
||||||
electron_1.ipcMain.handle('open-external', (event, url) => electron_1.shell.openExternal(url));
|
electron_1.ipcMain.handle('open-external', (event, url) => electron_1.shell.openExternal(url));
|
||||||
electron_1.ipcMain.handle('open-steam-app-login', async () => {
|
electron_1.ipcMain.handle('open-steam-app-login', async () => {
|
||||||
|
console.log('[SteamClient] Preparing for fresh login...');
|
||||||
await killSteam();
|
await killSteam();
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
// Clear auto-login registry
|
||||||
const clearReg = 'reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "" /f';
|
const clearReg = 'reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "" /f';
|
||||||
await new Promise((res) => (0, child_process_1.exec)(clearReg, () => res()));
|
await new Promise((res) => (0, child_process_1.exec)(clearReg, () => res()));
|
||||||
}
|
}
|
||||||
else if (process.platform === 'linux') {
|
else if (process.platform === 'linux') {
|
||||||
|
// On Linux we can use the steamClient helper to set an empty user
|
||||||
await steam_client_1.steamClient.setAutoLoginUser("", undefined, "");
|
await steam_client_1.steamClient.setAutoLoginUser("", undefined, "");
|
||||||
}
|
}
|
||||||
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
|
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
|
||||||
@@ -560,20 +535,34 @@ electron_1.ipcMain.handle('open-steam-app-login', async () => {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
electron_1.ipcMain.handle('open-steam-login', async (event, expectedSteamId) => {
|
electron_1.ipcMain.handle('open-steam-login', async (event, expectedSteamId) => {
|
||||||
|
// Use a unique partition per account to prevent session bleeding
|
||||||
const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new';
|
const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new';
|
||||||
const loginSession = electron_1.session.fromPartition(partitionId);
|
const loginSession = electron_1.session.fromPartition(partitionId);
|
||||||
if (!expectedSteamId)
|
// If adding a brand new account, explicitly clear previous trash
|
||||||
|
if (!expectedSteamId) {
|
||||||
|
console.log('[Auth] Clearing session for new account login...');
|
||||||
await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
|
await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
|
||||||
|
}
|
||||||
|
// If we have an existing cookie string for this account, pre-inject it
|
||||||
if (expectedSteamId) {
|
if (expectedSteamId) {
|
||||||
const accounts = store.get('accounts');
|
const accounts = store.get('accounts');
|
||||||
const account = accounts.find(a => a.steamId === expectedSteamId);
|
const account = accounts.find(a => a.steamId === expectedSteamId);
|
||||||
if (account?.steamLoginSecure) {
|
if (account?.steamLoginSecure) {
|
||||||
|
console.log(`[Auth] Pre-injecting existing cookies for ${account.personaName}...`);
|
||||||
const cookiePairs = account.steamLoginSecure.split(';').map(c => c.trim());
|
const cookiePairs = account.steamLoginSecure.split(';').map(c => c.trim());
|
||||||
for (const pair of cookiePairs) {
|
for (const pair of cookiePairs) {
|
||||||
const [name, value] = pair.split('=');
|
const [name, value] = pair.split('=');
|
||||||
if (name && value) {
|
if (name && value) {
|
||||||
try {
|
try {
|
||||||
await loginSession.cookies.set({ url: 'https://steamcommunity.com', domain: 'steamcommunity.com', name, value, path: '/', secure: true, httpOnly: name.includes('Secure') });
|
await loginSession.cookies.set({
|
||||||
|
url: 'https://steamcommunity.com',
|
||||||
|
domain: 'steamcommunity.com',
|
||||||
|
name: name,
|
||||||
|
value: value,
|
||||||
|
path: '/',
|
||||||
|
secure: true,
|
||||||
|
httpOnly: name.includes('Secure')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,8 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
loginToServer: () => electron_1.ipcRenderer.invoke('login-to-server'),
|
loginToServer: () => electron_1.ipcRenderer.invoke('login-to-server'),
|
||||||
getServerUserInfo: () => electron_1.ipcRenderer.invoke('get-server-user-info'),
|
getServerUserInfo: () => electron_1.ipcRenderer.invoke('get-server-user-info'),
|
||||||
syncNow: () => electron_1.ipcRenderer.invoke('sync-now'),
|
syncNow: () => electron_1.ipcRenderer.invoke('sync-now'),
|
||||||
scrapeAccount: (steamId) => electron_1.ipcRenderer.invoke('scrape-account', steamId),
|
|
||||||
getCommunityAccounts: () => electron_1.ipcRenderer.invoke('get-community-accounts'),
|
getCommunityAccounts: () => electron_1.ipcRenderer.invoke('get-community-accounts'),
|
||||||
getServerUsers: () => electron_1.ipcRenderer.invoke('get-server-users'),
|
getServerUsers: () => electron_1.ipcRenderer.invoke('get-server-users'),
|
||||||
// Admin API
|
|
||||||
adminGetStats: () => electron_1.ipcRenderer.invoke('admin-get-stats'),
|
|
||||||
adminGetUsers: () => electron_1.ipcRenderer.invoke('admin-get-users'),
|
|
||||||
adminDeleteUser: (userId) => electron_1.ipcRenderer.invoke('admin-delete-user', userId),
|
|
||||||
adminGetAccounts: () => electron_1.ipcRenderer.invoke('admin-get-accounts'),
|
|
||||||
adminRemoveAccount: (steamId) => electron_1.ipcRenderer.invoke('admin-remove-account', steamId),
|
|
||||||
onAccountsUpdated: (callback) => {
|
onAccountsUpdated: (callback) => {
|
||||||
const subscription = (_event, accounts) => callback(accounts);
|
const subscription = (_event, accounts) => callback(accounts);
|
||||||
electron_1.ipcRenderer.on('accounts-updated', subscription);
|
electron_1.ipcRenderer.on('accounts-updated', subscription);
|
||||||
|
|||||||
@@ -130,59 +130,5 @@ class BackendService {
|
|||||||
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
|
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- Admin API ---
|
|
||||||
async getAdminStats() {
|
|
||||||
if (!this.token)
|
|
||||||
return null;
|
|
||||||
try {
|
|
||||||
const response = await axios_1.default.get(`${this.url}/api/admin/stats`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async getAdminUsers() {
|
|
||||||
if (!this.token)
|
|
||||||
return [];
|
|
||||||
try {
|
|
||||||
const response = await axios_1.default.get(`${this.url}/api/admin/users`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async deleteUser(userId) {
|
|
||||||
if (!this.token)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
await axios_1.default.delete(`${this.url}/api/admin/users/${userId}`, { headers: this.headers });
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(e.response?.data?.message || 'Failed to delete user');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async getAdminAccounts() {
|
|
||||||
if (!this.token)
|
|
||||||
return [];
|
|
||||||
try {
|
|
||||||
const response = await axios_1.default.get(`${this.url}/api/admin/accounts`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async forceRemoveAccount(steamId) {
|
|
||||||
if (!this.token)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
await axios_1.default.delete(`${this.url}/api/admin/accounts/${steamId}`, { headers: this.headers });
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(e.response?.data?.message || 'Failed to remove account');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.BackendService = BackendService;
|
exports.BackendService = BackendService;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ interface Account {
|
|||||||
cooldownExpiresAt?: string;
|
cooldownExpiresAt?: string;
|
||||||
authError?: boolean;
|
authError?: boolean;
|
||||||
notes?: string;
|
notes?: string;
|
||||||
sharedWith?: any[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ServerConfig {
|
interface ServerConfig {
|
||||||
@@ -49,7 +48,6 @@ interface ServerConfig {
|
|||||||
serverSteamId?: string;
|
serverSteamId?: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
isAdmin?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- App State ---
|
// --- App State ---
|
||||||
@@ -93,26 +91,10 @@ const initBackend = () => {
|
|||||||
|
|
||||||
// --- System Tray ---
|
// --- System Tray ---
|
||||||
const createTray = () => {
|
const createTray = () => {
|
||||||
// Try to find the icon in various standard locations
|
const assetsDir = path.join(__dirname, '..', 'assets-build');
|
||||||
const possiblePaths = [
|
const possibleIcons = ['icon.svg', 'icon.png'];
|
||||||
path.join(__dirname, '..', 'assets-build'), // Dev
|
|
||||||
path.join(process.resourcesPath, 'assets-build'), // Packaged (External)
|
|
||||||
path.join(app.getAppPath(), 'dist', 'assets-build'), // Packaged (Internal dist)
|
|
||||||
path.join(app.getAppPath(), 'assets-build') // Packaged (Internal root)
|
|
||||||
];
|
|
||||||
|
|
||||||
let assetsDir = '';
|
|
||||||
for (const p of possiblePaths) {
|
|
||||||
if (fs.existsSync(p)) {
|
|
||||||
assetsDir = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const possibleIcons = ['icon.png', 'icon.svg'];
|
|
||||||
let iconPath = '';
|
let iconPath = '';
|
||||||
|
|
||||||
if (assetsDir) {
|
|
||||||
for (const name of possibleIcons) {
|
for (const name of possibleIcons) {
|
||||||
const fullPath = path.join(assetsDir, name);
|
const fullPath = path.join(assetsDir, name);
|
||||||
if (fs.existsSync(fullPath)) {
|
if (fs.existsSync(fullPath)) {
|
||||||
@@ -120,13 +102,11 @@ const createTray = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[Tray] Resolved assets directory: ${assetsDir || 'NOT FOUND'}`);
|
|
||||||
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
||||||
|
|
||||||
if (!iconPath) {
|
if (!iconPath) {
|
||||||
console.warn(`[Tray] FAILED: No valid icon found in searched paths.`);
|
console.warn(`[Tray] FAILED: No valid icon found in ${assetsDir}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,15 +114,24 @@ const createTray = () => {
|
|||||||
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||||
tray = new Tray(icon);
|
tray = new Tray(icon);
|
||||||
tray.setToolTip('Ultimate Ban Tracker');
|
tray.setToolTip('Ultimate Ban Tracker');
|
||||||
tray.on('click', () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } });
|
tray.on('click', () => {
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
} catch (e) { }
|
console.log(`[Tray] Successfully initialized`);
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(`[Tray] Critical error during initialization: ${e.message}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTrayMenu = () => {
|
const updateTrayMenu = () => {
|
||||||
if (!tray) return;
|
if (!tray) return;
|
||||||
const accounts = store.get('accounts') as Account[];
|
const accounts = store.get('accounts') as Account[];
|
||||||
const config = store.get('serverConfig');
|
const config = store.get('serverConfig');
|
||||||
|
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{ label: `Ultimate Ban Tracker v${app.getVersion()}`, enabled: false },
|
{ label: `Ultimate Ban Tracker v${app.getVersion()}`, enabled: false },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
@@ -154,11 +143,16 @@ const updateTrayMenu = () => {
|
|||||||
click: () => handleSwitchAccount(acc.loginName)
|
click: () => handleSwitchAccount(acc.loginName)
|
||||||
})) : [{ label: 'No accounts found', enabled: false }]
|
})) : [{ label: 'No accounts found', enabled: false }]
|
||||||
},
|
},
|
||||||
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
{
|
||||||
|
label: 'Sync Now',
|
||||||
|
enabled: !!config?.enabled,
|
||||||
|
click: () => syncAccounts()
|
||||||
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'Show Dashboard', click: () => { if (mainWindow) mainWindow.show(); } },
|
{ label: 'Show Dashboard', click: () => { if (mainWindow) mainWindow.show(); } },
|
||||||
{ label: 'Quit', click: () => { (app as any).isQuitting = true; app.quit(); } }
|
{ label: 'Quit', click: () => { (app as any).isQuitting = true; app.quit(); } }
|
||||||
]);
|
]);
|
||||||
|
|
||||||
tray.setContextMenu(contextMenu);
|
tray.setContextMenu(contextMenu);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -194,49 +188,8 @@ const handleSwitchAccount = async (loginName: string) => {
|
|||||||
} catch (e) { return false; }
|
} catch (e) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Scraper Helper ---
|
|
||||||
const scrapeAccountData = async (account: Account) => {
|
|
||||||
const now = new Date();
|
|
||||||
try {
|
|
||||||
const profile = await fetchProfileData(account.steamId, account.steamLoginSecure);
|
|
||||||
const bans = await scrapeBanStatus(profile.profileUrl, account.steamLoginSecure);
|
|
||||||
account.personaName = profile.personaName; account.profileUrl = profile.profileUrl;
|
|
||||||
account.vacBanned = bans.vacBanned; account.gameBans = bans.gameBans;
|
|
||||||
account.status = (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none';
|
|
||||||
account.lastBanCheck = now.toISOString();
|
|
||||||
if (profile.avatar && (!account.localAvatar || profile.avatar !== account.avatar)) {
|
|
||||||
account.avatar = profile.avatar;
|
|
||||||
const localPath = await downloadAvatar(account.steamId, profile.avatar);
|
|
||||||
if (localPath) account.localAvatar = localPath;
|
|
||||||
}
|
|
||||||
if (account.steamLoginSecure) {
|
|
||||||
try {
|
|
||||||
const result = await scrapeCooldown(account.steamId, account.steamLoginSecure);
|
|
||||||
account.authError = false; account.lastScrapeTime = now.toISOString();
|
|
||||||
if (result.isActive) {
|
|
||||||
account.cooldownExpiresAt = result.expiresAt ? result.expiresAt.toISOString() : new Date(Date.now() + 86400000).toISOString();
|
|
||||||
if (backend) await backend.pushCooldown(account.steamId, account.cooldownExpiresAt);
|
|
||||||
} else {
|
|
||||||
account.cooldownExpiresAt = undefined;
|
|
||||||
if (backend) await backend.pushCooldown(account.steamId, undefined);
|
|
||||||
}
|
|
||||||
} catch (e: any) {
|
|
||||||
if (e.message.includes('cookie') || e.message.includes('Sign In')) account.authError = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (backend && !account._id.startsWith('shared_')) {
|
|
||||||
await backend.shareAccount(account);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[Scraper] Failed to scrape ${account.personaName}:`, e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Sync Worker ---
|
// --- Sync Worker ---
|
||||||
const syncAccounts = async (isManual = false) => {
|
const syncAccounts = async () => {
|
||||||
console.log(`[Sync] Phase 1: Pulling from server...`);
|
|
||||||
initBackend();
|
initBackend();
|
||||||
let accounts = store.get('accounts') as Account[];
|
let accounts = store.get('accounts') as Account[];
|
||||||
let hasChanges = false;
|
let hasChanges = false;
|
||||||
@@ -248,13 +201,12 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
const exists = accounts.find(a => a.steamId === s.steamId);
|
const exists = accounts.find(a => a.steamId === s.steamId);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
accounts.push({
|
accounts.push({
|
||||||
_id: `shared_${s.steamId}`, steamId: s.steamId, personaName: s.personaName,
|
_id: `shared_${s.steamId}`,
|
||||||
avatar: s.avatar, profileUrl: s.profileUrl, vacBanned: s.vacBanned,
|
steamId: s.steamId, personaName: s.personaName, avatar: s.avatar, profileUrl: s.profileUrl,
|
||||||
gameBans: s.gameBans, cooldownExpiresAt: s.cooldownExpiresAt,
|
vacBanned: s.vacBanned, gameBans: s.gameBans, cooldownExpiresAt: s.cooldownExpiresAt,
|
||||||
loginName: s.loginName || '', steamLoginSecure: s.steamLoginSecure,
|
loginName: s.loginName || '', steamLoginSecure: s.steamLoginSecure, loginConfig: s.loginConfig,
|
||||||
loginConfig: s.loginConfig, sessionUpdatedAt: s.sessionUpdatedAt,
|
sessionUpdatedAt: s.sessionUpdatedAt, autoCheckCooldown: !!s.steamLoginSecure,
|
||||||
autoCheckCooldown: !!s.steamLoginSecure, status: (s.vacBanned || s.gameBans > 0) ? 'banned' : 'none',
|
status: (s.vacBanned || s.gameBans > 0) ? 'banned' : 'none', lastBanCheck: new Date().toISOString()
|
||||||
lastBanCheck: new Date().toISOString(), sharedWith: s.sharedWith
|
|
||||||
});
|
});
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -271,10 +223,6 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
exists.cooldownExpiresAt = s.cooldownExpiresAt;
|
exists.cooldownExpiresAt = s.cooldownExpiresAt;
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
if (JSON.stringify(exists.sharedWith) !== JSON.stringify(s.sharedWith)) {
|
|
||||||
exists.sharedWith = s.sharedWith;
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
@@ -286,39 +234,68 @@ const syncAccounts = async (isManual = false) => {
|
|||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 2: Background Scrapes
|
if (accounts.length === 0) return;
|
||||||
const runScrapes = async () => {
|
|
||||||
console.log(`[Sync] Phase 2: Starting background checks for ${accounts.length} accounts...`);
|
const updatedAccounts = [...accounts];
|
||||||
const currentAccounts = [...store.get('accounts') as Account[]];
|
|
||||||
let scrapeChanges = false;
|
let scrapeChanges = false;
|
||||||
for (const account of currentAccounts) {
|
|
||||||
|
for (const account of updatedAccounts) {
|
||||||
try {
|
try {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (backend && !account._id.startsWith('shared_')) await backend.shareAccount(account);
|
|
||||||
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
|
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
|
||||||
const lastScrape = account.lastScrapeTime ? new Date(account.lastScrapeTime) : new Date(0);
|
if ((now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName) {
|
||||||
const needsMetadata = (now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName;
|
const profile = await fetchProfileData(account.steamId, account.steamLoginSecure);
|
||||||
const needsCooldown = account.autoCheckCooldown && account.steamLoginSecure && (now.getTime() - lastScrape.getTime()) / 3600000 > 8;
|
const bans = await scrapeBanStatus(profile.profileUrl, account.steamLoginSecure);
|
||||||
|
account.personaName = profile.personaName; account.profileUrl = profile.profileUrl;
|
||||||
|
account.vacBanned = bans.vacBanned; account.gameBans = bans.gameBans;
|
||||||
|
account.status = (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none';
|
||||||
|
account.lastBanCheck = now.toISOString();
|
||||||
|
if (profile.avatar && (!account.localAvatar || profile.avatar !== account.avatar)) {
|
||||||
|
account.avatar = profile.avatar;
|
||||||
|
const localPath = await downloadAvatar(account.steamId, profile.avatar);
|
||||||
|
if (localPath) account.localAvatar = localPath;
|
||||||
|
}
|
||||||
|
if (account.loginName) {
|
||||||
|
const config = steamClient.extractAccountConfig(account.loginName);
|
||||||
|
if (config) { account.loginConfig = config; account.sessionUpdatedAt = new Date().toISOString(); }
|
||||||
|
}
|
||||||
|
if (backend) await backend.shareAccount(account);
|
||||||
|
scrapeChanges = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (needsMetadata || needsCooldown || isManual) {
|
if (account.autoCheckCooldown && account.steamLoginSecure) {
|
||||||
if (!isManual && needsCooldown) await new Promise(r => setTimeout(r, Math.floor(Math.random() * 30000) + 5000));
|
if (account.cooldownExpiresAt && new Date(account.cooldownExpiresAt) > now) continue;
|
||||||
if (await scrapeAccountData(account)) scrapeChanges = true;
|
const lastScrape = account.lastScrapeTime ? new Date(account.lastScrapeTime) : new Date(0);
|
||||||
|
if ((now.getTime() - lastScrape.getTime()) / 3600000 > 8) {
|
||||||
|
await new Promise(r => setTimeout(r, Math.floor(Math.random() * 60000) + 5000));
|
||||||
|
try {
|
||||||
|
const result = await scrapeCooldown(account.steamId, account.steamLoginSecure);
|
||||||
|
account.authError = false; account.lastScrapeTime = new Date().toISOString();
|
||||||
|
if (result.isActive) {
|
||||||
|
account.cooldownExpiresAt = result.expiresAt ? result.expiresAt.toISOString() : new Date(Date.now() + 86400000).toISOString();
|
||||||
|
if (backend) await backend.pushCooldown(account.steamId, account.cooldownExpiresAt);
|
||||||
|
} else if (account.cooldownExpiresAt) {
|
||||||
|
account.cooldownExpiresAt = undefined;
|
||||||
|
if (backend) await backend.pushCooldown(account.steamId, undefined);
|
||||||
|
}
|
||||||
|
scrapeChanges = true;
|
||||||
|
} catch (e: any) {
|
||||||
|
if (e.message.includes('cookie') || e.message.includes('Sign In')) { account.authError = true; scrapeChanges = true; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) { }
|
} catch (error) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrapeChanges) {
|
if (scrapeChanges) {
|
||||||
store.set('accounts', currentAccounts);
|
store.set('accounts', updatedAccounts);
|
||||||
if (mainWindow) mainWindow.webContents.send('accounts-updated', currentAccounts);
|
if (mainWindow) mainWindow.webContents.send('accounts-updated', updatedAccounts);
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
console.log('[Sync] Sync cycle finished.');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isManual) await runScrapes(); else runScrapes();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const scheduleNextSync = () => {
|
const scheduleNextSync = () => {
|
||||||
setTimeout(async () => { await syncAccounts(false); scheduleNextSync(); }, isDev ? 300000 : 1800000);
|
setTimeout(async () => { await syncAccounts(); scheduleNextSync(); }, isDev ? 120000 : 1800000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Discovery ---
|
// --- Discovery ---
|
||||||
@@ -357,21 +334,28 @@ const handleLocalAccountsFound = async (localAccounts: LocalSteamAccount[]) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Main Window ---
|
// --- Main Window Creation ---
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
||||||
webPreferences: { preload: path.join(__dirname, 'preload.js'), nodeIntegration: false, contextIsolation: true }
|
webPreferences: { preload: path.join(__dirname, 'preload.js'), nodeIntegration: false, contextIsolation: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.setMenu(null);
|
mainWindow.setMenu(null);
|
||||||
|
|
||||||
mainWindow.on('close', (event) => {
|
mainWindow.on('close', (event) => {
|
||||||
if (!(app as any).isQuitting) { event.preventDefault(); mainWindow?.hide(); }
|
if (!(app as any).isQuitting) {
|
||||||
|
event.preventDefault();
|
||||||
|
mainWindow?.hide();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isDev) mainWindow.loadURL('http://localhost:5173');
|
if (isDev) mainWindow.loadURL('http://localhost:5173');
|
||||||
else mainWindow.loadFile(path.join(__dirname, '..', 'dist', 'index.html'));
|
else mainWindow.loadFile(path.join(__dirname, '..', 'dist', 'index.html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- App Lifecycle ---
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
protocol.handle('steam-resource', (request) => {
|
protocol.handle('steam-resource', (request) => {
|
||||||
let rawPath = decodeURIComponent(request.url.replace('steam-resource://', ''));
|
let rawPath = decodeURIComponent(request.url.replace('steam-resource://', ''));
|
||||||
@@ -380,10 +364,11 @@ app.whenReady().then(() => {
|
|||||||
if (!fs.existsSync(absolutePath)) return new Response('Not Found', { status: 404 });
|
if (!fs.existsSync(absolutePath)) return new Response('Not Found', { status: 404 });
|
||||||
try { return net.fetch(pathToFileURL(absolutePath).toString()); } catch (e) { return new Response('Error', { status: 500 }); }
|
try { return net.fetch(pathToFileURL(absolutePath).toString()); } catch (e) { return new Response('Error', { status: 500 }); }
|
||||||
});
|
});
|
||||||
|
|
||||||
createWindow();
|
createWindow();
|
||||||
createTray();
|
createTray();
|
||||||
initBackend();
|
initBackend();
|
||||||
setTimeout(() => syncAccounts(false), 5000);
|
setTimeout(syncAccounts, 5000);
|
||||||
scheduleNextSync();
|
scheduleNextSync();
|
||||||
steamClient.startWatching(handleLocalAccountsFound);
|
steamClient.startWatching(handleLocalAccountsFound);
|
||||||
});
|
});
|
||||||
@@ -408,20 +393,17 @@ ipcMain.handle('login-to-server', async () => {
|
|||||||
if (!config.url) return false;
|
if (!config.url) return false;
|
||||||
return new Promise<boolean>((resolve) => {
|
return new Promise<boolean>((resolve) => {
|
||||||
const authWindow = new BrowserWindow({
|
const authWindow = new BrowserWindow({
|
||||||
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Server',
|
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Ban Tracker Server',
|
||||||
webPreferences: { nodeIntegration: false, contextIsolation: true }
|
webPreferences: { nodeIntegration: false, contextIsolation: true }
|
||||||
});
|
});
|
||||||
authWindow.loadURL(`${config.url}/auth/steam`);
|
authWindow.loadURL(`${config.url}/auth/steam`);
|
||||||
let captured = false;
|
let captured = false;
|
||||||
const saveServerAuth = (token: string) => {
|
const saveServerAuth = (token: string) => {
|
||||||
if (captured) return; captured = true;
|
if (captured) return; captured = true;
|
||||||
let serverSteamId = undefined; let isAdmin = false;
|
let serverSteamId = undefined;
|
||||||
try {
|
try { const payload = JSON.parse(Buffer.from(token.split('.')[1]!, 'base64').toString()); serverSteamId = payload.steamId; } catch (e) {}
|
||||||
const payload = JSON.parse(Buffer.from(token.split('.')[1]!, 'base64').toString());
|
|
||||||
serverSteamId = payload.steamId; isAdmin = !!payload.isAdmin;
|
|
||||||
} catch (e) {}
|
|
||||||
const current = store.get('serverConfig');
|
const current = store.get('serverConfig');
|
||||||
store.set('serverConfig', { ...current, token, serverSteamId, isAdmin, enabled: true });
|
store.set('serverConfig', { ...current, token, serverSteamId, enabled: true });
|
||||||
initBackend();
|
initBackend();
|
||||||
authWindow.close();
|
authWindow.close();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@@ -441,21 +423,7 @@ ipcMain.handle('login-to-server', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('get-server-user-info', () => ({ steamId: store.get('serverConfig').serverSteamId }));
|
ipcMain.handle('get-server-user-info', () => ({ steamId: store.get('serverConfig').serverSteamId }));
|
||||||
ipcMain.handle('sync-now', async () => { await syncAccounts(true); return true; });
|
ipcMain.handle('sync-now', async () => { await syncAccounts(); return true; });
|
||||||
|
|
||||||
ipcMain.handle('scrape-account', async (event, steamId: string) => {
|
|
||||||
const accounts = store.get('accounts') as Account[];
|
|
||||||
const account = accounts.find(a => a.steamId === steamId);
|
|
||||||
if (!account) return false;
|
|
||||||
const success = await scrapeAccountData(account);
|
|
||||||
if (success) {
|
|
||||||
store.set('accounts', accounts);
|
|
||||||
if (mainWindow) mainWindow.webContents.send('accounts-updated', accounts);
|
|
||||||
updateTrayMenu();
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('add-account', async (event, { identifier }) => {
|
ipcMain.handle('add-account', async (event, { identifier }) => {
|
||||||
try {
|
try {
|
||||||
initBackend();
|
initBackend();
|
||||||
@@ -472,7 +440,7 @@ ipcMain.handle('add-account', async (event, { identifier }) => {
|
|||||||
loginName: existing.loginName || '', steamLoginSecure: existing.steamLoginSecure,
|
loginName: existing.loginName || '', steamLoginSecure: existing.steamLoginSecure,
|
||||||
loginConfig: existing.loginConfig, sessionUpdatedAt: existing.sessionUpdatedAt,
|
loginConfig: existing.loginConfig, sessionUpdatedAt: existing.sessionUpdatedAt,
|
||||||
autoCheckCooldown: !!existing.steamLoginSecure, status: (existing.vacBanned || existing.gameBans > 0) ? 'banned' : 'none',
|
autoCheckCooldown: !!existing.steamLoginSecure, status: (existing.vacBanned || existing.gameBans > 0) ? 'banned' : 'none',
|
||||||
lastBanCheck: new Date().toISOString(), sharedWith: existing.sharedWith
|
lastBanCheck: new Date().toISOString()
|
||||||
};
|
};
|
||||||
store.set('accounts', [...accounts, newAccount]);
|
store.set('accounts', [...accounts, newAccount]);
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
@@ -534,47 +502,64 @@ ipcMain.handle('revoke-all-account-access', async (event, steamId: string) => {
|
|||||||
|
|
||||||
ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
|
ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
|
||||||
ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
|
ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
|
||||||
|
|
||||||
// --- Admin IPC ---
|
|
||||||
ipcMain.handle('admin-get-stats', async () => { initBackend(); return backend ? await backend.getAdminStats() : null; });
|
|
||||||
ipcMain.handle('admin-get-users', async () => { initBackend(); return backend ? await backend.getAdminUsers() : []; });
|
|
||||||
ipcMain.handle('admin-delete-user', async (event, userId: string) => { initBackend(); if (backend) await backend.deleteUser(userId); return true; });
|
|
||||||
ipcMain.handle('admin-get-accounts', async () => { initBackend(); return backend ? await backend.getAdminAccounts() : []; });
|
|
||||||
ipcMain.handle('admin-remove-account', async (event, steamId: string) => { initBackend(); if (backend) await backend.forceRemoveAccount(steamId); return true; });
|
|
||||||
|
|
||||||
ipcMain.handle('switch-account', async (event, loginName: string) => await handleSwitchAccount(loginName));
|
ipcMain.handle('switch-account', async (event, loginName: string) => await handleSwitchAccount(loginName));
|
||||||
ipcMain.handle('open-external', (event, url: string) => shell.openExternal(url));
|
ipcMain.handle('open-external', (event, url: string) => shell.openExternal(url));
|
||||||
|
|
||||||
ipcMain.handle('open-steam-app-login', async () => {
|
ipcMain.handle('open-steam-app-login', async () => {
|
||||||
|
console.log('[SteamClient] Preparing for fresh login...');
|
||||||
await killSteam();
|
await killSteam();
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
// Clear auto-login registry
|
||||||
const clearReg = 'reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "" /f';
|
const clearReg = 'reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "" /f';
|
||||||
await new Promise<void>((res) => exec(clearReg, () => res()));
|
await new Promise<void>((res) => exec(clearReg, () => res()));
|
||||||
} else if (process.platform === 'linux') {
|
} else if (process.platform === 'linux') {
|
||||||
|
// On Linux we can use the steamClient helper to set an empty user
|
||||||
await steamClient.setAutoLoginUser("", undefined, "");
|
await steamClient.setAutoLoginUser("", undefined, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
|
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
|
||||||
exec(command);
|
exec(command);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('open-steam-login', async (event, expectedSteamId: string) => {
|
ipcMain.handle('open-steam-login', async (event, expectedSteamId: string) => {
|
||||||
|
// Use a unique partition per account to prevent session bleeding
|
||||||
const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new';
|
const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new';
|
||||||
const loginSession = session.fromPartition(partitionId);
|
const loginSession = session.fromPartition(partitionId);
|
||||||
if (!expectedSteamId) await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
|
|
||||||
|
// If adding a brand new account, explicitly clear previous trash
|
||||||
|
if (!expectedSteamId) {
|
||||||
|
console.log('[Auth] Clearing session for new account login...');
|
||||||
|
await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have an existing cookie string for this account, pre-inject it
|
||||||
if (expectedSteamId) {
|
if (expectedSteamId) {
|
||||||
const accounts = store.get('accounts') as Account[];
|
const accounts = store.get('accounts') as Account[];
|
||||||
const account = accounts.find(a => a.steamId === expectedSteamId);
|
const account = accounts.find(a => a.steamId === expectedSteamId);
|
||||||
if (account?.steamLoginSecure) {
|
if (account?.steamLoginSecure) {
|
||||||
|
console.log(`[Auth] Pre-injecting existing cookies for ${account.personaName}...`);
|
||||||
const cookiePairs = account.steamLoginSecure.split(';').map(c => c.trim());
|
const cookiePairs = account.steamLoginSecure.split(';').map(c => c.trim());
|
||||||
for (const pair of cookiePairs) {
|
for (const pair of cookiePairs) {
|
||||||
const [name, value] = pair.split('=');
|
const [name, value] = pair.split('=');
|
||||||
if (name && value) {
|
if (name && value) {
|
||||||
try { await loginSession.cookies.set({ url: 'https://steamcommunity.com', domain: 'steamcommunity.com', name, value, path: '/', secure: true, httpOnly: name.includes('Secure') }); } catch (e) {}
|
try {
|
||||||
|
await loginSession.cookies.set({
|
||||||
|
url: 'https://steamcommunity.com',
|
||||||
|
domain: 'steamcommunity.com',
|
||||||
|
name: name,
|
||||||
|
value: value,
|
||||||
|
path: '/',
|
||||||
|
secure: true,
|
||||||
|
httpOnly: name.includes('Secure')
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<boolean>((resolve) => {
|
return new Promise<boolean>((resolve) => {
|
||||||
const loginWindow = new BrowserWindow({
|
const loginWindow = new BrowserWindow({
|
||||||
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Steam',
|
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Steam',
|
||||||
|
|||||||
@@ -19,17 +19,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
loginToServer: () => ipcRenderer.invoke('login-to-server'),
|
loginToServer: () => ipcRenderer.invoke('login-to-server'),
|
||||||
getServerUserInfo: () => ipcRenderer.invoke('get-server-user-info'),
|
getServerUserInfo: () => ipcRenderer.invoke('get-server-user-info'),
|
||||||
syncNow: () => ipcRenderer.invoke('sync-now'),
|
syncNow: () => ipcRenderer.invoke('sync-now'),
|
||||||
scrapeAccount: (steamId: string) => ipcRenderer.invoke('scrape-account', steamId),
|
|
||||||
getCommunityAccounts: () => ipcRenderer.invoke('get-community-accounts'),
|
getCommunityAccounts: () => ipcRenderer.invoke('get-community-accounts'),
|
||||||
getServerUsers: () => ipcRenderer.invoke('get-server-users'),
|
getServerUsers: () => ipcRenderer.invoke('get-server-users'),
|
||||||
|
|
||||||
// Admin API
|
|
||||||
adminGetStats: () => ipcRenderer.invoke('admin-get-stats'),
|
|
||||||
adminGetUsers: () => ipcRenderer.invoke('admin-get-users'),
|
|
||||||
adminDeleteUser: (userId: string) => ipcRenderer.invoke('admin-delete-user', userId),
|
|
||||||
adminGetAccounts: () => ipcRenderer.invoke('admin-get-accounts'),
|
|
||||||
adminRemoveAccount: (steamId: string) => ipcRenderer.invoke('admin-remove-account', steamId),
|
|
||||||
|
|
||||||
onAccountsUpdated: (callback: (accounts: any[]) => void) => {
|
onAccountsUpdated: (callback: (accounts: any[]) => void) => {
|
||||||
const subscription = (_event: IpcRendererEvent, accounts: any[]) => callback(accounts);
|
const subscription = (_event: IpcRendererEvent, accounts: any[]) => callback(accounts);
|
||||||
ipcRenderer.on('accounts-updated', subscription);
|
ipcRenderer.on('accounts-updated', subscription);
|
||||||
|
|||||||
@@ -119,48 +119,4 @@ export class BackendService {
|
|||||||
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
|
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Admin API ---
|
|
||||||
|
|
||||||
public async getAdminStats() {
|
|
||||||
if (!this.token) return null;
|
|
||||||
try {
|
|
||||||
const response = await axios.get(`${this.url}/api/admin/stats`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
} catch (e) { return null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getAdminUsers() {
|
|
||||||
if (!this.token) return [];
|
|
||||||
try {
|
|
||||||
const response = await axios.get(`${this.url}/api/admin/users`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
} catch (e) { return []; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public async deleteUser(userId: string) {
|
|
||||||
if (!this.token) return;
|
|
||||||
try {
|
|
||||||
await axios.delete(`${this.url}/api/admin/users/${userId}`, { headers: this.headers });
|
|
||||||
} catch (e: any) {
|
|
||||||
throw new Error(e.response?.data?.message || 'Failed to delete user');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getAdminAccounts() {
|
|
||||||
if (!this.token) return [];
|
|
||||||
try {
|
|
||||||
const response = await axios.get(`${this.url}/api/admin/accounts`, { headers: this.headers });
|
|
||||||
return response.data;
|
|
||||||
} catch (e) { return []; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public async forceRemoveAccount(steamId: string) {
|
|
||||||
if (!this.token) return;
|
|
||||||
try {
|
|
||||||
await axios.delete(`${this.url}/api/admin/accounts/${steamId}`, { headers: this.headers });
|
|
||||||
} catch (e: any) {
|
|
||||||
throw new Error(e.response?.data?.message || 'Failed to remove account');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Ultimate Ban Tracker</title>
|
<title>frontend</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
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.0",
|
"version": "1.2.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ultimate-ban-tracker-desktop",
|
"name": "ultimate-ban-tracker-desktop",
|
||||||
"version": "1.3.0",
|
"version": "1.2.0",
|
||||||
"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.0",
|
"version": "1.2.0",
|
||||||
"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",
|
||||||
@@ -28,8 +28,7 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist-electron/**/*",
|
"dist-electron/**/*"
|
||||||
"assets-build/**/*"
|
|
||||||
],
|
],
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": [
|
"target": [
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ export interface ServerConfig {
|
|||||||
token?: string;
|
token?: string;
|
||||||
serverSteamId?: string;
|
serverSteamId?: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
isAdmin?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AccountsContextType {
|
interface AccountsContextType {
|
||||||
@@ -49,17 +48,9 @@ interface AccountsContextType {
|
|||||||
updateServerConfig: (config: Partial<ServerConfig>) => Promise<void>;
|
updateServerConfig: (config: Partial<ServerConfig>) => Promise<void>;
|
||||||
loginToServer: () => Promise<void>;
|
loginToServer: () => Promise<void>;
|
||||||
syncNow: () => Promise<void>;
|
syncNow: () => Promise<void>;
|
||||||
scrapeAccount: (steamId: string) => Promise<boolean>;
|
|
||||||
getCommunityAccounts: () => Promise<any[]>;
|
getCommunityAccounts: () => Promise<any[]>;
|
||||||
getServerUsers: () => Promise<any[]>;
|
getServerUsers: () => Promise<any[]>;
|
||||||
refreshAccounts: (showLoading?: boolean) => Promise<void>;
|
refreshAccounts: (showLoading?: boolean) => Promise<void>;
|
||||||
|
|
||||||
// Admin Methods
|
|
||||||
adminGetStats: () => Promise<any>;
|
|
||||||
adminGetUsers: () => Promise<any[]>;
|
|
||||||
adminDeleteUser: (userId: string) => Promise<void>;
|
|
||||||
adminGetAccounts: () => Promise<any[]>;
|
|
||||||
adminRemoveAccount: (steamId: string) => Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AccountsContext = createContext<AccountsContextType | undefined>(undefined);
|
const AccountsContext = createContext<AccountsContextType | undefined>(undefined);
|
||||||
@@ -115,12 +106,6 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrapeAccount = async (steamId: string) => {
|
|
||||||
const success = await (window as any).electronAPI.scrapeAccount(steamId);
|
|
||||||
if (success) await syncNow();
|
|
||||||
return success;
|
|
||||||
};
|
|
||||||
|
|
||||||
const addAccount = async (data: { identifier: string }) => {
|
const addAccount = async (data: { identifier: string }) => {
|
||||||
await (window as any).electronAPI.addAccount(data);
|
await (window as any).electronAPI.addAccount(data);
|
||||||
await refreshAccounts();
|
await refreshAccounts();
|
||||||
@@ -189,19 +174,11 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
|||||||
return await (window as any).electronAPI.getServerUsers();
|
return await (window as any).electronAPI.getServerUsers();
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Admin Methods ---
|
|
||||||
const adminGetStats = async () => (window as any).electronAPI.adminGetStats();
|
|
||||||
const adminGetUsers = async () => (window as any).electronAPI.adminGetUsers();
|
|
||||||
const adminDeleteUser = async (userId: string) => (window as any).electronAPI.adminDeleteUser(userId);
|
|
||||||
const adminGetAccounts = async () => (window as any).electronAPI.adminGetAccounts();
|
|
||||||
const adminRemoveAccount = async (steamId: string) => (window as any).electronAPI.adminRemoveAccount(steamId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountsContext.Provider value={{
|
<AccountsContext.Provider value={{
|
||||||
accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount,
|
accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount,
|
||||||
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
|
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
|
||||||
getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts,
|
getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts
|
||||||
scrapeAccount, adminGetStats, adminGetUsers, adminDeleteUser, adminGetAccounts, adminRemoveAccount
|
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</AccountsContext.Provider>
|
</AccountsContext.Provider>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
DialogActions, CircularProgress, Paper, Chip,
|
DialogActions, CircularProgress, Paper, Chip,
|
||||||
Table, TableBody, TableCell, TableContainer, TableHead, TableRow,
|
Table, TableBody, TableCell, TableContainer, TableHead, TableRow,
|
||||||
Switch, FormControlLabel, Divider, List, ListItem, ListItemText, ListItemSecondaryAction,
|
Switch, FormControlLabel, Divider, List, ListItem, ListItemText, ListItemSecondaryAction,
|
||||||
Select, MenuItem, FormControl, InputLabel, Tabs, Tab
|
Select, MenuItem, FormControl, InputLabel
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import SearchIcon from '@mui/icons-material/Search';
|
import SearchIcon from '@mui/icons-material/Search';
|
||||||
import AddIcon from '@mui/icons-material/Add';
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
@@ -25,116 +25,11 @@ import GppBadIcon from '@mui/icons-material/GppBad';
|
|||||||
import PeopleIcon from '@mui/icons-material/People';
|
import PeopleIcon from '@mui/icons-material/People';
|
||||||
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
|
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
|
||||||
import WorkspacePremiumIcon from '@mui/icons-material/WorkspacePremium';
|
import WorkspacePremiumIcon from '@mui/icons-material/WorkspacePremium';
|
||||||
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
|
|
||||||
import StorageIcon from '@mui/icons-material/Storage';
|
|
||||||
import GroupIcon from '@mui/icons-material/Group';
|
|
||||||
import AccountTreeIcon from '@mui/icons-material/AccountTree';
|
|
||||||
import { useAccounts, type Account } from '../hooks/useAccounts';
|
import { useAccounts, type Account } from '../hooks/useAccounts';
|
||||||
import { useAppTheme } from '../theme/ThemeContext';
|
import { useAppTheme } from '../theme/ThemeContext';
|
||||||
import type { ThemeType } from '../theme/SteamTheme';
|
import type { ThemeType } from '../theme/SteamTheme';
|
||||||
import NebulaBanner from '../components/NebulaBanner';
|
import NebulaBanner from '../components/NebulaBanner';
|
||||||
|
|
||||||
const AdminPanel: React.FC<{ open: boolean, onClose: () => void }> = ({ open, onClose }) => {
|
|
||||||
const { adminGetStats, adminGetUsers, adminDeleteUser, adminGetAccounts, adminRemoveAccount } = useAccounts();
|
|
||||||
const [tab, setTab] = useState(0);
|
|
||||||
const [stats, setStats] = useState<any>(null);
|
|
||||||
const [users, setUsers] = useState<any[]>([]);
|
|
||||||
const [accounts, setAccounts] = useState<any[]>([]);
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
|
|
||||||
const loadData = async () => {
|
|
||||||
setLoading(true);
|
|
||||||
try {
|
|
||||||
if (tab === 0) setStats(await adminGetStats());
|
|
||||||
if (tab === 1) setUsers(await adminGetUsers());
|
|
||||||
if (tab === 2) setAccounts(await adminGetAccounts());
|
|
||||||
} catch (e) {}
|
|
||||||
setLoading(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => { if (open) loadData(); }, [open, tab]);
|
|
||||||
|
|
||||||
const handleDeleteUser = async (id: string) => {
|
|
||||||
if (window.confirm("Wipe this user and all their accounts?")) {
|
|
||||||
await adminDeleteUser(id);
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleForceRemove = async (steamId: string) => {
|
|
||||||
if (window.confirm("Force remove this account from server?")) {
|
|
||||||
await adminRemoveAccount(steamId);
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onClose={onClose} maxWidth="md" fullWidth>
|
|
||||||
<DialogTitle sx={{ bgcolor: 'background.paper', color: 'text.primary', display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
||||||
<AdminPanelSettingsIcon color="primary" /> Server Administration
|
|
||||||
</DialogTitle>
|
|
||||||
<Tabs value={tab} onChange={(_, v) => setTab(v)} sx={{ bgcolor: 'background.paper', borderBottom: 1, borderColor: 'divider' }}>
|
|
||||||
<Tab icon={<StorageIcon />} label="Overview" />
|
|
||||||
<Tab icon={<GroupIcon />} label="Users" />
|
|
||||||
<Tab icon={<AccountTreeIcon />} label="Global Accounts" />
|
|
||||||
</Tabs>
|
|
||||||
<DialogContent sx={{ bgcolor: 'background.paper', minHeight: 400, pt: 2 }}>
|
|
||||||
{loading ? <Box sx={{ display: 'flex', justifyContent: 'center', mt: 10 }}><CircularProgress /></Box> : (
|
|
||||||
<>
|
|
||||||
{tab === 0 && stats && (
|
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 2, mt: 2 }}>
|
|
||||||
{[
|
|
||||||
{ label: 'Total Users', value: stats.users },
|
|
||||||
{ label: 'Total Accounts', value: stats.accounts },
|
|
||||||
{ label: 'Active Cooldowns', value: stats.activeCooldowns }
|
|
||||||
].map((s) => (
|
|
||||||
<Paper key={s.label} sx={{ p: 3, textAlign: 'center', bgcolor: 'rgba(0,0,0,0.1)' }}>
|
|
||||||
<Typography variant="h4" color="primary" sx={{ fontWeight: 'bold' }}>{s.value}</Typography>
|
|
||||||
<Typography variant="caption" color="textSecondary">{s.label}</Typography>
|
|
||||||
</Paper>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
{tab === 1 && (
|
|
||||||
<List>
|
|
||||||
{users.map(u => (
|
|
||||||
<ListItem key={u._id} divider sx={{ borderColor: 'divider' }}>
|
|
||||||
<Avatar src={u.avatar} sx={{ mr: 2 }} />
|
|
||||||
<ListItemText primary={u.personaName} secondary={u.steamId} primaryTypographyProps={{ color: 'text.primary' }} />
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<IconButton color="error" onClick={() => handleDeleteUser(u._id)}><DeleteIcon /></IconButton>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
)}
|
|
||||||
{tab === 2 && (
|
|
||||||
<List>
|
|
||||||
{accounts.map(a => (
|
|
||||||
<ListItem key={a.steamId} divider sx={{ borderColor: 'divider' }}>
|
|
||||||
<Avatar src={a.avatar} variant="square" sx={{ mr: 2 }} />
|
|
||||||
<ListItemText
|
|
||||||
primary={a.personaName}
|
|
||||||
secondary={`Owned by: ${a.addedBy?.personaName || 'Unknown'} (${a.steamId})`}
|
|
||||||
primaryTypographyProps={{ color: 'text.primary' }}
|
|
||||||
/>
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<IconButton color="error" onClick={() => handleForceRemove(a.steamId)}><DeleteIcon /></IconButton>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions sx={{ bgcolor: 'background.paper', p: 2 }}>
|
|
||||||
<Button onClick={onClose} variant="contained" color="inherit">Close Panel</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Dashboard: React.FC = () => {
|
const Dashboard: React.FC = () => {
|
||||||
const { currentTheme, setTheme } = useAppTheme();
|
const { currentTheme, setTheme } = useAppTheme();
|
||||||
const {
|
const {
|
||||||
@@ -144,7 +39,6 @@ const Dashboard: React.FC = () => {
|
|||||||
|
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||||
const [isAdminPanelOpen, setIsAdminPanelOpen] = useState(false);
|
|
||||||
const [serverUrl, setServerUrl] = useState('');
|
const [serverUrl, setServerUrl] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -176,15 +70,6 @@ const Dashboard: React.FC = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, WebkitAppRegion: 'no-drag' } as any}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, WebkitAppRegion: 'no-drag' } as any}>
|
||||||
{/* Admin Button - Only visible if isAdmin is true */}
|
|
||||||
{serverConfig?.isAdmin && (
|
|
||||||
<Tooltip title="Open Admin Panel">
|
|
||||||
<IconButton color="primary" onClick={() => setIsAdminPanelOpen(true)}>
|
|
||||||
<AdminPanelSettingsIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', mr: 1 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', mr: 1 }}>
|
||||||
{isSyncing ? (
|
{isSyncing ? (
|
||||||
<CircularProgress size={16} sx={{ color: 'primary.main', mr: 1 }} />
|
<CircularProgress size={16} sx={{ color: 'primary.main', mr: 1 }} />
|
||||||
@@ -361,9 +246,6 @@ const Dashboard: React.FC = () => {
|
|||||||
<Button onClick={() => setIsSettingsOpen(false)} color="inherit" variant="contained">Done</Button>
|
<Button onClick={() => setIsSettingsOpen(false)} color="inherit" variant="contained">Done</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{/* Admin Panel */}
|
|
||||||
<AdminPanel open={isAdminPanelOpen} onClose={() => setIsAdminPanelOpen(false)} />
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -376,12 +258,11 @@ const AccountRow: React.FC<{
|
|||||||
onSwitch: (login: string) => void,
|
onSwitch: (login: string) => void,
|
||||||
onAuth: () => void
|
onAuth: () => void
|
||||||
}> = ({ account, onDelete, onSwitch, onAuth }) => {
|
}> = ({ account, onDelete, onSwitch, onAuth }) => {
|
||||||
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig, scrapeAccount } = useAccounts();
|
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig } = useAccounts();
|
||||||
const [timeLeft, setTimeLeft] = useState<string | null>(null);
|
const [timeLeft, setTimeLeft] = useState<string | null>(null);
|
||||||
const [isShareOpen, setIsShareOpen] = useState(false);
|
const [isShareOpen, setIsShareOpen] = useState(false);
|
||||||
const [targetUserId, setTargetUserId] = useState('');
|
const [targetUserId, setTargetUserId] = useState('');
|
||||||
const [isSharing, setIsSharing] = useState(false);
|
const [isSharing, setIsSharing] = useState(false);
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
||||||
const [serverUsers, setServerUsers] = useState<any[]>([]);
|
const [serverUsers, setServerUsers] = useState<any[]>([]);
|
||||||
|
|
||||||
const cooldownDate = account?.cooldownExpiresAt ? new Date(account.cooldownExpiresAt) : null;
|
const cooldownDate = account?.cooldownExpiresAt ? new Date(account.cooldownExpiresAt) : null;
|
||||||
@@ -405,12 +286,6 @@ const AccountRow: React.FC<{
|
|||||||
const [imgSrc, setImgSrc] = useState(avatarSrc);
|
const [imgSrc, setImgSrc] = useState(avatarSrc);
|
||||||
useEffect(() => { setImgSrc(avatarSrc); }, [avatarSrc]);
|
useEffect(() => { setImgSrc(avatarSrc); }, [avatarSrc]);
|
||||||
|
|
||||||
const handleRefresh = async () => {
|
|
||||||
setIsRefreshing(true);
|
|
||||||
await scrapeAccount(account.steamId);
|
|
||||||
setIsRefreshing(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleOpenShare = async () => {
|
const handleOpenShare = async () => {
|
||||||
setIsShareOpen(true);
|
setIsShareOpen(true);
|
||||||
try {
|
try {
|
||||||
@@ -419,7 +294,8 @@ const AccountRow: React.FC<{
|
|||||||
(window as any).electronAPI.getServerUserInfo()
|
(window as any).electronAPI.getServerUserInfo()
|
||||||
]);
|
]);
|
||||||
const filtered = (Array.isArray(users) ? users : []).filter(u =>
|
const filtered = (Array.isArray(users) ? users : []).filter(u =>
|
||||||
u.steamId !== selfInfo.steamId && u.steamId !== account.steamId
|
u.steamId !== selfInfo.steamId &&
|
||||||
|
u.steamId !== account.steamId
|
||||||
);
|
);
|
||||||
setServerUsers(filtered);
|
setServerUsers(filtered);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
@@ -529,12 +405,7 @@ const AccountRow: React.FC<{
|
|||||||
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
|
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
{account.steamLoginSecure && !account.authError && (
|
{account.steamLoginSecure && !account.authError && (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
||||||
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem' }}>TRACKING</Typography>
|
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem' }}>TRACKING</Typography>
|
||||||
<IconButton size="small" onClick={handleRefresh} disabled={isRefreshing} sx={{ p: 0.2, color: 'text.secondary', '&:hover': { color: 'primary.main' } }}>
|
|
||||||
{isRefreshing ? <CircularProgress size={10} color="inherit" /> : <SyncIcon sx={{ fontSize: 12 }} />}
|
|
||||||
</IconButton>
|
|
||||||
</Box>
|
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
Reference in New Issue
Block a user