Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022 Passport project refresh #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
# http://EditorConfig.org
# https://www.jetbrains.com/help/rider/EditorConfig_Properties.html

# This file is the top-most EditorConfig file
root = true

# All Files
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120

# C# Files
[*.cs]
csharp_align_multiline_parameter = true
csharp_align_multiline_extends_list = true
csharp_align_linq_query = true
csharp_place_attribute_on_same_line = false
csharp_empty_block_style = together_same_line
csharp_space_within_single_line_array_initializer_braces = true
csharp_empty_block_style = together
max_line_length = 120

# Solution Files
[*.sln]
indent_style = tab

# XML Project Files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
xml_wrap_tags_and_pi = false

# Configuration Files
[*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
Expand All @@ -35,3 +37,4 @@ indent_size = 2
# Markdown Files
[*.md]
trim_trailing_whitespace = false
indent_size = 2
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

79 changes: 35 additions & 44 deletions Telegram.Bot.Extensions.Passport.sln
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 17
VisualStudioVersion = 17.2.32422.2
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "deps", "deps", "{2CAB4FDA-D625-40D2-BC54-68FE375D821B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegram.Bot", "deps\Telegram.Bot\src\Telegram.Bot\Telegram.Bot.csproj", "{EC89AC57-7C57-4612-97BA-23FB5E7532EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{219FA372-F501-4189-A114-9F4BC224374A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegram.Bot.Extensions.Passport", "src\Telegram.Bot.Extensions.Passport\Telegram.Bot.Extensions.Passport.csproj", "{D6753021-F292-4465-9E8B-7D0CE7A4D504}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Telegram.Bot.Extensions.Passport", "src\Telegram.Bot.Extensions.Passport\Telegram.Bot.Extensions.Passport.csproj", "{D6753021-F292-4465-9E8B-7D0CE7A4D504}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quickstart", "src\Quickstart\Quickstart.csproj", "{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quickstart", "src\Quickstart\Quickstart.csproj", "{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8804BAE3-C00C-4618-91B3-65A38CEF34F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "test\IntegrationTests\IntegrationTests.csproj", "{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "test\IntegrationTests\IntegrationTests.csproj", "{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "test\UnitTests\UnitTests.csproj", "{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{90B24D96-E3FB-44DB-AAE4-14BE3C1BB0C2}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -28,29 +29,7 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EC89AC57-7C57-4612-97BA-23FB5E7532EF} = {2CAB4FDA-D625-40D2-BC54-68FE375D821B}
{D6753021-F292-4465-9E8B-7D0CE7A4D504} = {219FA372-F501-4189-A114-9F4BC224374A}
{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17} = {8804BAE3-C00C-4618-91B3-65A38CEF34F0}
{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0} = {8804BAE3-C00C-4618-91B3-65A38CEF34F0}
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8} = {219FA372-F501-4189-A114-9F4BC224374A}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|x64.ActiveCfg = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|x64.Build.0 = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|x86.ActiveCfg = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Debug|x86.Build.0 = Debug|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|Any CPU.Build.0 = Release|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|x64.ActiveCfg = Release|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|x64.Build.0 = Release|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|x86.ActiveCfg = Release|Any CPU
{EC89AC57-7C57-4612-97BA-23FB5E7532EF}.Release|x86.Build.0 = Release|Any CPU
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -63,6 +42,18 @@ Global
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Release|x64.Build.0 = Release|Any CPU
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Release|x86.ActiveCfg = Release|Any CPU
{D6753021-F292-4465-9E8B-7D0CE7A4D504}.Release|x86.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x64.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x86.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x86.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|Any CPU.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x64.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x64.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x86.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x86.Build.0 = Release|Any CPU
{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -87,17 +78,17 @@ Global
{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0}.Release|x64.Build.0 = Release|Any CPU
{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0}.Release|x86.ActiveCfg = Release|Any CPU
{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0}.Release|x86.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x64.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x86.ActiveCfg = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Debug|x86.Build.0 = Debug|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|Any CPU.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x64.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x64.Build.0 = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x86.ActiveCfg = Release|Any CPU
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D6753021-F292-4465-9E8B-7D0CE7A4D504} = {219FA372-F501-4189-A114-9F4BC224374A}
{1DFDD1AD-8543-46CC-B54A-1E2E2D2B62C8} = {219FA372-F501-4189-A114-9F4BC224374A}
{8B4D1075-75E4-49D1-8AB7-19EC01DF3F17} = {8804BAE3-C00C-4618-91B3-65A38CEF34F0}
{8CF594BF-BA8C-43C2-B7C4-69F7155A48F0} = {8804BAE3-C00C-4618-91B3-65A38CEF34F0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BEA217AA-95F7-41B7-A7A4-835147B5B53E}
EndGlobalSection
EndGlobal
1 change: 0 additions & 1 deletion deps/Telegram.Bot
Submodule Telegram.Bot deleted from 18e287
4 changes: 2 additions & 2 deletions src/Quickstart/EncryptionKeyParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct EncryptionKeyParameters
public byte[] D;

public static explicit operator EncryptionKeyParameters(RSAParameters parameters) =>
new EncryptionKeyParameters
new()
{
E = parameters.Exponent,
M = parameters.Modulus,
Expand All @@ -32,7 +32,7 @@ public static explicit operator EncryptionKeyParameters(RSAParameters parameters
};

public static explicit operator RSAParameters(EncryptionKeyParameters parameters) =>
new RSAParameters
new()
{
Exponent = parameters.E,
Modulus = parameters.M,
Expand Down
12 changes: 6 additions & 6 deletions src/Quickstart/EncryptionKeyUtility.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.IO;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System.IO;
using System.Security.Cryptography;

namespace Quickstart
{
Expand All @@ -20,10 +20,10 @@ public static class EncryptionKeyUtility
/// <returns>JSON string representing RSA parameters of the <paramref name="key"/></returns>
public static string SerializeRsaParameters(string key)
{
PemReader pemReader = new PemReader(new StringReader(key));
AsymmetricCipherKeyPair keyPair = (AsymmetricCipherKeyPair) pemReader.ReadObject();
PemReader pemReader = new(new StringReader(key));
AsymmetricCipherKeyPair keyPair = (AsymmetricCipherKeyPair)pemReader.ReadObject();
RSAParameters parameters = DotNetUtilities.ToRSAParameters(keyPair.Private as RsaPrivateCrtKeyParameters);
return JsonConvert.SerializeObject((EncryptionKeyParameters) parameters);
return JsonConvert.SerializeObject((EncryptionKeyParameters)parameters);
}

/// <summary>
Expand All @@ -33,6 +33,6 @@ public static string SerializeRsaParameters(string key)
/// <param name="json">JSON-serialized RSA key parameters</param>
/// <returns>Created RSA instance representing the encryption key</returns>
public static RSA GetRsaKeyFromJson(string json) =>
RSA.Create((RSAParameters) JsonConvert.DeserializeObject<EncryptionKeyParameters>(json));
RSA.Create((RSAParameters)JsonConvert.DeserializeObject<EncryptionKeyParameters>(json));
}
}
Loading