diff --git a/package.json b/package.json index 0e3bf18..ad6ef06 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "hasha": "^5.2.2", "izitoast": "^1.4.0", "minecraft-launcher-core": "^3.16.18", - "msmc": "^3.1.4", + "msmc": "^4.0.5", "node-fetch": "^2.6.9", "vue": "^3.2.47" }, diff --git a/src/server/minecraft.js b/src/server/minecraft.js index 32e5dc1..e9e4c62 100644 --- a/src/server/minecraft.js +++ b/src/server/minecraft.js @@ -7,7 +7,7 @@ const { join } = require('path') const constants = require("constants") const zip = require('extract-zip') const logger = require('electron-log') -const msmc = require('msmc') +const { auth, lst } = require('msmc') const decompress = require('decompress') const decompressTar = require('decompress-targz') @@ -49,34 +49,28 @@ class Minecraft { * Used to login through a Microsoft account */ microsoftLogin(event, win) { - msmc.fastLaunch("electron", - (update) => { - switch (update.type) { - case "Error": - event.sender.send("loginError") - this.showNotification("Une erreur est survenue", update.data, "error") - logger.error("MC-Account error:", update.data); - break; - } - }).then(result => { - if(msmc.errorCheck(result)) { - event.sender.send("loginError") - logger.error(result.reason) - this.showNotification("Erreur de connexion", result.reason, "error") - } else { - if(!msmc.isDemoUser(result)) { - this.auth = msmc.getMCLC().getAuth(result) + const authManager = new auth("select_account") + authManager.launch("electron").then(async xboxManager => { + xboxManager.getMinecraft().then(async token => { + if(!token.isDemo()) { + this.auth = token.mclc() win.loadFile('src/client/index.html') } else { event.sender.send("loginError") logger.error("[MS login] User haven't purchase the game") this.showNotification("Erreur de connexion", "Vous ne possèdez pas de licence Minecraft sur ce compte", "error") } - } - }).catch(reason => { + }).catch(err => { + event.sender.send("loginError") + logger.error("[MS login] " + lst(err)) + this.showNotification("Erreur de connexion à Mojang", lst(err), "error") + }) + }).catch(err => { event.sender.send("loginError") - logger.error(reason) - this.showNotification("Erreur de connexion", "Erreur inconnue", "error") + if(err != "error.gui.closed") { + logger.error("[MS login] " + lst(err)) + this.showNotification("Une erreur de connexion à Xbox est survenue", lst(err), "error") + } }) } diff --git a/yarn.lock b/yarn.lock index 827ed44..c67758e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2481,12 +2481,13 @@ ms@^2.0.0, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -msmc@^3.1.4: - version "3.1.4" - resolved "https://registry.yarnpkg.com/msmc/-/msmc-3.1.4.tgz#2a60cc22445f5ff44115fbe295aff7938b4088a9" - integrity sha512-3UHLlZXtFKRdJ3g6lb0vevC9RpObOE2+oiIS0SWLR2l75I60eXp6mF2XnFoZ7MgSeOmlwcU+lEGuIm3fT9UErg== +msmc@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/msmc/-/msmc-4.0.5.tgz#8451ff18929394cb28dfe680d69b70eebd09b074" + integrity sha512-HT3OY8IAphEQqlDV1mS4ccoffIpE6nCWChmIL7Uxuc2iL3HQinb8ULq8q8jfDRrIUobtI5dqVlG3PlrQa/4s7g== dependencies: node-fetch "2.x" + tslib "^2.4.0" nanoid@^3.3.3: version "3.3.4" @@ -3493,10 +3494,10 @@ trim-repeated@^1.0.0: dependencies: escape-string-regexp "^1.0.2" -tslib@^2.1.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@^2.1.0, tslib@^2.4.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" + integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== tunnel-agent@^0.6.0: version "0.6.0"