feat/makepkg + project structure #12
19
PKGBUILD
19
PKGBUILD
@@ -1,7 +1,7 @@
|
||||
# Maintainer: Nils Pukropp <nils@narl.io>
|
||||
pkgname=ultimate-ban-tracker
|
||||
pkgver=1.3.3
|
||||
pkgrel=5
|
||||
pkgrel=6
|
||||
pkgdesc="Professional Steam Account Manager & Ban Tracker"
|
||||
arch=('x86_64')
|
||||
url="https://narl.io"
|
||||
@@ -14,18 +14,21 @@ sha256sums=('SKIP')
|
||||
build() {
|
||||
cd "${srcdir}/ultimate-ban-tracker"
|
||||
|
||||
# Clean previous build state if any
|
||||
rm -rf frontend/node_modules
|
||||
# Clean state
|
||||
rm -rf frontend/node_modules frontend/package-lock.json
|
||||
|
||||
cd frontend
|
||||
# Fresh install with all dependencies
|
||||
npm install
|
||||
|
||||
# Force fresh install and handle electron's postinstall quirks
|
||||
npm install --omit=optional
|
||||
|
||||
# Ensure icon is converted
|
||||
# Ensure icon is converted (IMv7 compatible)
|
||||
if command -v magick &> /dev/null; then
|
||||
magick -background none -size 512x512 assets-build/icon.svg assets-build/icon.png
|
||||
else
|
||||
convert -background none -size 512x512 assets-build/icon.svg assets-build/icon.png
|
||||
fi
|
||||
|
||||
# Build production
|
||||
# Build production binary for linux specifically
|
||||
npm run electron:build -- --linux
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ const backend_1 = require("./services/backend");
|
||||
// Reliable isDev check
|
||||
const isDev = !electron_1.app.isPackaged;
|
||||
electron_1.app.name = "Ultimate Ban Tracker";
|
||||
// Force Wayland/Ozone support if on Linux
|
||||
if (process.platform === 'linux') {
|
||||
electron_1.app.commandLine.appendSwitch('enable-features', 'UseOzonePlatform');
|
||||
electron_1.app.commandLine.appendSwitch('ozone-platform', 'wayland');
|
||||
}
|
||||
// Load environment variables
|
||||
dotenv_1.default.config({ path: path_1.default.join(electron_1.app.getAppPath(), '..', '.env') });
|
||||
// --- App State ---
|
||||
@@ -60,55 +65,67 @@ const initBackend = () => {
|
||||
};
|
||||
// --- System Tray ---
|
||||
const createTray = () => {
|
||||
// Try to find the icon in various standard locations
|
||||
const possiblePaths = [
|
||||
path_1.default.join(__dirname, '..', 'assets-build'), // Dev
|
||||
path_1.default.join(process.resourcesPath, 'assets-build'), // Packaged (External)
|
||||
path_1.default.join(electron_1.app.getAppPath(), 'dist', 'assets-build'), // Packaged (Internal dist)
|
||||
path_1.default.join(electron_1.app.getAppPath(), 'assets-build') // Packaged (Internal root)
|
||||
console.log('[Tray] Initializing...');
|
||||
// 1. Determine source path (handling both Dev and Prod/ASAR)
|
||||
let sourceIconPath = '';
|
||||
const possibleSourcePaths = [
|
||||
path_1.default.join(electron_1.app.getAppPath(), 'assets-build', 'icon.png'), // Priority 1: ASAR/Internal
|
||||
path_1.default.join(__dirname, '..', 'assets-build', 'icon.png'), // Priority 2: Dev
|
||||
path_1.default.join(process.resourcesPath, 'assets-build', 'icon.png') // Priority 3: External resources
|
||||
];
|
||||
let assetsDir = '';
|
||||
for (const p of possiblePaths) {
|
||||
for (const p of possibleSourcePaths) {
|
||||
if (fs_1.default.existsSync(p)) {
|
||||
assetsDir = p;
|
||||
sourceIconPath = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const possibleIcons = ['icon.png', 'icon.svg'];
|
||||
let iconPath = '';
|
||||
if (assetsDir) {
|
||||
for (const name of possibleIcons) {
|
||||
const fullPath = path_1.default.join(assetsDir, name);
|
||||
if (fs_1.default.existsSync(fullPath)) {
|
||||
iconPath = fullPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`[Tray] Resolved assets directory: ${assetsDir || 'NOT FOUND'}`);
|
||||
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
||||
if (!iconPath) {
|
||||
console.warn(`[Tray] FAILED: No valid icon found in searched paths.`);
|
||||
return;
|
||||
}
|
||||
if (!sourceIconPath) {
|
||||
console.warn('[Tray] FAILED: No source icon found. Using empty fallback.');
|
||||
try {
|
||||
const icon = electron_1.nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||
tray = new electron_1.Tray(icon);
|
||||
tray.setToolTip('Ultimate Ban Tracker');
|
||||
tray.on('click', () => { if (mainWindow) {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
} });
|
||||
// Load initial themed icon
|
||||
const config = store.get('serverConfig');
|
||||
if (config?.theme) {
|
||||
setAppIcon(config.theme);
|
||||
}
|
||||
else {
|
||||
updateTrayMenu(); // Fallback to refresh menu
|
||||
}
|
||||
tray = new electron_1.Tray(electron_1.nativeImage.createEmpty());
|
||||
}
|
||||
catch (e) { }
|
||||
return;
|
||||
}
|
||||
// 2. LINUX FIX: Extract icon from ASAR to real filesystem
|
||||
let finalIconPath = sourceIconPath;
|
||||
if (process.platform === 'linux') {
|
||||
try {
|
||||
const tempIconPath = path_1.default.join(electron_1.app.getPath('temp'), 'ultimate-ban-tracker-tray.png');
|
||||
try {
|
||||
fs_1.default.unlinkSync(tempIconPath);
|
||||
}
|
||||
catch (e) { }
|
||||
console.log(`[Tray] Extracting icon to: ${tempIconPath}`);
|
||||
fs_1.default.copyFileSync(sourceIconPath, tempIconPath);
|
||||
finalIconPath = tempIconPath;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Tray] Failed to extract icon: ${e.message}`);
|
||||
}
|
||||
}
|
||||
try {
|
||||
console.log(`[Tray] Creating tray with icon: ${finalIconPath}`);
|
||||
const icon = electron_1.nativeImage.createFromPath(finalIconPath).resize({ width: 16, height: 16 });
|
||||
tray = new electron_1.Tray(icon);
|
||||
tray.setToolTip('Ultimate Ban Tracker');
|
||||
if (process.platform === 'linux') {
|
||||
tray.setIgnoreMouseEvents(false);
|
||||
}
|
||||
tray.on('click', () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
|
||||
}
|
||||
});
|
||||
updateTrayMenu();
|
||||
const config = store.get('serverConfig');
|
||||
if (config?.theme)
|
||||
setAppIcon(config.theme);
|
||||
console.log(`[Tray] Successfully initialized`);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Tray] Error: ${e.message}`);
|
||||
}
|
||||
};
|
||||
const updateTrayMenu = () => {
|
||||
if (!tray)
|
||||
@@ -124,30 +141,33 @@ const updateTrayMenu = () => {
|
||||
label: `${acc.personaName} ${acc.loginName ? `(${acc.loginName})` : ''}`,
|
||||
enabled: !!acc.loginName,
|
||||
click: () => handleSwitchAccount(acc.loginName)
|
||||
})) : [{ label: 'No accounts found', enabled: false }]
|
||||
})) : [{ label: 'No accounts tracked', enabled: false }]
|
||||
},
|
||||
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Show Dashboard', click: () => { if (mainWindow)
|
||||
mainWindow.show(); } },
|
||||
{ label: 'Quit', click: () => { electron_1.app.isQuitting = true; electron_1.app.quit(); } }
|
||||
{ label: 'Show Dashboard', click: () => { if (mainWindow) {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
} } },
|
||||
{ label: 'Quit', click: () => {
|
||||
electron_1.app.isQuitting = true;
|
||||
if (tray)
|
||||
tray.destroy();
|
||||
electron_1.app.quit();
|
||||
} }
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
};
|
||||
const setAppIcon = (themeName = 'steam') => {
|
||||
const assetsDir = path_1.default.join(__dirname, '..', 'assets-build', 'icons');
|
||||
const assetsDir = path_1.default.join(electron_1.app.getAppPath(), 'assets-build', 'icons');
|
||||
const iconPath = path_1.default.join(assetsDir, `${themeName}.svg`);
|
||||
if (!fs_1.default.existsSync(iconPath))
|
||||
return;
|
||||
const icon = electron_1.nativeImage.createFromPath(iconPath);
|
||||
// Update Tray
|
||||
if (tray) {
|
||||
if (tray)
|
||||
tray.setImage(icon.resize({ width: 16, height: 16 }));
|
||||
}
|
||||
// Update Main Window
|
||||
if (mainWindow) {
|
||||
if (mainWindow)
|
||||
mainWindow.setIcon(icon);
|
||||
}
|
||||
};
|
||||
// --- Steam Logic ---
|
||||
const killSteam = async () => {
|
||||
@@ -164,13 +184,23 @@ const handleSwitchAccount = async (loginName) => {
|
||||
if (!loginName)
|
||||
return false;
|
||||
try {
|
||||
await killSteam();
|
||||
const accounts = store.get('accounts');
|
||||
const account = accounts.find(a => a.loginName === loginName);
|
||||
if (account && !account._id.startsWith('shared_')) {
|
||||
const freshConfig = steam_client_1.steamClient.extractAccountConfig(loginName);
|
||||
if (freshConfig) {
|
||||
account.loginConfig = freshConfig;
|
||||
account.sessionUpdatedAt = new Date().toISOString();
|
||||
if (backend)
|
||||
await backend.shareAccount(account);
|
||||
store.set('accounts', accounts);
|
||||
}
|
||||
}
|
||||
await killSteam();
|
||||
if (process.platform === 'win32') {
|
||||
const regCommand = `reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "${loginName}" /f`;
|
||||
const rememberCommand = `reg add "HKCU\\Software\\Valve\\Steam" /v RememberPassword /t REG_DWORD /d 1 /f`;
|
||||
await new Promise((res, rej) => (0, child_process_1.exec)(`${regCommand} && ${rememberCommand}`, (e) => e ? rej(e) : res()));
|
||||
const regBase = 'reg add "HKCU\\Software\\Valve\\Steam"';
|
||||
const commands = [`${regBase} /v AutoLoginUser /t REG_SZ /d "${loginName}" /f`, `${regBase} /v RememberPassword /t REG_DWORD /d 1 /f`, `${regBase} /v AlreadyLoggedIn /t REG_DWORD /d 1 /f`, `${regBase} /v WantsOfflineMode /t REG_DWORD /d 0 /f`];
|
||||
await new Promise((res, rej) => (0, child_process_1.exec)(commands.join(' && '), (e) => e ? rej(e) : res()));
|
||||
if (account && account.loginConfig)
|
||||
steam_client_1.steamClient.injectAccountConfig(loginName, account.loginConfig);
|
||||
}
|
||||
@@ -219,27 +249,21 @@ const scrapeAccountData = async (account) => {
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof scraper_1.SteamAuthError) {
|
||||
if (e instanceof scraper_1.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_'))
|
||||
await backend.shareAccount(account);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Scraper] Failed to scrape ${account.personaName}:`, e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// --- Sync Worker ---
|
||||
const syncAccounts = async (isManual = false) => {
|
||||
console.log(`[Sync] Phase 1: Pulling from server...`);
|
||||
console.log(`[Sync] Starting ${isManual ? 'MANUAL' : 'BACKGROUND'} phase 1 (Server Pull)...`);
|
||||
initBackend();
|
||||
let accounts = store.get('accounts');
|
||||
let hasChanges = false;
|
||||
@@ -261,16 +285,10 @@ const syncAccounts = async (isManual = false) => {
|
||||
hasChanges = true;
|
||||
}
|
||||
else {
|
||||
const sDate = s.sessionUpdatedAt ? new Date(s.sessionUpdatedAt) : new Date(0);
|
||||
const lDate = exists.sessionUpdatedAt ? new Date(exists.sessionUpdatedAt) : new Date(0);
|
||||
// 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)
|
||||
@@ -285,7 +303,6 @@ const syncAccounts = async (isManual = false) => {
|
||||
exists.sessionUpdatedAt = s.sessionUpdatedAt;
|
||||
hasChanges = true;
|
||||
}
|
||||
// 2. Metadata Sync (Pull) - Always "Newest Wins"
|
||||
const sMetaDate = s.lastMetadataCheck ? new Date(s.lastMetadataCheck) : new Date(0);
|
||||
const lMetaDate = exists.lastBanCheck ? new Date(exists.lastBanCheck) : new Date(0);
|
||||
if (sMetaDate > lMetaDate) {
|
||||
@@ -297,7 +314,6 @@ const syncAccounts = async (isManual = false) => {
|
||||
exists.lastBanCheck = s.lastMetadataCheck;
|
||||
hasChanges = true;
|
||||
}
|
||||
// Cooldown Sync (Pull)
|
||||
const sScrapeDate = s.lastScrapeTime ? new Date(s.lastScrapeTime) : new Date(0);
|
||||
const lScrapeDate = exists.lastScrapeTime ? new Date(exists.lastScrapeTime) : new Date(0);
|
||||
if (sScrapeDate > lScrapeDate) {
|
||||
@@ -312,7 +328,9 @@ const syncAccounts = async (isManual = false) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
catch (e) {
|
||||
console.error('[Sync] Pull failed:', e);
|
||||
}
|
||||
}
|
||||
if (hasChanges) {
|
||||
store.set('accounts', accounts);
|
||||
@@ -320,9 +338,8 @@ const syncAccounts = async (isManual = false) => {
|
||||
mainWindow.webContents.send('accounts-updated', accounts);
|
||||
updateTrayMenu();
|
||||
}
|
||||
// Phase 2: Background Scrapes
|
||||
const runScrapes = async () => {
|
||||
console.log(`[Sync] Phase 2: Starting background checks for ${accounts.length} accounts...`);
|
||||
console.log(`[Sync] Starting phase 2 (Scrapes) for ${accounts.length} accounts...`);
|
||||
const currentAccounts = [...store.get('accounts')];
|
||||
let scrapeChanges = false;
|
||||
for (const account of currentAccounts) {
|
||||
@@ -349,87 +366,29 @@ const syncAccounts = async (isManual = false) => {
|
||||
mainWindow.webContents.send('accounts-updated', currentAccounts);
|
||||
updateTrayMenu();
|
||||
}
|
||||
console.log('[Sync] Sync cycle finished.');
|
||||
console.log('[Sync] All phases complete.');
|
||||
};
|
||||
if (isManual)
|
||||
await runScrapes();
|
||||
else
|
||||
runScrapes();
|
||||
};
|
||||
const scheduleNextSync = () => {
|
||||
setTimeout(async () => { await syncAccounts(false); scheduleNextSync(); }, isDev ? 300000 : 1800000);
|
||||
};
|
||||
// --- Discovery ---
|
||||
const addingAccounts = new Set();
|
||||
const handleLocalAccountsFound = async (localAccounts) => {
|
||||
const currentAccounts = store.get('accounts');
|
||||
let hasChanges = false;
|
||||
for (const local of localAccounts) {
|
||||
if (addingAccounts.has(local.steamId))
|
||||
continue;
|
||||
const exists = currentAccounts.find(a => a.steamId === local.steamId);
|
||||
if (exists) {
|
||||
if (!exists.loginName && local.accountName) {
|
||||
exists.loginName = local.accountName;
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
addingAccounts.add(local.steamId);
|
||||
try {
|
||||
const profile = await (0, steam_web_1.fetchProfileData)(local.steamId);
|
||||
const bans = await (0, steam_web_1.scrapeBanStatus)(profile.profileUrl);
|
||||
const localPath = await downloadAvatar(profile.steamId, profile.avatar);
|
||||
// Wait and retry snagging the config (Steam takes time to write it)
|
||||
let loginConfig = undefined;
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await new Promise(r => setTimeout(r, 2000));
|
||||
loginConfig = steam_client_1.steamClient.extractAccountConfig(local.accountName);
|
||||
if (loginConfig)
|
||||
break;
|
||||
}
|
||||
currentAccounts.push({
|
||||
_id: Date.now().toString() + Math.random().toString().slice(2, 5),
|
||||
steamId: local.steamId, personaName: profile.personaName || local.accountName,
|
||||
loginName: local.accountName, autoCheckCooldown: false, avatar: profile.avatar,
|
||||
localAvatar: localPath, profileUrl: profile.profileUrl,
|
||||
loginConfig, sessionUpdatedAt: loginConfig ? new Date().toISOString() : undefined,
|
||||
status: (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none',
|
||||
vacBanned: bans.vacBanned, gameBans: bans.gameBans, lastBanCheck: new Date().toISOString()
|
||||
});
|
||||
hasChanges = true;
|
||||
}
|
||||
catch (e) { }
|
||||
addingAccounts.delete(local.steamId);
|
||||
}
|
||||
}
|
||||
if (hasChanges) {
|
||||
store.set('accounts', currentAccounts);
|
||||
if (mainWindow)
|
||||
mainWindow.webContents.send('accounts-updated', currentAccounts);
|
||||
updateTrayMenu();
|
||||
}
|
||||
};
|
||||
// --- Main Window ---
|
||||
function createWindow() {
|
||||
mainWindow = new electron_1.BrowserWindow({
|
||||
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
||||
webPreferences: { preload: path_1.default.join(__dirname, 'preload.js'), nodeIntegration: false, contextIsolation: true }
|
||||
});
|
||||
mainWindow.setMenu(null);
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!electron_1.app.isQuitting) {
|
||||
event.preventDefault();
|
||||
mainWindow?.hide();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (isDev)
|
||||
mainWindow.loadURL('http://localhost:5173');
|
||||
else
|
||||
mainWindow.loadFile(path_1.default.join(__dirname, '..', 'dist', 'index.html'));
|
||||
const scheduleNextSync = () => { setTimeout(async () => { await syncAccounts(false); scheduleNextSync(); }, isDev ? 300000 : 1800000); };
|
||||
// --- Single Instance & Window ---
|
||||
const gotTheLock = electron_1.app.requestSingleInstanceLock();
|
||||
if (!gotTheLock) {
|
||||
electron_1.app.quit();
|
||||
}
|
||||
electron_1.app.whenReady().then(() => {
|
||||
else {
|
||||
electron_1.app.on('second-instance', () => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized())
|
||||
mainWindow.restore();
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
}
|
||||
});
|
||||
electron_1.app.whenReady().then(() => {
|
||||
electron_1.protocol.handle('steam-resource', (request) => {
|
||||
let rawPath = decodeURIComponent(request.url.replace('steam-resource://', ''));
|
||||
if (process.platform !== 'win32' && !rawPath.startsWith('/'))
|
||||
@@ -450,13 +409,50 @@ electron_1.app.whenReady().then(() => {
|
||||
setTimeout(() => syncAccounts(false), 5000);
|
||||
scheduleNextSync();
|
||||
steam_client_1.steamClient.startWatching(handleLocalAccountsFound);
|
||||
});
|
||||
}
|
||||
function createWindow() {
|
||||
mainWindow = new electron_1.BrowserWindow({
|
||||
width: 1280, height: 800, title: "Ultimate Ban Tracker", backgroundColor: '#171a21', autoHideMenuBar: true,
|
||||
webPreferences: { preload: path_1.default.join(__dirname, 'preload.js'), nodeIntegration: false, contextIsolation: true }
|
||||
});
|
||||
mainWindow.setMenu(null);
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!isQuitting) {
|
||||
event.preventDefault();
|
||||
mainWindow?.hide();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (isDev)
|
||||
mainWindow.loadURL('http://localhost:5173');
|
||||
else
|
||||
mainWindow.loadFile(path_1.default.join(__dirname, '..', 'dist', 'index.html'));
|
||||
}
|
||||
electron_1.app.on('before-quit', () => {
|
||||
console.log('[App] Preparing to quit...');
|
||||
electron_1.app.isQuitting = true;
|
||||
if (tray)
|
||||
tray.destroy();
|
||||
});
|
||||
electron_1.app.on('window-all-closed', () => { if (process.platform !== 'darwin' && electron_1.app.isQuitting)
|
||||
electron_1.app.quit(); });
|
||||
electron_1.app.on('activate', () => { if (electron_1.BrowserWindow.getAllWindows().length === 0)
|
||||
createWindow();
|
||||
electron_1.app.on('activate', () => { if (electron_1.BrowserWindow.getAllWindows().length === 0 && gotTheLock) { /* Handled */ }
|
||||
else
|
||||
mainWindow?.show(); });
|
||||
// Handle terminal termination (Ctrl+C / SIGTERM)
|
||||
const handleSignal = (signal) => {
|
||||
console.log(`[App] Received ${signal}`);
|
||||
if (!electron_1.app.isQuitting && mainWindow) {
|
||||
console.log(`[App] Hiding window instead of quitting due to ${signal}`);
|
||||
mainWindow.hide();
|
||||
}
|
||||
else if (electron_1.app.isQuitting) {
|
||||
electron_1.app.quit();
|
||||
}
|
||||
};
|
||||
process.on('SIGINT', () => handleSignal('SIGINT'));
|
||||
process.on('SIGTERM', () => handleSignal('SIGTERM'));
|
||||
// --- IPC Handlers ---
|
||||
electron_1.ipcMain.handle('get-accounts', () => store.get('accounts'));
|
||||
electron_1.ipcMain.handle('get-server-config', () => store.get('serverConfig'));
|
||||
@@ -473,10 +469,7 @@ electron_1.ipcMain.handle('login-to-server', async () => {
|
||||
if (!config.url)
|
||||
return false;
|
||||
return new Promise((resolve) => {
|
||||
const authWindow = new electron_1.BrowserWindow({
|
||||
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Server',
|
||||
webPreferences: { nodeIntegration: false, contextIsolation: true }
|
||||
});
|
||||
const authWindow = new electron_1.BrowserWindow({ width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Server', webPreferences: { nodeIntegration: false, contextIsolation: true } });
|
||||
authWindow.loadURL(`${config.url}/auth/steam`);
|
||||
let captured = false;
|
||||
const saveServerAuth = (token) => {
|
||||
@@ -505,13 +498,11 @@ electron_1.ipcMain.handle('login-to-server', async () => {
|
||||
saveServerAuth(authToken);
|
||||
callback({ cancel: false });
|
||||
});
|
||||
authWindow.on('page-title-updated', (event, title) => {
|
||||
if (title.includes('AUTH_TOKEN:')) {
|
||||
authWindow.on('page-title-updated', (event, title) => { if (title.includes('AUTH_TOKEN:')) {
|
||||
const token = title.split('AUTH_TOKEN:')[1];
|
||||
if (token)
|
||||
saveServerAuth(token);
|
||||
}
|
||||
});
|
||||
} });
|
||||
authWindow.on('closed', () => resolve(false));
|
||||
});
|
||||
});
|
||||
@@ -559,12 +550,7 @@ electron_1.ipcMain.handle('add-account', async (event, { identifier }) => {
|
||||
const bans = await (0, steam_web_1.scrapeBanStatus)(profile.profileUrl);
|
||||
const localAvatar = await downloadAvatar(profile.steamId, profile.avatar);
|
||||
const accounts = store.get('accounts');
|
||||
const newAccount = {
|
||||
_id: Date.now().toString(), steamId: profile.steamId, personaName: profile.personaName,
|
||||
loginName: '', avatar: profile.avatar, localAvatar: localAvatar, profileUrl: profile.profileUrl,
|
||||
autoCheckCooldown: false, vacBanned: bans.vacBanned, gameBans: bans.gameBans,
|
||||
status: (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none', lastBanCheck: new Date().toISOString()
|
||||
};
|
||||
const newAccount = { _id: Date.now().toString(), steamId: profile.steamId, personaName: profile.personaName, loginName: '', avatar: profile.avatar, localAvatar: localAvatar, profileUrl: profile.profileUrl, autoCheckCooldown: false, vacBanned: bans.vacBanned, gameBans: bans.gameBans, status: (bans.vacBanned || bans.gameBans > 0) ? 'banned' : 'none', lastBanCheck: new Date().toISOString() };
|
||||
store.set('accounts', [...accounts, newAccount]);
|
||||
updateTrayMenu();
|
||||
return newAccount;
|
||||
@@ -601,21 +587,12 @@ electron_1.ipcMain.handle('share-account-with-user', async (event, steamId, targ
|
||||
}
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
electron_1.ipcMain.handle('revoke-account-access', async (event, steamId, targetSteamId) => {
|
||||
initBackend();
|
||||
if (backend)
|
||||
return await backend.revokeAccess(steamId, targetSteamId);
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
electron_1.ipcMain.handle('revoke-all-account-access', async (event, steamId) => {
|
||||
initBackend();
|
||||
if (backend)
|
||||
return await backend.revokeAllAccess(steamId);
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
electron_1.ipcMain.handle('revoke-account-access', async (event, steamId, targetSteamId) => { initBackend(); if (backend)
|
||||
return await backend.revokeAccess(steamId, targetSteamId); throw new Error('Backend not configured'); });
|
||||
electron_1.ipcMain.handle('revoke-all-account-access', async (event, steamId) => { initBackend(); if (backend)
|
||||
return await backend.revokeAllAccess(steamId); throw new Error('Backend not configured'); });
|
||||
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() : []; });
|
||||
// --- 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)
|
||||
@@ -624,15 +601,11 @@ electron_1.ipcMain.handle('admin-get-accounts', async () => { initBackend(); ret
|
||||
electron_1.ipcMain.handle('admin-remove-account', async (event, steamId) => { initBackend(); if (backend)
|
||||
await backend.forceRemoveAccount(steamId); return true; });
|
||||
electron_1.ipcMain.handle('force-sync', async () => { await syncAccounts(true); return true; });
|
||||
electron_1.ipcMain.handle('update-app-icon', (event, themeName) => {
|
||||
setAppIcon(themeName);
|
||||
return true;
|
||||
});
|
||||
electron_1.ipcMain.handle('update-app-icon', (event, themeName) => { setAppIcon(themeName); return true; });
|
||||
electron_1.ipcMain.handle('switch-account', async (event, loginName) => {
|
||||
if (!loginName)
|
||||
return false;
|
||||
try {
|
||||
// PROACTIVE SYNC: Try to snag the freshest token before we kill Steam
|
||||
const accounts = store.get('accounts');
|
||||
const account = accounts.find(a => a.loginName === loginName);
|
||||
if (account && !account._id.startsWith('shared_')) {
|
||||
@@ -648,12 +621,7 @@ electron_1.ipcMain.handle('switch-account', async (event, loginName) => {
|
||||
await killSteam();
|
||||
if (process.platform === 'win32') {
|
||||
const regBase = 'reg add "HKCU\\Software\\Valve\\Steam"';
|
||||
const commands = [
|
||||
`${regBase} /v AutoLoginUser /t REG_SZ /d "${loginName}" /f`,
|
||||
`${regBase} /v RememberPassword /t REG_DWORD /d 1 /f`,
|
||||
`${regBase} /v AlreadyLoggedIn /t REG_DWORD /d 1 /f`,
|
||||
`${regBase} /v WantsOfflineMode /t REG_DWORD /d 0 /f`
|
||||
];
|
||||
const commands = [`${regBase} /v AutoLoginUser /t REG_SZ /d "${loginName}" /f`, `${regBase} /v RememberPassword /t REG_DWORD /d 1 /f`, `${regBase} /v AlreadyLoggedIn /t REG_DWORD /d 1 /f`, `${regBase} /v WantsOfflineMode /t REG_DWORD /d 0 /f`];
|
||||
await new Promise((res, rej) => (0, child_process_1.exec)(commands.join(' && '), (e) => e ? rej(e) : res()));
|
||||
if (account && account.loginConfig)
|
||||
steam_client_1.steamClient.injectAccountConfig(loginName, account.loginConfig);
|
||||
@@ -704,10 +672,7 @@ electron_1.ipcMain.handle('open-steam-login', async (event, expectedSteamId) =>
|
||||
}
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const loginWindow = new electron_1.BrowserWindow({
|
||||
width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Steam',
|
||||
webPreferences: { nodeIntegration: false, contextIsolation: true, partition: partitionId }
|
||||
});
|
||||
const loginWindow = new electron_1.BrowserWindow({ width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Steam', webPreferences: { nodeIntegration: false, contextIsolation: true, partition: partitionId } });
|
||||
loginWindow.loadURL('https://steamcommunity.com/login/home/?goto=my/gcpd/730');
|
||||
const checkCookie = setInterval(async () => {
|
||||
try {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview",
|
||||
"electron:dev": "concurrently -k \"cross-env BROWSER=none npm run dev\" \"npx tsc -p electron/tsconfig.json -w\" \"wait-on http://localhost:5173 && wait-on dist-electron/main.js && electron .\"",
|
||||
"electron:build": "vite build && npx tsc -p electron/tsconfig.json && npm prune --production && npm install && electron-builder --publish never"
|
||||
"electron:build": "vite build && npx tsc -p electron/tsconfig.json && electron-builder --publish never"
|
||||
},
|
||||
"build": {
|
||||
"appId": "io.narl.ultimatebantracker",
|
||||
|
||||
Reference in New Issue
Block a user