mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
attempt to fix code 5001
This commit is contained in:
@@ -22,13 +22,13 @@ internal sealed partial class UserFingerprintService : IUserFingerprintService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (user.Entity.FingerprintLastUpdateTime >= DateTimeOffset.UtcNow - TimeSpan.FromDays(7))
|
if (user.Entity.FingerprintLastUpdateTime >= DateTimeOffset.UtcNow - TimeSpan.FromDays(7))
|
||||||
//{
|
{
|
||||||
// if (!string.IsNullOrEmpty(user.Fingerprint))
|
if (!string.IsNullOrEmpty(user.Fingerprint))
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
string device = Core.Random.GetUpperAndNumberString(12);
|
string device = Core.Random.GetUpperAndNumberString(12);
|
||||||
string product = Core.Random.GetUpperAndNumberString(6);
|
string product = Core.Random.GetUpperAndNumberString(6);
|
||||||
|
|||||||
@@ -74,10 +74,9 @@ internal sealed partial class LoginMihoyoUserPage : Microsoft.UI.Xaml.Controls.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cookie stokenV2 = Cookie.FromLoginResult(loginResultResponse.Data);
|
Cookie stokenV2 = Cookie.FromLoginResult(loginResultResponse.Data);
|
||||||
webCookie.TryGetDeviceFp(out string? deviceFp);
|
|
||||||
|
|
||||||
await ISupportLoginByWebView
|
await ISupportLoginByWebView
|
||||||
.PostHandleCurrentCookieAsync(serviceProvider, InputCookie.Create(stokenV2, false, deviceFp))
|
.PostHandleCurrentCookieAsync(serviceProvider, InputCookie.Create(stokenV2, false, default))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,9 +120,11 @@ internal static class ApiEndpoints
|
|||||||
/// <returns>游戏记录实时便笺字符串</returns>
|
/// <returns>游戏记录实时便笺字符串</returns>
|
||||||
public static string GameRecordDailyNote(in PlayerUid uid)
|
public static string GameRecordDailyNote(in PlayerUid uid)
|
||||||
{
|
{
|
||||||
return $"{ApiTakumiRecordApi}/dailyNote?server={uid.Region}&role_id={uid.Value}";
|
return $"{GameRecordDailyNotePath}?server={uid.Region}&role_id={uid.Value}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public const string GameRecordDailyNotePath = $"{ApiTakumiRecordApi}/dailyNote";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏记录主页
|
/// 游戏记录主页
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -25,17 +25,13 @@ internal sealed partial class CardClient
|
|||||||
private readonly ILogger<CardClient> logger;
|
private readonly ILogger<CardClient> logger;
|
||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
/// <summary>
|
public async ValueTask<Response<VerificationRegistration>> CreateVerificationAsync(User user, CardVerifiationHeaders headers, CancellationToken token)
|
||||||
/// 注册验证码
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">用户</param>
|
|
||||||
/// <param name="token">取消令牌</param>
|
|
||||||
/// <returns>注册结果</returns>
|
|
||||||
public async ValueTask<Response<VerificationRegistration>> CreateVerificationAsync(User user, CancellationToken token)
|
|
||||||
{
|
{
|
||||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.CardCreateVerification(true))
|
.SetRequestUri(ApiEndpoints.CardCreateVerification(true))
|
||||||
.SetUserCookieAndFpHeader(user, CookieType.LToken)
|
.SetUserCookieAndFpHeader(user, CookieType.LToken)
|
||||||
|
.SetHeader("x-rpc-challenge_game", $"{headers.ChallengeGame}")
|
||||||
|
.SetHeader("x-rpc-challenge_path", headers.ChallengePath)
|
||||||
.Get();
|
.Get();
|
||||||
|
|
||||||
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
|
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
|
||||||
@@ -110,4 +106,20 @@ internal sealed partial class CardClient
|
|||||||
[JsonPropertyName("geetest_seccode")]
|
[JsonPropertyName("geetest_seccode")]
|
||||||
public string GeetestSeccode { get; set; }
|
public string GeetestSeccode { get; set; }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class CardVerifiationHeaders
|
||||||
|
{
|
||||||
|
public int ChallengeGame { get; private set; }
|
||||||
|
|
||||||
|
public string ChallengePath { get; private set; }
|
||||||
|
|
||||||
|
public static CardVerifiationHeaders Create(string path)
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
ChallengeGame = 2,
|
||||||
|
ChallengePath = path,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
resp.Message = SH.WebDailyNoteVerificationFailed;
|
resp.Message = SH.WebDailyNoteVerificationFailed;
|
||||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||||
|
|
||||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||||
|
|
||||||
|
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||||
{
|
{
|
||||||
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordDailyNote(userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordDailyNote(userAndUid.Uid))
|
||||||
@@ -88,7 +90,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordIndex(userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordIndex(userAndUid.Uid))
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.Get();
|
.Get();
|
||||||
|
|
||||||
@@ -105,12 +106,13 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||||
|
|
||||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||||
|
|
||||||
|
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||||
{
|
{
|
||||||
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordIndex(userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordIndex(userAndUid.Uid))
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.SetXrpcChallenge(challenge)
|
.SetXrpcChallenge(challenge)
|
||||||
.Get();
|
.Get();
|
||||||
@@ -139,7 +141,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordSpiralAbyss(schedule, userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordSpiralAbyss(schedule, userAndUid.Uid))
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.Get();
|
.Get();
|
||||||
|
|
||||||
@@ -156,12 +157,13 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||||
|
|
||||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||||
|
|
||||||
|
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||||
{
|
{
|
||||||
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder verifiedbuilder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordSpiralAbyss(schedule, userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordSpiralAbyss(schedule, userAndUid.Uid))
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.SetXrpcChallenge(challenge)
|
.SetXrpcChallenge(challenge)
|
||||||
.Get();
|
.Get();
|
||||||
@@ -189,7 +191,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordRoleBasicInfo(userAndUid.Uid))
|
.SetRequestUri(ApiEndpoints.GameRecordRoleBasicInfo(userAndUid.Uid))
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.Get();
|
.Get();
|
||||||
|
|
||||||
@@ -215,7 +216,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordCharacter)
|
.SetRequestUri(ApiEndpoints.GameRecordCharacter)
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.PostJson(new CharacterData(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id)));
|
.PostJson(new CharacterData(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id)));
|
||||||
|
|
||||||
@@ -232,12 +232,13 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
|||||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||||
|
|
||||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||||
|
|
||||||
|
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||||
{
|
{
|
||||||
HttpRequestMessageBuilder verifiedBuilder = httpRequestMessageBuilderFactory.Create()
|
HttpRequestMessageBuilder verifiedBuilder = httpRequestMessageBuilderFactory.Create()
|
||||||
.SetRequestUri(ApiEndpoints.GameRecordCharacter)
|
.SetRequestUri(ApiEndpoints.GameRecordCharacter)
|
||||||
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
.SetUserCookieAndFpHeader(userAndUid, CookieType.Cookie)
|
||||||
.SetHeader("x-rpc-page", "v4.2.2-ys_#/ys/daily")
|
|
||||||
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
.SetReferer(ApiEndpoints.WebStaticMihoyoReferer)
|
||||||
.SetXrpcChallenge(challenge)
|
.SetXrpcChallenge(challenge)
|
||||||
.PostJson(new CharacterData(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id)));
|
.PostJson(new CharacterData(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id)));
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ internal sealed partial class HomaGeetestCardVerifier : IGeetestCardVerifier
|
|||||||
private readonly CardClient cardClient;
|
private readonly CardClient cardClient;
|
||||||
private readonly HomaGeetestClient homaGeetestClient;
|
private readonly HomaGeetestClient homaGeetestClient;
|
||||||
|
|
||||||
public async ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CancellationToken token)
|
public async ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CardVerifiationHeaders headers, CancellationToken token)
|
||||||
{
|
{
|
||||||
Response.Response<VerificationRegistration> registrationResponse = await cardClient.CreateVerificationAsync(user, token).ConfigureAwait(false);
|
Response.Response<VerificationRegistration> registrationResponse = await cardClient.CreateVerificationAsync(user, headers, token).ConfigureAwait(false);
|
||||||
if (registrationResponse.IsOk())
|
if (registrationResponse.IsOk())
|
||||||
{
|
{
|
||||||
VerificationRegistration registration = registrationResponse.Data;
|
VerificationRegistration registration = registrationResponse.Data;
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
|||||||
|
|
||||||
internal interface IGeetestCardVerifier
|
internal interface IGeetestCardVerifier
|
||||||
{
|
{
|
||||||
ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CancellationToken token);
|
ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CardVerifiationHeaders headers, CancellationToken token);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user