diff --git a/app/assets/js/actionbinder.js b/app/assets/js/actionbinder.js index 50a1fca..ea6762b 100644 --- a/app/assets/js/actionbinder.js +++ b/app/assets/js/actionbinder.js @@ -1,10 +1,10 @@ -const mojang = require('mojang') const path = require('path') const {AssetGuard} = require(path.join(__dirname, 'assets', 'js', 'assetguard.js')) const ProcessBuilder = require(path.join(__dirname, 'assets', 'js', 'processbuilder.js')) const ConfigManager = require(path.join(__dirname, 'assets', 'js', 'configmanager.js')) const DiscordWrapper = require(path.join(__dirname, 'assets', 'js', 'discordwrapper.js')) -const mojang2 = require(path.join(__dirname, 'assets', 'js', 'mojang.js')) +const Mojang = require(path.join(__dirname, 'assets', 'js', 'mojang.js')) +const AuthManager = require(path.join(__dirname, 'assets', 'js', 'authmanager.js')) let mojangStatusListener @@ -28,7 +28,7 @@ document.addEventListener('readystatechange', function(){ console.log('Refreshing Mojang Statuses..') try { let status = 'grey' - const statuses = await mojang2.status() + const statuses = await Mojang.status() greenCount = 0 for(let i=0; i} - an array of each stored authenticated account. + */ +exports.getAuthAccounts = function(){ + return config.authenticationDatabase +} + +/** + * Returns the authenticated account with the given uuid. Value may + * be null. + * + * @param {String} uuid - the uuid of the authenticated account. + * @returns {Object} - the authenticated account with the given uuid. + */ +exports.getAuthAccount = function(uuid){ + return config.authenticationDatabase[uuid] +} + +/** + * Update the access token of an authenticated account. + * + * @param {String} uuid - uuid of the authenticated account. + * @param {String} accessToken - the new Access Token. + * + * @returns {Object} - the authenticated account object created by this action. + */ +exports.updateAuthAccount = function(uuid, accessToken){ + config.authenticationDatabase[uuid].accessToken = accessToken + return config.authenticationDatabase[uuid] +} + +/** + * Adds an authenticated account to the database to be stored. + * + * @param {String} uuid - uuid of the authenticated account. + * @param {String} accessToken - accessToken of the authenticated account. + * @param {String} username - username (usually email) of the authenticated account. + * @param {String} displayName - in game name of the authenticated account. + * + * @returns {Object} - the authenticated account object created by this action. + */ +exports.addAuthAccount = function(uuid, accessToken, username, displayName){ + config.selectedAccount = uuid + config.authenticationDatabase[uuid] = { + accessToken, + username, + uuid, + displayName + } + return config.authenticationDatabase[uuid] +} + +/** + * Get the currently selected authenticated account. + * + * @returns {Object} - the selected authenticated account. + */ +exports.getSelectedAccount = function(){ + return config.authenticationDatabase[config.selectedAccount] +} // User Configurable Settings diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index 9f1da79..e3dbf8e 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -131,7 +131,7 @@ class ProcessBuilder { let val = null; switch(identifier){ case 'auth_player_name': - val = this.authUser.selectedProfile.name + val = this.authUser.displayName break case 'version_name': //val = versionData.id @@ -147,7 +147,7 @@ class ProcessBuilder { val = this.versionData.assets break case 'auth_uuid': - val = this.authUser.selectedProfile.id + val = this.authUser.uuid break case 'auth_access_token': val = this.authUser.accessToken diff --git a/package-lock.json b/package-lock.json index 0d58ed4..c1b8d98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1237,10 +1237,6 @@ } } }, - "mojang": { - "version": "https://registry.npmjs.org/mojang/-/mojang-0.4.1.tgz", - "integrity": "sha1-aWPEL8RlDrwASCSGvdqpB2Mhmi4=" - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", diff --git a/package.json b/package.json index b8b5eda..d4f53c0 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "ejs-electron": "^2.0.1", "find-java-home": "^0.2.0", "jquery": "^3.2.1", - "mojang": "^0.4.1", "request-promise-native": "^1.0.5", "uuid": "^3.1.0" },