Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
MazeAuth System + Electron 8
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlegamer committed Apr 4, 2020
1 parent e7d2305 commit 58d44d4
Show file tree
Hide file tree
Showing 11 changed files with 1,395 additions and 1,574 deletions.
45 changes: 22 additions & 23 deletions app/assets/js/mojang.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@ const minecraftAgent = {
name: 'Minecraft',
version: 1
}
const authpath = 'https://authserver.mojang.com'
const authpath = 'https://mazeauth.mazecity.fr' //'https://authserver.mojang.com'
const statuses = [
{
service: 'sessionserver.mojang.com',
service: 'sessionserver.mazecity.fr',
status: 'grey',
name: 'Multiplayer Session Service',
name: 'MazeServers',
essential: true
},
{
service: 'authserver.mojang.com',
service: 'authserver.mazecity.fr',
status: 'grey',
name: 'Authentication Service',
name: 'MazeAuth Service',
essential: true
},
{
service: 'textures.minecraft.net',
service: 'skin.mazecity.fr',
status: 'grey',
name: 'Minecraft Skins',
name: 'MazeSkins System',
essential: false
},
{
service: 'api.mojang.com',
service: 'api.mazecity.fr',
status: 'grey',
name: 'Public API',
name: 'Public MazeAPI',
essential: false
},
{
service: 'minecraft.net',
service: 'mazecity.fr',
status: 'grey',
name: 'Minecraft.net',
name: 'Mazecity.fr',
essential: false
},
{
service: 'account.mojang.com',
service: 'forum.mazecity.fr',
status: 'grey',
name: 'Mojang Accounts Website',
name: 'Mazecity Forum',
essential: false
}
]
Expand Down Expand Up @@ -79,25 +79,25 @@ exports.statusToHex = function(status){
}

/**
* Retrieves the status of Mojang's services.
* Retrieves the status of Mazecity's services.
* The response is condensed into a single object. Each service is
* a key, where the value is an object containing a status and name
* property.
*
* @see http://wiki.vg/Mojang_API#API_Status
* @see http://wiki.vg/Mojang_API#API_Status -> NOW Mazecity
*/
exports.status = function(){
return new Promise((resolve, reject) => {
request.get('https://status.mojang.com/check',
request.get('https://status.mazecity.fr/check/',
{
json: true,
timeout: 2500
},
function(error, response, body){

if(error || response.statusCode !== 200){
logger.warn('Unable to retrieve Mojang status.')
logger.debug('Error while retrieving Mojang statuses:', error)
logger.warn('Unable to retrieve Mazecity status.')
logger.debug('Error while retrieving Mazecity statuses:', error)
//reject(error || response.statusCode)
for(let i=0; i<statuses.length; i++){
statuses[i].status = 'grey'
Expand Down Expand Up @@ -143,8 +143,7 @@ exports.authenticate = function(username, password, clientToken, requestUser = t
if(clientToken != null){
body.clientToken = clientToken
}

request.post(authpath + '/authenticate',
request.post(authpath + '/authserver/authenticate',
{
json: true,
body
Expand Down Expand Up @@ -175,7 +174,7 @@ exports.authenticate = function(username, password, clientToken, requestUser = t
*/
exports.validate = function(accessToken, clientToken){
return new Promise((resolve, reject) => {
request.post(authpath + '/validate',
request.post(authpath + '/authserver/validate',
{
json: true,
body: {
Expand Down Expand Up @@ -210,7 +209,7 @@ exports.validate = function(accessToken, clientToken){
*/
exports.invalidate = function(accessToken, clientToken){
return new Promise((resolve, reject) => {
request.post(authpath + '/invalidate',
request.post(authpath + '/authserver/invalidate',
{
json: true,
body: {
Expand Down Expand Up @@ -246,7 +245,7 @@ exports.invalidate = function(accessToken, clientToken){
*/
exports.refresh = function(accessToken, clientToken, requestUser = true){
return new Promise((resolve, reject) => {
request.post(authpath + '/refresh',
request.post(authpath + '/authserver/refresh',
{
json: true,
body: {
Expand Down
6 changes: 5 additions & 1 deletion app/assets/js/processbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ class ProcessBuilder {
args = args.concat(ConfigManager.getJVMOptions())
args.push('-Djava.library.path=' + tempNativePath)

args.push('-Duuid=' +this.authUser.uuid.trim())
args.push('-Dtoken=' +this.authUser.accessToken)
args.push('-D' +this.authUser.accessToken)

// Main Java Class
args.push(this.forgeData.mainClass)

Expand Down Expand Up @@ -503,7 +507,7 @@ class ProcessBuilder {
val = this.authUser.accessToken
break
case 'user_type':
val = 'mojang'
val = 'mazecity'
break
case 'version_type':
val = this.versionData.type
Expand Down
14 changes: 7 additions & 7 deletions app/assets/js/scripts/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,13 @@ function dlAsync(login = true){
loggerAEx.log(data)
})
aEx.on('error', (err) => {
loggerLaunchSuite.error('Error during launch', err)
showLaunchFailure('Error During Launch', err.message || 'See console (CTRL + Shift + i) for more details.')
loggerLaunchSuite.error('Error during launch 1', err)
showLaunchFailure('Error During Launch 1', err.message || 'See console (CTRL + Shift + i) for more details.')
})
aEx.on('close', (code, signal) => {
if(code !== 0){
loggerLaunchSuite.error(`AssetExec exited with code ${code}, assuming error.`)
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.')
showLaunchFailure('Error During Launch 1', 'See console (CTRL + Shift + i) for more details.')
}
})

Expand Down Expand Up @@ -633,8 +633,8 @@ function dlAsync(login = true){
if(m.result.forgeData == null || m.result.versionData == null){
loggerLaunchSuite.error('Error during validation:', m.result)

loggerLaunchSuite.error('Error during launch', m.result.error)
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.')
loggerLaunchSuite.error('Error during launch 2, No Forge downloaded', m.result.error)
showLaunchFailure('Error during launch 2, No Forge downloaded', 'Please check the console (CTRL + Shift + i) for more details.')

allGood = false
}
Expand Down Expand Up @@ -707,8 +707,8 @@ function dlAsync(login = true){

} catch(err) {

loggerLaunchSuite.error('Error during launch', err)
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.')
loggerLaunchSuite.error('Error during launch 3', err)
showLaunchFailure('Error During Launch 3', 'Please check the console (CTRL + Shift + i) for more details.')

}
}
Expand Down
3 changes: 1 addition & 2 deletions app/assets/js/scripts/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ loginButton.addEventListener('click', () => {

// Show loading stuff.
loginLoading(true)

AuthManager.addAccount(loginUsername.value, loginPassword.value).then((value) => {
updateSelectedAccount(value)
loginButton.innerHTML = loginButton.innerHTML.replace(Lang.queryJS('login.loggingIn'), Lang.queryJS('login.success'))
Expand Down Expand Up @@ -294,7 +293,7 @@ loginButton.addEventListener('click', () => {
toggleOverlay(false)
})
toggleOverlay(true)
loggerLogin.log('Error while logging in.', err)
loggerLogin.log('Error while logging in.', err, loginUsername.value, loginPassword.value)
})

})
3 changes: 1 addition & 2 deletions app/assets/js/scripts/uicore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ window.eval = global.eval = function () {

// Display warning when devtools window is opened.
remote.getCurrentWebContents().on('devtools-opened', () => {
console.log('%cThe console is dark and full of terrors.', 'color: white; -webkit-text-stroke: 4px #a02d2a; font-size: 60px; font-weight: bold')
console.log('%cNe regardez pas la console si on ne vous l\'a pas demandé', 'color: white; -webkit-text-stroke: 4px #a02d2a; font-size: 60px; font-weight: bold')
console.log('%cIf you\'ve been told to paste something here, you\'re being scammed.', 'font-size: 16px')
console.log('%cUnless you know exactly what you\'re doing, close this window.', 'font-size: 16px')
})

// Disable zoom, needed for darwin.
webFrame.setZoomLevel(0)
webFrame.setVisualZoomLevelLimits(1, 1)
webFrame.setLayoutZoomLevelLimits(0, 0)

// Initialize auto updates in production environments.
let updateCheckListener
Expand Down
14 changes: 6 additions & 8 deletions app/assets/js/serverstatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const net = require('net')
//const net = require('net')
const request = require('request')

/**
Expand Down Expand Up @@ -80,29 +80,27 @@ exports.getStatus = function(address, port = 25565){

exports.getStatus = function(address){
return new Promise((resolve, reject) => {
request.get('https://mcapi.us/server/status?ip=mazecity.boxtoplay.com',
request.get('https://api.mcsrvstat.us/2/mazecraft.mine.gg',
{
json: true,
timeout: 2500
},
function(error, response, body){

if(error || response.statusCode !== 200){
logger.warn('Unable to retrieve Mazecity status.')
logger.debug('Error while retrieving Mazecity statuses:', error)
//reject(error || response.statusCode)
reject(error || response.statusCode)
resolve({
online: false
})
} else {
resolve({
online: true,
version: body.server.name.replace(/\u0000/g, ''),
motd: body.motd.replace(/\u0000/g, ''),
onlinePlayers: body.players.now,
version: body.version,
onlinePlayers: body.players.online,
maxPlayers: body.players.max
})
}
})
console.log(request)
})
}
2 changes: 1 addition & 1 deletion app/landing.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</div>
<div class="bot_divider"></div>
<div id="mojangStatusWrapper">
<span class="bot_label">MOJANG STATUS</span>
<span class="bot_label">MAZECITY STATUS</span>
<span id="mojang_status_icon">&#8226;</span>
<div id="mojangStatusTooltip">
<div id="mojangStatusTooltipTitle">Services</div>
Expand Down
22 changes: 11 additions & 11 deletions app/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@
<div id="loginCancelContainer" style="display: none;">
<button id="loginCancelButton">
<div id="loginCancelIcon">X</div>
<span id="loginCancelText">Cancel</span>
<span id="loginCancelText">Annule</span>
</button>
</div>
<div id="loginContent">
<form id="loginForm">
<img id="loginImageSeal" src="assets/images/discord.png"/>
<span id="loginSubheader">MINECRAFT LOGIN</span>
<span id="loginSubheader">MAZECITY LOGIN</span>
<div class="loginFieldContainer">
<svg id="profileSVG" class="loginSVG" viewBox="40 37 65.36 61.43">
<g>
<path d="M86.77,58.12A13.79,13.79,0,1,0,73,71.91,13.79,13.79,0,0,0,86.77,58.12M97,103.67a3.41,3.41,0,0,0,3.39-3.84,27.57,27.57,0,0,0-54.61,0,3.41,3.41,0,0,0,3.39,3.84Z"/>
</g>
</svg>
<span class="loginErrorSpan" id="loginEmailError">* Invalid Value</span>
<input id="loginUsername" class="loginField" type="text" placeholder="EMAIL OR USERNAME"/>
<input id="loginUsername" class="loginField" type="text" placeholder="Pseudo"/>
</div>
<div class="loginFieldContainer">
<svg id="lockSVG" class="loginSVG" viewBox="40 32 60.36 70.43">
<g>
<path d="M86.16,54a16.38,16.38,0,1,0-32,0H44V102.7H96V54Zm-25.9-3.39a9.89,9.89,0,1,1,19.77,0A9.78,9.78,0,0,1,79.39,54H60.89A9.78,9.78,0,0,1,60.26,50.59ZM70,96.2a6.5,6.5,0,0,1-6.5-6.5,6.39,6.39,0,0,1,3.1-5.4V67h6.5V84.11a6.42,6.42,0,0,1,3.39,5.6A6.5,6.5,0,0,1,70,96.2Z"/>
</g>
</svg>
<span class="loginErrorSpan" id="loginPasswordError">* Required</span>
<input id="loginPassword" class="loginField" type="password" placeholder="PASSWORD"/>
<span class="loginErrorSpan" id="loginPasswordError">* Requis</span>
<input id="loginPassword" class="loginField" type="password" placeholder="Mot de passe"/>
</div>
<div id="loginOptions">
<span class="loginSpanDim">
<a href="https://help.mojang.com/customer/en/portal/articles/329524-change-or-forgot-password">forgot password?</a>
<a href="https://mazecity.fr/forgot">Mot de passe oublié ?</a>
</span>
<label id="checkmarkContainer">
<input id="loginRememberOption" type="checkbox" checked>
<span id="loginRememberText" class="loginSpanDim">remember me?</span>
<span id="loginRememberText" class="loginSpanDim">Rester connecté ?</span>
<span class="loginCheckmark"></span>
</label>
</div>
<button id="loginButton" disabled>
<div id="loginButtonContent">
LOGIN
Connexion
<svg id="loginSVG" viewBox="0 0 24.87 13.97">
<defs>
<style>.arrowLine{fill:none;stroke:#FFF;stroke-width:2px;transition: 0.25s ease;}</style>
Expand All @@ -54,10 +54,10 @@
</button>
<div id="loginDisclaimer">
<span class="loginSpanDim" id="loginRegisterSpan">
<a href="https://minecraft.net/en-us/store/minecraft/">Need an Account?</a>
<a href="https://mazeauth.mazecity.fr/authserver/register">Besoin d'un compte?</a>
</span>
<p class="loginDisclaimerText">Your password is sent directly to mojang and never stored.</p>
<p class="loginDisclaimerText">MazeLauncher is not affiliated with Mojang AB.</p>
<p class="loginDisclaimerText">Si c'est votre premiere fois, veuillez créer votre compte.</p>
<p class="loginDisclaimerText">Mazecity et ses services ne sont pas affiliés à Mojang AB ou Microsoft.</p>
</div>
</form>
</div>
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ ipcMain.on('distributionIndexDone', (event, res) => {
// https://electronjs.org/docs/tutorial/offscreen-rendering
app.disableHardwareAcceleration()

app.allowRendererProcessReuse = true

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
Expand Down Expand Up @@ -119,7 +121,7 @@ function createWindow() {

win.removeMenu()

win.setResizable(true)
win.resizable = true

win.on('closed', () => {
win = null
Expand Down
Loading

0 comments on commit 58d44d4

Please sign in to comment.