aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-02-25 01:11:06 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-02-25 01:11:06 -0500
commitbd3a7a25792b837c5f28c7580adf132abc6f35e7 (patch)
tree2a3ec046f8f76f115e648f2bc6d1576cfa0a6c6f
parent52645b724834e669788a45edb9d135f243432540 (diff)
Squashed commit of the following:
commit 069f81fc3c87c437eceff756ddca7a4c1b58044d Author: vnugent <public@vaughnnugent.com> Date: Sat Feb 24 22:33:34 2024 -0500 feat: #3 setup mode, admin signup, fixes, and contianerize! commit 97ffede9eb312fca0257afa06969d47a12703f3b Author: vnugent <public@vaughnnugent.com> Date: Mon Feb 19 22:26:03 2024 -0500 feat: new account setup and invitation links commit 1c8f59bc0a1b25ce5013b0f1fc7fa73c0de415d6 Author: vnugent <public@vaughnnugent.com> Date: Thu Feb 15 16:49:59 2024 -0500 feat: update packages, drag/drop link, and fix some button padding
-rw-r--r--back-end/src/Endpoints/BmAccountEndpoint.cs492
-rw-r--r--back-end/src/Endpoints/BookmarkEndpoint.cs50
-rw-r--r--back-end/src/ImportExportUtil.cs10
-rw-r--r--back-end/src/Model/BookmarkEntry.cs44
-rw-r--r--back-end/src/Model/BookmarkStore.cs88
-rw-r--r--back-end/src/Model/SimpleBookmarkContext.cs7
-rw-r--r--back-end/src/Model/UserSettingsDbStore.cs6
-rw-r--r--back-end/src/RoleHelpers.cs42
-rw-r--r--back-end/src/SimpleBookmark.csproj10
-rw-r--r--back-end/src/SimpleBookmark.json16
-rw-r--r--back-end/src/SimpleBookmarkEntry.cs12
-rw-r--r--ci/config/SimpleBookmark.json16
-rw-r--r--ci/config/config.json15
-rw-r--r--ci/container/Dockerfile89
-rw-r--r--ci/container/Taskfile.yaml91
-rw-r--r--ci/container/config-templates/Essentials.Accounts-template.json76
-rw-r--r--ci/container/config-templates/PageRouter-template.json6
-rw-r--r--ci/container/config-templates/SessionProvider-template.json21
-rw-r--r--ci/container/config-templates/SimpleBookmark-template.json22
-rw-r--r--ci/container/config-templates/config-template.json166
-rw-r--r--ci/container/docker-compose.yaml45
-rw-r--r--ci/container/run.sh15
-rw-r--r--ci/container/static/routes.xml46
-rw-r--r--ci/install.taskfile.yaml19
-rw-r--r--ci/plugins.taskfile.yaml75
-rw-r--r--ci/taskfile.yaml86
-rw-r--r--front-end/package-lock.json364
-rw-r--r--front-end/package.json2
-rw-r--r--front-end/src/App.vue26
-rw-r--r--front-end/src/components/Bookmarks.vue77
-rw-r--r--front-end/src/components/Login.vue21
-rw-r--r--front-end/src/components/Login/AdminReg.vue84
-rw-r--r--front-end/src/components/Login/UserPass.vue2
-rw-r--r--front-end/src/components/Registation.vue137
-rw-r--r--front-end/src/components/Settings.vue10
-rw-r--r--front-end/src/components/Settings/Bookmarks.vue119
-rw-r--r--front-end/src/components/Settings/Registation.vue130
-rw-r--r--front-end/src/components/global/ConfirmPrompt.vue2
-rw-r--r--front-end/src/components/global/Dialog.vue4
-rw-r--r--front-end/src/components/global/PasswordPrompt.vue2
-rw-r--r--front-end/src/main.ts2
-rw-r--r--front-end/src/store/bookmarks.ts1
-rw-r--r--front-end/src/store/index.ts13
-rw-r--r--front-end/src/store/registation.ts110
44 files changed, 2224 insertions, 447 deletions
diff --git a/back-end/src/Endpoints/BmAccountEndpoint.cs b/back-end/src/Endpoints/BmAccountEndpoint.cs
new file mode 100644
index 0000000..9b57d39
--- /dev/null
+++ b/back-end/src/Endpoints/BmAccountEndpoint.cs
@@ -0,0 +1,492 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+using System;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Text.Json.Serialization;
+
+using FluentValidation;
+
+using VNLib.Utils.Memory;
+using VNLib.Utils.Logging;
+using VNLib.Utils.Extensions;
+using VNLib.Hashing;
+using VNLib.Hashing.IdentityUtility;
+using VNLib.Plugins;
+using VNLib.Plugins.Essentials;
+using VNLib.Plugins.Essentials.Accounts;
+using VNLib.Plugins.Essentials.Endpoints;
+using VNLib.Plugins.Essentials.Extensions;
+using VNLib.Plugins.Essentials.Users;
+using VNLib.Plugins.Extensions.Loading;
+using VNLib.Plugins.Extensions.Validation;
+using VNLib.Plugins.Extensions.Loading.Users;
+using VNLib.Plugins.Extensions.Loading.Events;
+
+using SimpleBookmark.Model;
+
+namespace SimpleBookmark.Endpoints
+{
+ [ConfigurationName("registration")]
+ internal sealed class BmAccountEndpoint : UnprotectedWebEndpoint
+ {
+
+ private static readonly IValidator<NewUserRequest> NewRequestVal = NewUserRequest.GetValidator();
+ private static readonly IValidator<RegSubmitRequest> RegSubmitVal = RegSubmitRequest.GetValidator();
+ private static readonly IValidator<RegSubmitRequest> AdminRegVal = RegSubmitRequest.GetAdminValidator();
+
+ private readonly IUserManager Users;
+ private readonly TimeSpan Expiration;
+ private readonly JwtAuthManager AuthMan;
+ //private readonly BookmarkStore Bookmarks;
+ private readonly bool SetupMode;
+ private readonly bool Enabled;
+
+ public BmAccountEndpoint(PluginBase plugin, IConfigScope config)
+ {
+ string path = config.GetRequiredProperty("path", p => p.GetString()!);
+ InitPathAndLog(path, plugin.Log);
+
+ //get setup mode and enabled startup arguments
+ SetupMode = plugin.HostArgs.HasArgument("--setup");
+ Enabled = !plugin.HostArgs.HasArgument("--disable-registation");
+
+ Expiration = config.GetRequiredProperty("token_lifetime_mins", p => p.GetTimeSpan(TimeParseType.Minutes));
+
+ Users = plugin.GetOrCreateSingleton<UserManager>();
+ //Bookmarks = plugin.GetOrCreateSingleton<BookmarkStore>();
+
+ /*
+ * JWT manager allows regenerating the signing key on a set interval.
+ *
+ * This means that if keys are generated on the edge of an interval,
+ * it will expire at the next interval which could be much shorter
+ * than the set interval. This is a security feature to prevent
+ * long term exposure of a signing key.
+ *
+ */
+ AuthMan = new JwtAuthManager();
+
+ if(config.TryGetProperty("key_regen_interval_mins", p => p.GetTimeSpan(TimeParseType.Minutes), out TimeSpan regen))
+ {
+ plugin.ScheduleInterval(AuthMan, regen, false);
+ }
+ }
+
+ //Essentially a whoami endpoint for current user
+ protected override VfReturnType Get(HttpEntity entity)
+ {
+ WebMessage msg = new()
+ {
+ Success = true
+ };
+
+ //Only authorized users can check their status
+ if (Enabled && entity.IsClientAuthorized(AuthorzationCheckLevel.Critical))
+ {
+ //Pass user status when logged in
+ msg.Result = new StatusResponse
+ {
+ SetupMode = SetupMode,
+ Enabled = Enabled,
+ CanInvite = entity.Session.CanAddUser(),
+ ExpirationTime = (int)Expiration.TotalSeconds
+ };
+ }
+ else
+ {
+ msg.Result = new StatusResponse
+ {
+ SetupMode = SetupMode,
+ Enabled = Enabled
+ };
+ }
+
+ return VirtualOk(entity, msg);
+ }
+
+ /*
+ * PUT will generate a new user request if the current has an admin
+ * role. This will return a jwt token that can be used to register a new
+ * user account. The token will expire after a set time.
+ */
+
+ protected override async ValueTask<VfReturnType> PutAsync(HttpEntity entity)
+ {
+ ValErrWebMessage webm = new();
+
+ if (webm.Assert(Enabled, "User registation was disabled via commandline"))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.Forbidden);
+ }
+
+ //Only authorized users can generate new requests
+ if(!entity.IsClientAuthorized(AuthorzationCheckLevel.Critical))
+ {
+ webm.Result = "You do not have permissions to create new users";
+ return VirtualClose(entity, webm, HttpStatusCode.Unauthorized);
+ }
+
+ //Make sure user is an admin
+ if (webm.Assert(entity.Session.CanAddUser(), "You do not have permissions to create new users"))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.Forbidden);
+ }
+
+ //Try to get the new user request
+ NewUserRequest? request = entity.GetJsonFromFile<NewUserRequest>();
+ if (webm.Assert(request != null, "No request body provided"))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.BadRequest);
+ }
+
+ if(!NewRequestVal.Validate(request, webm))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.UnprocessableEntity);
+ }
+
+ //Make sure the user does not already exist
+ using (IUser? user = await Users.GetUserFromUsernameAsync(request.Username!, entity.EventCancellation))
+ {
+ if (webm.Assert(user == null, "User already exists"))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.Conflict);
+ }
+ }
+
+ //Start with min user privilages
+ ulong privileges = RoleHelpers.MinUserRole;
+
+ //Optionally allow the user to add new userse
+ if(request.CanAddUsers)
+ {
+ privileges = RoleHelpers.WithAddUserRole(privileges);
+ }
+
+ //Init new request
+ using JsonWebToken jwt = new();
+
+ //issue new payload for registration
+ jwt.WritePayload(new JwtPayload
+ {
+ Expiration = entity.RequestedTimeUtc.Add(Expiration).ToUnixTimeSeconds(),
+ Subject = request.Username!,
+ PrivLevel = privileges,
+ Nonce = RandomHash.GetRandomHex(16)
+ });
+
+ AuthMan.SignJwt(jwt);
+ webm.Result = jwt.Compile();
+ webm.Success = true;
+
+ return VirtualClose(entity, webm, HttpStatusCode.OK);
+ }
+
+ protected override async ValueTask<VfReturnType> PostAsync(HttpEntity entity)
+ {
+ ValErrWebMessage webm = new();
+
+ if (webm.Assert(Enabled, "User registation was disabled via commandline."))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.Forbidden);
+ }
+
+ using RegSubmitRequest? req = await entity.GetJsonFromFileAsync<RegSubmitRequest>();
+
+ if (webm.Assert(req != null, "No request body provided."))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.BadRequest);
+ }
+
+ //Users can specify an admin username when setup mode is enabled
+ if (!string.IsNullOrWhiteSpace(req.AdminUsername))
+ {
+ if(webm.Assert(SetupMode, "Admin registation is not enabled."))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.Forbidden);
+ }
+
+ //Validate against admin reg
+ if(!AdminRegVal.Validate(req, webm))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.UnprocessableEntity);
+ }
+
+ try
+ {
+ //Default to min user privilages + add user privilages, technically the same as admin here
+ ulong adminPriv = RoleHelpers.WithAddUserRole(RoleHelpers.MinUserRole);
+
+ await CreateUserAsync(req.AdminUsername, adminPriv, req.Password, entity.EventCancellation);
+
+ webm.Result = "Successfully created your new admin account.";
+ webm.Success = true;
+
+ return VirtualClose(entity, webm, HttpStatusCode.Created);
+ }
+ catch (UserExistsException)
+ {
+ webm.Result = "User account already exists";
+ return VirtualClose(entity, webm, HttpStatusCode.Conflict);
+ }
+ }
+
+ //Normal link registration
+ if(!RegSubmitVal.Validate(req, webm))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.UnprocessableEntity);
+ }
+
+ try
+ {
+ //Try to recover the initial jwt from the request
+ using JsonWebToken jwt = JsonWebToken.Parse(req.Token!);
+
+ if (webm.Assert(AuthMan.VerifyJwt(jwt), "Registation failed, your link is invalid."))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.BadRequest);
+ }
+
+ JwtPayload p = jwt.GetPayload<JwtPayload>()!;
+
+ //Make sure the token is not expired
+ if (webm.Assert(p.Expiration > entity.RequestedTimeUtc.ToUnixTimeSeconds(), "Registation failed, your link has expired"))
+ {
+ return VirtualClose(entity, webm, HttpStatusCode.BadRequest);
+ }
+
+ //Check that the user is not already registered
+ using (IUser? user = await Users.GetUserFromUsernameAsync(p.Subject, entity.EventCancellation))
+ {
+ if (webm.Assert(user == null, "Your account already exists"))
+ {
+ /*
+ * It should be fine to tell the user that the account already exists
+ * because login tokens are "secret" and the user would have to know
+ * the token to use it.
+ */
+
+ return VirtualClose(entity, webm, HttpStatusCode.Conflict);
+ }
+ }
+
+ //Create the new user
+ await CreateUserAsync(p.Subject, p.PrivLevel, req.Password, entity.EventCancellation);
+
+ webm.Result = "Successfully created you new account!";
+ webm.Success = true;
+
+ return VirtualClose(entity, webm, HttpStatusCode.Created);
+ }
+ catch (FormatException)
+ {
+ webm.Result = "Registation failed, your link is invalid.";
+ return VirtualClose(entity, webm, HttpStatusCode.BadRequest);
+ }
+ }
+
+ private async Task CreateUserAsync(string userName, ulong privLevel, string? password, CancellationToken cancellation)
+ {
+ //Create the new user
+ UserCreationRequest newUser = new()
+ {
+ EmailAddress = userName,
+ InitialStatus = UserStatus.Active,
+ Privileges = privLevel,
+ Password = PrivateString.ToPrivateString(password, false),
+ };
+
+ using IUser user = await Users.CreateUserAsync(newUser, null, cancellation);
+
+ //Assign a local account status and email address
+ user.SetAccountOrigin(AccountUtil.LOCAL_ACCOUNT_ORIGIN);
+ user.EmailAddress = userName;
+
+ await user.ReleaseAsync(cancellation);
+ }
+
+
+ /*
+ * TODO
+ * USERS DELETE OWN ACCOUNTS HERE
+ *
+ * Users may delete their own accounts if they are logged in.
+ * This function should delete all bookmarks, and their own account
+ * from the table. This requires password elevation aswell.
+ */
+ protected override ValueTask<VfReturnType> DeleteAsync(HttpEntity entity)
+ {
+ return base.DeleteAsync(entity);
+ }
+
+ private sealed class JwtAuthManager() : IIntervalScheduleable
+ {
+ /*
+ * Random signing keys are rotated on the configured expiration
+ * interval.
+ */
+
+ private byte[] secretKey = RandomHash.GetRandomBytes(64);
+
+ Task IIntervalScheduleable.OnIntervalAsync(ILogProvider log, CancellationToken cancellationToken)
+ {
+ secretKey = RandomHash.GetRandomBytes(64);
+ return Task.CompletedTask;
+ }
+
+ public void SignJwt(JsonWebToken jwt)
+ {
+ if (ManagedHash.IsAlgSupported(HashAlg.BlAKE2B))
+ {
+ jwt.Sign(secretKey, HashAlg.BlAKE2B);
+ }
+ else if (ManagedHash.IsAlgSupported(HashAlg.SHA3_256))
+ {
+ jwt.Sign(secretKey, HashAlg.SHA3_256);
+ }
+ else
+ {
+ //fallback to sha256
+ jwt.Sign(secretKey, HashAlg.SHA256);
+ }
+ }
+
+ public bool VerifyJwt(JsonWebToken jwt)
+ {
+ if (ManagedHash.IsAlgSupported(HashAlg.BlAKE2B))
+ {
+ return jwt.Verify(secretKey, HashAlg.BlAKE2B);
+ }
+ else if (ManagedHash.IsAlgSupported(HashAlg.SHA3_256))
+ {
+ return jwt.Verify(secretKey, HashAlg.SHA3_256);
+ }
+ else
+ {
+ //fallback to sha256
+ return jwt.Verify(secretKey, HashAlg.SHA256);
+ }
+ }
+ }
+
+
+ private sealed class JwtPayload
+ {
+ [JsonPropertyName("sub")]
+ public string Subject { get; set; } = string.Empty;
+
+ [JsonPropertyName("level")]
+ public ulong PrivLevel { get; set; }
+
+ [JsonPropertyName("exp")]
+ public long Expiration { get; set; }
+
+ [JsonPropertyName("n")]
+ public string Nonce { get; set; } = string.Empty;
+ }
+
+ private sealed class NewUserRequest
+ {
+ [JsonPropertyName("username")]
+ public string Username { get; set; } = string.Empty;
+
+ [JsonPropertyName("can_add_users")]
+ public bool CanAddUsers { get; set; }
+
+ public static IValidator<NewUserRequest> GetValidator()
+ {
+ InlineValidator<NewUserRequest> val = new();
+
+ val.RuleFor(p => p.Username)
+ .NotNull()
+ .NotEmpty()
+ .EmailAddress()
+ .Length(1, 200);
+
+ return val;
+ }
+ }
+
+ private sealed class StatusResponse
+ {
+ [JsonPropertyName("setup_mode")]
+ public bool SetupMode { get; set; }
+
+ [JsonPropertyName("enabled")]
+ public bool Enabled { get; set; }
+
+ [JsonPropertyName("can_invite")]
+ public bool? CanInvite { get; set; }
+
+ [JsonPropertyName("link_expiration")]
+ public int? ExpirationTime { get; set; }
+ }
+
+ private sealed class RegSubmitRequest() : PrivateStringManager(1)
+ {
+ [JsonPropertyName("token")]
+ public string? Token { get; set; }
+
+ [JsonPropertyName("admin_username")]
+ public string? AdminUsername { get; set; }
+
+ [JsonPropertyName("password")]
+ public string? Password
+ {
+ get => base[0];
+ set => base[0] = value;
+ }
+
+ public static IValidator<RegSubmitRequest> GetValidator()
+ {
+ InlineValidator<RegSubmitRequest> val = new();
+
+ val.RuleFor(p => p.Token)
+ .NotNull()
+ .NotEmpty()
+ .Length(1, 500);
+
+ val.RuleFor(p => p.Password)
+ .NotEmpty()
+ .Length(min: 8, max: 100)
+ .Password()
+ .WithMessage(errorMessage: "Password does not meet minium requirements");
+
+ return val;
+ }
+
+ public static IValidator<RegSubmitRequest> GetAdminValidator()
+ {
+ InlineValidator<RegSubmitRequest> val = new();
+
+ val.RuleFor(p => p.Password)
+ .NotEmpty()
+ .Length(min: 8, max: 100)
+ .Password()
+ .WithMessage(errorMessage: "Password does not meet minium requirements");
+
+ val.RuleFor(p => p.AdminUsername)
+ .NotNull()
+ .NotEmpty()
+ .EmailAddress()
+ .Length(1, 200);
+
+ return val;
+ }
+ }
+ }
+}
diff --git a/back-end/src/Endpoints/BookmarkEndpoint.cs b/back-end/src/Endpoints/BookmarkEndpoint.cs
index e6e388d..001a41b 100644
--- a/back-end/src/Endpoints/BookmarkEndpoint.cs
+++ b/back-end/src/Endpoints/BookmarkEndpoint.cs
@@ -31,6 +31,7 @@ using Microsoft.EntityFrameworkCore;
using VNLib.Utils;
using VNLib.Utils.IO;
using VNLib.Utils.Memory;
+using VNLib.Utils.Extensions;
using VNLib.Net.Http;
using VNLib.Plugins;
using VNLib.Plugins.Essentials;
@@ -38,7 +39,6 @@ using VNLib.Plugins.Essentials.Accounts;
using VNLib.Plugins.Essentials.Endpoints;
using VNLib.Plugins.Essentials.Extensions;
using VNLib.Plugins.Extensions.Loading;
-using VNLib.Plugins.Extensions.Loading.Sql;
using VNLib.Plugins.Extensions.Data.Extensions;
using VNLib.Plugins.Extensions.Validation;
@@ -60,9 +60,8 @@ namespace SimpleBookmark.Endpoints
string? path = config.GetRequiredProperty("path", p => p.GetString()!);
InitPathAndLog(path, plugin.Log);
- //Init new bookmark store
- IAsyncLazy<DbContextOptions> options = plugin.GetContextOptionsAsync();
- Bookmarks = new BookmarkStore(options);
+ //Init bookmark store
+ Bookmarks = plugin.GetOrCreateSingleton<BookmarkStore>();
//Load config
BmConfig = config.GetRequiredProperty("config", p => p.Deserialize<BookmarkStoreConfig>()!);
@@ -342,7 +341,7 @@ namespace SimpleBookmark.Endpoints
if (failOnInvalid)
{
//Get any invalid entires and create a validation result
- BookmarkError[] invalidEntires = sanitized.Select(b =>
+ BookmarkError[] invalidEntires = sanitized.Select(static b =>
{
ValidationResult result = BmValidator.Validate(b);
if(result.IsValid)
@@ -378,16 +377,24 @@ namespace SimpleBookmark.Endpoints
//Remove any invalid entires
sanitized = sanitized.Where(static b => BmValidator.Validate(b).IsValid);
}
+ try
+ {
+ //Try to update the records
+ ERRNO result = await Bookmarks.AddBulkAsync(sanitized, entity.Session.UserID, entity.RequestedTimeUtc, entity.EventCancellation);
- //Try to update the records
- ERRNO result = await Bookmarks.AddBulkAsync(sanitized, entity.Session.UserID, entity.RequestedTimeUtc, entity.EventCancellation);
-
- webm.Result = $"Successfully added {result} of {batch.Length} bookmarks";
- webm.Success = true;
+ webm.Result = $"Successfully added {result} of {batch.Length} bookmarks";
+ webm.Success = true;
- return VirtualClose(entity, webm, HttpStatusCode.OK);
+ return VirtualClose(entity, webm, HttpStatusCode.OK);
+ }
+ catch (DbUpdateException dbe) when(dbe.InnerException is not null)
+ {
+ //Set entire batch as an error
+ webm.Result = GetResultFromEntires(batch, dbe.InnerException.Message);
+ return VirtualOk(entity, webm);
+ }
}
-
+
///<inheritdoc/>
protected override async ValueTask<VfReturnType> DeleteAsync(HttpEntity entity)
{
@@ -418,10 +425,29 @@ namespace SimpleBookmark.Endpoints
return VirtualClose(entity, webm, HttpStatusCode.OK);
}
+ private static BatchUploadResult GetResultFromEntires(IEnumerable<BookmarkEntry> errors, string message)
+ {
+ BookmarkError[] invalidEntires = errors.Select(e => new BookmarkError
+ {
+ Errors = new object[] { new ValidationFailure(string.Empty, message) },
+ Subject = e
+ }).ToArray();
+
+ return new BatchUploadResult()
+ {
+ Errors = invalidEntires,
+ Message = message
+ };
+ }
+
+
sealed class BatchUploadResult
{
[JsonPropertyName("invalid")]
public BookmarkError[]? Errors { get; set; }
+
+ [JsonPropertyName("message")]
+ public string? Message { get; set; }
}
sealed class BookmarkError
diff --git a/back-end/src/ImportExportUtil.cs b/back-end/src/ImportExportUtil.cs
index 6fa554c..aff7109 100644
--- a/back-end/src/ImportExportUtil.cs
+++ b/back-end/src/ImportExportUtil.cs
@@ -16,17 +16,16 @@
using System;
using System.IO;
using System.Text.Json;
-using SimpleBookmark.Model;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using VNLib.Utils.IO;
-
+using SimpleBookmark.Model;
namespace SimpleBookmark
{
- internal static class ImportExportUtil
+ internal static partial class ImportExportUtil
{
/// <summary>
/// Exports a colletion of bookmarks to a netscape bookmark file
@@ -78,7 +77,7 @@ namespace SimpleBookmark
}
//Remove illegal characters from a string, ", \, and control characters
- private static readonly Regex _illegalChars = new("[\"\\p{Cc}]", RegexOptions.Compiled);
+ private static readonly Regex _illegalChars = GetIllegalCharsReg();
private static string? Escape(string? input)
{
@@ -140,5 +139,8 @@ namespace SimpleBookmark
writer.WriteEndArray();
}
+
+ [GeneratedRegex("[\"\\p{Cc}]", RegexOptions.Compiled)]
+ private static partial Regex GetIllegalCharsReg();
}
}
diff --git a/back-end/src/Model/BookmarkEntry.cs b/back-end/src/Model/BookmarkEntry.cs
index 0ce7644..fc981ec 100644
--- a/back-end/src/Model/BookmarkEntry.cs
+++ b/back-end/src/Model/BookmarkEntry.cs
@@ -32,6 +32,7 @@ namespace SimpleBookmark.Model
internal sealed partial class BookmarkEntry : DbModelBase, IUserEntity, IJsonOnDeserialized
{
[Key]
+ [MaxLength(64)]
public override string Id { get; set; }
public override DateTime Created { get; set; }
@@ -39,12 +40,13 @@ namespace SimpleBookmark.Model
public override DateTime LastModified { get; set; }
[JsonIgnore]
+ [MaxLength(64)]
public string? UserId { get; set; }
- [MaxLength(100)]
+ [MaxLength(200)]
public string? Name { get; set; }
- [MaxLength(200)]
+ [MaxLength(300)]
public string? Url { get; set; }
[MaxLength(500)]
@@ -53,7 +55,7 @@ namespace SimpleBookmark.Model
//Json flavor
[NotMapped]
[JsonPropertyName("Tags")]
- public string[]? JsonTags
+ public string?[]? JsonTags
{
get => Tags?.Split(',');
set => Tags = value is null ? null : string.Join(',', value);
@@ -61,7 +63,7 @@ namespace SimpleBookmark.Model
//Database flavor as string
[JsonIgnore]
- [MaxLength(100)]
+ [MaxLength(100)]
public string? Tags { get; set; }
public static IValidator<BookmarkEntry> GetValidator()
@@ -71,21 +73,29 @@ namespace SimpleBookmark.Model
validator.RuleFor(p => p.Name)
.NotEmpty()
.Matches(@"^[a-zA-Z0-9_\-\|\., ]+$", RegexOptions.Compiled)
- .MaximumLength(100);
+ .MaximumLength(200);
validator.RuleFor(p => p.Url)
.NotEmpty()
.Matches(@"^https?://", RegexOptions.Compiled)
- .MaximumLength(200);
+ .MaximumLength(300);
+ //Description should be valid utf-8 and not exceed 500 characters
validator.RuleFor(p => p.Description)
+ .Matches(@"^[\u0000-\u007F]+$", RegexOptions.Compiled).When(p => !string.IsNullOrEmpty(p.Description))
+ .WithMessage("Description contains illegal unicode characters")
.MaximumLength(500);
- //Tags must be non-empty and alphanumeric only, no spaces
+ //Tags must be non-empty and alphanumeric only, no spaces, only if tags are not null
validator.RuleForEach(p => p.JsonTags)
- .NotNull()
- .NotEmpty()
- .Matches(@"^[a-zA-Z0-9]+$", RegexOptions.Compiled);
+ .Matches(@"^[a-zA-Z0-9\-]+$", RegexOptions.Compiled).When(v => v.JsonTags is not null && v.JsonTags.Length > 0, ApplyConditionTo.CurrentValidator)
+ .WithMessage("Tags for this bookmark contain invalid characters -> {PropertyValue}")
+ .Length(1, 64).When(v => v.JsonTags is not null && v.JsonTags.Length > 0, ApplyConditionTo.CurrentValidator)
+ .WithMessage("One or more tags for this bookmark are too long");
+
+ validator.RuleFor(p => p.Tags)
+ .MaximumLength(100)
+ .WithMessage("You have too many tags or tag names are too long");
return validator;
}
@@ -96,6 +106,20 @@ namespace SimpleBookmark.Model
Name = Name?.Trim();
Url = Url?.Trim();
Description = Description?.Trim();
+
+ //Trim tags array
+ if(JsonTags != null)
+ {
+ for (int i = 0; i < JsonTags.Length; i++)
+ {
+ JsonTags[i] = JsonTags[i].Trim();
+ }
+ }
+
+ if(string.IsNullOrWhiteSpace(Tags))
+ {
+ Tags = null;
+ }
}
}
}
diff --git a/back-end/src/Model/BookmarkStore.cs b/back-end/src/Model/BookmarkStore.cs
index 8578976..ec020e8 100644
--- a/back-end/src/Model/BookmarkStore.cs
+++ b/back-end/src/Model/BookmarkStore.cs
@@ -22,15 +22,18 @@ using System.Threading.Tasks;
using System.Collections.Generic;
using VNLib.Utils;
+using VNLib.Plugins;
using VNLib.Plugins.Extensions.Data;
using VNLib.Plugins.Extensions.Loading;
using VNLib.Plugins.Extensions.Data.Abstractions;
-
+using VNLib.Plugins.Extensions.Loading.Sql;
namespace SimpleBookmark.Model
{
- internal sealed class BookmarkStore(IAsyncLazy<DbContextOptions> dbOptions) : DbStore<BookmarkEntry>
+ internal sealed class BookmarkStore(PluginBase plugin) : DbStore<BookmarkEntry>
{
+ private readonly IAsyncLazy<DbContextOptions> dbOptions = plugin.GetContextOptionsAsync();
+
///<inheritdoc/>
public override IDbQueryLookup<BookmarkEntry> QueryTable { get; } = new BookmarkQueryLookup();
@@ -52,6 +55,8 @@ namespace SimpleBookmark.Model
public async Task<BookmarkEntry[]> SearchBookmarksAsync(string userId, string? query, string[] tags, int limit, int page, CancellationToken cancellation)
{
+ BookmarkEntry[] results;
+
ArgumentNullException.ThrowIfNull(userId);
ArgumentNullException.ThrowIfNull(tags);
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(limit, 0);
@@ -59,31 +64,56 @@ namespace SimpleBookmark.Model
//Init new db connection
await using SimpleBookmarkContext context = new(dbOptions.Value);
- await context.OpenTransactionAsync(cancellation);
- //Start with userid
+ //Build the query starting with the user's bookmarks
IQueryable<BookmarkEntry> q = context.Bookmarks.Where(b => b.UserId == userId);
+ //reduce result set by search query first
+ if (!string.IsNullOrWhiteSpace(query))
+ {
+ q = WithSearch(q, query);
+ }
+
+ q = q.OrderByDescending(static b => b.Created);
+
+ /*
+ * For some databases server-side tag filtering is not supported.
+ * Client side evaluation must be used to finally filter the results.
+ *
+ * I am attempting to reduce the result set as much as possible on server-side
+ * evaluation before pulling the results into memory. So search, ordering and
+ * first tag filtering is done on server-side. The final tag filtering is done
+ * for multiple tags on client-side along with pagination. For bookmarks, I expect
+ * the result set to at worst double digits for most users, so this should be fine.
+ *
+ */
+
if (tags.Length > 0)
{
- //if tags are set, only return bookmarks that match the tags
- q = q.Where(b => b.Tags != null && tags.All(t => b.Tags!.Contains(t)));
+
+ //filter out bookmarks that do not have any tags and reduce by the first tag
+ q = q.Where(static b => b.Tags != null && b.Tags.Length > 0)
+ .Where(b => EF.Functions.Like(b.Tags, $"%{tags[0]}%"));
}
- if (!string.IsNullOrWhiteSpace(query))
+ if(tags.Length > 1)
{
- //if query is set, only return bookmarks that match the query
- q = q.Where(b => EF.Functions.Like(b.Name, $"%{query}%") || EF.Functions.Like(b.Description, $"%{query}%"));
+ //Finally pull all results into memory
+ BookmarkEntry[] bookmarkEntries = await q.ToArrayAsync(cancellation);
+
+ //filter out bookmarks that do not have all requested tags, then skip and take the requested page
+ results = bookmarkEntries.Where(b => tags.All(p => b.JsonTags!.Contains(p)))
+ .Skip(page * limit)
+ .Take(limit)
+ .ToArray();
}
-
- //return bookmarks in descending order of creation
- q = q.OrderByDescending(static b => b.Created);
-
- //return only the requested page
- q = q.Skip(page * limit).Take(limit);
-
- //execute query
- BookmarkEntry[] results = await q.ToArrayAsync(cancellation);
+ else
+ {
+ //execute server-side query
+ results = await q.Skip(page * limit)
+ .Take(limit)
+ .ToArrayAsync(cancellation);
+ }
//Close db and commit transaction
await context.SaveAndCloseAsync(true, cancellation);
@@ -91,14 +121,19 @@ namespace SimpleBookmark.Model
return results;
}
+ private static IQueryable<BookmarkEntry> WithSearch(IQueryable<BookmarkEntry> q, string query)
+ {
+ //if query is set, only return bookmarks that match the query
+ return q.Where(b => EF.Functions.Like(b.Name, $"%{query}%") || EF.Functions.Like(b.Description, $"%{query}%"));
+ }
+
public async Task<string[]> GetAllTagsForUserAsync(string userId, CancellationToken cancellation)
{
ArgumentNullException.ThrowIfNull(userId);
//Init new db connection
await using SimpleBookmarkContext context = new(dbOptions.Value);
- await context.OpenTransactionAsync(cancellation);
-
+
//Get all tags for the user
string[] tags = await context.Bookmarks
.Where(b => b.UserId == userId)
@@ -116,11 +151,19 @@ namespace SimpleBookmark.Model
.ToArray();
}
+ public async Task<ERRNO> DeleteAllForUserAsync(string userId, CancellationToken cancellation)
+ {
+ await using SimpleBookmarkContext context = new(dbOptions.Value);
+
+ context.Bookmarks.RemoveRange(context.Bookmarks.Where(b => b.UserId == userId));
+
+ return await context.SaveAndCloseAsync(true, cancellation);
+ }
+
public async Task<ERRNO> AddBulkAsync(IEnumerable<BookmarkEntry> bookmarks, string userId, DateTimeOffset now, CancellationToken cancellation)
{
//Init new db connection
await using SimpleBookmarkContext context = new(dbOptions.Value);
- await context.OpenTransactionAsync(cancellation);
//Setup clean bookmark instances
bookmarks = bookmarks.Select(b => new BookmarkEntry
@@ -162,8 +205,7 @@ namespace SimpleBookmark.Model
public IQueryable<BookmarkEntry> GetSingleQueryBuilder(IDbContextHandle context, params string[] constraints)
{
string bookmarkId = constraints[0];
- string userId = constraints[1];
-
+ string userId = constraints[1];
return from b in context.Set<BookmarkEntry>()
where b.UserId == userId && b.Id == bookmarkId
diff --git a/back-end/src/Model/SimpleBookmarkContext.cs b/back-end/src/Model/SimpleBookmarkContext.cs
index 2470695..25343d9 100644
--- a/back-end/src/Model/SimpleBookmarkContext.cs
+++ b/back-end/src/Model/SimpleBookmarkContext.cs
@@ -22,12 +22,12 @@ using VNLib.Plugins.Extensions.Loading.Sql;
namespace SimpleBookmark.Model
{
- internal sealed class SimpleBookmarkContext : TransactionalDbContext, IDbTableDefinition
+ internal sealed class SimpleBookmarkContext : DBContextBase, IDbTableDefinition
{
public DbSet<BookmarkEntry> Bookmarks { get; set; }
- public DbSet<UserSettingsEntry> BmSettings { get; set; }
+ public DbSet<UserSettingsEntry> SbSettings { get; set; }
public SimpleBookmarkContext(DbContextOptions options) : base(options)
{ }
@@ -56,7 +56,6 @@ namespace SimpleBookmark.Model
.WithColumn(p => p.Name)
.AllowNull(true)
- .MaxLength(100)
.Next()
.WithColumn(p => p.Version)
@@ -70,12 +69,10 @@ namespace SimpleBookmark.Model
.WithColumn(p => p.Description)
.AllowNull(true)
- .MaxLength(500)
.Next()
.WithColumn(p => p.Tags)
.AllowNull(true)
- .MaxLength(100)
.Next();
}
diff --git a/back-end/src/Model/UserSettingsDbStore.cs b/back-end/src/Model/UserSettingsDbStore.cs
index aa44fa2..d392262 100644
--- a/back-end/src/Model/UserSettingsDbStore.cs
+++ b/back-end/src/Model/UserSettingsDbStore.cs
@@ -33,9 +33,8 @@ namespace SimpleBookmark.Model
//Init new db connection
await using SimpleBookmarkContext context = new(dbOptions.Value);
- await context.OpenTransactionAsync(cancellation);
- UserSettingsEntry? settings = await context.BmSettings.FirstOrDefaultAsync(p => p.UserId == userId, cancellation);
+ UserSettingsEntry? settings = await context.SbSettings.FirstOrDefaultAsync(p => p.UserId == userId, cancellation);
//Close db and commit transaction
await context.SaveAndCloseAsync(true, cancellation);
@@ -50,10 +49,9 @@ namespace SimpleBookmark.Model
//Init new db connection
await using SimpleBookmarkContext context = new(dbOptions.Value);
- await context.OpenTransactionAsync(cancellation);
//Search for existing settings entry
- UserSettingsEntry? existing = await context.BmSettings.FirstOrDefaultAsync(p => p.UserId == userId, cancellation);
+ UserSettingsEntry? existing = await context.SbSettings.FirstOrDefaultAsync(p => p.UserId == userId, cancellation);
if (existing is null)
{
diff --git a/back-end/src/RoleHelpers.cs b/back-end/src/RoleHelpers.cs
new file mode 100644
index 0000000..a49d72a
--- /dev/null
+++ b/back-end/src/RoleHelpers.cs
@@ -0,0 +1,42 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+using VNLib.Plugins.Essentials.Accounts;
+using VNLib.Plugins.Essentials.Users;
+using VNLib.Plugins.Essentials.Sessions;
+
+namespace SimpleBookmark
+{
+ internal static class RoleHelpers
+ {
+ public const ulong CanAddUserRoleOption = 1 << AccountUtil.OPTIONS_MSK_OFFSET;
+
+ /// <summary>
+ /// A minium user role with read/write/delete access to their own bookmarks.
+ /// </summary>
+ public const ulong MinUserRole = AccountUtil.MINIMUM_LEVEL | AccountUtil.ALLFILE_MSK;
+
+ public static bool CanAddUser(this IUser user) => (user.Privileges & CanAddUserRoleOption) != 0;
+
+ public static bool CanAddUser(this ref readonly SessionInfo session) => (session.Privilages & CanAddUserRoleOption) != 0;
+
+ /// <summary>
+ /// Adds the add-user role to the given privileges for a user.
+ /// </summary>
+ /// <param name="privs"></param>
+ /// <returns>The modified privilege level</returns>
+ public static ulong WithAddUserRole(ulong privs) => privs | CanAddUserRoleOption;
+ }
+}
diff --git a/back-end/src/SimpleBookmark.csproj b/back-end/src/SimpleBookmark.csproj
index 581c3af..03d3b03 100644
--- a/back-end/src/SimpleBookmark.csproj
+++ b/back-end/src/SimpleBookmark.csproj
@@ -34,11 +34,11 @@
<ItemGroup>
<PackageReference Include="MemoryPack" Version="1.10.0" />
- <PackageReference Include="VNLib.Plugins.Extensions.Data" Version="0.1.0-ci0047" />
- <PackageReference Include="VNLib.Plugins.Extensions.Loading" Version="0.1.0-ci0047" />
- <PackageReference Include="VNLib.Plugins.Extensions.Loading.Sql" Version="0.1.0-ci0047" />
- <PackageReference Include="VNLib.Plugins.Extensions.Validation" Version="0.1.0-ci0047" />
- <PackageReference Include="VNLib.Plugins.Extensions.VNCache" Version="0.1.0-ci0051" />
+ <PackageReference Include="VNLib.Plugins.Extensions.Data" Version="0.1.0-ci0049" />
+ <PackageReference Include="VNLib.Plugins.Extensions.Loading" Version="0.1.0-ci0049" />
+ <PackageReference Include="VNLib.Plugins.Extensions.Loading.Sql" Version="0.1.0-ci0049" />
+ <PackageReference Include="VNLib.Plugins.Extensions.Validation" Version="0.1.0-ci0049" />
+ <PackageReference Include="VNLib.Plugins.Extensions.VNCache" Version="0.1.0-ci0052" />
</ItemGroup>
<ItemGroup>
diff --git a/back-end/src/SimpleBookmark.json b/back-end/src/SimpleBookmark.json
index 56ee217..27ebff8 100644
--- a/back-end/src/SimpleBookmark.json
+++ b/back-end/src/SimpleBookmark.json
@@ -1,16 +1,22 @@
{
//Comments are allowed
- "debug": false,
+ "debug": false, //Enables obnoxious debug logging
"bm_endpoint": {
- "path": "/bookmarks", //Path for the bookmarks endpoint
+ "path": "/bookmarks", //Path for the bookmarks endpoint
"config": {
- "max_limit": 100, //Max results per page
- "default_limit": 20, //Default results per page
- "user_quota": 5000 //Max bookmarks per user
+ "max_limit": 100, //Max results per page
+ "default_limit": 20, //Default results per page
+ "user_quota": 5000 //Max bookmarks per user
}
+ },
+
+ "registration": {
+ "path": "/register", //Path for the registration endpoint
+ "token_lifetime_mins": 360, //Token lifetime in minutes
+ "key_regen_interval_mins": 3600 //Signing key regeneration interval in minutes
}
} \ No newline at end of file
diff --git a/back-end/src/SimpleBookmarkEntry.cs b/back-end/src/SimpleBookmarkEntry.cs
index 48fcb2a..a1c9590 100644
--- a/back-end/src/SimpleBookmarkEntry.cs
+++ b/back-end/src/SimpleBookmarkEntry.cs
@@ -49,6 +49,7 @@ namespace SimpleBookmark
{
//route the bm endpoint
this.Route<BookmarkEndpoint>();
+ this.Route<BmAccountEndpoint>();
//Ensure database is created after a delay
this.ObserveWork(() => this.EnsureDbCreatedAsync<SimpleBookmarkContext>(this), 1000);
@@ -81,7 +82,7 @@ namespace SimpleBookmark
Documentation: https://www.vaughnnugent.com/resources/software/articles?tags=docs,_simple-bookmark
GitHub: https://github.com/VnUgE/simple-bookmark
-
+ {warning}
Your server is now running at the following locations:{0}
******************************************************************************";
@@ -103,7 +104,14 @@ namespace SimpleBookmark
sb.AppendLine(intf);
}
- Log.Information(template, sb);
+ //See if setup mode is enabled
+ bool setupMode = HostArgs.HasArgument("--setup") && !HostArgs.HasArgument("--disable-registation");
+
+ string warnMessage = setupMode
+ ? "\nWARNING: This server is in setup mode. Account registation is open to all users.\n"
+ : string.Empty;
+
+ Log.Information(template, warnMessage, sb);
}
}
}
diff --git a/ci/config/SimpleBookmark.json b/ci/config/SimpleBookmark.json
index f097602..6cb1b93 100644
--- a/ci/config/SimpleBookmark.json
+++ b/ci/config/SimpleBookmark.json
@@ -1,16 +1,22 @@
{
//Comments are allowed
- "debug": false,
+ "debug": false, //Enables obnoxious debug logging
"bm_endpoint": {
- "path": "/api/bookmarks", //Path for the bookmarks endpoint
+ "path": "/api/bookmarks", //Path for the bookmarks endpoint
"config": {
- "max_limit": 100, //Max results per page
- "default_limit": 20, //Default results per page
- "user_quota": 5000 //Max bookmarks per user
+ "max_limit": 100, //Max results per page
+ "default_limit": 20, //Default results per page
+ "user_quota": 5000 //Max bookmarks per user
}
+ },
+
+ "registration": {
+ "path": "/api/register", //Path for the registration endpoint
+ "token_lifetime_mins": 360, //Token lifetime in minutes
+ "key_regen_interval_mins": 3600 //Signing key regeneration interval in minutes
}
} \ No newline at end of file
diff --git a/ci/config/config.json b/ci/config/config.json
index 4740cd3..e4b33e8 100644
--- a/ci/config/config.json
+++ b/ci/config/config.json
@@ -84,6 +84,7 @@
"X-Content-Type-Options": "nosniff",
"X-Xss-Protection": "1; mode=block",
"X-Frame-Options": "DENY",
+ "Server":"VNLib.Webserver",
"Content-Security-Policy": "default-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; frame-src 'none'; object-src 'none'; referrer no-referrer-when-downgrade; upgrade-insecure-requests; block-all-mixed-content;"
},
@@ -125,7 +126,7 @@
"reload_delay_sec": 2,
"path": "plugins",
"config_dir": "config",
- "assets": "plugins/assets"
+ "assets": "plugins/assets/"
},
"disabled sys_log": {
@@ -148,15 +149,9 @@
//Sql for the users database
"sql": {
- "db_type": "sqlite", //mysql, mssql(default), sqlite
- "source": "simple-bookmark.db" //For sqlite only
-
- //"hostname": "example.com",
- //"username": "simple-bookmark",
- //"catalog": "simple-bookmark",
- //"min_pool_size": 5,
- //"ms_security": false
- //"trust_cert": false
+ "debug": false,
+ "provider": "VNLib.Plugins.Extensions.Sql.SQLite.dll",
+ "source": "simple-bookmark.db" //For sqlite only
},
//caching should be setup globally after VNCache #78a47dd
diff --git a/ci/container/Dockerfile b/ci/container/Dockerfile
new file mode 100644
index 0000000..365f1c7
--- /dev/null
+++ b/ci/container/Dockerfile
@@ -0,0 +1,89 @@
+#Copyright (c) Vaughn Nugent
+#Licensed under the GNU AGPL V3.0
+
+#use plain alpine latest to build native libraries in
+FROM alpine:3.19 as native-cont
+
+#install public libs and build tools
+RUN apk update && apk add build-base cmake npm git
+#most universal way to use Task is from NPM
+RUN npm install -g @go-task/cli
+
+WORKDIR /build
+
+#include local artifacts
+COPY app/ .
+
+#build internal libraries and copy the libraries to the /lib output directory
+RUN mkdir out/
+RUN task build-libs
+
+#APP CONTAINER
+#move into a clean dotnet apline lean image
+FROM mcr.microsoft.com/dotnet/runtime:8.0.2-alpine3.19-amd64 as app-cont
+
+LABEL name="vnuge/simple-bookmark"
+LABEL maintainer="Vaughn Nugent <vnpublic@proton.me>"
+LABEL description="A linkding inspired, self hosted, bookmark manager"
+
+#copy local artifacts again in run container
+COPY app/ /app
+
+#pull compiled libs from build container
+COPY --from=native-cont /build/out /app/lib
+
+RUN apk update && apk add --no-cache gettext icu-libs dumb-init
+
+#workdir
+WORKDIR /app
+
+#default to 8080 for TLS on TCP
+EXPOSE 8080/tcp
+
+VOLUME /app/data
+VOLUME /app/ssl
+#expose an assets directory for custom assets install
+VOLUME /app/usr/assets
+
+#disable dotnet invariant culture on alpine
+ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0
+
+#add helper/required libraries
+#ENV VNLIB_SHARED_HEAP_FILE_PATH=/app/lib/libvn_rpmalloc.so not ready yet, still need to debug
+ENV VNLIB_ARGON2_DLL_PATH=/app/lib/libargon2.so
+
+#set default env variables
+ENV MAX_BOOKMARKS=5000
+
+#SQL Config
+ENV SQL_LIB_PATH=VNLib.Plugins.Extensions.Sql.SQLite.dll
+ENV SQL_CONNECTION_STRING="Data Source=data/simple-bookmark.db;"
+
+#ACCOUNTS
+ENV MAX_LOGIN_ATTEMPS=10
+
+#HC Vault
+ENV HC_VAULT_ADDR=""
+ENV HC_VAULT_TOKEN=""
+
+#VNCACHE (default to memory only)
+ENV CACHE_ASM_PATH=VNLib.Data.Caching.Providers.VNCache.dll
+ENV MEMCACHE_ONLY=true
+ENV REDIS_CONNECTION_STRING=""
+ENV VNCACHE_INITIAL_NODES=[]
+
+#SECRETS
+ENV PASSWORD_PEPPER=""
+ENV DATABASE_PASSWORD=""
+ENV REDIS_PASSWORD=""
+ENV VNCACHE_CLIENT_PRIVATE_KEY=""
+ENV VNCACHE_CACHE_PUBLIC_KEY=""
+
+#HTTP/PROXY Config
+ENV HTTP_DOWNSTREAM_SERVERS=[]
+ENV SSL_JSON="{}"
+
+#run the init script within dumb-init
+ENTRYPOINT ["dumb-init", "--"]
+CMD ["ash", "./run.sh"]
+
diff --git a/ci/container/Taskfile.yaml b/ci/container/Taskfile.yaml
new file mode 100644
index 0000000..19ce71c
--- /dev/null
+++ b/ci/container/Taskfile.yaml
@@ -0,0 +1,91 @@
+# https://taskfile.dev
+
+#Called by the vnbuild system to produce builds for my website
+#https://www.vaughnnugent.com/resources/software
+
+version: "3"
+
+vars:
+ BUILDS_URL: https://www.vaughnnugent.com/public/resources/software/builds
+ PACKAGE_FILE_NAME: "sb-alpine3.19-oci.tgz"
+ INCLUDE_FILES: "Dockerfile, docker-compose.yaml"
+
+includes:
+ install:
+ taskfile: ../install.taskfile.yaml
+ optional: true #not needed for inside container build
+
+tasks:
+
+ #called from inside the container to build native libraries
+ build-libs:
+ vars:
+ OUT_DIR: "{{.USER_WORKING_DIR}}/out"
+
+ #build stage generates the following libraries
+ generates:
+ - "{{.USER_WORKING_DIR}}/out/libargon2.so"
+ - "{{.USER_WORKING_DIR}}/out/libvn_rpmalloc.so"
+ - "{{.USER_WORKING_DIR}}/out/libvn_compress.so"
+
+ cmds:
+ #build argon2 lib
+ - cd lib/argon2/ && task && cp build/libargon2.so {{.OUT_DIR}}/libargon2.so
+ #build rpmalloc library
+ - cd lib/vnlib_rpmalloc/ && task && cp build/libvn_rpmalloc.so {{.OUT_DIR}}/libvn_rpmalloc.so
+ #install zlib and brotli native libraries from the source repos (they dont have active releases anymore :()
+ - mkdir -p lib/third-party
+ - cd lib/third-party && git clone https://github.com/cloudflare/zlib.git
+ - cd lib/third-party && git clone https://github.com/google/brotli.git
+ #build native compression lib and put in lib dir
+ - cd lib/vnlib_compress && cmake -B./build && cmake --build build/ --config Release && cp build/libvn_compress.so {{.OUT_DIR}}/libvn_compress.so
+
+
+ #called from ci pipline to build the package
+ build:
+ vars:
+ SQLITE_RUNTIMES: 'build/app/plugins/assets/VNLib.Plugins.Extensions.Loading.Sql.SQLite/runtimes'
+ cmds:
+ - cmd: wsl dos2unix ./run.sh
+ #make build directory
+ - cmd: powershell -Command "mkdir build, build/app, build/app/config-templates/, build/app/static/ -Force"
+ #copy the existing linux-x64 build to the build folder
+ - cmd: powershell -Command "cp -Recurse -Force ../build/linux-x64/* build/app/"
+ #copy local scripts into the build folder
+ - cmd: powershell -Command "cp -Force run.sh, Taskfile.yaml build/app/"
+ - cmd: powershell -Command "cp -Force Dockerfile, docker-compose.yaml build/"
+ - cmd: powershell -Command "cp -Force static/* build/app/static/"
+ - cmd: powershell -Command "cp -Force config-templates/* build/app/config-templates/"
+ #remove the default config file as it's not needed in the container
+ - cmd: powershell -Command "rm -Force build/app/config.json"
+ - cmd: powershell -Command "rm -Force -Recurse build/app/config/"
+
+ #move the linux-musl-x64 directory out of assets before removing the rest of the runtimes and then move it back
+ - cmd: powershell -Command "mv {{.SQLITE_RUNTIMES}}/linux-musl-x64 build/linux-musl-x64"
+ - cmd: powershell -Command "rm -Recurse -Force {{.SQLITE_RUNTIMES}}" && powershell -Command "mkdir {{.SQLITE_RUNTIMES}}"
+ - cmd: powershell -Command "mv build/linux-musl-x64 {{.SQLITE_RUNTIMES}}/linux-musl-x64 "
+
+ #install rpmalloc
+ - task: install-rpmalloc-lib
+
+ postbuild_success:
+ cmds:
+ #tar up the build directory and move it to the output bin directory
+ - cmd: cd build/ && tar -czf ../../bin/{{.PACKAGE_FILE_NAME}} .
+
+ clean:
+ ignore_error: true
+ cmds:
+ - cmd: powershell -Command "rm -Recurse -Force ./build"
+
+
+ install-rpmalloc-lib:
+ internal: true
+ cmds:
+ #install compressor plugin
+ - task: install:install
+ vars:
+ PROJECT_NAME: 'vnlib_rpmalloc'
+ MODULE_NAME: "VNLib.Core"
+ FILE_NAME: "src.tgz"
+ DIR: './build/app/lib/vnlib_rpmalloc' \ No newline at end of file
diff --git a/ci/container/config-templates/Essentials.Accounts-template.json b/ci/container/config-templates/Essentials.Accounts-template.json
new file mode 100644
index 0000000..6e36986
--- /dev/null
+++ b/ci/container/config-templates/Essentials.Accounts-template.json
@@ -0,0 +1,76 @@
+{
+ "debug": false,
+
+ //endpoints
+
+ "login_endpoint": {
+ "path": "/api/account/login",
+ "max_login_attempts": ${MAX_LOGIN_ATTEMPS}, //10 failed attempts in 10 minutes
+ "failed_attempt_timeout_sec": 600 //10 minutes
+ },
+
+ "keepalive_endpoint": {
+ "path": "/api/account/keepalive",
+ //Regen token every 10 mins along with cookies
+ "token_refresh_sec": 600 //10 minutes
+ },
+
+ "profile_endpoint": {
+ "path": "/api/account/profile"
+ },
+
+ "password_endpoint": {
+ "path": "/api/account/reset"
+ },
+
+ "mfa_endpoint": {
+ "path": "/api/account/mfa"
+ },
+
+ "logout_endpoint": {
+ "path": "/api/account/logout"
+ },
+
+ "pki_auth_endpoint": {
+ "path": "/api/account/pki",
+ "jwt_time_dif_sec": 30,
+ "max_login_attempts": 10,
+ "failed_attempt_timeout_sec": 600,
+ //Configures the PATCH and DELETE methods to update the user's stored key when logged in
+ "enable_key_update": true
+ },
+
+ //If mfa is defined, configures mfa enpoints and enables mfa logins
+ "mfa": {
+ "upgrade_expires_secs": 180,
+ "nonce_size": 64,
+
+ //Defines totp specific arguments
+ "totp": {
+ "digits": 6,
+ "issuer": "Simple-Bookmark",
+ "period_secs": 30,
+ "algorithm": "sha1",
+ "secret_size": 32,
+ "window_size": 2
+ }
+ },
+
+ //Defines the included account provider
+ "account_security": {
+ //Time in seconds before a session is considered expired
+ "session_valid_for_sec": 3600,
+ //Path/domain for all security cookies
+ "cookie_domain": "",
+ "cookie_path": "/",
+ "status_cookie_name": "li", //front-end cookie name must match to detect login status
+ "otp_header_name": "X-Web-Token", //Front-end header name must match
+ "otp_time_diff_sec": 30,
+ "otp_key_size": 64,
+ "pubkey_cookie_name": "client-id",
+ "pubkey_signing_key_size": 32,
+ "strict_origin": false,
+ "strict_path": true, //Can be enabled if front-end is running on the same server
+ //"allowed_origins": [""]
+ }
+} \ No newline at end of file
diff --git a/ci/container/config-templates/PageRouter-template.json b/ci/container/config-templates/PageRouter-template.json
new file mode 100644
index 0000000..7cfdf24
--- /dev/null
+++ b/ci/container/config-templates/PageRouter-template.json
@@ -0,0 +1,6 @@
+{
+ "debug": false,
+ "store": {
+ "route_file": "static/routes.xml"
+ }
+} \ No newline at end of file
diff --git a/ci/container/config-templates/SessionProvider-template.json b/ci/container/config-templates/SessionProvider-template.json
new file mode 100644
index 0000000..e281edf
--- /dev/null
+++ b/ci/container/config-templates/SessionProvider-template.json
@@ -0,0 +1,21 @@
+{
+
+ "debug": false,
+
+ //Provider assemblies to load
+ "provider_assemblies": [ "VNLib.Plugins.Sessions.VNCache.dll" ],
+
+ //Web session provider, valid format for VNCache and also memory sessions
+ "web": {
+ //Cache system key prefix
+ "cache_prefix": "websessions",
+ //The session cookie name
+ "cookie_name": "sb-session",
+ //Size in bytes for generated session ids
+ "cookie_size": 40,
+ //time (in seconds) a session is valid for
+ "valid_for_sec": 3600,
+ //The maxium number of connections waiting for the cache server responses
+ "max_waiting_connections": 100
+ }
+} \ No newline at end of file
diff --git a/ci/container/config-templates/SimpleBookmark-template.json b/ci/container/config-templates/SimpleBookmark-template.json
new file mode 100644
index 0000000..6f39001
--- /dev/null
+++ b/ci/container/config-templates/SimpleBookmark-template.json
@@ -0,0 +1,22 @@
+{
+
+ //Comments are allowed
+ "debug": false, //Enables obnoxious debug logging
+
+ "bm_endpoint": {
+
+ "path": "/api/bookmarks", //Path for the bookmarks endpoint
+
+ "config": {
+ "max_limit": 100, //Max results per page
+ "default_limit": 20, //Default results per page
+ "user_quota": ${MAX_BOOKMARKS} //Max bookmarks per user
+ }
+ },
+
+ "registration": {
+ "path": "/api/register", //Path for the registration endpoint
+ "token_lifetime_mins": 360, //Token lifetime in minutes
+ "key_regen_interval_mins": 3600 //Signing key regeneration interval in minutes
+ }
+} \ No newline at end of file
diff --git a/ci/container/config-templates/config-template.json b/ci/container/config-templates/config-template.json
new file mode 100644
index 0000000..10092dd
--- /dev/null
+++ b/ci/container/config-templates/config-template.json
@@ -0,0 +1,166 @@
+{
+
+ //Host application config, config is loaded as a read-only DOM that is available
+ //to the host and loaded child plugins, all elements are available to plugins via the 'HostConfig' property
+
+ "http": {
+ //The defaut HTTP version to being requests with (does not support http/2 yet)
+ "default_version": "HTTP/1.1",
+ //The maxium size (in bytes) of response messges that will be compressed
+ "compression_limit": 512000,
+ //Minium response size (in bytes) to compress
+ "compression_minimum": 2048,
+ //The size of the buffer to use when parsing multipart/form data uploads
+ "multipart_max_buf_size": 8192,
+ //The maxium ammount of data (in bytes) allows for mulitpart/form data file uploads
+ "multipart_max_size": 80240,
+ //Absolute maximum size (in bytes) of the request entity body (exludes headers)
+ "max_entity_size": 1024000,
+ //Keepalive ms for HTTP1.1 keepalive connections
+ "keepalive_ms": 1000000,
+ //The buffer size to use when parsing headers (also the maxium request header size allowed)
+ "header_buf_size": 8128,
+ //The maxium number of headers allowed in an HTTP request message
+ "max_request_header_count": 50,
+ //The maxium number of allowed network connections, before 503s will be issued automatically and connections closed
+ "max_connections": 5000,
+ //The size in bytes of the buffer to use when writing response messages
+ "response_buf_size": 4096,
+ //time (in ms) to wait for a response from an active connection in recv mode, before dropping it
+ "recv_timeout_ms": 5000,
+ //Time in ms to wait for the client to accept transport data before terminating the connection
+ "send_timeout_ms": 60000,
+ //The size (in bytes) of the buffer used to store all response header data
+ "response_header_buf_size": 16384,
+ //Max number of file uploads allowed per request
+ "max_uploads_per_request": 10
+ },
+
+ //Compression is installed in the container at lib/ directory along with the native library supporting gzip and brotli
+ "compression_lib": "lib/vnlib.net.compression/VNLib.Net.Compression.dll",
+
+ //Setup the native lib
+ "vnlib.net.compression": {
+ "lib_path": "lib/libvn_compress.so",
+ "level": 1
+ },
+
+
+ //Maxium ammount of time a request is allowed to be processed (includes loading or waiting for sessions) before operations will be cancelled and a 503 returned
+ "max_execution_time_ms": 20000,
+
+ //Collection of objects to define hosts+interfaces to build server listeners from
+ "virtual_hosts": [
+ {
+ //The interface to bind to, you may not mix TLS and non-TLS connections on the same interface
+ "interface": {
+ "address": "0.0.0.0",
+ "port": 8080
+ },
+
+ //Collection of "trusted" servers to allow proxy header support from
+ "downstream_servers": ${HTTP_DOWNSTREAM_SERVERS},
+
+ //The hostname to listen for, "*" as wildcard, and "[system]" as the default hostname for the current machine
+ "hostname": "*",
+ "path": "dist/",
+
+ //A list of file extensions to deny access to, if a resource is requested and has one of the following extensions, a 404 is returned
+ "deny_extensions": [ ".ts", ".json", ".htaccess", ".php" ],
+ //The default file extensions to append to a resource that does not have a file extension
+ "default_files": [ "index.html", "index.htm" ],
+
+ //A list of error file objects, files are loaded into memory (and watched for changes) and returned when the specified error code occurs
+ "error_files": [],
+
+ //The default
+ "cache_default_sec": 864000,
+
+ "ssl": ${SSL_JSON},
+ }
+ ],
+
+
+ //Defines the directory where plugin's are to be loaded from
+ "plugins": {
+ //Hot-reload creates collectable assemblies that allow full re-load support in the host application, should only be used for development purposes!
+ "hot_reload": false,
+ "path": "plugins/",
+ "config_dir": "config/",
+ "assets": "plugins/assets/"
+ },
+
+ "sys_log": {
+ "path": "data/logs/sys-log.txt",
+ "flush_sec": 5,
+ "retained_files": 31,
+ "file_size_limit": 10485760,
+ "interval": "infinite"
+ },
+
+ "app_log": {
+ "path": "data/logs/app-log.txt",
+ "flush_sec": 5,
+ "retained_files": 31,
+ "file_size_limit": 10485760,
+ "interval": "infinite"
+ },
+
+ //HASHICORP VAULT
+ "hashicorp_vault": {
+ "url": "${HC_VAULT_ADDR}",
+ "token": "${HC_VAULT_TOKEN}"
+ },
+
+ //SQL CONFIG
+ "sql": {
+ "provider": "${SQL_LIB_PATH}",
+ "connection_string": "${SQL_CONNECTION_STRING}"
+ },
+
+ //VNCACHE global config
+ //Enable vncache as the providers above rely on the object caching server
+ "cache": {
+
+ "assembly_name": "${CACHE_ASM_PATH}",
+ "url": "${REDIS_CONNECTION_STRING}",
+
+ //Max size (in bytes) of allowed data to be stored in each user's session object
+ "max_object_size": 8128,
+
+ //Request timeout
+ "request_timeout_sec": 10,
+
+ //Time delay between cluster node discovery
+ "discovery_interval_sec": 120,
+
+ //Initial nodes to discover from
+ "initial_nodes": ${VNCACHE_INITIAL_NODES},
+
+ //Disable TLS
+ "use_tls": false,
+
+ //Setting this value to true will cause the cache store to load a memory-only instance, without remote backing
+ "memory_only": ${MEMCACHE_ONLY},
+
+ //enable memory cache
+ "memory_cache": {
+ "buckets": 20,
+ "bucket_size": 5000,
+ "max_age_sec": 600,
+ "refresh_interval_sec": 60,
+ "zero_all": false,
+ "max_object_size": 8128
+ }
+ },
+
+ "secrets": {
+ //Special key used by the loading library for access to the PasswordHashing library to pepper password hashes
+ "passwords": "${PASSWORD_PEPPER}",
+ "db_password": "${DATABASE_PASSWORD}",
+ "client_private_key": "${VNCACHE_CLIENT_PRIVATE_KEY}",
+ "cache_public_key": "${VNCACHE_CACHE_PUBLIC_KEY}",
+ "redis_password": "${REDIS_PASSWORD}"
+ }
+}
+
diff --git a/ci/container/docker-compose.yaml b/ci/container/docker-compose.yaml
new file mode 100644
index 0000000..0c3d1e1
--- /dev/null
+++ b/ci/container/docker-compose.yaml
@@ -0,0 +1,45 @@
+#Copyright (c) Vaughn Nugent
+#Licensed under the GNU AGPLv3
+
+version: '3.6'
+
+services:
+ simple-bookmark:
+ image: vnuge/simple-bookmark
+ container_name: simple-bookmark
+ restart: unless-stopped
+ volumes:
+ - ./data:/app/data
+ - ./assets:/app/usr/assets:ro
+ - ./ssl:/app/ssl:ro
+ ports:
+ - 8080:8080
+ environment:
+ MAX_BOOKMARKS: "5000"
+ #SQL Config
+ SQL_LIB_PATH: "VNLib.Plugins.Extensions.Sql.SQLite.dll"
+ SQL_CONNECTION_STRING: "Data Source=data/simple-bookmark.db;"
+ #HC Vault
+ HC_VAULT_ADDR: ""
+ HC_VAULT_TOKEN: ""
+ #VNCACHE (default to memory only)
+ CACHE_ASM_PATH: "VNLib.Data.Caching.Providers.VNCache.dll"
+ MEMCACHE_ONLY: "true"
+ REDIS_CONNECTION_STRING: ""
+ VNCACHE_INITIAL_NODES: "[]"
+ #ACCOUNTS
+ MAX_LOGIN_ATTEMPS: "10"
+
+ #SECRETS
+ PASSWORD_PEPPER: ""
+ DATABASE_PASSWORD: ""
+ REDIS_PASSWORD: ""
+ VNCACHE_CLIENT_PRIVATE_KEY: ""
+ VNCACHE_CACHE_PUBLIC_KEY: ""
+
+ #HTTP
+ HTTP_DOWNSTREAM_SERVERS: "[]"
+ #SSL_JSON: '{"cert": "ssl/cert.pem", "privkey":"ssl/priv.pem"}'
+
+ SERVER_ARGS: "--input-off"
+
diff --git a/ci/container/run.sh b/ci/container/run.sh
new file mode 100644
index 0000000..2c2636c
--- /dev/null
+++ b/ci/container/run.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+#this script will be invoked by dumb-init in the container on statup and is located at /app
+
+rm -rf config && mkdir config
+
+#substitude all -template files in the config-templates dir and write them to the config dir
+for file in config-templates/*-template.json; do
+ envsubst < $file > config/$(basename $file -template.json).json
+done
+
+cp usr/assets/* plugins/assets/ -rf
+
+#start the server
+dotnet webserver/VNLib.WebServer.dll --config config/config.json $SERVER_ARGS \ No newline at end of file
diff --git a/ci/container/static/routes.xml b/ci/container/static/routes.xml
new file mode 100644
index 0000000..85f9830
--- /dev/null
+++ b/ci/container/static/routes.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<!--Routes container element holds a collection of route elements-->
+<routes>
+ <!--
+ Example route configuration for a single page app
+ where the tree looks like this:
+ / (index.html)
+ /assets (assets directory) (css and js files)
+
+ Wildcard hosts match all hosts that do not have rules with more specific hosts
+ -->
+
+ <!--
+ Allow assets directory to pass through for all requests, using the Continue routine (1)
+
+ Because this route has a more specific path than the catch all route
+ it will be processed first
+ -->
+ <route routine="1" privilege="0">
+
+ <!--Wildcard host-->
+ <hostname>*</hostname>
+
+ <!--All paths that start with /assets/ will be matched-->
+ <path>/assets/*</path>
+ </route>
+
+ <!--Show the index file when navigating to /-->
+ <route routine="4" privilege="0">
+ <hostname>*</hostname>
+ <path>/</path>
+ <alternate>index.html</alternate>
+ </route>
+
+ <!--Redirect all other pages back to the app (homepage)-->
+ <route routine="2" privilege="0">
+ <hostname>*</hostname>
+ <path>/*</path>
+ <alternate>/</alternate>
+ </route>
+
+
+ <!--All routes that do not match will be allowed, this is only / since it does not have a matching rule-->
+
+</routes> \ No newline at end of file
diff --git a/ci/install.taskfile.yaml b/ci/install.taskfile.yaml
new file mode 100644
index 0000000..e1624a3
--- /dev/null
+++ b/ci/install.taskfile.yaml
@@ -0,0 +1,19 @@
+# https://taskfile.dev
+
+#Called by the vnbuild system to produce builds for my website
+#https://www.vaughnnugent.com/resources/software
+
+version: "3"
+
+tasks:
+
+ install:
+ internal: true
+ cmds:
+ #make the plugin directory
+ - cmd: powershell -Command "mkdir {{.DIR}} -Force"
+ ignore_error: true
+ - cd {{.DIR}} && powershell "{{ .PROJECT_DIR }}/install.ps1" -BaseUrl {{.BUILDS_URL}} -ModuleName {{.MODULE_NAME}} -ProjectName {{.PROJECT_NAME}} -FileName {{.FILE_NAME}}
+ - cd {{.DIR}} && tar -xzf {{.FILE_NAME}}
+ #remove the archive file
+ - cd {{.DIR}} && powershell -Command "rm {{.FILE_NAME}}" \ No newline at end of file
diff --git a/ci/plugins.taskfile.yaml b/ci/plugins.taskfile.yaml
index 66641ab..f39121d 100644
--- a/ci/plugins.taskfile.yaml
+++ b/ci/plugins.taskfile.yaml
@@ -5,22 +5,29 @@
version: "3"
+includes:
+ install:
+ taskfile: install.taskfile.yaml
+
vars:
tasks:
all:
+ deps:
+ - install-accounts
+ - install-router
+ - install-sessions
+ - install-vncache
+ - install-vncache-sessions
+ - install-users
+ - install-sqlite
+ - install-argon2-lib
+ - install-compression
+ - install-compressor-lib
+
cmds:
- echo "Installing and configuring plugins and UI"
- - task: install-accounts
- - task: install-router
- - task: install-sessions
- - task: install-vncache
- - task: install-vncache-sessions
- - task: install-users
- - task: install-argon2-lib
- - task: install-compression
- - task: install-compressor-lib
- task: build-bookmarks
build-bookmarks:
@@ -39,7 +46,7 @@ tasks:
install-accounts:
cmds:
#install accounts plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Plugins.Essentials.Accounts'
MODULE_NAME: "Plugins.Essentials"
@@ -49,7 +56,7 @@ tasks:
install-router:
cmds:
#install router plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Plugins.Essentials.Content.Routing'
MODULE_NAME: "Plugins.Essentials"
@@ -59,7 +66,7 @@ tasks:
install-sessions:
cmds:
#install sessions plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'SessionProvider'
MODULE_NAME: "VNLib.Plugins.Sessions"
@@ -69,7 +76,7 @@ tasks:
install-users:
cmds:
#install users plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Plugins.Essentials.Users'
MODULE_NAME: "VNLib.Plugins.Essentials.Users"
@@ -79,7 +86,7 @@ tasks:
install-vncache:
cmds:
#install vncache global cache provider plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Data.Caching.Providers.VNCache'
MODULE_NAME: "VNLib.Data.Caching"
@@ -89,17 +96,27 @@ tasks:
install-vncache-sessions:
cmds:
#install vncache-web-sessions plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Plugins.Sessions.VNCache'
MODULE_NAME: "VNLib.Plugins.Sessions"
FILE_NAME: "release.tgz"
DIR: './plugins/assets/VNLib.Plugins.Sessions.VNCache'
+ install-sqlite:
+ cmds:
+ #install SQLite asset package
+ - task: install:install
+ vars:
+ PROJECT_NAME: 'VNLib.Plugins.Extensions.Loading.Sql.SQLite'
+ MODULE_NAME: "VNLib.Plugins.Extensions"
+ FILE_NAME: "release.tgz"
+ DIR: './plugins/assets/VNLib.Plugins.Extensions.Loading.Sql.SQLite'
+
install-compression:
cmds:
#install compression plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Net.Compression'
MODULE_NAME: "VNLib.Core"
@@ -109,7 +126,7 @@ tasks:
install-compressor-lib:
cmds:
#install compressor plugin
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'vnlib_compress'
MODULE_NAME: "VNLib.Core"
@@ -119,7 +136,7 @@ tasks:
install-argon2-lib:
cmds:
#install the argon2 binary for Windows
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'phc-winner-argon2'
MODULE_NAME: "VNLib.Core"
@@ -127,7 +144,7 @@ tasks:
DIR: './lib/argon2'
#install the argon2 source code package for Linux and Mac
- - task: install-plugin
+ - task: install:install
vars:
PROJECT_NAME: 'phc-winner-argon2'
MODULE_NAME: "VNLib.Core"
@@ -135,23 +152,7 @@ tasks:
DIR: './lib/argon2'
#remove unneeded files
- - cmd: powershell -Command "rm ./lib/argon2/man -Recurse"
- ignore_error: true
- - cmd: powershell -Command "rm ./lib/argon2/latex -Recurse"
- ignore_error: true
- - cmd: powershell -Command "rm ./lib/argon2/kats -Recurse"
- ignore_error: true
- - cmd: powershell -Command "rm ./lib/argon2/argon2-specs.pdf"
- ignore_error: true
- - cmd: powershell -Command "rm ./lib/argon2/package.json"
+ - for: [ man, latex, kats, argon2-specs.pdf, package.json ]
+ cmd: powershell -Command "rm ./lib/argon2/{{.ITEM}} -Recurse"
ignore_error: true
- install-plugin:
- cmds:
- #make the plugin directory
- - cmd: powershell -Command "mkdir {{.DIR}} -Force"
- ignore_error: true
- - cd {{.DIR}} && powershell "{{.USER_WORKING_DIR}}/install.ps1" -BaseUrl {{.BUILDS_URL}} -ModuleName {{.MODULE_NAME}} -ProjectName {{.PROJECT_NAME}} -FileName {{.FILE_NAME}}
- - cd {{.DIR}} && tar -xzf {{.FILE_NAME}}
- #remove the archive file
- - cd {{.DIR}} && powershell -Command "rm {{.FILE_NAME}}" \ No newline at end of file
diff --git a/ci/taskfile.yaml b/ci/taskfile.yaml
index e59e080..1a36e41 100644
--- a/ci/taskfile.yaml
+++ b/ci/taskfile.yaml
@@ -9,9 +9,16 @@ vars:
BUILDS_URL: https://www.vaughnnugent.com/public/resources/software/builds
includes:
+ install:
+ taskfile: install.taskfile.yaml
+
plugins:
taskfile: plugins.taskfile.yaml
+ container:
+ dir: container #always run from the container directory
+ taskfile: container/Taskfile.yaml
+
tasks:
build:
@@ -27,44 +34,37 @@ tasks:
- task: install-plugins
- task: install-webserver
+
+ #run container build last
+ - task: container:build
install-webserver:
cmds:
- #setup env
- - task: create-env
- vars:
- TARGET_OS: win-x64
-
- - task: create-env
- vars:
- TARGET_OS: linux-x64
-
- - task: create-env
- vars:
- TARGET_OS: osx-x64
-
+ - for: [ win-x64, linux-x64, osx-x64 ]
+ task: create-env
+ vars:
+ TARGET_OS: '{{.ITEM}}'
postbuild_success:
cmds:
#make bin dir
- cmd: powershell -Command "mkdir bin -Force"
ignore_error: true
+ - for: [ win-x64, linux-x64, osx-x64 ]
+ task: pack
+ vars:
+ TARGET_OS: '{{.ITEM}}'
- - task: pack
- vars:
- TARGET_OS: win-x64
- - task: pack
- vars:
- TARGET_OS: linux-x64
- - task: pack
- vars:
- TARGET_OS: osx-x64
-
+ - task: container:postbuild_success
install-plugins:
cmds:
#add plugins
- task: plugins:all
+
+ build-container:
+ cmds:
+ - task: container:build
create-env:
vars:
@@ -74,17 +74,9 @@ tasks:
- cmd: powershell -Command "mkdir {{.BUILD_DIR}} -Force"
ignore_error: true
- #copy plugins
- - cmd: powershell -Command "cp -Recurse -Force plugins {{.BUILD_DIR}}"
-
- #copy wwwroot
- - cmd: powershell -Command "cp -Recurse -Force dist {{.BUILD_DIR}}"
-
- #copy libraries
- - cmd: powershell -Command "cp -Recurse -Force lib {{.BUILD_DIR}}"
-
- #copy config
- - cmd: powershell -Command "cp -Recurse -Force config {{.BUILD_DIR}}"
+ #copy build files
+ - for: [ plugins, dist, lib, config ]
+ cmd: powershell -Command "cp -Recurse -Force {{.ITEM}} {{.BUILD_DIR}}"
- task: get-webserver
vars:
@@ -94,27 +86,14 @@ tasks:
get-webserver:
internal: true
cmds:
- - task: install
+ - task: install:install
vars:
PROJECT_NAME: 'VNLib.Webserver'
MODULE_NAME: "VNLib.Webserver"
FILE_NAME: "{{.TARGET_OS}}-release.tgz"
- BUILD_DIR: '{{.BUILD_DIR}}/webserver'
+ DIR: '{{.BUILD_DIR}}/webserver'
- cmd: powershell -Command "cp -Force ./config/config.json {{.BUILD_DIR}}/config.json"
-
- install:
- internal: true
- vars:
- DIR: '"{{.BUILD_DIR}}"'
- cmds:
- #make the plugin directory
- - cmd: powershell -Command "mkdir {{.DIR}} -Force"
- ignore_error: true
- - cd {{.DIR}} && powershell "{{.USER_WORKING_DIR}}/install.ps1" -BaseUrl {{.BUILDS_URL}} -ModuleName {{.MODULE_NAME}} -ProjectName {{.PROJECT_NAME}} -FileName {{.FILE_NAME}}
- - cd {{.DIR}} && tar -xzf {{.FILE_NAME}}
- #remove the tar file
- - cd {{.DIR}} && powershell -Command "rm {{.FILE_NAME}}"
pack:
internal: true
@@ -127,8 +106,7 @@ tasks:
clean:
ignore_error: true
cmds:
- - cmd: powershell -Command "rm -Recurse -Force ./build"
- - cmd: powershell -Command "rm -Recurse -Force ./bin"
- - cmd: powershell -Command "rm -Recurse -Force ./dist"
- - cmd: powershell -Command "rm -Recurse -Force ./plugins"
- - cmd: powershell -Command "rm -Recurse -Force ./lib" \ No newline at end of file
+ - for: [ ./build, ./bin, ./dist, ./plugins, ./lib ]
+ cmd: powershell -Command "rm -Recurse -Force '{{.ITEM}}'"
+
+ - task: container:clean \ No newline at end of file
diff --git a/front-end/package-lock.json b/front-end/package-lock.json
index e5afed6..f35132c 100644
--- a/front-end/package-lock.json
+++ b/front-end/package-lock.json
@@ -10,7 +10,7 @@
"license": "agpl3",
"dependencies": {
"@headlessui/vue": "^1.7.17",
- "@vnuge/vnlib.browser": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/df7dc615532d3441f527374d18664c1a5a336de6/@vnuge-vnlib.browser/release.tgz",
+ "@vnuge/vnlib.browser": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/0d3612601ee2ff42cc72c9a4e29de66ea9cdc3fd/@vnuge-vnlib.browser/release.tgz",
"@vuelidate/core": "^2.0.2",
"@vuelidate/validators": "^2.0.2",
"@vueuse/core": "^10.3.x",
@@ -497,9 +497,9 @@
}
},
"node_modules/@headlessui/vue": {
- "version": "1.7.17",
- "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.17.tgz",
- "integrity": "sha512-hmJChv8HzKorxd9F70RGnECAwZfkvmmwOqreuKLWY/19d5qbWnSdw+DNbuA/Uo6X5rb4U5B3NrT+qBKPmjhRqw==",
+ "version": "1.7.19",
+ "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.19.tgz",
+ "integrity": "sha512-VFjKPybogux/5/QYGSq4zgG/x3RcxId15W8uguAJAjPBxelI23dwjOjTx/mIiMkM/Hd3rzFxcf2aIp56eEWRcA==",
"dependencies": {
"@tanstack/vue-virtual": "^3.0.0-beta.60"
},
@@ -602,9 +602,9 @@
}
},
"node_modules/@jridgewell/resolve-uri": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
- "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"dev": true,
"engines": {
"node": ">=6.0.0"
@@ -686,9 +686,9 @@
}
},
"node_modules/@rollup/rollup-android-arm-eabi": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.6.tgz",
- "integrity": "sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.11.0.tgz",
+ "integrity": "sha512-BV+u2QSfK3i1o6FucqJh5IK9cjAU6icjFFhvknzFgu472jzl0bBojfDAkJLBEsHFMo+YZg6rthBvBBt8z12IBQ==",
"cpu": [
"arm"
],
@@ -699,9 +699,9 @@
]
},
"node_modules/@rollup/rollup-android-arm64": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.6.tgz",
- "integrity": "sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.11.0.tgz",
+ "integrity": "sha512-0ij3iw7sT5jbcdXofWO2NqDNjSVVsf6itcAkV2I6Xsq4+6wjW1A8rViVB67TfBEan7PV2kbLzT8rhOVWLI2YXw==",
"cpu": [
"arm64"
],
@@ -712,9 +712,9 @@
]
},
"node_modules/@rollup/rollup-darwin-arm64": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.6.tgz",
- "integrity": "sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.11.0.tgz",
+ "integrity": "sha512-yPLs6RbbBMupArf6qv1UDk6dzZvlH66z6NLYEwqTU0VHtss1wkI4UYeeMS7TVj5QRVvaNAWYKP0TD/MOeZ76Zg==",
"cpu": [
"arm64"
],
@@ -725,9 +725,9 @@
]
},
"node_modules/@rollup/rollup-darwin-x64": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.6.tgz",
- "integrity": "sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.11.0.tgz",
+ "integrity": "sha512-OvqIgwaGAwnASzXaZEeoJY3RltOFg+WUbdkdfoluh2iqatd090UeOG3A/h0wNZmE93dDew9tAtXgm3/+U/B6bw==",
"cpu": [
"x64"
],
@@ -738,9 +738,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.6.tgz",
- "integrity": "sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.11.0.tgz",
+ "integrity": "sha512-X17s4hZK3QbRmdAuLd2EE+qwwxL8JxyVupEqAkxKPa/IgX49ZO+vf0ka69gIKsaYeo6c1CuwY3k8trfDtZ9dFg==",
"cpu": [
"arm"
],
@@ -751,9 +751,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm64-gnu": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.6.tgz",
- "integrity": "sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.11.0.tgz",
+ "integrity": "sha512-673Lu9EJwxVB9NfYeA4AdNu0FOHz7g9t6N1DmT7bZPn1u6bTF+oZjj+fuxUcrfxWXE0r2jxl5QYMa9cUOj9NFg==",
"cpu": [
"arm64"
],
@@ -764,9 +764,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm64-musl": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.6.tgz",
- "integrity": "sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.11.0.tgz",
+ "integrity": "sha512-yFW2msTAQNpPJaMmh2NpRalr1KXI7ZUjlN6dY/FhWlOclMrZezm5GIhy3cP4Ts2rIAC+IPLAjNibjp1BsxCVGg==",
"cpu": [
"arm64"
],
@@ -777,9 +777,9 @@
]
},
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.6.tgz",
- "integrity": "sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.11.0.tgz",
+ "integrity": "sha512-kKT9XIuhbvYgiA3cPAGntvrBgzhWkGpBMzuk1V12Xuoqg7CI41chye4HU0vLJnGf9MiZzfNh4I7StPeOzOWJfA==",
"cpu": [
"riscv64"
],
@@ -790,9 +790,9 @@
]
},
"node_modules/@rollup/rollup-linux-x64-gnu": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.6.tgz",
- "integrity": "sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.11.0.tgz",
+ "integrity": "sha512-6q4ESWlyTO+erp1PSCmASac+ixaDv11dBk1fqyIuvIUc/CmRAX2Zk+2qK1FGo5q7kyDcjHCFVwgGFCGIZGVwCA==",
"cpu": [
"x64"
],
@@ -803,9 +803,9 @@
]
},
"node_modules/@rollup/rollup-linux-x64-musl": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.6.tgz",
- "integrity": "sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.11.0.tgz",
+ "integrity": "sha512-vIAQUmXeMLmaDN78HSE4Kh6xqof2e3TJUKr+LPqXWU4NYNON0MDN9h2+t4KHrPAQNmU3w1GxBQ/n01PaWFwa5w==",
"cpu": [
"x64"
],
@@ -816,9 +816,9 @@
]
},
"node_modules/@rollup/rollup-win32-arm64-msvc": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.6.tgz",
- "integrity": "sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.11.0.tgz",
+ "integrity": "sha512-LVXo9dDTGPr0nezMdqa1hK4JeoMZ02nstUxGYY/sMIDtTYlli1ZxTXBYAz3vzuuvKO4X6NBETciIh7N9+abT1g==",
"cpu": [
"arm64"
],
@@ -829,9 +829,9 @@
]
},
"node_modules/@rollup/rollup-win32-ia32-msvc": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.6.tgz",
- "integrity": "sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.11.0.tgz",
+ "integrity": "sha512-xZVt6K70Gr3I7nUhug2dN6VRR1ibot3rXqXS3wo+8JP64t7djc3lBFyqO4GiVrhNaAIhUCJtwQ/20dr0h0thmQ==",
"cpu": [
"ia32"
],
@@ -842,9 +842,9 @@
]
},
"node_modules/@rollup/rollup-win32-x64-msvc": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.6.tgz",
- "integrity": "sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.11.0.tgz",
+ "integrity": "sha512-f3I7h9oTg79UitEco9/2bzwdciYkWr8pITs3meSDSlr1TdvQ7IxkQaaYN2YqZXX5uZhiYL+VuYDmHwNzhx+HOg==",
"cpu": [
"x64"
],
@@ -916,9 +916,9 @@
"peer": true
},
"node_modules/@vitejs/plugin-vue": {
- "version": "5.0.3",
- "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.3.tgz",
- "integrity": "sha512-b8S5dVS40rgHdDrw+DQi/xOM9ed+kSRZzfm1T74bMmBDCd8XO87NKlFYInzCtwvtWwXZvo1QxE2OSspTATWrbA==",
+ "version": "5.0.4",
+ "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.4.tgz",
+ "integrity": "sha512-WS3hevEszI6CEVEx28F8RjTX97k3KsrcY6kvTg7+Whm5y3oYvcqzVeGCU3hxSAn4uY2CLCkeokkGKpoctccilQ==",
"dev": true,
"engines": {
"node": "^18.0.0 || >=20.0.0"
@@ -930,8 +930,8 @@
},
"node_modules/@vnuge/vnlib.browser": {
"version": "0.1.13",
- "resolved": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/df7dc615532d3441f527374d18664c1a5a336de6/@vnuge-vnlib.browser/release.tgz",
- "integrity": "sha512-Ddm0cVV4GeNaO5Dd8ycMklswnXBY4L+7gOSu2W1vOOabc8YDaP2XsTaA+xImFVLXj86hQbBTRUUKF9Ebacx+WQ==",
+ "resolved": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/0d3612601ee2ff42cc72c9a4e29de66ea9cdc3fd/@vnuge-vnlib.browser/release.tgz",
+ "integrity": "sha512-3SG6FehSVGo8p6O4XW7KPdWA19oOOQn5XmAnWHN81LqAMPzn4rwOMTICYomIMhDuxddi5v7lnNUrSCihTnWXlw==",
"license": "MIT",
"peerDependencies": {
"@vueuse/core": "^10.x",
@@ -973,55 +973,55 @@
}
},
"node_modules/@vue/compiler-core": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.15.tgz",
- "integrity": "sha512-XcJQVOaxTKCnth1vCxEChteGuwG6wqnUHxAm1DO3gCz0+uXKaJNx8/digSz4dLALCy8n2lKq24jSUs8segoqIw==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.19.tgz",
+ "integrity": "sha512-gj81785z0JNzRcU0Mq98E56e4ltO1yf8k5PQ+tV/7YHnbZkrM0fyFyuttnN8ngJZjbpofWE/m4qjKBiLl8Ju4w==",
"dependencies": {
- "@babel/parser": "^7.23.6",
- "@vue/shared": "3.4.15",
+ "@babel/parser": "^7.23.9",
+ "@vue/shared": "3.4.19",
"entities": "^4.5.0",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
}
},
"node_modules/@vue/compiler-dom": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.15.tgz",
- "integrity": "sha512-wox0aasVV74zoXyblarOM3AZQz/Z+OunYcIHe1OsGclCHt8RsRm04DObjefaI82u6XDzv+qGWZ24tIsRAIi5MQ==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.19.tgz",
+ "integrity": "sha512-vm6+cogWrshjqEHTzIDCp72DKtea8Ry/QVpQRYoyTIg9k7QZDX6D8+HGURjtmatfgM8xgCFtJJaOlCaRYRK3QA==",
"dependencies": {
- "@vue/compiler-core": "3.4.15",
- "@vue/shared": "3.4.15"
+ "@vue/compiler-core": "3.4.19",
+ "@vue/shared": "3.4.19"
}
},
"node_modules/@vue/compiler-sfc": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.15.tgz",
- "integrity": "sha512-LCn5M6QpkpFsh3GQvs2mJUOAlBQcCco8D60Bcqmf3O3w5a+KWS5GvYbrrJBkgvL1BDnTp+e8q0lXCLgHhKguBA==",
- "dependencies": {
- "@babel/parser": "^7.23.6",
- "@vue/compiler-core": "3.4.15",
- "@vue/compiler-dom": "3.4.15",
- "@vue/compiler-ssr": "3.4.15",
- "@vue/shared": "3.4.15",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.19.tgz",
+ "integrity": "sha512-LQ3U4SN0DlvV0xhr1lUsgLCYlwQfUfetyPxkKYu7dkfvx7g3ojrGAkw0AERLOKYXuAGnqFsEuytkdcComei3Yg==",
+ "dependencies": {
+ "@babel/parser": "^7.23.9",
+ "@vue/compiler-core": "3.4.19",
+ "@vue/compiler-dom": "3.4.19",
+ "@vue/compiler-ssr": "3.4.19",
+ "@vue/shared": "3.4.19",
"estree-walker": "^2.0.2",
- "magic-string": "^0.30.5",
+ "magic-string": "^0.30.6",
"postcss": "^8.4.33",
"source-map-js": "^1.0.2"
}
},
"node_modules/@vue/compiler-ssr": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.15.tgz",
- "integrity": "sha512-1jdeQyiGznr8gjFDadVmOJqZiLNSsMa5ZgqavkPZ8O2wjHv0tVuAEsw5hTdUoUW4232vpBbL/wJhzVW/JwY1Uw==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.19.tgz",
+ "integrity": "sha512-P0PLKC4+u4OMJ8sinba/5Z/iDT84uMRRlrWzadgLA69opCpI1gG4N55qDSC+dedwq2fJtzmGald05LWR5TFfLw==",
"dependencies": {
- "@vue/compiler-dom": "3.4.15",
- "@vue/shared": "3.4.15"
+ "@vue/compiler-dom": "3.4.19",
+ "@vue/shared": "3.4.19"
}
},
"node_modules/@vue/devtools-api": {
- "version": "6.5.1",
- "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.5.1.tgz",
- "integrity": "sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA=="
+ "version": "6.6.1",
+ "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.1.tgz",
+ "integrity": "sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA=="
},
"node_modules/@vue/language-core": {
"version": "1.8.27",
@@ -1073,48 +1073,48 @@
}
},
"node_modules/@vue/reactivity": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.15.tgz",
- "integrity": "sha512-55yJh2bsff20K5O84MxSvXKPHHt17I2EomHznvFiJCAZpJTNW8IuLj1xZWMLELRhBK3kkFV/1ErZGHJfah7i7w==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.19.tgz",
+ "integrity": "sha512-+VcwrQvLZgEclGZRHx4O2XhyEEcKaBi50WbxdVItEezUf4fqRh838Ix6amWTdX0CNb/b6t3Gkz3eOebfcSt+UA==",
"dependencies": {
- "@vue/shared": "3.4.15"
+ "@vue/shared": "3.4.19"
}
},
"node_modules/@vue/runtime-core": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.15.tgz",
- "integrity": "sha512-6E3by5m6v1AkW0McCeAyhHTw+3y17YCOKG0U0HDKDscV4Hs0kgNT5G+GCHak16jKgcCDHpI9xe5NKb8sdLCLdw==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.19.tgz",
+ "integrity": "sha512-/Z3tFwOrerJB/oyutmJGoYbuoadphDcJAd5jOuJE86THNZji9pYjZroQ2NFsZkTxOq0GJbb+s2kxTYToDiyZzw==",
"dependencies": {
- "@vue/reactivity": "3.4.15",
- "@vue/shared": "3.4.15"
+ "@vue/reactivity": "3.4.19",
+ "@vue/shared": "3.4.19"
}
},
"node_modules/@vue/runtime-dom": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.15.tgz",
- "integrity": "sha512-EVW8D6vfFVq3V/yDKNPBFkZKGMFSvZrUQmx196o/v2tHKdwWdiZjYUBS+0Ez3+ohRyF8Njwy/6FH5gYJ75liUw==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.19.tgz",
+ "integrity": "sha512-IyZzIDqfNCF0OyZOauL+F4yzjMPN2rPd8nhqPP2N1lBn3kYqJpPHHru+83Rkvo2lHz5mW+rEeIMEF9qY3PB94g==",
"dependencies": {
- "@vue/runtime-core": "3.4.15",
- "@vue/shared": "3.4.15",
+ "@vue/runtime-core": "3.4.19",
+ "@vue/shared": "3.4.19",
"csstype": "^3.1.3"
}
},
"node_modules/@vue/server-renderer": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.15.tgz",
- "integrity": "sha512-3HYzaidu9cHjrT+qGUuDhFYvF/j643bHC6uUN9BgM11DVy+pM6ATsG6uPBLnkwOgs7BpJABReLmpL3ZPAsUaqw==",
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.19.tgz",
+ "integrity": "sha512-eAj2p0c429RZyyhtMRnttjcSToch+kTWxFPHlzGMkR28ZbF1PDlTcmGmlDxccBuqNd9iOQ7xPRPAGgPVj+YpQw==",
"dependencies": {
- "@vue/compiler-ssr": "3.4.15",
- "@vue/shared": "3.4.15"
+ "@vue/compiler-ssr": "3.4.19",
+ "@vue/shared": "3.4.19"
},
"peerDependencies": {
- "vue": "3.4.15"
+ "vue": "3.4.19"
}
},
"node_modules/@vue/shared": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.15.tgz",
- "integrity": "sha512-KzfPTxVaWfB+eGcGdbSf4CWdaXcGDqckoeXUh7SB3fZdEtzPCK2Vq9B/lRRL3yutax/LWITz+SwvgyOxz5V75g=="
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.19.tgz",
+ "integrity": "sha512-/KliRRHMF6LoiThEy+4c1Z4KB/gbPrGjWwJR+crg2otgrf/egKzRaCPvJ51S5oetgsgXLfc4Rm5ZgrKHZrtMSw=="
},
"node_modules/@vuelidate/core": {
"version": "2.0.3",
@@ -1471,9 +1471,9 @@
}
},
"node_modules/browserslist": {
- "version": "4.22.3",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.3.tgz",
- "integrity": "sha512-UAp55yfwNv0klWNapjs/ktHoguxuQNGnOzxYmfnXIS+8AsRDZkSDxg7R1AX3GKzn078SBI5dzwzj/Yx0Or0e3A==",
+ "version": "4.23.0",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz",
+ "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==",
"dev": true,
"funding": [
{
@@ -1490,8 +1490,8 @@
}
],
"dependencies": {
- "caniuse-lite": "^1.0.30001580",
- "electron-to-chromium": "^1.4.648",
+ "caniuse-lite": "^1.0.30001587",
+ "electron-to-chromium": "^1.4.668",
"node-releases": "^2.0.14",
"update-browserslist-db": "^1.0.13"
},
@@ -1521,9 +1521,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001583",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001583.tgz",
- "integrity": "sha512-acWTYaha8xfhA/Du/z4sNZjHUWjkiuoAi2LM+T/aL+kemKQgPT1xBb/YKjlQ0Qo8gvbHsGNplrEJ+9G3gL7i4Q==",
+ "version": "1.0.30001587",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz",
+ "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==",
"dev": true,
"funding": [
{
@@ -1557,16 +1557,10 @@
}
},
"node_modules/chokidar": {
- "version": "3.5.3",
- "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
- "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"dev": true,
- "funding": [
- {
- "type": "individual",
- "url": "https://paulmillr.com/funding/"
- }
- ],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
@@ -1579,6 +1573,9 @@
"engines": {
"node": ">= 8.10.0"
},
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ },
"optionalDependencies": {
"fsevents": "~2.3.2"
}
@@ -1742,15 +1739,15 @@
}
},
"node_modules/dotenv": {
- "version": "16.4.1",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz",
- "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==",
+ "version": "16.4.4",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.4.tgz",
+ "integrity": "sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
- "url": "https://github.com/motdotla/dotenv?sponsor=1"
+ "url": "https://dotenvx.com"
}
},
"node_modules/eastasianwidth": {
@@ -1760,9 +1757,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
- "version": "1.4.656",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.656.tgz",
- "integrity": "sha512-9AQB5eFTHyR3Gvt2t/NwR0le2jBSUNwCnMbUCejFWHD+so4tH40/dRLgoE+jxlPeWS43XJewyvCv+I8LPMl49Q==",
+ "version": "1.4.671",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.671.tgz",
+ "integrity": "sha512-UUlE+/rWbydmp+FW8xlnnTA5WNA0ZZd2XL8CuMS72rh+k4y1f8+z6yk3UQhEwqHQWj6IBdL78DwWOdGMvYfQyA==",
"dev": true
},
"node_modules/emoji-regex": {
@@ -1821,9 +1818,9 @@
}
},
"node_modules/escalade": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
- "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
+ "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
"dev": true,
"engines": {
"node": ">=6"
@@ -2029,9 +2026,9 @@
"peer": true
},
"node_modules/fastq": {
- "version": "1.17.0",
- "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.0.tgz",
- "integrity": "sha512-zGygtijUMT7jnk3h26kUms3BkSDp4IfIKjmnqI2tvx6nuBfiF1UqOxbnLfzdv+apBy+53oaImsKtMw/xYbW+1w==",
+ "version": "1.17.1",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
+ "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
"dependencies": {
"reusify": "^1.0.4"
}
@@ -2097,9 +2094,9 @@
"peer": true
},
"node_modules/flowbite": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/flowbite/-/flowbite-2.2.1.tgz",
- "integrity": "sha512-iiZyBTtriEDRHrqXZgpKHaxl4B2J8HZUP8Yn1RXozUDKszWHDVj4GxQqMMB9AJHRWOgXV/4E/LJZ/zqQgBUhWA==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/flowbite/-/flowbite-2.3.0.tgz",
+ "integrity": "sha512-pm3JRo8OIJHGfFYWgaGpPv8E+UdWy0Z3gEAGufw+G/1dusaU/P1zoBLiQpf2/+bYAi+GBQtPVG86KYlV0W+AFQ==",
"dependencies": {
"@popperjs/core": "^2.9.3",
"mini-svg-data-uri": "^1.4.3"
@@ -2257,9 +2254,9 @@
}
},
"node_modules/hasown": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
- "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
+ "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.2"
@@ -2436,9 +2433,9 @@
}
},
"node_modules/jose": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/jose/-/jose-5.2.0.tgz",
- "integrity": "sha512-oW3PCnvyrcm1HMvGTzqjxxfnEs9EoFOFWi2HsEGhlFVOXxTE3K9GKWVMFoFw06yPUqwpvEWic1BmtUZBI/tIjw==",
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-5.2.2.tgz",
+ "integrity": "sha512-/WByRr4jDcsKlvMd1dRJnPfS1GVO3WuKyaurJ/vvXcOaUQO8rnNObCQMlv/5uCceVQIq5Q4WLF44ohsdiTohdg==",
"funding": {
"url": "https://github.com/sponsors/panva"
}
@@ -2563,9 +2560,9 @@
}
},
"node_modules/magic-string": {
- "version": "0.30.6",
- "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.6.tgz",
- "integrity": "sha512-n62qCLbPjNjyo+owKtveQxZFZTBm+Ms6YoGD23Wew6Vw337PElFNifQpknPruVRQV57kVShPnLGo9vWxVhpPvA==",
+ "version": "0.30.7",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.7.tgz",
+ "integrity": "sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
},
@@ -2958,9 +2955,9 @@
}
},
"node_modules/postcss": {
- "version": "8.4.33",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz",
- "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==",
+ "version": "8.4.35",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz",
+ "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==",
"funding": [
{
"type": "opencollective",
@@ -3056,12 +3053,15 @@
}
},
"node_modules/postcss-load-config/node_modules/lilconfig": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.0.0.tgz",
- "integrity": "sha512-K2U4W2Ff5ibV7j7ydLr+zLAkIg5JJ4lPn1Ltsdt+Tz/IjQ8buJ55pZAxoP34lqIiwtF9iAvtLv3JGv7CAyAg+g==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.0.tgz",
+ "integrity": "sha512-p3cz0JV5vw/XeouBU3Ldnp+ZkBjE+n8ydJ4mcwBrOiXXPqNlrzGBqWs9X4MWF7f+iKUBu794Y8Hh8yawiJbCjw==",
"dev": true,
"engines": {
"node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/antonk52"
}
},
"node_modules/postcss-nested": {
@@ -3224,9 +3224,9 @@
}
},
"node_modules/rollup": {
- "version": "4.9.6",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.9.6.tgz",
- "integrity": "sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==",
+ "version": "4.11.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.11.0.tgz",
+ "integrity": "sha512-2xIbaXDXjf3u2tajvA5xROpib7eegJ9Y/uPlSFhXLNpK9ampCczXAhLEb5yLzJyG3LAdI1NWtNjDXiLyniNdjQ==",
"dev": true,
"dependencies": {
"@types/estree": "1.0.5"
@@ -3239,19 +3239,19 @@
"npm": ">=8.0.0"
},
"optionalDependencies": {
- "@rollup/rollup-android-arm-eabi": "4.9.6",
- "@rollup/rollup-android-arm64": "4.9.6",
- "@rollup/rollup-darwin-arm64": "4.9.6",
- "@rollup/rollup-darwin-x64": "4.9.6",
- "@rollup/rollup-linux-arm-gnueabihf": "4.9.6",
- "@rollup/rollup-linux-arm64-gnu": "4.9.6",
- "@rollup/rollup-linux-arm64-musl": "4.9.6",
- "@rollup/rollup-linux-riscv64-gnu": "4.9.6",
- "@rollup/rollup-linux-x64-gnu": "4.9.6",
- "@rollup/rollup-linux-x64-musl": "4.9.6",
- "@rollup/rollup-win32-arm64-msvc": "4.9.6",
- "@rollup/rollup-win32-ia32-msvc": "4.9.6",
- "@rollup/rollup-win32-x64-msvc": "4.9.6",
+ "@rollup/rollup-android-arm-eabi": "4.11.0",
+ "@rollup/rollup-android-arm64": "4.11.0",
+ "@rollup/rollup-darwin-arm64": "4.11.0",
+ "@rollup/rollup-darwin-x64": "4.11.0",
+ "@rollup/rollup-linux-arm-gnueabihf": "4.11.0",
+ "@rollup/rollup-linux-arm64-gnu": "4.11.0",
+ "@rollup/rollup-linux-arm64-musl": "4.11.0",
+ "@rollup/rollup-linux-riscv64-gnu": "4.11.0",
+ "@rollup/rollup-linux-x64-gnu": "4.11.0",
+ "@rollup/rollup-linux-x64-musl": "4.11.0",
+ "@rollup/rollup-win32-arm64-msvc": "4.11.0",
+ "@rollup/rollup-win32-ia32-msvc": "4.11.0",
+ "@rollup/rollup-win32-x64-msvc": "4.11.0",
"fsevents": "~2.3.2"
}
},
@@ -3295,9 +3295,9 @@
}
},
"node_modules/semver": {
- "version": "7.5.4",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
- "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
+ "version": "7.6.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
+ "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -3723,13 +3723,13 @@
"dev": true
},
"node_modules/vite": {
- "version": "5.0.12",
- "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz",
- "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==",
+ "version": "5.1.3",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.1.3.tgz",
+ "integrity": "sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==",
"dev": true,
"dependencies": {
"esbuild": "^0.19.3",
- "postcss": "^8.4.32",
+ "postcss": "^8.4.35",
"rollup": "^4.2.0"
},
"bin": {
@@ -3778,15 +3778,15 @@
}
},
"node_modules/vue": {
- "version": "3.4.15",
- "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.15.tgz",
- "integrity": "sha512-jC0GH4KkWLWJOEQjOpkqU1bQsBwf4R1rsFtw5GQJbjHVKWDzO6P0nWWBTmjp1xSemAioDFj1jdaK1qa3DnMQoQ==",
- "dependencies": {
- "@vue/compiler-dom": "3.4.15",
- "@vue/compiler-sfc": "3.4.15",
- "@vue/runtime-dom": "3.4.15",
- "@vue/server-renderer": "3.4.15",
- "@vue/shared": "3.4.15"
+ "version": "3.4.19",
+ "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.19.tgz",
+ "integrity": "sha512-W/7Fc9KUkajFU8dBeDluM4sRGc/aa4YJnOYck8dkjgZoXtVsn3OeTGni66FV1l3+nvPA7VBFYtPioaGKUmEADw==",
+ "dependencies": {
+ "@vue/compiler-dom": "3.4.19",
+ "@vue/compiler-sfc": "3.4.19",
+ "@vue/runtime-dom": "3.4.19",
+ "@vue/server-renderer": "3.4.19",
+ "@vue/shared": "3.4.19"
},
"peerDependencies": {
"typescript": "*"
diff --git a/front-end/package.json b/front-end/package.json
index fabf4ff..740807a 100644
--- a/front-end/package.json
+++ b/front-end/package.json
@@ -18,7 +18,7 @@
},
"dependencies": {
"@headlessui/vue": "^1.7.17",
- "@vnuge/vnlib.browser": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/df7dc615532d3441f527374d18664c1a5a336de6/@vnuge-vnlib.browser/release.tgz",
+ "@vnuge/vnlib.browser": "https://www.vaughnnugent.com/public/resources/software/builds/Plugins.Essentials/0d3612601ee2ff42cc72c9a4e29de66ea9cdc3fd/@vnuge-vnlib.browser/release.tgz",
"@vuelidate/core": "^2.0.2",
"@vuelidate/validators": "^2.0.2",
"@vueuse/core": "^10.3.x",
diff --git a/front-end/src/App.vue b/front-end/src/App.vue
index 01e91e7..4bd94c8 100644
--- a/front-end/src/App.vue
+++ b/front-end/src/App.vue
@@ -1,8 +1,7 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useStore, TabId } from './store';
-import { defineAsyncComponent } from 'vue';
-import { apiCall } from '@vnuge/vnlib.browser';
+import { computed, defineAsyncComponent } from 'vue';
import { isEqual } from 'lodash-es';
import { useDark } from '@vueuse/core';
import SideMenuItem from './components/SideMenuItem.vue';
@@ -12,6 +11,7 @@ const Settings = defineAsyncComponent(() => import('./components/Settings.vue'))
const Confirm = defineAsyncComponent(() => import('./components/global/ConfirmPrompt.vue'));
const Alerts = defineAsyncComponent(() => import('./components/Alerts.vue'));
const Login = defineAsyncComponent(() => import('./components/Login.vue'));
+const Registation = defineAsyncComponent(() => import('./components/Registation.vue'));
const PasswordPrompt = defineAsyncComponent(() => import('./components/global/PasswordPrompt.vue'));
const store = useStore();
@@ -20,12 +20,7 @@ const darkMode = useDark()
store.setSiteTitle('Simple Bookmark')
-const logout = () => {
- apiCall(async () => {
- const { logout } = await store.socialOauth()
- await logout()
- })
-}
+const isSetupMode = computed(() => store.registation.status?.setup_mode === true)
const showIf = (tabId: TabId, active: TabId) => isEqual(tabId, active)
@@ -39,7 +34,7 @@ const showIf = (tabId: TabId, active: TabId) => isEqual(tabId, active)
<div id="app" class="min-h-screen pb-16 text-gray-700 bg-gray-50 dark:bg-gray-900 dark:text-white sm:pb-0">
<div class="relative">
- <div class="absolute z-50 right-10 top-10">
+ <div class="fixed z-50 right-10 top-10">
<Alerts />
</div>
</div>
@@ -47,7 +42,7 @@ const showIf = (tabId: TabId, active: TabId) => isEqual(tabId, active)
<Confirm />
<PasswordPrompt />
- <aside id="logo-sidebar" class="fixed top-0 left-0 z-10 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0" aria-label="Sidebar">
+ <aside id="logo-sidebar" class="fixed top-0 left-0 z-20 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0" aria-label="Sidebar">
<div class="flex flex-col h-full px-3 py-4 overflow-y-auto bg-white dark:bg-gray-800">
<div class="flex-auto">
<a href="/" class="flex items-center ps-2.5 mb-5">
@@ -106,7 +101,14 @@ const showIf = (tabId: TabId, active: TabId) => isEqual(tabId, active)
</div>
</aside>
+ <div v-if="isSetupMode" class="relative mb-16 sm:mb-10">
+ <div class="fixed top-0 z-10 w-full p-2 text-center text-white bg-amber-600">
+ Setup mode is enabled. Restart the server without --setup flag to disable this warning
+ </div>
+ </div>
+
<div class="h-full py-6 md:p-6 sm:ml-64">
+
<div v-if="showIf(TabId.Bookmarks, activeTab)" class="flex flex-col w-full h-full">
<Bookmarks />
</div>
@@ -118,6 +120,10 @@ const showIf = (tabId: TabId, active: TabId) => isEqual(tabId, active)
<div v-if="showIf(TabId.Settings, activeTab)" class="flex w-full h-full">
<Settings />
</div>
+
+ <div v-if="showIf(TabId.Register, activeTab)" class="flex w-full h-full">
+ <Registation/>
+ </div>
</div>
<div class="fixed bottom-0 left-0 z-50 w-full h-16 bg-white border-t border-gray-200 sm:hidden dark:bg-gray-700 dark:border-gray-600">
diff --git a/front-end/src/components/Bookmarks.vue b/front-end/src/components/Bookmarks.vue
index 93ddd73..cc3cd6a 100644
--- a/front-end/src/components/Bookmarks.vue
+++ b/front-end/src/components/Bookmarks.vue
@@ -5,10 +5,10 @@ import { get, set, formatTimeAgo, useToggle, useTimestamp, useFileDialog, asyncC
import { useVuelidate } from '@vuelidate/core';
import { required, maxLength, minLength, helpers } from '@vuelidate/validators';
import { apiCall, useConfirm, useGeneralToaster, useVuelidateWrapper, useWait } from '@vnuge/vnlib.browser';
-import { clone, cloneDeep, join, defaultTo, every, filter, includes, isEmpty, isEqual, first, isString, chunk, map, forEach } from 'lodash-es';
+import { clone, cloneDeep, join, defaultTo, every, filter, includes, isEmpty, isEqual, first, isString, chunk, map, forEach, isNil } from 'lodash-es';
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
import { parseNetscapeBookmarkString } from './Boomarks/util.ts';
-import type { Bookmark, BookmarkError } from '../store/bookmarks';
+import type { BatchUploadResult, Bookmark, BookmarkError } from '../store/bookmarks';
import AddOrUpdateForm from './Boomarks/AddOrUpdateForm.vue';
const Dialog = defineAsyncComponent(() => import('./global/Dialog.vue'));
@@ -27,7 +27,7 @@ const { copy } = useClipboard()
//Refresh on page load
store.bookmarks.refresh();
-const safeNameRegex = /^[a-zA-Z0-9_\-\|\. ]*$/;
+const safeNameRegex = /^[a-zA-Z0-9_\-\|\., ]*$/;
const safeUrlRegex = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
const safeTagRegex = /^[a-zA-Z0-9-_]*$/;
@@ -38,19 +38,19 @@ const addOrEditValidator = (buffer: Ref<Partial<Bookmark>>) => {
required: helpers.withMessage('Name cannot be empty', required),
safeName: helpers.withMessage('Bookmark name contains illegal characters', (value: string) => safeNameRegex.test(value)),
minLength: helpers.withMessage('Name must be at least 1 characters', minLength(1)),
- maxLength: helpers.withMessage('Name must have less than 100 characters', maxLength(100))
+ maxLength: helpers.withMessage('Name must have less than 200 characters', maxLength(200))
},
Url: {
required: helpers.withMessage('Url cannot be empty', required),
safeUrl: helpers.withMessage('Url contains illegal characters or is not a valid URL', (value: string) => safeUrlRegex.test(value)),
minLength: helpers.withMessage('Url must be at least 1 characters', minLength(1)),
- maxLength: helpers.withMessage('Url must have less than 200 characters', maxLength(200))
+ maxLength: helpers.withMessage('Url must have less than 300 characters', maxLength(300))
},
Description: {
- maxLength: helpers.withMessage('Description must have less than 512 characters', maxLength(512))
+ maxLength: helpers.withMessage('Description must have less than 500 characters', maxLength(500))
},
Tags: {
- maxLength: helpers.withMessage('Tags must have less than 32 characters', (tags: string[]) => every(tags, tag => tag.length < 32)),
+ maxLength: helpers.withMessage('Tags must have less than 64 characters', (tags: string[]) => every(tags, tag => tag.length < 64)),
safeTag: helpers.withMessage('Tags contains illegal characters', (tags: string[]) => every(tags, tag => safeTagRegex.test(tag)))
}
}));
@@ -99,6 +99,7 @@ const bmDelete = async (bookmark: Bookmark) => {
const isTagSelected = (tag: string, currentTags: MaybeRef<string[]>) => includes(get(currentTags), tag);
const execSearch = () => store.bookmarks.query = get(localSearch);
+const clearTags = () => store.bookmarks.tags = [];
const percentToWith = (percent: number) => ({ width: `${percent}%` });
const printErroMessage = (error: BookmarkError) => {
const errorMessages = map(error.errors, e=> e.message);
@@ -262,22 +263,39 @@ const upload = (() => {
const bms = get(foundBookmarks);
if(get(fixErrors)){
- //try to fix names
- forEach(bms, bm => {
- //If the name is not safe, replace all illegal characters
- if(!safeNameRegex.test(bm.Name)){
- bm.Name = bm.Name.replace(/[^a-zA-Z0-9_\-\|\. ]/g, ' ');
- }
- })
//truncate name length
forEach(bms, bm => {
if(bm.Name.length > 100){
- bm.Name = bm.Name.substring(0, 100);
+ bm.Name = bm.Name.substring(0, 199);
+ }
+
+ //Replace illegal characters from name strings
+ bm.Name = bm.Name.replace(/[^a-zA-Z0-9_\-\|\., ]/g, ' ');
+
+ if(!isNil(bm.Description)){
+ //truncate description
+ if (bm.Description.length > 500) {
+ bm.Description = bm.Description.substring(0, 499);
+ }
+
+ bm.Description = bm.Description.replace(/[^\x00-\x7F]/g, ''); //only allow utf-8 characters
}
+
+ //Try to remove illegal chars from tags
+ bm.Tags = map(bm.Tags, tag => tag.replace(/[^a-zA-Z0-9\-]/g, ''));
})
}
+ forEach(bms, bm => {
+ //Remove any empty tags
+ bm.Tags = filter(bm.Tags, tag => tag?.length > 0);
+
+ if(isEmpty(bm.Tags)){
+ (bm.Tags as any) = null;
+ }
+ })
+
const chunks = chunk(bms, 20);
for(let i = 0; i < chunks.length; i++){
@@ -290,9 +308,18 @@ const upload = (() => {
//See if an error occured
if(!isString(result) && 'invalid' in result){
+ const { message, invalid } = result as BatchUploadResult;
+
//add errors to the error list
- errors.value.push(...result.invalid);
+ errors.value.push(...invalid);
isError = true;
+
+ if(message){
+ toaster.error({
+ title: `Batch ${i} upload failed due to an error`,
+ text: message
+ })
+ }
}
if(isError){
@@ -382,14 +409,14 @@ const upload = (() => {
<MenuItems class="absolute z-10 bg-white divide-y divide-gray-100 rounded-b shadow right-2 lg:left-0 min-w-32 lg:end-0 dark:bg-gray-700">
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton">
<!-- Use the `active` state to conditionally style the active item. -->
- <MenuItem as="template" v-slot="{ active }">
+ <MenuItem as="template" v-slot="{ }">
<li>
<button @click="add.open()" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Manual
</button>
</li>
</MenuItem>
- <MenuItem as="template" v-slot="{ active }">
+ <MenuItem as="template" v-slot="{ }">
<li>
<button @click="upload.open()" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Upload html
@@ -402,7 +429,7 @@ const upload = (() => {
</Menu>
</div>
</div>
- <div class="grid flex-auto grid-cols-4 gap-8 mt-4 max-w-[60rem] mx-auto w-full">
+ <div class="grid flex-auto grid-cols-4 gap-8 sm:mt-4 max-w-[60rem] mx-auto w-full">
<div class="col-span-4 lg:col-span-3">
@@ -414,7 +441,7 @@ const upload = (() => {
<span class="sr-only">Loading...</span>
</div>
- <div class="mx-auto mt-2">
+ <div class="mx-auto sm:mt-2">
<div class="grid h-full grid-cols-1 gap-1 leading-tight md:leading-normal">
<div v-for="bm in bookmarks" :key="bm.Id" :id="join(['bm', bm.Id], '-')" class="w-full p-1">
@@ -476,7 +503,15 @@ const upload = (() => {
</div>
</div>
<div class="hidden lg:block">
- <div class="mt-10">
+ <div class="h-10">
+ <div class="ml-12">
+ <button :disabled="isEmpty(selectedTags)" @click="clearTags()"
+ class="text-sm font-bold text-gray-600 duration-75 ease-linear disabled:opacity-0 hover:underline">
+ Clear Tags
+ </button>
+ </div>
+ </div>
+ <div class="mt-1">
<ul class="grid grid-cols-2">
<li v-for="tag in tags" :key="tag" class="text-sm">
<span
diff --git a/front-end/src/components/Login.vue b/front-end/src/components/Login.vue
index eeda1ba..3022940 100644
--- a/front-end/src/components/Login.vue
+++ b/front-end/src/components/Login.vue
@@ -1,15 +1,19 @@
<script setup lang="ts">
+import { computed, defineAsyncComponent } from 'vue'
import { apiCall, useWait } from '@vnuge/vnlib.browser'
import { storeToRefs } from 'pinia'
import { useStore } from '../store'
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from '@headlessui/vue'
import UserPass from './Login/UserPass.vue'
import PkiLogin from './Login/PkiLogin.vue'
+const AdminReg = defineAsyncComponent(() => import('./Login/AdminReg.vue'))
const { waiting } = useWait();
const store = useStore();
const { loggedIn, siteTitle } = storeToRefs(store);
+const adminRegEnabled = computed(() => store.registation.status?.enabled && store.registation.status?.setup_mode);
+
const logout = () => {
apiCall(async () => {
const { logout } = await store.socialOauth()
@@ -20,7 +24,7 @@ const logout = () => {
</script>
<template>
<section id="login-page" class="flex-auto">
- <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto lg:py-24">
+ <div class="flex flex-col items-center justify-center px-2 py-8 mx-auto sm:px-6 lg:py-24">
<div class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
<span class="p-2 mr-2 bg-blue-500 rounded-full">
<svg class="w-5 h-5 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 14 20">
@@ -35,11 +39,19 @@ const logout = () => {
<div v-if="!loggedIn">
<!-- password/username login -->
<h1 class="text-xl font-bold leading-tight tracking-tight text-center text-gray-900 md:text-2xl dark:text-white">
- Sign in to your account
+ {{ adminRegEnabled ? "Create admin account" : "Sign in to your account" }}
</h1>
- <TabGroup class="w-full" as="div">
+ <TabGroup class="w-full" as="div">
<TabList as="ul" class="flex flex-wrap justify-center -mb-px text-sm font-medium text-center text-gray-500 dark:text-gray-400">
+ <Tab v-if="adminRegEnabled" as="template" v-slot="{ selected }" class="cursor-pointer me-2">
+ <div class="tab group" :class="{ selected }">
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
+ <path d="M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z"/>
+ </svg>
+ Create
+ </div>
+ </Tab>
<Tab as="template" v-slot="{ selected }" class="cursor-pointer me-2">
<div class="tab group" :class="{ selected }">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
@@ -58,6 +70,9 @@ const logout = () => {
</Tab>
</TabList>
<TabPanels class="mt-4" as="div">
+ <TabPanel v-if="adminRegEnabled" :unmount="false">
+ <AdminReg />
+ </TabPanel>
<TabPanel :unmount="false">
<UserPass />
</TabPanel>
diff --git a/front-end/src/components/Login/AdminReg.vue b/front-end/src/components/Login/AdminReg.vue
new file mode 100644
index 0000000..8546512
--- /dev/null
+++ b/front-end/src/components/Login/AdminReg.vue
@@ -0,0 +1,84 @@
+<script setup lang="ts">
+import { reactive, computed } from 'vue'
+import { useVuelidate } from '@vuelidate/core'
+import { required, maxLength, minLength, email, helpers } from '@vuelidate/validators'
+import { useVuelidateWrapper, apiCall, useWait } from '@vnuge/vnlib.browser'
+import { useStore } from '../../store'
+
+const { waiting } = useWait();
+const store = useStore();
+
+const vState = reactive({ username: '', password: '', repeat: ''})
+
+const rules = computed(() =>({
+ username: {
+ required: helpers.withMessage('Email cannot be empty', required),
+ email: helpers.withMessage('Your email address is not valid', email),
+ maxLength: helpers.withMessage('Email address must be less than 50 characters', maxLength(50))
+ },
+ password: {
+ required: helpers.withMessage('Password cannot be empty', required),
+ minLength: helpers.withMessage('Password must be at least 8 characters', minLength(8)),
+ maxLength: helpers.withMessage('Password must have less than 128 characters', maxLength(128))
+ },
+ repeat:{
+ required: helpers.withMessage('Password cannot be empty', required),
+ minLength: helpers.withMessage('Password must be at least 8 characters', minLength(8)),
+ maxLength: helpers.withMessage('Password must have less than 128 characters', maxLength(128)),
+ match: helpers.withMessage('Passwords must match', (value: string) => value === vState.password)
+ }
+}));
+
+const v$ = useVuelidate(rules, vState)
+const { validate } = useVuelidateWrapper(v$ as any);
+
+const onSubmit = async () => {
+
+ // If the form is not valid set the error message
+ if (!await validate()) {
+ return
+ }
+
+ // Run login in an apicall wrapper
+ await apiCall(async ({ toaster }) => {
+
+ const res = await store.registation.api.registerAdmin(
+ v$.value.username.$model,
+ v$.value.password.$model
+ );
+
+ const message = res.getResultOrThrow();
+
+ toaster.general.success({
+ title: 'Success!',
+ text: message
+ })
+ })
+}
+</script>
+
+<template>
+ <form class="space-y-4 md:space-y-6" id="admin-registation" action="#" @submit.prevent="onSubmit" :disabled="waiting">
+ <fieldset>
+ <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Email</label>
+ <input type="email" name="email" id="email" class="input" placeholder="name@company.com" required
+ v-model="v$.username.$model">
+ </fieldset>
+ <fieldset>
+ <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
+ <input type="password" name="password" id="password" class="input" placeholder="••••••••" required
+ v-model="v$.password.$model">
+ </fieldset>
+ <fieldset>
+ <label for="repeat-password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Repeat Password</label>
+ <input type="password" name="repeat-password" id="repeat-password" class="input" placeholder="••••••••" required
+ v-model="v$.repeat.$model">
+ </fieldset>
+ <button form="admin-registation" type="submit" class="btn">Register</button>
+ </form>
+ <p class="py-4 text-sm text-red-500">
+ This tab is only visible when the server is in setup mode. You can create as many admin accounts as you like now.
+ </p>
+</template>
+
+<style scoped lang="scss"></style> \ No newline at end of file
diff --git a/front-end/src/components/Login/UserPass.vue b/front-end/src/components/Login/UserPass.vue
index 9d72d08..c47e594 100644
--- a/front-end/src/components/Login/UserPass.vue
+++ b/front-end/src/components/Login/UserPass.vue
@@ -99,7 +99,7 @@ const onSubmit = async () => {
</form>
<form v-else class="space-y-4 md:space-y-6" action="#" @submit.prevent="onSubmit" :disabled="waiting">
<fieldset>
- <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
+ <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Email</label>
<input type="email" name="email" id="email" class="input" placeholder="name@company.com" required
v-model="v$.username.$model"
>
diff --git a/front-end/src/components/Registation.vue b/front-end/src/components/Registation.vue
new file mode 100644
index 0000000..56508e8
--- /dev/null
+++ b/front-end/src/components/Registation.vue
@@ -0,0 +1,137 @@
+<script setup lang="ts">
+import { apiCall, useWait } from '@vnuge/vnlib.browser'
+import { storeToRefs } from 'pinia'
+import { useQuery, useStore } from '../store'
+import { computed, ref, watch } from 'vue';
+import { get } from '@vueuse/core';
+import { delay, isEmpty, noop } from 'lodash-es';
+import { decodeJwt } from 'jose';
+
+const { waiting } = useWait();
+const store = useStore();
+const { siteTitle } = storeToRefs(store)
+
+const enabled = computed(() => store.registation.status?.enabled === true);
+
+const password = ref();
+const repeatPassword = ref();
+const token = useQuery("token")
+
+const tVals = computed(() => {
+ try{
+ const { sub, level, exp } = decodeJwt<{level:number, sub:string, exp:number}>(get(token)!)
+ const isPrilageed = (level & ( 1 << 0x08)) !== 0;
+ const isExpired = exp < Date.now() / 1000;
+ return { email: sub, isPrilageed , isExpired }
+ }
+ catch{
+ return { email: '', isPrilageed: false, isExpired: true }
+ }
+})
+
+const onSubmit = () =>{
+
+ const passwrd = get(password);
+ if(isEmpty(passwrd)){
+ return;
+ }
+
+ apiCall(async ({ toaster }) => {
+ const result = await store.registation.api.completeRegistation(get(token)!, passwrd)
+ const message = result.getResultOrThrow();
+
+ toaster.general.success({
+ title:'Completed!',
+ text: message
+ })
+
+ //redirect to login page on success
+ delay(() => {
+ //Clear token value
+ window.location.assign('/')
+ } , 1000)
+ });
+}
+
+//If token or enabled changes and both are true, reload and clear all arguments
+watch([enabled, token], ([en, t]) => (en && t) ? noop() : window.location.assign('/'))
+
+</script>
+<template>
+ <section id="reg-page" class="flex-auto">
+ <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto lg:py-24">
+ <div class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
+ <span class="p-2 mr-2 bg-blue-500 rounded-full">
+ <svg class="w-5 h-5 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor" viewBox="0 0 14 20">
+ <path
+ d="M13 20a1 1 0 0 1-.64-.231L7 15.3l-5.36 4.469A1 1 0 0 1 0 19V2a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v17a1 1 0 0 1-1 1Z" />
+ </svg>
+ </span>
+ <span class="self-center font-semibold whitespace-nowrap">{{ siteTitle }}</span>
+ </div>
+ <div
+ class="w-full bg-white rounded shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
+ <div class="p-6 space-y-4 md:space-y-6 sm:p-8">
+
+ <!-- password/username login -->
+ <h1
+ class="text-xl font-bold leading-tight tracking-tight text-center text-gray-900 md:text-2xl dark:text-white">
+ Sign up
+ </h1>
+
+ <div class="" v-if="tVals.isExpired">
+ <p class="py-4 text-lg text-center text-red-500 dark:text-red-400">
+ Your sign up link has expired
+ </p>
+ <div class="mt-4">
+ <a href="/">
+ <button class="w-full btn blue">Go back</button>
+ </a>
+ </div>
+ </div>
+
+ <form v-else class="space-y-4 md:space-y-6" action="#" @submit.prevent="onSubmit" :disabled="waiting">
+ <fieldset>
+ <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
+ <input type="email" name="email" id="email" class="input" placeholder="" disabled
+ :value="tVals.email"
+ >
+ </fieldset>
+ <fieldset>
+ <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
+ <input type="password" name="password" id="password" class="input" placeholder="••••••••" required
+ v-model="password"
+ >
+ </fieldset>
+ <fieldset>
+ <label for="repeat-password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Repeat Password</label>
+ <input type="password" name="repeat-password" id="repeat-password" class="input" placeholder="••••••••" required
+ v-model="repeatPassword"
+ >
+ </fieldset>
+ <fieldset>
+ <div class="flex items-center">
+ <input disabled id="disabled-checked-checkbox" type="checkbox" :value="tVals.isPrilageed"
+ class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
+ <label for="disabled-checked-checkbox" class="text-sm font-medium text-gray-400 ms-2 dark:text-gray-500">
+ Can add users
+ </label>
+ </div>
+ </fieldset>
+ <button type="submit" class="btn">Submit</button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </section>
+</template>
+
+<style lang="scss">
+#reg-page {
+
+ button[type="submit"] {
+ @apply w-full focus:ring-4 focus:outline-none font-medium rounded text-sm px-5 py-2.5 text-center;
+ @apply text-white bg-blue-600 hover:bg-blue-700 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800;
+ }
+}</style> \ No newline at end of file
diff --git a/front-end/src/components/Settings.vue b/front-end/src/components/Settings.vue
index 720c556..83d3f79 100644
--- a/front-end/src/components/Settings.vue
+++ b/front-end/src/components/Settings.vue
@@ -1,11 +1,13 @@
<script setup lang="ts">
import { useDark } from '@vueuse/core';
import { useStore } from '../store';
+import { defineAsyncComponent } from 'vue';
import Oauth2Apps from './Settings/Oauth2Apps.vue';
import PasswordReset from './Settings/PasswordReset.vue';
import PkiSettings from './Settings/PkiSettings.vue';
import TotpSettings from './Settings/TotpSettings.vue';
import Bookmarks from './Settings/Bookmarks.vue';
+const Registation = defineAsyncComponent(() => import('./Settings/Registation.vue'));
const store = useStore();
const darkMode = useDark();
@@ -39,7 +41,7 @@ const darkMode = useDark();
</div>
</div>
- <div class="">
+ <div class="">
<h3 class="text-xl font-bold">Boomarks</h3>
<div class="relative mt-4">
@@ -61,7 +63,11 @@ const darkMode = useDark();
<!-- Only load component if oauth2 plugin is enabled -->
<div v-if="store.oauth2" class="">
- <Oauth2Apps />
+ <Oauth2Apps />
+ </div>
+
+ <div v-if="store.registation.status?.can_invite" class="mb-10">
+ <Registation />
</div>
</div>
diff --git a/front-end/src/components/Settings/Bookmarks.vue b/front-end/src/components/Settings/Bookmarks.vue
index 7f73921..a4ab55a 100644
--- a/front-end/src/components/Settings/Bookmarks.vue
+++ b/front-end/src/components/Settings/Bookmarks.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { apiCall, useWait } from '@vnuge/vnlib.browser';
-import { useStore, type DownloadContentType } from '../../store';
+import { useStore, type DownloadContentType, TabId } from '../../store';
import { ref } from 'vue';
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
@@ -36,52 +36,83 @@ const downloadBookmarks = (contentType: DownloadContentType) => {
});
}
+const bookmarkHref = `
+javascript: (function() {
+ const bookmarkUrl = window.location;
+ let applicationUrl = '${window.location.origin}';
+ applicationUrl += '?tab=${TabId.Bookmarks}&url=' + encodeURIComponent(bookmarkUrl);
+ applicationUrl += '&title='+document.title;
+ window.open(applicationUrl);
+})();`
+
</script>
<template>
- <div class="relative w-fit">
+ <div class="flex flex-col gap-4">
+ <div class="flex-row hidden gap-2 sm:flex">
+ <div class="">
+ <a :href="bookmarkHref" @click.prevent="" class="text-sm cursor-move btn light">
+ <span class="whitespace-nowrap">
+ Add Bookmark 📎
+ </span>
+ </a>
+ </div>
+ <p class="p-0.5 my-auto text-sm flex flex-row">
+ <span class="">
+ <svg class="w-6 h-5 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12l4-4m-4 4 4 4"/>
+ </svg>
+ </span>
+ <span>
+ Drag this button to your bookmarks bar to quickly add a new bookmark
+ </span>
+ </p>
+ </div>
+ <div class="relative ml-auto sm:ml-0 w-fit">
<Menu>
- <MenuButton :disabled="waiting" class="flex items-center gap-3 btn light">
- <div class="hidden lg:inline">Download</div>
- <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none">
- <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 13V4M7 14H5a1 1 0 0 0-1 1v4c0 .6.4 1 1 1h14c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1h-2m-1-5-4 5-4-5m9 8h0"/>
- </svg>
- </MenuButton>
- <transition
- enter-active-class="transition duration-100 ease-out"
- enter-from-class="transform scale-95 opacity-0"
- enter-to-class="transform scale-100 opacity-100"
- leave-active-class="transition duration-75 ease-out"
- leave-from-class="transform scale-100 opacity-100"
- leave-to-class="transform scale-95 opacity-0"
- >
- <MenuItems class="absolute z-10 bg-white divide-y divide-gray-100 rounded-b shadow right-2 lg:left-0 min-w-32 lg:end-0 dark:bg-gray-700">
- <ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton">
- <!-- Use the `active` state to conditionally style the active item. -->
- <MenuItem as="template" v-slot="{ }">
- <li>
- <button @click="downloadBookmarks('text/html')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
- HTML
- </button>
- </li>
- </MenuItem>
- <MenuItem as="template" v-slot="{ }">
- <li>
- <button @click="downloadBookmarks('text/csv')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
- CSV
- </button>
- </li>
- </MenuItem>
- <MenuItem as="template" v-slot="{ }">
- <li>
- <button @click="downloadBookmarks('application/json')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
- JSON
- </button>
- </li>
- </MenuItem>
- </ul>
- </MenuItems>
- </transition>
- </Menu>
+ <MenuButton :disabled="waiting" class="flex items-center gap-3 btn light">
+ <div class="hidden lg:inline">Download</div>
+ <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none">
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 13V4M7 14H5a1 1 0 0 0-1 1v4c0 .6.4 1 1 1h14c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1h-2m-1-5-4 5-4-5m9 8h0"/>
+ </svg>
+ </MenuButton>
+ <transition
+ enter-active-class="transition duration-100 ease-out"
+ enter-from-class="transform scale-95 opacity-0"
+ enter-to-class="transform scale-100 opacity-100"
+ leave-active-class="transition duration-75 ease-out"
+ leave-from-class="transform scale-100 opacity-100"
+ leave-to-class="transform scale-95 opacity-0"
+ >
+ <MenuItems class="absolute z-10 bg-white divide-y divide-gray-100 rounded-b shadow right-2 lg:left-0 min-w-32 lg:end-0 dark:bg-gray-700">
+ <ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton">
+ <!-- Use the `active` state to conditionally style the active item. -->
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('text/html')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ HTML
+ </button>
+ </li>
+ </MenuItem>
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('text/csv')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ CSV
+ </button>
+ </li>
+ </MenuItem>
+ <MenuItem as="template" v-slot="{ }">
+ <li>
+ <button @click="downloadBookmarks('application/json')" class="block w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
+ JSON
+ </button>
+ </li>
+ </MenuItem>
+ </ul>
+ </MenuItems>
+ </transition>
+ </Menu>
+ </div>
</div>
+
<a ref="downloadAnchor" class="hidden"></a>
</template> \ No newline at end of file
diff --git a/front-end/src/components/Settings/Registation.vue b/front-end/src/components/Settings/Registation.vue
new file mode 100644
index 0000000..a0f208e
--- /dev/null
+++ b/front-end/src/components/Settings/Registation.vue
@@ -0,0 +1,130 @@
+<script setup lang="ts">
+import { computed, defineAsyncComponent, ref, shallowReactive, shallowRef } from 'vue';
+import { useStore } from '../../store';
+import { get, set, useClipboard, useTimeAgo, useToggle } from '@vueuse/core';
+import { apiCall, useVuelidateWrapper } from '@vnuge/vnlib.browser';
+import { defaultTo } from 'lodash-es';
+import { useVuelidate } from '@vuelidate/core'
+import { required, maxLength, minLength, helpers, email } from '@vuelidate/validators'
+const Dialog = defineAsyncComponent(() => import('../global/Dialog.vue'));
+
+const store = useStore();
+const { copy, copied } = useClipboard()
+
+const [isOpen, toggleOpen] = useToggle(false)
+const vState = shallowReactive({ email: '' })
+
+const canInvite = ref<boolean>(false)
+const inviteLink = shallowRef<string | undefined>()
+
+const expirationDate = computed(() => Date.now() + (1000 * defaultTo(store.registation.status?.link_expiration, 0)))
+const fromNowTime = useTimeAgo(expirationDate)
+
+const rules = computed(() => {
+ return {
+ email: {
+ required: helpers.withMessage('Email is required', required),
+ maxLength: helpers.withMessage('Email must be less than 255 characters', maxLength(255)),
+ minLength: helpers.withMessage('Email must be at least 3 characters', minLength(3)),
+ email: helpers.withMessage('Email must be a valid email', email)
+ },
+ }
+})
+
+const v$ = useVuelidate(rules, vState)
+const { validate } = useVuelidateWrapper(v$ as any)
+
+const onSubmit = async () => {
+ if (!await validate()) return
+
+ apiCall(async () => {
+ //Rest password and pass totp code
+ const { link } = await store.registation.api.createSignupLink(vState.email, get(canInvite))
+ set(inviteLink, link)
+ })
+}
+
+const onCancel = () => {
+ vState.email = ''
+ v$.value.$reset()
+ set(canInvite, false)
+ set(inviteLink, undefined)
+ toggleOpen(false)
+}
+
+</script>
+
+<template>
+ <div class="">
+
+ <div class="flex flex-row justify-between w-full">
+ <h3 class="text-xl font-bold">Registation</h3>
+
+ <div class="flex flex-row justify-end">
+ <button class="btn blue" @click="toggleOpen(true)">Invite User</button>
+ </div>
+ </div>
+ <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
+ Create a one-time invite link you can send to add a new user to your server.
+ </p>
+ <p class="text-sm text-gray-500 dark:text-gray-400">
+ Links expire <span class="text-blue-500">{{ fromNowTime }}</span>
+ </p>
+ <Dialog :open="isOpen" title="Invite User" @cancel="onCancel">
+ <template #body>
+ <div class="p-4">
+
+ <div v-if="inviteLink" class="">
+ <p class="my-2 text-lg font-medium text-center text-gray-900 dark:text-white">
+ Link expires {{ fromNowTime }}
+ </p>
+
+ <label for="invite-link" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
+ Invite link
+ </label>
+ <input
+ :value="inviteLink"
+ type="url"
+ id="invite-link"
+ class="input"
+ readonly
+ >
+
+ <div class="mt-4 ml-auto w-fit">
+ <button @click="copy(inviteLink)" type="submit" :disabled="copied" class="btn blue">
+ {{ copied ? 'Copied!' : 'Copy' }}
+ </button>
+ </div>
+
+ </div>
+
+ <form v-else @submit.prevent="onSubmit">
+
+ <fieldset class="mb-4">
+ <label for="user-email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Email address</label>
+ <input v-model="v$.email.$model" type="email" id="user-email" class="input"
+ :class="{ 'error': v$.email.$error, 'dirty': v$.email.$dirty }"
+ placeholder="user@simplebookmark.com"
+ required
+ >
+ </fieldset>
+
+ <fieldset class="px-2">
+ <h4 class="font-bold text-gray-700 dark:text-white">Permissions</h4>
+ <div class="flex items-center mt-2 mb-4">
+ <input id="can-invite-input" type="checkbox" v-model="canInvite" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
+ <label for="can-invite-input" class="text-sm font-medium text-gray-900 ms-2 dark:text-gray-300">Can invite users</label>
+ </div>
+ </fieldset>
+
+ <div class="ml-auto w-fit">
+ <button type="submit" class="btn blue">
+ Create Link
+ </button>
+ </div>
+ </form>
+ </div>
+ </template>
+ </Dialog>
+ </div>
+</template> \ No newline at end of file
diff --git a/front-end/src/components/global/ConfirmPrompt.vue b/front-end/src/components/global/ConfirmPrompt.vue
index 24d3b9c..8cc9920 100644
--- a/front-end/src/components/global/ConfirmPrompt.vue
+++ b/front-end/src/components/global/ConfirmPrompt.vue
@@ -33,7 +33,7 @@ onReveal(m => message.value = defaultTo(m, {}));
</p>
</div>
<!-- Modal footer -->
- <div class="flex items-center justify-end p-4 border-t border-gray-200 rounded-b md:p-5 dark:border-gray-600">
+ <div class="flex items-center justify-end gap-2 p-4 border-t border-gray-200 rounded-b md:p-5 dark:border-gray-600">
<button
@click="confirm()"
type="button"
diff --git a/front-end/src/components/global/Dialog.vue b/front-end/src/components/global/Dialog.vue
index a27d5ee..65d9165 100644
--- a/front-end/src/components/global/Dialog.vue
+++ b/front-end/src/components/global/Dialog.vue
@@ -19,10 +19,10 @@ onClickOutside(dialog, () => get(open) ? cancel() : noop())
<template>
<!-- Main modal -->
<Dialog :open="open" id="static-modal" data-modal-backdrop="static" tabindex="-1"
- class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-10 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
+ class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-20 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="fixed inset-0 bg-black/30" aria-hidden="true" />
- <div class="relative w-full max-w-xl max-h-full p-4 mx-auto mt-2 md:mt-32">
+ <div class="relative w-full max-w-xl max-h-full p-4 mx-auto mt-[8rem] md:mt-32">
<!-- Modal content -->
<div class="relative bg-white rounded shadow dark:bg-gray-700" ref="dialog">
<!-- Modal header -->
diff --git a/front-end/src/components/global/PasswordPrompt.vue b/front-end/src/components/global/PasswordPrompt.vue
index 50024fb..e0dc349 100644
--- a/front-end/src/components/global/PasswordPrompt.vue
+++ b/front-end/src/components/global/PasswordPrompt.vue
@@ -86,7 +86,7 @@ onReveal(m => message.value = defaultTo(m, {}));
</form>
</div>
<!-- Modal footer -->
- <div class="flex items-center justify-end p-4 border-t border-gray-200 rounded-b md:p-5 dark:border-gray-600">
+ <div class="flex items-center justify-end gap-2 p-4 border-t border-gray-200 rounded-b md:p-5 dark:border-gray-600">
<button
@click="formSubmitted"
type="button"
diff --git a/front-end/src/main.ts b/front-end/src/main.ts
index 30c3f10..c5be406 100644
--- a/front-end/src/main.ts
+++ b/front-end/src/main.ts
@@ -29,6 +29,7 @@ import { profilePlugin } from './store/userProfile'
import { mfaSettingsPlugin } from './store/mfaSettingsPlugin'
import { socialMfaPlugin } from './store/socialMfaPlugin'
import { bookmarkPlugin } from './store/bookmarks'
+import { registationPlugin } from './store/registation';
//Setup the vnlib api
configureApi({
@@ -69,6 +70,7 @@ store.use(profilePlugin('/account/profile'))
.use(socialMfaPlugin())
//Add the oauth2 apps plugin
.use(bookmarkPlugin('/bookmarks'))
+ .use(registationPlugin('/register'))
//Setup oauth apps plugin (disabled for now)
//.use(oauth2AppsPlugin('/oauth/apps', '/oauth/scopes'))
diff --git a/front-end/src/store/bookmarks.ts b/front-end/src/store/bookmarks.ts
index 76cc5b9..2af8344 100644
--- a/front-end/src/store/bookmarks.ts
+++ b/front-end/src/store/bookmarks.ts
@@ -33,6 +33,7 @@ export interface Bookmark{
export interface BatchUploadResult{
readonly invalid: BookmarkError[]
+ readonly message?: string
}
export interface BookmarkError{
diff --git a/front-end/src/store/index.ts b/front-end/src/store/index.ts
index bcd79ad..09c5a2d 100644
--- a/front-end/src/store/index.ts
+++ b/front-end/src/store/index.ts
@@ -15,7 +15,7 @@
import { useSession, useAutoHeartbeat } from "@vnuge/vnlib.browser";
import { toRefs, set, watchDebounced, useLocalStorage } from "@vueuse/core";
-import { noop, toSafeInteger, toString, defaults } from "lodash-es";
+import { toSafeInteger, toString, defaults } from "lodash-es";
import { defineStore } from "pinia";
import { computed, shallowRef, watch } from "vue";
@@ -53,7 +53,8 @@ export enum TabId{
Bookmarks,
Profile,
Settings,
- Login
+ Login,
+ Register
}
/**
@@ -80,7 +81,13 @@ export const useStore = defineStore('main', () => {
})
//If not logged in, redirect to login tab
- watch(loggedIn, (loggedIn) => loggedIn ? noop() : set(activeTab, TabId.Login), { immediate: true })
+ watch(loggedIn, (li) =>{
+ if (li || activeTab.value == TabId.Register){
+ return;
+ }
+
+ set(activeTab, TabId.Login);
+ }, { immediate: true })
//Setup heartbeat for 5 minutes
useAutoHeartbeat(shallowRef(5 * 60 * 1000), autoHeartbeat)
diff --git a/front-end/src/store/registation.ts b/front-end/src/store/registation.ts
new file mode 100644
index 0000000..b07e3e2
--- /dev/null
+++ b/front-end/src/store/registation.ts
@@ -0,0 +1,110 @@
+// Copyright (C) 2024 Vaughn Nugent
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+import 'pinia'
+import { MaybeRef, shallowRef, watch } from 'vue';
+import { WebMessage, useAxios } from '@vnuge/vnlib.browser';
+import { get } from '@vueuse/core';
+import { PiniaPluginContext, PiniaPlugin, storeToRefs } from 'pinia'
+import { defer } from 'lodash-es';
+import { TabId } from '.';
+
+export interface SignupToken {
+ readonly link: string
+}
+
+export interface RegistationStatus{
+ readonly setup_mode: boolean
+ readonly enabled: boolean
+ readonly can_invite: boolean
+ readonly link_expiration: number
+}
+
+export interface UserRegistationApi {
+ createSignupLink(username: string, canAddUsers: boolean): Promise<SignupToken>
+ getStatus(): Promise<RegistationStatus>
+ registerAdmin(username: string, password: string): Promise<WebMessage<string>>
+ completeRegistation(token: string, password: string): Promise<WebMessage<string>>
+}
+
+declare module 'pinia' {
+ export interface PiniaCustomProperties {
+ registation:{
+ api: UserRegistationApi
+ status: RegistationStatus | undefined
+ }
+ }
+}
+
+
+const useRegApi = (endpoint: MaybeRef<string>): UserRegistationApi => {
+
+ const axios = useAxios(null);
+
+ const createSignupLink = async (username: string, hasAddPerms: boolean): Promise<SignupToken> => {
+ const { data } = await axios.put<WebMessage<string>>(get(endpoint), {
+ username,
+ can_add_users:hasAddPerms
+ })
+
+ const token = data.getResultOrThrow();
+
+ return { link: `${window.location.origin}?tab=${TabId.Register}&token=${token}` }
+ }
+
+ const getStatus = async (): Promise<RegistationStatus> => {
+ const { data } = await axios.get<WebMessage<RegistationStatus>>(get(endpoint))
+ return data.getResultOrThrow();
+ }
+
+ const completeRegistation = async (token: string, password: string): Promise<WebMessage<string>> => {
+ const { data } = await axios.post<WebMessage<string>>(get(endpoint), { token, password })
+ return data;
+ }
+
+ const registerAdmin = async (username: string, password: string): Promise<WebMessage<string>> => {
+ const { data } = await axios.post<WebMessage<string>>(get(endpoint), { admin_username:username, password })
+ return data;
+ }
+
+ return {
+ createSignupLink,
+ getStatus,
+ completeRegistation,
+ registerAdmin
+ }
+}
+
+export const registationPlugin = (regEndpoint: MaybeRef<string>): PiniaPlugin => {
+
+ return ({ store }: PiniaPluginContext): any => {
+
+ const { loggedIn } = storeToRefs(store)
+
+ const regApi = useRegApi(regEndpoint)
+ const status = shallowRef<RegistationStatus | undefined>()
+
+ const getStatus = async () => status.value = await regApi.getStatus()
+
+ watch(loggedIn, () => defer(getStatus), { immediate: true })
+
+ return{
+ registation: {
+ api: regApi,
+ status,
+ }
+ }
+ }
+} \ No newline at end of file