mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user