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