import { Logger } from 'winston'; import { IAuthorizonConfig } from '../config'; import { Context, ContextStore } from '../utils/context'; import { IAction, IResource, IUser } from './interfaces'; export interface IEnforcer { isAllowed(user: IUser | string, action: IAction, resource: IResource, context?: Context): Promise; } /** * this client is dealing with evaluation of isAllowed() queries. */ export declare class Enforcer implements IEnforcer { private config; private logger; contextStore: ContextStore; private client; constructor(config: IAuthorizonConfig, logger: Logger); /** * Usage: * * // with (resource, action): * const user = { key: 'UNIQUE_USER_ID' }; * authorizon.is_allowed(user, 'get', {'type': 'task', 'id': '23'}) * authorizon.is_allowed(user, 'get', {'type': 'task'}) * * // with (url, method): * const { resource, action } = authorizon.getUrlContext('/lists/3/todos/37', 'GET'); * authorizon.is_allowed(user, action, resource) * * @param user * @param action * @param resource * @param context * * @returns whether or not action is allowed for given user */ isAllowed(user: IUser | string, action: IAction, resource: IResource, context?: Context): Promise; private static normalizeResource; private static resourceRepr; getMethods(): IEnforcer; }