diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6375822..c765fe4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,15 +6,16 @@ - + + + + + - - - - - - - + + + + - { + "keyToString": { + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.git.unshallow": "true", + "RunOnceActivity.go.formatter.settings.were.checked": "true", + "RunOnceActivity.go.migrated.go.modules.settings": "true", + "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true", + "git-widget-placeholder": "offline-mode", + "go.import.settings.migrated": "true", + "go.sdk.automatically.set": "true", + "last_opened_file_path": "/home/dart/repo/skirda/yggdrasil-server", + "node.js.detected.package.eslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "npm.start.executor": "Debug", + "ts.external.directory.path": "/opt/goland/plugins/javascript-plugin/jsLanguageServicesImpl/external" } -}]]> +} diff --git a/Callback/index.html b/Callback/index.html index 8447ef8..5f00106 100644 --- a/Callback/index.html +++ b/Callback/index.html @@ -157,7 +157,7 @@ Успешная авторизация! Для начала игры вам необходимо вернутся в лаунчер. -
+
@@ -174,7 +174,7 @@ (Eror Pizda Poezdu) -
+
diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index 80625e3..c619666 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -2208,7 +2208,7 @@ input:checked + .toggleSwitchSlider:before { } /* About information links. */ -#settingsAboutButtons { +#footer-label { display: flex; padding: 0px 15px; margin-bottom: 5px; diff --git a/app/assets/js/authmanager.js b/app/assets/js/authmanager.js index 7a48316..eebfeda 100644 --- a/app/assets/js/authmanager.js +++ b/app/assets/js/authmanager.js @@ -175,14 +175,13 @@ exports.addMojangAccount = async function(username, password){ /** - * @param {string} uuid + * @param {string} uuid Minecraft profile uuid * @param {string} accessToken * @param {string} username - * @param {string} displayName * @param {string} skirdaToken * */ -exports.addSkirdaAccount = async function(uuid, accessToken, username, displayName, skirdaToken){ - const ret = ConfigManager.addSkirdaAccount(uuid, accessToken, username, displayName, skirdaToken) +exports.addSkirdaAccount = async function(uuid, accessToken, username, skirdaToken){ + const ret = ConfigManager.addSkirdaAccount(uuid, accessToken, username, skirdaToken) ConfigManager.save() return ret } @@ -415,7 +414,7 @@ async function validateSelectedMojangAccount(){ const auth_api_url = 'https://skirda.brzezinski.ru' async function validateSelectedSkirdaAccount(){ const current = ConfigManager.getSelectedAccount() - + console.log(current) const resp = await fetch(`${auth_api_url}/auth/refresh`, { headers: { 'Content-Type': 'application/json', diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index 8fe0ead..5d8e7ba 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -364,15 +364,14 @@ exports.addOfflineAccount = function(usernameOffline){ return config.authenticationDatabase[fake_uuid] } -exports.addSkirdaAccount = function(uuid, accessToken, username, displayName, skirdaToken){ - console.log(username) +exports.addSkirdaAccount = function(uuid, accessToken, username, skirdaToken){ config.selectedAccount = uuid config.authenticationDatabase[uuid] = { type: 'skirda', accessToken, username: username.trim(), uuid: uuid.trim(), - displayName: displayName.trim(), + displayName: username.trim(), skirdaJWT: skirdaToken.trim() } return config.authenticationDatabase[uuid] diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index 7d847f7..42b976a 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -375,6 +375,10 @@ class ProcessBuilder { args.push('-Xms' + ConfigManager.getMinRAM(this.server.rawServer.id)) args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id)) args.push('-Djava.library.path=' + tempNativePath) + args.push('-Dminecraft.api.auth.host=https://skirda.brzezinski.ru/yggdrasil/auth') + args.push('-Dminecraft.api.account.host=https://skirda.brzezinski.ru/yggdrasil/account') + args.push('-Dminecraft.api.session.host=https://skirda.brzezinski.ru/yggdrasil') + args.push('-Dminecraft.api.services.host=https://skirda.brzezinski.ru/yggdrasil/services)') // Main Java Class args.push(this.modManifest.mainClass) diff --git a/app/assets/js/scripts/loginOptions.js b/app/assets/js/scripts/loginOptions.js index 64e85aa..42f5ec4 100644 --- a/app/assets/js/scripts/loginOptions.js +++ b/app/assets/js/scripts/loginOptions.js @@ -3,6 +3,8 @@ const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft') const loginOptionMojang = document.getElementById('loginOptionMojang') const loginOptionOffline = document.getElementById('loginOptionOffline') const loginOptionSkirdaAuth = document.getElementById('loginOptionSkirdaAuth') +// const loginOptionSkirdaAuthStage1 = document.getElementById('loginOptionSkirdaStage1') +// const loginOptionSkirdaAuthStage2 = document.getElementById('loginOptionSkirdaStage2') const loginOptionSkirdaDiskord = document.getElementById('loginOptionSkirdaDiscord') const loginOptionSkirdaTelegram = document.getElementById('loginOptionSkirdaTelegram') const loginOptionsCancelButton = document.getElementById('loginOptionCancelButton') @@ -67,23 +69,58 @@ function loginOptionsCancelEnabled(val){ // }) // } + + loginOptionSkirdaAuth.onclick = (e) => { - console.log("aaaa") switchView(getCurrentView(), VIEWS.loginSkirdaAuth, 500, 500, () => { loginViewOnSuccess = loginOptionsViewOnLoginSuccess loginViewOnCancel = loginOptionsViewOnLoginCancel + // const stage1 = document.getElementById('loginOptionSkirdaStage1') + // const stage2 = document.getElementById('loginOptionSkirdaStage2') + // /** @type {HTMLInputElement}*/ + // const usernameInput = document.getElementById('loginOptionSkirdaSubmitUsername') + // /** @type {HTMLButtonElement}*/ + // const submitButton = document.getElementById('loginOptionSkirdaSubmitUsernameButton') + // + // + // stage1.style.display = 'none' + // stage2.style.display = 'block' + // + // submitButton.addEventListener('click', (e) => { + // SkirdaAuth.CheckFreeUsername('aaa', usernameInput.value).then((res) => { + // if (res.error !== undefined){ + // console.error(res.error) + // return + // } + // + // console.log('ok') + // }) + // }) + // + // usernameInput.addEventListener('input', (input) =>{ + // submitButton.disabled = !usernameInput.checkValidity() + // }) SkirdaAuth.Init().then((result) => { - console.log(result) - - AuthManager.addSkirdaAccount(result.ygg_auth_resp.profile.id, result.skirda_auth_resp.token, result.skirda_auth_resp.name, result.skirda_auth_resp.name, result.skirda_auth_resp.token).then((value) => { - console.log(value) - updateSelectedAccount(value) - }).then((value) => { - switchView(getCurrentView(), VIEWS.landing, 500, 500, async () => { - + if (result.error) { + console.error(result) + } else { + SkirdaAuth.YggdrasilAuth(result.token).then(ygg_res => { + if (ygg_res.error !== undefined) { + console.error(ygg_res) + } else { + AuthManager.addSkirdaAccount( + ygg_res.profile.id, + ygg_res.accessToken, + ygg_res.profile.name, + result.token).then((value) => { + updateSelectedAccount(value) + }).then((value) => { + switchView(getCurrentView(), VIEWS.landing, 500, 500, async () => {}) + }) + } }) - }) + } }) }) } diff --git a/app/assets/js/scripts/loginSkirda.js b/app/assets/js/scripts/loginSkirda.js index f0e91d4..15f5404 100644 --- a/app/assets/js/scripts/loginSkirda.js +++ b/app/assets/js/scripts/loginSkirda.js @@ -1,37 +1,46 @@ const sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth' -/**@typedef {Object} SkirdaAuthInitResponse - * @property {string} redirect_url - * @property {string} subscribe_url - * */ - - - -/**@typedef {Object} SkirdaAuthResponse - * @property {string} id - * @property {string} name +/** @typedef {Object} SkirdaAuthError + * @property {string} error */ -/**@typedef {Object} YggdrasilProfile - * @property {string} id - * @property {string} name +/** @typedef {Object} YggdrasilError + * @property {string} error + * @property {string} path */ -/**@typedef {Object} SkirdaYggdrasilAuthResponse - * @property {YggdrasilProfile} profile +/** @typedef {Object} SkirdaAuthInitResponse + * @property {string} redirect_url + * @property {string} subscribe_url */ -/** @typedef {Object} SkirdaAuthResultResponse - * @property {SkirdaAuthResponse} skirda_auth_resp - * @property {SkirdaYggdrasilAuthResponse} ygg_auth_resp - **/ +/** @typedef {Object} SkirdaAuthResponse + * @property {string} id + * @property {string} name + * @property {string} token + */ -class SkirdaAuth{ - constructor(){ +/** @typedef {Object} SkirdaYggdrasilAuthResponse + * @property {string} clientToken + * @property {string} accessToken //jwt from skirda yggdrasil service with minecraft username + * @property {YggdrasilProfile} profile + */ + +/** @typedef {Object} YggdrasilProfile + * @property {string} id + * @property {string} name + */ + + +class SkirdaAuth { + constructor() { console.log('Skirda Auth') } - static async #fetchInit(){ + /** + * @returns {Promise} + */ + static async #fetchInit() { const resp = await fetch(`${sk_tg_auth_api_url}/telegram/init`, {}) if (!resp.ok) { throw new Error(`Response status: ${resp.status}`) @@ -45,31 +54,25 @@ class SkirdaAuth{ } } + /** - * @return Promise + * @return {Promise} * */ static async Init() { const initResp = await SkirdaAuth.#fetchInit() await shell.openExternal(initResp.redirect_url) - const authResult = await SkirdaAuth.#subscribe(initResp.subscribe_url) - console.log(authResult) + // const yggResp = await SkirdaAuth.#yggdrasilAuth(authResult.token) + // console.log(yggResp) - const yggResp = await SkirdaAuth.#yggdrasilAuth(authResult.token) - console.log(yggResp) - // console.log(yggResp.profile) - - return { - 'skirda_auth_resp': authResult, - 'ygg_auth_resp': yggResp - } + return await SkirdaAuth.#subscribe(initResp.subscribe_url) } /** * @param subscribe_url - * @returns {Promise} + * @returns {Promise} */ static async #subscribe(subscribe_url) { const resp = await fetch(subscribe_url, {}) @@ -79,20 +82,21 @@ class SkirdaAuth{ } return await resp.json() } catch (error) { - console.error(error.message) - return null + return { + error: error.message, + } } } /** * @param {string} token - * @return SkirdaYggdrasilAuthResponse + * @return {Promise} * */ - static async #yggdrasilAuth(token) { + static async YggdrasilAuth(token) { const ygg_auth_api_url = 'https://skirda.brzezinski.ru' const resp = await fetch(`${ygg_auth_api_url}/yggdrasil/skirda/authenticate`, { headers: { - // 'Content-Type': 'application/json', + 'Content-Type': 'application/json', 'Authorization': token } }) @@ -100,7 +104,36 @@ class SkirdaAuth{ try { return await resp.json() } catch (error) { - console.error(error.message) + return { + error: error.message, + path: 'skirda/authenticate', + } } } + + /** + * @param {string} token + * @param {string} username + * @return {Promise} + * */ + static async CheckFreeUsername(token, username) { + const ygg_auth_api_url = 'https://skirda.brzezinski.ru' + const resp = await fetch(`${ygg_auth_api_url}/yggdrasil/skirda/checkFreeUsername`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token + } + }) + + try { + return await resp.json() + } catch (error) { + return { + error: error.message, + path: 'skirda/checkFreeUsername', + } + } + + } } \ No newline at end of file diff --git a/app/assets/js/skirda-auth/auth.js b/app/assets/js/skirda-auth/auth.js deleted file mode 100644 index e69de29..0000000 diff --git a/app/loginSkirda.ejs b/app/loginSkirda.ejs index 822c238..2376896 100644 --- a/app/loginSkirda.ejs +++ b/app/loginSkirda.ejs @@ -5,13 +5,38 @@
- Authorize through Skirda Discord + TEMP TEXT
-
- Мы открыли браузер для дальнейшей авторизации через DiscordAAAAAAAAAAA +
+
+ MEGA GHOPA WATCH YOR BROWSER DUMB FOOL +
+
+ +
-
+
diff --git a/app/settings.ejs b/app/settings.ejs index 4f944ce..eb15149 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -370,7 +370,7 @@
-