fixes
This commit is contained in:
parent
a3b5f2dd53
commit
3ae025e288
@ -401,8 +401,8 @@ async function validateSelectedMojangAccount(){
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -411,19 +411,9 @@ async function validateSelectedMojangAccount(){
|
||||
* @returns {Promise.<boolean>} Promise which resolves to true if the access token is valid,
|
||||
* otherwise false.
|
||||
*/
|
||||
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',
|
||||
'Authorization': current.accessToken,
|
||||
}
|
||||
})
|
||||
|
||||
console.log(resp)
|
||||
return resp.status === 200
|
||||
return await SkirdaAuth.YggRefresh(current.accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@ const ConfigManager = require('./configmanager')
|
||||
|
||||
// Old WesterosCraft url.
|
||||
// exports.REMOTE_DISTRO_URL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/distribution.json'
|
||||
exports.REMOTE_DISTRO_URL = 'http://localhost:8090/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'http://localhost:8090/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'https://helios-files.geekcorner.eu.org/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'https://skirda-minecraft-distribution.brzezinski.ru/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'https://helios-files.geekcorner.eu.org/distribution.json'
|
||||
@ -12,6 +12,7 @@ exports.REMOTE_DISTRO_URL = 'http://localhost:8090/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'http://skirda-nebula.brzezinski.ru/distribution.json'
|
||||
// exports.REMOTE_DISTRO_URL = 'http://gregbrzezinski:8080/distribution/manifest'
|
||||
// exports.REMOTE_DISTRO_URL = 'http://localhost:8080/distribution/files/files/distribution.json'
|
||||
exports.REMOTE_DISTRO_URL = 'https://cdn.brzezinski.ru/nebula/distribution.json'
|
||||
|
||||
const api = new DistributionAPI(
|
||||
ConfigManager.getLauncherDirectory(),
|
||||
|
@ -362,6 +362,7 @@ class ProcessBuilder {
|
||||
|
||||
let args = []
|
||||
|
||||
|
||||
// Classpath Argument
|
||||
args.push('-cp')
|
||||
args.push(this.classpathArg(mods, tempNativePath).join(ProcessBuilder.getClasspathSeparator()))
|
||||
@ -375,10 +376,11 @@ 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)')
|
||||
|
||||
args.push('-Dminecraft.api.auth.host=https://yggdrasil.brzezinski.ru/auth')
|
||||
args.push('-Dminecraft.api.account.host=https://yggdrasil.brzezinski.ru/account')
|
||||
args.push('-Dminecraft.api.session.host=https://yggdrasil.brzezinski.ru')
|
||||
args.push('-Dminecraft.api.services.host=https://yggdrasil.brzezinski.ru/services')
|
||||
|
||||
// Main Java Class
|
||||
args.push(this.modManifest.mainClass)
|
||||
@ -409,6 +411,12 @@ class ProcessBuilder {
|
||||
// Debug securejarhandler
|
||||
// args.push('-Dbsl.debug=true')
|
||||
|
||||
args.push('-Dminecraft.api.auth.host=https://yggdrasil.brzezinski.ru/auth')
|
||||
args.push('-Dminecraft.api.account.host=https://yggdrasil.brzezinski.ru/account')
|
||||
args.push('-Dminecraft.api.session.host=https://yggdrasil.brzezinski.ru')
|
||||
args.push('-Dminecraft.api.services.host=https://yggdrasil.brzezinski.ru/services')
|
||||
|
||||
|
||||
if(this.modManifest.arguments.jvm != null) {
|
||||
for(const argStr of this.modManifest.arguments.jvm) {
|
||||
args.push(argStr
|
||||
|
@ -104,10 +104,12 @@ loginOptionSkirdaAuth.onclick = (e) => {
|
||||
SkirdaAuth.Init().then((result) => {
|
||||
if (result.error) {
|
||||
console.error(result)
|
||||
switchView(getCurrentView(), VIEWS.loginOptions, 500, 500, async () => {})
|
||||
} else {
|
||||
SkirdaAuth.YggdrasilAuth(result.token).then(ygg_res => {
|
||||
if (ygg_res.error !== undefined) {
|
||||
console.error(ygg_res)
|
||||
switchView(getCurrentView(), VIEWS.loginOptions, 500, 500, async () => {})
|
||||
} else {
|
||||
AuthManager.addSkirdaAccount(
|
||||
ygg_res.profile.id,
|
||||
|
@ -1,5 +1,3 @@
|
||||
const sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth'
|
||||
|
||||
/** @typedef {Object} SkirdaAuthError
|
||||
* @property {string} error
|
||||
*/
|
||||
@ -33,6 +31,10 @@ const sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth'
|
||||
|
||||
|
||||
class SkirdaAuth {
|
||||
static #ygg_auth_api_url = 'https://skirda.brzezinski.ru/yggdrasil'
|
||||
static #sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth'
|
||||
|
||||
|
||||
constructor() {
|
||||
console.log('Skirda Auth')
|
||||
}
|
||||
@ -41,16 +43,20 @@ class SkirdaAuth {
|
||||
* @returns {Promise<SkirdaAuthResponse|SkirdaAuthError>}
|
||||
*/
|
||||
static async #fetchInit() {
|
||||
const resp = await fetch(`${sk_tg_auth_api_url}/telegram/init`, {})
|
||||
const resp = await fetch(`${SkirdaAuth.#sk_tg_auth_api_url}/telegram/init`, {})
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Response status: ${resp.status}`)
|
||||
return {
|
||||
error: 'unknown error on auth request'
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return await resp.json()
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
return null
|
||||
return {
|
||||
error: error.message,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +67,10 @@ class SkirdaAuth {
|
||||
static async Init() {
|
||||
const initResp = await SkirdaAuth.#fetchInit()
|
||||
|
||||
if (initResp.error !== undefined) {
|
||||
return initResp
|
||||
}
|
||||
|
||||
await shell.openExternal(initResp.redirect_url)
|
||||
|
||||
// const yggResp = await SkirdaAuth.#yggdrasilAuth(authResult.token)
|
||||
@ -78,7 +88,9 @@ class SkirdaAuth {
|
||||
const resp = await fetch(subscribe_url, {})
|
||||
try {
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Response status: ${resp.status}`)
|
||||
return {
|
||||
error: 'unknown error on subscribe to auth result',
|
||||
}
|
||||
}
|
||||
return await resp.json()
|
||||
} catch (error) {
|
||||
@ -89,16 +101,15 @@ class SkirdaAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} token
|
||||
* @param {string} skirdaToken
|
||||
* @return {Promise<SkirdaYggdrasilAuthResponse|YggdrasilError>}
|
||||
* */
|
||||
static async YggdrasilAuth(token) {
|
||||
const ygg_auth_api_url = 'https://skirda.brzezinski.ru'
|
||||
const resp = await fetch(`${ygg_auth_api_url}/yggdrasil/skirda/authenticate`, {
|
||||
static async YggdrasilAuth(skirdaToken) {
|
||||
const resp = await fetch(`${SkirdaAuth.#ygg_auth_api_url}/skirda/authenticate`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token
|
||||
}
|
||||
'Authorization': skirdaToken
|
||||
},
|
||||
})
|
||||
|
||||
try {
|
||||
@ -117,8 +128,7 @@ class SkirdaAuth {
|
||||
* @return {Promise<bool|YggdrasilError>}
|
||||
* */
|
||||
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`, {
|
||||
const resp = await fetch(`${SkirdaAuth.#ygg_auth_api_url}/skirda/checkFreeUsername`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -136,4 +146,27 @@ class SkirdaAuth {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} yggToken
|
||||
* @param {string} skirdaToken
|
||||
* @return {Promise<boolean>}
|
||||
* */
|
||||
static async YggRefresh(yggToken, skirdaToken) {
|
||||
const resp = await fetch(`${SkirdaAuth.#ygg_auth_api_url}/refresh`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
'accessToken': yggToken,
|
||||
'clientToken': skirdaToken, // This is skirda token
|
||||
})
|
||||
})
|
||||
|
||||
try {
|
||||
const respJSON = await resp.json()
|
||||
return respJSON.error === undefined
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user