import { NextFunction, Request, Response } from "express";

//#region src/utils/accessControl.d.ts
declare enum AccessRule {
  none = "none",
  authenticated = "authenticated",
  admin = "admin",
  noneAuthenticated = "not-authenticated",
  hasOrganization = "has-organization",
  hasProject = "has-project",
  hasBearer = "has-bearer",
  oauth2 = "oauth2",
}
declare const accessControl: <R extends AccessRule | AccessRule[]>(res: Response, accessRule: R) => {
  success: boolean;
  message: string;
  data: {
    user: any;
    organization: any;
    project: any;
    authType: any;
  };
};
/**
 * Middleware to control API access based on access rules.
 *
 * This middleware allows for multiple access rules to be passed, either as individual `AccessRule` or
 * an array of `AccessRule` groups. Access is granted if at least one of the following conditions is met:
 *
 * - The user satisfies all `AccessRule` within any group of rules passed as an array.
 * - The user satisfies any single `AccessRule` passed individually.
 *
 * Example usage:
 *
 * ```typescript
 * // Allow access if the user has both `hasProject` and `hasOrganization`, or if they have `admin` rights
 * app.use('/protected-route', apiAccessControlMiddleWare([AccessRule.hasProject, AccessRule.hasOrganization], AccessRule.admin));
 * ```
 *
 * In this example:
 * - The user will be granted access if they have both `hasProject` and `hasOrganization`.
 * - Alternatively, the user will also be granted access if they have `admin` privileges.
 *
 * @param {...(AccessRule | AccessRule[])[]} accessRules - One or more access rules or groups of access rules.
 * - Single `AccessRule`: The user must satisfy this rule for access to be granted.
 * - Array of `AccessRule`: The user must satisfy all rules in the array for access to be granted.
 * @returns {Function} Express middleware function that checks if the user has the required access.
 *
 * If the user does not meet any of the provided access rules, a 403 Forbidden status is returned.
 *
 * @example
 * // Example 1: Require admin privileges
 * app.use('/admin', apiAccessControlMiddleWare(AccessRule.admin));
 *
 * @example
 * // Example 2: Require both project and organization access, or admin privileges
 * app.use('/dashboard', apiAccessControlMiddleWare([AccessRule.hasProject, AccessRule.hasOrganization], AccessRule.admin));
 */
declare const accessControlMiddleWare: (...accessRules: (AccessRule | AccessRule[])[]) => (_req: Request<unknown>, res: Response, next: NextFunction) => void;
//#endregion
export { AccessRule, accessControl, accessControlMiddleWare };
//# sourceMappingURL=accessControl.d.ts.map