UNPKG

@lanaqi/rsr

Version:
292 lines (291 loc) 6.83 kB
import type { AccessAuthentication, AccessAuthorization } from './aaa'; import type { AccessPath } from './common'; import type { AccessResource } from './resource'; /** * 访问记录器 */ export interface AccessRecorder { /** * 获取当前路径 */ getCurrentPath(): AccessPath | undefined; /** * 设置当前路径 * @param currentPath 当前路径 */ setCurrentPath(currentPath: AccessPath): void; /** * 存在当前路径 */ existCurrentPath(): boolean; /** * 是否当前路径名 * @param pathname 路径名 */ isCurrentPath(pathname: string): boolean; /** * 是否当前路径名集合 * @param pathnames 路径名集合 */ isCurrentPaths(...pathnames: string[]): boolean; /** * 获取允许路径 */ getAllowPath(): AccessPath | undefined; /** * 设置允许路径 * @param allowPath 允许路径 */ setAllowPath(allowPath: AccessPath): void; /** * 存在允许路径 */ existAllowPath(): boolean; /** * 是否允许路径名 * @param pathname 路径名 */ isAllowPath(pathname: string): boolean; /** * 是否允许路径名集合 * @param pathnames 路径名集合 */ isAllowPaths(...pathnames: string[]): boolean; /** * 获取原始路径 */ getOriginPath(): AccessPath | undefined; /** * 设置原始路径 * @param originPath 原始路径 */ setOriginPath(originPath: AccessPath): void; /** * 存在原始路径 */ existOriginPath(): boolean; /** * 是否原始路径名 * @param pathname 路径名 */ isOriginPath(pathname: string): boolean; /** * 是否原始路径名集合 * @param pathnames 路径名集合 */ isOriginPaths(...pathnames: string[]): boolean; /** * 获取访问资源 */ getAccessResource(): AccessResource | undefined; /** * 设置访问资源 * @param accessResource 访问资源 */ setAccessResource(accessResource: AccessResource): void; /** * 存在访问资源 */ existAccessResource(): boolean; /** * 获取访问认证 */ getAccessAuthentication(): AccessAuthentication | undefined; /** * 设置访问认证 * @param accessAuthentication 访问认证 */ setAccessAuthentication(accessAuthentication: AccessAuthentication): void; /** * 存在访问认证 */ existAccessAuthentication(): boolean; /** * 获取访问授权 */ getAccessAuthorization(): AccessAuthorization | undefined; /** * 设置访问授权 * @param accessAuthorization 访问授权 */ setAccessAuthorization(accessAuthorization: AccessAuthorization): void; /** * 存在访问授权 */ existAccessAuthorization(): boolean; /** * 清理原始路径 */ clearOriginPath(): void; /** * 清理访问资源 */ clearAccessResource(): void; /** * 清理访问认证 */ clearAccessAuthentication(): void; /** * 清理访问授权 */ clearAccessAuthorization(): void; } /** * 简单记录器 */ export declare class SimpleRecorder implements AccessRecorder { /** * 当前路径 * @private */ private currentPath?; /** * 允许路径 * @private */ private allowPath?; /** * 原始路径 * @private */ private originPath?; /** * 访问资源 * @private */ private accessResource?; /** * 访问认证 * @private */ private accessAuthentication?; /** * 访问授权 * @private */ private accessAuthorization?; /** * 获取当前路径 */ getCurrentPath(): AccessPath | undefined; /** * 设置当前路径 * @param currentPath 当前路径 */ setCurrentPath(currentPath: AccessPath): void; /** * 存在当前路径 */ existCurrentPath(): boolean; /** * 是否当前路径名 * @param pathname 当前路径名 */ isCurrentPath(pathname: string): boolean; /** * 是否当前路径名集合 * @param pathnames 路径名集合 */ isCurrentPaths(...pathnames: string[]): boolean; /** * 获取允许路径 */ getAllowPath(): AccessPath | undefined; /** * 设置允许路径 * @param allowPath 允许路径 */ setAllowPath(allowPath: AccessPath): void; /** * 存在允许路径 */ existAllowPath(): boolean; /** * 是否允许路径名 * @param pathname 允许路径名 */ isAllowPath(pathname: string): boolean; /** * 是否允许路径名集合 * @param pathnames 路径名集合 */ isAllowPaths(...pathnames: string[]): boolean; /** * 获取原始路径 */ getOriginPath(): AccessPath | undefined; /** * 设置原始路径 * @param originPath 原始路径 */ setOriginPath(originPath: AccessPath): void; /** * 存在原始路径 */ existOriginPath(): boolean; /** * 是否原始路径名 * @param pathname 路径名 */ isOriginPath(pathname: string): boolean; /** * 是否原始路径名集合 * @param pathnames 路径名集合 */ isOriginPaths(...pathnames: string[]): boolean; /** * 获取访问资源 */ getAccessResource(): AccessResource | undefined; /** * 设置访问资源 * @param accessResource 访问资源 */ setAccessResource(accessResource: AccessResource): void; /** * 存在访问资源 */ existAccessResource(): boolean; /** * 获取访问认证 */ getAccessAuthentication(): AccessAuthentication | undefined; /** * 设置访问认证 * @param accessAuthentication 访问认证 */ setAccessAuthentication(accessAuthentication: AccessAuthentication): void; /** * 存在访问认证 */ existAccessAuthentication(): boolean; /** * 获取访问授权 */ getAccessAuthorization(): AccessAuthorization | undefined; /** * 设置访问授权 * @param accessAuthorization 访问授权 */ setAccessAuthorization(accessAuthorization: AccessAuthorization): void; /** * 存在访问授权 */ existAccessAuthorization(): boolean; /** * 清理原始路径 */ clearOriginPath(): void; /** * 清理访问资源 */ clearAccessResource(): void; /** * 清理访问认证 */ clearAccessAuthentication(): void; /** * 清理访问授权 */ clearAccessAuthorization(): void; }