{"version":3,"file":"role-guard.mjs","sources":["../../../../src/lib/routing/guards/role-guard.ts"],"sourcesContent":["/**\n * @file Role-Based Guard\n * @description Route guard for role-based access control. Checks if the user\n * has the required roles to access a route.\n *\n * @module @/lib/routing/guards/role-guard\n *\n * This module provides:\n * - Role requirement definitions\n * - Multiple role matching strategies\n * - Role hierarchy support\n * - Role inheritance\n * - Denial handling\n *\n * @example\n * ```typescript\n * import { createRoleGuard, RoleGuard } from '@/lib/routing/guards/role-guard';\n *\n * const adminGuard = createRoleGuard({\n *   requiredRoles: ['admin'],\n *   matchStrategy: 'any',\n *   unauthorizedPath: '/unauthorized',\n * });\n *\n * const managerGuard = createRoleGuard({\n *   requiredRoles: ['admin', 'manager'],\n *   matchStrategy: 'any',\n * });\n * ```\n */\n\nimport {\n  BaseRouteGuard,\n  GuardResult,\n  type GuardContext,\n  type GuardResultObject,\n} from './route-guard';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Role matching strategy\n */\nexport type RoleMatchStrategy =\n  | 'any' // User must have at least one of the required roles\n  | 'all' // User must have all required roles\n  | 'none'; // User must not have any of the specified roles\n\n/**\n * Role guard configuration\n */\nexport interface RoleGuardConfig {\n  /** Guard name */\n  readonly name?: string;\n  /** Required roles */\n  readonly requiredRoles: readonly string[];\n  /** How to match roles */\n  readonly matchStrategy?: RoleMatchStrategy;\n  /** Path to redirect unauthorized users */\n  readonly unauthorizedPath?: string;\n  /** Custom unauthorized message */\n  readonly unauthorizedMessage?: string;\n  /** Role hierarchy (role -> parent roles) */\n  readonly roleHierarchy?: Record<string, readonly string[]>;\n  /** Custom role check function */\n  readonly checkRoles?: (\n    userRoles: readonly string[],\n    requiredRoles: readonly string[],\n    strategy: RoleMatchStrategy\n  ) => boolean;\n  /** Get user roles from context */\n  readonly getUserRoles?: (context: GuardContext) => readonly string[];\n  /** Routes this guard applies to */\n  readonly routes?: readonly string[];\n  /** Routes to exclude */\n  readonly exclude?: readonly string[];\n  /** Guard priority */\n  readonly priority?: number;\n  /** Feature flag */\n  readonly featureFlag?: string;\n}\n\n/**\n * Role check result\n */\nexport interface RoleCheckResult {\n  /** Whether user has required roles */\n  readonly hasAccess: boolean;\n  /** User's roles */\n  readonly userRoles: readonly string[];\n  /** Required roles */\n  readonly requiredRoles: readonly string[];\n  /** Missing roles (for 'all' strategy) */\n  readonly missingRoles: readonly string[];\n  /** Matched roles (for 'any' strategy) */\n  readonly matchedRoles: readonly string[];\n  /** Strategy used */\n  readonly strategy: RoleMatchStrategy;\n}\n\n// =============================================================================\n// Constants\n// =============================================================================\n\n/**\n * Default role guard configuration\n */\nexport const DEFAULT_ROLE_CONFIG: Partial<RoleGuardConfig> = {\n  name: 'role',\n  matchStrategy: 'any',\n  unauthorizedPath: '/unauthorized',\n  unauthorizedMessage: 'You do not have the required role to access this page',\n  priority: 20,\n};\n\n// =============================================================================\n// RoleGuard Class\n// =============================================================================\n\n/**\n * Role-based route guard\n *\n * @example\n * ```typescript\n * const guard = new RoleGuard({\n *   requiredRoles: ['admin', 'super-admin'],\n *   matchStrategy: 'any',\n *   roleHierarchy: {\n *     'super-admin': ['admin'],\n *   },\n * });\n *\n * const result = await guard.execute('canActivate', context);\n * ```\n */\nexport class RoleGuard extends BaseRouteGuard {\n  private readonly roleConfig: RoleGuardConfig;\n  private readonly _expandedRoles: ReadonlySet<string>;\n\n  constructor(config: RoleGuardConfig) {\n    const mergedConfig = { ...DEFAULT_ROLE_CONFIG, ...config };\n\n    super({\n      name: mergedConfig.name ?? 'role',\n      description: `Role guard - requires: ${config.requiredRoles.join(', ')}`,\n      priority: mergedConfig.priority,\n      routes: mergedConfig.routes,\n      exclude: mergedConfig.exclude,\n      featureFlag: mergedConfig.featureFlag,\n      canActivate: async (context) => this.checkRoleAccess(context),\n      canLoad: async (context) => this.checkRoleAccess(context),\n    });\n\n    this.roleConfig = mergedConfig;\n\n    // Pre-expand roles with hierarchy\n    this._expandedRoles = this.expandRolesWithHierarchy(\n      config.requiredRoles,\n      config.roleHierarchy ?? {}\n    );\n  }\n\n  /**\n   * Get required roles\n   */\n  getRequiredRoles(): readonly string[] {\n    return this.roleConfig.requiredRoles;\n  }\n\n  /**\n   * Get match strategy\n   */\n  getMatchStrategy(): RoleMatchStrategy {\n    return this.roleConfig.matchStrategy ?? 'any';\n  }\n\n  /**\n   * Check roles without full guard execution\n   */\n  checkRoles(userRoles: readonly string[]): RoleCheckResult {\n    return this.performRoleCheck(userRoles);\n  }\n\n  /**\n   * Expand roles with hierarchy (include parent roles)\n   */\n  private expandRolesWithHierarchy(\n    roles: readonly string[],\n    hierarchy: Record<string, readonly string[]>\n  ): ReadonlySet<string> {\n    const expanded = new Set<string>(roles);\n\n    // For each role, add its parents recursively\n    const addParents = (role: string, visited: Set<string>): void => {\n      if (visited.has(role)) return; // Prevent cycles\n      visited.add(role);\n\n      const parents = hierarchy[role];\n      if (parents) {\n        for (const parent of parents) {\n          expanded.add(parent);\n          addParents(parent, visited);\n        }\n      }\n    };\n\n    for (const role of roles) {\n      addParents(role, new Set());\n    }\n\n    return expanded;\n  }\n\n  /**\n   * Check if user has required role access\n   */\n  private async checkRoleAccess(context: GuardContext): Promise<GuardResultObject> {\n    // Get user roles\n    const userRoles = this.getUserRoles(context);\n\n    // Check if user is authenticated\n    if (userRoles.length === 0 && context.user?.isAuthenticated === false) {\n      return Promise.resolve(\n        GuardResult.redirect(this.roleConfig.unauthorizedPath ?? '/unauthorized', {\n          state: { reason: 'Not authenticated' },\n        })\n      );\n    }\n\n    // Check role access\n    const checkResult = this.performRoleCheck(userRoles);\n\n    if (!checkResult.hasAccess) {\n      return Promise.resolve(this.handleUnauthorized(context, checkResult));\n    }\n\n    return Promise.resolve(GuardResult.allow({ roleCheck: checkResult }));\n  }\n\n  /**\n   * Get user roles from context\n   */\n  private getUserRoles(context: GuardContext): readonly string[] {\n    if (this.roleConfig.getUserRoles) {\n      return this.roleConfig.getUserRoles(context);\n    }\n\n    return context.user?.roles ?? [];\n  }\n\n  /**\n   * Perform role check based on strategy\n   */\n  private performRoleCheck(userRoles: readonly string[]): RoleCheckResult {\n    const strategy = this.roleConfig.matchStrategy ?? 'any';\n    const { requiredRoles } = this.roleConfig;\n\n    // Use custom check if provided\n    if (this.roleConfig.checkRoles) {\n      const hasAccess = this.roleConfig.checkRoles(userRoles, requiredRoles, strategy);\n      return {\n        hasAccess,\n        userRoles,\n        requiredRoles,\n        missingRoles: hasAccess ? [] : requiredRoles.filter((r) => !userRoles.includes(r)),\n        matchedRoles: requiredRoles.filter((r) => userRoles.includes(r)),\n        strategy,\n      };\n    }\n\n    // Expand user roles with hierarchy\n    const expandedUserRoles = this.expandUserRolesWithHierarchy(userRoles);\n\n    // Check based on strategy using pre-expanded required roles\n    let hasAccess = false;\n    const missingRoles: string[] = [];\n    const matchedRoles: string[] = [];\n\n    // Check if user has any of the required roles (or roles that satisfy them via hierarchy)\n    for (const role of this._expandedRoles) {\n      if (expandedUserRoles.has(role)) {\n        matchedRoles.push(role);\n      } else {\n        missingRoles.push(role);\n      }\n    }\n\n    switch (strategy) {\n      case 'any':\n        hasAccess = matchedRoles.length > 0;\n        break;\n      case 'all':\n        hasAccess = missingRoles.length === 0;\n        break;\n      case 'none':\n        hasAccess = matchedRoles.length === 0;\n        break;\n    }\n\n    return {\n      hasAccess,\n      userRoles,\n      requiredRoles,\n      missingRoles,\n      matchedRoles,\n      strategy,\n    };\n  }\n\n  /**\n   * Expand user roles with hierarchy\n   */\n  private expandUserRolesWithHierarchy(userRoles: readonly string[]): Set<string> {\n    const hierarchy = this.roleConfig.roleHierarchy ?? {};\n    const expanded = new Set<string>(userRoles);\n\n    // For hierarchy, a role includes its children's permissions\n    // So if user has 'super-admin' and hierarchy says super-admin includes 'admin',\n    // then user effectively has 'admin' role too\n    const addChildren = (role: string, visited: Set<string>): void => {\n      if (visited.has(role)) return;\n      visited.add(role);\n\n      // Check if this role is a parent of any other role\n      for (const [childRole, parents] of Object.entries(hierarchy)) {\n        if (parents.includes(role)) {\n          expanded.add(childRole);\n        }\n      }\n\n      // Also add explicit children\n      const children = hierarchy[role];\n      if (children) {\n        for (const child of children) {\n          expanded.add(child);\n        }\n      }\n    };\n\n    for (const role of userRoles) {\n      addChildren(role, new Set());\n    }\n\n    return expanded;\n  }\n\n  /**\n   * Handle unauthorized access\n   */\n  private handleUnauthorized(\n    _context: GuardContext,\n    checkResult: RoleCheckResult\n  ): GuardResultObject {\n    const unauthorizedPath = this.roleConfig.unauthorizedPath ?? '/unauthorized';\n    const message =\n      this.roleConfig.unauthorizedMessage ??\n      'You do not have the required role to access this page';\n\n    return GuardResult.redirect(unauthorizedPath, {\n      state: {\n        reason: message,\n        requiredRoles: checkResult.requiredRoles,\n        missingRoles: checkResult.missingRoles,\n        strategy: checkResult.strategy,\n      },\n    });\n  }\n}\n\n// =============================================================================\n// Factory Functions\n// =============================================================================\n\n/**\n * Create a role guard\n *\n * @param config - Guard configuration\n * @returns RoleGuard instance\n */\nexport function createRoleGuard(config: RoleGuardConfig): RoleGuard {\n  return new RoleGuard(config);\n}\n\n/**\n * Create a guard requiring a single role\n *\n * @param role - Required role\n * @param options - Additional options\n * @returns RoleGuard instance\n */\nexport function requireRole(\n  role: string,\n  options: Partial<Omit<RoleGuardConfig, 'requiredRoles'>> = {}\n): RoleGuard {\n  return new RoleGuard({\n    ...options,\n    requiredRoles: [role],\n    matchStrategy: 'any',\n  });\n}\n\n/**\n * Create a guard requiring any of the specified roles\n *\n * @param roles - Roles (any one required)\n * @param options - Additional options\n * @returns RoleGuard instance\n */\nexport function requireAnyRole(\n  roles: readonly string[],\n  options: Partial<Omit<RoleGuardConfig, 'requiredRoles' | 'matchStrategy'>> = {}\n): RoleGuard {\n  return new RoleGuard({\n    ...options,\n    requiredRoles: roles,\n    matchStrategy: 'any',\n  });\n}\n\n/**\n * Create a guard requiring all specified roles\n *\n * @param roles - Roles (all required)\n * @param options - Additional options\n * @returns RoleGuard instance\n */\nexport function requireAllRoles(\n  roles: readonly string[],\n  options: Partial<Omit<RoleGuardConfig, 'requiredRoles' | 'matchStrategy'>> = {}\n): RoleGuard {\n  return new RoleGuard({\n    ...options,\n    requiredRoles: roles,\n    matchStrategy: 'all',\n  });\n}\n\n/**\n * Create a guard excluding users with specified roles\n *\n * @param roles - Roles to exclude\n * @param options - Additional options\n * @returns RoleGuard instance\n */\nexport function excludeRoles(\n  roles: readonly string[],\n  options: Partial<Omit<RoleGuardConfig, 'requiredRoles' | 'matchStrategy'>> = {}\n): RoleGuard {\n  return new RoleGuard({\n    ...options,\n    requiredRoles: roles,\n    matchStrategy: 'none',\n    unauthorizedMessage: 'Access denied for your role',\n  });\n}\n\n/**\n * Create an admin guard\n *\n * @param options - Additional options\n * @returns RoleGuard for admin access\n */\nexport function createAdminGuard(\n  options: Partial<Omit<RoleGuardConfig, 'requiredRoles'>> = {}\n): RoleGuard {\n  return new RoleGuard({\n    name: 'admin',\n    requiredRoles: ['admin', 'super-admin'],\n    matchStrategy: 'any',\n    roleHierarchy: {\n      'super-admin': ['admin'],\n    },\n    unauthorizedMessage: 'Admin access required',\n    ...options,\n  });\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Check if user has a specific role\n *\n * @param userRoles - User's roles\n * @param role - Role to check\n * @param hierarchy - Optional role hierarchy\n * @returns True if user has role\n */\nexport function hasRole(\n  userRoles: readonly string[],\n  role: string,\n  hierarchy?: Record<string, readonly string[]>\n): boolean {\n  if (userRoles.includes(role)) {\n    return true;\n  }\n\n  if (hierarchy !== null && hierarchy !== undefined) {\n    // Check if user has a parent role\n    for (const userRole of userRoles) {\n      const parents = hierarchy[role];\n      if (parents?.includes(userRole) === true) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n\n/**\n * Check if user has any of the specified roles\n *\n * @param userRoles - User's roles\n * @param roles - Roles to check\n * @param hierarchy - Optional role hierarchy\n * @returns True if user has any role\n */\nexport function hasAnyRole(\n  userRoles: readonly string[],\n  roles: readonly string[],\n  hierarchy?: Record<string, readonly string[]>\n): boolean {\n  return roles.some((role) => hasRole(userRoles, role, hierarchy));\n}\n\n/**\n * Check if user has all specified roles\n *\n * @param userRoles - User's roles\n * @param roles - Roles to check\n * @param hierarchy - Optional role hierarchy\n * @returns True if user has all roles\n */\nexport function hasAllRoles(\n  userRoles: readonly string[],\n  roles: readonly string[],\n  hierarchy?: Record<string, readonly string[]>\n): boolean {\n  return roles.every((role) => hasRole(userRoles, role, hierarchy));\n}\n\n/**\n * Get missing roles for a user\n *\n * @param userRoles - User's roles\n * @param requiredRoles - Required roles\n * @param hierarchy - Optional role hierarchy\n * @returns Array of missing roles\n */\nexport function getMissingRoles(\n  userRoles: readonly string[],\n  requiredRoles: readonly string[],\n  hierarchy?: Record<string, readonly string[]>\n): string[] {\n  return requiredRoles.filter((role) => !hasRole(userRoles, role, hierarchy));\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\n/**\n * Type guard for RoleGuard\n */\nexport function isRoleGuard(value: unknown): value is RoleGuard {\n  return value instanceof RoleGuard;\n}\n\n/**\n * Type guard for RoleCheckResult\n */\nexport function isRoleCheckResult(value: unknown): value is RoleCheckResult {\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    'hasAccess' in value &&\n    'userRoles' in value &&\n    'requiredRoles' in value &&\n    'strategy' in value\n  );\n}\n"],"names":["DEFAULT_ROLE_CONFIG","RoleGuard","BaseRouteGuard","config","mergedConfig","context","userRoles","roles","hierarchy","expanded","addParents","role","visited","parents","parent","GuardResult","checkResult","strategy","requiredRoles","hasAccess","r","expandedUserRoles","missingRoles","matchedRoles","addChildren","childRole","children","child","_context","unauthorizedPath","message","createRoleGuard","requireRole","options","requireAnyRole","requireAllRoles","excludeRoles","createAdminGuard","hasRole","userRole","hasAnyRole","hasAllRoles","getMissingRoles","isRoleGuard","value","isRoleCheckResult"],"mappings":";AA6GO,MAAMA,IAAgD;AAAA,EAC3D,MAAM;AAAA,EACN,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,UAAU;AACZ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