diff --git a/.gitignore b/.gitignore index add57be..b59e83d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,93 @@ +############################################ +# .NET Build +############################################ + bin/ obj/ -/packages/ -riderModule.iml -/_ReSharper.Caches/ \ No newline at end of file +out/ +publish/ + +############################################ +# Visual Studio +############################################ + +.vs/ +*.user +*.suo +*.userprefs +*.csproj.user +*.dbmdl +*.cache +*.pdb +*.opendb + +############################################ +# Rider / JetBrains +############################################ + +.idea/ +*.sln.iml + +############################################ +# VSCode +############################################ + +.vscode/ + +############################################ +# NuGet +############################################ + +*.nupkg +*.snupkg +packages/ +.nuget/ +.nuget/packages/ + +############################################ +# Logs +############################################ + +*.log +logs/ + +############################################ +# OS files +############################################ + +.DS_Store +Thumbs.db + +############################################ +# Local secrets / environment +############################################ + +.env +.env.* +secrets.json +appsettings.Development.json + +############################################ +# E2EE private keys +############################################ + +keys/* +!keys/.gitkeep + +############################################ +# Local test databases / data folders +############################################ + +data/ +*.db +*.sqlite +*.sqlite3 + +############################################ +# Temporary files +############################################ + +*.tmp +*.temp +*.bak +*.swp \ No newline at end of file diff --git a/.idea/.idea.RelayCore/.idea/.gitignore b/.idea/.idea.RelayCore/.idea/.gitignore deleted file mode 100644 index 50dbf98..0000000 --- a/.idea/.idea.RelayCore/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/projectSettingsUpdater.xml -/modules.xml -/contentModel.xml -/.idea.RelayCore.iml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.RelayCore/.idea/AndroidProjectSystem.xml b/.idea/.idea.RelayCore/.idea/AndroidProjectSystem.xml deleted file mode 100644 index e82600c..0000000 --- a/.idea/.idea.RelayCore/.idea/AndroidProjectSystem.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/.idea.RelayCore/.idea/encodings.xml b/.idea/.idea.RelayCore/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.RelayCore/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.RelayCore/.idea/indexLayout.xml b/.idea/.idea.RelayCore/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.RelayCore/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.RelayCore/.idea/vcs.xml b/.idea/.idea.RelayCore/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/.idea.RelayCore/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d6dc02a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base -USER $APP_UID -WORKDIR /app - -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build -ARG BUILD_CONFIGURATION=Release -WORKDIR /src -COPY ["RelayCore.csproj", "./"] -RUN dotnet restore "RelayCore.csproj" -COPY . . -WORKDIR "/src/" -RUN dotnet build "./RelayCore.csproj" -c $BUILD_CONFIGURATION -o /app/build - -FROM build AS publish -ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./RelayCore.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "RelayCore.dll"] diff --git a/Program.cs b/Program.cs deleted file mode 100644 index 33ea9c4..0000000 --- a/Program.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System.ComponentModel.Design; -using SurrealDb.Net; -using SurrealDb.Net.Models; -using SurrealDb.Net.Models.Auth; -using System.Text.Json; -using PasswordHasher; - -using var db = new SurrealDbClient("ws://127.0.0.1:8000/rpc"); - -await db.SignIn(new RootAuth { Username = "root", Password = "secret" }); -await db.Use("test", "test"); - -var user = new Users -{ - Username = "Keeper317", - Email = "Keeper317@gmail.com", - CreatedAt = DateTime.Now, - UpdatedAt = DateTime.Now, - LastLogin = DateTime.Now, - TwoFactorEnabled = false, - EmailVerified = false, - AccountStatus = (int) AccountStatuses.Active, - OnlineStatus = (int) OnlineStatuses.Online, -}; -var created = await db.Create("users", user); -Console.WriteLine($"Created Person: {ToJsonString(created)}"); -var hasher = new PasswordHasher.PasswordHasher(); -user.Password = hasher.HashPassword(created.Id + "password"); -user.UpdatedAt = DateTime.Now; -user.LastLogin = DateTime.Now; -user.Id = created.Id; - -bool isValid = hasher.VerifyPassword(created.Id + "password", user.Password); -Console.WriteLine($"Password match: {isValid}"); - -var updated = await db.Merge("users", new() { Id = created.Id, Password = user.Password }); - -// var updated = await db.Merge( -// new() { Id = (TABLE, "8b4nwczy6x8f8zd5sslq"), Marketing = true } -// ); -Console.WriteLine($"Updated Person: {ToJsonString(updated)}"); -// -var people = await db.Select("users"); -Console.WriteLine($"Select Person: {ToJsonString(people)}"); -// -// var queryResponse = await db.Query($"SELECT Marketing, count() AS Count FROM type::table({TABLE}) GROUP BY Marketing"); -// var groups = queryResponse.GetValue>(0); -// Console.WriteLine($"Get Value as group: {ToJsonString(groups)}"); - -await db.Delete("users"); - - -static string ToJsonString(object? o) -{ - return JsonSerializer.Serialize(o, new JsonSerializerOptions { WriteIndented = true, }); -} - -public class ResponsibilityMerge : Record -{ - public bool Marketing { get; set; } -} -public class Group -{ - public bool Marketing { get; set; } - public int Count { get; set; } -} - -public class Users : Record -{ - public required string Username { get; set; } - public string? Password { get; set; } - public required string Email { get; set; } - public required DateTime CreatedAt { get; set; } - public required DateTime UpdatedAt { get; set; } - public required DateTime LastLogin { get; set; } - public bool TwoFactorEnabled { get; set; } - public bool EmailVerified { get; set; } - public required int AccountStatus { get; set; } - public required int OnlineStatus { get; set; } -} - -public class PasswordHash : Record -{ - public string? Password { get; set; } -} - -public class Sessions : Record -{ - public required string UserId { get; set; } - public required string TokenHash { get; set; } - public required DateTime IssuedAt { get; set; } - public required DateTime ExpiresAt { get; set; } - public DateTime? LastUsedAt { get; set; } - public bool Revoked { get; set; } - public required string DeviceName { get; set; } - public required string IpAddress { get; set; } - public required string UserAgent { get; set; } -} - -public class PasswordReset : Record -{ - public required string UserId { get; set; } - public required string TokenHash { get; set; } - public required DateTime CreatedAt { get; set; } - public required DateTime ExpiresAt { get; set; } - public bool Revoked { get; set; } -} - -public class Licenses : Record -{ - public required string UserId { get; set; } - public required int LicenseType { get; set; } - public required int Status { get; set; } - public required DateTime CreatedAt { get; set; } - public required DateTime StartsAt { get; set; } - public required DateTime UpdatedAt { get; set; } - public required DateTime ExpiresAt { get; set; } - -} - -public class AuthAudits : Record -{ - public required string UserId { get; set; } - public required int EventType { get; set; } - public bool Success { get; set; } - public required string IpAddress { get; set; } - public required string UserAgent { get; set; } - public required string Details { get; set; } - public required DateTime CreatedAt { get; set; } -} -enum AccountStatuses -{ - Active, - Suspended, - Banned, - Deleted -} - -enum OnlineStatuses -{ - Online, - Busy, - DND, - Invisible, - Offline -} - -enum LicenseStatuses -{ - Active, - Expired, - Renewable, - Revoked -} - -enum LicenseType -{ - Free, - Basic, - Advanced, - Pro, - Enterprise -} - -enum LogEvents -{ - LoginSuccess, - LoginFailure, - LogoutSuccess, - LogoutFailure, - PasswordResetSuccess, - PasswordResetFailure, -} \ No newline at end of file diff --git a/Relay.sln b/Relay.sln new file mode 100644 index 0000000..add378e --- /dev/null +++ b/Relay.sln @@ -0,0 +1,62 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelayCore", "RelayCore\RelayCore.csproj", "{346BE501-DE74-4E88-9787-4722FBC8BD0D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelayClient", "RelayClient\RelayClient.csproj", "{AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelayServer", "RelayServer\RelayServer.csproj", "{38995780-E9AA-44D6-B62D-07CCA45E4E4C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|x64.ActiveCfg = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|x64.Build.0 = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|x86.ActiveCfg = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Debug|x86.Build.0 = Debug|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|Any CPU.Build.0 = Release|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|x64.ActiveCfg = Release|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|x64.Build.0 = Release|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|x86.ActiveCfg = Release|Any CPU + {346BE501-DE74-4E88-9787-4722FBC8BD0D}.Release|x86.Build.0 = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|x64.ActiveCfg = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|x64.Build.0 = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|x86.ActiveCfg = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Debug|x86.Build.0 = Debug|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|Any CPU.Build.0 = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|x64.ActiveCfg = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|x64.Build.0 = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|x86.ActiveCfg = Release|Any CPU + {AB9DA5AB-55DC-4DE4-834C-E1E1BCD0C3CD}.Release|x86.Build.0 = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|x64.ActiveCfg = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|x64.Build.0 = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|x86.ActiveCfg = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Debug|x86.Build.0 = Debug|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|Any CPU.Build.0 = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|x64.ActiveCfg = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|x64.Build.0 = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|x86.ActiveCfg = Release|Any CPU + {38995780-E9AA-44D6-B62D-07CCA45E4E4C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RelayClient/.gitignore b/RelayClient/.gitignore new file mode 100644 index 0000000..b59e83d --- /dev/null +++ b/RelayClient/.gitignore @@ -0,0 +1,93 @@ +############################################ +# .NET Build +############################################ + +bin/ +obj/ +out/ +publish/ + +############################################ +# Visual Studio +############################################ + +.vs/ +*.user +*.suo +*.userprefs +*.csproj.user +*.dbmdl +*.cache +*.pdb +*.opendb + +############################################ +# Rider / JetBrains +############################################ + +.idea/ +*.sln.iml + +############################################ +# VSCode +############################################ + +.vscode/ + +############################################ +# NuGet +############################################ + +*.nupkg +*.snupkg +packages/ +.nuget/ +.nuget/packages/ + +############################################ +# Logs +############################################ + +*.log +logs/ + +############################################ +# OS files +############################################ + +.DS_Store +Thumbs.db + +############################################ +# Local secrets / environment +############################################ + +.env +.env.* +secrets.json +appsettings.Development.json + +############################################ +# E2EE private keys +############################################ + +keys/* +!keys/.gitkeep + +############################################ +# Local test databases / data folders +############################################ + +data/ +*.db +*.sqlite +*.sqlite3 + +############################################ +# Temporary files +############################################ + +*.tmp +*.temp +*.bak +*.swp \ No newline at end of file diff --git a/RelayClient/App.xaml b/RelayClient/App.xaml new file mode 100644 index 0000000..0485623 --- /dev/null +++ b/RelayClient/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/RelayClient/App.xaml.cs b/RelayClient/App.xaml.cs new file mode 100644 index 0000000..3da581d --- /dev/null +++ b/RelayClient/App.xaml.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace RelayClient; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } +} \ No newline at end of file diff --git a/RelayClient/AppShell.xaml b/RelayClient/AppShell.xaml new file mode 100644 index 0000000..b205bde --- /dev/null +++ b/RelayClient/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/RelayClient/AppShell.xaml.cs b/RelayClient/AppShell.xaml.cs new file mode 100644 index 0000000..b751b95 --- /dev/null +++ b/RelayClient/AppShell.xaml.cs @@ -0,0 +1,9 @@ +namespace RelayClient; + +public partial class AppShell : Shell +{ + public AppShell() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/RelayClient/MainPage.xaml b/RelayClient/MainPage.xaml new file mode 100644 index 0000000..f8b87d0 --- /dev/null +++ b/RelayClient/MainPage.xaml @@ -0,0 +1,36 @@ + + + + + + + +