diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a43bc01..fc5589c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -17,7 +17,7 @@ jobs: dotnet-version: 8.0.x - name: Build release - run: dotnet build src/Devlord.Utilities/Devlord.Utilities.csproj --configuration Release + run: dotnet build --configuration Release - name: Pack prerelease with build number if: "github.event.release.prerelease" run: | diff --git a/.nupkg/Devlord.Utilities.7.0.1-local.nupkg b/.nupkg/Devlord.Utilities.7.0.1-local.nupkg new file mode 100644 index 0000000..268ad35 Binary files /dev/null and b/.nupkg/Devlord.Utilities.7.0.1-local.nupkg differ diff --git a/.nupkg/Devlord.Utilities.Mail.7.0.1-local.nupkg b/.nupkg/Devlord.Utilities.Mail.7.0.1-local.nupkg new file mode 100644 index 0000000..22ad896 Binary files /dev/null and b/.nupkg/Devlord.Utilities.Mail.7.0.1-local.nupkg differ diff --git a/Devlord.Utilities.sln b/Devlord.Utilities.sln index 553d0b6..cd91bcc 100644 --- a/Devlord.Utilities.sln +++ b/Devlord.Utilities.sln @@ -10,17 +10,20 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{33918F2B-0111-483C-B796-328D8AB07E35}" ProjectSection(SolutionItems) = preProject appveyor.yml = appveyor.yml - LICENSE = LICENSE + LICENSE.txt = LICENSE.txt README.md = README.md + images\devlord-105.png = images\devlord-105.png + .github\workflows\dotnet.yml = .github\workflows\dotnet.yml + .github\workflows\package.yml = .github\workflows\package.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D98FBDA4-114C-469D-A722-A8DB70F42BFE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F789018F-60C1-4E97-8E2F-5FFD41A008D1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encryptamajig", "src\Encryptamajig\Encryptamajig.csproj", "{E5BACB77-AE20-4834-9AAA-DED949436118}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Devlord.Utilities.Mail", "src\Devlord.Utilities.Mail\Devlord.Utilities.Mail.csproj", "{5336A7B7-3BA1-4025-B39D-B831DEA65668}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encryptamajig.Tests", "test\Encryptamajig.Tests\Encryptamajig.Tests.csproj", "{239FCC70-2688-4EAF-8C19-85A348840E34}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Devlord.Utilities.MapsApi", "src\Devlord.Utilities.MapsApi\Devlord.Utilities.MapsApi.csproj", "{C6AEABA2-94DD-4642-8DD8-8795DAAE797C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -36,14 +39,14 @@ Global {F41E3A90-DCB2-4E86-B9A1-DC45B0DFB998}.Debug|Any CPU.Build.0 = Debug|Any CPU {F41E3A90-DCB2-4E86-B9A1-DC45B0DFB998}.Release|Any CPU.ActiveCfg = Release|Any CPU {F41E3A90-DCB2-4E86-B9A1-DC45B0DFB998}.Release|Any CPU.Build.0 = Release|Any CPU - {E5BACB77-AE20-4834-9AAA-DED949436118}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5BACB77-AE20-4834-9AAA-DED949436118}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5BACB77-AE20-4834-9AAA-DED949436118}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5BACB77-AE20-4834-9AAA-DED949436118}.Release|Any CPU.Build.0 = Release|Any CPU - {239FCC70-2688-4EAF-8C19-85A348840E34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {239FCC70-2688-4EAF-8C19-85A348840E34}.Debug|Any CPU.Build.0 = Debug|Any CPU - {239FCC70-2688-4EAF-8C19-85A348840E34}.Release|Any CPU.ActiveCfg = Release|Any CPU - {239FCC70-2688-4EAF-8C19-85A348840E34}.Release|Any CPU.Build.0 = Release|Any CPU + {5336A7B7-3BA1-4025-B39D-B831DEA65668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5336A7B7-3BA1-4025-B39D-B831DEA65668}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5336A7B7-3BA1-4025-B39D-B831DEA65668}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5336A7B7-3BA1-4025-B39D-B831DEA65668}.Release|Any CPU.Build.0 = Release|Any CPU + {C6AEABA2-94DD-4642-8DD8-8795DAAE797C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6AEABA2-94DD-4642-8DD8-8795DAAE797C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6AEABA2-94DD-4642-8DD8-8795DAAE797C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6AEABA2-94DD-4642-8DD8-8795DAAE797C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -51,8 +54,8 @@ Global GlobalSection(NestedProjects) = preSolution {BDA4FCBB-3582-42E0-B383-1BAB2BC69547} = {D98FBDA4-114C-469D-A722-A8DB70F42BFE} {F41E3A90-DCB2-4E86-B9A1-DC45B0DFB998} = {F789018F-60C1-4E97-8E2F-5FFD41A008D1} - {E5BACB77-AE20-4834-9AAA-DED949436118} = {D98FBDA4-114C-469D-A722-A8DB70F42BFE} - {239FCC70-2688-4EAF-8C19-85A348840E34} = {F789018F-60C1-4E97-8E2F-5FFD41A008D1} + {5336A7B7-3BA1-4025-B39D-B831DEA65668} = {D98FBDA4-114C-469D-A722-A8DB70F42BFE} + {C6AEABA2-94DD-4642-8DD8-8795DAAE797C} = {D98FBDA4-114C-469D-A722-A8DB70F42BFE} EndGlobalSection GlobalSection(CodealikeProperties) = postSolution SolutionGuid = 786e0001-a81c-40a8-96b1-bd100ef383c7 diff --git a/Devlord.Utilities.sln.DotSettings b/Devlord.Utilities.sln.DotSettings index e64a9f3..e6ce0c5 100644 --- a/Devlord.Utilities.sln.DotSettings +++ b/Devlord.Utilities.sln.DotSettings @@ -1,19 +1,20 @@  -------------------------------------------------------------------------------------------------------------------- -<copyright file="$FILENAME$" company="Lord Design"> - © $CURRENT_YEAR$ Lord Design +<copyright file="${File.FileName}" company="Lord Design"> + © ${CurrentDate.Year} Lord Design </copyright> <license type="GPL-3.0"> You may use freely and commercially without modification; if you make changes, please share back to the community. </license> -<author>$USER_NAME$</author> +<author>${User.Name}</author> -------------------------------------------------------------------------------------------------------------------- DR True True True + True <data><IncludeFilters /><ExcludeFilters><Filter ModuleMask="Devlord.Utilities" ModuleVersionMask="*" ClassMask="Devlord.Utilities.Properties.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="Devlord.Utilities" ModuleVersionMask="*" ClassMask="Devlord.Utilities.Resources.*" FunctionMask="*" IsEnabled="True" /></ExcludeFilters></data> True True diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index 1cf2fdc..9f363ff 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -devlord utilities +Devlord.Utilities ==================== +A useful class library for universal utilities like consuming RESTful APIs. -A useful class library for universal utilities like encryption, sending emails, and consuming RESTful APIs. - -| Master | Develop | NuGet | -| ----- | ----- | ----- | -| [![Build status](https://ci.appveyor.com/api/projects/status/i0us4v5jxi6llk3e/branch/master?svg=true)](https://ci.appveyor.com/project/lorddev/utilities/branch/master) | [![Build status](https://ci.appveyor.com/api/projects/status/i0us4v5jxi6llk3e/branch/develop?svg=true)](https://ci.appveyor.com/project/lorddev/utilities/branch/develop) | [![NuGet Package](https://buildstats.info/nuget/Devlord.Utilities)](https://www.nuget.org/packages/Devlord.Utilities/) | +| Main | Develop | NuGet | +| ----- | ----- | ----- | +| [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg?branch=develop)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![NuGet](https://img.shields.io/badge/nuget-%23004880.svg?style=for-the-badge&logo=nuget&logoColor=white)](https://www.nuget.org/packages/Devlord.Utilities/) | To install Devlord.Utilities, run the following command in the Package Manager Console: @@ -16,13 +15,20 @@ Or from the command-line: dotnet add package Devlord.Utilities +### Breaking Changes + +* Mail utilities have been moved to the Devlord.Utilities.Mail package. +* Maps API utilities have been moved to the Devlord.Utilities.MapsApi package. +* Encryption has been deprecated because the protocols are no longer recommended. +* UnderscoreContractResolver has been removed in favor of System.Text.Json snake case handling. +* ValueText.Value has been changed from string to decimal. + ### Feature Summary * .NET Core compatibility * System.Threading.Timers service clocks * Email throttling to help you avoid being suspended by your ISP * Generic HTTP API wrappers -* Two-way AES encryption * "Micro-ORM" DataReader mapper for when using a full-featured ORM would be overkill More details below, but for even _more_ details, see the [project wiki](https://github.com/lorddev/utilities/wiki). @@ -89,11 +95,6 @@ A multithreaded SMTP queued mail sender, has a configurable throttle for mail fr } ``` -### Crypt - -Bidirectional encryption methods useful for storing credit cards or encrypting passwords or API keys to save in a project's -configuration files. (Not recommend for use with user's site credentials as those should use one-way encryption.) - ### DRMapper Allows mapping of an `IDataReader` to POCO classes using reflection. It's faster than you might expect. diff --git a/images/devlord-105.png b/images/devlord-105.png new file mode 100644 index 0000000..946133b Binary files /dev/null and b/images/devlord-105.png differ diff --git a/src/Devlord.Utilities/Botmail.cs b/src/Devlord.Utilities.Mail/Botmail.cs similarity index 94% rename from src/Devlord.Utilities/Botmail.cs rename to src/Devlord.Utilities.Mail/Botmail.cs index 91d8c5c..dd7c1e5 100644 --- a/src/Devlord.Utilities/Botmail.cs +++ b/src/Devlord.Utilities.Mail/Botmail.cs @@ -6,9 +6,7 @@ // aaron@lorddesign.net // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; - -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// The botmail. diff --git a/src/Devlord.Utilities.Mail/Devlord.Utilities.Mail.csproj b/src/Devlord.Utilities.Mail/Devlord.Utilities.Mail.csproj new file mode 100644 index 0000000..677c525 --- /dev/null +++ b/src/Devlord.Utilities.Mail/Devlord.Utilities.Mail.csproj @@ -0,0 +1,33 @@ + + + + net8.0;net10.0 + enable + enable + 7.0.1 + Devlords Cooperative + devlord + https://github.com/lorddev/utilities + Copyright © 2026 Aaron Lord + GPL-3.0-only + devlord-105.png + https://github.com/lorddev/utilities + Git + utils utilities email gmail mailbot + Utilities class library so you don't have to rewrite your utilities on every project. + README.md + + + + + + + + + + + + + + + diff --git a/src/Devlord.Utilities/DevlordSettingsExtension.cs b/src/Devlord.Utilities.Mail/DevlordSettingsExtension.cs similarity index 88% rename from src/Devlord.Utilities/DevlordSettingsExtension.cs rename to src/Devlord.Utilities.Mail/DevlordSettingsExtension.cs index 6e11bfb..c9459b8 100644 --- a/src/Devlord.Utilities/DevlordSettingsExtension.cs +++ b/src/Devlord.Utilities.Mail/DevlordSettingsExtension.cs @@ -12,11 +12,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { public static class DevlordSettingsExtension { - public static IServiceCollection AddDevlordUtilities(this IServiceCollection services, + public static IServiceCollection AddDevlordMail(this IServiceCollection services, IConfiguration namedConfigurationSection) { services.Configure(namedConfigurationSection); diff --git a/src/Devlord.Utilities/GmailThrottles.cs b/src/Devlord.Utilities.Mail/GmailThrottles.cs similarity index 80% rename from src/Devlord.Utilities/GmailThrottles.cs rename to src/Devlord.Utilities.Mail/GmailThrottles.cs index 212eb08..d293ecb 100644 --- a/src/Devlord.Utilities/GmailThrottles.cs +++ b/src/Devlord.Utilities.Mail/GmailThrottles.cs @@ -1,8 +1,4 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// The throttles. diff --git a/src/Devlord.Utilities/IMailbotFactory.cs b/src/Devlord.Utilities.Mail/IMailbotFactory.cs similarity index 95% rename from src/Devlord.Utilities/IMailbotFactory.cs rename to src/Devlord.Utilities.Mail/IMailbotFactory.cs index 06fee98..15dc414 100644 --- a/src/Devlord.Utilities/IMailbotFactory.cs +++ b/src/Devlord.Utilities.Mail/IMailbotFactory.cs @@ -9,7 +9,7 @@ // Aaron Lord // -------------------------------------------------------------------------------------------------------------------- -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { public interface IMailbotFactory { diff --git a/src/Devlord.Utilities/MailFormat.cs b/src/Devlord.Utilities.Mail/MailFormat.cs similarity index 81% rename from src/Devlord.Utilities/MailFormat.cs rename to src/Devlord.Utilities.Mail/MailFormat.cs index 1e544fc..49d1e16 100644 --- a/src/Devlord.Utilities/MailFormat.cs +++ b/src/Devlord.Utilities.Mail/MailFormat.cs @@ -1,4 +1,4 @@ -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { public enum MailFormat { diff --git a/src/Devlord.Utilities/MailThrottle.cs b/src/Devlord.Utilities.Mail/MailThrottle.cs similarity index 97% rename from src/Devlord.Utilities/MailThrottle.cs rename to src/Devlord.Utilities.Mail/MailThrottle.cs index 7957cec..4ee9950 100644 --- a/src/Devlord.Utilities/MailThrottle.cs +++ b/src/Devlord.Utilities.Mail/MailThrottle.cs @@ -10,11 +10,7 @@ // aaron@lorddesign.net // -------------------------------------------------------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// The mail throttle. diff --git a/src/Devlord.Utilities/Mailbot.cs b/src/Devlord.Utilities.Mail/Mailbot.cs similarity index 65% rename from src/Devlord.Utilities/Mailbot.cs rename to src/Devlord.Utilities.Mail/Mailbot.cs index 04bcd64..200a9d7 100644 --- a/src/Devlord.Utilities/Mailbot.cs +++ b/src/Devlord.Utilities.Mail/Mailbot.cs @@ -1,4 +1,4 @@ -// -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // // © Lord Design. Modified GPL: You may use freely and commercially without modification; you can modify if result // is also free. @@ -10,13 +10,11 @@ // aaron@lorddesign.net // -------------------------------------------------------------------------------------------------------------------- -using System.Threading.Tasks; -using Devlord.Utilities.Cryptography; using MailKit.Net.Smtp; using MailKit.Security; using MimeKit; -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// Multi-threaded mailer to keep your systems running by sending messages asynchronously. If you're using it in a @@ -26,8 +24,6 @@ public class Mailbot { #region Fields - private readonly Crypt _crypt = new Crypt(); - /// /// The throttles. /// @@ -42,15 +38,6 @@ public class Mailbot /// internal Mailbot() { - _crypt.Key = new byte[] - { - 80, 20, 245, 0, 124, 61, 192, 137, 232, 79, 249, 228, 1, 246, 187, 3, 228, 215, 250, 11, - 131, 33, 180, 143, 41, 217, 4, 16, 219, 34, 50, 115, 96, 140, 146, 24, 5, 69, 58, 183, 66, 88, 58, 44, - 213, 81, 26, 187, 247, 101, 163, 248, 103, 3, 179, 60, 14, 152, 90, 230, 92, 69, 100, 246, 32, 27, 201, - 123, 99, 229, 66, 118, 185, 241, 136, 38, 174, 104, 203, 207, 4, 175, 223, 104, 140, 234, 20, 228, 209, - 175, 94, 212, 105, 165, 47, 61, 100, 219, 18, - 224 - }; } #endregion @@ -64,7 +51,7 @@ internal Mailbot() public int SmtpPort { get; internal set; } public string SmtpLogin { get; internal set; } - public string EncryptedPassword { get; internal set; } + public string SmtpPassword { get; internal set; } #endregion @@ -83,19 +70,18 @@ private async Task SendMail(Botmail botmail) Throttles.Wait(); var mm = new MimeMessage(); - mm.From.Add(new MailboxAddress(botmail.Addresser)); + mm.From.Add(MailboxAddress.Parse(botmail.Addresser)); mm.Subject = botmail.Subject; mm.Body = new TextPart(botmail.Format.ToString().ToLower()) { Text = botmail.Body }; - botmail.Addressees.ForEach(a => mm.To.Add(new MailboxAddress(a))); + botmail.Addressees.ForEach(a => mm.To.Add(MailboxAddress.Parse(a))); using (var client = new SmtpClient()) { - client.Connect(SmtpServer, SmtpPort, SecureSocketOptions.SslOnConnect); - await client.AuthenticateAsync(SmtpLogin, - _crypt.DecryptSecret(EncryptedPassword)); + await client.ConnectAsync(SmtpServer, SmtpPort, SecureSocketOptions.SslOnConnect); + await client.AuthenticateAsync(SmtpLogin, SmtpPassword); await client.SendAsync(mm); Throttles.Increment(); client.Disconnect(true); diff --git a/src/Devlord.Utilities/MailbotFactory.cs b/src/Devlord.Utilities.Mail/MailbotFactory.cs similarity index 94% rename from src/Devlord.Utilities/MailbotFactory.cs rename to src/Devlord.Utilities.Mail/MailbotFactory.cs index f38a9bd..53da23c 100644 --- a/src/Devlord.Utilities/MailbotFactory.cs +++ b/src/Devlord.Utilities.Mail/MailbotFactory.cs @@ -9,14 +9,12 @@ // Aaron Lord // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using Devlord.Utilities.Exceptions; using Microsoft.Extensions.Options; [assembly: InternalsVisibleTo("Devlord.Utilities.Tests")] -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { public class MailbotFactory : IMailbotFactory { @@ -56,7 +54,7 @@ public Mailbot GetMailbot(string name) SmtpServer = thisOptions.SmtpServer, SmtpPort = thisOptions.SmtpPort, SmtpLogin = thisOptions.SmtpLogin, - EncryptedPassword = thisOptions.SmtpPassword, + SmtpPassword = thisOptions.SmtpPassword, Throttles = new Throttles(thisOptions.MaxPerMinute, thisOptions.MaxPerHour, thisOptions.MaxPerDay) }; diff --git a/src/Devlord.Utilities.Mail/README.md b/src/Devlord.Utilities.Mail/README.md new file mode 100644 index 0000000..60b336a --- /dev/null +++ b/src/Devlord.Utilities.Mail/README.md @@ -0,0 +1,69 @@ +Devlord.Utilities.Mail +==================== + + +A useful class library for universal utilities like sending emails and consuming RESTful APIs. + +| Main | Develop | NuGet | +| ----- | ----- | ----- | +| [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg?branch=develop)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![NuGet](https://img.shields.io/badge/nuget-%23004880.svg?style=for-the-badge&logo=nuget&logoColor=white)](https://www.nuget.org/packages/Devlord.Utilities.Mail/) | + +To install Devlord.Utilities.Mail, run the following command in the Package Manager Console: + + PM> Install-Package Devlord.Utilities.Mail + +Or from the command-line: + + dotnet add package Devlord.Utilities.Mail + +### Changes from Devlord.Utilities 6.0 + +* Mail utilities have been moved to the Devlord.Utilities.Mail package. +* `Devlord.Utilities.Mail` is the new namespace. + +### Feature Summary + +* .NET Core compatibility +* Email throttling to help you avoid being suspended by your ISP + +More details below, but for even _more_ details, see the [project wiki](https://github.com/lorddev/utilities/wiki). + +### Mailbot + +A multithreaded SMTP queued mail sender, has a configurable throttle for mail frequency sent by a single account. + +**Configuration** + +```json +{ + "Devlord.Utilities": { + "MailSettings": [ + { + "Name": "Gmail", + "SmtpServer": "mail.google.com", + "SmtpPort": 587, + "SmtpPassword": "", + "MaxPerMinute": 500, + "MaxPerHour": 500, + "MaxPerDay": 500 + } + ] + } +} +``` + +### Contributing + +Yes, please! + +### License + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published +by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see . + +Contact [lorddev](https://github.com/lorddev) on GitHub or [@devlord@hachyderm.io](https://hachyderm.io/@devlord) on Mastodon. diff --git a/src/Devlord.Utilities/ThrottleInterval.cs b/src/Devlord.Utilities.Mail/ThrottleInterval.cs similarity index 91% rename from src/Devlord.Utilities/ThrottleInterval.cs rename to src/Devlord.Utilities.Mail/ThrottleInterval.cs index adc58d1..d016631 100644 --- a/src/Devlord.Utilities/ThrottleInterval.cs +++ b/src/Devlord.Utilities.Mail/ThrottleInterval.cs @@ -1,4 +1,4 @@ -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// The throttle interval. diff --git a/src/Devlord.Utilities/Throttles.cs b/src/Devlord.Utilities.Mail/Throttles.cs similarity index 96% rename from src/Devlord.Utilities/Throttles.cs rename to src/Devlord.Utilities.Mail/Throttles.cs index 642abf3..b7388df 100644 --- a/src/Devlord.Utilities/Throttles.cs +++ b/src/Devlord.Utilities.Mail/Throttles.cs @@ -1,8 +1,4 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Devlord.Utilities +namespace Devlord.Utilities.Mail { /// /// The throttles. diff --git a/src/Devlord.Utilities.MapsApi/Devlord.Utilities.MapsApi.csproj b/src/Devlord.Utilities.MapsApi/Devlord.Utilities.MapsApi.csproj new file mode 100644 index 0000000..15bc0c3 --- /dev/null +++ b/src/Devlord.Utilities.MapsApi/Devlord.Utilities.MapsApi.csproj @@ -0,0 +1,32 @@ + + + + net8.0;net10.0 + enable + enable + 7.0.1 + Devlords Cooperative + devlord + https://github.com/lorddev/utilities + Copyright © 2026 Aaron Lord + GPL-3.0-only + devlord-105.png + https://github.com/lorddev/utilities + Git + utils utilities distance-matrix + Utilities class library so you don't have to rewrite your utilities on every project. + README.md + + + + + + + + + + + + + + diff --git a/src/Devlord.Utilities.MapsApi/DevlordSettingsExtension.cs b/src/Devlord.Utilities.MapsApi/DevlordSettingsExtension.cs new file mode 100644 index 0000000..21225ca --- /dev/null +++ b/src/Devlord.Utilities.MapsApi/DevlordSettingsExtension.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// © 2022 Lord Design +// +// +// You may use freely and commercially without modification; if you make changes, please share back to the +// community. +// +// Aaron Lord +// -------------------------------------------------------------------------------------------------------------------- + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace Devlord.Utilities +{ + public static class DevlordSettingsExtension + { + public static IServiceCollection AddDevlordMaps(this IServiceCollection services, + IConfiguration namedConfigurationSection) + { + services.Configure(namedConfigurationSection); + + return services; + } + } +} \ No newline at end of file diff --git a/src/Devlord.Utilities/MapsApi/DistanceElement.cs b/src/Devlord.Utilities.MapsApi/DistanceElement.cs similarity index 100% rename from src/Devlord.Utilities/MapsApi/DistanceElement.cs rename to src/Devlord.Utilities.MapsApi/DistanceElement.cs diff --git a/src/Devlord.Utilities/MapsApi/DistanceResults.cs b/src/Devlord.Utilities.MapsApi/DistanceResults.cs similarity index 60% rename from src/Devlord.Utilities/MapsApi/DistanceResults.cs rename to src/Devlord.Utilities.MapsApi/DistanceResults.cs index b8a277b..487f3c4 100644 --- a/src/Devlord.Utilities/MapsApi/DistanceResults.cs +++ b/src/Devlord.Utilities.MapsApi/DistanceResults.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; +using System.Text.Json; namespace Devlord.Utilities.MapsApi { @@ -28,22 +25,21 @@ public DistanceElement GetResult(int index) public string ToJson() { - string json = JsonConvert.SerializeObject( + string json = JsonSerializer.Serialize( this, - Formatting.Indented, Settings); return json; } - private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings - { - ContractResolver = - new UnderscoreContractResolver() + private static readonly JsonSerializerOptions Settings = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + WriteIndented = true, }; - public static DistanceResults FromJson(string json) + public static DistanceResults? FromJson(string json) { - return JsonConvert.DeserializeObject(json, Settings); + return JsonSerializer.Deserialize(json, Settings); } } } \ No newline at end of file diff --git a/src/Devlord.Utilities/MapsApi/DistanceService.cs b/src/Devlord.Utilities.MapsApi/DistanceService.cs similarity index 100% rename from src/Devlord.Utilities/MapsApi/DistanceService.cs rename to src/Devlord.Utilities.MapsApi/DistanceService.cs diff --git a/src/Devlord.Utilities/MapsApi/ElementRow.cs b/src/Devlord.Utilities.MapsApi/ElementRow.cs similarity index 100% rename from src/Devlord.Utilities/MapsApi/ElementRow.cs rename to src/Devlord.Utilities.MapsApi/ElementRow.cs diff --git a/src/Devlord.Utilities.MapsApi/README.md b/src/Devlord.Utilities.MapsApi/README.md new file mode 100644 index 0000000..6cbf036 --- /dev/null +++ b/src/Devlord.Utilities.MapsApi/README.md @@ -0,0 +1,67 @@ +Devlord.Utilities.MapsApi +==================== + + +A useful class library for universal utilities like sending emails and consuming RESTful APIs. + +| Main | Develop | NuGet | +| ----- | ----- | ----- | +| [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![.NET](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml/badge.svg?branch=develop)](https://github.com/lorddev/utilities/actions/workflows/dotnet.yml) | [![NuGet](https://img.shields.io/badge/nuget-%23004880.svg?style=for-the-badge&logo=nuget&logoColor=white)](https://www.nuget.org/packages/Devlord.Utilities.MapsApi/) | + +To install Devlord.Utilities.MapsApi, run the following command in the Package Manager Console: + + PM> Install-Package Devlord.Utilities.MapsApi + +Or from the command-line: + + dotnet add package Devlord.Utilities.MapsApi + +### Changes from Devlord.Utilities 6.0 + +* UnderscoreContractResolver has been removed in favor of System.Text.Json snake case handling. +* ValueText.Value has been changed from string to decimal. + +### Distance API + +POCO classes for accessing the Google Maps distance API. + +Usage with a custom JSON contract resolver that converts the Google JSON property names to POCO object properties. + +```csharp + const string BaseUri = "https://maps.googleapis.com/maps/api/distancematrix/json"; + + using (IApiCall client = new ApiCall(BaseUri, + new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() })) + { + client.QueryParams.Add("sensor", "false"); + client.QueryParams.Add("origins", "95969"); + client.QueryParams.Add("destinations", "95928"); + IApiResult result = client.Execute(); + } +``` + +**Configuration** + +```json +{ + "Devlord.Utilities": { + "GoogleMapsApiKey": "", + } +} +``` + +### Contributing + +Yes, please! + +### License + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published +by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see . + +Contact [lorddev](https://github.com/lorddev) on GitHub or [@devlord@hachyderm.io](https://hachyderm.io/@devlord) on Mastodon. diff --git a/src/Devlord.Utilities/MapsApi/ValueText.cs b/src/Devlord.Utilities.MapsApi/ValueText.cs similarity index 74% rename from src/Devlord.Utilities/MapsApi/ValueText.cs rename to src/Devlord.Utilities.MapsApi/ValueText.cs index 0fea529..f71bd5a 100644 --- a/src/Devlord.Utilities/MapsApi/ValueText.cs +++ b/src/Devlord.Utilities.MapsApi/ValueText.cs @@ -4,6 +4,6 @@ public struct ValueText { public string Text { get; set; } - public string Value { get; set; } + public decimal Value { get; set; } } } \ No newline at end of file diff --git a/src/Devlord.Utilities/ApiCall.cs b/src/Devlord.Utilities/ApiCall.cs index 6509398..5f44ba1 100644 --- a/src/Devlord.Utilities/ApiCall.cs +++ b/src/Devlord.Utilities/ApiCall.cs @@ -4,8 +4,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Text; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; +using System.Text.Json; #pragma warning disable S1449 // Culture should be specified for "string" operations @@ -15,9 +14,9 @@ public class ApiCall : IApiCall { #region Fields - private readonly HttpClient _client = new HttpClient(); + private readonly HttpClient _client = new(); - private readonly JsonSerializerSettings _settings; + private readonly JsonSerializerOptions _settings; private bool _disposed; @@ -33,10 +32,10 @@ public ApiCall(string endpoint) QueryParams = new Dictionary(); Method = "GET"; _endPoint = endpoint; - _settings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() }; + _settings = new JsonSerializerOptions(); } - public ApiCall(string endpoint, JsonSerializerSettings settings) + public ApiCall(string endpoint, JsonSerializerOptions settings) : this(endpoint) { _settings = settings; @@ -49,7 +48,7 @@ public ApiCall(Uri endpoint) protected ApiCall() { - _settings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() }; + _settings = new JsonSerializerOptions(); } #endregion @@ -91,7 +90,7 @@ public virtual IApiResult Execute(Uri endPoint) where T : class } else { - serialize = JsonConvert.SerializeObject; + serialize = x => JsonSerializer.Serialize(x); format = "application/json"; } @@ -131,7 +130,7 @@ public virtual IApiResult Execute(Uri endPoint) where T : class // Assume we know how to deserialize the object. if (format.EndsWith("json")) { - var dataItem = JsonConvert.DeserializeObject(content, _settings); + var dataItem = JsonSerializer.Deserialize(content, _settings); return new ApiResult { StatusCode = response.StatusCode, DataItem = dataItem }; } diff --git a/src/Devlord.Utilities/App_Readme/Elmah.txt b/src/Devlord.Utilities/App_Readme/Elmah.txt deleted file mode 100644 index 784b309..0000000 --- a/src/Devlord.Utilities/App_Readme/Elmah.txt +++ /dev/null @@ -1,15 +0,0 @@ -A new HTTP handler has been configured in your application for consulting the -error log and its feeds. It is reachable at elmah.axd under your application -root. If, for example, your application is deployed at http://www.example.com, -the URL for ELMAH would be http://www.example.com/elmah.axd. You can, of -course, change this path in your application's configuration file. - -ELMAH is also set up to be secure such that it can only be accessed locally. -You can enable remote access but then it is paramount that you secure access -to authorized users or/and roles only. This can be done using standard -authorization rules and configuration already built into ASP.NET. For more -information, see http://code.google.com/p/elmah/wiki/SecuringErrorLogPages on -the project site. - -Please review the commented out authorization section under - and make the appropriate changes. diff --git a/src/Devlord.Utilities/Cryptography/Crypt.cs b/src/Devlord.Utilities/Cryptography/Crypt.cs deleted file mode 100644 index a278054..0000000 --- a/src/Devlord.Utilities/Cryptography/Crypt.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// © 2017 Lord Design -// -// -// You may use freely and commercially without modification; if you make changes, please share back to the -// community. -// -// Aaron Lord -// -------------------------------------------------------------------------------------------------------------------- - -using System; -using System.Security.Cryptography; -using System.Text; -using Encryptamajig; -using BC = BCrypt.Net.BCrypt; - -namespace Devlord.Utilities.Cryptography -{ - /// - /// A basic wrapper for crucial encryption algorithms. - /// - public class Crypt - { - #region Fields - - public byte[] Key { get; set; } - - public static UTF8Encoding SafeUtf8 = new UTF8Encoding(false, true); - - #endregion - - #region Public Methods and Operators - - /// - /// Run this method in a Test project to quickly get a new key of strong random bytes. Iterate through the byte - /// with a StringBuilder to construct your private field instantiator. - /// - /// - /// The . - /// - public static byte[] MakeKey() - { - var random = new byte[100]; - var rng = RandomNumberGenerator.Create(); - rng.GetBytes(random); - return random; - } - - public string HideSecretPassword(string secret) - { - return AesEncryptamajig.Encrypt(secret, Convert.ToBase64String(Key)); - } - - public string DecryptSecret(string cipher) - { - return AesEncryptamajig.Decrypt(cipher, Convert.ToBase64String(Key)); - } - - public string OneWay(string cleartext) - { - var bcrypt = BC.HashPassword(cleartext); - return bcrypt; - } - - /// - /// Todo: BCrypt expects string for cleartext, but that's not secure due to GC issues with strings in memory. - /// Need to "override" BCrypt's behavior here, or somehow access their private static method. - /// - /// - /// - /// - public bool Verify(byte[] input, string storedCipherText) - { - return BC.Verify(SafeUtf8.GetString(input), storedCipherText); - } - #endregion - } -} \ No newline at end of file diff --git a/src/Devlord.Utilities/Devlord.Utilities.csproj b/src/Devlord.Utilities/Devlord.Utilities.csproj index 7a060bc..d132c4e 100644 --- a/src/Devlord.Utilities/Devlord.Utilities.csproj +++ b/src/Devlord.Utilities/Devlord.Utilities.csproj @@ -1,41 +1,32 @@ - netstandard2.1;net6.0 + net8.0 false false false false - 6.0.0 + 7.0.1 Devlords Cooperative devlord https://github.com/lorddev/utilities - Copyright © 2022 Aaron Lord - https://raw.githubusercontent.com/lorddev/utilities/master/LICENSE - https://raw.githubusercontent.com/lorddev/devlords-org/develop/Image.png + Copyright © 2026 Aaron Lord + GPL-3.0-only + devlord-105.png https://github.com/lorddev/utilities Git - utils utilities email distance-matrix micro-orm logging encryption + utils utilities email distance-matrix micro-orm Utilities class library so you don't have to rewrite your utilities on every project. - ... true - Devlord.Utilities.nuspec 22b9d517-6954-4beb-b7be-ba24eb9ac441 + README.md - - - - - - - - - - - - - + + + + + @@ -44,6 +35,11 @@ ExceptionText.resx + + + + + ResXFileCodeGenerator diff --git a/src/Devlord.Utilities/Devlord.Utilities.nuspec b/src/Devlord.Utilities/Devlord.Utilities.nuspec deleted file mode 100644 index 30c605a..0000000 --- a/src/Devlord.Utilities/Devlord.Utilities.nuspec +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - Devlord.Utilities - - - 6.0.0 - Devlord.Utilities - - - Aaron Lord - - - devlord - - - https://raw.githubusercontent.com/lorddev/utilities/master/LICENSE - https://github.com/lorddev/utilities - - - https://raw.githubusercontent.com/lorddev/devlords-org/develop/Image.png - - - false - Utilities class library so you don't have to rewrite your utilities on every project. - - - * Upgraded .NET targets to netstandard2.1 and net6.0 - * Refactored configuration for MailbotFactory and Throttles (see README) - * Fixed bugs in API querystrings - - - Multipurpose universal utilities library so you don't have to write your own utils for every project. Includes extensions, encapsulation of logging and encryption, basic datareader-to-POCO mapping, a mailer throttle, and strongly-typed API callers. - - - Copyright © 2022 Aaron Lord - - - utils utilities email distance-matrix micro-orm logging encryption - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Devlord.Utilities/Devlord.Utilities.nuspec2 b/src/Devlord.Utilities/Devlord.Utilities.nuspec2 deleted file mode 100644 index 501b9ad..0000000 --- a/src/Devlord.Utilities/Devlord.Utilities.nuspec2 +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Devlord.Utilities - 5.0.0 - Devlord.Utilities - lorddev/authors> - Devlords Cooperative - https://raw.githubusercontent.com/lorddev/utilities/master/LICENSE - https://github.com/lorddev/utilities - https://raw.githubusercontent.com/lorddev/devlords-org/develop/Image.png - false - Multipurpose universal utilities library so you don't have to write your own utils for every project. Includes extensions, encapsulation of logging and encryption, DataReader-to-POCO mapping, a mailer throttle, and strongly-typed API callers. Also includes a .NET Core-compatible build of Encryptamajig. - New IDataReader mapper for dynamic ORM. - Copyright © 2017 Aaron Lord - utils utilities email distance-matrix micro-orm logging encryption - - - - - - - - - \ No newline at end of file diff --git a/src/Devlord.Utilities/DevlordOptions.cs b/src/Devlord.Utilities/DevlordOptions.cs index f5ff3d2..2c9d5ee 100644 --- a/src/Devlord.Utilities/DevlordOptions.cs +++ b/src/Devlord.Utilities/DevlordOptions.cs @@ -11,11 +11,6 @@ // Aaron Lord // -------------------------------------------------------------------------------------------------------------------- -using System; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; -using Newtonsoft.Json; - namespace Devlord.Utilities { public class DevlordOptions diff --git a/src/Devlord.Utilities/Exceptions/DevlordConfigurationException.cs b/src/Devlord.Utilities/Exceptions/DevlordConfigurationException.cs index 4d3312f..1342151 100644 --- a/src/Devlord.Utilities/Exceptions/DevlordConfigurationException.cs +++ b/src/Devlord.Utilities/Exceptions/DevlordConfigurationException.cs @@ -21,10 +21,5 @@ public class DevlordConfigurationException : Exception public DevlordConfigurationException(string s) : base(s) { } - - protected DevlordConfigurationException(SerializationInfo info, StreamingContext context) : base(info, context) - { - - } } } \ No newline at end of file diff --git a/src/Devlord.Utilities/Logger.Core.cs b/src/Devlord.Utilities/Logger.Core.cs index d674ca0..142d7af 100644 --- a/src/Devlord.Utilities/Logger.Core.cs +++ b/src/Devlord.Utilities/Logger.Core.cs @@ -1,4 +1,4 @@ -// -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // // © Lord Design // @@ -11,8 +11,6 @@ // Aaron Lord // -------------------------------------------------------------------------------------------------------------------- -using Elmah.Io; - #if !NET451 using System.Diagnostics; diff --git a/src/Devlord.Utilities/Properties/AssemblyInfo.cs b/src/Devlord.Utilities/Properties/AssemblyInfo.cs index 2dd4ef1..190a5c9 100644 --- a/src/Devlord.Utilities/Properties/AssemblyInfo.cs +++ b/src/Devlord.Utilities/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyTitle("Devlord.Utilities")] [assembly: AssemblyDescription( - "Multipurpose universal utilities library so you don't have to write your own utils for every project. Includes extensions, encapsulation of logging and encryption, DataReader-to-POCO mapping, a mailer throttle, and strongly-typed API callers. Also includes a .NET Core-compatible build of Encryptamajig.")] + "Multipurpose universal utilities library so you don't have to write your own utils for every project. Includes extensions, DataReader-to-POCO mapping, a mailer throttle, and strongly-typed API callers.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/Devlord.Utilities/Services/ContinuousLoop.cs b/src/Devlord.Utilities/Services/ContinuousLoop.cs index 1e3f0c1..3c211be 100644 --- a/src/Devlord.Utilities/Services/ContinuousLoop.cs +++ b/src/Devlord.Utilities/Services/ContinuousLoop.cs @@ -28,16 +28,17 @@ public class ContinuousLoop : ServiceTimer /// /// Adding multiple events to the timer will allow the events to run consecutively, though in no particular order. /// - /// + /// /// - public override ServiceTimer AddEvent(ServiceTimerEventHandler @event) + + public override ServiceTimer AddEvent(ServiceTimerEventHandler elapsedHandler) { _queuedTimers++; Events += (s, e) => { try { - @event.Invoke(this, e); + elapsedHandler.Invoke(this, e); } catch (Exception error) { diff --git a/src/Devlord.Utilities/UnderscoreContractResolver.cs b/src/Devlord.Utilities/UnderscoreContractResolver.cs deleted file mode 100644 index 40c98a8..0000000 --- a/src/Devlord.Utilities/UnderscoreContractResolver.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Text.RegularExpressions; -using Newtonsoft.Json.Serialization; - -namespace Devlord.Utilities -{ - public class UnderscoreContractResolver : DefaultContractResolver - { - #region Methods - - protected override string ResolvePropertyName(string propertyName) - { - return Regex.Replace(propertyName, "(?<=[a-z])[A-Z]", m => "_" + m).ToLower(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Devlord.Utilities/package-lock.json b/src/Devlord.Utilities/package-lock.json new file mode 100644 index 0000000..efd9be1 --- /dev/null +++ b/src/Devlord.Utilities/package-lock.json @@ -0,0 +1,984 @@ +{ + "name": "asp.net", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "asp.net", + "version": "1.0.0", + "devDependencies": { + "gulp-bump": "0.1.9" + } + }, + "node_modules/ansi-regex": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", + "integrity": "sha512-sGwIGMjhYdW26/IhwK2gkWWI8DRCVO6uj3hYgHT+zD+QL1pa37tM3ujhyfcJIYSbsxp7Gxhy7zrRW/1AHm4BmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ansi-styles": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", + "integrity": "sha512-f2PKUkN5QngiSemowa6Mrk9MPCdtFiOSmibjZ+j1qhLGHHYsqZwmBMRF3IRMVXo8sybDqx2fJl2d/8OphBoWkA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/array-find-index": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "integrity": "sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha512-DLIsRzJVBQu72meAKPkWQOLcujdXT32hwdfnkI1frSiSRMK1MofjKHf+MEx0SB6fjEFXL8fBDv1dKymBlOp4Qw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/camelcase-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "integrity": "sha512-bA/Z/DERHKqoEOrp+qeGKw1QlvEQkGZSc0XaY6VnTxZr+Kv1G5zFwttpjv8qxZ/sBPT4nthwZaAcsAZTJlSKXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "camelcase": "^2.0.0", + "map-obj": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/chalk": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", + "integrity": "sha512-bIKA54hP8iZhyDT81TOsJiQvR1gW+ZYSXFaZUAvoD4wCHdbHY2actmpTE4x344ZlFqHbvoxKOaESULTZN2gstg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^1.1.0", + "escape-string-regexp": "^1.0.0", + "has-ansi": "^0.1.0", + "strip-ansi": "^0.3.0", + "supports-color": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha512-dhUqc57gSMCo6TX85FLfe51eC/s+Im2MLkAgJwfaRRexR2tA4dd3eLEW4L6efzHc2iNorrRRXITifnDLlRrhaA==", + "dev": true, + "license": "MIT" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/currently-unhandled": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", + "integrity": "sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-find-index": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dateformat": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", + "integrity": "sha512-5sFRfAAmbHdIts+eKjR9kYJoF0ViCMVX9yqLu5A7S/v+nd077KgCITOMiirmyCBiZpKLDXbBOkYm6tu7rX/TKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-stdin": "^4.0.1", + "meow": "^3.3.0" + }, + "bin": { + "dateformat": "bin/cli.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha512-+AWBwjGadtksxjOQSFDhPNQbed7icNXApT4+2BNpsXzcCBiInq2H9XW0O8sfHFaPmnQRs7cg/P0fAr2IWQSW0g==", + "dev": true, + "license": "BSD", + "dependencies": { + "readable-stream": "~1.1.9" + } + }, + "node_modules/error-ex": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz", + "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha512-F5aQMywwJ2n85s4hJPTT9RPxGmubonuB10MNYo17/xph174n2MIR33HRguhzVag10O/npM7SPk73LMZNP+FaWw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/gulp-bump": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/gulp-bump/-/gulp-bump-0.1.9.tgz", + "integrity": "sha512-p+SP6YF62hHSwwqXaR64Z991OhGlF4OQ1B9T7R6ryo4FdIgo3tf/XInOapT5++KkMVTV215gKgocKXMEF+1DLQ==", + "dev": true, + "dependencies": { + "gulp-util": "^2.2.14", + "semver": "^2.2.1", + "through2": "^0.5.1" + }, + "engines": { + "node": ">= 0.9.0" + } + }, + "node_modules/gulp-util": { + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz", + "integrity": "sha512-9rtv4sj9EtCWYGD15HQQvWtRBtU9g1t0+w29tphetHxjxEAuBKQJkhGqvlLkHEtUjEgoqIpsVwPKU1yMZAa+wA==", + "deprecated": "gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5", + "dev": true, + "dependencies": { + "chalk": "^0.5.0", + "dateformat": "^1.0.7-1.2.3", + "lodash._reinterpolate": "^2.4.1", + "lodash.template": "^2.4.1", + "minimist": "^0.2.0", + "multipipe": "^0.1.0", + "through2": "^0.5.0", + "vinyl": "^0.2.1" + }, + "engines": { + "node": ">= 0.9" + } + }, + "node_modules/has-ansi": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", + "integrity": "sha512-1YsTg1fk2/6JToQhtZkArMkurq8UoWU1Qe0aR3VUHjgij4nOylSWLWAtBXoZ4/dXOmugfLGm1c+QhuD0JyedFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^0.2.0" + }, + "bin": { + "has-ansi": "cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true, + "license": "ISC" + }, + "node_modules/indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha512-aqwDFWSgSgfRaEwao5lg5KEcVd/2a+D1rvoG7NdilmYz0NwRk6StWpWdz/Hpk34MKPpx7s8XxUqimfcQK6gGlg==", + "dev": true, + "license": "MIT", + "dependencies": { + "repeating": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-finite": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", + "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/lodash._escapehtmlchar": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", + "integrity": "sha512-eHm2t2Lg476lq5v4FVmm3B5mCaRlDyTE8fnMfPCEq2o46G4au0qNXIKh7YWhjprm1zgSMLcMSs1XHMgkw02PbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._htmlescapes": "~2.4.1" + } + }, + "node_modules/lodash._escapestringchar": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz", + "integrity": "sha512-iZ6Os4iipaE43pr9SBks+UpZgAjJgRC+lGf7onEoByMr1+Nagr1fmR7zCM6Q4RGMB/V3a57raEN0XZl7Uub3/g==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash._htmlescapes": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz", + "integrity": "sha512-g79hNmMOBVyV+4oKIHM7MWy9Awtk3yqf0Twlawr6f+CmG44nTwBh9I5XiLUnk39KTfYoDBpS66glQGgQCnFIuA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash._isnative": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz", + "integrity": "sha512-BOlKGKNHhCHswGOWtmVb5zBygyxN7EmTuzVOSQI6QSoGhG+kvv71gICFS1TBpnqvT1n53txK8CDK3u5D2/GZxQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash._objecttypes": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz", + "integrity": "sha512-XpqGh1e7hhkOzftBfWE7zt+Yn9mVHFkDhicVttvKLsoCMLVVL+xTQjfjB4X4vtznauxv0QZ5ZAeqjvat0dh62Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash._reinterpolate": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz", + "integrity": "sha512-QGEOOjJi7W9LIgDAMVgtGBb8Qgo8ieDlSOCoZjtG45ZNRvDJZjwVMTYlfTIWdNRUiR1I9BjIqQ3Zaf1+DYM94g==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash._reunescapedhtml": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz", + "integrity": "sha512-CfmZRU1Mk4E/5jh+Wu8lc7tuc3VkuwWZYVIgdPDH9NRSHgiL4Or3AA4JCIpgrkVzHOM+jKu2OMkAVquruhRHDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._htmlescapes": "~2.4.1", + "lodash.keys": "~2.4.1" + } + }, + "node_modules/lodash._shimkeys": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz", + "integrity": "sha512-lBrglYxLD/6KAJ8IEa5Lg+YHgNAL7FyKqXg4XOUI+Du/vtniLs1ZqS+yHNKPkK54waAgkdUnDOYaWf+rv4B+AA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._objecttypes": "~2.4.1" + } + }, + "node_modules/lodash.defaults": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz", + "integrity": "sha512-5wTIPWwGGr07JFysAZB8+7JB2NjJKXDIwogSaRX5zED85zyUAQwtOqUk8AsJkkigUcL3akbHYXd5+BPtTGQPZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._objecttypes": "~2.4.1", + "lodash.keys": "~2.4.1" + } + }, + "node_modules/lodash.escape": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", + "integrity": "sha512-PiEStyvZ8gz37qBE+HqME1Yc/ewb/59AMOu8pG7Ztani86foPTxgzckQvMdphmXPY6V5f20Ex/CaNBqHG4/ycQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._escapehtmlchar": "~2.4.1", + "lodash._reunescapedhtml": "~2.4.1", + "lodash.keys": "~2.4.1" + } + }, + "node_modules/lodash.isobject": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz", + "integrity": "sha512-sTebg2a1PoicYEZXD5PBdQcTlIJ6hUslrlWr7iV0O7n+i4596s2NQ9I5CaZ5FbXSfya/9WQsrYLANUJv9paYVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._objecttypes": "~2.4.1" + } + }, + "node_modules/lodash.keys": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz", + "integrity": "sha512-ZpJhwvUXHSNL5wYd1RM6CUa2ZuqorG9ngoJ9Ix5Cce+uX7I5O/E06FCJdhSZ33b5dVyeQDnIlWH7B2s5uByZ7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._isnative": "~2.4.1", + "lodash._shimkeys": "~2.4.1", + "lodash.isobject": "~2.4.1" + } + }, + "node_modules/lodash.template": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz", + "integrity": "sha512-5yLOQwlS69xbaez3g9dA1i0GMAj8pLDHp8lhA4V7M1vRam1lqD76f0jg5EV+65frbqrXo1WH9ZfKalfYBzJ5yQ==", + "deprecated": "This package is deprecated. Use https://socket.dev/npm/package/eta instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._escapestringchar": "~2.4.1", + "lodash._reinterpolate": "~2.4.1", + "lodash.defaults": "~2.4.1", + "lodash.escape": "~2.4.1", + "lodash.keys": "~2.4.1", + "lodash.templatesettings": "~2.4.1", + "lodash.values": "~2.4.1" + } + }, + "node_modules/lodash.templatesettings": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz", + "integrity": "sha512-vY3QQ7GxbeLe8XfTvoYDbaMHO5iyTDJS1KIZrxp00PRMmyBKr8yEcObHSl2ppYTwd8MgqPXAarTvLA14hx8ffw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash._reinterpolate": "~2.4.1", + "lodash.escape": "~2.4.1" + } + }, + "node_modules/lodash.values": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz", + "integrity": "sha512-fQwubKvj2Nox2gy6YnjFm8C1I6MIlzKUtBB+Pj7JGtloGqDDL5CPRr4DUUFWPwXWwAl2k3f4C3Aw8H1qAPB9ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.keys": "~2.4.1" + } + }, + "node_modules/loud-rejection": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", + "integrity": "sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "currently-unhandled": "^0.4.1", + "signal-exit": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/meow": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "integrity": "sha512-TNdwZs0skRlpPpCUK25StC4VH+tP5GgeY1HQOOGP+lQ2xtdkN2VtT/5tiX9k3IWpkBPV9b3LsAWXn4GGi/PrSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "camelcase-keys": "^2.0.0", + "decamelize": "^1.1.2", + "loud-rejection": "^1.0.0", + "map-obj": "^1.0.1", + "minimist": "^1.1.3", + "normalize-package-data": "^2.3.4", + "object-assign": "^4.0.1", + "read-pkg-up": "^1.0.1", + "redent": "^1.0.0", + "trim-newlines": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/meow/node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minimist": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.4.tgz", + "integrity": "sha512-Pkrrm8NjyQ8yVt8Am9M+yUt74zE3iokhzbG1bFVNjLB92vwM71hf40RkEsryg98BujhVOncKm/C1xROxZ030LQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha512-7ZxrUybYv9NonoXgwoOqtStIu18D1c3eFZj27hqgf5kBrBF8Q+tE8V0MW8dKM5QLkQPh1JhhbKgHLY9kifov4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "duplexer2": "0.0.2" + } + }, + "node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "error-ex": "^1.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/redent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", + "integrity": "sha512-qtW5hKzGQZqKoh6JNSD+4lfitfPKGz42e6QwiRmPM5mmKtR0N41AbJRYu0xJi7nhOJ4WDgRkKvAk6tw4WIwR4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^2.1.0", + "strip-indent": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-finite": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-2.3.2.tgz", + "integrity": "sha512-abLdIKCosKfpnmhS52NCTjO4RiLspDfsn37prjzGrp9im5DPJOgh82Os92vtwGh6XdQryKI/7SREZnV+aqiXrA==", + "dev": true, + "license": "BSD", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.22", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz", + "integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-ansi": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", + "integrity": "sha512-DerhZL7j6i6/nEnVG0qViKXI0OKouvvpsAiaj7c+LfqZZZxdwZtv8+UiA/w4VUJpT8UzX0pR1dcHOii1GbmruQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^0.2.1" + }, + "bin": { + "strip-ansi": "cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-utf8": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", + "integrity": "sha512-I5iQq6aFMM62fBEAIB/hXzwJD6EEZ0xEGCX2t7oXqaKPIRgt4WruAQ285BISgdkP+HLGWyeGmNJcpIwFeRYRUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-stdin": "^4.0.1" + }, + "bin": { + "strip-indent": "cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-color": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", + "integrity": "sha512-tdCZ28MnM7k7cJDJc7Eq80A9CsRFAAOZUy41npOZCs++qSjfIy7o5Rh46CBk+Dk5FbKJ33X3Tqg4YrV07N5RaA==", + "dev": true, + "license": "MIT", + "bin": { + "supports-color": "cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/through2": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", + "integrity": "sha512-zexCrAOTbjkBCXGyozn7hhS3aEaqdrc59mAD2E3dKYzV1vFuEGQ1hEDJN2oQMQFwy4he2zyLqPZV+AlfS8ZWJA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readable-stream": "~1.0.17", + "xtend": "~3.0.0" + } + }, + "node_modules/through2/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/trim-newlines": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", + "integrity": "sha512-Nm4cF79FhSTzrLKGDMi3I4utBtFv8qKy4sq1enftf2gMdpqI8oVQTAfySkTz5r49giVzDj88SVZXP4CeYQwjaw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/vinyl": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz", + "integrity": "sha512-4gFk9xrecazOTuFKcUYrE1TjHSYL63dio72D+q0d1mHF51FEcxTT2RHFpHbN5TNJgmPYHuVsBdhvXEOCDcytSA==", + "dev": true, + "dependencies": { + "clone-stats": "~0.0.1" + }, + "engines": { + "node": ">= 0.9" + } + }, + "node_modules/xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha512-sp/sT9OALMjRW1fKDlPeuSZlDQpkqReA0pyJukniWbTGoEKefHxhGJynE3PNhUMlcM8qWIjPwecwCw4LArS5Eg==", + "dev": true, + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/src/Devlord.Utilities/packages.config b/src/Devlord.Utilities/packages.config index 082ce43..bd4d7c8 100644 --- a/src/Devlord.Utilities/packages.config +++ b/src/Devlord.Utilities/packages.config @@ -3,6 +3,5 @@ - - + \ No newline at end of file diff --git a/src/Encryptamajig/AesEncryptamajig.cs b/src/Encryptamajig/AesEncryptamajig.cs deleted file mode 100644 index a2d806b..0000000 --- a/src/Encryptamajig/AesEncryptamajig.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace Encryptamajig -{ - using System; - using System.IO; - using System.Linq; - using System.Security.Cryptography; - - /// - /// A simple wrapper to the AesManaged class and the AES algorithm. - /// Requires a securely stored key which should be a random string of characters that an attacker could never guess. - /// Make sure to save the Key if you want to decrypt your data later! - /// If you're using this with a Web app, put the key in the web.config and encrypt the web.config. - /// - public static class AesEncryptamajig - { - private const int SaltSize = 32; - - /// - /// Encrypts the plainText input using the given Key. - /// A 256-bit random salt will be generated and prepended to the cipherText before it is base64 encoded. - /// - /// The plain text to encrypt. - /// The plain text encryption key. - /// The salt and the cipherText, Base64 encoded for convenience. - public static string Encrypt(string plainText, string key) - { - CheckInput(plainText, "plainText"); - CheckInput(key, "key"); - - // Derive a new Salt and IV from the Key - var bytes = DeriveBytes(key); - - // Return the encrypted keys from the memory stream, in Base64 form so we can send it right to a database (if we want). - var cipherTextBytes = EncryptStream(plainText, bytes); - var buffer = bytes.Salt; - Array.Resize(ref buffer, buffer.Length + cipherTextBytes.Length); - Array.Copy(cipherTextBytes, 0, buffer, SaltSize, cipherTextBytes.Length); - - return Convert.ToBase64String(buffer); - } - - /// - /// Decrypts the cipherText using the Key. - /// - /// The cipherText to decrypt. - /// The plain text encryption key. - /// The decrypted text. - public static string Decrypt(string cipherText, string key) - { - CheckInput(cipherText, "cipherText"); - CheckInput(key, "key"); - - // Extract the salt from our cipherText - var allTheBytes = Convert.FromBase64String(cipherText); - var saltBytes = allTheBytes.Take(SaltSize).ToArray(); - var ciphertextBytes = allTheBytes.Skip(SaltSize).Take(allTheBytes.Length - SaltSize).ToArray(); - - var bytes = DeriveBytes(key, saltBytes); - return DecryptStream(ciphertextBytes, bytes); - } - - private static bool CheckInput(string field, string fieldName) - { - if (string.IsNullOrEmpty(field)) - { - throw new ArgumentNullException(fieldName); - } - - return field.Trim().Length > 0; - } - - // Supress warnings due to .NET 3.5 compatibility - // ReSharper disable SuspiciousTypeConversion.Global - #pragma warning disable S1944 // Inappropriate casts should not be made - private static DeriveResult DeriveBytes(string key) - { - var deriver = new Rfc2898DeriveBytes(key, SaltSize); - var result = new DeriveResult - { - Salt = deriver.Salt, - Key = deriver.GetBytes(32), - InitializationVector = deriver.GetBytes(16) - }; - ((IDisposable)deriver).Dispose(); - return result; - } - - private static DeriveResult DeriveBytes(string key, byte[] saltBytes) - { - var deriver = new Rfc2898DeriveBytes(key, saltBytes); - - // Derive the previous IV from the Key and Salt - var result = new DeriveResult - { - Key = deriver.GetBytes(32), - InitializationVector = deriver.GetBytes(16) - }; - - ((IDisposable)deriver).Dispose(); - return result; - } - - private static byte[] EncryptStream(string clearText, DeriveResult bytes) - { - // Create an encryptor to perform the stream transform. - // Create the streams used for encryption. - using (var aesManaged = new AesManaged()) - using (var encryptor = aesManaged.CreateEncryptor(bytes.Key, bytes.InitializationVector)) - using (var memoryStream = new MemoryStream()) - { - using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) - using (var streamWriter = new StreamWriter(cryptoStream)) - { - // Send the data through the StreamWriter, through the CryptoStream, to the underlying MemoryStream - streamWriter.Write(clearText); - - // vv Have to dispose of the SW here in order to maintain the integrity of the memoryStream. - } - - // Return the encrypted keys from the memory stream, in Base64 form so we can send it right to a database (if we want). - var cipherTextBytes = memoryStream.ToArray(); - return cipherTextBytes; - } - } - - private static string DecryptStream(byte[] cipher, DeriveResult keys) - { - // Create a decrytor to perform the stream transform. - // Create the streams used for decryption. - // The default Cipher Mode is CBC and the Padding is PKCS7 which are both good - using (var aesManaged = new AesManaged()) - using (var decryptor = aesManaged.CreateDecryptor(keys.Key, keys.InitializationVector)) - using (var memoryStream = new MemoryStream(cipher)) - using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) - using (var streamReader = new StreamReader(cryptoStream)) - { - // Return the decrypted keys from the decrypting stream. - return streamReader.ReadToEnd(); - } - } - } -} diff --git a/src/Encryptamajig/AesManaged.cs b/src/Encryptamajig/AesManaged.cs deleted file mode 100644 index 9dfc24a..0000000 --- a/src/Encryptamajig/AesManaged.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Source: https://github.com/dotnet/corefx/commit/6d523750c4356af1d5c9e001c362baa833059833#diff-4d021d7c9e9a9ef5fdf2d896a928c0b6 - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.ComponentModel; -using System.Security.Cryptography; - -#if NETSTANDARD1_5 || NETSTANDARD1_3 -namespace Encryptamajig -{ - [EditorBrowsable(EditorBrowsableState.Never)] - public sealed class AesManaged : Aes - { - private readonly Aes _impl; - - public AesManaged() - { - // This class wraps Aes - _impl = Create(); - } - - public override int BlockSize - { - get => _impl.BlockSize; - set => _impl.BlockSize = value; - } - - public override byte[] IV - { - get => _impl.IV; - set => _impl.IV = value; - } - - public override byte[] Key - { - get => _impl.Key; - set => _impl.Key = value; - } - - public override int KeySize - { - get => _impl.KeySize; - set => _impl.KeySize = value; - } - - public override CipherMode Mode - { - get => _impl.Mode; - set => _impl.Mode = value; - } - - public override PaddingMode Padding - { - get => _impl.Padding; - set => _impl.Padding = value; - } - - public override KeySizes[] LegalBlockSizes => _impl.LegalBlockSizes; - public override KeySizes[] LegalKeySizes => _impl.LegalKeySizes; - - public override ICryptoTransform CreateEncryptor() - { - return _impl.CreateEncryptor(); - } - - public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV) - { - return _impl.CreateEncryptor(rgbKey, rgbIV); - } - - public override ICryptoTransform CreateDecryptor() - { - return _impl.CreateDecryptor(); - } - - public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV) - { - return _impl.CreateDecryptor(rgbKey, rgbIV); - } - - public override void GenerateIV() - { - _impl.GenerateIV(); - } - - public override void GenerateKey() - { - _impl.GenerateKey(); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - _impl.Dispose(); - } - - base.Dispose(disposing); - } - } -} - -#endif \ No newline at end of file diff --git a/src/Encryptamajig/DeriveResult.cs b/src/Encryptamajig/DeriveResult.cs deleted file mode 100644 index 973c24f..0000000 --- a/src/Encryptamajig/DeriveResult.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Encryptamajig -{ - /// - /// Holds the result of derivation functions, including salt and key/iv pair. - /// - internal struct DeriveResult - { - public byte[] Salt { get; set; } - - public byte[] Key { get; set; } - - public byte[] InitializationVector { get; set; } - } -} diff --git a/src/Encryptamajig/Encryptamajig.csproj b/src/Encryptamajig/Encryptamajig.csproj deleted file mode 100644 index 54a3401..0000000 --- a/src/Encryptamajig/Encryptamajig.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - netstandard2.1;net6.0 - false - false - false - false - false - false - false - LICENSE - 2.0 - Supports .NET Core netstandard 1.3 - https://github.com/jbubriski/Encryptamajig - John Bubriski - https://github.com/jbubriski/Encryptamajig - Git - Encryption - - - - - - - 1.0.0 - - - - - - - - - diff --git a/src/Encryptamajig/LICENSE b/src/Encryptamajig/LICENSE deleted file mode 100644 index ad64f7d..0000000 --- a/src/Encryptamajig/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 John Bubriski - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/src/Encryptamajig/Properties/AssemblyInfo.cs b/src/Encryptamajig/Properties/AssemblyInfo.cs deleted file mode 100644 index 64a3da8..0000000 --- a/src/Encryptamajig/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Encryptamajig")] -[assembly: AssemblyDescription("A simple wrapper to the .NET AES encryption algorithm functionality.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("John Bubriski")] -[assembly: AssemblyProduct("Encryptamajig")] -[assembly: AssemblyCopyright("Copyright © John Bubriski 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ad445e2e-0998-4131-9941-556d7a6fcca1")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Encryptamajig/README.md b/src/Encryptamajig/README.md deleted file mode 100644 index 42fd262..0000000 --- a/src/Encryptamajig/README.md +++ /dev/null @@ -1,54 +0,0 @@ -This software is derived from https://github.com/jbubriski/Encryptamajig. See the included LICENSE file for its own license, which is different from the license for Devlord.Utilities. - -The text below is jbubriski's. - ---------------- - -# Encryptamajig - -A simple wrapper to the .NET AES encryption algorithm functionality. - -**(Note: this is not a new encryption alogorithm, it's simply a wrapper that forces you to use AES as correctly.)** - -## But Why? - -> **"But John, there are so many encryption examples on the 'Net, why do we need another? Can't I just roll my own?"** - -When you look at encryption examples online many are verbose, misleading, outdated, or **flat out insecure**. By creating this project I hope to provide a single resource that myself and others can use to incoporate encryption into their .NET projects. - -My goal is to make sure this project uses an up-to-date encryption algorithm and forces appropriate usage of that algorithm. - -## Who Should Use This - -Anyone needing to encrypt data using a good algorithm that doesn't want to screw it up. - -## Issues We Avoid - - - Use of the ECB cipher mode. Simply put, ECB is unsecure. If you don't believe me, look at the images in this [Wikipedia article on the various cipher modes](http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation). - - Use of older or less secure algorithms. (Right now this is more of an assumption, I will try and cite specific algorithms to avoid and update this readme) - - Incorrect usage of encryption algorithms and block cipher modes. - - Guess work. Which algorithm do I use, how do I use it, what size should my key be, what size should my IV be, do I need a salt, etc. - - Use of the Rijndael algorithm. While Rijndael is a good algorithm, it's the **predecessor** to AES. So why not use AES? Read these articles if you more reasons or if you don't believe me: [The Differences Between Rijndael and AES](http://blogs.msdn.com/b/shawnfa/archive/2006/10/09/the-differences-between-rijndael-and-aes.aspx) and [the MSDN documentation for Rijndael](http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndael(v=vs.90).aspx). - - Ugly code. This code is tight. - -## Usage - -The AesEncryptamajig class provides 2 methods: 1 for encrypting and 1 for decrypting. You call both methods with your plain text key, and the data that you want to encrypt/decrypt. After encrypting data for the first time using this library, the salt will be prepended to the ciphertext. When you decrypt the data using this library, the salt is extracted, and the IV (Initialization Vector) is recreated. This way, you don't have to worry about storing the Salt/IV separately. - -Make sure you are storing your key someplace safe. If you're writing a web appication, you can store the Key in the Web.Config, **but make sure you encrypt the Web.Config**. - -## Encryption Resources - -Do you want to know more? (All links via Wikipedia) - -- [Encryption](http://en.wikipedia.org/wiki/Encryption) -- [Keys](http://en.wikipedia.org/wiki/Key_\(cryptography\)) -- [Initialization Vectors](http://en.wikipedia.org/wiki/Initialization_vector) -- [Block Cipher Modes](http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation) -- [AES](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard) - -## Disclaimer - -I am not a security expert but I think I got the big things right. **If you are an expert** and you see that I'm doing something wrong, [please tell me](https://github.com/jbubriski)! I will take the time to look at your pull requests if you send one! - -"You don't know what you don't know", or more like "I don't know what I don't know". diff --git a/test/Devlord.Utilities.Tests/CryptKeyTests.cs b/test/Devlord.Utilities.Tests/CryptKeyTests.cs deleted file mode 100644 index 705628b..0000000 --- a/test/Devlord.Utilities.Tests/CryptKeyTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Text; -using Devlord.Utilities.Cryptography; -using Xunit; -using Xunit.Abstractions; - -namespace Devlord.Utilities.Tests -{ - public class CryptKeyTests - { - public CryptKeyTests(ITestOutputHelper output) - { - _output = output; - } - - private readonly ITestOutputHelper _output; - - [Fact(Skip = "This is meant for outputting arrays that we can copy to code. Run it manually.")] - public void MakeNewKeyAsString() - { - var key = Crypt.MakeKey(); - var builder = new StringBuilder("var newKey = new byte[]"); - builder.AppendLine("{"); - - var lastIndex = key.Length - 1; - - for (var i = 0; i < key.Length; i++) - { - builder.Append(" " + key[i]); - if (i != lastIndex) - { - builder.Append(','); - } - - builder.AppendLine(); - } - - builder.AppendLine("};"); - - _output.WriteLine(builder.ToString()); - } - - [Fact] - public void VerifyBCryptSimple() - { - // Arrange - const string clearText = "P@s5W1rdBruh"; - var encryptor = new Crypt(); - var ciphered = encryptor.OneWay(clearText); - - // first: "$2a$10$3btSI0hlWbdg5.xdb/x0suZGjxwiFsw7omOFvlLnoduPH3BB5Af6W" - - // Act - var result = encryptor.Verify(Crypt.SafeUtf8.GetBytes(clearText), - "$2a$10$3btSI0hlWbdg5.xdb/x0suZGjxwiFsw7omOFvlLnoduPH3BB5Af6W"); - - // Assert - Assert.True(result); - - result = encryptor.Verify(new byte[] - { - 80, - 64, - 115, - 53, - 87, - 49, - 114, - 100, - 66, - 114, - 117, - 104 - }, "$2a$10$L048plNTmEuy4znjJe5K8uS0y9EPWp0vNvicaLYcqlmaT/bJawGJy" - - ); - - result.ShouldBeTrue(); - - result = encryptor.Verify(Crypt.SafeUtf8.GetBytes("fakePass"), - "$2a$10$/.Ca2J2etjIfXPUCWAKB5.ldzqDw00A7MYuggwFCwzkX3GPZ5Ptfu"); - - Assert.False(result); - } - } -} \ No newline at end of file diff --git a/test/Devlord.Utilities.Tests/Devlord.Utilities.Tests.csproj b/test/Devlord.Utilities.Tests/Devlord.Utilities.Tests.csproj index 84b371b..7422ad5 100644 --- a/test/Devlord.Utilities.Tests/Devlord.Utilities.Tests.csproj +++ b/test/Devlord.Utilities.Tests/Devlord.Utilities.Tests.csproj @@ -1,6 +1,6 @@ - + - netstandard2.1;net6.0 + net10.0 10 false false @@ -16,25 +16,22 @@ 22b9d517-6954-4beb-b7be-ba24eb9ac441 - - - - - + + + + + - - + + - - all runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -43,6 +40,8 @@ + + diff --git a/test/Devlord.Utilities.Tests/DevlordTestConfiguration.cs b/test/Devlord.Utilities.Tests/DevlordTestConfiguration.cs index 5d36fe8..2b590da 100644 --- a/test/Devlord.Utilities.Tests/DevlordTestConfiguration.cs +++ b/test/Devlord.Utilities.Tests/DevlordTestConfiguration.cs @@ -9,6 +9,7 @@ // Aaron Lord // -------------------------------------------------------------------------------------------------------------------- +using Devlord.Utilities.Mail; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; @@ -27,7 +28,8 @@ public DevlordTestConfiguration() .AddUserSecrets() .Build(); var services = new ServiceCollection().AddOptions(); - services.AddDevlordUtilities(config.GetSection("Devlord.Utilities")); + services.AddDevlordMail(config.GetSection("Devlord.Utilities")); + services.AddDevlordMaps(config.GetSection("Devlord.Utilities")); Options = services.BuildServiceProvider().GetService>().Value; //return config; } diff --git a/test/Devlord.Utilities.Tests/DistanceApiTests.cs b/test/Devlord.Utilities.Tests/DistanceApiTests.cs index 64a8040..02200bc 100644 --- a/test/Devlord.Utilities.Tests/DistanceApiTests.cs +++ b/test/Devlord.Utilities.Tests/DistanceApiTests.cs @@ -1,9 +1,9 @@ using System.Linq; using System.Net; using System.Net.Http; +using System.Text.Json; using System.Text.RegularExpressions; using Devlord.Utilities.MapsApi; -using Newtonsoft.Json; using Xunit; namespace Devlord.Utilities.Tests @@ -26,7 +26,7 @@ private static double ParseDuration(string distanceString) return double.Parse(resultDuration); } - [Fact] + [Fact(Skip = "Needs to be run with user secrets")] public void ReturnsDeserializedResults() { var endPoint = @@ -45,9 +45,9 @@ public void ReturnsDeserializedResults() var content = response.Content.ReadAsStringAsync().Result; - var settings = new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() }; + var settings = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }; - var parsedObject = JsonConvert.DeserializeObject(content, settings); + var parsedObject = JsonSerializer.Deserialize(content, settings); Assert.Equal(typeof(DistanceElement), parsedObject.Rows.ElementAt(0).Elements.ElementAt(0).GetType()); @@ -57,7 +57,7 @@ public void ReturnsDeserializedResults() } } - [Fact] + [Fact(Skip = "Needs to be run with user secrets")] public void ReturnsExpectedResultWithCustomApi() { string endPoint = @@ -65,7 +65,11 @@ public void ReturnsExpectedResultWithCustomApi() + _options.GoogleMapsApiKey; using (IApiCall client = new ApiCall(endPoint, - new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() })) + new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + WriteIndented = true, + })) { var result = client.Execute(); Assert.Equal(HttpStatusCode.OK, result.StatusCode); @@ -131,7 +135,7 @@ public void ReturnsJsonResults() } } - [Fact] + [Fact(Skip = "Needs to be run with user secrets")] public void ReturnsResultWithCustomApiAndQueryParams() { string baseUri = "https://maps.googleapis.com/maps/api/distancematrix/json?key=" @@ -139,7 +143,11 @@ public void ReturnsResultWithCustomApiAndQueryParams() // sensor=false&origins=95969&destinations=95928 using (IApiCall client = new ApiCall(baseUri, - new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() })) + new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + WriteIndented = true, + })) { client.QueryParams.Add("sensor", "false"); client.QueryParams.Add("origins", "95969"); diff --git a/test/Devlord.Utilities.Tests/JsonDeserializerTests.cs b/test/Devlord.Utilities.Tests/JsonDeserializerTests.cs index 71e0ee0..aaf6074 100644 --- a/test/Devlord.Utilities.Tests/JsonDeserializerTests.cs +++ b/test/Devlord.Utilities.Tests/JsonDeserializerTests.cs @@ -1,8 +1,8 @@ using System.Linq; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Text.RegularExpressions; using Devlord.Utilities.MapsApi; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Xunit; namespace Devlord.Utilities.Tests @@ -12,10 +12,14 @@ public class JsonDeserializerTests [Fact] public void TestCustomResolver() { - var settings = new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() }; + var settings = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + WriteIndented = true, + }; var bob = new { PropertyName = "asdf" }; - var json = JsonConvert.SerializeObject(bob, Formatting.Indented, settings); + var json = JsonSerializer.Serialize(bob, settings); // For macOS, Linux compatibility json = json.Replace("\r\n", "\n"); @@ -23,7 +27,7 @@ public void TestCustomResolver() } [Fact] - public void TestDeserializeDynamic() + public void TestDeserializeStronglyTyped() { var input = @"{ ""destination_addresses"" : [ ""Chico, CA 95928, USA"" ], @@ -49,43 +53,13 @@ public void TestDeserializeDynamic() } ".Replace("\r\n", "\n"); - var settings = new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() }; - - dynamic parsedObject = JsonConvert.DeserializeObject(input, settings); - - Assert.Equal(typeof(JObject), parsedObject.rows[0].elements[0].GetType()); - } - - [Fact] - public void TestDeserializeStrongTyped() - { - var input = @"{ - ""destination_addresses"" : [ ""Chico, CA 95928, USA"" ], - ""origin_addresses"" : [ ""Paradise, CA 95969, USA"" ], - ""rows"" : [ - { - ""elements"" : [ + var settings = new JsonSerializerOptions { - ""distance"" : { - ""text"" : ""27.7 km"", - ""value"" : 27722 - }, - ""duration"" : { - ""text"" : ""25 mins"", - ""value"" : 1518 - }, - ""status"" : ""OK"" - } - ] - } - ], - ""status"" : ""OK"" -} -".Replace("\r\n", "\n"); - - var settings = new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() }; + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + WriteIndented = true, + }; - var parsedObject = JsonConvert.DeserializeObject(input, settings); + var parsedObject = JsonSerializer.Deserialize(input, settings); Assert.Equal(typeof(DistanceElement), parsedObject.Rows.ElementAt(0).Elements.ElementAt(0).GetType()); diff --git a/test/Devlord.Utilities.Tests/MailTests.cs b/test/Devlord.Utilities.Tests/MailTests.cs index db9bb88..2a9d55b 100644 --- a/test/Devlord.Utilities.Tests/MailTests.cs +++ b/test/Devlord.Utilities.Tests/MailTests.cs @@ -1,10 +1,8 @@ using System; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using Devlord.Utilities.Cryptography; using Devlord.Utilities.Exceptions; -using Microsoft.Extensions.Options; +using Devlord.Utilities.Mail; using Xunit; namespace Devlord.Utilities.Tests @@ -17,28 +15,7 @@ public MailTests(DevlordTestConfiguration fixture) { _fixture = fixture; } - - [Fact] - public void EncryptPassword() - { - Debug.WriteLine("asdf"); - - var crypt = new Crypt - { - Key = - new byte[] - { - 80, 20, 245, 0, 124, 61, 192, 137, 232, 79, 249, 228, 1, 246, 187, 3, 228, - 215, 250, 11, 131, 33, 180, 143, 41, 217, 4, 16, 219, 34, 50, 115, 96, 140, - 146, 24, 5, 69, 58, 183, 66, 88, 58, 44, 213, 81, 26, 187, 247, 101, 163, - 248, 103, 3, 179, 60, 14, 152, 90, 230, 92, 69, 100, 246, 32, 27, 201, 123, - 99, 229, 66, 118, 185, 241, 136, 38, 174, 104, 203, 207, 4, 175, 223, 104, - 140, 234, 20, 228, 209, 175, 94, 212, 105, 165, 47, 61, 100, 219, 18, 224 - } - }; - Debug.WriteLine(crypt.HideSecretPassword("AuOsVkTXzzrcq58RZ+AsOBzL5KwkztAyXB5ZQOIfOY7E")); - } - + [Fact(Skip = "Dude, don't be sending emails from unit tests!")] public async Task TestMailbot() { @@ -68,7 +45,7 @@ public async Task TestMailbot() SmtpPort = thisOptions.SmtpPort, SmtpLogin = thisOptions.SmtpLogin, SmtpServer = thisOptions.SmtpServer, - EncryptedPassword = thisOptions.SmtpPassword + SmtpPassword = thisOptions.SmtpPassword }.QueueMail(botMail); } catch (Exception e) diff --git a/test/Devlord.Utilities.Tests/Services/ContinuousLoopTests.cs b/test/Devlord.Utilities.Tests/Services/ContinuousLoopTests.cs index 873c7ad..42c7c2c 100644 --- a/test/Devlord.Utilities.Tests/Services/ContinuousLoopTests.cs +++ b/test/Devlord.Utilities.Tests/Services/ContinuousLoopTests.cs @@ -32,7 +32,7 @@ public ContinuousLoopTests(ITestOutputHelper output) [Fact] public void TestContinuousLoop() { - Console.WriteLine(@"Test app start logging."); + _output.WriteLine("Test app start logging."); var success = false; ServiceTimer timedMultiple = new ContinuousLoop(); timedMultiple.AddEvent(LoopedElapsed) diff --git a/test/Devlord.Utilities.Tests/TestLogger.cs b/test/Devlord.Utilities.Tests/TestLogger.cs deleted file mode 100644 index 5200000..0000000 --- a/test/Devlord.Utilities.Tests/TestLogger.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Extensions.Logging; -using Xunit; -#if NETCOREAPP1_1 -using LogType = Microsoft.Extensions.Logging.LogLevel; - -#elif NET462 -using LogType = System.Diagnostics.EventLogEntryType; -#endif - -namespace Devlord.Utilities.Tests -{ - public class TestLogger : IDevLogger - { - public void Log(Exception exception) - { - Console.WriteLine(exception); - Errors.Add(exception); - throw new Exception("Logged exception found in tested code. Rethrowing...", exception); - } - - public void WriteEntry(string message, LogLevel error, LogCode errorCode = LogCode.None) - { - throw new NotImplementedException(); - } - - private static readonly List Errors = new List(); - - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, - Func formatter) - { - throw new NotImplementedException(); - } - - public bool IsEnabled(LogLevel logLevel) - { - throw new NotImplementedException(); - } - - public IDisposable BeginScope(TState state) - { - throw new NotImplementedException(); - } - - [Fact] - public void VerifyNoErrors() - { - Assert.Empty(Errors); - } - } -} \ No newline at end of file diff --git a/test/Devlord.Utilities.Tests/packages.config b/test/Devlord.Utilities.Tests/packages.config index 3358f43..3a0face 100644 --- a/test/Devlord.Utilities.Tests/packages.config +++ b/test/Devlord.Utilities.Tests/packages.config @@ -5,7 +5,6 @@ - \ No newline at end of file diff --git a/test/Encryptamajig.Tests/Encryptamajig.Tests.csproj b/test/Encryptamajig.Tests/Encryptamajig.Tests.csproj deleted file mode 100644 index 7fe74b8..0000000 --- a/test/Encryptamajig.Tests/Encryptamajig.Tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - netstandard2.1;net6.0 - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Encryptamajig.Tests/EncryptamajigTests.cs b/test/Encryptamajig.Tests/EncryptamajigTests.cs deleted file mode 100644 index 2d4b490..0000000 --- a/test/Encryptamajig.Tests/EncryptamajigTests.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Diagnostics; -using System.Security.Cryptography; -using Xunit; - -namespace Encryptamajig.Tests -{ - public class EncryptamajigTests - { - // A test credit card number - private static readonly string _plainText = "4111111111111111"; - - // The key should be a random string of characters that an attacker could never guess - private static readonly string _key = "Something you can't guess"; - - [Fact] - public void AesManaged_EncryptionRoundtripWithCustomInputs_ReturnsOriginalText() - { - // Arrange - // Act - var encrypted = AesEncryptamajig.Encrypt(_plainText, _key); - var roundtrip = AesEncryptamajig.Decrypt(encrypted, _key); - - Debug.WriteLine(_plainText); - Debug.WriteLine(encrypted); - Debug.WriteLine(roundtrip); - - // Assert - Assert.NotEqual(_plainText, encrypted); - Assert.Equal(_plainText, roundtrip); - } - - [Fact] - public void AesManaged_EncryptionRoundtripWithRandomKey_ReturnsOriginalText() - { - // Arrange - var aesManaged = new AesManaged(); - - var key = Convert.ToBase64String(aesManaged.Key); - - // Act - var encrypted = AesEncryptamajig.Encrypt(_plainText, key); - var roundtrip = AesEncryptamajig.Decrypt(encrypted, key); - - Debug.WriteLine(_plainText); - Debug.WriteLine(encrypted); - Debug.WriteLine(roundtrip); - - // Assert - Assert.NotEqual(_plainText, encrypted); - Assert.Equal(_plainText, roundtrip); - } - - [Fact] - public void AesManaged_ReencryptionWithSameKey_ReturnsSameText() - { - // Arrange - var aesManaged = new AesManaged(); - - var key = Convert.ToBase64String(aesManaged.Key); - - // Act - var encrypted1 = AesEncryptamajig.Encrypt(_plainText, key); - var roundtrip1 = AesEncryptamajig.Decrypt(encrypted1, key); - - Debug.WriteLine("Plain Text: " + _plainText); - Debug.WriteLine("Encrypted: " + encrypted1); - Debug.WriteLine("Roundtrip: " + roundtrip1); - - // Act 2 (encrypt the same data again) - var encrypted2 = AesEncryptamajig.Encrypt(_plainText, key); - var roundtrip2 = AesEncryptamajig.Decrypt(encrypted2, key); - - - Debug.WriteLine("Encrypted again: " + encrypted2); - Debug.WriteLine("Roundtrip again: " + roundtrip2); - - // Assert - Assert.NotEqual(_plainText, encrypted1); - Assert.NotEqual(_plainText, encrypted2); - - Assert.Equal(_plainText, roundtrip1); - Assert.Equal(_plainText, roundtrip2); - - Assert.NotEqual(encrypted1, encrypted2); - } - - [Fact] - public void Decrypt_WithDifferentKey_ThrowsException() - { - // Arrange - var aesManaged = new AesManaged(); - - var originalKey = Convert.ToBase64String(aesManaged.Key); - - // This should generate a new key - aesManaged = new AesManaged(); - var newKey = Convert.ToBase64String(aesManaged.Key); - - // Act - var encrypted = AesEncryptamajig.Encrypt(_plainText, originalKey); - - Debug.WriteLine("Org Key = " + originalKey); - Debug.WriteLine("New Key = " + newKey); - - // Assert - Assert.Throws(() => - { - var roundtrip = AesEncryptamajig.Decrypt(encrypted, newKey); - }); - } - } -} \ No newline at end of file diff --git a/test/Encryptamajig.Tests/Properties/AssemblyInfo.cs b/test/Encryptamajig.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 10c87c5..0000000 --- a/test/Encryptamajig.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Encryptamajig.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Encryptamajig.Tests")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("186270a9-32ff-412b-b654-a9a599d81620")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/Encryptamajig.Tests/corefx/AesManagedTests.cs b/test/Encryptamajig.Tests/corefx/AesManagedTests.cs deleted file mode 100644 index ccd0cc3..0000000 --- a/test/Encryptamajig.Tests/corefx/AesManagedTests.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Source: https://github.com/dotnet/corefx/commit/6d523750c4356af1d5c9e001c362baa833059833#diff-4d021d7c9e9a9ef5fdf2d896a928c0b6 - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Text; -using Test.Cryptography; -using Xunit; -using System.Security.Cryptography; - -namespace Encryptamajig.Tests -{ - /// - /// Since AesManaged wraps Aes, we only test minimally here. - /// - public class AesManagedTests - { - [Fact] - public static void VerifyDefaults() - { - using (var alg = new AesManaged()) - { - Assert.Equal(128, alg.BlockSize); - Assert.Equal(256, alg.KeySize); - Assert.Equal(CipherMode.CBC, alg.Mode); - Assert.Equal(PaddingMode.PKCS7, alg.Padding); - } - } - - [Fact] - public static void EncryptDecryptKnownECB192() - { - byte[] plainTextBytes = - new ASCIIEncoding().GetBytes("This is a sentence that is longer than a block, it ensures that multi-block functions work."); - - byte[] encryptedBytesExpected = new byte[] - { - 0xC9, 0x7F, 0xA5, 0x5B, 0xC3, 0x92, 0xDC, 0xA6, - 0xE4, 0x9F, 0x2D, 0x1A, 0xEF, 0x7A, 0x27, 0x03, - 0x04, 0x9C, 0xFB, 0x56, 0x63, 0x38, 0xAE, 0x4F, - 0xDC, 0xF6, 0x36, 0x98, 0x28, 0x05, 0x32, 0xE9, - 0xF2, 0x6E, 0xEC, 0x0C, 0x04, 0x9D, 0x12, 0x17, - 0x18, 0x35, 0xD4, 0x29, 0xFC, 0x01, 0xB1, 0x20, - 0xFA, 0x30, 0xAE, 0x00, 0x53, 0xD4, 0x26, 0x25, - 0xA4, 0xFD, 0xD5, 0xE6, 0xED, 0x79, 0x35, 0x2A, - 0xE2, 0xBB, 0x95, 0x0D, 0xEF, 0x09, 0xBB, 0x6D, - 0xC5, 0xC4, 0xDB, 0x28, 0xC6, 0xF4, 0x31, 0x33, - 0x9A, 0x90, 0x12, 0x36, 0x50, 0xA0, 0xB7, 0xD1, - 0x35, 0xC4, 0xCE, 0x81, 0xE5, 0x2B, 0x85, 0x6B, - }; - - byte[] aes192Key = new byte[] - { - 0xA6, 0x1E, 0xC7, 0x54, 0x37, 0x4D, 0x8C, 0xA5, - 0xA4, 0xBB, 0x99, 0x50, 0x35, 0x4B, 0x30, 0x4D, - 0x6C, 0xFE, 0x3B, 0x59, 0x65, 0xCB, 0x93, 0xE3, - }; - - using (var alg = new AesManaged()) - { - // The CipherMode and KeySize are different than the default values; this ensures the type - // forwards the state properly to Aes. - alg.Mode = CipherMode.ECB; - alg.Key = aes192Key; - - byte[] encryptedBytes = alg.Encrypt(plainTextBytes); - Assert.Equal(encryptedBytesExpected, encryptedBytes); - - byte[] decryptedBytes = alg.Decrypt(encryptedBytes); - Assert.Equal(plainTextBytes, decryptedBytes); - } - } - - [Fact] - public static void TestShims() - { - using (var alg = new AesManaged()) - { - alg.BlockSize = 128; - Assert.Equal(128, alg.BlockSize); - - var emptyIV = new byte[alg.BlockSize / 8]; - alg.IV = emptyIV; - Assert.Equal(emptyIV, alg.IV); - alg.GenerateIV(); - Assert.NotEqual(emptyIV, alg.IV); - - var emptyKey = new byte[alg.KeySize / 8]; - alg.Key = emptyKey; - Assert.Equal(emptyKey, alg.Key); - alg.GenerateKey(); - Assert.NotEqual(emptyKey, alg.Key); - - alg.KeySize = 128; - Assert.Equal(128, alg.KeySize); - - alg.Mode = CipherMode.ECB; - Assert.Equal(CipherMode.ECB, alg.Mode); - - alg.Padding = PaddingMode.PKCS7; - Assert.Equal(PaddingMode.PKCS7, alg.Padding); - } - } - - [Fact] - public void AesManaged_NewInstances_ReturnsNewKeyAndIv() - { - // Arrange - // Act - var aesManaged = new AesManaged(); - var aesManaged2 = new AesManaged(); - - Debug.WriteLine(Convert.ToBase64String(aesManaged.Key)); - Debug.WriteLine(Convert.ToBase64String(aesManaged2.Key)); - - Debug.WriteLine(Convert.ToBase64String(aesManaged.IV)); - Debug.WriteLine(Convert.ToBase64String(aesManaged2.IV)); - - // Assert - Assert.NotEqual(aesManaged.Key, aesManaged2.Key); - Assert.NotEqual(aesManaged.IV, aesManaged2.IV); - } - } -} diff --git a/test/Encryptamajig.Tests/corefx/CryptoUtils.cs b/test/Encryptamajig.Tests/corefx/CryptoUtils.cs deleted file mode 100644 index 8cb7e38..0000000 --- a/test/Encryptamajig.Tests/corefx/CryptoUtils.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Security.Cryptography; -// ReSharper disable CheckNamespace - -namespace Test.Cryptography -{ - internal static class CryptoUtils - { - internal static byte[] Encrypt(this SymmetricAlgorithm alg, byte[] plainText, int blockSizeMultipler = 1) - { - using (ICryptoTransform encryptor = alg.CreateEncryptor()) - { - return encryptor.Transform(plainText, blockSizeMultipler); - } - } - - internal static byte[] Decrypt(this SymmetricAlgorithm alg, byte[] cipher, int blockSizeMultipler = 1) - { - using (ICryptoTransform decryptor = alg.CreateDecryptor()) - { - return decryptor.Transform(cipher, blockSizeMultipler); - } - } - - internal static byte[] Transform(this ICryptoTransform transform, byte[] input, int blockSizeMultipler = 1) - { - List output = new List(input.Length); - int blockSize = transform.InputBlockSize * blockSizeMultipler; - for (int i = 0; i <= input.Length; i += blockSize) - { - int count = Math.Min(blockSize, input.Length - i); - if (count >= blockSize) - { - byte[] buffer = new byte[blockSize]; - int numBytesWritten = transform.TransformBlock(input, i, count, buffer, 0); - Array.Resize(ref buffer, numBytesWritten); - output.AddRange(buffer); - } - else - { - byte[] finalBlock = transform.TransformFinalBlock(input, i, count); - output.AddRange(finalBlock); - break; - } - } - - return output.ToArray(); - } - } -} \ No newline at end of file diff --git a/test/Encryptamajig.Tests/packages.config b/test/Encryptamajig.Tests/packages.config deleted file mode 100644 index 0c82178..0000000 --- a/test/Encryptamajig.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file