diff --git a/assets/depot-downloader/DepotDownloader.dll b/assets/depot-downloader/DepotDownloader.dll index 93041c37..77ef040d 100644 Binary files a/assets/depot-downloader/DepotDownloader.dll and b/assets/depot-downloader/DepotDownloader.dll differ diff --git a/assets/depot-downloader/DepotDownloader.exe b/assets/depot-downloader/DepotDownloader.exe index f0a7af47..85080ee8 100644 Binary files a/assets/depot-downloader/DepotDownloader.exe and b/assets/depot-downloader/DepotDownloader.exe differ diff --git a/assets/depot-downloader/DepotDownloader.pdb b/assets/depot-downloader/DepotDownloader.pdb index 7639db06..76d32ddb 100644 Binary files a/assets/depot-downloader/DepotDownloader.pdb and b/assets/depot-downloader/DepotDownloader.pdb differ diff --git a/assets/depot-downloader/ref/DepotDownloader.dll b/assets/depot-downloader/ref/DepotDownloader.dll new file mode 100644 index 00000000..74206ceb Binary files /dev/null and b/assets/depot-downloader/ref/DepotDownloader.dll differ diff --git a/src/main/ipcs/bs-download-ipcs.ts b/src/main/ipcs/bs-download-ipcs.ts index 907f4049..009624c6 100644 --- a/src/main/ipcs/bs-download-ipcs.ts +++ b/src/main/ipcs/bs-download-ipcs.ts @@ -3,7 +3,7 @@ import path from 'path'; import { ChildProcessWithoutNullStreams, spawn } from 'child_process'; import { UtilsService } from '../services/utils.service'; import { BSVersion } from '../services/bs-version-manager.service'; -import { BSInstallerService } from '../services/bs-installer.service'; +import { BSInstallerService, DownloadEventType } from '../services/bs-installer.service'; export interface InitDownloadInfoInterface { @@ -23,36 +23,12 @@ export interface DownloadInfo { stay?: boolean } -const DEPOT_DOWNLOADER_EXE = 'DepotDownloader.exe'; - -let PROCESS: ChildProcessWithoutNullStreams; - ipcMain.on('bs-download.start', async (event, args: DownloadInfo) => { BSInstallerService.getInstance().downloadBsVersion(args); - return; - const DEPOT_DOWNLOADER_PATH = path.join(UtilsService.getInstance().getAssetsPath(), 'depot-downloader', DEPOT_DOWNLOADER_EXE); - console.log(UtilsService.getInstance().getAssetsPath()); - console.log(DEPOT_DOWNLOADER_PATH); - console.log(args.cwd); - UtilsService.getInstance().createFolderIfNotExist(args.cwd); - PROCESS = spawn(DEPOT_DOWNLOADER_PATH, [`-app ${args.app}`, `-depot ${args.depot}`, `-manifest ${args.manifest}`, `-username ${args.username}`, `-dir ${args.folder}`, args.stay ? `-remember-password` : ''], {shell: true, cwd: args.cwd}); - - PROCESS.stdout.on('data', data => { - - const out: string[] = data.toString().split('|'); - console.log(out); - - if(out[0] === "[Progress]"){ event.reply('bs-download.progress', out[1]); } - else if(out[0] === "[Password]"){ event.reply('bs-download.not-connected', args.bsVersion); PROCESS.kill(); } - else if(out[0] === "[2FA]"){ event.reply('bs-download.ask-2fa'); } - else if(out[0] === "[Guard]"){ event.reply('bs-download.ask-guard'); } - else if(out[0] === "[Error]"){ event.reply('bs-download.error', out); } - - }); - - PROCESS.stderr.on('data', (data) => {console.log(data.toString())}); }); -ipcMain.on('bs-download.enter-password', async (event, value: string) => { - if(PROCESS){ PROCESS.stdin.write(`${value}\n`); } -}); +ipcMain.on(`bs-download${DownloadEventType.GUARD_CODE}`, async (event, args) => { + BSInstallerService.getInstance().sendInputProcess(args); +}) + + diff --git a/src/main/preload.ts b/src/main/preload.ts index c3e2037a..69143b69 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -1,8 +1,6 @@ import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron'; -export type Channels = 'bs-download.start'|'bs-download.send-input'|'window.close'|'window.maximize'|'window.minimize'|'window.reset'; - -export type ReplyChannels = 'bs-download.ask-password'; +export type Channels = any; contextBridge.exposeInMainWorld('electron', { ipcRenderer: { diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index ff46f71b..47751f3a 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -91,13 +91,17 @@ export class BSInstallerService{ this.downloadProcess.stdout.on('data', (data) => { console.log(data.toString()); const out = (data.toString() as string).split("|"); - if(out[0] === DownloadEventType.NOT_LOGGED_IN && downloadInfos.password){ this.sendInputProcess(downloadInfos.password); } + if(out[0] === DownloadEventType.NOT_LOGGED_IN && downloadInfos.password){ setTimeout(() => {this.sendInputProcess(downloadInfos.password);}, 2000) } else if(out[0] === DownloadEventType.NOT_LOGGED_IN){ this.downloadProcess.kill(); this.utils.ipcSend(`bs-download.${DownloadEventType.NOT_LOGGED_IN}`); } else if(out[0] === DownloadEventType.GUARD_CODE){ this.utils.ipcSend(`bs-download.${DownloadEventType.GUARD_CODE}`); } else if(out[0] === DownloadEventType.TWO_FA_CODE){ this.utils.ipcSend(`bs-download.${DownloadEventType.TWO_FA_CODE}`); } else if(out[0] === DownloadEventType.PROGESS){ this.utils.ipcSend(`bs-download.${DownloadEventType.PROGESS}`, parseFloat(out[1])); } else if(out[0] === DownloadEventType.FINISH){ this.utils.ipcSend(`bs-download.${DownloadEventType.FINISH}`); this.downloadProcess.kill(); } - else if(out[0] === DownloadEventType.ERROR){ this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); this.downloadProcess.kill(); } + else if(out[0] === DownloadEventType.ERROR){ + console.log("ERROR"); + this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); + this.downloadProcess.kill('SIGINT'); + } }) this.downloadProcess.stdout.on('error', err => { diff --git a/src/renderer/components/modal/modal-types/guard-modal.component.tsx b/src/renderer/components/modal/modal-types/guard-modal.component.tsx new file mode 100644 index 00000000..b9ba20dc --- /dev/null +++ b/src/renderer/components/modal/modal-types/guard-modal.component.tsx @@ -0,0 +1,28 @@ +import { ModalExitCode, ModalResponse } from "../../../services/modale.service"; +import { useState } from "react"; +import BeatConflict from "../../../../../assets/beat-conflict.png" + +export function GuardModal({resolver}: {resolver: (x: ModalResponse) => void}) { + + const [guardCode, setGuardCode] = useState(''); + + const loggin = () => resolver({exitCode: ModalExitCode.COMPLETED, data: guardCode}); + const cancel = () => resolver({exitCode: ModalExitCode.CANCELED}); + + return ( +
+ ) +} diff --git a/src/renderer/components/modal/modal.component.tsx b/src/renderer/components/modal/modal.component.tsx index da476f26..92d58b11 100644 --- a/src/renderer/components/modal/modal.component.tsx +++ b/src/renderer/components/modal/modal.component.tsx @@ -4,6 +4,7 @@ import { useEffect, useState } from "react" import { distinctUntilChanged } from "rxjs"; import { LoginModal } from "./modal-types/login-modal.component"; +import { GuardModal } from "./modal-types/guard-modal.component"; export function Modal() { @@ -23,6 +24,7 @@ export function Modal() { modalSevice.resolve({exitCode: ModalExitCode.NO_CHOICE})} className={`absolute top-0 bottom-0 right-0 left-0 transition-opacity bg-black ${modalType? "opacity-40" : "opacity-0"}`}>