UNPKG

@compugit/react-rbac

Version:

A comprehensive Role-Based Access Control (RBAC) library for React applications with support for groups, roles, permissions, and protected components

32 lines (31 loc) 1.44 kB
import type { AuthorizationMode } from "../types/rbac"; export declare const useRBAC: () => { user: import("../types/rbac").User | null; loading: boolean; error: string | null; initialized: boolean; userPermissions: import("../types/rbac").Permission[]; userRoles: import("../types/rbac").Role[]; userGroups: import("../types/rbac").Group[]; hasPermission: (permissionName: string | string[], mode?: AuthorizationMode) => boolean; hasRole: (roleName: string | string[], mode?: AuthorizationMode) => boolean; hasGroup: (groupName: string | string[], mode?: AuthorizationMode) => boolean; hasAccess: (options: { permissions?: string[]; roles?: string[]; groups?: string[]; mode?: AuthorizationMode; }) => boolean; canAccess: (resource: string, action: string) => boolean; isAuthenticated: () => boolean; isInRole: (roleName: string) => boolean; isInGroup: (groupName: string) => boolean; setUser: (user: import("../types/rbac").User | null) => void; setLoading: (loading: boolean) => void; setError: (error: string | null) => void; updateUserPermissions: (permissions: import("../types/rbac").Permission[]) => void; updateUserRoles: (roles: import("../types/rbac").Role[]) => void; updateUserGroups: (groups: import("../types/rbac").Group[]) => void; clearAuth: () => void; refreshUser: () => Promise<void>; };