mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
30cf049f23
- Rename AuthorizedDomains to WebDomains - Introduce explicit Steam audience constants and web audience mappings - Improve Steam token/domain resolution and cookie installation flow - Allow mobile-issued tokens with "web" audience to be used for web domains - Align authorization logic closer to actual Steam audience behavior - Rename cookie APIs from Add* to Set* where appropriate
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using AchiesUtilities.Web.Models;
|
|
using SteamLib.Authentication;
|
|
using SteamLibForked.Abstractions;
|
|
|
|
namespace SteamLib.Web;
|
|
|
|
public static class ClientBuilder
|
|
{
|
|
public static HttpClientHandlerPair BuildMobileClient(IWebProxy? proxy, IMobileSessionData? sessionData,
|
|
bool disposeHandler = true)
|
|
{
|
|
sessionData?.EnsureValidated();
|
|
var handler = new HttpClientHandler();
|
|
var client = new HttpClient(handler, disposeHandler);
|
|
|
|
client.DefaultRequestHeaders.Accept.ParseAdd(
|
|
"application/json, text/javascript, text/html, application/xml, text/xml, */*");
|
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("okhttp/3.12.12");
|
|
|
|
if (proxy != null)
|
|
{
|
|
handler.Proxy = proxy;
|
|
}
|
|
|
|
var container = handler.CookieContainer;
|
|
if (sessionData == null)
|
|
{
|
|
container.ClearMobileSessionCookies();
|
|
}
|
|
else
|
|
{
|
|
container.SetSteamMobileCookies(sessionData);
|
|
}
|
|
|
|
//Nebula tweak:
|
|
handler.CookieContainer.InjectWebTradeEligibilityCookie();
|
|
ConfigureCommon(handler, client);
|
|
return new HttpClientHandlerPair(client, handler);
|
|
}
|
|
|
|
|
|
private static void ConfigureCommon(HttpClientHandler handler, HttpClient client)
|
|
{
|
|
ConfigureCommonClient(client);
|
|
handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
|
|
}
|
|
|
|
private static void ConfigureCommonClient(HttpClient client)
|
|
{
|
|
client.Timeout = TimeSpan.FromSeconds(50);
|
|
client.DefaultRequestHeaders.Referrer = new Uri("https://steamcommunity.com");
|
|
client.DefaultRequestHeaders.Add("Origin", "https://steamcommunity.com");
|
|
client.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-US"));
|
|
}
|
|
} |