add bcrypt and refactored auth resolve (#147)

* reworked auth architecture with improved password handling and claims

Refactored password strategy to prepare supporting bcrypt, improving hashing/encryption flexibility. Updated authentication flow with enhanced user resolution mechanisms, safe JWT generation, and consistent profile handling. Adjusted dependencies to include bcryptjs and updated lock files accordingly.

* fix strategy forms handling, add register route and hidden fields

Refactored strategy forms to include hidden fields for type and name. Added a registration route with necessary adjustments to the admin controller and routes. Corrected field handling within relevant forms and components.

* refactored auth handling to support bcrypt, extracted user pool

* update email regex to allow '+' and '_' characters

* update test stub password for AppAuth spec

* update data exceptions to use HttpStatus constants, adjust logging level in AppUserPool

* rework strategies to extend a base class instead of interface

* added simple bcrypt test
This commit is contained in:
dswbx
2025-04-20 10:46:29 +02:00
committed by GitHub
parent edb5d5f4a9
commit 79ca2a9939
28 changed files with 721 additions and 477 deletions
+5 -2
View File
@@ -1,9 +1,12 @@
import type { ContentfulStatusCode } from "hono/utils/http-status";
import { HttpStatus } from "./utils/reqres";
export class Exception extends Error {
code = 400;
code: ContentfulStatusCode = HttpStatus.BAD_REQUEST;
override name = "Exception";
protected _context = undefined;
constructor(message: string, code?: number) {
constructor(message: string, code?: ContentfulStatusCode) {
super(message);
if (code) {
this.code = code;
+14 -4
View File
@@ -98,7 +98,7 @@ export function decodeSearch(str) {
export const enum HttpStatus {
// Informational responses (100199)
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
//SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
EARLY_HINTS = 103,
@@ -107,8 +107,8 @@ export const enum HttpStatus {
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
RESET_CONTENT = 205,
//NO_CONTENT = 204,
//RESET_CONTENT = 205,
PARTIAL_CONTENT = 206,
MULTI_STATUS = 207,
ALREADY_REPORTED = 208,
@@ -119,7 +119,7 @@ export const enum HttpStatus {
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
//NOT_MODIFIED = 304,
USE_PROXY = 305,
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308,
@@ -168,3 +168,13 @@ export const enum HttpStatus {
NOT_EXTENDED = 510,
NETWORK_AUTHENTICATION_REQUIRED = 511,
}
// biome-ignore lint/suspicious/noConstEnum: <explanation>
export const enum HttpStatusEmpty {
// Informational responses (100199)
SWITCHING_PROTOCOLS = 101,
// Successful responses (200299)
NO_CONTENT = 204,
RESET_CONTENT = 205,
// Redirection messages (300399)
NOT_MODIFIED = 304,
}
+5
View File
@@ -132,3 +132,8 @@ export function slugify(str: string): string {
.replace(/-+/g, "-") // remove consecutive hyphens
);
}
export function truncate(str: string, length = 50, end = "..."): string {
if (str.length <= length) return str;
return str.substring(0, length) + end;
}
+5
View File
@@ -179,6 +179,11 @@ export const StringIdentifier = tb.Type.String({
maxLength: 150,
});
export const StrictObject = <T extends tb.TProperties>(
properties: T,
options?: tb.ObjectOptions,
): tb.TObject<T> => tb.Type.Object(properties, { ...options, additionalProperties: false });
SetErrorFunction((error) => {
if (error?.schema?.errorMessage) {
return error.schema.errorMessage;