feat: Full rework of account management

Complete rewrite of the account management and related systems.
Makes the architecture more modular,
allowing for easier extensions and configurations.
This commit is contained in:
Joachim Van Herwegen
2022-03-16 10:12:13 +01:00
parent ade977bb4f
commit a47f5236ef
366 changed files with 12345 additions and 5111 deletions

View File

@@ -29,6 +29,22 @@ export function isValidFileName(name: string): boolean {
return /^[\w.-]+$/u.test(name);
}
/**
* Checks if the given string is a valid URL.
*
* @param url - String to check.
* @returns True if the string is a valid URL.
*/
export function isUrl(url: string): boolean {
try {
// eslint-disable-next-line no-new
new URL(url);
return true;
} catch {
return false;
}
}
/**
* Converts milliseconds to an ISO 8601 duration string.
* The only categories used are days, hours, minutes, and seconds,

View File

@@ -266,6 +266,9 @@ export const SOLID_ERROR_TERM = createVocabulary('urn:npm:solid:community-server
);
export const SOLID_HTTP = createVocabulary('urn:npm:solid:community-server:http:',
'accountCookie',
// When the above cookie expires, expects an ISO date string
'accountCookieExpiration',
// Unit, start, and end are used for range headers
'end',
'location',

View File

@@ -13,7 +13,7 @@ export class MethodNotAllowedHttpError extends BaseHttpError {
public readonly methods: Readonly<string[]>;
public constructor(methods: string[] = [], message?: string, options?: HttpErrorOptions) {
super(message ?? `${methods} are not allowed.`, options);
super(message ?? `${methods.join(', ')} ${methods.length === 1 ? 'is' : 'are'} not allowed.`, options);
// Can not override `generateMetadata` as `this.methods` is not defined yet
for (const method of methods) {
this.metadata.add(SOLID_ERROR.terms.disallowedMethod, method);

View File

@@ -2,6 +2,9 @@ import { resolvePromiseOrValue } from '../PromiseUtil';
import type { PromiseOrValue } from '../PromiseUtil';
import type { SetMultiMap } from './SetMultiMap';
export type ArrayElement<TArray extends readonly any[]> = TArray[number];
export type EmptyObject = Record<string, never>;
export type MapKey<T> = T extends Map<infer TKey, any> ? TKey : never;
export type MapValue<T> = T extends Map<any, infer TValue> ? TValue : never;
export type MapEntry<T> = T extends Map<any, any> ? [MapKey<T>, MapValue<T>] : never;