style: format

This commit is contained in:
Fu Diwei
2022-05-06 20:29:27 +08:00
parent d364c1a354
commit 7e6cfa5ca3
2352 changed files with 3542 additions and 4198 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI
{
@@ -35,10 +35,10 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
try
{
if (!Utilities.WxBizMsgCryptor.TryParseXml(callbackXml, out string? encryptedXml))
if (!Utilities.WechatEventDataCryptor.TryParseXml(callbackXml, out string? encryptedXml))
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed, because of empty encrypted data.");
callbackXml = Utilities.WxBizMsgCryptor.AESDecrypt(cipherText: encryptedXml!, encodingAESKey: client.Credentials.EncodingAESKey!, out _);
callbackXml = Utilities.WechatEventDataCryptor.AESDecrypt(cipherText: encryptedXml!, encodingAESKey: client.Credentials.EncodingAESKey!, out _);
return Utilities.XmlUtility.Deserialize<TEvent>(callbackXml);
}
catch (WechatOpenAIException)
@@ -104,13 +104,13 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
try
{
string cipher = Utilities.WxBizMsgCryptor.AESEncrypt(
string cipher = Utilities.WechatEventDataCryptor.AESEncrypt(
plainText: xml,
encodingAESKey: client.Credentials.EncodingAESKey!,
appId: client.Credentials.AppId!
);
xml = Utilities.WxBizMsgCryptor.WrapXml(sToken: client.Credentials.Token!, sMsgEncrypt: cipher);
xml = Utilities.WechatEventDataCryptor.WrapXml(sToken: client.Credentials.Token!, sMsgEncrypt: cipher);
}
catch (Exception ex)
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
@@ -112,7 +112,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
using var fileContent = new ByteArrayContent(request.FileBytes ?? Array.Empty<byte>());
using var paramContent = new StringContent(
Utilities.WxBizMsgCryptor.AESEncrypt(
Utilities.WechatEventDataCryptor.AESEncrypt(
plainText: Utilities.XmlUtility.Serialize(request),
encodingAESKey: client.Credentials.EncodingAESKey!,
appId: client.Credentials.AppId!

View File

@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests")]
[assembly: InternalsVisibleTo("SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests")]

View File

@@ -24,4 +24,4 @@
### 【更新日志】
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat/blob/main/CHANGELOG.md)。
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat/blob/main/CHANGELOG.md)。

View File

@@ -40,7 +40,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="JWT" Version="8.9.0" />
<PackageReference Include="JWT" Version="9.0.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.5.0" />
</ItemGroup>

View File

@@ -1,4 +1,4 @@
using System;
using System;
using JWT;
using JWT.Algorithms;
using JWT.Serializers;
@@ -10,7 +10,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
{
private static readonly Lazy<IJwtEncoder> _encoder = new Lazy<IJwtEncoder>(() =>
{
#pragma warning disable CS0618
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
#pragma warning restore CS0618
IJsonSerializer serializer = new JsonNetSerializer(new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore });
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using JWT;
using JWT.Algorithms;
using JWT.Serializers;
@@ -10,7 +10,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
{
private static readonly Lazy<IJwtEncoder> _encoder = new Lazy<IJwtEncoder>(() =>
{
#pragma warning disable CS0618
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
#pragma warning restore CS0618
IJsonSerializer serializer = new JsonNetSerializer(new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore });
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -10,7 +10,7 @@ using System.Xml;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
{
public static class WxBizMsgCryptor
internal static class WechatEventDataCryptor
{
private const int AES_KEY_SIZE = 256;
private const int AES_BLOCK_SIZE = 128;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -103,7 +103,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
if (data is WechatOpenAIPlatformRequest.Serialization.IEncryptedXmlable)
{
string plainXml = Utilities.XmlUtility.Serialize(data);
string encryptedXml = Utilities.WxBizMsgCryptor.AESEncrypt(plainText: plainXml, encodingAESKey: Credentials.EncodingAESKey!, appId: Credentials.AppId!);
string encryptedXml = Utilities.WechatEventDataCryptor.AESEncrypt(plainText: plainXml, encodingAESKey: Credentials.EncodingAESKey!, appId: Credentials.AppId!);
data = new { encrypt = encryptedXml };
}

View File

@@ -8,17 +8,17 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
public abstract class WechatOpenAIPlatformResponse : ICommonResponse
{
/// <summary>
///
///
/// </summary>
int ICommonResponse.RawStatus { get; set; }
/// <summary>
///
///
/// </summary>
IDictionary<string, string> ICommonResponse.RawHeaders { get; set; } = default!;
/// <summary>
///
///
/// </summary>
byte[] ICommonResponse.RawBytes { get; set; } = default!;

View File

@@ -8,17 +8,17 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
public abstract class WechatOpenAIThirdPartyResponse : ICommonResponse
{
/// <summary>
///
///
/// </summary>
int ICommonResponse.RawStatus { get; set; }
/// <summary>
///
///
/// </summary>
IDictionary<string, string> ICommonResponse.RawHeaders { get; set; } = default!;
/// <summary>
///
///
/// </summary>
byte[] ICommonResponse.RawBytes { get; set; } = default!;