check for viaversion.github.io, updated some auth

This commit is contained in:
creeper123123321 2020-11-07 22:40:14 -03:00 committed by GitHub
parent 6038b18c9a
commit 35c90c8055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,7 +63,7 @@
alert("Couldn't authenticate with Minecraft.ID: " + urlParams.get("mcauth_msg")); alert("Couldn't authenticate with Minecraft.ID: " + urlParams.get("mcauth_msg"));
} }
var wsUrl = "wss://" + window.location.host + "/ws"; var wsUrl = window.location.host == "viaversion.github.io" ? prompt("VIAaaS instance WS URL") : "wss://" + window.location.host + "/ws";
var socket = null; var socket = null;
var connectionStatus = document.getElementById("connection_status"); var connectionStatus = document.getElementById("connection_status");
@ -81,7 +81,7 @@
username: $("#email").val(), username: $("#email").val(),
password: $("#password").val(), password: $("#password").val(),
clientToken: clientToken, clientToken: clientToken,
}), }),
contentType: "application/json", contentType: "application/json",
dataType: "json" dataType: "json"
}).done((data) => { }).done((data) => {
@ -284,11 +284,12 @@
removeToken(parsed.token); removeToken(parsed.token);
} }
} else if (parsed.action == "session_hash_request") { } else if (parsed.action == "session_hash_request") {
if (confirm("Confirm auth request sent from VIAaaS instance? info: " + event.data)) { if (confirm("Allow auth impersonation from VIAaaS instance? info: " + JSON.stringify(parsed))) {
let accounts = getMcAccounts().filter(it => it.name.toLowerCase() == parsed.user.toLowerCase()); let accounts = getMcAccounts().filter(it => it.name.toLowerCase() == parsed.user.toLowerCase());
accounts.forEach(it => { accounts.forEach(it => {
refreshAccountIfNeeded(it, (data) => { refreshAccountIfNeeded(it, (data) => {
$.ajax({type: "post", $.ajax({
type: "post",
url: localStorage.getItem("cors-proxy") + "https://sessionserver.mojang.com/session/minecraft/join", url: localStorage.getItem("cors-proxy") + "https://sessionserver.mojang.com/session/minecraft/join",
data: JSON.stringify({ data: JSON.stringify({
accessToken: data.accessToken, accessToken: data.accessToken,
@ -301,17 +302,20 @@
confirmJoin(parsed.session_hash); confirmJoin(parsed.session_hash);
}).fail((e) => { }).fail((e) => {
console.log(e); console.log(e);
alert("Failed to authenticate to Minecraft backend server!"); confirmJoin(parsed.session_hash);
alert("Failed to contact session server!");
}); });
}, () => { }, () => {
if (confirm("Couldn't refresh " + parsed.user + " account in browser. Continue without authentication (works on LAN worlds)?")) { confirmJoin(parsed.session_hash);
confirmJoin(parsed.session_hash); alert("Couldn't refresh " + parsed.user + " account in browser.");
}
}); });
}); });
if (accounts.length == 0 && confirm("Couldn't find " + parsed.user + " account in browser. Continue without authentication (works on LAN worlds)?")) { if (accounts.length == 0) {
alert("Couldn't find " + parsed.user + " account in browser.");
confirmJoin(parsed.session_hash); confirmJoin(parsed.session_hash);
} }
} else if (confirm("Continue without authentication (works on LAN worlds)?")) {
confirmJoin(parsed.session_hash);
} }
} }
}; };