mirror of
https://github.com/redstrate/Kawari.git
synced 2025-05-06 12:47:45 +00:00
Add Bootstrap styling for the launcher page, implement launcher login
Instead of the placeholder SID, it sets it to an actual one that can be used with the lobby server.
This commit is contained in:
parent
a9ec268a4f
commit
def9b4ab48
3 changed files with 174 additions and 120 deletions
|
@ -1,146 +1,190 @@
|
||||||
<!DOCTYPE html>
|
{% extends "layout.html" %}
|
||||||
<html lang=en>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge;">
|
|
||||||
<title>Kawari Launcher</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
{% block title %}Kawari Launcher{% endblock %}
|
||||||
<p>Welcome to Kawari!</p>
|
|
||||||
|
|
||||||
<input type="button" value="System Info" onclick="window.external.user('systemInfo');" />
|
{% block body %}
|
||||||
<input type="button" value="Play" onclick="window.external.user('startPlay');" />
|
<p>Welcome to Kawari!</p>
|
||||||
<input type="button" value="Login" onclick="window.external.user('login=auth,ok,sid,9001,terms,1,region,2,etmadd,0,playable,1,ps3pkg,0,maxex,5,product,1');" />
|
|
||||||
<input type="button" value="Login Error" onclick="window.external.user('login=auth,ng,err,Test error.');" />
|
|
||||||
<input type="button" value="Exit" onclick="window.external.user('requestExit');" />
|
|
||||||
<input type="button" value="Reboot" onclick="window.external.user('requestReboot');" />
|
|
||||||
<input type="button" value="Open Google" onclick="window.external.user('link=https://google.com/');" />
|
|
||||||
<input type="button" value="Accept EULA" onclick="window.external.user('eulaOk');" />
|
|
||||||
<input type="button" value="Accept Ex EULA" onclick="window.external.user('eulaExOk');" />
|
|
||||||
<input type="button" value="Disable DX11" onclick="window.external.user('config=dx11enabled=0');" />
|
|
||||||
<input type="button" value="Enable DX11" onclick="window.external.user('config=dx11enabled=1');" />
|
|
||||||
<input type="button" value="Request Config" onclick="window.external.user('requestConfig');" />
|
|
||||||
<input type="button" value="Request Login Url" onclick="window.external.user('requestLoginUrl');" />
|
|
||||||
<input type="button" value="Request Platform" onclick="window.external.user('requestDP');" />
|
|
||||||
<input type="button" value="Config Tool" onclick="window.external.user('configTransport');" />
|
|
||||||
|
|
||||||
<p id="replace-me">meh</p>
|
<form id="login">
|
||||||
|
<label for="sqexid" class="form-label">Username</label><br>
|
||||||
|
<input type='text' id='sqexid' name='sqexid' class="form-control"/><br>
|
||||||
|
<label for="password" class="form-label">Password</label><br>
|
||||||
|
<input id='password' name='password' class="form-control" type="password"/><br>
|
||||||
|
<label for="otppw" class="form-label">One-Time Password</label><br>
|
||||||
|
<input type='text' id='otppw' name='otppw' class="form-control"/><br>
|
||||||
|
<input type="hidden" id="_STORED_" name="_STORED_" value="34657" />
|
||||||
|
<button type='submit' class="btn btn-primary">Login</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<input type="button" value="System Info" onclick="window.external.user('systemInfo');" />
|
||||||
function checkHandlerType(e) {
|
<input type="button" value="Play" onclick="window.external.user('startPlay');" />
|
||||||
if ('function' != typeof e) throw new Error('Protocol Callback is not function.');
|
<input type="button" value="Login" onclick="window.external.user('login=auth,ok,sid,9001,terms,1,region,2,etmadd,0,playable,1,ps3pkg,0,maxex,5,product,1');" />
|
||||||
return e
|
<input type="button" value="Login Error" onclick="window.external.user('login=auth,ng,err,Test error.');" />
|
||||||
}
|
<input type="button" value="Exit" onclick="window.external.user('requestExit');" />
|
||||||
|
<input type="button" value="Reboot" onclick="window.external.user('requestReboot');" />
|
||||||
|
<input type="button" value="Open Google" onclick="window.external.user('link=https://google.com/');" />
|
||||||
|
<input type="button" value="Accept EULA" onclick="window.external.user('eulaOk');" />
|
||||||
|
<input type="button" value="Accept Ex EULA" onclick="window.external.user('eulaExOk');" />
|
||||||
|
<input type="button" value="Disable DX11" onclick="window.external.user('config=dx11enabled=0');" />
|
||||||
|
<input type="button" value="Enable DX11" onclick="window.external.user('config=dx11enabled=1');" />
|
||||||
|
<input type="button" value="Request Config" onclick="window.external.user('requestConfig');" />
|
||||||
|
<input type="button" value="Request Login Url" onclick="window.external.user('requestLoginUrl');" />
|
||||||
|
<input type="button" value="Request Platform" onclick="window.external.user('requestDP');" />
|
||||||
|
<input type="button" value="Config Tool" onclick="window.external.user('configTransport');" />
|
||||||
|
|
||||||
function fromAppConfig(thing) {
|
<p id="replace-me">meh</p>
|
||||||
document.getElementById('replace-me').innerText += "config: " + JSON.stringify(thing);
|
|
||||||
}
|
|
||||||
window.fromAppConfig = this.checkHandlerType(fromAppConfig);
|
|
||||||
|
|
||||||
function fromAppWarn(thing) {
|
<script type="text/javascript">
|
||||||
document.getElementById('replace-me').innerText += "warn: " + JSON.stringify(thing);
|
let req;
|
||||||
}
|
function readystatechange(event) {
|
||||||
window.fromAppWarn = this.checkHandlerType(fromAppWarn);
|
if (req.readyState == 4) {
|
||||||
|
// This login endpoint sends a "window.external.user" which we need to evaludate.
|
||||||
|
eval(req.response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fromAppStartVersionCheck(thing) {
|
function error(event) {
|
||||||
document.getElementById('replace-me').innerText += "version: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "login error: " + event;
|
||||||
|
}
|
||||||
|
|
||||||
// the official launcher does some preparation stuff here, and when it's finished it tells it the ID it just recieved
|
function login() {
|
||||||
window.external.user('received=' + thing.ID);
|
let sqexid = document.getElementById('sqexid').value;
|
||||||
}
|
let password = document.getElementById('password').value;
|
||||||
window.fromAppStartVersionCheck = this.checkHandlerType(fromAppStartVersionCheck);
|
let otppw = document.getElementById('otppw').value;
|
||||||
|
let stored = document.getElementById('_STORED_').value;
|
||||||
|
|
||||||
function fromAppDP(thing) {
|
req = new XMLHttpRequest();
|
||||||
document.getElementById('replace-me').innerText += "dp: " + JSON.stringify(thing);
|
req.addEventListener("readystatechange", readystatechange);
|
||||||
}
|
req.addEventListener("error", error);
|
||||||
window.fromAppDP = this.checkHandlerType(fromAppDP);
|
req.open("POST", "http://ffxiv-login.square.localhost/oauth/ffxivarr/login/login.send");
|
||||||
|
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
req.send("sqexid=" + sqexid + "&password=" + password + "&otppw=" + otppw + "&_STORED_=" + stored);
|
||||||
|
}
|
||||||
|
|
||||||
function fromAppDisplaySettings(thing) {
|
function checkHandlerType(e) {
|
||||||
document.getElementById('replace-me').innerText += "display settings: " + JSON.stringify(thing);
|
if ('function' != typeof e) throw new Error('Protocol Callback is not function.');
|
||||||
}
|
return e
|
||||||
window.fromAppDisplaySettings = this.checkHandlerType(fromAppDisplaySettings);
|
}
|
||||||
|
|
||||||
function fromAppResumeInfo(thing) {
|
function fromAppConfig(thing) {
|
||||||
document.getElementById('replace-me').innerText += "resume info: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "config: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppConfig = this.checkHandlerType(fromAppConfig);
|
||||||
|
|
||||||
// acknowledge
|
function fromAppWarn(thing) {
|
||||||
window.external.user('received=' + thing.ID);
|
document.getElementById('replace-me').innerText += "warn: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppResumeInfo = this.checkHandlerType(fromAppResumeInfo);
|
window.fromAppWarn = this.checkHandlerType(fromAppWarn);
|
||||||
|
|
||||||
function fromAppLoginUrl(thing) {
|
function fromAppStartVersionCheck(thing) {
|
||||||
document.getElementById('replace-me').innerText += "login info: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "version: " + JSON.stringify(thing);
|
||||||
}
|
|
||||||
window.fromAppLoginUrl = this.checkHandlerType(fromAppLoginUrl);
|
|
||||||
|
|
||||||
function fromAppExAgree(thing) {
|
// the official launcher does some preparation stuff here, and when it's finished it tells it the ID it just recieved
|
||||||
document.getElementById('replace-me').innerText += "ex agree: " + JSON.stringify(thing);
|
window.external.user('received=' + thing.ID);
|
||||||
}
|
}
|
||||||
window.fromAppExAgree = this.checkHandlerType(fromAppExAgree);
|
window.fromAppStartVersionCheck = this.checkHandlerType(fromAppStartVersionCheck);
|
||||||
|
|
||||||
function fromAppStartDownload(thing) {
|
function fromAppDP(thing) {
|
||||||
document.getElementById('replace-me').innerText += "start download: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "dp: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppStartDownload = this.checkHandlerType(fromAppStartDownload);
|
window.fromAppDP = this.checkHandlerType(fromAppDP);
|
||||||
|
|
||||||
function fromAppDownloadProgress(thing) {
|
function fromAppDisplaySettings(thing) {
|
||||||
document.getElementById('replace-me').innerText += "download prog: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "display settings: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppDownloadProgress = this.checkHandlerType(fromAppDownloadProgress);
|
window.fromAppDisplaySettings = this.checkHandlerType(fromAppDisplaySettings);
|
||||||
|
|
||||||
function fromAppInstallProgress(thing) {
|
function fromAppResumeInfo(thing) {
|
||||||
document.getElementById('replace-me').innerText += "install prog: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "resume info: " + JSON.stringify(thing);
|
||||||
}
|
|
||||||
window.fromAppInstallProgress = this.checkHandlerType(fromAppInstallProgress);
|
|
||||||
|
|
||||||
function fromAppStartInstall(thing) {
|
// acknowledge
|
||||||
document.getElementById('replace-me').innerText += "start install: " + JSON.stringify(thing);
|
window.external.user('received=' + thing.ID);
|
||||||
}
|
}
|
||||||
window.fromAppStartInstall = this.checkHandlerType(fromAppStartInstall);
|
window.fromAppResumeInfo = this.checkHandlerType(fromAppResumeInfo);
|
||||||
|
|
||||||
function fromAppWaitPlay(thing) {
|
function fromAppLoginUrl(thing) {
|
||||||
document.getElementById('replace-me').innerText += "wait play: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "login info: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppLoginUrl = this.checkHandlerType(fromAppLoginUrl);
|
||||||
|
|
||||||
// the official launcher does some preparation stuff here, and when it's finished it tells it the ID it just recieved
|
function fromAppExAgree(thing) {
|
||||||
window.external.user('received=' + thing.ID);
|
document.getElementById('replace-me').innerText += "ex agree: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppExAgree = this.checkHandlerType(fromAppExAgree);
|
||||||
|
|
||||||
// it requests the config again?
|
function fromAppStartDownload(thing) {
|
||||||
window.external.user('requestConfig');
|
document.getElementById('replace-me').innerText += "start download: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppWaitPlay = this.checkHandlerType(fromAppWaitPlay);
|
window.fromAppStartDownload = this.checkHandlerType(fromAppStartDownload);
|
||||||
|
|
||||||
function fromAppStartFileCheck(thing) {
|
function fromAppDownloadProgress(thing) {
|
||||||
document.getElementById('replace-me').innerText += "file check: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "download prog: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppStartFileCheck = this.checkHandlerType(fromAppStartFileCheck);
|
window.fromAppDownloadProgress = this.checkHandlerType(fromAppDownloadProgress);
|
||||||
|
|
||||||
function fromAppFileCheckProgress(thing) {
|
function fromAppInstallProgress(thing) {
|
||||||
document.getElementById('replace-me').innerText += "file check prog: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "install prog: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppFileCheckProgress = this.checkHandlerType(fromAppFileCheckProgress);
|
window.fromAppInstallProgress = this.checkHandlerType(fromAppInstallProgress);
|
||||||
|
|
||||||
function fromAppFinishedFileCheck(thing) {
|
function fromAppStartInstall(thing) {
|
||||||
document.getElementById('replace-me').innerText += "file check finished: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "start install: " + JSON.stringify(thing);
|
||||||
}
|
}
|
||||||
window.fromAppFinishedFileCheck = this.checkHandlerType(fromAppFinishedFileCheck);
|
window.fromAppStartInstall = this.checkHandlerType(fromAppStartInstall);
|
||||||
|
|
||||||
function fromAppServiceAgreement(thing) {
|
function fromAppWaitPlay(thing) {
|
||||||
document.getElementById('replace-me').innerText += "agreement: " + JSON.stringify(thing);
|
document.getElementById('replace-me').innerText += "wait play: " + JSON.stringify(thing);
|
||||||
}
|
|
||||||
window.fromAppServiceAgreement = this.checkHandlerType(fromAppServiceAgreement);
|
|
||||||
|
|
||||||
function fromAppDialog(thing) {
|
// the official launcher does some preparation stuff here, and when it's finished it tells it the ID it just recieved
|
||||||
document.getElementById('replace-me').innerText += "dialog: " + JSON.stringify(thing);
|
window.external.user('received=' + thing.ID);
|
||||||
}
|
|
||||||
window.fromAppDialog = this.checkHandlerType(fromAppDialog);
|
|
||||||
|
|
||||||
// this is what the retail launcher does
|
// it requests the config again?
|
||||||
window.external.user('permissionFromApp=1');
|
window.external.user('requestConfig');
|
||||||
window.external.user('requestDP');
|
}
|
||||||
window.external.user('requestConfig');
|
window.fromAppWaitPlay = this.checkHandlerType(fromAppWaitPlay);
|
||||||
window.external.user('requestDisplaySettings');
|
|
||||||
window.external.user('requestResumeInfo');
|
function fromAppStartFileCheck(thing) {
|
||||||
</script>
|
document.getElementById('replace-me').innerText += "file check: " + JSON.stringify(thing);
|
||||||
</body>
|
}
|
||||||
</html>
|
window.fromAppStartFileCheck = this.checkHandlerType(fromAppStartFileCheck);
|
||||||
|
|
||||||
|
function fromAppFileCheckProgress(thing) {
|
||||||
|
document.getElementById('replace-me').innerText += "file check prog: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppFileCheckProgress = this.checkHandlerType(fromAppFileCheckProgress);
|
||||||
|
|
||||||
|
function fromAppFinishedFileCheck(thing) {
|
||||||
|
document.getElementById('replace-me').innerText += "file check finished: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppFinishedFileCheck = this.checkHandlerType(fromAppFinishedFileCheck);
|
||||||
|
|
||||||
|
function fromAppServiceAgreement(thing) {
|
||||||
|
document.getElementById('replace-me').innerText += "agreement: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppServiceAgreement = this.checkHandlerType(fromAppServiceAgreement);
|
||||||
|
|
||||||
|
function fromAppDialog(thing) {
|
||||||
|
document.getElementById('replace-me').innerText += "dialog: " + JSON.stringify(thing);
|
||||||
|
}
|
||||||
|
window.fromAppDialog = this.checkHandlerType(fromAppDialog);
|
||||||
|
|
||||||
|
// this is what the retail launcher does
|
||||||
|
window.external.user('permissionFromApp=1');
|
||||||
|
window.external.user('requestDP');
|
||||||
|
window.external.user('requestConfig');
|
||||||
|
window.external.user('requestDisplaySettings');
|
||||||
|
window.external.user('requestResumeInfo');
|
||||||
|
|
||||||
|
// setup form submission
|
||||||
|
const form = document.getElementById("login");
|
||||||
|
form.addEventListener("submit", function (event) {
|
||||||
|
// ie11 is amazing
|
||||||
|
if (event.preventDefault) {
|
||||||
|
event.preventDefault();
|
||||||
|
} else {
|
||||||
|
event.returnValue = false;
|
||||||
|
}
|
||||||
|
login();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge;">
|
||||||
<title>{% block title %}some website{% endblock %}</title>
|
<title>{% block title %}some website{% endblock %}</title>
|
||||||
<link href="/static/bootstrap.min.css" rel="stylesheet">
|
<link href="/static/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -5,9 +5,16 @@ use kawari::config::get_config;
|
||||||
use minijinja::Environment;
|
use minijinja::Environment;
|
||||||
use minijinja::context;
|
use minijinja::context;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use tower_http::services::ServeDir;
|
||||||
|
|
||||||
fn setup_default_environment() -> Environment<'static> {
|
fn setup_default_environment() -> Environment<'static> {
|
||||||
let mut env = Environment::new();
|
let mut env = Environment::new();
|
||||||
|
env.add_template_owned(
|
||||||
|
"layout.html",
|
||||||
|
std::fs::read_to_string("resources/templates/layout.html")
|
||||||
|
.expect("Failed to find template!"),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
env.add_template_owned(
|
env.add_template_owned(
|
||||||
"launcher.html",
|
"launcher.html",
|
||||||
std::fs::read_to_string("resources/templates/launcher.html")
|
std::fs::read_to_string("resources/templates/launcher.html")
|
||||||
|
@ -41,7 +48,9 @@ async fn root(Query(_): Query<Params>) -> Html<String> {
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let app = Router::new().route("/v700/index.html", get(root));
|
let app = Router::new()
|
||||||
|
.route("/v700/index.html", get(root))
|
||||||
|
.nest_service("/static", ServeDir::new("resources/static"));
|
||||||
|
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue