Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Code style refactor
Leendert de Borst1904cc3122af
diff --git a/.editorconfig b/.editorconfigindex 0d90013eb..3bc03fa1f 100644--- a/.editorconfig+++ b/.editorconfig@@ -12,6 +12,23 @@ insert_final_newline = true[*.cs]indent_style = spaceindent_size = 4+csharp_indent_labels = one_less_than_current+csharp_using_directive_placement = outside_namespace:silent+csharp_prefer_simple_using_statement = true:suggestion+csharp_prefer_braces = true:silent+csharp_style_namespace_declarations = block_scoped:silent+csharp_style_prefer_method_group_conversion = true:silent+csharp_style_prefer_top_level_statements = true:silent+csharp_style_prefer_primary_constructors = true:suggestion+csharp_style_expression_bodied_methods = false:silent+csharp_style_expression_bodied_constructors = false:silent+csharp_style_expression_bodied_operators = false:silent+csharp_style_expression_bodied_properties = true:silent+csharp_style_expression_bodied_indexers = true:silent+csharp_style_expression_bodied_accessors = true:silent+csharp_style_expression_bodied_lambdas = true:silent+csharp_style_expression_bodied_local_functions = false:silent+dotnet_diagnostic.SA1011.severity = none# Razor files[*.razor]@@ -47,3 +64,54 @@ indent_size = 4[*.xml]indent_style = spaceindent_size = 4++[*.{cs,vb}]+#### Naming styles ####++# Naming rules++dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i++dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion+dotnet_naming_rule.types_should_be_pascal_case.symbols = types+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case++dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case++# Symbol specifications++dotnet_naming_symbols.interface.applicable_kinds = interface+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected+dotnet_naming_symbols.interface.required_modifiers =++dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected+dotnet_naming_symbols.types.required_modifiers =++dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected+dotnet_naming_symbols.non_field_members.required_modifiers =++# Naming styles++dotnet_naming_style.begins_with_i.required_prefix = I+dotnet_naming_style.begins_with_i.required_suffix =+dotnet_naming_style.begins_with_i.word_separator =+dotnet_naming_style.begins_with_i.capitalization = pascal_case++dotnet_naming_style.pascal_case.required_prefix =+dotnet_naming_style.pascal_case.required_suffix =+dotnet_naming_style.pascal_case.word_separator =+dotnet_naming_style.pascal_case.capitalization = pascal_case++dotnet_naming_style.pascal_case.required_prefix =+dotnet_naming_style.pascal_case.required_suffix =+dotnet_naming_style.pascal_case.word_separator =+dotnet_naming_style.pascal_case.capitalization = pascal_case+dotnet_style_operator_placement_when_wrapping = beginning_of_line+tab_width = 4+end_of_line = crlfdiff --git a/.gitignore b/.gitignoreindex 6f9cb9c9e..147b5ae38 100644--- a/.gitignore+++ b/.gitignore@@ -369,3 +369,4 @@ MigrationBackup/FodyWeavers.xsd.idea+*.licenseheaderdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex f31545d31..109800c36 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -6,6 +6,18 @@ Note: all instructions below are based on MacOS. If you are using a different op## Getting StartedIn order to contribute to this project, you will need to have the following tools installed on your machine:+- Make sure to install the latest version of .NET SDK 8:++```bash+# Install .NET SDK 8++# On MacOS via brew:+brew install --cask dotnet-sdk++# On Windows via winget+winget install Microsoft.DotNet.SDK.8+```+- Dotnet CLI EF Tools```bashdiff --git a/aliasvault.sln b/aliasvault.slnindex e8177947d..c3f388fd9 100644--- a/aliasvault.sln+++ b/aliasvault.sln@@ -1,28 +1,31 @@Microsoft Visual Studio Solution File, Format Version 12.00-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault", "src\AliasVault\AliasVault.csproj", "{BD2050C0-DC26-4777-9514-546525307370}"+# Visual Studio Version 17+VisualStudioVersion = 17.10.34928.147+MinimumVisualStudioVersion = 10.0.40219.1+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault", "src\AliasVault\AliasVault.csproj", "{BD2050C0-DC26-4777-9514-546525307370}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasDb", "src\AliasDb\AliasDb.csproj", "{64F47C9A-FE69-4793-B469-28BAADEC6706}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasDb", "src\AliasDb\AliasDb.csproj", "{64F47C9A-FE69-4793-B469-28BAADEC6706}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasGenerators", "src\AliasGenerators\AliasGenerators.csproj", "{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasGenerators", "src\AliasGenerators\AliasGenerators.csproj", "{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}"EndProjectProject("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaviconExtractor", "src\Utilities\FaviconExtractor\FaviconExtractor.csproj", "{ED328644-A152-403D-86EB-81201AA07744}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaviconExtractor", "src\Utilities\FaviconExtractor\FaviconExtractor.csproj", "{ED328644-A152-403D-86EB-81201AA07744}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.UnitTests", "src\Tests\AliasVault.UnitTests\AliasVault.UnitTests.csproj", "{8E6A418A-B305-465D-857D-49953605C18E}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.UnitTests", "src\Tests\AliasVault.UnitTests\AliasVault.UnitTests.csproj", "{8E6A418A-B305-465D-857D-49953605C18E}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cryptography", "src\Utilities\Cryptography\Cryptography.csproj", "{427EA8E2-EA76-467E-A6BC-201EFE40C0D0}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cryptography", "src\Utilities\Cryptography\Cryptography.csproj", "{427EA8E2-EA76-467E-A6BC-201EFE40C0D0}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.Api", "src\AliasVault.Api\AliasVault.Api.csproj", "{B797C533-260E-4DA2-83B1-0EE4BCFE08DB}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.Api", "src\AliasVault.Api\AliasVault.Api.csproj", "{B797C533-260E-4DA2-83B1-0EE4BCFE08DB}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.WebApp", "src\AliasVault.WebApp\AliasVault.WebApp.csproj", "{25248E01-5A4B-4F95-A63C-BEA01499A1C2}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.WebApp", "src\AliasVault.WebApp\AliasVault.WebApp.csproj", "{25248E01-5A4B-4F95-A63C-BEA01499A1C2}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.Shared", "src\AliasVault.Shared\AliasVault.Shared.csproj", "{15EFE0D0-F41B-47D7-86B7-8F840335CB82}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.Shared", "src\AliasVault.Shared\AliasVault.Shared.csproj", "{15EFE0D0-F41B-47D7-86B7-8F840335CB82}"EndProjectProject("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{29DE523D-EEF2-41E9-AC12-F20D8D02BEBB}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.E2ETests", "src\Tests\AliasVault.E2ETests\AliasVault.E2ETests.csproj", "{AF013D08-1BF6-4E23-87D2-37F614BE7952}"+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AliasVault.E2ETests", "src\Tests\AliasVault.E2ETests\AliasVault.E2ETests.csproj", "{AF013D08-1BF6-4E23-87D2-37F614BE7952}"EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolution@@ -71,10 +74,13 @@ Global{AF013D08-1BF6-4E23-87D2-37F614BE7952}.Release|Any CPU.ActiveCfg = Release|Any CPU{AF013D08-1BF6-4E23-87D2-37F614BE7952}.Release|Any CPU.Build.0 = Release|Any CPUEndGlobalSection+ GlobalSection(SolutionProperties) = preSolution+ HideSolutionNode = FALSE+ EndGlobalSectionGlobalSection(NestedProjects) = preSolution{ED328644-A152-403D-86EB-81201AA07744} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}- {427EA8E2-EA76-467E-A6BC-201EFE40C0D0} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}{8E6A418A-B305-465D-857D-49953605C18E} = {29DE523D-EEF2-41E9-AC12-F20D8D02BEBB}+ {427EA8E2-EA76-467E-A6BC-201EFE40C0D0} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}{AF013D08-1BF6-4E23-87D2-37F614BE7952} = {29DE523D-EEF2-41E9-AC12-F20D8D02BEBB}EndGlobalSectionEndGlobaldiff --git a/src/AliasDb/AliasDb.csproj b/src/AliasDb/AliasDb.csprojindex 7237aabb2..7d1eeb45b 100644--- a/src/AliasDb/AliasDb.csproj+++ b/src/AliasDb/AliasDb.csproj@@ -4,22 +4,23 @@<TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable>+ <GenerateDocumentationFile>True</GenerateDocumentationFile></PropertyGroup><ItemGroup>- <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.5" />- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5">+ <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6" />+ <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference>- <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.5" />- <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />- <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />+ <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.6" />+ <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />+ <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /><PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference>@@ -29,6 +30,7 @@<Content Include="..\..\LICENSE.md"><Link>LICENSE.md</Link></Content>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" /></ItemGroup></Project>diff --git a/src/AliasDb/AliasDbContext.cs b/src/AliasDb/AliasDbContext.csindex 086a3e2bc..3051e890e 100644--- a/src/AliasDb/AliasDbContext.cs+++ b/src/AliasDb/AliasDbContext.cs@@ -1,7 +1,12 @@-namespace AliasDb;+//-----------------------------------------------------------------------+// <copyright file="AliasDbContext.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasDb;using Microsoft.EntityFrameworkCore;-using Microsoft.Extensions.Configuration;using Microsoft.AspNetCore.Identity.EntityFrameworkCore;/// <summary>@@ -48,29 +53,7 @@ public class AliasDbContext : IdentityDbContext/// <summary>/// Gets or sets the AspNetUserRefreshTokens DbSet./// </summary>- public DbSet<AspNetUserRefreshTokens> AspNetUserRefreshTokens { get; set; }-- /// <summary>- /// Sets up the connection string if it is not already configured.- /// </summary>- /// <param name="optionsBuilder">DbContextOptionsBuilder instance.</param>- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)- {- // If the options are not already configured, use the appsettings.json file.- // Tip: the E2E tests will provide a different connection string directly- // which will override this default config.- /*if (!optionsBuilder.IsConfigured)- {- var configuration = new ConfigurationBuilder()- .SetBasePath(Directory.GetCurrentDirectory())- .AddJsonFile("appsettings.json")- .Build();-- optionsBuilder- .UseSqlite(configuration.GetConnectionString("AliasDbContext"))- .UseLazyLoadingProxies();- } */- }+ public DbSet<AspNetUserRefreshToken> AspNetUserRefreshTokens { get; set; }/// <summary>/// The OnModelCreating method.@@ -128,8 +111,8 @@ public class AliasDbContext : IdentityDbContext.HasForeignKey(i => i.DefaultPasswordId).OnDelete(DeleteBehavior.SetNull);- // Configure the Login - UserId entity- modelBuilder.Entity<AspNetUserRefreshTokens>()+ // Configure the User - AspNetUserRefreshToken entity+ modelBuilder.Entity<AspNetUserRefreshToken>().HasOne(p => p.User).WithMany().HasForeignKey(p => p.UserId)diff --git a/src/AliasDb/AspNetUserRefreshTokens.cs b/src/AliasDb/AspNetUserRefreshTokens.csindex 09510c5f8..209b00d7f 100644--- a/src/AliasDb/AspNetUserRefreshTokens.cs+++ b/src/AliasDb/AspNetUserRefreshTokens.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="AspNetUserRefreshTokens.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasDb;using Microsoft.AspNetCore.Identity;@@ -7,7 +13,7 @@ using System.ComponentModel.DataAnnotations.Schema;/// <summary>/// Refresh tokens for users./// </summary>-public class AspNetUserRefreshTokens+public class AspNetUserRefreshToken{/// <summary>/// Gets or sets Refresh Token ID.diff --git a/src/AliasDb/Identity.cs b/src/AliasDb/Identity.csindex d3adcbb1c..1d3d0dd3d 100644--- a/src/AliasDb/Identity.cs+++ b/src/AliasDb/Identity.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="Identity.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasDb;using System.ComponentModel.DataAnnotations;diff --git a/src/AliasDb/Login.cs b/src/AliasDb/Login.csindex 55c10f318..aa54991a6 100644--- a/src/AliasDb/Login.cs+++ b/src/AliasDb/Login.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="Login.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasDb;using Microsoft.AspNetCore.Identity;diff --git a/src/AliasDb/Password.cs b/src/AliasDb/Password.csindex d24416f5e..7f59460f1 100644--- a/src/AliasDb/Password.cs+++ b/src/AliasDb/Password.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="Password.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasDb;using System.ComponentModel.DataAnnotations;diff --git a/src/AliasDb/Service.cs b/src/AliasDb/Service.csindex 17a1037c8..6be0fd790 100644--- a/src/AliasDb/Service.cs+++ b/src/AliasDb/Service.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="Service.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasDb;using System.ComponentModel.DataAnnotations;diff --git a/src/AliasGenerators/AliasGenerators.csproj b/src/AliasGenerators/AliasGenerators.csprojindex 2be79c532..e7f2bfa61 100644--- a/src/AliasGenerators/AliasGenerators.csproj+++ b/src/AliasGenerators/AliasGenerators.csproj@@ -4,10 +4,19 @@<TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable>+ <GenerateDocumentationFile>True</GenerateDocumentationFile></PropertyGroup>+ <ItemGroup>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>+<ItemGroup><PackageReference Include="SpamOK.PasswordGenerator" Version="1.0.1" />+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup></Project>diff --git a/src/AliasGenerators/Identity/IIdentityGenerator.cs b/src/AliasGenerators/Identity/IIdentityGenerator.csindex 7517b3df0..7addd5a15 100644--- a/src/AliasGenerators/Identity/IIdentityGenerator.cs+++ b/src/AliasGenerators/Identity/IIdentityGenerator.cs@@ -1,6 +1,19 @@+//-----------------------------------------------------------------------+// <copyright file="IIdentityGenerator.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Identity;+/// <summary>+/// IdentityGenerator interface.+/// </summary>public interface IIdentityGenerator{+ /// <summary>+ /// Generates a random identity.+ /// </summary>+ /// <returns>Identity model object which contains the random identity.</returns>Task<Models.Identity> GenerateRandomIdentityAsync();}diff --git a/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs b/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.csindex 179b39cce..faab122af 100644--- a/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs+++ b/src/AliasGenerators/Identity/Implementations/FigIdentityGenerator.cs@@ -1,25 +1,38 @@-using System.Text.Json;-+//-----------------------------------------------------------------------+// <copyright file="FigIdentityGenerator.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Identity.Implementations;+using System.Text.Json;+/// <summary>/// Identity generator which generates random identities using the identiteitgenerator.nl semi-public API./// </summary>public class FigIdentityGenerator : IIdentityGenerator{- private static readonly HttpClient httpClient = new HttpClient();+ private static readonly HttpClient HttpClient = new();+ private static readonly string Url = "https://api.identiteitgenerator.nl/generate/identity";+ /// <inheritdoc/>public async Task<Identity.Models.Identity> GenerateRandomIdentityAsync(){- var response = await httpClient.GetAsync("https://api.identiteitgenerator.nl/generate/identity");+ var response = await HttpClient.GetAsync(Url);response.EnsureSuccessStatusCode();var json = await response.Content.ReadAsStringAsync();var identity = JsonSerializer.Deserialize<Identity.Models.Identity>(json, new JsonSerializerOptions{- PropertyNameCaseInsensitive = true+ PropertyNameCaseInsensitive = true,});+ if (identity is null)+ {+ throw new InvalidOperationException("Failed to deserialize the identity from FIG WebApi.");+ }+return identity;}}diff --git a/src/AliasGenerators/Identity/Implementations/StaticIdentityGenerator.cs b/src/AliasGenerators/Identity/Implementations/StaticIdentityGenerator.csindex 75f0116fe..5b56f52d0 100644--- a/src/AliasGenerators/Identity/Implementations/StaticIdentityGenerator.cs+++ b/src/AliasGenerators/Identity/Implementations/StaticIdentityGenerator.cs@@ -1,17 +1,23 @@-using AliasGenerators.Identity;-+//-----------------------------------------------------------------------+// <copyright file="StaticIdentityGenerator.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Identity.Implementations;+using AliasGenerators.Identity;+/// <summary>/// Static identity generator which implements IIdentityGenerator but always returns/// the same static identity for testing purposes./// </summary>public class StaticIdentityGenerator : IIdentityGenerator{+ /// <inheritdoc/>public async Task<Identity.Models.Identity> GenerateRandomIdentityAsync(){- await Task.Delay(1); // Simulate async operation-+ await Task.Yield(); // Add an await statement to make the method truly asynchronous.return new Identity.Models.Identity{FirstName = "John",diff --git a/src/AliasGenerators/Identity/Models/Address.cs b/src/AliasGenerators/Identity/Models/Address.csnew file mode 100644index 000000000..2cac78a54--- /dev/null+++ b/src/AliasGenerators/Identity/Models/Address.cs@@ -0,0 +1,38 @@+//-----------------------------------------------------------------------+// <copyright file="Address.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasGenerators.Identity.Models;++/// <summary>+/// Address model.+/// </summary>+public class Address+{+ /// <summary>+ /// Gets or sets the street.+ /// </summary>+ public string Street { get; set; } = null!;++ /// <summary>+ /// Gets or sets the city.+ /// </summary>+ public string City { get; set; } = null!;++ /// <summary>+ /// Gets or sets the state.+ /// </summary>+ public string State { get; set; } = null!;++ /// <summary>+ /// Gets or sets the zip code.+ /// </summary>+ public string ZipCode { get; set; } = null!;++ /// <summary>+ /// Gets or sets the country.+ /// </summary>+ public string Country { get; set; } = null!;+}diff --git a/src/AliasGenerators/Identity/Models/Identity.cs b/src/AliasGenerators/Identity/Models/Identity.csindex deed581e6..15b79fac9 100644--- a/src/AliasGenerators/Identity/Models/Identity.cs+++ b/src/AliasGenerators/Identity/Models/Identity.cs@@ -1,38 +1,88 @@+//-----------------------------------------------------------------------+// <copyright file="Identity.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Identity.Models;+/// <summary>+/// Identity model.+/// </summary>public class Identity{- public string Id { get; set; }+ /// <summary>+ /// Gets or sets the id.+ /// </summary>+ public string Id { get; set; } = null!;++ /// <summary>+ /// Gets or sets the gender.+ /// </summary>public int Gender { get; set; }- public string FirstName { get; set; }- public string LastName { get; set; }- public string NickName { get; set; }++ /// <summary>+ /// Gets or sets the first name.+ /// </summary>+ public string FirstName { get; set; } = null!;++ /// <summary>+ /// Gets or sets the last name.+ /// </summary>+ public string LastName { get; set; } = null!;++ /// <summary>+ /// Gets or sets the nickname. This is also used as the username.+ /// </summary>+ public string NickName { get; set; } = null!;++ /// <summary>+ /// Gets or sets the birth date.+ /// </summary>public DateTime BirthDate { get; set; }- public Address Address { get; set; }- public Job Job { get; set; }- public List<string> Hobbies { get; set; }- public string EmailPrefix { get; set; }- public string Password { get; set; }- public string PhoneMobile { get; set; }- public string BankAccountIBAN { get; set; }- public string ProfilePhotoBase64 { get; set; }- public string ProfilePhotoPrompt { get; set; }-}-public class Address-{- public string Street { get; set; }- public string City { get; set; }- public string State { get; set; }- public string ZipCode { get; set; }- public string Country { get; set; }-}+ /// <summary>+ /// Gets or sets the address.+ /// </summary>+ public Address Address { get; set; } = null!;-public class Job-{- public string Title { get; set; }- public string Company { get; set; }- public string Salary { get; set; }- public decimal SalaryCalculated { get; set; }- public string Description { get; set; }+ /// <summary>+ /// Gets or sets the job.+ /// </summary>+ public Job Job { get; set; } = null!;++ /// <summary>+ /// Gets or sets the hobbies.+ /// </summary>+ public List<string> Hobbies { get; set; } = null!;++ /// <summary>+ /// Gets or sets the email address prefix.+ /// </summary>+ public string EmailPrefix { get; set; } = null!;++ /// <summary>+ /// Gets or sets the password.+ /// </summary>+ public string Password { get; set; } = null!;++ /// <summary>+ /// Gets or sets the phone mobile.+ /// </summary>+ public string PhoneMobile { get; set; } = null!;++ /// <summary>+ /// Gets or sets the bank account IBAN.+ /// </summary>+ public string BankAccountIBAN { get; set; } = null!;++ /// <summary>+ /// Gets or sets the profile photo in base64 format.+ /// </summary>+ public string ProfilePhotoBase64 { get; set; } = null!;++ /// <summary>+ /// Gets or sets the profile photo prompt.+ /// </summary>+ public string ProfilePhotoPrompt { get; set; } = null!;}diff --git a/src/AliasGenerators/Identity/Models/Job.cs b/src/AliasGenerators/Identity/Models/Job.csnew file mode 100644index 000000000..842aaa8cc--- /dev/null+++ b/src/AliasGenerators/Identity/Models/Job.cs@@ -0,0 +1,38 @@+//-----------------------------------------------------------------------+// <copyright file="Job.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasGenerators.Identity.Models;++/// <summary>+/// Job model.+/// </summary>+public class Job+{+ /// <summary>+ /// Gets or sets the title.+ /// </summary>+ public string Title { get; set; } = null!;++ /// <summary>+ /// Gets or sets the company.+ /// </summary>+ public string Company { get; set; } = null!;++ /// <summary>+ /// Gets or sets the salary.+ /// </summary>+ public string Salary { get; set; } = null!;++ /// <summary>+ /// Gets or sets the calculated salary.+ /// </summary>+ public decimal SalaryCalculated { get; set; }++ /// <summary>+ /// Gets or sets the description.+ /// </summary>+ public string Description { get; set; } = null!;+}diff --git a/src/AliasGenerators/Password/IPasswordGenerator.cs b/src/AliasGenerators/Password/IPasswordGenerator.csindex f40ffca3a..3f5e5e265 100644--- a/src/AliasGenerators/Password/IPasswordGenerator.cs+++ b/src/AliasGenerators/Password/IPasswordGenerator.cs@@ -1,6 +1,19 @@+//-----------------------------------------------------------------------+// <copyright file="IPasswordGenerator.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Implementations;+/// <summary>+/// Interface for password generators.+/// </summary>public interface IPasswordGenerator{+ /// <summary>+ /// Generates a random password.+ /// </summary>+ /// <returns>Random generated password as string.</returns>string GenerateRandomPassword();}diff --git a/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs b/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.csindex db62a9834..a2e127437 100644--- a/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs+++ b/src/AliasGenerators/Password/Implementations/SpamOkPasswordGenerator.cs@@ -1,3 +1,9 @@+//-----------------------------------------------------------------------+// <copyright file="SpamOkPasswordGenerator.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------namespace AliasGenerators.Password.Implementations;using AliasGenerators.Implementations;@@ -7,10 +13,7 @@ using AliasGenerators.Implementations;/// </summary>public class SpamOkPasswordGenerator : IPasswordGenerator{- /// <summary>- /// Generates a random password using the SpamOK library with diceware (dictionary) method.- /// </summary>- /// <returns></returns>+ /// <inheritdoc/>public string GenerateRandomPassword(){var passwordBuilder = new SpamOK.PasswordGenerator.BasicPasswordBuilder();@@ -24,7 +27,6 @@ public class SpamOkPasswordGenerator : IPasswordGenerator.GeneratePassword().ToString();-return password;}}diff --git a/src/AliasVault.Api/AliasVault.Api.csproj b/src/AliasVault.Api/AliasVault.Api.csprojindex fa7343c68..a0e0a0f45 100644--- a/src/AliasVault.Api/AliasVault.Api.csproj+++ b/src/AliasVault.Api/AliasVault.Api.csproj@@ -16,7 +16,11 @@</PackageReference><PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.0" /><PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.6.0" />- <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /></ItemGroup><ItemGroup>@@ -29,6 +33,7 @@<Content Include="..\..\.dockerignore"><Link>.dockerignore</Link></Content>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" /></ItemGroup></Project>diff --git a/src/AliasVault.Api/Controllers/AuthController.cs b/src/AliasVault.Api/Controllers/AuthController.csindex 612e0d1ee..08f14ba84 100644--- a/src/AliasVault.Api/Controllers/AuthController.cs+++ b/src/AliasVault.Api/Controllers/AuthController.cs@@ -73,7 +73,7 @@ public class AuthController : ControllerBasevar newRefreshToken = GenerateRefreshToken();// Add new refresh token.- _context.AspNetUserRefreshTokens.Add(new AspNetUserRefreshTokens+ _context.AspNetUserRefreshTokens.Add(new AspNetUserRefreshToken{UserId = user.Id,DeviceIdentifier = deviceIdentifier,@@ -219,7 +219,7 @@ public class AuthController : ControllerBase_context.AspNetUserRefreshTokens.RemoveRange(existingTokens);// Add new refresh token.- _context.AspNetUserRefreshTokens.Add(new AspNetUserRefreshTokens+ _context.AspNetUserRefreshTokens.Add(new AspNetUserRefreshToken{UserId = user.Id,DeviceIdentifier = deviceIdentifier,diff --git a/src/AliasVault.Shared/AliasVault.Shared.csproj b/src/AliasVault.Shared/AliasVault.Shared.csprojindex 3a6353295..bec8a2d8a 100644--- a/src/AliasVault.Shared/AliasVault.Shared.csproj+++ b/src/AliasVault.Shared/AliasVault.Shared.csproj@@ -6,4 +6,15 @@<Nullable>enable</Nullable></PropertyGroup>+ <ItemGroup>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>++ <ItemGroup>+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ </ItemGroup>+</Project>diff --git a/src/AliasVault.WebApp/AliasVault.WebApp.csproj b/src/AliasVault.WebApp/AliasVault.WebApp.csprojindex fe3dc1730..9d5a9d60d 100644--- a/src/AliasVault.WebApp/AliasVault.WebApp.csproj+++ b/src/AliasVault.WebApp/AliasVault.WebApp.csproj@@ -10,10 +10,14 @@<ItemGroup><PackageReference Include="Blazored.LocalStorage" Version="4.5.0" /><PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.6" />- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2"/>+ <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" /><PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.6" />- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" PrivateAssets="all"/>+ <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all" /><PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup><ItemGroup>@@ -23,6 +27,7 @@<Content Include="..\..\.dockerignore"><Link>.dockerignore</Link></Content>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" /></ItemGroup><ItemGroup>diff --git a/src/AliasVault/AliasVault.csproj b/src/AliasVault/AliasVault.csprojindex ee73b6b27..d67e3a5ca 100644--- a/src/AliasVault/AliasVault.csproj+++ b/src/AliasVault/AliasVault.csproj@@ -16,18 +16,15 @@<Content Include="..\..\LICENSE.md"><Link>LICENSE.md</Link></Content>+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" /></ItemGroup><ItemGroup>- <None Include="stylecop.json" />- </ItemGroup>-- <ItemGroup>- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5">+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference>- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference>diff --git a/src/AliasVault/stylecop.json b/src/AliasVault/stylecop.jsondeleted file mode 100644index 067679031..000000000--- a/src/AliasVault/stylecop.json+++ /dev/null@@ -1,19 +0,0 @@-{- "settings": {- "documentationRules": {- "companyName": "lanedirt",- "xmlHeader": true,- "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",- "variables": {- "licenseName": "MIT",- "licenseFile": "LICENSE.md"- },- "headerDecoration": "-----------------------------------------------------------------------"- },- "indentation": {- "indentationSize": 4,- "tabSize": 4,- "useTabs": false- }- }-}diff --git a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csprojindex 3da7ac303..a29c75d2f 100644--- a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj+++ b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj@@ -9,14 +9,28 @@<IsTestProject>true</IsTestProject></PropertyGroup>+ <ItemGroup>+ <AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>+<ItemGroup><PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.6" />- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>- <PackageReference Include="NUnit" Version="3.13.3"/>- <PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>- <PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>- <PackageReference Include="Microsoft.Playwright.NUnit" Version="1.27.1"/>- <PackageReference Include="coverlet.collector" Version="6.0.0"/>+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />+ <PackageReference Include="NUnit" Version="4.1.0" />+ <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />+ <PackageReference Include="NUnit.Analyzers" Version="4.2.0">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ <PackageReference Include="Microsoft.Playwright.NUnit" Version="1.44.0" />+ <PackageReference Include="coverlet.collector" Version="6.0.2">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup><ItemGroup>diff --git a/src/Tests/AliasVault.E2ETests/WebAppManager.cs b/src/Tests/AliasVault.E2ETests/WebAppManager.csindex 0cb1c5f01..846a696f0 100644--- a/src/Tests/AliasVault.E2ETests/WebAppManager.cs+++ b/src/Tests/AliasVault.E2ETests/WebAppManager.cs@@ -40,10 +40,7 @@ public class WebAppManager_blazorWasmProcess.ErrorDataReceived += (sender, args) =>{TestContext.Out.WriteLine(args.Data);- if (args.Data != null && (args.Data.Contains("error") || args.Data.Contains("fail")))- {- _blazorWasmErrors.Add(args.Data);- }+ _blazorWasmErrors.Add(args.Data);};_blazorWasmProcess.Start();diff --git a/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj b/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csprojindex b30347e1c..ff25ab06e 100644--- a/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj+++ b/src/Tests/AliasVault.UnitTests/AliasVault.UnitTests.csproj@@ -1,4 +1,4 @@-<Project Sdk="Microsoft.NET.Sdk">+<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net8.0</TargetFramework>@@ -11,11 +11,25 @@</PropertyGroup><ItemGroup>- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>- <PackageReference Include="NUnit" Version="3.13.3"/>- <PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>- <PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>- <PackageReference Include="coverlet.collector" Version="6.0.0"/>+ <Content Include="..\..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>++ <ItemGroup>+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />+ <PackageReference Include="NUnit" Version="4.1.0" />+ <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />+ <PackageReference Include="NUnit.Analyzers" Version="4.2.0">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ <PackageReference Include="coverlet.collector" Version="6.0.2">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup><ItemGroup>diff --git a/src/Utilities/Cryptography/Cryptography.csproj b/src/Utilities/Cryptography/Cryptography.csprojindex d6ede0c2c..ee96652ee 100644--- a/src/Utilities/Cryptography/Cryptography.csproj+++ b/src/Utilities/Cryptography/Cryptography.csproj@@ -6,8 +6,16 @@<Nullable>enable</Nullable></PropertyGroup>+ <ItemGroup>+ <AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>+<ItemGroup><PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" />+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup></Project>diff --git a/src/Utilities/FaviconExtractor/FaviconExtractor.csproj b/src/Utilities/FaviconExtractor/FaviconExtractor.csprojindex d6ccd0f77..9d3026df9 100644--- a/src/Utilities/FaviconExtractor/FaviconExtractor.csproj+++ b/src/Utilities/FaviconExtractor/FaviconExtractor.csproj@@ -6,8 +6,16 @@<Nullable>enable</Nullable></PropertyGroup>+ <ItemGroup>+ <Content Include="..\..\stylecop.json" Link="stylecop.json" />+ </ItemGroup>+<ItemGroup><PackageReference Include="HtmlAgilityPack" Version="1.11.61" />+ <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference></ItemGroup></Project>diff --git a/src/AliasDb/stylecop.json b/src/stylecop.jsonsimilarity index 100%rename from src/AliasDb/stylecop.jsonrename to src/stylecop.json