-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💾 Feat(Dashboard): Accept remote KWC invoking.
- Loading branch information
1 parent
c7f2835
commit 4608129
Showing
6 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
KitX Shared/KitX.Shared.CSharp/Security/EncryptedContent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using KitX.Shared.CSharp.Device; | ||
|
||
namespace KitX.Shared.CSharp.Security; | ||
|
||
public class EncryptedContent | ||
{ | ||
public DeviceLocator? Device { get; set; } | ||
|
||
public string? RsaEncryptedAesKeyBase64 { get; set; } | ||
|
||
public string? AesEncryptedContentBase64 { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
KitX Shared/KitX.Shared.CSharp/WebCommand/Infos/CompressionInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace KitX.Shared.CSharp.WebCommand.Infos; | ||
|
||
public struct CompressionInfo | ||
public class CompressionInfo | ||
{ | ||
|
||
} |
13 changes: 9 additions & 4 deletions
13
KitX Shared/KitX.Shared.CSharp/WebCommand/Infos/EncryptionInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
namespace KitX.Shared.CSharp.WebCommand.Infos; | ||
|
||
public struct EncryptionInfo | ||
public class EncryptionInfo | ||
{ | ||
public bool IsEncrypted { get; set; } | ||
public bool IsEncrypted { get; set; } = false; | ||
|
||
public string EncryptionMethod { get; set; } | ||
public EncryptionMethods EncryptionMethod { get; set; } = EncryptionMethods.RSA; | ||
} | ||
|
||
public string EncryptionKeyId { get; set; } | ||
public enum EncryptionMethods | ||
{ | ||
Custom = 0, | ||
RSA = 1, | ||
AES = 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
using KitX.Shared.CSharp.Device; | ||
using System; | ||
using KitX.Shared.CSharp.Device; | ||
using KitX.Shared.CSharp.WebCommand.Infos; | ||
|
||
namespace KitX.Shared.CSharp.WebCommand; | ||
|
||
public struct Request | ||
public class Request | ||
{ | ||
public string Type { get; set; } | ||
public RequestTypes Type { get; set; } = RequestTypes.Command; | ||
|
||
public string Version { get; set; } | ||
public RequestVersions Version { get; set; } = RequestVersions.V1; | ||
|
||
public DeviceLocator Sender { get; set; } | ||
public DeviceLocator? Sender { get; set; } | ||
|
||
public DeviceLocator Target { get; set; } | ||
public DeviceLocator? Target { get; set; } | ||
|
||
public EncryptionInfo EncryptionInfo { get; set; } | ||
public EncryptionInfo EncryptionInfo { get; set; } = new(); | ||
|
||
public CompressionInfo CompressionInfo { get; set; } | ||
public CompressionInfo CompressionInfo { get; set; } = new(); | ||
|
||
public string Content { get; set; } | ||
public string Content { get; set; } = string.Empty; | ||
} | ||
|
||
public enum RequestTypes | ||
{ | ||
Unknown = 0, | ||
Command = 1, | ||
} | ||
|
||
public enum RequestVersions | ||
{ | ||
Unknown = 0, | ||
V1 = 1, | ||
} | ||
|
||
public static class RequestExtensions | ||
{ | ||
public static string GetContent(this Request request, Func<string, string> decryptFunc) => decryptFunc.Invoke(request.Content); | ||
|
||
public static void Match(this Request request, string decryptedContent, Action<string>? matchCommand = null) | ||
{ | ||
switch (request.Type) | ||
{ | ||
case RequestTypes.Unknown: | ||
break; | ||
case RequestTypes.Command: | ||
matchCommand?.Invoke(decryptedContent); | ||
break; | ||
} | ||
} | ||
|
||
public static Request Rebuild(this Request request, Func<Request, Request> rebuilder) => rebuilder(request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters