Compare commits
No commits in common. "f39b26a4ff4756af1fc3a0f84e628e5ff9771a70" and "0795219071b30129ec4386a52c5e1e19d26f0f51" have entirely different histories.
f39b26a4ff
...
0795219071
BIN
Callback/img/Logo.png
Normal file
BIN
Callback/img/Logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
BIN
Callback/img/bg.png
Normal file
BIN
Callback/img/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 MiB |
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-image: url(../../skirda/skirdaGoBackend/authskirda/templates/callback/img/bg.png);
|
background-image: url(img/bg.png);
|
||||||
background-repeat:no-repeat;
|
background-repeat:no-repeat;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
@ -150,7 +150,7 @@
|
|||||||
<div id="loginSkirdaAuthorizationWindow" style="display: none;">
|
<div id="loginSkirdaAuthorizationWindow" style="display: none;">
|
||||||
<div id="settingsAboutCurrentContent" class="Centered">
|
<div id="settingsAboutCurrentContent" class="Centered">
|
||||||
<div id="settingsAboutCurrentHeadline">
|
<div id="settingsAboutCurrentHeadline">
|
||||||
<img id="settingsAboutLogo" src="../../skirda/skirdaGoBackend/authskirda/templates/callback/img/Logo.png">
|
<img id="settingsAboutLogo" src="img/Logo.png">
|
||||||
<span id="settingsAboutTitle">Авторизация через Discord</span>
|
<span id="settingsAboutTitle">Авторизация через Discord</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="settingsAboutCurrentVersion">
|
<div id="settingsAboutCurrentVersion">
|
||||||
@ -166,7 +166,7 @@
|
|||||||
<div id="loginSkirdaAuthorizationWindow" >
|
<div id="loginSkirdaAuthorizationWindow" >
|
||||||
<div id="settingsAboutCurrentContent" class="Centered">
|
<div id="settingsAboutCurrentContent" class="Centered">
|
||||||
<div id="settingsAboutCurrentHeadline">
|
<div id="settingsAboutCurrentHeadline">
|
||||||
<img id="settingsAboutLogo" src="../../skirda/skirdaGoBackend/authskirda/templates/callback/img/Logo.png">
|
<img id="settingsAboutLogo" src="img/Logo.png">
|
||||||
<span id="settingsAboutTitle">Авторизация через Discord</span>
|
<span id="settingsAboutTitle">Авторизация через Discord</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="settingsAboutCurrentVersion" class="Centered">
|
<div id="settingsAboutCurrentVersion" class="Centered">
|
||||||
|
4096
Callback/launcher.css
Normal file
4096
Callback/launcher.css
Normal file
File diff suppressed because it is too large
Load Diff
@ -72,9 +72,8 @@ exports.addMojangAccount = async function(username, password){
|
|||||||
* @param {string} skirdaToken
|
* @param {string} skirdaToken
|
||||||
* */
|
* */
|
||||||
exports.addSkirdaAccount = async function(uuid, accessToken, username, displayName, skirdaToken){
|
exports.addSkirdaAccount = async function(uuid, accessToken, username, displayName, skirdaToken){
|
||||||
const ret = ConfigManager.addSkirdaAccount(uuid, accessToken, username, displayName, skirdaToken)
|
ConfigManager.addSkirdaAccount(uuid, accessToken, username, displayName, skirdaToken)
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addOfflineAccount = async function(usernameOffline){
|
exports.addOfflineAccount = async function(usernameOffline){
|
||||||
@ -294,40 +293,6 @@ async function validateSelectedMojangAccount(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
// require('./scripts/loginSkirdaDiscord')
|
|
||||||
/**
|
|
||||||
* Validate the selected account with Skirda's authserver. If the account is not valid,
|
|
||||||
* we will attempt to refresh the access token and update that value. If that fails, a
|
|
||||||
* new login will be required.
|
|
||||||
*
|
|
||||||
* @returns {Promise.<boolean>} Promise which resolves to true if the access token is valid,
|
|
||||||
* otherwise false.
|
|
||||||
*/
|
|
||||||
async function validateSelectedSkirdaAccount(){
|
|
||||||
const current = ConfigManager.getSelectedAccount()
|
|
||||||
const result = await SkirdaDiscordAuth.ValidateAccount(current.accessToken)
|
|
||||||
// const response = await MojangRestAPI.validate(current.accessToken, ConfigManager.getClientToken())
|
|
||||||
// const isValid = response.data
|
|
||||||
if(!result){
|
|
||||||
const refreshResponse = await MojangRestAPI.refresh(current.accessToken, ConfigManager.getClientToken())
|
|
||||||
if(refreshResponse.responseStatus === RestResponseStatus.SUCCESS) {
|
|
||||||
const session = refreshResponse.data
|
|
||||||
ConfigManager.updateMojangAuthAccount(current.uuid, session.accessToken)
|
|
||||||
ConfigManager.save()
|
|
||||||
} else {
|
|
||||||
log.error('Error while validating selected profile:', refreshResponse.error)
|
|
||||||
log.info('Account access token is invalid.')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
log.info('Account access token validated.')
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
log.info('Account access token validated.')
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -402,14 +367,10 @@ async function validateSelectedMicrosoftAccount(){
|
|||||||
exports.validateSelected = async function(){
|
exports.validateSelected = async function(){
|
||||||
const current = ConfigManager.getSelectedAccount()
|
const current = ConfigManager.getSelectedAccount()
|
||||||
|
|
||||||
switch (current.type) {
|
if(current.type === 'microsoft') {
|
||||||
case 'mojang':
|
|
||||||
return await validateSelectedMojangAccount()
|
|
||||||
// break
|
|
||||||
case 'microsoft':
|
|
||||||
return await validateSelectedMicrosoftAccount()
|
return await validateSelectedMicrosoftAccount()
|
||||||
// break
|
} else {
|
||||||
case 'skirda':
|
return await validateSelectedMojangAccount()
|
||||||
return await validateSelectedSkirdaAccount()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,6 @@ document.getElementById('avatarOverlay').onclick = async e => {
|
|||||||
// Bind selected account
|
// Bind selected account
|
||||||
function updateSelectedAccount(authUser){
|
function updateSelectedAccount(authUser){
|
||||||
let username = Lang.queryJS('landing.selectedAccount.noAccountSelected')
|
let username = Lang.queryJS('landing.selectedAccount.noAccountSelected')
|
||||||
console.log(authUser)
|
|
||||||
if(authUser != null){
|
if(authUser != null){
|
||||||
if(authUser.displayName != null){
|
if(authUser.displayName != null){
|
||||||
username = authUser.displayName
|
username = authUser.displayName
|
||||||
@ -246,7 +245,7 @@ const refreshServerStatus = async (fade = false) => {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
const servStat = await getServerStatus(47, serv.hostname, serv.port)
|
const servStat = await getServerStatus(47, serv.hostname, serv.port)
|
||||||
// console.log(servStat)
|
console.log(servStat)
|
||||||
pLabel = Lang.queryJS('landing.serverStatus.players')
|
pLabel = Lang.queryJS('landing.serverStatus.players')
|
||||||
pVal = servStat.players.online + '/' + servStat.players.max
|
pVal = servStat.players.online + '/' + servStat.players.max
|
||||||
|
|
||||||
|
@ -2,14 +2,8 @@
|
|||||||
// const fs = require('fs')
|
// const fs = require('fs')
|
||||||
// const {addSkirdaAccount} = require('configmanager')
|
// const {addSkirdaAccount} = require('configmanager')
|
||||||
// const auth_api_url = 'http://192.168.88.10:8083'
|
// const auth_api_url = 'http://192.168.88.10:8083'
|
||||||
// const auth_api_url = 'http://localhost:8083'
|
|
||||||
const auth_api_url = 'http://skirda-auth.brzezinski.ru'
|
const auth_api_url = 'http://skirda-auth.brzezinski.ru'
|
||||||
|
|
||||||
function uuidv4() {
|
|
||||||
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c =>
|
|
||||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
class SkirdaDiscordAuth{
|
class SkirdaDiscordAuth{
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} DiscordRedirectAuth
|
* @typedef {Object} DiscordRedirectAuth
|
||||||
@ -18,9 +12,9 @@ class SkirdaDiscordAuth{
|
|||||||
*
|
*
|
||||||
* @return {Promise<DiscordRedirectAuth | string>}
|
* @return {Promise<DiscordRedirectAuth | string>}
|
||||||
* */
|
* */
|
||||||
static temp_installId = uuidv4()
|
temp_installId = '26c175e2-71bd-4d80-9553-cc1575fc8ef9'
|
||||||
static async Init(){
|
async Init(){
|
||||||
const resp = await fetch(`${auth_api_url}/v1/auth/discord/init?installId=${SkirdaDiscordAuth.temp_installId}`)
|
const resp = await fetch(`${auth_api_url}/v1/auth/discord/init?installId=${this.temp_installId}`)
|
||||||
|
|
||||||
if (resp.statusCode !== 200){
|
if (resp.statusCode !== 200){
|
||||||
return await resp.text()
|
return await resp.text()
|
||||||
@ -34,13 +28,15 @@ class SkirdaDiscordAuth{
|
|||||||
// * @param timeout {number} Timeout to poll in seconds
|
// * @param timeout {number} Timeout to poll in seconds
|
||||||
* @return {SkirdaUserResp | string} Result of OAuth login
|
* @return {SkirdaUserResp | string} Result of OAuth login
|
||||||
*/
|
*/
|
||||||
static async CyclePolling(requestId){
|
async CyclePolling(requestId){
|
||||||
for (let i = 0; i < 15; i++) {
|
for (let i = 0; i < 15; i++) {
|
||||||
const resp = await SkirdaDiscordAuth._poll(requestId)
|
const resp = await this._poll(requestId)
|
||||||
|
|
||||||
|
// console.log(resp)
|
||||||
|
|
||||||
switch (resp.status){
|
switch (resp.status){
|
||||||
case 204:
|
case 204:
|
||||||
await SkirdaDiscordAuth._sleep(4000)
|
await this._sleep(4000)
|
||||||
continue
|
continue
|
||||||
case 200:
|
case 200:
|
||||||
return await resp.json()
|
return await resp.json()
|
||||||
@ -64,7 +60,7 @@ class SkirdaDiscordAuth{
|
|||||||
* @param jwtToken {string} JWT Token for auth
|
* @param jwtToken {string} JWT Token for auth
|
||||||
* @return {YggProfile | string} Result of auth
|
* @return {YggProfile | string} Result of auth
|
||||||
*/
|
*/
|
||||||
static async YggdrasilAuth(jwtToken){
|
async YggdrasilAuth(jwtToken){
|
||||||
const resp = await fetch(`${auth_api_url}/yggdrasil/skirda/authenticate`, {
|
const resp = await fetch(`${auth_api_url}/yggdrasil/skirda/authenticate`, {
|
||||||
headers:{
|
headers:{
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -89,89 +85,49 @@ class SkirdaDiscordAuth{
|
|||||||
* @param requestId {string}
|
* @param requestId {string}
|
||||||
* @return {Response}
|
* @return {Response}
|
||||||
* */
|
* */
|
||||||
static async _poll(requestId){
|
async _poll(requestId){
|
||||||
return await fetch(`${auth_api_url}/v1/auth/discord/periodicPolling?installId=${SkirdaDiscordAuth.temp_installId}&requestId=${requestId}`)
|
const resp = await fetch(`${auth_api_url}/v1/auth/discord/periodicPolling?installId=${this.temp_installId}&requestId=${requestId}`)
|
||||||
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
static _sleepSetTimeout_ctrl
|
_sleepSetTimeout_ctrl
|
||||||
/**
|
/**
|
||||||
* @param ms {number}
|
* @param ms {number}
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
static async _sleep(ms) {
|
async _sleep(ms) {
|
||||||
clearInterval(this._sleepSetTimeout_ctrl)
|
clearInterval(this._sleepSetTimeout_ctrl)
|
||||||
return new Promise(resolve => this._sleepSetTimeout_ctrl = setTimeout(resolve, ms))
|
return new Promise(resolve => this._sleepSetTimeout_ctrl = setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
static async ValidateAccount(jwtToken) {
|
|
||||||
const resp = await fetch(`${auth_api_url}/v1/auth/refresh`,{
|
|
||||||
headers:{
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': jwtToken
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// console.log(resp, resp.statusCode)
|
|
||||||
return resp.status === 200
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const skAuth = new SkirdaDiscordAuth()
|
const skAuth = new SkirdaDiscordAuth()
|
||||||
const loginSkirdaDiscordButton = document.getElementById('loginSkirdaDiscordInitAuth')
|
const loginSkirdaDiscordButton = document.getElementById('loginSkirdaDiscordInitAuth')
|
||||||
/**
|
|
||||||
* @return boolean
|
|
||||||
* */
|
|
||||||
async function InitSkirdaDiscordLogin (){
|
async function InitSkirdaDiscordLogin (){
|
||||||
const res = await SkirdaDiscordAuth.Init()
|
const res = await skAuth.Init()
|
||||||
let redir
|
|
||||||
try {
|
|
||||||
redir = JSON.parse(res)
|
|
||||||
} catch (e) {
|
|
||||||
SpawnError(Lang.queryJS('login.error.unknown'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(redir)
|
|
||||||
|
|
||||||
|
const redir = JSON.parse(res) //FIXME
|
||||||
|
console.log(redir)
|
||||||
const resOpenUrl = await shell.openExternal(redir.redirectUrl)
|
const resOpenUrl = await shell.openExternal(redir.redirectUrl)
|
||||||
|
|
||||||
const skirdaAuth = await SkirdaDiscordAuth.CyclePolling(redir.requestId)
|
const skirdaAuth = await skAuth.CyclePolling(redir.requestId)
|
||||||
//TODO validate resp
|
//TODO validate resp
|
||||||
// console.log(skirdaAuth)
|
console.log(skirdaAuth)
|
||||||
|
// skirdaAuth.skirdaUserId = '2a5fd868-1ac5-4ccf-a22f-183822de2d61'
|
||||||
|
|
||||||
if (typeof skirdaAuth.token !== 'string'){
|
const yggAuth = await skAuth.YggdrasilAuth(skirdaAuth.token)
|
||||||
SpawnError(Lang.queryJS('login.error.unknown'))
|
//TODO validate resp
|
||||||
return
|
const yggAuthRes = JSON.parse(yggAuth)
|
||||||
}
|
console.log(yggAuthRes)
|
||||||
|
|
||||||
const yggAuth = await SkirdaDiscordAuth.YggdrasilAuth(skirdaAuth.token)
|
|
||||||
let yggAuthRes
|
|
||||||
try {
|
|
||||||
yggAuthRes = JSON.parse(yggAuth)
|
|
||||||
} catch (e) {
|
|
||||||
SpawnError(Lang.queryJS('login.error.unknown'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// console.log(yggAuthRes)
|
|
||||||
|
|
||||||
|
|
||||||
AuthManager.addSkirdaAccount(yggAuthRes.profile.id, skirdaAuth.token, skirdaAuth.skirdaUserId, yggAuthRes.profile.name, skirdaAuth.token).then((value) => {
|
AuthManager.addSkirdaAccount(yggAuthRes.profile.id, skirdaAuth.token, skirdaAuth.skirdaUserId, yggAuthRes.profile.name, skirdaAuth.token)
|
||||||
updateSelectedAccount(value)
|
|
||||||
})
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
switchView(VIEWS.loginSkirdaDiscord, VIEWS.landing, 500, 500)
|
switchView(VIEWS.loginSkirdaDiscord, VIEWS.landing, 500, 500)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
function SpawnError(actualDisplayableError){
|
|
||||||
setOverlayContent(actualDisplayableError.title, actualDisplayableError.desc, Lang.queryJS('login.tryAgain'))
|
|
||||||
setOverlayHandler(() => {
|
|
||||||
formDisabled(false)
|
|
||||||
toggleOverlay(false)
|
|
||||||
})
|
|
||||||
toggleOverlay(true)
|
|
||||||
}
|
|
@ -667,7 +667,7 @@ function populateAuthAccounts(){
|
|||||||
|
|
||||||
authKeys.forEach((val) => {
|
authKeys.forEach((val) => {
|
||||||
const acc = authAccounts[val]
|
const acc = authAccounts[val]
|
||||||
// console.log(acc)
|
console.log(acc)
|
||||||
|
|
||||||
const accHtml = `<div class="settingsAuthAccount" uuid="${acc.uuid}">
|
const accHtml = `<div class="settingsAuthAccount" uuid="${acc.uuid}">
|
||||||
<div class="settingsAuthAccountLeft">
|
<div class="settingsAuthAccountLeft">
|
||||||
|
@ -79,9 +79,9 @@ async function showMainUI(data){
|
|||||||
|
|
||||||
// If this is enabled in a development environment we'll get ratelimited.
|
// If this is enabled in a development environment we'll get ratelimited.
|
||||||
// The relaunch frequency is usually far too high.
|
// The relaunch frequency is usually far too high.
|
||||||
// if(!isDev && isLoggedIn){
|
if(!isDev && isLoggedIn){
|
||||||
validateSelectedAccount()
|
validateSelectedAccount()
|
||||||
// }
|
}
|
||||||
|
|
||||||
if(ConfigManager.isFirstLaunch()){
|
if(ConfigManager.isFirstLaunch()){
|
||||||
currentView = VIEWS.welcome
|
currentView = VIEWS.welcome
|
||||||
|
@ -153,12 +153,12 @@ requiredValue = "* Требуется"
|
|||||||
|
|
||||||
[js.login.error.unknown]
|
[js.login.error.unknown]
|
||||||
title = "Неизвестная ошибка при авторизации"
|
title = "Неизвестная ошибка при авторизации"
|
||||||
desc = "Произошла неизвестная ошибка. Проверте консоль (Ctrl + Shift + I) чтобы узнать, что случулось."
|
desc = "Произошла неизвестная ошибка. Проверте консоль для дополнительных деталей."
|
||||||
|
|
||||||
[js.landing.launch]
|
[js.landing.launch]
|
||||||
pleaseWait = "Пожалуйста, подождите..."
|
pleaseWait = "Пожалуйста, подождите..."
|
||||||
failureTitle = "Ошибка при запуске :("
|
failureTitle = "Ошибка при запуске :("
|
||||||
failureText = "Сделайте скриншот из консоли (CTRL + Shift + I) и скажите Грише, что все пошло по пизде."
|
failureText = "Сделайте скриншот из консоли (CTRL + Shift + i) и скажите Грише, что все пошло по пизде."
|
||||||
okay = "Окей"
|
okay = "Окей"
|
||||||
|
|
||||||
[js.landing.selectedAccount]
|
[js.landing.selectedAccount]
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
<div id="iframecontainer">
|
<div id="iframecontainer">
|
||||||
<iframe id="dynmapiframe" src="https://minemap.gregbrzezinski.com" frameborder="0"></iframe>
|
<iframe id="dynmapiframe" src="https://minemap.gregbrzezinski.com" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<!-- <script src="./assets/js/scripts/dynmap.js"></script>-->
|
<script src="./assets/js/scripts/dynmap.js"></script>
|
||||||
</div>
|
</div>
|
@ -113,7 +113,7 @@
|
|||||||
<div id="iframecontainer">
|
<div id="iframecontainer">
|
||||||
<iframe id="dynmapiframe" src="https://mc.westeroscraft.com/#" frameborder="0"></iframe>
|
<iframe id="dynmapiframe" src="https://mc.westeroscraft.com/#" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<!-- <script src="./assets/js/scripts/dynmap.js"></script>-->
|
<script src="./assets/js/scripts/dynmap.js"></script>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div id="newsContent" article="-1" style="display: none;">-->
|
<!-- <div id="newsContent" article="-1" style="display: none;">-->
|
||||||
<!-- <div id="newsStatusContainer">-->
|
<!-- <div id="newsStatusContainer">-->
|
||||||
|
Loading…
Reference in New Issue
Block a user