Skip to content

Commit 480ab7a

Browse files
author
ComputerElite
committed
final touches
1 parent 16db66e commit 480ab7a

File tree

6 files changed

+95
-49
lines changed

6 files changed

+95
-49
lines changed

Assets/html/downgrade.html

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
</div>
7474
<div class="guideHeader">How do I use this?</div>
7575
<div class="guideSteps" id="instructions">
76-
Heck wait until I wrote the instructions or even finished the backend you fucking idiot
76+
Type in your token and a password in the <code>Tools & Options</code> section (Open the app on your PC. You can find the adress you need to type in in the <code>Tools & Options</code> section). After you did that simply search the app and click the version you want to download.
77+
<br>
78+
You can then check the progress in the <code>Download progress</code> section.
79+
<b>While downloading do NOT close the app</b>
7780
</div>
7881
<div class="guideHeader">Is this legal?</div>
7982
<div class="guideSteps">
@@ -118,10 +121,6 @@
118121
<div class="item">id</div>
119122
</div>
120123
<div id="versions" style="display: flex; color: #EEEEEE; width: 100%; justify-content: space-evenly; flex-direction: column;">
121-
</div>
122-
123-
<div style="font-size: 22px; text-align: center; font-weight: bold;" id="dlcsHeader">DLCs</div>
124-
<div style="display: flex; flex-wrap: wrap;" id="dlcs">
125124
</div>`
126125
const storeSkeleton = `<div style="display: flex; flex-wrap: wrap; justify-content: flex-start;" id="apps">
127126
</div>
@@ -280,7 +279,6 @@
280279
showingVersions = true;
281280
document.getElementById("resultContainer").innerHTML = versionSkeleton
282281
document.getElementById("versions").innerHTML = loader
283-
document.getElementById("dlcs").innerHTML = loader
284282
versions = []
285283
finished = 0
286284
required = 3
@@ -374,22 +372,6 @@
374372
finished = required - 1
375373
ReportIssue()
376374
})
377-
var dlcs = document.getElementById("dlcs")
378-
PostRequest(requestUrl, `access_token=${access_token}&variables={"id":"${id}","first": 100}&doc_id=3998937106836519`).then((res) => {
379-
dlcs.innerHTML = ""
380-
res.data.node.latest_supported_binary.firstIapItems.edges.forEach(dlc => {
381-
if(dlc.node.latest_supported_asset_file != undefined) {
382-
dlcs.innerHTML += GetDlcFormatted({
383-
id: dlc.node.latest_supported_asset_file.id,
384-
name: dlc.node.display_name
385-
}, headset == "RIFT")
386-
}
387-
388-
})
389-
if(dlcs.innerHTML == "") dlcs.innerHTML = "<div style='flex:1;'>None</div>"
390-
}).catch(err => {
391-
dlcs.innerHTML = `<div style="font-size: 22px; text-align: center; font-weight: bold; width: 100%; margin-bottom: 30px;">Request to Oculus failed. DLCs haven't been cached</div>`
392-
})
393375

394376
//BETA
395377
/*
@@ -482,19 +464,11 @@
482464
}
483465

484466
function Download(id, isRift, appid, versioncode, version) {
485-
var password = prompt("Enter your password you set when you entered your token")
486-
fetch("/download", {
487-
method: "POST",
488-
body: JSON.stringify({
489-
password: password,
490-
binaryId: id,
491-
version: version,
492-
app: document.getElementById("versionHeader").innerHTML.replace("Versions for ", "")
493-
})
494-
}).then(res => {
495-
alert("Added to download queue. Check downloads tab for more info")
496-
})
497-
//window.top.postMessage(, "*");
467+
window.top.postMessage(JSON.stringify({
468+
binaryId: id,
469+
version: version,
470+
app: document.getElementById("versionHeader").innerHTML.replace("Versions for ", "")
471+
}), "*")
498472
}
499473

500474
function GetFormatted(element, isRift) {
@@ -514,12 +488,6 @@
514488
</a>`
515489
}
516490

517-
function GetDlcFormatted(element, isRift) {
518-
return `<a class="zoom defTextColor" style="flex: 1; background-color: #222222; font-size: 18px; padding: 5px; margin: 5px; cursor: pointer;" onclick="Download(${element.id}, ${isRift})" oncontextmenu="return SetupContextMenu(event, '${element.id}', true);">
519-
${element.name}
520-
</a>`
521-
}
522-
523491

524492
var issueReported = false
525493
function ReportIssue() {

Assets/html/index.html

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<iframe src="downgrade.html" style="width: 100%; height: 100%; border: none; overflow-y: visible;"></iframe>
6363
</div>
6464
<div class="contentItem hidden" id="download">
65-
<div id="progressBarContainers">
65+
<div id="progressBarContainers" style="width: 95%;">
6666

6767
</div>
6868

@@ -116,6 +116,27 @@
116116
</div>
117117
</div>
118118

119+
<div class="listContainer darken hidden" id="getPasswordContainer">
120+
<div class="restoreStep" id="step7">
121+
<div class="contentHeader headerMargin">
122+
Password needed
123+
</div>
124+
Please enter the password you set when settings your oculus token. If you didn't set one or forgot your password abort the download and head to the <code>Tools & Options</code> section to set your token and password.
125+
<br>
126+
Check the <code>download progress</code> section to see if the download was successful. (There will be no indecation if the password you )
127+
<input type="password" id="passwordConfirm" placeholder="password">
128+
<div id="step7box" class="textBox"></div>
129+
<div class="buttonSelectionContainer">
130+
<div class="buttonContainer">
131+
<div class="button" id="abortPassword">Abort Download</div>
132+
</div>
133+
<div class="buttonContainer buttonMargin">
134+
<div class="button" id="confirmPassword">Start dowload</div>
135+
</div>
136+
</div>
137+
</div>
138+
</div>
139+
119140
<div class="listContainer darken hidden" id="deleteContainer">
120141
<div class="restoreStep" id="step6">
121142
<div class="contentHeader headerMargin">
@@ -295,6 +316,10 @@
295316
})
296317
}
297318

319+
setInterval(() => {
320+
UpdateUI()
321+
}, 10000)
322+
298323
setInterval(() => {
299324
fetch("/downloads").then(res => {
300325
res.json().then(json => {
@@ -310,6 +335,7 @@
310335
</div>`
311336
})
312337
})
338+
if(document.getElementById("progressBarContainers").innerHTML == "") document.getElementById("progressBarContainers").innerHTML = "No downloads running"
313339
})
314340
}, 500)
315341

@@ -520,8 +546,41 @@
520546
document.getElementById("deleteContainer").className = "listContainer darken"
521547
}
522548

523-
document.getElementById("deleteBackup").onclick = () => {
524-
OpenDeletePopup()
549+
function CloseGetPasswordPopup() {
550+
document.getElementById("getPasswordContainer").className = "listContainer darken hidden"
551+
HideTextBox("step7box")
552+
GotoStep(7)
553+
}
554+
555+
function OpenGetPasswordPopup() {
556+
CloseGetPasswordPopup()
557+
document.getElementById("getPasswordContainer").className = "listContainer darken"
558+
}
559+
var options = {}
560+
window.onmessage = (e) => {
561+
options = JSON.parse(e.data)
562+
OpenGetPasswordPopup()
563+
}
564+
document.getElementById("abortPassword").onclick = () => {
565+
CloseGetPasswordPopup()
566+
}
567+
document.getElementById("confirmPassword").onclick = () => {
568+
options.password = document.getElementById("passwordConfirm").value
569+
fetch("/download", {
570+
method: "POST",
571+
body: JSON.stringify(options)
572+
}).then(res => {
573+
res.text().then(text => {
574+
if(res.status == 403) {
575+
TextBoxError("step7box", text)
576+
} else if(res.status == 200) {
577+
TextBoxGood("step7box", text)
578+
setTimeout(() => {
579+
CloseGetPasswordPopup()
580+
}, 5000)
581+
}
582+
})
583+
})
525584
}
526585

527586
document.getElementById("delete").onclick = () => {

Assets/html/style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
}
2222

2323
.downloadProgressContainer {
24-
min-width: 500px;
24+
min-width: 150px;
25+
width: 100%;
2526
height: 20px;
2627
background-color: #777777;
28+
flex-shrink: 1;
2729
}
2830

2931
.downloadProgressBar {
@@ -38,6 +40,7 @@
3840

3941
.downloadText {
4042
margin-left: 10px;
43+
flex-grow: 1;
4144
}
4245

4346
.content {

CoreVars.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class CoreVars // aka config
77
{
88
public string currentApp { get; set; } = "";
99
public string token { get; set; } = "";
10+
public string password { get; set; } = "";
1011
public readonly string QAVSDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/";
1112
public readonly string QAVDTmpDowngradeDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpDowngrade/";
1213
public readonly string QAVSBackupDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/Backups/";

QuestAppVersionSwitcher.csproj.user

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<SelectedDevice>Samsung SM-A202F</SelectedDevice>
5-
<ActiveDebugProfile>Samsung SM-A202F</ActiveDebugProfile>
6-
<DefaultDevice>pixel_2_pie_9_0_-_api_28</DefaultDevice>
4+
<SelectedDevice>Oculus Quest</SelectedDevice>
5+
<ActiveDebugProfile>Oculus Quest</ActiveDebugProfile>
6+
<DefaultDevice>pixel_3a_xl_r_11_0_-_api_30</DefaultDevice>
77
<AndroidDesignerPreferredTheme>AppTheme</AndroidDesignerPreferredTheme>
88
<AndroidDesignerPreferredDevice>Nexus 4</AndroidDesignerPreferredDevice>
99
</PropertyGroup>

WebServer.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using ComputerUtils.Android.Encryption;
1515
using QuestPatcher.Axml;
1616
using System.IO.Compression;
17+
using System.Security.Cryptography;
18+
using System.Text;
1719

1820
namespace QuestAppVersionSwitcher
1921
{
@@ -22,6 +24,7 @@ public class QAVSWebserver
2224
HttpServer server = new HttpServer();
2325
public static readonly char[] ReservedChars = new char[] { '|', '\\', '?', '*', '<', '\'', ':', '>', '+', '[', ']', '/', '\'', ' ' };
2426
public List<DownloadManager> managers = new List<DownloadManager>();
27+
public SHA256 hasher = SHA256.Create();
2528

2629
public void Start()
2730
{
@@ -347,18 +350,25 @@ public void Start()
347350
{
348351
TokenRequest r = JsonSerializer.Deserialize<TokenRequest>(serverRequest.bodyString);
349352
CoreService.coreVars.token = PasswordEncryption.Encrypt(r.token, r.password);
353+
SHA256 s = SHA256.Create();
354+
CoreService.coreVars.password = GetSHA256OfString(r.password);
350355
CoreService.coreVars.Save();
351356
serverRequest.SendString("Set token");
352357
return true;
353358
}));
354359
server.AddRoute("POST", "/download", new Func<ServerRequest, bool>(serverRequest =>
355360
{
356361
DownloadRequest r = JsonSerializer.Deserialize<DownloadRequest>(serverRequest.bodyString);
362+
if(GetSHA256OfString(r.password) != CoreService.coreVars.password)
363+
{
364+
serverRequest.SendString("Password is wrong. Please try a different password or set a new one", "text/plain", 403);
365+
return true;
366+
}
357367
DownloadManager m = new DownloadManager();
358368
m.StartDownload(r.binaryId, r.password, r.version, r.app);
359369
m.DownloadFinishedEvent += DownloadCompleted;
360370
managers.Add(m);
361-
serverRequest.SendString("Added to downloads");
371+
serverRequest.SendString("Added to downloads. Check download progress tab. Pop up will close in 5 seconds");
362372
return true;
363373
}));
364374
server.AddRoute("GET", "/downloads", new Func<ServerRequest, bool>(serverRequest =>
@@ -377,6 +387,11 @@ public void Start()
377387
CoreService.browser.LoadUrl("http://127.0.0.1:50001/");
378388
}
379389

390+
public string GetSHA256OfString(string input)
391+
{
392+
return BitConverter.ToString(hasher.ComputeHash(Encoding.UTF8.GetBytes(input))).Replace("-", "");
393+
}
394+
380395
public void DownloadCompleted(DownloadManager m)
381396
{
382397
MemoryStream manifestStream = new MemoryStream();

0 commit comments

Comments
 (0)