diff --git a/package-lock.json b/package-lock.json index 2e1d1bf..d820c46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -501,83 +501,6 @@ } } }, - "@electron-forge/maker-zip": { - "version": "6.0.0-beta.59", - "resolved": "https://registry.npmjs.org/@electron-forge/maker-zip/-/maker-zip-6.0.0-beta.59.tgz", - "integrity": "sha512-JDRfhuCPIT0k2S2mMKMj4BfcIAvDlMvBHwf2ERp2FbroCdlKnL5taYHNLNlGBldVjNqNuees1S3cQnLh+4rLag==", - "dev": true, - "requires": { - "@electron-forge/maker-base": "6.0.0-beta.59", - "@electron-forge/shared-types": "6.0.0-beta.59", - "cross-zip": "^4.0.0", - "fs-extra": "^10.0.0" - }, - "dependencies": { - "@electron-forge/async-ora": { - "version": "6.0.0-beta.59", - "resolved": "https://registry.npmjs.org/@electron-forge/async-ora/-/async-ora-6.0.0-beta.59.tgz", - "integrity": "sha512-vF60XyjHCyoyXHgkDi/tZy+OB9K6oSBio2at7B4pwZLO6nqstofkeAB+Gz/XUsVj9Nim+vHKtyXPzE0BTXQkZQ==", - "dev": true, - "requires": { - "colors": "^1.4.0", - "debug": "^4.3.1", - "log-symbols": "^4.0.0", - "ora": "^5.0.0", - "pretty-ms": "^7.0.0" - } - }, - "@electron-forge/maker-base": { - "version": "6.0.0-beta.59", - "resolved": "https://registry.npmjs.org/@electron-forge/maker-base/-/maker-base-6.0.0-beta.59.tgz", - "integrity": "sha512-S/Qdu2kwio5PdZgoDDxZPo6JSf2YwcuXi3sy9Tw2Qj58+ZT9nOHn0C+JBHI8sREv3IRK52Axu1/RYkwtX9+V8w==", - "dev": true, - "requires": { - "@electron-forge/shared-types": "6.0.0-beta.59", - "fs-extra": "^10.0.0", - "which": "^2.0.2" - } - }, - "@electron-forge/shared-types": { - "version": "6.0.0-beta.59", - "resolved": "https://registry.npmjs.org/@electron-forge/shared-types/-/shared-types-6.0.0-beta.59.tgz", - "integrity": "sha512-3tRCgfHqn5/8LijlVZsLb2xHm9W3qgzQ+KZNWXdYhb0Wj1+h6/sXn8rlxw10Mmb2mlYJEBW/NvIhpUDHgrGPXA==", - "dev": true, - "requires": { - "@electron-forge/async-ora": "6.0.0-beta.59", - "electron-packager": "^15.0.0", - "electron-rebuild": "^2.3.2", - "ora": "^5.0.0" - } - }, - "fs-extra": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", - "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - } - } - }, "@electron-forge/plugin-base": { "version": "6.0.0-beta.59", "resolved": "https://registry.npmjs.org/@electron-forge/plugin-base/-/plugin-base-6.0.0-beta.59.tgz", @@ -1602,12 +1525,6 @@ "which": "^2.0.1" } }, - "cross-zip": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cross-zip/-/cross-zip-4.0.0.tgz", - "integrity": "sha512-MEzGfZo0rqE10O/B+AEcCSJLZsrWuRUvmqJTqHNqBtALhaJc3E3ixLGLJNTRzEA2K34wbmOHC4fwYs9sVsdcCA==", - "dev": true - }, "cuint": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz", @@ -3542,6 +3459,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "msmc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/msmc/-/msmc-2.2.0.tgz", + "integrity": "sha512-nUvxPXpy/tnVcLbx4zUyEn88bAvWVJhhYNavnGVd4cebGMgiRv0SAxVE5pVMJAr5mtAqb9klxqZPNurIfvYdcg==", + "requires": { + "node-fetch": "^2.6.1" + } + }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -3602,8 +3527,7 @@ "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-gyp": { "version": "7.1.2", diff --git a/package.json b/package.json index 1af405d..782e1de 100644 --- a/package.json +++ b/package.json @@ -1,44 +1,44 @@ -{ - "name": "altarik-launcher", - "author": "Altarik", - "version": "0.4.1", - "description": "Altarik Launcher", - "main": "src/server/main.js", - "repository": "AltarikMC/Launcher", - "bugs": "https://github.com/AltarikMC/Launcher/issues", - "keywords": [], - "contributors": [ - "SexiestCHiba" - ], - "maintainers": [ - "SexiestCHiba" - ], - "os": [ - "win32" - ], - "license": "BSD-3-Clause", - "scripts": { - "start": "electron-forge start", - "test": "electron .", - "package": "electron-forge package", - "make": "electron-forge make" - }, - "devDependencies": { - "@electron-forge/cli": "^6.0.0-beta.59", - "@electron-forge/maker-squirrel": "^6.0.0-beta.59", - "@electron-forge/maker-zip": "^6.0.0-beta.59", - "electron": "^13.2.1" - }, - "dependencies": { - "axios": "^0.21.1", - "electron-is-dev": "^2.0.0", - "electron-log": "^4.4.1", - "electron-squirrel-startup": "^1.0.0", - "extract-zip": "^2.0.1", - "hasha": "^5.2.2", - "minecraft-launcher-core": "^3.16.7" - }, - "config": { - "forge": "./config.forge.js" - } -} +{ + "name": "altarik-launcher", + "author": "Altarik", + "version": "0.4.1", + "description": "Altarik Launcher", + "main": "src/server/main.js", + "repository": "AltarikMC/Launcher", + "bugs": "https://github.com/AltarikMC/Launcher/issues", + "keywords": [], + "contributors": [ + "SexiestCHiba" + ], + "maintainers": [ + "SexiestCHiba" + ], + "os": [ + "win32" + ], + "license": "BSD-3-Clause", + "scripts": { + "start": "electron-forge start", + "test": "electron .", + "package": "electron-forge package", + "make": "electron-forge make" + }, + "devDependencies": { + "@electron-forge/cli": "^6.0.0-beta.59", + "@electron-forge/maker-squirrel": "^6.0.0-beta.59", + "electron": "^13.2.1" + }, + "dependencies": { + "axios": "^0.21.1", + "electron-is-dev": "^2.0.0", + "electron-log": "^4.4.1", + "electron-squirrel-startup": "^1.0.0", + "extract-zip": "^2.0.1", + "hasha": "^5.2.2", + "minecraft-launcher-core": "^3.16.7", + "msmc": "^2.2.0" + }, + "config": { + "forge": "./config.forge.js" + } +} diff --git a/src/client/assets/css/login.css b/src/client/assets/css/login.css index 0530425..b2b38af 100644 --- a/src/client/assets/css/login.css +++ b/src/client/assets/css/login.css @@ -20,7 +20,7 @@ body{ height:100%; } -#login { +#content > * { position:relative; width: 300px; top:50%; @@ -30,6 +30,11 @@ body{ padding: 8px; } +#microsoft-button { + border-width: 0; + cursor: pointer; +} + #login input[type="text"], #login input[type="password"]{ width:100%; diff --git a/src/client/assets/js/login.js b/src/client/assets/js/login.js index e62d4bc..a5f1f87 100644 --- a/src/client/assets/js/login.js +++ b/src/client/assets/js/login.js @@ -1,25 +1,36 @@ const form = document.querySelector('#login-form') const user = document.querySelector('#nickname') const password = document.querySelector('#password') - +const microsoftButton = document.querySelector("#microsoft-button") form.addEventListener("submit", (e) => { e.preventDefault() - form.disabled = true - if(user.value) { - ipcRenderer.send("login", { - user: user.value, - pass: password.value - }) - }else{ - ipcRenderer.send("notification", { - title: "error", - body: "Veuillez entrer des identifiants" - }) + if(!microsoftButton.disabled) { + form.disabled = true + if(user.value) { + ipcRenderer.send("login", { + user: user.value, + pass: password.value + }) + }else{ + ipcRenderer.send("notification", { + title: "error", + body: "Veuillez entrer des identifiants" + }) + } + } +}) + +microsoftButton.addEventListener("click", (e) => { + e.preventDefault() + if(!form.disabled) { + microsoftButton.disabled = true + form.disabled = true + ipcRenderer.send("microsoft-login") } - }) ipcRenderer.on("loginError", event => { form.disabled = false + microsoftButton.disabled = false }) \ No newline at end of file diff --git a/src/client/index.html b/src/client/index.html index 1ef3b2c..8b5f349 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -2,7 +2,7 @@ - Launcher Projet Secret + Altarik Launcher diff --git a/src/client/login.html b/src/client/login.html index 68f44db..50f4247 100644 --- a/src/client/login.html +++ b/src/client/login.html @@ -2,7 +2,7 @@ - Launcher Projet Secret + Altarik Launcher @@ -30,6 +30,7 @@ + diff --git a/src/server/main.js b/src/server/main.js index 24749f5..393fb01 100644 --- a/src/server/main.js +++ b/src/server/main.js @@ -2,9 +2,9 @@ const { app, BrowserWindow, Menu, ipcMain, Notification, autoUpdater, dialog } = const logger = require('electron-log') const { join } = require('path') if (require('electron-squirrel-startup')) { - require("./install.js").handleSquirrelEvent(app) - app.quit() - return; + require("./install.js").handleSquirrelEvent(app) + app.quit() + return } require('./updater.js').configUpdater(app, autoUpdater, dialog, logger) @@ -14,22 +14,25 @@ const iconPath = join(__dirname, "icon.ico") let win = null function createWindow () { - win = new BrowserWindow({ - width: 1000, - minWidth: 1000, - maxWidth: 1000, - height: 600, - minHeight: 600, - maxHeight: 600, - icon: iconPath, - webPreferences: { - nodeIntegration: true, - contextIsolation: false - }, - frame: false, - }) - // Menu.setApplicationMenu(null) - win.loadFile('src/client/login.html') + win = new BrowserWindow({ + width: 1000, + minWidth: 1000, + maxWidth: 1000, + height: 600, + minHeight: 600, + maxHeight: 600, + icon: iconPath, + webPreferences: { + nodeIntegration: true, + contextIsolation: false + }, + frame: false, + }) + // Menu.setApplicationMenu(null) + win.loadFile('src/client/login.html') + win.on("close", () => { + app.quit() + }) } const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js"); @@ -37,33 +40,37 @@ const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js"); setWindow(win) app.whenReady().then(() => { - createWindow() + createWindow() }) app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit() - } + if (process.platform !== 'darwin') { + app.quit() + } }) ipcMain.on('minimizeWindow', () => { - minimizeWindow(win) + minimizeWindow(win) }) ipcMain.on('closeWindow', () => { - closeWindow(win) + closeWindow(win) }) app.on('activate', () => { - if (win === null){ - createWindow() - } + if (win === null){ + createWindow() + } }) ipcMain.on("login", (event, args) => { minecraft.login(event, win, showNotification, args.user, args.pass) }) +ipcMain.on("microsoft-login", (event, args) => { + minecraft.microsoftLogin(event, win, showNotification) +}) + ipcMain.on("invalidateData", event => { minecraft.invalidateData(event) }) @@ -73,15 +80,15 @@ ipcMain.on("launch", (event, args) => { }) function showNotification(title, body="") { - new Notification({ title: title, body: body }).show() + new Notification({ title: title, body: body, silent: false, icon: "../../icon.ico"}).show() } ipcMain.on("notification", (event, args) => { - showNotification(args.title, args.body) + showNotification(args.title, args.body) }) ipcMain.on("disconnect", (e) => { - win.loadFile('src/client/login.html') + win.loadFile('src/client/login.html') }) diff --git a/src/server/minecraft.js b/src/server/minecraft.js index dbe2559..c9464d6 100644 --- a/src/server/minecraft.js +++ b/src/server/minecraft.js @@ -3,10 +3,11 @@ const { Client, Authenticator } = require('minecraft-launcher-core') const axios = require('axios').default const hasha = require('hasha'); const fs = require('fs') -const { join, resolve } = require('path') +const { join } = require('path') const constants = require("constants") const zip = require('extract-zip') const logger = require('electron-log') +const msmc = require('msmc') class Minecraft { @@ -16,6 +17,9 @@ class Minecraft { auth = null modsList = undefined + /** + * Used to login through Mojang account + */ login(event, win, showNotification, username, password) { this.auth = null if(isDev || password.trim() !== "") { @@ -26,7 +30,7 @@ class Minecraft { }) }).catch((err) => { event.sender.send("loginError") - logger.error(err) + logger.error("[MJ login] User haven't purchase the game") showNotification("Erreur de connexion") }) } else { @@ -34,6 +38,43 @@ class Minecraft { } } + /** + * Used to login through a Microsoft account + */ + microsoftLogin(event, win, showNotification) { + msmc.fastLaunch("electron", + (update) => { + switch (update.type) { + case "Error": + event.sender.send("loginError") + showNotification("Une erreur est survenue", update.data) + logger.error("MC-Account error:", update.data); + break; + } + }).then(result => { + if(msmc.errorCheck(result)) { + event.sender.send("loginError") + logger.error(result.reason) + showNotification("Erreur de connexion", result.reason) + } else { + if(!msmc.isDemoUser(result)) { + this.auth = msmc.getMCLC().getAuth(result) + win.loadFile('src/client/index.html').then(() => { + event.sender.send("nick", { name: this.auth.name }) + }) + } else { + event.sender.send("loginError") + logger.error("[MS login] User haven't purchase the game") + showNotification("Erreur de connexion", "Vous ne possèdez pas de licence Minecraft sur ce compte") + } + } + }).catch(reason => { + event.sender.send("loginError") + logger.error(reason) + showNotification("Erreur de connexion") + }) + } + launch(event, showNotification, args) { this.extractJava(Number(args.chapter), event).then((javaPath) => { this.extractMods(Number(args.chapter), event).then((chapter) => {