MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / GetStoreHeader

Method GetStoreHeader

KBotExt/LCU.cpp:236–276  ·  view source on GitHub ↗

TODO: sync with LCU header, it's almost the same

Source from the content-addressed store, hash-verified

234
235// TODO: sync with LCU header, it's almost the same
236std::string LCU::GetStoreHeader()
237{
238 std::string storeUrl = Request("GET", "/lol-store/v1/getStoreUrl");
239 std::erase(storeUrl, '"');
240
241 std::string accessToken = Request("GET", "/lol-rso-auth/v1/authorization/access-token");
242 Json::CharReaderBuilder builder;
243 const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
244 JSONCPP_STRING err;
245 Json::Value root;
246 if (reader->parse(accessToken.c_str(), accessToken.c_str() + static_cast<int>(accessToken.length()), &root, &err))
247 {
248 std::string storeToken = root["token"].asString();
249 std::string storeHost;
250 if (auto n = storeUrl.find("https://"); n != std::string::npos)
251 {
252 storeHost = storeUrl.substr(n + strlen("https://"));
253 }
254 std::string storeHeader = "Host: " + storeHost + "\r\n" +
255 "Connection: keep-alive\r\n" +
256 "AUTHORIZATION: Bearer " + storeToken + "\r\n" +
257 "Accept: application/json" + "\r\n" +
258 "Accept-Language: en-US,en;q=0.9" + "\r\n" +
259 "Content-Type: application/json" + "\r\n" +
260 "Origin: https://127.0.0.1:" + std::to_string(league.port) + "\r\n" +
261 "User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) LeagueOfLegendsClient/" + league.version +
262 " (CEF 91) Safari/537.36" + "\r\n" +
263 //X-B3-SpanId:
264 //X-B3-TraceId:
265 R"(sec-ch-ua: "Chromium";v="91")" + "\r\n" +
266 "sec-ch-ua-mobile: ?0" + "\r\n" +
267 "Sec-Fetch-Site: same-origin" + "\r\n" +
268 "Sec-Fetch-Mode: no-cors" + "\r\n" +
269 "Sec-Fetch-Dest: empty" + "\r\n" +
270 "Referer: https://127.0.0.1:" + std::to_string(league.port) + "\r\n" +
271 "Accept-Encoding: "/*gzip,*/ + "deflate, br";
272 return storeHeader;
273 }
274
275 return "";
276}
277
278/**
279 * \brief Fixes Wininet error 12158, #80 in GitHub issues

Callers

nothing calls this directly

Calls 2

eraseFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected