mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-22 06:19:50 +01:00
add support to microsoft auth (untested cause I haven't minecraft on a microsoft account)
This commit is contained in:
parent
2105ebb88a
commit
cac1afbd31
94
package-lock.json
generated
94
package-lock.json
generated
@ -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": {
|
"@electron-forge/plugin-base": {
|
||||||
"version": "6.0.0-beta.59",
|
"version": "6.0.0-beta.59",
|
||||||
"resolved": "https://registry.npmjs.org/@electron-forge/plugin-base/-/plugin-base-6.0.0-beta.59.tgz",
|
"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"
|
"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": {
|
"cuint": {
|
||||||
"version": "0.2.2",
|
"version": "0.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
},
|
},
|
||||||
|
"msmc": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/msmc/-/msmc-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-g2X/VbdarLfT76reSKGgBKmnllliZnEx2KSxBTt53Y/BWek3WD6e1WfsYb3AOpNV34O9FEO2kbgelUb9FLmviQ==",
|
||||||
|
"requires": {
|
||||||
|
"node-fetch": "^2.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"mute-stream": {
|
"mute-stream": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
|
||||||
@ -3602,8 +3527,7 @@
|
|||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node-gyp": {
|
"node-gyp": {
|
||||||
"version": "7.1.2",
|
"version": "7.1.2",
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-forge/cli": "^6.0.0-beta.59",
|
"@electron-forge/cli": "^6.0.0-beta.59",
|
||||||
"@electron-forge/maker-squirrel": "^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.1.9"
|
"electron": "^13.1.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -36,7 +35,8 @@
|
|||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"hasha": "^5.2.2",
|
"hasha": "^5.2.2",
|
||||||
"minecraft-launcher-core": "^3.16.6"
|
"minecraft-launcher-core": "^3.16.6",
|
||||||
|
"msmc": "^2.1.3"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"forge": "./config.forge.js"
|
"forge": "./config.forge.js"
|
||||||
|
@ -20,7 +20,7 @@ body{
|
|||||||
height:100%;
|
height:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login {
|
#content > * {
|
||||||
position:relative;
|
position:relative;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
top:50%;
|
top:50%;
|
||||||
@ -30,6 +30,11 @@ body{
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#microsoft-button {
|
||||||
|
border-width: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
#login input[type="text"],
|
#login input[type="text"],
|
||||||
#login input[type="password"]{
|
#login input[type="password"]{
|
||||||
width:100%;
|
width:100%;
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
const form = document.querySelector('#login-form')
|
const form = document.querySelector('#login-form')
|
||||||
const user = document.querySelector('#nickname')
|
const user = document.querySelector('#nickname')
|
||||||
const password = document.querySelector('#password')
|
const password = document.querySelector('#password')
|
||||||
|
const microsoftButton = document.querySelector("#microsoft-button")
|
||||||
|
|
||||||
form.addEventListener("submit", (e) => {
|
form.addEventListener("submit", (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
form.disabled = true
|
if(!microsoftButton.disabled) {
|
||||||
if(user.value) {
|
form.disabled = true
|
||||||
ipcRenderer.send("login", {
|
if(user.value) {
|
||||||
user: user.value,
|
ipcRenderer.send("login", {
|
||||||
pass: password.value
|
user: user.value,
|
||||||
})
|
pass: password.value
|
||||||
}else{
|
})
|
||||||
ipcRenderer.send("notification", {
|
}else{
|
||||||
title: "error",
|
ipcRenderer.send("notification", {
|
||||||
body: "Veuillez entrer des identifiants"
|
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 => {
|
ipcRenderer.on("loginError", event => {
|
||||||
form.disabled = false
|
form.disabled = false
|
||||||
|
microsoftButton.disabled = false
|
||||||
})
|
})
|
@ -30,6 +30,7 @@
|
|||||||
<input type="submit" value="Se connecter">
|
<input type="submit" value="Se connecter">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<button id="microsoft-button">Connexion avec un compte Microsoft</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="assets/js/script.js"></script>
|
<script src="assets/js/script.js"></script>
|
||||||
|
@ -2,9 +2,9 @@ const { app, BrowserWindow, Menu, ipcMain, Notification, autoUpdater, dialog } =
|
|||||||
const logger = require('electron-log')
|
const logger = require('electron-log')
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
if (require('electron-squirrel-startup')) {
|
if (require('electron-squirrel-startup')) {
|
||||||
require("./install.js").handleSquirrelEvent(app)
|
require("./install.js").handleSquirrelEvent(app)
|
||||||
app.quit()
|
app.quit()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
require('./updater.js').configUpdater(app, autoUpdater, dialog, logger)
|
require('./updater.js').configUpdater(app, autoUpdater, dialog, logger)
|
||||||
|
|
||||||
@ -14,22 +14,25 @@ const iconPath = join(__dirname, "icon.ico")
|
|||||||
let win = null
|
let win = null
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
minWidth: 1000,
|
minWidth: 1000,
|
||||||
maxWidth: 1000,
|
maxWidth: 1000,
|
||||||
height: 600,
|
height: 600,
|
||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
maxHeight: 600,
|
maxHeight: 600,
|
||||||
icon: iconPath,
|
icon: iconPath,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: false
|
contextIsolation: false
|
||||||
},
|
},
|
||||||
frame: false,
|
frame: false,
|
||||||
})
|
})
|
||||||
// Menu.setApplicationMenu(null)
|
// Menu.setApplicationMenu(null)
|
||||||
win.loadFile('src/client/login.html')
|
win.loadFile('src/client/login.html')
|
||||||
|
win.on("close", () => {
|
||||||
|
app.quit()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js");
|
const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js");
|
||||||
@ -37,33 +40,37 @@ const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js");
|
|||||||
setWindow(win)
|
setWindow(win)
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('minimizeWindow', () => {
|
ipcMain.on('minimizeWindow', () => {
|
||||||
minimizeWindow(win)
|
minimizeWindow(win)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('closeWindow', () => {
|
ipcMain.on('closeWindow', () => {
|
||||||
closeWindow(win)
|
closeWindow(win)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (win === null){
|
if (win === null){
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on("login", (event, args) => {
|
ipcMain.on("login", (event, args) => {
|
||||||
minecraft.login(event, win, showNotification, args.user, args.pass)
|
minecraft.login(event, win, showNotification, args.user, args.pass)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on("microsoft-login", (event, args) => {
|
||||||
|
minecraft.microsoftLogin(event, win, showNotification)
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.on("invalidateData", event => {
|
ipcMain.on("invalidateData", event => {
|
||||||
minecraft.invalidateData(event)
|
minecraft.invalidateData(event)
|
||||||
})
|
})
|
||||||
@ -73,15 +80,15 @@ ipcMain.on("launch", (event, args) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function showNotification(title, body="") {
|
function showNotification(title, body="") {
|
||||||
new Notification({ title: title, body: body }).show()
|
new Notification({ title: title, body: body }).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on("notification", (event, args) => {
|
ipcMain.on("notification", (event, args) => {
|
||||||
showNotification(args.title, args.body)
|
showNotification(args.title, args.body)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on("disconnect", (e) => {
|
ipcMain.on("disconnect", (e) => {
|
||||||
win.loadFile('src/client/login.html')
|
win.loadFile('src/client/login.html')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,10 +3,11 @@ const { Client, Authenticator } = require('minecraft-launcher-core')
|
|||||||
const axios = require('axios').default
|
const axios = require('axios').default
|
||||||
const hasha = require('hasha');
|
const hasha = require('hasha');
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { join, resolve } = require('path')
|
const { join } = require('path')
|
||||||
const constants = require("constants")
|
const constants = require("constants")
|
||||||
const zip = require('extract-zip')
|
const zip = require('extract-zip')
|
||||||
const logger = require('electron-log')
|
const logger = require('electron-log')
|
||||||
|
const msmc = require('msmc')
|
||||||
|
|
||||||
class Minecraft {
|
class Minecraft {
|
||||||
|
|
||||||
@ -16,6 +17,9 @@ class Minecraft {
|
|||||||
auth = null
|
auth = null
|
||||||
modsList = undefined
|
modsList = undefined
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to login through Mojang account
|
||||||
|
*/
|
||||||
login(event, win, showNotification, username, password) {
|
login(event, win, showNotification, username, password) {
|
||||||
this.auth = null
|
this.auth = null
|
||||||
if(isDev || password.trim() !== "") {
|
if(isDev || password.trim() !== "") {
|
||||||
@ -34,6 +38,42 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to login through a Microsoft account
|
||||||
|
*/
|
||||||
|
microsoftLogin(event, win, showNotification) {
|
||||||
|
msmc.getElectron().FastLaunch(
|
||||||
|
(callback) => {
|
||||||
|
this.auth = msmc.getMCLC().getAuth(callback)
|
||||||
|
this.auth.then(v => {
|
||||||
|
win.loadFile('src/client/index.html').then(() => {
|
||||||
|
event.sender.send("nick", { name: v.name })
|
||||||
|
})
|
||||||
|
}).catch((err) => {
|
||||||
|
event.sender.send("loginError")
|
||||||
|
logger.error(err)
|
||||||
|
showNotification("Erreur de connexion")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
(update) => {
|
||||||
|
switch (update.type) {
|
||||||
|
case "Rejection":
|
||||||
|
event.sender.send("loginError")
|
||||||
|
showNotification("Connexion rejetée")
|
||||||
|
logger.error("Fetch rejected!", update.data);
|
||||||
|
break;
|
||||||
|
case "Error":
|
||||||
|
event.sender.send("loginError")
|
||||||
|
showNotification("Une erreur est survenue", update.data)
|
||||||
|
logger.error("MC-Account error:", update.data);
|
||||||
|
break;
|
||||||
|
case "Cancelled":
|
||||||
|
logger.warn("Connexion annulée");
|
||||||
|
event.sender.send("loginError")
|
||||||
|
}
|
||||||
|
}, "login")
|
||||||
|
}
|
||||||
|
|
||||||
launch(event, showNotification, args) {
|
launch(event, showNotification, args) {
|
||||||
this.extractJava(Number(args.chapter), event).then((javaPath) => {
|
this.extractJava(Number(args.chapter), event).then((javaPath) => {
|
||||||
this.extractMods(Number(args.chapter), event).then((chapter) => {
|
this.extractMods(Number(args.chapter), event).then((chapter) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user