Compare commits
39 Commits
64fe49e58e
...
v1.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
| eca3a728fc | |||
| b64ddafab9 | |||
| 9174bcfca2 | |||
| d30005acbd | |||
| a5cc155ffc | |||
| 276d3bd4de | |||
| 60b3dd1ca1 | |||
| 34a71de2dc | |||
| 83dbfce8b2 | |||
| c208ecea95 | |||
| cf78e3c329 | |||
| 589acdebcb | |||
| 4037d7bce3 | |||
| fc3382c91e | |||
| 5d611fd8be | |||
| ee44de182c | |||
| 6dc940bb3a | |||
| fa29bd5a85 | |||
| 88d2a2133c | |||
| 5812888bb7 | |||
| 9d5f77dc09 | |||
| 75accbe5b6 | |||
| 2719bd527a | |||
| d68f0a2740 | |||
| e16a537621 | |||
| 6f66f33a9b | |||
| f0740997d0 | |||
| 1f5d2e08e5 | |||
| 7d1e19d881 | |||
| 6c6da941d5 | |||
| 6c46a31fe9 | |||
| 0b1bd727e6 | |||
| 59244e2b54 | |||
| ebed6c078c | |||
| 7d49209c0b | |||
| e47e722e27 | |||
| 1293331c50 | |||
| b7e22b33af | |||
| 20b41d90ab |
@@ -41,6 +41,12 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ELECTRON_BUILDER_ALLOW_EMPTY_REPOSITORY: true
|
ELECTRON_BUILDER_ALLOW_EMPTY_REPOSITORY: true
|
||||||
|
|
||||||
|
- name: Extract Version
|
||||||
|
id: get_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(node -p "require('./frontend/package.json').version")
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Upload Release Artifacts
|
- name: Upload Release Artifacts
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
||||||
@@ -49,8 +55,8 @@ jobs:
|
|||||||
frontend/release/*.AppImage
|
frontend/release/*.AppImage
|
||||||
frontend/release/*.deb
|
frontend/release/*.deb
|
||||||
frontend/release/*.exe
|
frontend/release/*.exe
|
||||||
tag_name: v${{ github.run_number }}
|
tag_name: v${{ steps.get_version.outputs.VERSION }}
|
||||||
name: Release v${{ github.run_number }}
|
name: Release v${{ steps.get_version.outputs.VERSION }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
env:
|
env:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,10 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
deleteAccount: (id) => electron_1.ipcRenderer.invoke('delete-account', id),
|
deleteAccount: (id) => electron_1.ipcRenderer.invoke('delete-account', id),
|
||||||
switchAccount: (loginName) => electron_1.ipcRenderer.invoke('switch-account', loginName),
|
switchAccount: (loginName) => electron_1.ipcRenderer.invoke('switch-account', loginName),
|
||||||
shareAccountWithUser: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('share-account-with-user', steamId, targetSteamId),
|
shareAccountWithUser: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('share-account-with-user', steamId, targetSteamId),
|
||||||
|
revokeAccountAccess: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
|
||||||
|
revokeAllAccountAccess: (steamId) => electron_1.ipcRenderer.invoke('revoke-all-account-access', steamId),
|
||||||
openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url),
|
openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url),
|
||||||
|
openSteamAppLogin: () => electron_1.ipcRenderer.invoke('open-steam-app-login'),
|
||||||
openSteamLogin: (steamId) => electron_1.ipcRenderer.invoke('open-steam-login', steamId),
|
openSteamLogin: (steamId) => electron_1.ipcRenderer.invoke('open-steam-login', steamId),
|
||||||
// Server Config & Auth
|
// Server Config & Auth
|
||||||
getServerConfig: () => electron_1.ipcRenderer.invoke('get-server-config'),
|
getServerConfig: () => electron_1.ipcRenderer.invoke('get-server-config'),
|
||||||
@@ -16,8 +19,15 @@ 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);
|
||||||
|
|||||||
@@ -67,19 +67,24 @@ class BackendService {
|
|||||||
gameBans: account.gameBans,
|
gameBans: account.gameBans,
|
||||||
loginName: account.loginName,
|
loginName: account.loginName,
|
||||||
steamLoginSecure: account.steamLoginSecure,
|
steamLoginSecure: account.steamLoginSecure,
|
||||||
loginConfig: account.loginConfig
|
loginConfig: account.loginConfig,
|
||||||
|
sessionUpdatedAt: account.sessionUpdatedAt,
|
||||||
|
lastMetadataCheck: account.lastBanCheck,
|
||||||
|
lastScrapeTime: account.lastScrapeTime,
|
||||||
|
cooldownExpiresAt: account.cooldownExpiresAt
|
||||||
}, { headers: this.headers });
|
}, { headers: this.headers });
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('[Backend] Failed to share account');
|
console.error('[Backend] Failed to share account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async pushCooldown(steamId, cooldownExpiresAt) {
|
async pushCooldown(steamId, cooldownExpiresAt, lastScrapeTime) {
|
||||||
if (!this.token)
|
if (!this.token)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
await axios_1.default.patch(`${this.url}/api/sync/${steamId}/cooldown`, {
|
await axios_1.default.patch(`${this.url}/api/sync/${steamId}/cooldown`, {
|
||||||
cooldownExpiresAt
|
cooldownExpiresAt,
|
||||||
|
lastScrapeTime
|
||||||
}, { headers: this.headers });
|
}, { headers: this.headers });
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -100,5 +105,88 @@ class BackendService {
|
|||||||
throw new Error(e.response?.data?.message || 'Failed to share account');
|
throw new Error(e.response?.data?.message || 'Failed to share account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async revokeAccess(steamId, targetSteamId) {
|
||||||
|
if (!this.token)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
const response = await axios_1.default.delete(`${this.url}/api/sync/${steamId}/share`, {
|
||||||
|
headers: this.headers,
|
||||||
|
data: { targetSteamId }
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(`[Backend] Failed to revoke access for ${steamId} from ${targetSteamId}`);
|
||||||
|
throw new Error(e.response?.data?.message || 'Failed to revoke access');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async revokeAllAccess(steamId) {
|
||||||
|
if (!this.token)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
const response = await axios_1.default.delete(`${this.url}/api/sync/${steamId}/share/all`, {
|
||||||
|
headers: this.headers
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(`[Backend] Failed to revoke all access for ${steamId}`);
|
||||||
|
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;
|
||||||
|
|||||||
@@ -57,17 +57,23 @@ const scrapeCooldown = async (steamId, steamLoginSecure) => {
|
|||||||
let expirationDate = undefined;
|
let expirationDate = undefined;
|
||||||
$('table').each((_, table) => {
|
$('table').each((_, table) => {
|
||||||
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
||||||
const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration'));
|
const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration') || h.includes('Cooldown Expiration'));
|
||||||
if (expirationIndex !== -1) {
|
if (expirationIndex !== -1) {
|
||||||
const firstRow = $(table).find('tr').not(':has(th)').first();
|
const rows = $(table).find('tr').not(':has(th)');
|
||||||
const dateText = firstRow.find('td').eq(expirationIndex).text().trim();
|
rows.each((_, row) => {
|
||||||
if (dateText && dateText !== '') {
|
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
||||||
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
if (dateText && dateText !== '') {
|
||||||
const parsed = new Date(cleanDateText);
|
// Steam uses 'GMT' which some JS engines don't parse well, replace with 'UTC'
|
||||||
if (!isNaN(parsed.getTime())) {
|
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
||||||
expirationDate = parsed;
|
const parsed = new Date(cleanDateText);
|
||||||
|
if (!isNaN(parsed.getTime())) {
|
||||||
|
// We want the newest expiration date found
|
||||||
|
if (!expirationDate || parsed > expirationDate) {
|
||||||
|
expirationDate = parsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (expirationDate && expirationDate.getTime() > Date.now()) {
|
if (expirationDate && expirationDate.getTime() > Date.now()) {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class SteamClientService {
|
|||||||
if (platform === 'win32') {
|
if (platform === 'win32') {
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
'C:\\Program Files (x86)\\Steam',
|
'C:\\Program Files (x86)\\Steam',
|
||||||
'C:\\Program Files\\Steam'
|
'C:\\Program Files\\Steam',
|
||||||
|
path_1.default.join(process.env.APPDATA || '', 'Steam'),
|
||||||
];
|
];
|
||||||
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
||||||
}
|
}
|
||||||
@@ -29,7 +30,8 @@ class SteamClientService {
|
|||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
path_1.default.join(home, '.steam/steam'),
|
path_1.default.join(home, '.steam/steam'),
|
||||||
path_1.default.join(home, '.local/share/Steam'),
|
path_1.default.join(home, '.local/share/Steam'),
|
||||||
path_1.default.join(home, '.var/app/com.valvesoftware.Steam/.steam/steam')
|
path_1.default.join(home, '.var/app/com.valvesoftware.Steam/.steam/steam'), // Flatpak
|
||||||
|
path_1.default.join(home, 'snap/steam/common/.steam/steam'), // Snap
|
||||||
];
|
];
|
||||||
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
this.steamPath = possiblePaths.find(p => fs_1.default.existsSync(p)) || null;
|
||||||
}
|
}
|
||||||
@@ -47,12 +49,35 @@ class SteamClientService {
|
|||||||
return null;
|
return null;
|
||||||
return path_1.default.join(this.steamPath, 'config', 'config.vdf');
|
return path_1.default.join(this.steamPath, 'config', 'config.vdf');
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Safe Atomic Write: Writes to a temp file and renames it.
|
||||||
|
* This prevents file corruption if the app crashes during write.
|
||||||
|
*/
|
||||||
|
safeWriteVdf(filePath, data) {
|
||||||
|
const tempPath = `${filePath}.tmp_${Date.now()}`;
|
||||||
|
const dir = path_1.default.dirname(filePath);
|
||||||
|
try {
|
||||||
|
if (!fs_1.default.existsSync(dir))
|
||||||
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
||||||
|
const vdfContent = (0, simple_vdf_1.stringify)(data);
|
||||||
|
fs_1.default.writeFileSync(tempPath, vdfContent, 'utf-8');
|
||||||
|
// Atomic rename
|
||||||
|
fs_1.default.renameSync(tempPath, filePath);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(`[SteamClient] Atomic write failed for ${filePath}: ${e.message}`);
|
||||||
|
if (fs_1.default.existsSync(tempPath))
|
||||||
|
fs_1.default.unlinkSync(tempPath);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
startWatching(callback) {
|
startWatching(callback) {
|
||||||
this.onAccountsChanged = callback;
|
this.onAccountsChanged = callback;
|
||||||
const loginUsersPath = this.getLoginUsersPath();
|
const loginUsersPath = this.getLoginUsersPath();
|
||||||
if (loginUsersPath && fs_1.default.existsSync(loginUsersPath)) {
|
if (loginUsersPath && fs_1.default.existsSync(loginUsersPath)) {
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
chokidar_1.default.watch(loginUsersPath, { persistent: true }).on('change', () => {
|
chokidar_1.default.watch(loginUsersPath, { persistent: true, ignoreInitial: true }).on('change', () => {
|
||||||
|
console.log(`[SteamClient] loginusers.vdf changed, re-scanning...`);
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -63,16 +88,20 @@ class SteamClientService {
|
|||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
||||||
|
if (!content.trim())
|
||||||
|
return; // Empty file
|
||||||
const data = (0, simple_vdf_1.parse)(content);
|
const data = (0, simple_vdf_1.parse)(content);
|
||||||
if (!data || !data.users)
|
if (!data || !data.users)
|
||||||
return;
|
return;
|
||||||
const accounts = [];
|
const accounts = [];
|
||||||
for (const [steamId64, userData] of Object.entries(data.users)) {
|
for (const [steamId64, userData] of Object.entries(data.users)) {
|
||||||
const user = userData;
|
const user = userData;
|
||||||
|
if (!user || !user.AccountName)
|
||||||
|
continue;
|
||||||
accounts.push({
|
accounts.push({
|
||||||
steamId: steamId64,
|
steamId: steamId64,
|
||||||
accountName: user.AccountName,
|
accountName: user.AccountName,
|
||||||
personaName: user.PersonaName,
|
personaName: user.PersonaName || user.AccountName,
|
||||||
timestamp: parseInt(user.Timestamp) || 0
|
timestamp: parseInt(user.Timestamp) || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -91,32 +120,38 @@ class SteamClientService {
|
|||||||
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
||||||
const data = (0, simple_vdf_1.parse)(content);
|
const data = (0, simple_vdf_1.parse)(content);
|
||||||
const accounts = data?.InstallConfigStore?.Software?.Valve?.Steam?.Accounts;
|
const accounts = data?.InstallConfigStore?.Software?.Valve?.Steam?.Accounts;
|
||||||
if (accounts && accounts[accountName]) {
|
return (accounts && accounts[accountName]) ? accounts[accountName] : null;
|
||||||
return accounts[accountName];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('[SteamClient] Failed to extract config.vdf data');
|
console.error('[SteamClient] Failed to extract config.vdf data');
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
injectAccountConfig(accountName, accountData) {
|
injectAccountConfig(accountName, accountData) {
|
||||||
const configPath = this.getConfigVdfPath();
|
const configPath = this.getConfigVdfPath();
|
||||||
if (!configPath)
|
if (!configPath)
|
||||||
return;
|
return;
|
||||||
// Create directory if it doesn't exist
|
let data = {
|
||||||
const configDir = path_1.default.dirname(configPath);
|
InstallConfigStore: {
|
||||||
if (!fs_1.default.existsSync(configDir))
|
Software: {
|
||||||
fs_1.default.mkdirSync(configDir, { recursive: true });
|
Valve: {
|
||||||
let data = { InstallConfigStore: { Software: { Valve: { Steam: { Accounts: {} } } } } };
|
Steam: {
|
||||||
|
Accounts: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
if (fs_1.default.existsSync(configPath)) {
|
if (fs_1.default.existsSync(configPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
const content = fs_1.default.readFileSync(configPath, 'utf-8');
|
||||||
data = (0, simple_vdf_1.parse)(content);
|
const parsed = (0, simple_vdf_1.parse)(content);
|
||||||
|
if (parsed && typeof parsed === 'object')
|
||||||
|
data = parsed;
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
// Ensure structure exists
|
// Ensure safe nesting
|
||||||
if (!data.InstallConfigStore)
|
if (!data.InstallConfigStore)
|
||||||
data.InstallConfigStore = {};
|
data.InstallConfigStore = {};
|
||||||
if (!data.InstallConfigStore.Software)
|
if (!data.InstallConfigStore.Software)
|
||||||
@@ -129,25 +164,22 @@ class SteamClientService {
|
|||||||
data.InstallConfigStore.Software.Valve.Steam.Accounts = {};
|
data.InstallConfigStore.Software.Valve.Steam.Accounts = {};
|
||||||
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
||||||
try {
|
try {
|
||||||
fs_1.default.writeFileSync(configPath, (0, simple_vdf_1.stringify)(data));
|
this.safeWriteVdf(configPath, data);
|
||||||
console.log(`[SteamClient] Injected login config for ${accountName} into config.vdf`);
|
console.log(`[SteamClient] Safely injected session for ${accountName}`);
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error('[SteamClient] Failed to write config.vdf');
|
|
||||||
}
|
}
|
||||||
|
catch (e) { }
|
||||||
}
|
}
|
||||||
async setAutoLoginUser(accountName, accountConfig, steamId) {
|
async setAutoLoginUser(accountName, accountConfig, steamId) {
|
||||||
const platform = os_1.default.platform();
|
const platform = os_1.default.platform();
|
||||||
const loginUsersPath = this.getLoginUsersPath();
|
const loginUsersPath = this.getLoginUsersPath();
|
||||||
if (loginUsersPath) {
|
if (loginUsersPath) {
|
||||||
const configDir = path_1.default.dirname(loginUsersPath);
|
|
||||||
if (!fs_1.default.existsSync(configDir))
|
|
||||||
fs_1.default.mkdirSync(configDir, { recursive: true });
|
|
||||||
let data = { users: {} };
|
let data = { users: {} };
|
||||||
if (fs_1.default.existsSync(loginUsersPath)) {
|
if (fs_1.default.existsSync(loginUsersPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(loginUsersPath, 'utf-8');
|
const content = fs_1.default.readFileSync(loginUsersPath, 'utf-8');
|
||||||
data = (0, simple_vdf_1.parse)(content);
|
const parsed = (0, simple_vdf_1.parse)(content);
|
||||||
|
if (parsed && parsed.users)
|
||||||
|
data = parsed;
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
@@ -156,7 +188,7 @@ class SteamClientService {
|
|||||||
let found = false;
|
let found = false;
|
||||||
for (const [id, user] of Object.entries(data.users)) {
|
for (const [id, user] of Object.entries(data.users)) {
|
||||||
const u = user;
|
const u = user;
|
||||||
if (u.AccountName.toLowerCase() === accountName.toLowerCase()) {
|
if (u.AccountName?.toLowerCase() === accountName.toLowerCase()) {
|
||||||
u.mostrecent = "1";
|
u.mostrecent = "1";
|
||||||
u.RememberPassword = "1";
|
u.RememberPassword = "1";
|
||||||
u.AllowAutoLogin = "1";
|
u.AllowAutoLogin = "1";
|
||||||
@@ -169,8 +201,8 @@ class SteamClientService {
|
|||||||
u.mostrecent = "0";
|
u.mostrecent = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found && steamId) {
|
if (!found && steamId && accountName) {
|
||||||
console.log(`[SteamClient] Provisioning user ${accountName} into loginusers.vdf`);
|
console.log(`[SteamClient] Provisioning new user profile for ${accountName}`);
|
||||||
data.users[steamId] = {
|
data.users[steamId] = {
|
||||||
AccountName: accountName,
|
AccountName: accountName,
|
||||||
PersonaName: accountName,
|
PersonaName: accountName,
|
||||||
@@ -184,51 +216,53 @@ class SteamClientService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs_1.default.writeFileSync(loginUsersPath, (0, simple_vdf_1.stringify)(data));
|
this.safeWriteVdf(loginUsersPath, data);
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error('[SteamClient] Failed to write loginusers.vdf');
|
|
||||||
}
|
}
|
||||||
|
catch (e) { }
|
||||||
}
|
}
|
||||||
if (accountConfig) {
|
if (accountConfig && accountName) {
|
||||||
this.injectAccountConfig(accountName, accountConfig);
|
this.injectAccountConfig(accountName, accountConfig);
|
||||||
}
|
}
|
||||||
|
// --- Linux Registry / Registry.vdf Hardening ---
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
const regLocations = [
|
const regLocations = [
|
||||||
path_1.default.join(os_1.default.homedir(), '.steam', 'registry.vdf'),
|
path_1.default.join(os_1.default.homedir(), '.steam', 'registry.vdf'),
|
||||||
path_1.default.join(os_1.default.homedir(), '.steam', 'steam', 'registry.vdf')
|
path_1.default.join(os_1.default.homedir(), '.steam', 'steam', 'registry.vdf')
|
||||||
];
|
];
|
||||||
for (const regPath of regLocations) {
|
for (const regPath of regLocations) {
|
||||||
let regData = { Registry: { HKCU: { Software: { Valve: { Steam: {} } } } } };
|
if (!fs_1.default.existsSync(path_1.default.dirname(regPath)))
|
||||||
|
continue;
|
||||||
|
let regData = { Registry: { HKCU: { Software: { Valve: { Steam: {
|
||||||
|
AutoLoginUser: "",
|
||||||
|
RememberPassword: "1",
|
||||||
|
AlreadyLoggedIn: "1"
|
||||||
|
} } } } } };
|
||||||
if (fs_1.default.existsSync(regPath)) {
|
if (fs_1.default.existsSync(regPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs_1.default.readFileSync(regPath, 'utf-8');
|
const content = fs_1.default.readFileSync(regPath, 'utf-8');
|
||||||
regData = (0, simple_vdf_1.parse)(content);
|
const parsed = (0, simple_vdf_1.parse)(content);
|
||||||
|
if (parsed && typeof parsed === 'object')
|
||||||
|
regData = parsed;
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
else {
|
// Deep merge helper
|
||||||
const regDir = path_1.default.dirname(regPath);
|
const ensurePath = (obj, keys) => {
|
||||||
if (!fs_1.default.existsSync(regDir))
|
|
||||||
fs_1.default.mkdirSync(regDir, { recursive: true });
|
|
||||||
}
|
|
||||||
const setPath = (obj, keys, val) => {
|
|
||||||
let curr = obj;
|
let curr = obj;
|
||||||
for (let i = 0; i < keys.length - 1; i++) {
|
for (const key of keys) {
|
||||||
if (!curr[keys[i]])
|
if (!curr[key] || typeof curr[key] !== 'object')
|
||||||
curr[keys[i]] = {};
|
curr[key] = {};
|
||||||
curr = curr[keys[i]];
|
curr = curr[key];
|
||||||
}
|
}
|
||||||
curr[keys[keys.length - 1]] = val;
|
return curr;
|
||||||
};
|
};
|
||||||
const steamReg = ['Registry', 'HKCU', 'Software', 'Valve', 'Steam'];
|
const steamKey = ensurePath(regData, ['Registry', 'HKCU', 'Software', 'Valve', 'Steam']);
|
||||||
setPath(regData, [...steamReg, 'AutoLoginUser'], accountName);
|
steamKey.AutoLoginUser = accountName;
|
||||||
setPath(regData, [...steamReg, 'RememberPassword'], "1");
|
steamKey.RememberPassword = "1";
|
||||||
setPath(regData, [...steamReg, 'AlreadyLoggedIn'], "1");
|
steamKey.AlreadyLoggedIn = "1";
|
||||||
setPath(regData, [...steamReg, 'WantsOfflineMode'], "0");
|
steamKey.WantsOfflineMode = "0";
|
||||||
try {
|
try {
|
||||||
fs_1.default.writeFileSync(regPath, (0, simple_vdf_1.stringify)(regData));
|
this.safeWriteVdf(regPath, regData);
|
||||||
console.log(`[SteamClient] Registry updated: ${regPath}`);
|
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,10 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
deleteAccount: (id: string) => ipcRenderer.invoke('delete-account', id),
|
deleteAccount: (id: string) => ipcRenderer.invoke('delete-account', id),
|
||||||
switchAccount: (loginName: string) => ipcRenderer.invoke('switch-account', loginName),
|
switchAccount: (loginName: string) => ipcRenderer.invoke('switch-account', loginName),
|
||||||
shareAccountWithUser: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('share-account-with-user', steamId, targetSteamId),
|
shareAccountWithUser: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('share-account-with-user', steamId, targetSteamId),
|
||||||
|
revokeAccountAccess: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
|
||||||
|
revokeAllAccountAccess: (steamId: string) => ipcRenderer.invoke('revoke-all-account-access', steamId),
|
||||||
openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
|
openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
|
||||||
|
openSteamAppLogin: () => ipcRenderer.invoke('open-steam-app-login'),
|
||||||
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
|
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
|
||||||
|
|
||||||
// Server Config & Auth
|
// Server Config & Auth
|
||||||
@@ -16,9 +19,17 @@ 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);
|
||||||
|
|||||||
@@ -61,18 +61,23 @@ export class BackendService {
|
|||||||
gameBans: account.gameBans,
|
gameBans: account.gameBans,
|
||||||
loginName: account.loginName,
|
loginName: account.loginName,
|
||||||
steamLoginSecure: account.steamLoginSecure,
|
steamLoginSecure: account.steamLoginSecure,
|
||||||
loginConfig: account.loginConfig
|
loginConfig: account.loginConfig,
|
||||||
|
sessionUpdatedAt: account.sessionUpdatedAt,
|
||||||
|
lastMetadataCheck: account.lastBanCheck,
|
||||||
|
lastScrapeTime: account.lastScrapeTime,
|
||||||
|
cooldownExpiresAt: account.cooldownExpiresAt
|
||||||
}, { headers: this.headers });
|
}, { headers: this.headers });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Backend] Failed to share account');
|
console.error('[Backend] Failed to share account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushCooldown(steamId: string, cooldownExpiresAt?: string) {
|
public async pushCooldown(steamId: string, cooldownExpiresAt?: string, lastScrapeTime?: string) {
|
||||||
if (!this.token) return;
|
if (!this.token) return;
|
||||||
try {
|
try {
|
||||||
await axios.patch(`${this.url}/api/sync/${steamId}/cooldown`, {
|
await axios.patch(`${this.url}/api/sync/${steamId}/cooldown`, {
|
||||||
cooldownExpiresAt
|
cooldownExpiresAt,
|
||||||
|
lastScrapeTime
|
||||||
}, { headers: this.headers });
|
}, { headers: this.headers });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Backend] Failed to push cooldown for ${steamId}`);
|
console.error(`[Backend] Failed to push cooldown for ${steamId}`);
|
||||||
@@ -91,4 +96,75 @@ export class BackendService {
|
|||||||
throw new Error(e.response?.data?.message || 'Failed to share account');
|
throw new Error(e.response?.data?.message || 'Failed to share account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async revokeAccess(steamId: string, targetSteamId: string) {
|
||||||
|
if (!this.token) return;
|
||||||
|
try {
|
||||||
|
const response = await axios.delete(`${this.url}/api/sync/${steamId}/share`, {
|
||||||
|
headers: this.headers,
|
||||||
|
data: { targetSteamId }
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(`[Backend] Failed to revoke access for ${steamId} from ${targetSteamId}`);
|
||||||
|
throw new Error(e.response?.data?.message || 'Failed to revoke access');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async revokeAllAccess(steamId: string) {
|
||||||
|
if (!this.token) return;
|
||||||
|
try {
|
||||||
|
const response = await axios.delete(`${this.url}/api/sync/${steamId}/share/all`, {
|
||||||
|
headers: this.headers
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(`[Backend] Failed to revoke all access for ${steamId}`);
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,20 +29,25 @@ export const scrapeCooldown = async (steamId: string, steamLoginSecure: string):
|
|||||||
|
|
||||||
$('table').each((_, table) => {
|
$('table').each((_, table) => {
|
||||||
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
const headers = $(table).find('th').map((_, th) => $(th).text().trim()).get();
|
||||||
const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration'));
|
const expirationIndex = headers.findIndex(h => h.includes('Competitive Cooldown Expiration') || h.includes('Cooldown Expiration'));
|
||||||
|
|
||||||
if (expirationIndex !== -1) {
|
if (expirationIndex !== -1) {
|
||||||
const firstRow = $(table).find('tr').not(':has(th)').first();
|
const rows = $(table).find('tr').not(':has(th)');
|
||||||
const dateText = firstRow.find('td').eq(expirationIndex).text().trim();
|
rows.each((_, row) => {
|
||||||
|
const dateText = $(row).find('td').eq(expirationIndex).text().trim();
|
||||||
|
if (dateText && dateText !== '') {
|
||||||
|
// Steam uses 'GMT' which some JS engines don't parse well, replace with 'UTC'
|
||||||
|
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
||||||
|
const parsed = new Date(cleanDateText);
|
||||||
|
|
||||||
if (dateText && dateText !== '') {
|
if (!isNaN(parsed.getTime())) {
|
||||||
const cleanDateText = dateText.replace(' GMT', ' UTC');
|
// We want the newest expiration date found
|
||||||
const parsed = new Date(cleanDateText);
|
if (!expirationDate || parsed > (expirationDate as Date)) {
|
||||||
|
expirationDate = parsed;
|
||||||
if (!isNaN(parsed.getTime())) {
|
}
|
||||||
expirationDate = parsed;
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ class SteamClientService {
|
|||||||
if (platform === 'win32') {
|
if (platform === 'win32') {
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
'C:\\Program Files (x86)\\Steam',
|
'C:\\Program Files (x86)\\Steam',
|
||||||
'C:\\Program Files\\Steam'
|
'C:\\Program Files\\Steam',
|
||||||
|
path.join(process.env.APPDATA || '', 'Steam'),
|
||||||
];
|
];
|
||||||
this.steamPath = possiblePaths.find(p => fs.existsSync(p)) || null;
|
this.steamPath = possiblePaths.find(p => fs.existsSync(p)) || null;
|
||||||
} else if (platform === 'linux') {
|
} else if (platform === 'linux') {
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
path.join(home, '.steam/steam'),
|
path.join(home, '.steam/steam'),
|
||||||
path.join(home, '.local/share/Steam'),
|
path.join(home, '.local/share/Steam'),
|
||||||
path.join(home, '.var/app/com.valvesoftware.Steam/.steam/steam')
|
path.join(home, '.var/app/com.valvesoftware.Steam/.steam/steam'), // Flatpak
|
||||||
|
path.join(home, 'snap/steam/common/.steam/steam'), // Snap
|
||||||
];
|
];
|
||||||
this.steamPath = possiblePaths.find(p => fs.existsSync(p)) || null;
|
this.steamPath = possiblePaths.find(p => fs.existsSync(p)) || null;
|
||||||
}
|
}
|
||||||
@@ -53,13 +55,36 @@ class SteamClientService {
|
|||||||
return path.join(this.steamPath, 'config', 'config.vdf');
|
return path.join(this.steamPath, 'config', 'config.vdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Safe Atomic Write: Writes to a temp file and renames it.
|
||||||
|
* This prevents file corruption if the app crashes during write.
|
||||||
|
*/
|
||||||
|
private safeWriteVdf(filePath: string, data: any) {
|
||||||
|
const tempPath = `${filePath}.tmp_${Date.now()}`;
|
||||||
|
const dir = path.dirname(filePath);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||||
|
const vdfContent = stringify(data);
|
||||||
|
fs.writeFileSync(tempPath, vdfContent, 'utf-8');
|
||||||
|
|
||||||
|
// Atomic rename
|
||||||
|
fs.renameSync(tempPath, filePath);
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(`[SteamClient] Atomic write failed for ${filePath}: ${e.message}`);
|
||||||
|
if (fs.existsSync(tempPath)) fs.unlinkSync(tempPath);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public startWatching(callback: (accounts: LocalSteamAccount[]) => void) {
|
public startWatching(callback: (accounts: LocalSteamAccount[]) => void) {
|
||||||
this.onAccountsChanged = callback;
|
this.onAccountsChanged = callback;
|
||||||
const loginUsersPath = this.getLoginUsersPath();
|
const loginUsersPath = this.getLoginUsersPath();
|
||||||
|
|
||||||
if (loginUsersPath && fs.existsSync(loginUsersPath)) {
|
if (loginUsersPath && fs.existsSync(loginUsersPath)) {
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
chokidar.watch(loginUsersPath, { persistent: true }).on('change', () => {
|
chokidar.watch(loginUsersPath, { persistent: true, ignoreInitial: true }).on('change', () => {
|
||||||
|
console.log(`[SteamClient] loginusers.vdf changed, re-scanning...`);
|
||||||
this.readLocalAccounts();
|
this.readLocalAccounts();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -71,16 +96,20 @@ class SteamClientService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(filePath, 'utf-8');
|
const content = fs.readFileSync(filePath, 'utf-8');
|
||||||
|
if (!content.trim()) return; // Empty file
|
||||||
|
|
||||||
const data = parse(content) as any;
|
const data = parse(content) as any;
|
||||||
if (!data || !data.users) return;
|
if (!data || !data.users) return;
|
||||||
|
|
||||||
const accounts: LocalSteamAccount[] = [];
|
const accounts: LocalSteamAccount[] = [];
|
||||||
for (const [steamId64, userData] of Object.entries(data.users)) {
|
for (const [steamId64, userData] of Object.entries(data.users)) {
|
||||||
const user = userData as any;
|
const user = userData as any;
|
||||||
|
if (!user || !user.AccountName) continue;
|
||||||
|
|
||||||
accounts.push({
|
accounts.push({
|
||||||
steamId: steamId64,
|
steamId: steamId64,
|
||||||
accountName: user.AccountName,
|
accountName: user.AccountName,
|
||||||
personaName: user.PersonaName,
|
personaName: user.PersonaName || user.AccountName,
|
||||||
timestamp: parseInt(user.Timestamp) || 0
|
timestamp: parseInt(user.Timestamp) || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,35 +127,39 @@ class SteamClientService {
|
|||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(configPath, 'utf-8');
|
const content = fs.readFileSync(configPath, 'utf-8');
|
||||||
const data = parse(content) as any;
|
const data = parse(content) as any;
|
||||||
|
|
||||||
const accounts = data?.InstallConfigStore?.Software?.Valve?.Steam?.Accounts;
|
const accounts = data?.InstallConfigStore?.Software?.Valve?.Steam?.Accounts;
|
||||||
if (accounts && accounts[accountName]) {
|
return (accounts && accounts[accountName]) ? accounts[accountName] : null;
|
||||||
return accounts[accountName];
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[SteamClient] Failed to extract config.vdf data');
|
console.error('[SteamClient] Failed to extract config.vdf data');
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public injectAccountConfig(accountName: string, accountData: any) {
|
public injectAccountConfig(accountName: string, accountData: any) {
|
||||||
const configPath = this.getConfigVdfPath();
|
const configPath = this.getConfigVdfPath();
|
||||||
if (!configPath) return;
|
if (!configPath) return;
|
||||||
|
|
||||||
// Create directory if it doesn't exist
|
let data: any = {
|
||||||
const configDir = path.dirname(configPath);
|
InstallConfigStore: {
|
||||||
if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
|
Software: {
|
||||||
|
Valve: {
|
||||||
let data: any = { InstallConfigStore: { Software: { Valve: { Steam: { Accounts: {} } } } } };
|
Steam: {
|
||||||
|
Accounts: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (fs.existsSync(configPath)) {
|
if (fs.existsSync(configPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(configPath, 'utf-8');
|
const content = fs.readFileSync(configPath, 'utf-8');
|
||||||
data = parse(content) as any;
|
const parsed = parse(content) as any;
|
||||||
|
if (parsed && typeof parsed === 'object') data = parsed;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure structure exists
|
// Ensure safe nesting
|
||||||
if (!data.InstallConfigStore) data.InstallConfigStore = {};
|
if (!data.InstallConfigStore) data.InstallConfigStore = {};
|
||||||
if (!data.InstallConfigStore.Software) data.InstallConfigStore.Software = {};
|
if (!data.InstallConfigStore.Software) data.InstallConfigStore.Software = {};
|
||||||
if (!data.InstallConfigStore.Software.Valve) data.InstallConfigStore.Software.Valve = {};
|
if (!data.InstallConfigStore.Software.Valve) data.InstallConfigStore.Software.Valve = {};
|
||||||
@@ -136,11 +169,9 @@ class SteamClientService {
|
|||||||
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
data.InstallConfigStore.Software.Valve.Steam.Accounts[accountName] = accountData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(configPath, stringify(data));
|
this.safeWriteVdf(configPath, data);
|
||||||
console.log(`[SteamClient] Injected login config for ${accountName} into config.vdf`);
|
console.log(`[SteamClient] Safely injected session for ${accountName}`);
|
||||||
} catch (e) {
|
} catch (e) { }
|
||||||
console.error('[SteamClient] Failed to write config.vdf');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setAutoLoginUser(accountName: string, accountConfig?: any, steamId?: string): Promise<boolean> {
|
public async setAutoLoginUser(accountName: string, accountConfig?: any, steamId?: string): Promise<boolean> {
|
||||||
@@ -148,14 +179,12 @@ class SteamClientService {
|
|||||||
const loginUsersPath = this.getLoginUsersPath();
|
const loginUsersPath = this.getLoginUsersPath();
|
||||||
|
|
||||||
if (loginUsersPath) {
|
if (loginUsersPath) {
|
||||||
const configDir = path.dirname(loginUsersPath);
|
|
||||||
if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
|
|
||||||
|
|
||||||
let data: any = { users: {} };
|
let data: any = { users: {} };
|
||||||
if (fs.existsSync(loginUsersPath)) {
|
if (fs.existsSync(loginUsersPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(loginUsersPath, 'utf-8');
|
const content = fs.readFileSync(loginUsersPath, 'utf-8');
|
||||||
data = parse(content) as any;
|
const parsed = parse(content) as any;
|
||||||
|
if (parsed && parsed.users) data = parsed;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +193,7 @@ class SteamClientService {
|
|||||||
let found = false;
|
let found = false;
|
||||||
for (const [id, user] of Object.entries(data.users)) {
|
for (const [id, user] of Object.entries(data.users)) {
|
||||||
const u = user as any;
|
const u = user as any;
|
||||||
if (u.AccountName.toLowerCase() === accountName.toLowerCase()) {
|
if (u.AccountName?.toLowerCase() === accountName.toLowerCase()) {
|
||||||
u.mostrecent = "1";
|
u.mostrecent = "1";
|
||||||
u.RememberPassword = "1";
|
u.RememberPassword = "1";
|
||||||
u.AllowAutoLogin = "1";
|
u.AllowAutoLogin = "1";
|
||||||
@@ -177,8 +206,8 @@ class SteamClientService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && steamId) {
|
if (!found && steamId && accountName) {
|
||||||
console.log(`[SteamClient] Provisioning user ${accountName} into loginusers.vdf`);
|
console.log(`[SteamClient] Provisioning new user profile for ${accountName}`);
|
||||||
data.users[steamId] = {
|
data.users[steamId] = {
|
||||||
AccountName: accountName,
|
AccountName: accountName,
|
||||||
PersonaName: accountName,
|
PersonaName: accountName,
|
||||||
@@ -193,16 +222,15 @@ class SteamClientService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(loginUsersPath, stringify(data));
|
this.safeWriteVdf(loginUsersPath, data);
|
||||||
} catch (e) {
|
} catch (e) { }
|
||||||
console.error('[SteamClient] Failed to write loginusers.vdf');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountConfig) {
|
if (accountConfig && accountName) {
|
||||||
this.injectAccountConfig(accountName, accountConfig);
|
this.injectAccountConfig(accountName, accountConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Linux Registry / Registry.vdf Hardening ---
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
const regLocations = [
|
const regLocations = [
|
||||||
path.join(os.homedir(), '.steam', 'registry.vdf'),
|
path.join(os.homedir(), '.steam', 'registry.vdf'),
|
||||||
@@ -210,36 +238,40 @@ class SteamClientService {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const regPath of regLocations) {
|
for (const regPath of regLocations) {
|
||||||
let regData: any = { Registry: { HKCU: { Software: { Valve: { Steam: {} } } } } };
|
if (!fs.existsSync(path.dirname(regPath))) continue;
|
||||||
|
|
||||||
|
let regData: any = { Registry: { HKCU: { Software: { Valve: { Steam: {
|
||||||
|
AutoLoginUser: "",
|
||||||
|
RememberPassword: "1",
|
||||||
|
AlreadyLoggedIn: "1"
|
||||||
|
} } } } } };
|
||||||
|
|
||||||
if (fs.existsSync(regPath)) {
|
if (fs.existsSync(regPath)) {
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(regPath, 'utf-8');
|
const content = fs.readFileSync(regPath, 'utf-8');
|
||||||
regData = parse(content) as any;
|
const parsed = parse(content) as any;
|
||||||
|
if (parsed && typeof parsed === 'object') regData = parsed;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
} else {
|
|
||||||
const regDir = path.dirname(regPath);
|
|
||||||
if (!fs.existsSync(regDir)) fs.mkdirSync(regDir, { recursive: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setPath = (obj: any, keys: string[], val: string) => {
|
// Deep merge helper
|
||||||
|
const ensurePath = (obj: any, keys: string[]) => {
|
||||||
let curr = obj;
|
let curr = obj;
|
||||||
for (let i = 0; i < keys.length - 1; i++) {
|
for (const key of keys) {
|
||||||
if (!curr[keys[i]!]) curr[keys[i]!] = {};
|
if (!curr[key] || typeof curr[key] !== 'object') curr[key] = {};
|
||||||
curr = curr[keys[i]!];
|
curr = curr[key];
|
||||||
}
|
}
|
||||||
curr[keys[keys.length - 1]!] = val;
|
return curr;
|
||||||
};
|
};
|
||||||
|
|
||||||
const steamReg = ['Registry', 'HKCU', 'Software', 'Valve', 'Steam'];
|
const steamKey = ensurePath(regData, ['Registry', 'HKCU', 'Software', 'Valve', 'Steam']);
|
||||||
setPath(regData, [...steamReg, 'AutoLoginUser'], accountName);
|
steamKey.AutoLoginUser = accountName;
|
||||||
setPath(regData, [...steamReg, 'RememberPassword'], "1");
|
steamKey.RememberPassword = "1";
|
||||||
setPath(regData, [...steamReg, 'AlreadyLoggedIn'], "1");
|
steamKey.AlreadyLoggedIn = "1";
|
||||||
setPath(regData, [...steamReg, 'WantsOfflineMode'], "0");
|
steamKey.WantsOfflineMode = "0";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(regPath, stringify(regData));
|
this.safeWriteVdf(regPath, regData);
|
||||||
console.log(`[SteamClient] Registry updated: ${regPath}`);
|
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>frontend</title>
|
<title>Ultimate Ban Tracker</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.0.0",
|
"version": "1.3.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ultimate-ban-tracker-desktop",
|
"name": "ultimate-ban-tracker-desktop",
|
||||||
"version": "1.0.0",
|
"version": "1.3.2",
|
||||||
"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.0.0",
|
"version": "1.3.2",
|
||||||
"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,7 +28,8 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist-electron/**/*"
|
"dist-electron/**/*",
|
||||||
|
"assets-build/**/*"
|
||||||
],
|
],
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": [
|
"target": [
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface ServerConfig {
|
|||||||
token?: string;
|
token?: string;
|
||||||
serverSteamId?: string;
|
serverSteamId?: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
|
isAdmin?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AccountsContextType {
|
interface AccountsContextType {
|
||||||
@@ -38,16 +39,27 @@ interface AccountsContextType {
|
|||||||
updateAccount: (id: string, data: Partial<Account>) => Promise<void>;
|
updateAccount: (id: string, data: Partial<Account>) => Promise<void>;
|
||||||
deleteAccount: (id: string) => Promise<void>;
|
deleteAccount: (id: string) => Promise<void>;
|
||||||
switchAccount: (loginName: string) => Promise<void>;
|
switchAccount: (loginName: string) => Promise<void>;
|
||||||
|
openSteamAppLogin: () => Promise<void>;
|
||||||
openSteamLogin: (steamId: string) => Promise<void>;
|
openSteamLogin: (steamId: string) => Promise<void>;
|
||||||
shareAccountWithUser: (steamId: string, targetSteamId: string) => Promise<any>;
|
shareAccountWithUser: (steamId: string, targetSteamId: string) => Promise<any>;
|
||||||
|
revokeAccountAccess: (steamId: string, targetSteamId: string) => Promise<any>;
|
||||||
|
revokeAllAccountAccess: (steamId: string) => Promise<any>;
|
||||||
|
|
||||||
// Server Methods
|
// Server Methods
|
||||||
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);
|
||||||
@@ -103,6 +115,12 @@ 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();
|
||||||
@@ -125,6 +143,10 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
|||||||
await (window as any).electronAPI.switchAccount(loginName);
|
await (window as any).electronAPI.switchAccount(loginName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openSteamAppLogin = async () => {
|
||||||
|
await (window as any).electronAPI.openSteamAppLogin();
|
||||||
|
};
|
||||||
|
|
||||||
const openSteamLogin = async (steamId: string) => {
|
const openSteamLogin = async (steamId: string) => {
|
||||||
await (window as any).electronAPI.openSteamLogin(steamId);
|
await (window as any).electronAPI.openSteamLogin(steamId);
|
||||||
await syncNow();
|
await syncNow();
|
||||||
@@ -136,6 +158,18 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const revokeAccountAccess = async (steamId: string, targetSteamId: string) => {
|
||||||
|
const res = await (window as any).electronAPI.revokeAccountAccess(steamId, targetSteamId);
|
||||||
|
await syncNow();
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
const revokeAllAccountAccess = async (steamId: string) => {
|
||||||
|
const res = await (window as any).electronAPI.revokeAllAccountAccess(steamId);
|
||||||
|
await syncNow();
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
const updateServerConfig = async (config: Partial<ServerConfig>) => {
|
const updateServerConfig = async (config: Partial<ServerConfig>) => {
|
||||||
const updated = await (window as any).electronAPI.updateServerConfig(config);
|
const updated = await (window as any).electronAPI.updateServerConfig(config);
|
||||||
setServerConfig(updated);
|
setServerConfig(updated);
|
||||||
@@ -155,11 +189,19 @@ 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, openSteamLogin, updateServerConfig, loginToServer,
|
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
|
||||||
getCommunityAccounts, getServerUsers, shareAccountWithUser, 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,
|
||||||
Tabs, Tab, Select, MenuItem, FormControl, InputLabel
|
Select, MenuItem, FormControl, InputLabel, Tabs, Tab
|
||||||
} 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';
|
||||||
@@ -20,74 +20,137 @@ import LockResetIcon from '@mui/icons-material/LockReset';
|
|||||||
import SettingsIcon from '@mui/icons-material/Settings';
|
import SettingsIcon from '@mui/icons-material/Settings';
|
||||||
import ShareIcon from '@mui/icons-material/Share';
|
import ShareIcon from '@mui/icons-material/Share';
|
||||||
import GroupAddIcon from '@mui/icons-material/GroupAdd';
|
import GroupAddIcon from '@mui/icons-material/GroupAdd';
|
||||||
import PublicIcon from '@mui/icons-material/Public';
|
|
||||||
import ShieldIcon from '@mui/icons-material/Shield';
|
import ShieldIcon from '@mui/icons-material/Shield';
|
||||||
import GppBadIcon from '@mui/icons-material/GppBad';
|
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 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 {
|
||||||
accounts, isLoading, isSyncing, serverConfig, addAccount, deleteAccount,
|
accounts, isLoading, isSyncing, serverConfig, deleteAccount,
|
||||||
switchAccount, openSteamLogin, updateServerConfig, loginToServer,
|
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer, syncNow
|
||||||
getCommunityAccounts, syncNow
|
|
||||||
} = useAccounts();
|
} = useAccounts();
|
||||||
|
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
|
|
||||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||||
const [identifier, setIdentifier] = useState('');
|
const [isAdminPanelOpen, setIsAdminPanelOpen] = useState(false);
|
||||||
|
|
||||||
const [addTab, setAddTab] = useState(0);
|
|
||||||
const [communityAccounts, setCommunityAccounts] = useState<any[]>([]);
|
|
||||||
const [isCommunityLoading, setIsCommunityLoading] = useState(false);
|
|
||||||
const [serverUrl, setServerUrl] = useState('');
|
const [serverUrl, setServerUrl] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (serverConfig?.url) {
|
if (serverConfig?.url) setServerUrl(serverConfig.url);
|
||||||
setServerUrl(serverConfig.url);
|
|
||||||
}
|
|
||||||
}, [serverConfig?.url]);
|
}, [serverConfig?.url]);
|
||||||
|
|
||||||
const loadCommunity = async () => {
|
|
||||||
setIsCommunityLoading(true);
|
|
||||||
try {
|
|
||||||
const data = await getCommunityAccounts();
|
|
||||||
setCommunityAccounts(Array.isArray(data) ? data : []);
|
|
||||||
} catch (e) {
|
|
||||||
} finally {
|
|
||||||
setIsCommunityLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isAddDialogOpen && addTab === 1) {
|
|
||||||
loadCommunity();
|
|
||||||
}
|
|
||||||
}, [isAddDialogOpen, addTab]);
|
|
||||||
|
|
||||||
const handleAddAccount = async () => {
|
|
||||||
if (!identifier) return;
|
|
||||||
try {
|
|
||||||
await addAccount({ identifier });
|
|
||||||
setIsAddDialogOpen(false);
|
|
||||||
setIdentifier('');
|
|
||||||
} catch (e) {
|
|
||||||
console.error("[Dashboard] Add failed:", e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAddFromCommunity = async (commAcc: any) => {
|
|
||||||
try {
|
|
||||||
await addAccount({ identifier: commAcc.steamId });
|
|
||||||
setIsAddDialogOpen(false);
|
|
||||||
} catch (e) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveSettings = async () => {
|
const saveSettings = async () => {
|
||||||
await updateServerConfig({ url: serverUrl });
|
await updateServerConfig({ url: serverUrl });
|
||||||
alert("Server URL updated!");
|
alert("Server URL updated!");
|
||||||
@@ -113,6 +176,15 @@ 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 }} />
|
||||||
@@ -147,7 +219,7 @@ const Dashboard: React.FC = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
startIcon={<AddIcon />}
|
startIcon={<AddIcon />}
|
||||||
onClick={() => setIsAddDialogOpen(true)}
|
onClick={() => openSteamAppLogin()}
|
||||||
sx={{ height: 32 }}
|
sx={{ height: 32 }}
|
||||||
>
|
>
|
||||||
Add
|
Add
|
||||||
@@ -193,7 +265,7 @@ const Dashboard: React.FC = () => {
|
|||||||
{!isLoading && filteredAccounts.length === 0 && (
|
{!isLoading && filteredAccounts.length === 0 && (
|
||||||
<Box sx={{ width: '100%', mt: 10, textAlign: 'center' }}>
|
<Box sx={{ width: '100%', mt: 10, textAlign: 'center' }}>
|
||||||
<Typography variant="h6" color="textSecondary">
|
<Typography variant="h6" color="textSecondary">
|
||||||
No accounts tracked. Click "Add Account" to get started!
|
No accounts tracked. Click "Add" to get started!
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
@@ -234,14 +306,7 @@ const Dashboard: React.FC = () => {
|
|||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment: (
|
endAdornment: (
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
<Button
|
<Button variant="contained" size="small" onClick={saveSettings} sx={{ height: 30 }}>Apply</Button>
|
||||||
variant="contained"
|
|
||||||
size="small"
|
|
||||||
onClick={saveSettings}
|
|
||||||
sx={{ height: 30 }}
|
|
||||||
>
|
|
||||||
Apply
|
|
||||||
</Button>
|
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
@@ -297,61 +362,8 @@ const Dashboard: React.FC = () => {
|
|||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{/* Add Account Dialog */}
|
{/* Admin Panel */}
|
||||||
<Dialog open={isAddDialogOpen} onClose={() => setIsAddDialogOpen(false)} maxWidth="sm" fullWidth>
|
<AdminPanel open={isAdminPanelOpen} onClose={() => setIsAdminPanelOpen(false)} />
|
||||||
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary', p: 0 }}>
|
|
||||||
<Tabs value={addTab} onChange={(_, v) => setAddTab(v)} variant="fullWidth" textColor="inherit" indicatorColor="primary">
|
|
||||||
<Tab label="Manual Add" icon={<AddIcon />} iconPosition="start" />
|
|
||||||
<Tab label="From Community" icon={<PublicIcon />} iconPosition="start" disabled={!serverConfig?.token} />
|
|
||||||
</Tabs>
|
|
||||||
</DialogTitle>
|
|
||||||
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2, minHeight: 300 }}>
|
|
||||||
{addTab === 0 ? (
|
|
||||||
<>
|
|
||||||
<Typography variant="body2" color="textSecondary" sx={{ mb: 2 }}>
|
|
||||||
Enter a SteamID64 or Profile URL. You will need to authenticate to enable full tracking and instant login features.
|
|
||||||
</Typography>
|
|
||||||
<TextField
|
|
||||||
fullWidth
|
|
||||||
autoFocus
|
|
||||||
placeholder="SteamID64 or Profile URL"
|
|
||||||
value={identifier}
|
|
||||||
onChange={(e) => setIdentifier(e.target.value)}
|
|
||||||
sx={{ '& .MuiOutlinedInput-root': { backgroundColor: 'rgba(0, 0, 0, 0.1)' } }}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Box>
|
|
||||||
{isCommunityLoading ? (
|
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'center', p: 4 }}><CircularProgress size={32} /></Box>
|
|
||||||
) : (
|
|
||||||
<List>
|
|
||||||
{communityAccounts
|
|
||||||
.filter(ca => !safeAccounts.find(a => a.steamId === ca.steamId))
|
|
||||||
.map((ca) => (
|
|
||||||
<ListItem key={ca.steamId} divider sx={{ borderColor: 'divider' }}>
|
|
||||||
<Avatar src={ca.avatar} variant="square" sx={{ width: 32, height: 32, mr: 2 }} />
|
|
||||||
<ListItemText
|
|
||||||
primary={ca.personaName}
|
|
||||||
secondary={ca.steamId}
|
|
||||||
primaryTypographyProps={{ sx: { color: 'text.primary', fontWeight: 'bold' } }}
|
|
||||||
/>
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<Button size="small" variant="contained" onClick={() => handleAddFromCommunity(ca)}>Add</Button>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
{communityAccounts.length === 0 && <Typography align="center" color="textSecondary" sx={{ p: 4 }}>No shared accounts found on server.</Typography>}
|
|
||||||
</List>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}>
|
|
||||||
<Button onClick={() => setIsAddDialogOpen(false)} color="inherit">Cancel</Button>
|
|
||||||
{addTab === 0 && <Button onClick={handleAddAccount} variant="contained" color="success" disabled={!identifier}>Add</Button>}
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -364,21 +376,19 @@ 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, getServerUsers, serverConfig } = useAccounts();
|
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig, scrapeAccount } = 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;
|
||||||
const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now();
|
const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isCooldownActive || !cooldownDate) {
|
if (!isCooldownActive || !cooldownDate) { setTimeLeft(null); return; }
|
||||||
setTimeLeft(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const targetTime = cooldownDate.getTime();
|
const targetTime = cooldownDate.getTime();
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const diff = targetTime - Date.now();
|
const diff = targetTime - Date.now();
|
||||||
@@ -391,14 +401,15 @@ const AccountRow: React.FC<{
|
|||||||
return () => clearInterval(timer);
|
return () => clearInterval(timer);
|
||||||
}, [account?.cooldownExpiresAt, isCooldownActive]);
|
}, [account?.cooldownExpiresAt, isCooldownActive]);
|
||||||
|
|
||||||
const avatarSrc = account?.localAvatar
|
const avatarSrc = account?.localAvatar ? `steam-resource://${account.localAvatar}` : (account?.avatar || '');
|
||||||
? `steam-resource://${account.localAvatar}`
|
|
||||||
: (account?.avatar || '');
|
|
||||||
const [imgSrc, setImgSrc] = useState(avatarSrc);
|
const [imgSrc, setImgSrc] = useState(avatarSrc);
|
||||||
|
useEffect(() => { setImgSrc(avatarSrc); }, [avatarSrc]);
|
||||||
|
|
||||||
useEffect(() => {
|
const handleRefresh = async () => {
|
||||||
setImgSrc(avatarSrc);
|
setIsRefreshing(true);
|
||||||
}, [avatarSrc]);
|
await scrapeAccount(account.steamId);
|
||||||
|
setIsRefreshing(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleOpenShare = async () => {
|
const handleOpenShare = async () => {
|
||||||
setIsShareOpen(true);
|
setIsShareOpen(true);
|
||||||
@@ -408,8 +419,7 @@ 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 !== selfInfo.steamId && u.steamId !== account.steamId
|
||||||
u.steamId !== account.steamId
|
|
||||||
);
|
);
|
||||||
setServerUsers(filtered);
|
setServerUsers(filtered);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
@@ -420,130 +430,164 @@ const AccountRow: React.FC<{
|
|||||||
setIsSharing(true);
|
setIsSharing(true);
|
||||||
try {
|
try {
|
||||||
await shareAccountWithUser(account.steamId, targetUserId);
|
await shareAccountWithUser(account.steamId, targetUserId);
|
||||||
alert(`Account shared successfully!`);
|
|
||||||
setIsShareOpen(false);
|
|
||||||
setTargetUserId('');
|
setTargetUserId('');
|
||||||
} catch (e: any) {
|
} catch (e: any) { alert(e.message || "Failed to share account");
|
||||||
alert(e.message || "Failed to share account");
|
} finally { setIsSharing(false); }
|
||||||
} finally {
|
};
|
||||||
setIsSharing(false);
|
|
||||||
}
|
const handleRevoke = async (targetSteamId: string) => {
|
||||||
|
if (!window.confirm("Revoke access for this user?")) return;
|
||||||
|
try { await revokeAccountAccess(account.steamId, targetSteamId);
|
||||||
|
} catch (e: any) { alert(e.message); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRevokeAll = async () => {
|
||||||
|
if (!window.confirm("Completely stop sharing this account?")) return;
|
||||||
|
try { await revokeAllAccountAccess(account.steamId); setIsShareOpen(false);
|
||||||
|
} catch (e: any) { alert(e.message); }
|
||||||
};
|
};
|
||||||
|
|
||||||
const isBanned = account?.vacBanned || (account?.gameBans && account.gameBans > 0);
|
const isBanned = account?.vacBanned || (account?.gameBans && account.gameBans > 0);
|
||||||
const isShared = account?._id.startsWith('shared_');
|
|
||||||
|
// Primary account check
|
||||||
|
const isPrimaryAccount = serverConfig?.serverSteamId === account.steamId;
|
||||||
|
|
||||||
|
// Refined Shared Logic
|
||||||
|
const isSharedWithYou = account?._id.startsWith('shared_');
|
||||||
|
const hasSharedMembers = (account as any).sharedWith && (account as any).sharedWith.length > 0;
|
||||||
|
const showCommunityIcon = isSharedWithYou || hasSharedMembers;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow sx={{ '&:hover': { background: 'action.hover' }, borderBottom: '1px solid', borderColor: 'divider' }}>
|
<TableRow sx={{ '&:hover': { background: 'action.hover' }, borderBottom: '1px solid', borderColor: 'divider' }}>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Box sx={{ position: 'relative' }}>
|
<Box sx={{ position: 'relative' }}>
|
||||||
<Avatar src={imgSrc} variant="square" sx={{ width: 32, height: 32, border: '1px solid', borderColor: 'divider' }} />
|
<Avatar src={imgSrc} variant="square" sx={{ width: 32, height: 32, border: '1px solid', borderColor: 'divider' }} />
|
||||||
{isShared && (
|
{isPrimaryAccount && (
|
||||||
<Tooltip title="Community Shared Account">
|
<Tooltip title="Primary Community Account">
|
||||||
|
<WorkspacePremiumIcon sx={{ position: 'absolute', top: -8, left: -8, fontSize: 18, color: '#FFD700', filter: 'drop-shadow(0 0 2px rgba(0,0,0,0.5))' }} />
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
{showCommunityIcon && (
|
||||||
|
<Tooltip title={isSharedWithYou ? "Remote Shared Account" : "Actively Shared with Community"}>
|
||||||
<PeopleIcon sx={{ position: 'absolute', bottom: -4, right: -4, fontSize: 14, color: 'primary.main', bgcolor: 'background.default', borderRadius: '50%', border: '1px solid', borderColor: 'divider', p: 0.2 }} />
|
<PeopleIcon sx={{ position: 'absolute', bottom: -4, right: -4, fontSize: 14, color: 'primary.main', bgcolor: 'background.default', borderRadius: '50%', border: '1px solid', borderColor: 'divider', p: 0.2 }} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>
|
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>{account?.personaName || 'Unknown'}</Typography>
|
||||||
{account?.personaName || 'Unknown'}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>{account?.steamId}</Typography>
|
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>{account?.steamId}</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{isBanned ? (
|
{isBanned ? (
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'error.main' }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'error.main' }}>
|
||||||
<GppBadIcon sx={{ fontSize: 16 }} />
|
<GppBadIcon sx={{ fontSize: 16 }} /><Typography variant="caption" sx={{ fontWeight: 'bold' }}>BANNED</Typography>
|
||||||
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>ACCOUNT BANNED</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
||||||
{account?.vacBanned && (
|
{account?.vacBanned && <Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold' }} />}
|
||||||
<Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
|
{account?.gameBans ? account.gameBans > 0 && <Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold' }} /> : null}
|
||||||
)}
|
|
||||||
{account?.gameBans ? account.gameBans > 0 && (
|
|
||||||
<Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
|
|
||||||
) : null}
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'success.main' }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'success.main' }}>
|
||||||
<ShieldIcon sx={{ fontSize: 16 }} />
|
<ShieldIcon sx={{ fontSize: 16 }} /><Typography variant="caption" sx={{ fontWeight: 'bold' }}>SECURE</Typography>
|
||||||
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>SECURE</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{account?.authError ? (
|
{account?.authError ? (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', color: 'warning.main', gap: 0.5 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', color: 'warning.main', gap: 0.5 }}>
|
||||||
<LockResetIcon sx={{ fontSize: 16 }} />
|
<LockResetIcon sx={{ fontSize: 16 }} /><Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
|
||||||
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
) : isCooldownActive ? (
|
) : isCooldownActive ? (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', color: 'primary.main', gap: 0.5 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', color: 'primary.main', gap: 0.5 }}>
|
||||||
<TimerIcon sx={{ fontSize: 16 }} />
|
<TimerIcon sx={{ fontSize: 16 }} /><Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
|
||||||
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Typography variant="caption" sx={{ color: 'text.secondary' }}>Available</Typography>
|
<Typography variant="caption" sx={{ color: 'text.secondary' }}>Available</Typography>
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right">
|
<TableCell align="right">
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 0.5 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 0.5, alignItems: 'center' }}>
|
||||||
{account?.steamLoginSecure ? (
|
{account.loginName && (
|
||||||
<Button
|
<Button
|
||||||
variant="contained" size="small" onClick={() => onSwitch(account.loginName || '')}
|
variant="contained" size="small" onClick={() => onSwitch(account.loginName || '')}
|
||||||
sx={{ height: 28, fontSize: '0.7rem', bgcolor: 'secondary.main', '&:hover': { opacity: 0.9 } }}
|
sx={{ height: 28, fontSize: '0.7rem', bgcolor: 'secondary.main', '&:hover': { opacity: 0.9 }, minWidth: 60 }}
|
||||||
>
|
>LOGIN</Button>
|
||||||
LOGIN
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Button variant="outlined" size="small" onClick={onAuth} sx={{ height: 28, fontSize: '0.7rem' }}>AUTH</Button>
|
|
||||||
)}
|
)}
|
||||||
|
<Tooltip title={account.steamLoginSecure && !account.authError ? "Tracking active" : "Authenticate for cooldowns"}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
||||||
|
<IconButton
|
||||||
|
size="small" onClick={onAuth} disabled={!!(account.steamLoginSecure && !account.authError)}
|
||||||
|
sx={{
|
||||||
|
color: account.steamLoginSecure && !account.authError ? 'success.main' : (account.authError ? 'error.main' : 'warning.main'),
|
||||||
|
border: '1px solid', borderColor: account.steamLoginSecure && !account.authError ? 'success.main' : 'divider',
|
||||||
|
borderRadius: 1, background: account.steamLoginSecure && !account.authError ? 'rgba(163, 207, 6, 0.1)' : 'transparent'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
|
||||||
|
</IconButton>
|
||||||
|
{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>
|
||||||
|
<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>
|
||||||
|
</Tooltip>
|
||||||
|
<Divider orientation="vertical" flexItem sx={{ mx: 0.5, my: 0.5 }} />
|
||||||
<IconButton size="small" onClick={handleOpenShare} disabled={!serverConfig?.token}><ShareIcon fontSize="inherit" sx={{ color: 'primary.main' }}/></IconButton>
|
<IconButton size="small" onClick={handleOpenShare} disabled={!serverConfig?.token}><ShareIcon fontSize="inherit" sx={{ color: 'primary.main' }}/></IconButton>
|
||||||
<IconButton size="small" sx={{ color: 'text.secondary' }} onClick={() => (window as any).electronAPI.openExternal(account?.profileUrl || '')}><OpenInNewIcon fontSize="inherit"/></IconButton>
|
<IconButton size="small" sx={{ color: 'text.secondary' }} onClick={() => (window as any).electronAPI.openExternal(account?.profileUrl || '')}><OpenInNewIcon fontSize="inherit"/></IconButton>
|
||||||
<IconButton size="small" sx={{ color: 'error.main' }} onClick={() => onDelete(account?._id || '')}><DeleteIcon fontSize="inherit"/></IconButton>
|
<IconButton size="small" sx={{ color: 'error.main' }} onClick={() => onDelete(account?._id || '')}><DeleteIcon fontSize="inherit"/></IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* Share Dialog */}
|
|
||||||
<Dialog open={isShareOpen} onClose={() => setIsShareOpen(false)} maxWidth="xs" fullWidth>
|
<Dialog open={isShareOpen} onClose={() => setIsShareOpen(false)} maxWidth="xs" fullWidth>
|
||||||
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Share Account</DialogTitle>
|
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Permissions</DialogTitle>
|
||||||
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2 }}>
|
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2 }}>
|
||||||
<Typography variant="body2" sx={{ mb: 2 }}>
|
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>GRANT ACCESS</Typography>
|
||||||
Select a community member to share this account with.
|
<Box sx={{ display: 'flex', gap: 1, mb: 3 }}>
|
||||||
</Typography>
|
<FormControl fullWidth size="small">
|
||||||
<FormControl fullWidth size="small" sx={{ mt: 1 }}>
|
<InputLabel sx={{ color: 'text.secondary' }}>Select User</InputLabel>
|
||||||
<InputLabel sx={{ color: 'text.secondary' }}>Select User</InputLabel>
|
<Select
|
||||||
<Select
|
value={targetUserId} label="Select User" onChange={(e) => setTargetUserId(e.target.value as string)}
|
||||||
value={targetUserId}
|
sx={{ bgcolor: 'rgba(0,0,0,0.1)', color: 'text.primary' }}
|
||||||
label="Select User"
|
>
|
||||||
onChange={(e) => setTargetUserId(e.target.value as string)}
|
{serverUsers
|
||||||
sx={{ bgcolor: 'rgba(0,0,0,0.1)', color: 'text.primary' }}
|
.filter(u => !(account as any).sharedWith?.find((sw: any) => sw.steamId === u.steamId))
|
||||||
>
|
.map(user => (
|
||||||
{serverUsers.map(user => (
|
<MenuItem key={user.steamId} value={user.steamId}>
|
||||||
<MenuItem key={user.steamId} value={user.steamId}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}><Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />{user.personaName}</Box>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
</MenuItem>
|
||||||
<Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />
|
))}
|
||||||
{user.personaName}
|
{serverUsers.length === 0 && <MenuItem disabled>No eligible users found</MenuItem>}
|
||||||
</Box>
|
</Select>
|
||||||
</MenuItem>
|
</FormControl>
|
||||||
))}
|
<Button onClick={handleShare} variant="contained" disabled={!targetUserId || isSharing} sx={{ minWidth: 80 }}>{isSharing ? <CircularProgress size={16} color="inherit" /> : "Add"}</Button>
|
||||||
{serverUsers.length === 0 && <MenuItem disabled>No users found on server</MenuItem>}
|
</Box>
|
||||||
</Select>
|
<Divider sx={{ my: 2, borderColor: 'divider' }} />
|
||||||
</FormControl>
|
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>CURRENT ACCESS</Typography>
|
||||||
|
<List size="small" sx={{ bgcolor: 'rgba(0,0,0,0.05)', borderRadius: 1, mb: 2 }}>
|
||||||
|
{(account as any).sharedWith?.map((sw: any) => (
|
||||||
|
<ListItem key={sw.steamId} dense divider sx={{ borderColor: 'divider' }}>
|
||||||
|
<Avatar src={sw.avatar} sx={{ width: 24, height: 24, mr: 1 }} />
|
||||||
|
<ListItemText primary={sw.personaName} primaryTypographyProps={{ variant: 'body2', sx: { fontWeight: 'bold' } }} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<IconButton size="small" color="error" onClick={() => handleRevoke(sw.steamId)}><DeleteIcon fontSize="inherit" /></IconButton>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
{(!(account as any).sharedWith || (account as any).sharedWith.length === 0) && (
|
||||||
|
<Typography variant="caption" align="center" sx={{ display: 'block', p: 2, opacity: 0.6 }}>Not shared with anyone yet.</Typography>
|
||||||
|
)}
|
||||||
|
</List>
|
||||||
|
{(account as any).sharedWith?.length > 0 && (
|
||||||
|
<Button fullWidth variant="outlined" color="error" size="small" onClick={handleRevokeAll} startIcon={<GppBadIcon />}>Revoke All Shared Access</Button>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}>
|
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}><Button onClick={() => setIsShareOpen(false)} color="inherit" variant="contained">Done</Button></DialogActions>
|
||||||
<Button onClick={() => setIsShareOpen(false)} color="inherit" disabled={isSharing}>Cancel</Button>
|
|
||||||
<Button
|
|
||||||
onClick={handleShare}
|
|
||||||
variant="contained"
|
|
||||||
startIcon={isSharing ? <CircularProgress size={16} color="inherit" /> : <GroupAddIcon />}
|
|
||||||
disabled={!targetUserId || isSharing}
|
|
||||||
>
|
|
||||||
{isSharing ? "Sharing..." : "Grant Access"}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
234
frontend/src/pages/DashboardRow.tsx
Normal file
234
frontend/src/pages/DashboardRow.tsx
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
const AccountRow: React.FC<{
|
||||||
|
account: Account,
|
||||||
|
onDelete: (id: string) => void,
|
||||||
|
onSwitch: (login: string) => void,
|
||||||
|
onAuth: () => void
|
||||||
|
}> = ({ account, onDelete, onSwitch, onAuth }) => {
|
||||||
|
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig } = useAccounts();
|
||||||
|
const [timeLeft, setTimeLeft] = useState<string | null>(null);
|
||||||
|
const [isShareOpen, setIsShareOpen] = useState(false);
|
||||||
|
const [targetUserId, setTargetUserId] = useState('');
|
||||||
|
const [isSharing, setIsSharing] = useState(false);
|
||||||
|
const [serverUsers, setServerUsers] = useState<any[]>([]);
|
||||||
|
|
||||||
|
const cooldownDate = account?.cooldownExpiresAt ? new Date(account.cooldownExpiresAt) : null;
|
||||||
|
const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isCooldownActive || !cooldownDate) {
|
||||||
|
setTimeLeft(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const targetTime = cooldownDate.getTime();
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
const diff = targetTime - Date.now();
|
||||||
|
if (diff <= 0) { setTimeLeft(null); clearInterval(timer); return; }
|
||||||
|
const hours = Math.floor(diff / 3600000);
|
||||||
|
const mins = Math.floor((diff % 3600000) / 60000);
|
||||||
|
const secs = Math.floor((diff % 60000) / 1000);
|
||||||
|
setTimeLeft(`${hours}h ${mins}m ${secs}s`);
|
||||||
|
}, 1000);
|
||||||
|
return () => clearInterval(timer);
|
||||||
|
}, [account?.cooldownExpiresAt, isCooldownActive]);
|
||||||
|
|
||||||
|
const avatarSrc = account?.localAvatar
|
||||||
|
? `steam-resource://${account.localAvatar}`
|
||||||
|
: (account?.avatar || '');
|
||||||
|
const [imgSrc, setImgSrc] = useState(avatarSrc);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setImgSrc(avatarSrc);
|
||||||
|
}, [avatarSrc]);
|
||||||
|
|
||||||
|
const handleOpenShare = async () => {
|
||||||
|
setIsShareOpen(true);
|
||||||
|
try {
|
||||||
|
const [users, selfInfo] = await Promise.all([
|
||||||
|
getServerUsers(),
|
||||||
|
(window as any).electronAPI.getServerUserInfo()
|
||||||
|
]);
|
||||||
|
const filtered = (Array.isArray(users) ? users : []).filter(u =>
|
||||||
|
u.steamId !== selfInfo.steamId &&
|
||||||
|
u.steamId !== account.steamId
|
||||||
|
);
|
||||||
|
setServerUsers(filtered);
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleShare = async () => {
|
||||||
|
if (!targetUserId) return;
|
||||||
|
setIsSharing(true);
|
||||||
|
try {
|
||||||
|
await shareAccountWithUser(account.steamId, targetUserId);
|
||||||
|
setTargetUserId('');
|
||||||
|
} catch (e: any) {
|
||||||
|
alert(e.message || "Failed to share account");
|
||||||
|
} finally {
|
||||||
|
setIsSharing(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRevoke = async (targetSteamId: string) => {
|
||||||
|
if (!window.confirm("Revoke access for this user?")) return;
|
||||||
|
try {
|
||||||
|
await revokeAccountAccess(account.steamId, targetSteamId);
|
||||||
|
} catch (e: any) { alert(e.message); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRevokeAll = async () => {
|
||||||
|
if (!window.confirm("Completely stop sharing this account with the community?")) return;
|
||||||
|
try {
|
||||||
|
await revokeAllAccountAccess(account.steamId);
|
||||||
|
setIsShareOpen(false);
|
||||||
|
} catch (e: any) { alert(e.message); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const isBanned = account?.vacBanned || (account?.gameBans && account.gameBans > 0);
|
||||||
|
const isShared = account?._id.startsWith('shared_');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableRow sx={{ '&:hover': { background: 'action.hover' }, borderBottom: '1px solid', borderColor: 'divider' }}>
|
||||||
|
<TableCell>
|
||||||
|
<Box sx={{ position: 'relative' }}>
|
||||||
|
<Avatar src={imgSrc} variant="square" sx={{ width: 32, height: 32, border: '1px solid', borderColor: 'divider' }} />
|
||||||
|
{isShared && (
|
||||||
|
<Tooltip title="Community Shared Account">
|
||||||
|
<PeopleIcon sx={{ position: 'absolute', bottom: -4, right: -4, fontSize: 14, color: 'primary.main', bgcolor: 'background.default', borderRadius: '50%', border: '1px solid', borderColor: 'divider', p: 0.2 }} />
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>
|
||||||
|
{account?.personaName || 'Unknown'}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>{account?.steamId}</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{isBanned ? (
|
||||||
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'error.main' }}>
|
||||||
|
<GppBadIcon sx={{ fontSize: 16 }} />
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>ACCOUNT BANNED</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
||||||
|
{account?.vacBanned && (
|
||||||
|
<Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
|
||||||
|
)}
|
||||||
|
{account?.gameBans ? account.gameBans > 0 && (
|
||||||
|
<Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
|
||||||
|
) : null}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'success.main' }}>
|
||||||
|
<ShieldIcon sx={{ fontSize: 16 }} />
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>SECURE</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{account?.authError ? (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', color: 'warning.main', gap: 0.5 }}>
|
||||||
|
<LockResetIcon sx={{ fontSize: 16 }} />
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
|
||||||
|
</Box>
|
||||||
|
) : isCooldownActive ? (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', color: 'primary.main', gap: 0.5 }}>
|
||||||
|
<TimerIcon sx={{ fontSize: 16 }} />
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Typography variant="caption" sx={{ color: 'text.secondary' }}>Available</Typography>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="right">
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 0.5, alignItems: 'center' }}>
|
||||||
|
{account.loginName && (
|
||||||
|
<Button
|
||||||
|
variant="contained" size="small" onClick={() => onSwitch(account.loginName || '')}
|
||||||
|
sx={{ height: 28, fontSize: '0.7rem', bgcolor: 'secondary.main', '&:hover': { opacity: 0.9 }, minWidth: 60 }}
|
||||||
|
>
|
||||||
|
LOGIN
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Tooltip title={account.steamLoginSecure && !account.authError ? "Session valid - Tracking active" : (account.steamLoginSecure ? "Refresh scraper session" : "Authenticate for cooldown tracking")}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
||||||
|
<IconButton
|
||||||
|
size="small" onClick={onAuth}
|
||||||
|
disabled={!!(account.steamLoginSecure && !account.authError)}
|
||||||
|
sx={{
|
||||||
|
color: account.steamLoginSecure && !account.authError ? 'success.main' : (account.authError ? 'error.main' : 'warning.main'),
|
||||||
|
border: '1px solid', borderColor: account.steamLoginSecure && !account.authError ? 'success.main' : 'divider',
|
||||||
|
borderRadius: 1, background: account.steamLoginSecure && !account.authError ? 'rgba(163, 207, 6, 0.1)' : 'transparent'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
|
||||||
|
</IconButton>
|
||||||
|
{account.steamLoginSecure && !account.authError && (
|
||||||
|
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem', letterSpacing: '0.5px' }}>
|
||||||
|
TRACKING
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Divider orientation="vertical" flexItem sx={{ mx: 0.5, my: 0.5 }} />
|
||||||
|
|
||||||
|
<IconButton size="small" onClick={handleOpenShare} disabled={!serverConfig?.token}><ShareIcon fontSize="inherit" sx={{ color: 'primary.main' }}/></IconButton>
|
||||||
|
<IconButton size="small" sx={{ color: 'text.secondary' }} onClick={() => (window as any).electronAPI.openExternal(account?.profileUrl || '')}><OpenInNewIcon fontSize="inherit"/></IconButton>
|
||||||
|
<IconButton size="small" sx={{ color: 'error.main' }} onClick={() => onDelete(account?._id || '')}><DeleteIcon fontSize="inherit"/></IconButton>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Dialog open={isShareOpen} onClose={() => setIsShareOpen(false)} maxWidth="xs" fullWidth>
|
||||||
|
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Account Permissions</DialogTitle>
|
||||||
|
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2 }}>
|
||||||
|
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>GRANT ACCESS</Typography>
|
||||||
|
<Box sx={{ display: 'flex', gap: 1, mb: 3 }}>
|
||||||
|
<FormControl fullWidth size="small">
|
||||||
|
<InputLabel sx={{ color: 'text.secondary' }}>Select User</InputLabel>
|
||||||
|
<Select
|
||||||
|
value={targetUserId} label="Select User" onChange={(e) => setTargetUserId(e.target.value as string)}
|
||||||
|
sx={{ bgcolor: 'rgba(0,0,0,0.1)', color: 'text.primary' }}
|
||||||
|
>
|
||||||
|
{serverUsers
|
||||||
|
.filter(u => !(account as any).sharedWith?.find((sw: any) => sw.steamId === u.steamId))
|
||||||
|
.map(user => (
|
||||||
|
<MenuItem key={user.steamId} value={user.steamId}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}><Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />{user.personaName}</Box>
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
{serverUsers.length === 0 && <MenuItem disabled>No eligible users found</MenuItem>}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
<Button onClick={handleShare} variant="contained" disabled={!targetUserId || isSharing} sx={{ minWidth: 80 }}>
|
||||||
|
{isSharing ? <CircularProgress size={16} color="inherit" /> : "Add"}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Divider sx={{ my: 2, borderColor: 'divider' }} />
|
||||||
|
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>CURRENT ACCESS</Typography>
|
||||||
|
<List size="small" sx={{ bgcolor: 'rgba(0,0,0,0.05)', borderRadius: 1, mb: 2 }}>
|
||||||
|
{(account as any).sharedWith?.map((sw: any) => (
|
||||||
|
<ListItem key={sw.steamId} dense divider sx={{ borderColor: 'divider' }}>
|
||||||
|
<Avatar src={sw.avatar} sx={{ width: 24, height: 24, mr: 1 }} />
|
||||||
|
<ListItemText primary={sw.personaName} primaryTypographyProps={{ variant: 'body2', sx: { fontWeight: 'bold' } }} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<IconButton size="small" color="error" onClick={() => handleRevoke(sw.steamId)}><DeleteIcon fontSize="inherit" /></IconButton>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
{(!(account as any).sharedWith || (account as any).sharedWith.length === 0) && (
|
||||||
|
<Typography variant="caption" align="center" sx={{ display: 'block', p: 2, opacity: 0.6 }}>Not shared with anyone yet.</Typography>
|
||||||
|
)}
|
||||||
|
</List>
|
||||||
|
{(account as any).sharedWith?.length > 0 && (
|
||||||
|
<Button fullWidth variant="outlined" color="error" size="small" onClick={handleRevokeAll} startIcon={<GppBadIcon />}>Revoke All Shared Access</Button>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}><Button onClick={() => setIsShareOpen(false)} color="inherit" variant="contained">Done</Button></DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user