mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 499956d3b3 | |||
| c313685f6f |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bs-manager",
|
"name": "bs-manager",
|
||||||
"version": "1.4.7",
|
"version": "1.4.8",
|
||||||
"description": "BSManager",
|
"description": "BSManager",
|
||||||
"main": "./dist/main/main.js",
|
"main": "./dist/main/main.js",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
+134
-11
@@ -21,16 +21,20 @@ import { BSLauncherService } from "./services/bs-launcher/bs-launcher.service";
|
|||||||
import { IpcRequest } from "shared/models/ipc";
|
import { IpcRequest } from "shared/models/ipc";
|
||||||
import { LivShortcut } from "./services/liv/liv-shortcut.service";
|
import { LivShortcut } from "./services/liv/liv-shortcut.service";
|
||||||
import { SteamLauncherService } from "./services/bs-launcher/steam-launcher.service";
|
import { SteamLauncherService } from "./services/bs-launcher/steam-launcher.service";
|
||||||
|
import { readdirSync, statSync, unlinkSync } from "fs-extra";
|
||||||
|
|
||||||
|
export const filterStrings = new Set<string>();
|
||||||
|
export const filterPatterns = new Set<RegExp>();
|
||||||
|
|
||||||
const isDebug = process.env.NODE_ENV === "development" || process.env.DEBUG_PROD === "true";
|
const isDebug = process.env.NODE_ENV === "development" || process.env.DEBUG_PROD === "true";
|
||||||
|
|
||||||
log.transports.file.level = "info";
|
// Filter all occulus tokens
|
||||||
log.transports.file.resolvePath = () => {
|
filterPatterns.add(/FRL\S{10,}/g);
|
||||||
const now = new Date();
|
|
||||||
return path.join(app.getPath("logs"), `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}-v${app.getVersion()}.log`);
|
initLogger();
|
||||||
};
|
deleteOlestLogs();
|
||||||
|
deleteOldLogs();
|
||||||
|
|
||||||
log.catchErrors();
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
const sourceMapSupport = require("source-map-support");
|
const sourceMapSupport = require("source-map-support");
|
||||||
@@ -90,11 +94,11 @@ if (!gotTheLock) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
|
||||||
app.setAppUserModelId(APP_NAME);
|
app.setAppUserModelId(APP_NAME);
|
||||||
|
|
||||||
initServicesMustBeInitialized();
|
initServicesMustBeInitialized();
|
||||||
|
|
||||||
const deepLink = process.argv.find(arg => DeepLinkService.getInstance().isDeepLink(arg));
|
const deepLink = process.argv.find(arg => DeepLinkService.getInstance().isDeepLink(arg));
|
||||||
|
|
||||||
if (!deepLink) {
|
if (!deepLink) {
|
||||||
@@ -102,13 +106,132 @@ if (!gotTheLock) {
|
|||||||
} else {
|
} else {
|
||||||
DeepLinkService.getInstance().dispatchLinkOpened(deepLink);
|
DeepLinkService.getInstance().dispatchLinkOpened(deepLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamLauncherService.getInstance().restoreSteamVR();
|
SteamLauncherService.getInstance().restoreSteamVR();
|
||||||
|
|
||||||
// Log renderer errors
|
// Log renderer errors
|
||||||
ipcMain.on("log-error", (_, args: IpcRequest<unknown>) => {
|
ipcMain.on("log-error", (_, args: IpcRequest<unknown>) => {
|
||||||
log.error(args?.args);
|
log.error(args?.args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on("add-filter-string", (_, args: IpcRequest<string>) => {
|
||||||
|
filterStrings.add(args?.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on("add-filter-pattern", (_, args: IpcRequest<string>) => {
|
||||||
|
filterPatterns.add(new RegExp(args?.args));
|
||||||
|
});
|
||||||
|
|
||||||
}).catch(log.error);
|
}).catch(log.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initLogger(){
|
||||||
|
log.transports.file.level = "info";
|
||||||
|
log.transports.file.resolvePath = () => {
|
||||||
|
const now = new Date();
|
||||||
|
return path.join(app.getPath("logs"), `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}-v${app.getVersion()}.log`);
|
||||||
|
};
|
||||||
|
|
||||||
|
log.hooks.push((message) => {
|
||||||
|
|
||||||
|
const filterMessage = (filter: string|RegExp, ...param: unknown[]): unknown[] => {
|
||||||
|
return param.map(data => {
|
||||||
|
|
||||||
|
if(typeof data === "string"){
|
||||||
|
return data.replaceAll(filter, "****");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data instanceof Error){
|
||||||
|
data.message = data.message?.replaceAll(filter, "****");
|
||||||
|
data.stack = data.stack?.replaceAll(filter, "****");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data instanceof Array){
|
||||||
|
return filterMessage(filter, ...data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
filterStrings.forEach(filter => {
|
||||||
|
if(filter && message.data.length){
|
||||||
|
message.data = filterMessage(filter, ...message.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
filterPatterns.forEach(filter => {
|
||||||
|
if(filter && message.data.length){
|
||||||
|
message.data = filterMessage(filter, ...message.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return message;
|
||||||
|
});
|
||||||
|
|
||||||
|
log.catchErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogFilesEntries() {
|
||||||
|
try {
|
||||||
|
const logsFolder = app.getPath("logs");
|
||||||
|
let logs = readdirSync(logsFolder, { withFileTypes: true });
|
||||||
|
|
||||||
|
logs = logs.filter(file => file.isFile() && path.extname(file.name) === ".log");
|
||||||
|
|
||||||
|
logs.sort((a, b) => {
|
||||||
|
const aStat = statSync(path.join(logsFolder, a.name));
|
||||||
|
const bStat = statSync(path.join(logsFolder, b.name));
|
||||||
|
return bStat.mtime.getTime() - aStat.mtime.getTime();
|
||||||
|
});
|
||||||
|
|
||||||
|
return logs.map(file => {
|
||||||
|
const filePath = path.join(logsFolder, file.name);
|
||||||
|
const stat = statSync(filePath);
|
||||||
|
return {
|
||||||
|
path: filePath,
|
||||||
|
name: file.name,
|
||||||
|
stats: stat
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
log.error('Error while retrieving log files entries:', err);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep only the last 5 logs
|
||||||
|
function deleteOldLogs(): void{
|
||||||
|
try {
|
||||||
|
let logs = getLogFilesEntries();
|
||||||
|
|
||||||
|
logs = logs.slice(5);
|
||||||
|
|
||||||
|
logs.forEach(file => {
|
||||||
|
try {
|
||||||
|
unlinkSync(file.path);
|
||||||
|
log.info(`Deleted log file: ${file.path}`);
|
||||||
|
} catch (err) {
|
||||||
|
log.error(`Error deleting file ${file.path}:`, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
log.error("Error while deleting old logs:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporary function to delete logs before 2024-07-31
|
||||||
|
function deleteOlestLogs(): void{
|
||||||
|
// delete all logs before 2024-07-31
|
||||||
|
const date = new Date(2024, 6, 31); // month is 0-based
|
||||||
|
const logs = getLogFilesEntries().filter(file => file.stats.mtime.getTime() < date.getTime());
|
||||||
|
|
||||||
|
logs.forEach(file => {
|
||||||
|
try {
|
||||||
|
unlinkSync(file.path);
|
||||||
|
log.info(`Deleted log file: ${file.path}`);
|
||||||
|
} catch (err) {
|
||||||
|
log.error(`Error deleting file ${file.path}:`, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ export const EnterMetaTokenModal: ModalComponent<string> = ({resolver}) => {
|
|||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
resolver({exitCode: ModalExitCode.CANCELED});
|
resolver({exitCode: ModalExitCode.CANCELED});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="flex flex-col w-80 gap-4">
|
<form className="flex flex-col w-80 gap-4">
|
||||||
<h1 className="text-3xl uppercase tracking-wide w-full text-center">{t("modals.enter-meta-token.title")}</h1>
|
<h1 className="text-3xl uppercase tracking-wide w-full text-center">{t("modals.enter-meta-token.title")}</h1>
|
||||||
@@ -205,7 +205,7 @@ const PasswordInput = ({onChange, value}: {onChange: (value : {password: string,
|
|||||||
<input className="grow px-1 py-[2px] outline-none bg-transparent" onChange={e => onChange({password: e.target.value, valid: isPasswordValid(e.target.value)})} value={value} type={showPassword ? "text" : "password"} name="password" id="password" placeholder={t("modals.enter-meta-token.body.password")} />
|
<input className="grow px-1 py-[2px] outline-none bg-transparent" onChange={e => onChange({password: e.target.value, valid: isPasswordValid(e.target.value)})} value={value} type={showPassword ? "text" : "password"} name="password" id="password" placeholder={t("modals.enter-meta-token.body.password")} />
|
||||||
<BsmButton className="shrink-0 m-1 rounded-md p-0.5 !bg-light-main-color-3 dark:!bg-main-color-3" icon={showPassword ? "eye-cross" : "eye"} withBar={false} onClick={() => setShowPassword(prev => !prev)} />
|
<BsmButton className="shrink-0 m-1 rounded-md p-0.5 !bg-light-main-color-3 dark:!bg-main-color-3" icon={showPassword ? "eye-cross" : "eye"} withBar={false} onClick={() => setShowPassword(prev => !prev)} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,12 @@ export function logRenderError(...params: unknown[]){
|
|||||||
ipc.sendLazy("log-error", { args: params });
|
ipc.sendLazy("log-error", { args: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addFilterStringLog(str: string){
|
||||||
|
ipc.sendLazy("add-filter-string", { args: str });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addFilterPatternLog(pattern: string){
|
||||||
|
ipc.sendLazy("add-filter-pattern", { args: pattern });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { AbstractBsDownloaderService } from "./abstract-bs-downloader.service";
|
|||||||
import { DownloadInfo } from "main/services/bs-version-download/bs-steam-downloader.service";
|
import { DownloadInfo } from "main/services/bs-version-download/bs-steam-downloader.service";
|
||||||
import { MetaAuthErrorCodes, OculusDownloaderErrorCodes } from "shared/models/bs-version-download/oculus-download.model";
|
import { MetaAuthErrorCodes, OculusDownloaderErrorCodes } from "shared/models/bs-version-download/oculus-download.model";
|
||||||
import { EnterMetaTokenModal } from "renderer/components/modal/modal-types/bs-downgrade/enter-meta-token-modal.component";
|
import { EnterMetaTokenModal } from "renderer/components/modal/modal-types/bs-downgrade/enter-meta-token-modal.component";
|
||||||
|
import { addFilterStringLog } from "renderer";
|
||||||
|
|
||||||
export class OculusDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
|
export class OculusDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
|
||||||
|
|
||||||
@@ -88,6 +89,8 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addFilterStringLog(tokenRes.data);
|
||||||
|
|
||||||
return lastValueFrom(this.startDownloadBsVersion({ bsVersion, isVerification, token: tokenRes.data })).then(() => true);
|
return lastValueFrom(this.startDownloadBsVersion({ bsVersion, isVerification, token: tokenRes.data })).then(() => true);
|
||||||
|
|
||||||
})().then(res => {
|
})().then(res => {
|
||||||
@@ -126,4 +129,4 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
|
|||||||
return lastValueFrom(this.ipc.sendV2<void>("bs-oculus-clear-auth-token"));
|
return lastValueFrom(this.ipc.sendV2<void>("bs-oculus-clear-auth-token"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ import { DepotDownloaderErrorEvent, DepotDownloaderEvent, DepotDownloaderEventTy
|
|||||||
import { SteamMobileApproveModal } from "renderer/components/modal/modal-types/bs-downgrade/steam-mobile-approve-modal.component";
|
import { SteamMobileApproveModal } from "renderer/components/modal/modal-types/bs-downgrade/steam-mobile-approve-modal.component";
|
||||||
import { DownloaderServiceInterface } from "./bs-store-downloader.interface";
|
import { DownloaderServiceInterface } from "./bs-store-downloader.interface";
|
||||||
import { AbstractBsDownloaderService } from "./abstract-bs-downloader.service";
|
import { AbstractBsDownloaderService } from "./abstract-bs-downloader.service";
|
||||||
|
import { addFilterStringLog } from "renderer";
|
||||||
|
|
||||||
export class SteamDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
|
export class SteamDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
|
||||||
|
|
||||||
private static instance: SteamDownloaderService;
|
private static instance: SteamDownloaderService;
|
||||||
|
|
||||||
public static getInstance(): SteamDownloaderService {
|
public static getInstance(): SteamDownloaderService {
|
||||||
@@ -128,7 +129,7 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
|
|||||||
return this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.verification-finished"});
|
return this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.verification-finished"});
|
||||||
}
|
}
|
||||||
return this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.download-success"});
|
return this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.download-success"});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
@@ -182,7 +183,7 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
|
|||||||
}),
|
}),
|
||||||
share({connector: () => new ReplaySubject(1)})
|
share({connector: () => new ReplaySubject(1)})
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private tryAutoDownloadBsVersion(downloadInfo: DownloadSteamInfo){
|
private tryAutoDownloadBsVersion(downloadInfo: DownloadSteamInfo){
|
||||||
@@ -217,7 +218,7 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.progressBarService.show(this.downloadProgress$, true);
|
this.progressBarService.show(this.downloadProgress$, true);
|
||||||
|
|
||||||
const downloadPromise = (async () => {
|
const downloadPromise = (async () => {
|
||||||
|
|
||||||
const haveDotNet = await this.isDotNet6Installed().catch(() => false);
|
const haveDotNet = await this.isDotNet6Installed().catch(() => false);
|
||||||
@@ -227,9 +228,9 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
const downloadInfo: DownloadSteamInfo = {bsVersion, isVerification}
|
const downloadInfo: DownloadSteamInfo = {bsVersion, isVerification}
|
||||||
|
|
||||||
const autoDownload = await lastValueFrom(this.tryAutoDownloadBsVersion(downloadInfo)).then(() => true).catch(() => false);
|
const autoDownload = await lastValueFrom(this.tryAutoDownloadBsVersion(downloadInfo)).then(() => true).catch(() => false);
|
||||||
|
|
||||||
if(autoDownload){ return Promise.resolve(); }
|
if(autoDownload){ return Promise.resolve(); }
|
||||||
|
|
||||||
const qrCodeDownload$ = this.startQrCodeDownload(downloadInfo);
|
const qrCodeDownload$ = this.startQrCodeDownload(downloadInfo);
|
||||||
@@ -242,6 +243,10 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(loginRes?.data?.password){
|
||||||
|
addFilterStringLog(loginRes.data.password);
|
||||||
|
}
|
||||||
|
|
||||||
if(loginRes.data.stay){
|
if(loginRes.data.stay){
|
||||||
this.setSteamSession(loginRes.data.username);
|
this.setSteamSession(loginRes.data.username);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user