Skip to content

Commit a256398

Browse files
ComputerEliteComputerElite
authored andcommitted
add upload logs button
1 parent aa5afd4 commit a256398

36 files changed

+1282
-3
lines changed

Assets/html/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,19 @@ <h2>To download mods simply download any mod from one of the following sites</h2
219219
<div id="serverTextBox" class="textBox"></div>
220220
</div>
221221

222+
<div class="space">
223+
<div class="contentHeader">
224+
Help
225+
<div class="contentHeaderDescription">Utilities to help debugging QuestAppVersionSwitcher</div>
226+
</div>
227+
<div class="buttonContainer">
228+
<input type="password" placeholder="Enter QuestAppVersionSwitcher password" id="logspwd" class="buttonLabel" value="" style="width: 300px;">
229+
<div class="button" id="logs">Upload Logs</div>
230+
<div class="buttonLabel">ONLY do when instructed to do so. Uploads which apps you own to OculusDB for viewing by support members</div>
231+
</div>
232+
<div id="logsText" class="textBox"></div>
233+
</div>
234+
222235
<div class="space">
223236
All Backups together take up <b class="inline totalSize"></b> of space on your Device.
224237
<br>

Assets/html/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,23 @@ document.getElementById("confirmPassword").onclick = () => {
730730
})
731731
}
732732

733+
document.getElementById("logs").onclick = () => {
734+
TextBoxText("logsText", "Working.. please wait")
735+
fetch("/questappversionswitcher/uploadlogs?password=" + document.getElementById("logspwd").value).then(res => {
736+
res.text().then(text => {
737+
if (res.status == 403) {
738+
TextBoxError("logsText", text)
739+
} else if (res.status == 200) {
740+
fetch("https://oculusdb.rui2015.me/api/v1/qavsreport", {method: "POST", body: text}).then(res => {
741+
res.text().then(text => {
742+
TextBoxGood("logsText", "Logs uploaded successfully. Tell your support member this ID: " + text)
743+
})
744+
})
745+
}
746+
})
747+
})
748+
}
749+
733750
document.getElementById("abortLogin").onclick = () => {
734751
CloseGetPasswordPopup()
735752
}

OculusGraphQLApiLib/Constants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace OculusGraphQLApiLib
2+
{
3+
public class Constants
4+
{
5+
public static string UA = "OculusGraphQLApiLib/1.0";
6+
}
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Text.Json;
7+
using System.Threading.Tasks;
8+
9+
namespace OculusGraphQLApiLib.Folders
10+
{
11+
public class OculusFolder
12+
{
13+
public static string GetSoftwareDirectory(string oculusFolder, string canonicalName)
14+
{
15+
return oculusFolder + Path.DirectorySeparatorChar + "Software" + Path.DirectorySeparatorChar + canonicalName + Path.DirectorySeparatorChar;
16+
}
17+
18+
public static string GetManifestPath(string oculusFolder, string canonicalName)
19+
{
20+
return oculusFolder + Path.DirectorySeparatorChar + "Manifests" + Path.DirectorySeparatorChar + canonicalName + ".json";
21+
}
22+
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OculusGraphQLApiLib.GraphQL
8+
{
9+
public enum ActiveState
10+
{
11+
PERMANENT
12+
}
13+
14+
public enum GrantReason
15+
{
16+
UNKNOWN,
17+
PAID_OFFER,
18+
NUX,
19+
OCULUS_KEYS,
20+
DEVELOPER,
21+
NUX_BUNDLE,
22+
XBUY,
23+
RELEASE_CHANNEL_OFFER
24+
}
25+
}
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Net;
5+
using System.Text.Json;
6+
using System.Web;
7+
using ComputerUtils.Android.Logging;
8+
using OculusGraphQLApiLib.Results;
9+
10+
namespace OculusGraphQLApiLib
11+
{
12+
public class GraphQLClient
13+
{
14+
public string uri { get; set; } = "";
15+
public GraphQLOptions options { get; set; } = new GraphQLOptions();
16+
public const string oculusUri = "https://graph.oculus.com/graphql";
17+
public static string oculusStoreToken = "OC|752908224809889|";
18+
public static string forcedLocale = "";
19+
public static bool throwException = true;
20+
public static bool log = true;
21+
public static int retryTimes = 3;
22+
public static JsonSerializerOptions jsonOptions = new JsonSerializerOptions
23+
{
24+
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
25+
};
26+
27+
public GraphQLClient(string uri, GraphQLOptions options)
28+
{
29+
this.uri = uri;
30+
this.options = options;
31+
}
32+
33+
public GraphQLClient(string uri)
34+
{
35+
this.uri = uri;
36+
}
37+
38+
public GraphQLClient() { }
39+
40+
public string GetForcedLocale()
41+
{
42+
return forcedLocale != "" ? "?forced_locale=" + forcedLocale : "";
43+
}
44+
45+
public string Request(GraphQLOptions options)
46+
{
47+
WebClient c = new WebClient();
48+
//c.Headers.Add("x-requested-with", "RiftDowngrader");
49+
if (log) Logger.Log("Doing POST Request to " + uri + " with args " + options.ToLoggingString());
50+
try
51+
{
52+
string returning = c.UploadString(uri + GetForcedLocale(), "POST", options.ToStringEncoded());
53+
return returning;
54+
}
55+
catch (WebException e)
56+
{
57+
if (log) Logger.Log("Request failed (" + e.Status + "): \n" + new StreamReader(e.Response.GetResponseStream()).ReadToEnd(), LoggingType.Error);
58+
Console.ForegroundColor = ConsoleColor.Red;
59+
if(log) Console.WriteLine("Request to Oculus failed. Please try again later and/or contact ComputerElite.");
60+
if(throwException) throw new Exception(e.Status.ToString().StartsWith("4") ? "I fuqed up" : "Some Request to Oculus failed so yeah idk how to handle it.");
61+
}
62+
return "{}";
63+
}
64+
65+
public string Request(bool asBody = false, Dictionary<string, string> customHeaders = null, int retry = 0, string status = "200")
66+
{
67+
if (retry == retryTimes)
68+
{
69+
if (log) Logger.Log("Retry limit exceeded. Stopping requests");
70+
Console.ForegroundColor = ConsoleColor.Red;
71+
if (log) Console.WriteLine("Request to Oculus failed. Please try again later and/or contact ComputerElite.");
72+
if (throwException) throw new Exception(status.StartsWith("4") ? "I fuqed up" : "Some Request to Oculus failed so yeah idk how to handle it.");
73+
return "{}";
74+
}
75+
if(log && retry != 0) Logger.Log("Starting retry number " + retry);
76+
WebClient c = new WebClient();
77+
if (customHeaders != null)
78+
{
79+
foreach (KeyValuePair<string, string> header in customHeaders)
80+
{
81+
c.Headers.Add(header.Key, header.Value);
82+
}
83+
}
84+
if (log) Logger.Log("Doing POST Request to " + uri + " with args " + options.ToLoggingString());
85+
try
86+
{
87+
string res = "";
88+
if (asBody) res = c.UploadString(uri + GetForcedLocale(), "POST", options.ToStringEncoded());
89+
else res = c.UploadString(uri + "?" + this.options.ToString() + GetForcedLocale().Replace("?", "&"), "POST", "");
90+
if(log) Logger.Log(res);
91+
return res;
92+
}
93+
catch (WebException e)
94+
{
95+
96+
if (log) Logger.Log("Request failed, retrying (" + e.Status.ToString() + ", " + (int)e.Status + "): \n" + new StreamReader(e.Response.GetResponseStream()).ReadToEnd(), LoggingType.Error);
97+
return Request(asBody, customHeaders, retry + 1, e.Status.ToString());
98+
}
99+
return "{}";
100+
}
101+
102+
public static Data<Application> VersionHistory(string appid)
103+
{
104+
GraphQLClient c = OculusTemplate();
105+
c.options.doc_id = "1586217024733717";
106+
c.options.variables = "{\"id\":\"" + appid + "\"}";
107+
return JsonSerializer.Deserialize<Data<Application>>(c.Request(), jsonOptions);
108+
}
109+
110+
public static ViewerData<OculusUserWrapper> GetCurrentUser()
111+
{
112+
GraphQLClient c = OculusTemplate();
113+
c.options.doc_id = "4149322231793299";
114+
c.options.variables = "{}";
115+
return JsonSerializer.Deserialize<ViewerData<OculusUserWrapper>>(c.Request(), jsonOptions);
116+
}
117+
118+
public static Data<AppStoreAllAppsSection> AllApps(Headset headset, string cursor = null, int maxApps = 500)
119+
{
120+
GraphQLClient c = OculusTemplate();
121+
c.options.doc_id = "3821696797949516";
122+
string id = "";
123+
switch(headset)
124+
{
125+
case Headset.MONTEREY:
126+
id = "1888816384764129";
127+
break;
128+
case Headset.HOLLYWOOD:
129+
id = "1888816384764129";
130+
break;
131+
case Headset.RIFT:
132+
id = "1736210353282450";
133+
break;
134+
case Headset.LAGUNA:
135+
id = "1736210353282450";
136+
break;
137+
case Headset.GEARVR:
138+
id = "174868819587665";
139+
break;
140+
case Headset.PACIFIC:
141+
id = "174868819587665";
142+
break;
143+
}
144+
c.options.variables = "{\"sectionId\":\"" + id + "\",\"sortOrder\":null,\"sectionItemCount\":" + maxApps + ",\"sectionCursor\":" + (cursor == null ? "null" : "\"" + cursor + "\"") + ",\"hmdType\":\"" + HeadsetTools.GetHeadsetCodeName(headset) + "\"}";
145+
return JsonSerializer.Deserialize<Data<AppStoreAllAppsSection>>(c.Request());
146+
}
147+
148+
public static Data<NodesPrimaryBinaryApplication> AllVersionsOfApp(string appid) // DONE
149+
{
150+
GraphQLClient c = OculusTemplate();
151+
c.options.doc_id = "2885322071572384";
152+
c.options.variables = "{\"applicationID\":\"" + appid + "\"}";
153+
return JsonSerializer.Deserialize<Data<NodesPrimaryBinaryApplication>>(c.Request(), jsonOptions);
154+
}
155+
156+
public static ViewerData<OculusUserWrapper> GetActiveEntitelments() // DONE
157+
{
158+
GraphQLClient c = OculusTemplate();
159+
c.options.doc_id = "4850747515044496";
160+
c.options.variables = "{}";
161+
return JsonSerializer.Deserialize<ViewerData<OculusUserWrapper>>(c.Request(), jsonOptions);
162+
}
163+
164+
public static Data<EdgesPrimaryBinaryApplication> ReleaseChannelsOfApp(string appid) // DONE
165+
{
166+
GraphQLClient c = OculusTemplate();
167+
c.options.doc_id = "3828663700542720";
168+
c.options.variables = "{\"applicationID\":\"" + appid + "\"}";
169+
return JsonSerializer.Deserialize<Data<EdgesPrimaryBinaryApplication>>(c.Request(), jsonOptions);
170+
}
171+
172+
public static Data<ReleaseChannel> ReleaseChannelReleases(string channelId) // DONE
173+
{
174+
GraphQLClient c = OculusTemplate();
175+
c.options.doc_id = "3973666182694273";
176+
c.options.variables = "{\"releaseChannelID\":\"" + channelId + "\"}";
177+
return JsonSerializer.Deserialize<Data<ReleaseChannel>>(c.Request(), jsonOptions);
178+
}
179+
180+
public static ViewerData<ContextualSearch> StoreSearch(string query, Headset headset) // DONE
181+
{
182+
GraphQLClient c = OculusTemplate();
183+
c.options.doc_id = "3928907833885295";
184+
c.options.variables = "{\"query\":\"" + query + "\",\"hmdType\":\"" + HeadsetTools.GetHeadsetCodeName(headset) + "\",\"firstSearchResultItems\":100}";
185+
return JsonSerializer.Deserialize<ViewerData<ContextualSearch>>(c.Request(), jsonOptions);
186+
}
187+
188+
public static GraphQLClient CurrentVersionOfApp(string appid)
189+
{
190+
GraphQLClient c = OculusTemplate();
191+
c.options.doc_id = "1586217024733717";
192+
c.options.variables = "{\"id\":\"" + appid + "\"}";
193+
return c;
194+
}
195+
196+
public static Data<Application> GetAppDetail(string id, Headset headset)
197+
{
198+
GraphQLClient c = OculusTemplate();
199+
c.options.doc_id = "4282918028433524";
200+
c.options.variables = "{\"itemId\":\"" + id + "\",\"first\":20,\"last\":null,\"after\":null,\"before\":null,\"forward\":true,\"ordering\":null,\"ratingScores\":null,\"hmdType\":\"" + HeadsetTools.GetHeadsetCodeName(headset) + "\"}";
201+
return JsonSerializer.Deserialize<Data<Application>>(c.Request(), jsonOptions);
202+
}
203+
204+
public static Data<Application> GetDLCs(string appId)
205+
{
206+
GraphQLClient c = OculusTemplate();
207+
c.options.doc_id = "3853229151363174";
208+
c.options.variables = "{\"id\":\"" + appId + "\",\"first\":200,\"last\":null,\"after\":null,\"before\":null,\"forward\":true}";
209+
return JsonSerializer.Deserialize<Data<Application>>(c.Request(), jsonOptions);
210+
}
211+
212+
public static Data<AndroidBinary> GetBinaryDetails(string binaryId)
213+
{
214+
GraphQLClient c = OculusTemplate();
215+
c.options.doc_id = "4734929166632773";
216+
c.options.variables = "{\"binaryID\":\"" + binaryId + "\"}";
217+
return JsonSerializer.Deserialize<Data<AndroidBinary>>(c.Request(), jsonOptions);
218+
}
219+
220+
public static PlainData<AppBinaryInfoContainer> GetAssetFiles(string appId, long versionCode)
221+
{
222+
GraphQLClient c = OculusTemplate();
223+
c.options.doc = "query ($params: AppBinaryInfoArgs!) { app_binary_info(args: $params) { info { binary { ... on AndroidBinary { id package_name version_code asset_files { edges { node { ... on AssetFile { file_name uri size } } } } } } } }}";
224+
c.options.variables = "{\"params\":{\"app_params\":[{\"app_id\":\"" + appId + "\",\"version_code\":\"" + versionCode + "\"}]}}";
225+
return JsonSerializer.Deserialize<PlainData<AppBinaryInfoContainer>>(c.Request(), jsonOptions);
226+
}
227+
228+
public static GraphQLClient OculusTemplate()
229+
{
230+
GraphQLClient c = new GraphQLClient(oculusUri);
231+
GraphQLOptions o = new GraphQLOptions();
232+
o.access_token = oculusStoreToken;
233+
c.options = o;
234+
return c;
235+
}
236+
}
237+
238+
public class GraphQLOptions
239+
{
240+
public string access_token { get; set; } = "";
241+
public string variables { get; set; } = "";
242+
public string doc_id { get; set; } = "";
243+
public string doc { get; set; } = "";
244+
245+
public override string ToString()
246+
{
247+
return "access_token=" + access_token + "&variables=" + variables + "&doc_id=" + doc_id + "&doc=" + doc;
248+
}
249+
250+
public string ToStringEncoded()
251+
{
252+
return "access_token=" + access_token + "&variables=" + variables + "&doc_id=" + doc_id + "&doc=" + doc;
253+
}
254+
255+
public string ToLoggingString()
256+
{
257+
return "access_token=aSecret:)&variables=" + variables + "&doc_id=" + doc_id + "&doc=" + doc;
258+
}
259+
}}

0 commit comments

Comments
 (0)