Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add favicon extractor

Leendert de Borst17da137c01d6
diff --git a/aliasvault.sln b/aliasvault.sln
index cab0da2ec..aa6641b1c 100644
--- a/aliasvault.sln
+++ b/aliasvault.sln
@@ -6,6 +6,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasDb", "src\AliasDb\Alia
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasGenerators", "src\AliasGenerators\AliasGenerators.csproj", "{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}"
EndProject
+Project("{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}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AliasVault.Tests", "src\AliasVault.Tests\AliasVault.Tests.csproj", "{8E6A418A-B305-465D-857D-49953605C18E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -24,5 +30,16 @@ Global
{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78E84B4E-57D1-491A-8F4E-9879AE49DE0F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ED328644-A152-403D-86EB-81201AA07744}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ED328644-A152-403D-86EB-81201AA07744}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ED328644-A152-403D-86EB-81201AA07744}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ED328644-A152-403D-86EB-81201AA07744}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E6A418A-B305-465D-857D-49953605C18E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E6A418A-B305-465D-857D-49953605C18E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E6A418A-B305-465D-857D-49953605C18E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E6A418A-B305-465D-857D-49953605C18E}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {ED328644-A152-403D-86EB-81201AA07744} = {01AB9389-2F89-4F8E-A688-BF4BF1FC42C8}
EndGlobalSection
EndGlobal
diff --git a/src/AliasDb/Migrations/20240531142952_AddServiceLogo.Designer.cs b/src/AliasDb/Migrations/20240531142952_AddServiceLogo.Designer.cs
new file mode 100644
index 000000000..55aacae74
--- /dev/null
+++ b/src/AliasDb/Migrations/20240531142952_AddServiceLogo.Designer.cs
@@ -0,0 +1,496 @@
+// <auto-generated />
+using System;
+using AliasDb;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace AliasDb.Migrations
+{
+ [DbContext(typeof(AliasDbContext))]
+ [Migration("20240531142952_AddServiceLogo")]
+ partial class AddServiceLogo
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.5")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true);
+
+ modelBuilder.Entity("AliasDb.Identity", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("AddressCity")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("AddressCountry")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("AddressState")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("AddressStreet")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("AddressZipCode")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("BankAccountIBAN")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("BirthDate")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid?>("DefaultPasswordId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("EmailPrefix")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FirstName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("Gender")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("Hobbies")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("LastName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("NickName")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property<string>("PhoneMobile")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DefaultPasswordId");
+
+ b.ToTable("Identities");
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Description")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<Guid>("IdentityId")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid>("ServiceId")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IdentityId");
+
+ b.HasIndex("ServiceId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Logins");
+ });
+
+ modelBuilder.Entity("AliasDb.Password", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<Guid>("LoginId")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Value")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LoginId");
+
+ b.ToTable("Passwords");
+ });
+
+ modelBuilder.Entity("AliasDb.Service", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<byte[]>("Logo")
+ .HasColumnType("BLOB");
+
+ b.Property<string>("Name")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Url")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Services");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("RoleId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
+ {
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("RoleId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("AliasDb.Identity", b =>
+ {
+ b.HasOne("AliasDb.Password", "DefaultPassword")
+ .WithMany()
+ .HasForeignKey("DefaultPasswordId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.Navigation("DefaultPassword");
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.HasOne("AliasDb.Identity", "Identity")
+ .WithMany()
+ .HasForeignKey("IdentityId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasDb.Service", "Service")
+ .WithMany()
+ .HasForeignKey("ServiceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Identity");
+
+ b.Navigation("Service");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasDb.Password", b =>
+ {
+ b.HasOne("AliasDb.Login", "Login")
+ .WithMany("Passwords")
+ .HasForeignKey("LoginId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Login");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.Navigation("Passwords");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/AliasDb/Migrations/20240531142952_AddServiceLogo.cs b/src/AliasDb/Migrations/20240531142952_AddServiceLogo.cs
new file mode 100644
index 000000000..309c072c8
--- /dev/null
+++ b/src/AliasDb/Migrations/20240531142952_AddServiceLogo.cs
@@ -0,0 +1,39 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class AddServiceLogo : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<byte[]>(
+ name: "Logo",
+ table: "Services",
+ type: "BLOB",
+ nullable: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "Url",
+ table: "Services",
+ type: "TEXT",
+ maxLength: 255,
+ nullable: true);
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Logo",
+ table: "Services");
+
+ migrationBuilder.DropColumn(
+ name: "Url",
+ table: "Services");
+ }
+ }
+}
diff --git a/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs b/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
index 57d076c91..df1ec3d3e 100644
--- a/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
+++ b/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
@@ -48,6 +48,7 @@ namespace AliasDb.Migrations
.HasColumnType("VARCHAR");
b.Property<string>("BankAccountIBAN")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("BirthDate")
@@ -60,6 +61,7 @@ namespace AliasDb.Migrations
.HasColumnType("TEXT");
b.Property<string>("EmailPrefix")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
@@ -72,6 +74,7 @@ namespace AliasDb.Migrations
.HasColumnType("VARCHAR");
b.Property<string>("Hobbies")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("LastName")
@@ -84,6 +87,7 @@ namespace AliasDb.Migrations
.HasColumnType("VARCHAR");
b.Property<string>("PhoneMobile")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
@@ -106,6 +110,7 @@ namespace AliasDb.Migrations
.HasColumnType("TEXT");
b.Property<string>("Description")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<Guid>("IdentityId")
@@ -119,6 +124,7 @@ namespace AliasDb.Migrations
b.Property<string>("UserId")
.IsRequired()
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -148,6 +154,7 @@ namespace AliasDb.Migrations
.HasColumnType("TEXT");
b.Property<string>("Value")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
@@ -166,12 +173,20 @@ namespace AliasDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
+ b.Property<byte[]>("Logo")
+ .HasColumnType("BLOB");
+
b.Property<string>("Name")
+ .HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
+ b.Property<string>("Url")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
b.HasKey("Id");
b.ToTable("Services");
diff --git a/src/AliasDb/Service.cs b/src/AliasDb/Service.cs
index 2e1e21b3a..17a1037c8 100644
--- a/src/AliasDb/Service.cs
+++ b/src/AliasDb/Service.cs
@@ -1,7 +1,6 @@
namespace AliasDb;
using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// The service entity.
@@ -20,6 +19,17 @@ public class Service
[StringLength(255)]
public string? Name { get; set; }
+ /// <summary>
+ /// Gets or sets the service URL.
+ /// </summary>
+ [StringLength(255)]
+ public string? Url { get; set; }
+
+ /// <summary>
+ /// Gets or sets image logo of the service.
+ /// </summary>
+ public byte[]? Logo { get; set; } = null;
+
/// <summary>
/// Gets or sets the created timestamp.
/// </summary>
diff --git a/src/AliasVault.Tests/AliasVault.Tests.csproj b/src/AliasVault.Tests/AliasVault.Tests.csproj
new file mode 100644
index 000000000..3e6131513
--- /dev/null
+++ b/src/AliasVault.Tests/AliasVault.Tests.csproj
@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+
+ <IsPackable>false</IsPackable>
+ <IsTestProject>true</IsTestProject>
+ </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"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Utilities\FaviconExtractor\FaviconExtractor.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/src/AliasVault.Tests/FaviconExtractorTests.cs b/src/AliasVault.Tests/FaviconExtractorTests.cs
new file mode 100644
index 000000000..f57d7b815
--- /dev/null
+++ b/src/AliasVault.Tests/FaviconExtractorTests.cs
@@ -0,0 +1,16 @@
+namespace AliasVault.Tests;
+
+public class FaviconExtractorTests
+{
+ [SetUp]
+ public void Setup()
+ {
+ }
+
+ [Test]
+ public void ExtractFaviconSpamOK()
+ {
+ var faviconBytes = FaviconExtractor.FaviconService.GetFaviconAsync("https://spamok.com");
+ Assert.That(faviconBytes, Is.Not.Null);
+ }
+}
diff --git a/src/AliasVault.Tests/GlobalUsings.cs b/src/AliasVault.Tests/GlobalUsings.cs
new file mode 100644
index 000000000..cefced496
--- /dev/null
+++ b/src/AliasVault.Tests/GlobalUsings.cs
@@ -0,0 +1 @@
+global using NUnit.Framework;
\ No newline at end of file
diff --git a/src/AliasVault/AliasVault.csproj b/src/AliasVault/AliasVault.csproj
index edc9452a5..ee73b6b27 100644
--- a/src/AliasVault/AliasVault.csproj
+++ b/src/AliasVault/AliasVault.csproj
@@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\AliasGenerators\AliasGenerators.csproj" />
<ProjectReference Include="..\AliasDb\AliasDb.csproj" />
+ <ProjectReference Include="..\Utilities\FaviconExtractor\FaviconExtractor.csproj" />
</ItemGroup>
<ItemGroup>
diff --git a/src/AliasVault/Components/Pages/Aliases/AddEdit.razor b/src/AliasVault/Components/Pages/Aliases/AddEdit.razor
index 9d5225107..588a34a20 100644
--- a/src/AliasVault/Components/Pages/Aliases/AddEdit.razor
+++ b/src/AliasVault/Components/Pages/Aliases/AddEdit.razor
@@ -11,6 +11,7 @@
@using AliasGenerators.Password.Implementations
@using AliasVault.Models
@using AliasVault.Services
+@using Microsoft.IdentityModel.Tokens
@if (EditMode)
{
@@ -43,6 +44,10 @@ else
<label for="serviceName">Service Name</label>
<input type="text" class="form-control" id="serviceName" @bind="obj.Service.Name" required>
</div>
+ <div class="form-group">
+ <label for="serviceName">Service URL</label>
+ <input type="text" class="form-control" id="serviceUrl" @bind="obj.Service.Url" required>
+ </div>
</div>
</div>
@@ -262,6 +267,12 @@ else
// Save the login, identity, password, and service to the database.
using (var context = new AliasDbContext())
{
+ // Try to extract favicon from service URL
+ if (obj.Service.Url != null && !obj.Service.Url.IsNullOrEmpty())
+ {
+ obj.Service.Logo = await FaviconExtractor.FaviconService.GetFaviconAsync(obj.Service.Url);
+ }
+
if (EditMode)
{
obj = await AliasService.UpdateAliasAsync(obj);
diff --git a/src/AliasVault/Components/Pages/Aliases/Alias.razor b/src/AliasVault/Components/Pages/Aliases/Alias.razor
index 545f7fc48..4c6e57884 100644
--- a/src/AliasVault/Components/Pages/Aliases/Alias.razor
+++ b/src/AliasVault/Components/Pages/Aliases/Alias.razor
@@ -1,13 +1,31 @@
@using AliasDb
@inherits AuthorizePageBase
+<style>
+ .card {
+ border-radius: 10px;
+ transition: background-color 0.3s ease, box-shadow 0.3s ease;
+ }
+
+ .card:hover {
+ background-color: #abd5ff;
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
+ cursor: pointer;
+ }
+
+ .card-body {
+ padding: 1rem;
+ }
+</style>
+
<div class="col">
- <div class="card mb-3">
+ <div class="card mb-3" @onclick="ShowDetails">
<div class="card-body">
- <h5 class="card-title">@Login.Service.Name</h5>
- <p class="card-text">Username: @Login.Identity.NickName. Email: @Login.Identity.EmailPrefix. <small class="text-muted">Created: @Login.CreatedAt.ToShortDateString()</small>
- </p>
- <a href="javascript:void(0)" @onclick="ShowDetails" class="btn btn-primary">View</a>
+ <div class="card-text text-center">
+ <DisplayFavicon faviconBytes="@Login.Service.Logo"></DisplayFavicon>
+ <div>@Login.Service.Name</div>
+ <div><small class="text-muted">@Login.CreatedAt.ToShortDateString()</small></div>
+ </div>
</div>
</div>
</div>
diff --git a/src/AliasVault/Components/Pages/Aliases/View.razor b/src/AliasVault/Components/Pages/Aliases/View.razor
index fd50ea842..fd2def6d6 100644
--- a/src/AliasVault/Components/Pages/Aliases/View.razor
+++ b/src/AliasVault/Components/Pages/Aliases/View.razor
@@ -34,6 +34,7 @@
else
{
<h4>@Alias.Service.Name</h4>
+ <h5>@Alias.Service.Url</h5>
<div class="row row-cols-1 g-4">
<div class="card">
diff --git a/src/AliasVault/Components/Shared/DisplayFavicon.razor b/src/AliasVault/Components/Shared/DisplayFavicon.razor
new file mode 100644
index 000000000..cedb56228
--- /dev/null
+++ b/src/AliasVault/Components/Shared/DisplayFavicon.razor
@@ -0,0 +1,24 @@
+@if (faviconBytes != null)
+{
+ <img src="@faviconDataUrl" style="width: 50px;" alt="Favicon" />
+}
+else
+{
+ <img src="img/service-placeholder.webp" style="width: 50px;" alt="Favicon" />
+}
+
+@code {
+ [Parameter]
+ public byte[]? faviconBytes { get; set; }
+
+ private string? faviconDataUrl;
+
+ protected override void OnParametersSet()
+ {
+ if (faviconBytes != null)
+ {
+ string base64String = Convert.ToBase64String(faviconBytes);
+ faviconDataUrl = $"data:image/x-icon;base64,{base64String}";
+ }
+ }
+}
diff --git a/src/AliasVault/Services/AliasService.cs b/src/AliasVault/Services/AliasService.cs
index 760dd7d59..1ebae7be3 100644
--- a/src/AliasVault/Services/AliasService.cs
+++ b/src/AliasVault/Services/AliasService.cs
@@ -101,6 +101,8 @@ public class AliasService
// Update service.
record.Service.Name = aliasObject.Service.Name;
+ record.Service.Url = aliasObject.Service.Url;
+ record.Service.Logo = aliasObject.Service.Logo;
record.Service.UpdatedAt = DateTime.UtcNow;
await dbContext.SaveChangesAsync();
diff --git a/src/AliasVault/wwwroot/img/service-placeholder.webp b/src/AliasVault/wwwroot/img/service-placeholder.webp
new file mode 100644
index 000000000..85460a537
Binary files /dev/null and b/src/AliasVault/wwwroot/img/service-placeholder.webp differ
diff --git a/src/Utilities/FaviconExtractor/FaviconExtractor.cs b/src/Utilities/FaviconExtractor/FaviconExtractor.cs
new file mode 100644
index 000000000..a140aa5fe
--- /dev/null
+++ b/src/Utilities/FaviconExtractor/FaviconExtractor.cs
@@ -0,0 +1,85 @@
+namespace FaviconExtractor;
+
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+using HtmlAgilityPack;
+
+public class FaviconService
+{
+ public static async Task<byte[]> GetFaviconAsync(string url)
+ {
+ using (HttpClient client = new HttpClient())
+ {
+ HttpResponseMessage response = await client.GetAsync(url);
+ if (!response.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ string htmlContent = await response.Content.ReadAsStringAsync();
+ HtmlDocument htmlDoc = new HtmlDocument();
+ htmlDoc.LoadHtml(htmlContent);
+
+ // Find all favicon links in the HTML
+ var faviconNodes = htmlDoc.DocumentNode.SelectNodes("//link[contains(@rel, 'icon')]");
+ if (faviconNodes == null || !faviconNodes.Any())
+ {
+ return null;
+ }
+
+ // Extract favicon URLs and their sizes
+ var favicons = faviconNodes
+ .Select(node => new
+ {
+ Url = node.GetAttributeValue("href", null),
+ Size = GetFaviconSize(node.GetAttributeValue("sizes", "0x0"))
+ })
+ .Where(favicon => !string.IsNullOrEmpty(favicon.Url))
+ .OrderByDescending(favicon => favicon.Size)
+ .ToList();
+
+ if (!favicons.Any())
+ {
+ return null;
+ }
+
+ var bestFavicon = favicons.First();
+ var faviconUrl = bestFavicon.Url;
+
+ // If the favicon URL is relative, convert it to an absolute URL
+ if (!Uri.IsWellFormedUriString(faviconUrl, UriKind.Absolute))
+ {
+ var baseUri = new Uri(url);
+ faviconUrl = new Uri(baseUri, faviconUrl).ToString();
+ }
+
+ HttpResponseMessage faviconResponse = await client.GetAsync(faviconUrl);
+ if (!faviconResponse.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ byte[] faviconBytes = await faviconResponse.Content.ReadAsByteArrayAsync();
+ return faviconBytes;
+ }
+ }
+
+ private static int GetFaviconSize(string size)
+ {
+ if (string.IsNullOrEmpty(size) || size == "any")
+ {
+ return 0;
+ }
+
+ var sizeParts = size.Split('x');
+ if (sizeParts.Length == 2 &&
+ int.TryParse(sizeParts[0], out int width) &&
+ int.TryParse(sizeParts[1], out int height))
+ {
+ return width * height;
+ }
+
+ return 0;
+ }
+}
diff --git a/src/Utilities/FaviconExtractor/FaviconExtractor.csproj b/src/Utilities/FaviconExtractor/FaviconExtractor.csproj
new file mode 100644
index 000000000..d6ccd0f77
--- /dev/null
+++ b/src/Utilities/FaviconExtractor/FaviconExtractor.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
+ </ItemGroup>
+
+</Project>
diff --git a/src/Utilities/GenericHelpers/Class1.cs b/src/Utilities/GenericHelpers/Class1.cs
new file mode 100644
index 000000000..e95cd9efb
--- /dev/null
+++ b/src/Utilities/GenericHelpers/Class1.cs
@@ -0,0 +1,61 @@
+namespace GenericHelpers;
+
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+using HtmlAgilityPack;
+
+public class FaviconService
+{
+ public static async Task<byte[]?> GetFaviconAsync(string url)
+ {
+ try
+ {
+ using (HttpClient client = new HttpClient())
+ {
+ HttpResponseMessage response = await client.GetAsync(url);
+ if (!response.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ string htmlContent = await response.Content.ReadAsStringAsync();
+ HtmlDocument htmlDoc = new HtmlDocument();
+ htmlDoc.LoadHtml(htmlContent);
+
+ // Try to find the favicon link in the HTML
+ var faviconNode = htmlDoc.DocumentNode.SelectSingleNode("//link[@rel='icon' or @rel='shortcut icon']");
+ if (faviconNode == null)
+ {
+ return null;
+ }
+
+ var faviconUrl = faviconNode.GetAttributeValue("href", null);
+ if (string.IsNullOrEmpty(faviconUrl))
+ {
+ return null;
+ }
+
+ // If the favicon URL is relative, convert it to an absolute URL
+ if (!Uri.IsWellFormedUriString(faviconUrl, UriKind.Absolute))
+ {
+ var baseUri = new Uri(url);
+ faviconUrl = new Uri(baseUri, faviconUrl).ToString();
+ }
+
+ HttpResponseMessage faviconResponse = await client.GetAsync(faviconUrl);
+ if (!faviconResponse.IsSuccessStatusCode)
+ {
+ return null;
+ }
+
+ byte[] faviconBytes = await faviconResponse.Content.ReadAsByteArrayAsync();
+ return faviconBytes;
+ }
+ }
+ catch
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Utilities/GenericHelpers/GenericHelpers.csproj b/src/Utilities/GenericHelpers/GenericHelpers.csproj
new file mode 100644
index 000000000..3a6353295
--- /dev/null
+++ b/src/Utilities/GenericHelpers/GenericHelpers.csproj
@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+</Project>