import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { CheckConfig, Context, ContextStore } from '../utils/context'; import { IAction, IResource, IUser } from './interfaces'; export declare class PermitError extends Error { constructor(message: string); } export declare class PermitConnectionError extends PermitError { constructor(message: string); } export declare class PermitPDPStatusError extends PermitError { constructor(message: string); } export interface IEnforcer { /** * Checks if a `user` is authorized to perform an `action` on a `resource` within the specified context. * * @param user - The user object representing the user. * @param action - The action to be performed on the resource. * @param resource - The resource object representing the resource. * @param context - The context object representing the context in which the action is performed. * @returns `true` if the user is authorized, `false` otherwise. * @throws {@link PermitConnectionError} if an error occurs while sending the authorization request to the PDP. * @throws {@link PermitPDPStatusError} if received a response with unexpected status code from the PDP. */ check(user: IUser | string, action: IAction, resource: IResource | string, context?: Context, config?: CheckConfig): Promise; } /** * The {@link Enforcer} class is responsible for performing permission checks against the PDP. * It implements the {@link IEnforcer} interface. */ export declare class Enforcer implements IEnforcer { private config; private logger; contextStore: ContextStore; private client; /** * Creates an instance of the Enforcer class. * @param config - The configuration object for the Permit SDK. * @param logger - The logger instance for logging. */ constructor(config: IPermitConfig, logger: Logger); /** * Checks if a `user` is authorized to perform an `action` on a `resource` within the specified context. * * @param user - The user object representing the user. * @param action - The action to be performed on the resource. * @param resource - The resource object representing the resource. * @param context - The context object representing the context in which the action is performed. * @returns `true` if the user is authorized, `false` otherwise. * @throws {@link PermitConnectionError} if an error occurs while sending the authorization request to the PDP. * @throws {@link PermitPDPStatusError} if received a response with unexpected status code from the PDP. */ check(user: IUser | string, action: IAction, resource: IResource | string, context?: Context, // context provided specifically for this query config?: CheckConfig): Promise; private checkWithExceptions; private normalizeResource; private static userRepr; private static resourceRepr; private static resourceFromString; getMethods(): IEnforcer; }