Files
Nebula-Auth/src/SteamLibForked/Web/ClientBuilder.cs
T
achiez 30cf049f23 refactor(auth): redesign Steam audience and web domain authorization model
- 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
2026-05-12 16:36:37 +03:00

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"));
}
}