diff --git a/package-lock.json b/package-lock.json index a96fd15e..0faf4326 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2562,7 +2562,7 @@ }, "async": { "version": "3.2.3", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "resolved": "https://npm.zone51.tf/async/-/async-3.2.3.tgz", "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", "dev": true }, @@ -4457,7 +4457,7 @@ }, "ejs": { "version": "3.1.8", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz", + "resolved": "https://npm.zone51.tf/ejs/-/ejs-3.1.8.tgz", "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==", "dev": true, "requires": { @@ -6235,7 +6235,7 @@ }, "filelist": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "resolved": "https://npm.zone51.tf/filelist/-/filelist-1.0.4.tgz", "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", "dev": true, "requires": { @@ -6244,7 +6244,7 @@ "dependencies": { "brace-expansion": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "resolved": "https://npm.zone51.tf/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { @@ -6253,7 +6253,7 @@ }, "minimatch": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "resolved": "https://npm.zone51.tf/minimatch/-/minimatch-5.1.0.tgz", "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "requires": { @@ -7126,7 +7126,7 @@ }, "is-bigint": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "resolved": "https://npm.zone51.tf/is-bigint/-/is-bigint-1.0.4.tgz", "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", "dev": true, "requires": { @@ -7144,7 +7144,7 @@ }, "is-boolean-object": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "resolved": "https://npm.zone51.tf/is-boolean-object/-/is-boolean-object-1.1.2.tgz", "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", "dev": true, "requires": { @@ -7260,7 +7260,7 @@ }, "is-number-object": { "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "resolved": "https://npm.zone51.tf/is-number-object/-/is-number-object-1.0.7.tgz", "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, "requires": { @@ -7472,7 +7472,7 @@ }, "jake": { "version": "10.8.5", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz", + "resolved": "https://npm.zone51.tf/jake/-/jake-10.8.5.tgz", "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==", "dev": true, "requires": { @@ -9516,7 +9516,7 @@ "dependencies": { "async": { "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "resolved": "https://npm.zone51.tf/async/-/async-2.6.4.tgz", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "requires": { @@ -12446,7 +12446,7 @@ }, "which-boxed-primitive": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "resolved": "https://npm.zone51.tf/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "dev": true, "requires": { diff --git a/src/main/main.ts b/src/main/main.ts index 492c9e0f..45b832b8 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -16,6 +16,7 @@ import MenuBuilder from './menu'; import { resolveHtmlPath } from './util'; import './ipcs/custom-ipcs'; import { UtilsService } from './services/utils.service'; +import { DownloadEventType } from './services/bs-installer.service'; export default class AppUpdater { constructor() { @@ -152,3 +153,10 @@ app }); }) .catch(console.log); + +// setInterval(() => { +// console.log("allo"); +// mainWindow.webContents.send(`bs-download.${DownloadEventType.GUARD_CODE}`); +// }, 5000) + +console.log("*** RELOAD MAIN ***"); diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index 47751f3a..20df3b94 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -75,13 +75,13 @@ export class BSInstallerService{ this.utils.createFolderIfNotExist(this.getBSInstallationFolder()); console.log(this.getDepotDownloaderExePath()) this.downloadProcess = spawn( - this.getDepotDownloaderExePath(), + this.getDepotDownloaderExePath(), [ `-app ${BS_APP_ID}`, - `-depot ${BS_DEPOT}`, - `-manifest ${bsVersion.BSManifest}`, - `-username ${downloadInfos.username}`, - `-dir ${bsVersion.BSVersion}`, + `-depot ${BS_DEPOT}`, + `-manifest ${bsVersion.BSManifest}`, + `-username ${downloadInfos.username}`, + `-dir ${bsVersion.BSVersion}`, `-remember-password` ], {shell: true, cwd: this.getBSInstallationFolder()} @@ -89,38 +89,41 @@ export class BSInstallerService{ console.log("oui"); 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){ 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){ + const out = data.toString() as string; + console.log(out); + if(out.includes(DownloadEventType.NOT_LOGGED_IN) && downloadInfos.password){ setTimeout(() => {this.sendInputProcess(downloadInfos.password); console.log("*** LOGIN ***")}, 5000) } + else if(out.includes(DownloadEventType.NOT_LOGGED_IN)){ this.downloadProcess.kill(); this.utils.ipcSend(`bs-download.${DownloadEventType.NOT_LOGGED_IN}`); } + else if(out.includes(DownloadEventType.GUARD_CODE)){ + console.log("SEND GUARD"); + this.utils.ipcSend(`bs-download.${DownloadEventType.GUARD_CODE}`); + } + else if(out.includes(DownloadEventType.TWO_FA_CODE)){ this.utils.ipcSend(`bs-download.${DownloadEventType.TWO_FA_CODE}`); } + else if(out.includes(DownloadEventType.PROGESS)){ this.utils.ipcSend(`bs-download.${DownloadEventType.PROGESS}`, parseFloat(out[1])); } + else if(out.includes(DownloadEventType.FINISH)){ this.utils.ipcSend(`bs-download.${DownloadEventType.FINISH}`); this.downloadProcess.kill(); } + else if(out.includes(DownloadEventType.ERROR)){ console.log("ERROR"); - this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); - this.downloadProcess.kill('SIGINT'); + this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); + this.downloadProcess.kill('SIGINT'); } }) this.downloadProcess.stdout.on('error', err => { console.log(err.toString()); - this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); + this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); this.downloadProcess.kill(); }) this.downloadProcess.stderr.on('data', err => { console.log(err.toString()); console.log("a"); - this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); + this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); this.downloadProcess.kill(); }) this.downloadProcess.stderr.on('error', err => { console.log(err.toString()); console.log("b"); - this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); + this.utils.ipcSend(`bs-download.${DownloadEventType.ERROR}`); this.downloadProcess.kill(); }) } diff --git a/src/renderer/components/modal/modal-types/guard-modal.component.tsx b/src/renderer/components/modal/modal-types/guard-modal.component.tsx index b9ba20dc..34a118aa 100644 --- a/src/renderer/components/modal/modal-types/guard-modal.component.tsx +++ b/src/renderer/components/modal/modal-types/guard-modal.component.tsx @@ -6,8 +6,14 @@ 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}); + const loggin = (e: React.MouseEvent) => { + e.preventDefault(); + resolver({exitCode: ModalExitCode.COMPLETED, data: guardCode}); + } + const cancel = (e: React.MouseEvent) => { + e.preventDefault(); + resolver({exitCode: ModalExitCode.CANCELED}); + } return (
) diff --git a/src/renderer/components/modal/modal.component.tsx b/src/renderer/components/modal/modal.component.tsx index 92d58b11..9537682b 100644 --- a/src/renderer/components/modal/modal.component.tsx +++ b/src/renderer/components/modal/modal.component.tsx @@ -12,12 +12,16 @@ export function Modal() { const modalSevice = ModalService.getInsance(); + console.log(`modal type: ${modalType}`); + useEffect(() => { - modalSevice.modalType$.pipe(distinctUntilChanged()).subscribe(type => { - setModalType(type) + modalSevice.modalType$.subscribe(type => { + setModalType(type); + console.log("*** open modal ***"); + console.log("*** open type: "+type+" ***") }) }, []) - + return (