Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Authentication/MicrosoftAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
var resultDict = new RetrieveDeviceCode
{
ClientId = ClientId,
UserCode = responseDict.UserCode,

Check warning on line 58 in Authentication/MicrosoftAuthentication.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
DeviceCode = responseDict.DeviceCode,
VerificationUri = responseDict.VerificationUri,
Message = responseDict.Message
Expand Down Expand Up @@ -95,7 +95,7 @@
if (tokenRes.IsSuccessStatusCode)
{
var tokenData = tokenJson.ToJsonEntry<GetTokenResponse>();
if (!string.IsNullOrEmpty(tokenData.AccessToken))

Check warning on line 98 in Authentication/MicrosoftAuthentication.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
return new GetTokenResponse
{
ExpiresIn = tokenData.ExpiresIn,
Expand All @@ -112,7 +112,7 @@
try
{
var errorData = tokenJson.ToJsonEntry<GetTokenErrorResponse>();
switch (errorData.Error)

Check warning on line 115 in Authentication/MicrosoftAuthentication.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
case "authorization_declined":
throw new Exception("用户拒绝了授权");
Expand Down Expand Up @@ -170,7 +170,7 @@

var refreshResponseData = refreshResponse.ToJsonEntry<TokenResponse>();

tokenInfo.AccessToken = refreshResponseData.AccessToken;

Check warning on line 173 in Authentication/MicrosoftAuthentication.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
tokenInfo.RefreshToken = refreshResponseData.RefreshToken;
tokenInfo.ExpiresIn = refreshResponseData.ExpiresIn;

Expand Down Expand Up @@ -206,8 +206,12 @@
RelyingParty = "http://auth.xboxlive.com",
TokenType = "JWT"
};
var options = new JsonSerializerOptions()
{
WriteIndented = true
};

var xblLoginContentString = xboxLoginContent.Serialize();
var xblLoginContentString = xboxLoginContent.Serialize(options);

string xboxResponseString;

Expand Down Expand Up @@ -238,7 +242,7 @@
TokenType = "JWT"
};

var xstsPostData = getXstsJsonData.Serialize();
var xstsPostData = getXstsJsonData.Serialize(options);

var xstsResponse = await HttpUtil.SendHttpPostRequest("https://xsts.auth.xboxlive.com/xsts/authorize",
xstsPostData, "application/json");
Expand Down
2 changes: 1 addition & 1 deletion Skin/Fetchers/MicrosoftSkinFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MicrosoftSkinFetcher
/// <summary>
/// 获取微软皮肤
/// </summary>
/// <param name="account">皮肤图片字节信息</param>
/// <param name="account">微软账户</param>
/// <returns>皮肤图片字节信息</returns>
public static async Task<byte[]> GetMicrosoftSkinAsync(MicrosoftAccount account)
{
Expand Down
15 changes: 13 additions & 2 deletions Skin/Fetchers/UnifiedPassSkinFetcher.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using StarLight_Core.Models.Authentication;
using StarLight_Core.Models.Skin;
using StarLight_Core.Utilities;

Expand All @@ -12,9 +13,19 @@ public class UnifiedPassSkinFetcher
/// <summary>
/// 获取统一通行证皮肤
/// </summary>
/// <param name="uuid">微软账户 Uuid</param>
/// <param name="account">统一通行证账户</param>
/// <returns>皮肤图片字节信息</returns>
public static async Task<byte[]> GetMicrosoftUnifiedPassSkinAsync(string uuid)
public static async Task<byte[]> GetUnifiedPassSkinAsync(UnifiedPassAccount account)
{
return await GetUnifiedPassSkinAsync(account.Uuid);
}

/// <summary>
/// 获取统一通行证皮肤
/// </summary>
/// <param name="uuid">统一通行证账户 Uuid</param>
/// <returns>皮肤图片字节信息</returns>
public static async Task<byte[]> GetUnifiedPassSkinAsync(string uuid)
{
const string baseUrl = "https://auth.mc-user.com:233/sessionserver/session/minecraft/profile/";
var skinJson = await HttpUtil.GetStringAsync(baseUrl + uuid);
Expand Down
6 changes: 3 additions & 3 deletions Skin/SkinProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void ResizeImage(string inputFilePath, string outputFilePath, int
/// <param name="base64Image"></param>
/// <param name="outputFilePath"></param>
/// <param name="isDecoration"></param>
public static void GetLiftLeg(string base64Image, string outputFilePath, bool isDecoration = false)
public static void GetLeftLeg(string base64Image, string outputFilePath, bool isDecoration = false)
{
var imageBytes = Convert.FromBase64String(base64Image);

Expand Down Expand Up @@ -126,7 +126,7 @@ public static void GetRightLeg(string base64Image, string outputFilePath, bool i
/// <param name="base64Image"></param>
/// <param name="outputFilePath"></param>
/// <param name="isDecoration"></param>
public static void GetLiftArm_Alex(string base64Image, string outputFilePath, bool isDecoration = false)
public static void GetLeftArm_Alex(string base64Image, string outputFilePath, bool isDecoration = false)
{
var imageBytes = Convert.FromBase64String(base64Image);

Expand Down Expand Up @@ -222,7 +222,7 @@ public static void GetRightArm_Alex(string base64Image, string outputFilePath, b
/// <param name="base64Image"></param>
/// <param name="outputFilePath"></param>
/// <param name="isDecoration"></param>
public static void GetLiftArm_Steve(string base64Image, string outputFilePath, bool isDecoration = false)
public static void GetLeftArm_Steve(string base64Image, string outputFilePath, bool isDecoration = false)
{
var imageBytes = Convert.FromBase64String(base64Image);

Expand Down
3 changes: 2 additions & 1 deletion StarLight.Core.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down
7 changes: 4 additions & 3 deletions Utilities/JsonUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ public static class JsonUtil
/// 将对象序列化为 JSON 字符串
/// </summary>
/// <param name="obj">要序列化的对象</param>
/// <param name="options">可选的序列化选项</param>
/// <returns>表示对象的 JSON 字符串;若 <paramref name="obj"/> 为 null,则返回字符串 "null"</returns>
/// <exception cref="ArgumentNullException">当 <paramref name="obj"/> 为 null 时抛出</exception>
public static string Serialize(this object? obj)
public static string Serialize(this object? obj, JsonSerializerOptions? options = null)
{
return obj is null ? throw new ArgumentNullException(nameof(obj)) : JsonSerializer.Serialize(obj, Options);
return obj is null ? throw new ArgumentNullException(nameof(obj)) : JsonSerializer.Serialize(obj, options ?? Options);
}

/// <summary>
Expand All @@ -95,7 +96,7 @@ public static string Serialize(this object? obj)
/// </returns>
/// <exception cref="JsonException">JSON 字符串格式无效时抛出</exception>
public static JsonNode? ToJsonNode(this string json) => JsonNode.Parse(json);

/// <summary>
/// 将 JSON 字符串解析为 <see cref="JsonDocument"/> 对象
/// </summary>
Expand Down
Loading