mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: clean up structure using more AsyncHandlers and more folders
This commit is contained in:
parent
14cfe75865
commit
cc8f965495
@ -1,15 +1,9 @@
|
|||||||
|
import { AsyncHandler } from '../util/AsyncHandler';
|
||||||
import { Credentials } from './Credentials';
|
import { Credentials } from './Credentials';
|
||||||
import { HttpRequest } from '../server/HttpRequest';
|
import { HttpRequest } from '../server/HttpRequest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for extracting credentials.
|
* Responsible for extracting credentials from an incoming request.
|
||||||
|
* Will return `null` if no credentials were found.
|
||||||
*/
|
*/
|
||||||
export interface CredentialsExtractor {
|
export type CredentialsExtractor = AsyncHandler<HttpRequest, Credentials>;
|
||||||
/**
|
|
||||||
* Extracts the credentials found in an HttpRequest.
|
|
||||||
*
|
|
||||||
* @param request - The incoming request.
|
|
||||||
* @returns A promise resolving to the credentials.
|
|
||||||
*/
|
|
||||||
extractCredentials: (request: HttpRequest) => Promise<Credentials>;
|
|
||||||
}
|
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
|
import { AsyncHandler } from '../util/AsyncHandler';
|
||||||
import { Credentials } from '../authentication/Credentials';
|
import { Credentials } from '../authentication/Credentials';
|
||||||
import { PermissionSet } from '../ldp/permissions/PermissionSet';
|
import { PermissionSet } from '../ldp/permissions/PermissionSet';
|
||||||
import { ResourceIdentifier } from '../ldp/http/ResourceIdentifier';
|
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for the permission verification.
|
* Verifies if the given credentials have access to the given permissions on the given resource.
|
||||||
|
* An {@link Error} with the necessary explanation will be thrown when permissions are not granted.
|
||||||
*/
|
*/
|
||||||
export interface Authorizer {
|
export type Authorizer = AsyncHandler<AuthorizerArgs>;
|
||||||
|
|
||||||
|
export interface AuthorizerArgs {
|
||||||
/**
|
/**
|
||||||
* Verifies if the given credentials have access to the given permissions on the given resource.
|
* Credentials of the entity that wants to use the resource.
|
||||||
* @param credentials - Credentials of the entity that wants to use the resource.
|
|
||||||
* @param identifier - Identifier of the resource that will be read/modified.
|
|
||||||
* @param permissions - Permissions that are requested on the resource.
|
|
||||||
*
|
|
||||||
* @returns A promise resolving when the Authorizer is finished.
|
|
||||||
* An {@link Error} with the necessary explanation will be thrown when permissions are not granted.
|
|
||||||
*/
|
*/
|
||||||
ensurePermissions: (
|
credentials: Credentials;
|
||||||
credentials: Credentials,
|
/**
|
||||||
identifier: ResourceIdentifier,
|
* Identifier of the resource that will be read/modified.
|
||||||
permissions: PermissionSet,
|
*/
|
||||||
) => Promise<void>;
|
identifier: ResourceIdentifier;
|
||||||
|
/**
|
||||||
|
* Permissions that are requested on the resource.
|
||||||
|
*/
|
||||||
|
permissions: PermissionSet;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Representation } from './Representation';
|
import { Representation } from '../representation/Representation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the changes needed for a PATCH request.
|
* Represents the changes needed for a PATCH request.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Representation } from '../http/Representation';
|
import { Representation } from '../representation/Representation';
|
||||||
import { RepresentationPreferences } from '../http/RepresentationPreferences';
|
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
|
||||||
import { ResourceIdentifier } from '../http/ResourceIdentifier';
|
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single REST operation.
|
* A single REST operation.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { RepresentationMetadata } from '../ldp/http/RepresentationMetadata';
|
import { RepresentationMetadata } from '../ldp/representation/RepresentationMetadata';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The conditions of an HTTP conditional request.
|
* The conditions of an HTTP conditional request.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Representation } from '../ldp/http/Representation';
|
import { Representation } from '../ldp/representation/Representation';
|
||||||
import { RepresentationPreferences } from '../ldp/http/RepresentationPreferences';
|
import { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows converting from one resource representation to another.
|
* Allows converting from one resource representation to another.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Lock } from './Lock';
|
import { Lock } from './Lock';
|
||||||
import { ResourceIdentifier } from '../ldp/http/ResourceIdentifier';
|
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the locking of resources which is needed for non-atomic {@link ResourceStore}s.
|
* Allows the locking of resources which is needed for non-atomic {@link ResourceStore}s.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { RepresentationMetadata } from '../ldp/http/RepresentationMetadata';
|
import { RepresentationMetadata } from '../ldp/representation/RepresentationMetadata';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports mapping a file to an URL and back.
|
* Supports mapping a file to an URL and back.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Conditions } from './Conditions';
|
import { Conditions } from './Conditions';
|
||||||
import { Patch } from '../ldp/http/Patch';
|
import { Patch } from '../ldp/http/Patch';
|
||||||
import { Representation } from '../ldp/http/Representation';
|
import { Representation } from '../ldp/representation/Representation';
|
||||||
import { RepresentationPreferences } from '../ldp/http/RepresentationPreferences';
|
import { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
|
||||||
import { ResourceIdentifier } from '../ldp/http/ResourceIdentifier';
|
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ResourceStore represents a collection of resources.
|
* A ResourceStore represents a collection of resources.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user