@jmruthers/pace-core 0.5.109 → 0.5.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{DataTable-5HITILXS.js → DataTable-D3BK2FCN.js} +4 -4
  3. package/dist/{api-5I3E47G2.js → api-PIE4JRFS.js} +2 -2
  4. package/dist/{chunk-P72NKAT5.js → chunk-3J5N2T2N.js} +51 -11
  5. package/dist/chunk-3J5N2T2N.js.map +1 -0
  6. package/dist/{chunk-3TKTL5AZ.js → chunk-7GBEBJLR.js} +26 -34
  7. package/dist/chunk-7GBEBJLR.js.map +1 -0
  8. package/dist/{chunk-S4D3Z723.js → chunk-AWK2FAUN.js} +3 -3
  9. package/dist/{chunk-WWNOVFDC.js → chunk-HADXAZT3.js} +2 -2
  10. package/dist/{chunk-UW2DE6JX.js → chunk-HGZSO43Y.js} +2 -2
  11. package/dist/{chunk-F6TSYCKP.js → chunk-XRSP3H52.js} +12 -7
  12. package/dist/chunk-XRSP3H52.js.map +1 -0
  13. package/dist/components.js +4 -4
  14. package/dist/hooks.js +1 -1
  15. package/dist/index.js +6 -6
  16. package/dist/rbac/index.d.ts +34 -22
  17. package/dist/rbac/index.js +3 -3
  18. package/dist/utils.js +1 -1
  19. package/docs/api/classes/ColumnFactory.md +1 -1
  20. package/docs/api/classes/ErrorBoundary.md +1 -1
  21. package/docs/api/classes/InvalidScopeError.md +1 -1
  22. package/docs/api/classes/MissingUserContextError.md +1 -1
  23. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  24. package/docs/api/classes/PermissionDeniedError.md +1 -1
  25. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  26. package/docs/api/classes/RBACAuditManager.md +1 -1
  27. package/docs/api/classes/RBACCache.md +1 -1
  28. package/docs/api/classes/RBACEngine.md +9 -8
  29. package/docs/api/classes/RBACError.md +1 -1
  30. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  31. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  32. package/docs/api/classes/StorageUtils.md +1 -1
  33. package/docs/api/enums/FileCategory.md +1 -1
  34. package/docs/api/interfaces/AggregateConfig.md +1 -1
  35. package/docs/api/interfaces/ButtonProps.md +1 -1
  36. package/docs/api/interfaces/CardProps.md +1 -1
  37. package/docs/api/interfaces/ColorPalette.md +1 -1
  38. package/docs/api/interfaces/ColorShade.md +1 -1
  39. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  40. package/docs/api/interfaces/DataRecord.md +1 -1
  41. package/docs/api/interfaces/DataTableAction.md +1 -1
  42. package/docs/api/interfaces/DataTableColumn.md +1 -1
  43. package/docs/api/interfaces/DataTableProps.md +1 -1
  44. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  45. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  46. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  47. package/docs/api/interfaces/FileDisplayProps.md +1 -1
  48. package/docs/api/interfaces/FileMetadata.md +1 -1
  49. package/docs/api/interfaces/FileReference.md +1 -1
  50. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  51. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  52. package/docs/api/interfaces/FileUploadProps.md +1 -1
  53. package/docs/api/interfaces/FooterProps.md +1 -1
  54. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  55. package/docs/api/interfaces/InputProps.md +1 -1
  56. package/docs/api/interfaces/LabelProps.md +1 -1
  57. package/docs/api/interfaces/LoginFormProps.md +1 -1
  58. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  59. package/docs/api/interfaces/NavigationContextType.md +1 -1
  60. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  61. package/docs/api/interfaces/NavigationItem.md +1 -1
  62. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  63. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  64. package/docs/api/interfaces/Organisation.md +1 -1
  65. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  66. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  67. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  68. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  69. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  70. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  71. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  72. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  73. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  74. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  75. package/docs/api/interfaces/PaletteData.md +1 -1
  76. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  77. package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
  78. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  79. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  80. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  81. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  82. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  83. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  84. package/docs/api/interfaces/RBACConfig.md +19 -8
  85. package/docs/api/interfaces/RBACLogger.md +5 -5
  86. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  87. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  88. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  89. package/docs/api/interfaces/RouteConfig.md +1 -1
  90. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  91. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  92. package/docs/api/interfaces/StorageConfig.md +1 -1
  93. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  94. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  95. package/docs/api/interfaces/StorageListOptions.md +1 -1
  96. package/docs/api/interfaces/StorageListResult.md +1 -1
  97. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  98. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  99. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  100. package/docs/api/interfaces/StyleImport.md +1 -1
  101. package/docs/api/interfaces/SwitchProps.md +1 -1
  102. package/docs/api/interfaces/ToastActionElement.md +1 -1
  103. package/docs/api/interfaces/ToastProps.md +1 -1
  104. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  105. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  106. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  107. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  108. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  109. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  110. package/docs/api/interfaces/UsePublicFileDisplayOptions.md +1 -1
  111. package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
  112. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  113. package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
  114. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  115. package/docs/api/interfaces/UserEventAccess.md +1 -1
  116. package/docs/api/interfaces/UserMenuProps.md +1 -1
  117. package/docs/api/interfaces/UserProfile.md +1 -1
  118. package/docs/api/modules.md +21 -20
  119. package/docs/documentation-index.md +0 -2
  120. package/docs/rbac/README.md +114 -38
  121. package/docs/rbac/api-reference.md +63 -16
  122. package/docs/rbac/getting-started.md +16 -16
  123. package/docs/rbac/quick-start.md +110 -35
  124. package/docs/rbac/troubleshooting.md +125 -2
  125. package/package.json +1 -1
  126. package/src/components/NavigationMenu/NavigationMenu.test.tsx +38 -4
  127. package/src/components/NavigationMenu/NavigationMenu.tsx +71 -6
  128. package/src/rbac/api.test.ts +2 -2
  129. package/src/rbac/api.ts +2 -1
  130. package/src/rbac/components/PagePermissionGuard.tsx +21 -38
  131. package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +1 -1
  132. package/src/rbac/config.ts +2 -0
  133. package/src/rbac/engine.ts +15 -5
  134. package/src/rbac/security.ts +1 -1
  135. package/dist/chunk-3TKTL5AZ.js.map +0 -1
  136. package/dist/chunk-F6TSYCKP.js.map +0 -1
  137. package/dist/chunk-P72NKAT5.js.map +0 -1
  138. package/docs/rbac/breaking-changes-v3.md +0 -222
  139. package/docs/rbac/migration-guide.md +0 -260
  140. /package/dist/{DataTable-5HITILXS.js.map → DataTable-D3BK2FCN.js.map} +0 -0
  141. /package/dist/{api-5I3E47G2.js.map → api-PIE4JRFS.js.map} +0 -0
  142. /package/dist/{chunk-S4D3Z723.js.map → chunk-AWK2FAUN.js.map} +0 -0
  143. /package/dist/{chunk-WWNOVFDC.js.map → chunk-HADXAZT3.js.map} +0 -0
  144. /package/dist/{chunk-UW2DE6JX.js.map → chunk-HGZSO43Y.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.110] - 2025-01-27
11
+
12
+ ### Added
13
+ - **Automatic Page Permission Checking in NavigationMenu**: Navigation items with `href` but no explicit permissions/roles/accessLevel now automatically check for `read:page.{pageId}` permission, making navigation filtering more intuitive
14
+ - **RBAC Security Configuration Support**: `RBACEngine` and `createRBACEngine` now accept an optional `securityConfig` parameter, allowing customization of rate limits and security settings per instance
15
+
16
+ ### Changed
17
+ - **RBAC Rate Limit Increase**: Increased default `maxPermissionChecksPerMinute` from 100 to 1000 to accommodate normal application usage patterns
18
+ - **NavigationMenu Filtering Improvements**: Enhanced recursive filtering of navigation items with proper parent/child handling - parents without accessible children are now properly hidden
19
+ - **RBAC Documentation Updates**: Improved RBAC documentation with better examples, troubleshooting guides, and API references
20
+ - **PagePermissionGuard Scope Handling**: Replaced ref-based scope tracking with `useMemo` for better React compatibility and performance, with improved handling of undefined `appId` values
21
+
22
+ ### Fixed
23
+ - **PagePermissionGuard Infinite Loop Prevention**: Fixed potential infinite loops by improving scope stability and ensuring `useCan` only runs with valid scopes
24
+ - **PagePermissionGuard Error Logging**: Enhanced error logging with more context (permission strings, page IDs, scope validation status)
25
+ - **NavigationMenu Test Mocks**: Updated test mocks to default to permissive permissions (super admin access) for better test isolation and clearer test intent
26
+ - **RBAC API Test Assertions**: Fixed test assertions to correctly match `createRBACEngine` function signature with optional parameters
27
+
28
+ ### Removed
29
+ - **pace-core-devtools Package**: Removed the entire `pace-core-devtools` package and all related devtools functionality (AuditInspector, PerformanceMonitor, PermissionDebugger, RoleSimulator, etc.)
30
+ - **Outdated RBAC Documentation**: Removed deprecated `breaking-changes-v3.md` and `migration-guide.md` files that are no longer relevant
31
+
10
32
  ## [0.5.109] - 2025-11-03
11
33
 
12
34
  ### Added
@@ -54,9 +54,9 @@ import {
54
54
  sortHierarchicalDataWithSorting,
55
55
  validateHierarchicalData,
56
56
  validatePaginationConfig
57
- } from "./chunk-UW2DE6JX.js";
58
- import "./chunk-WWNOVFDC.js";
59
- import "./chunk-F6TSYCKP.js";
57
+ } from "./chunk-HGZSO43Y.js";
58
+ import "./chunk-HADXAZT3.js";
59
+ import "./chunk-XRSP3H52.js";
60
60
  import "./chunk-Q7APDV6H.js";
61
61
  import {
62
62
  CircuitBreaker,
@@ -157,4 +157,4 @@ export {
157
157
  validateHierarchicalData,
158
158
  validatePaginationConfig
159
159
  };
160
- //# sourceMappingURL=DataTable-5HITILXS.js.map
160
+ //# sourceMappingURL=DataTable-D3BK2FCN.js.map
@@ -19,7 +19,7 @@ import {
19
19
  isSuperAdmin,
20
20
  resolveAppContext,
21
21
  setupRBAC
22
- } from "./chunk-F6TSYCKP.js";
22
+ } from "./chunk-XRSP3H52.js";
23
23
  import "./chunk-Q7APDV6H.js";
24
24
  import "./chunk-PLDDJCW6.js";
25
25
  export {
@@ -44,4 +44,4 @@ export {
44
44
  resolveAppContext,
45
45
  setupRBAC
46
46
  };
47
- //# sourceMappingURL=api-5I3E47G2.js.map
47
+ //# sourceMappingURL=api-PIE4JRFS.js.map
@@ -25,16 +25,16 @@ import {
25
25
  SelectSeparator,
26
26
  SelectTrigger,
27
27
  SelectValue
28
- } from "./chunk-UW2DE6JX.js";
28
+ } from "./chunk-HGZSO43Y.js";
29
29
  import {
30
30
  usePermissions,
31
31
  useRBAC,
32
32
  useResolvedScope
33
- } from "./chunk-WWNOVFDC.js";
33
+ } from "./chunk-HADXAZT3.js";
34
34
  import {
35
35
  isPermitted,
36
36
  isSuperAdmin
37
- } from "./chunk-F6TSYCKP.js";
37
+ } from "./chunk-XRSP3H52.js";
38
38
  import {
39
39
  OrganisationProvider_exports,
40
40
  PublicErrorBoundary,
@@ -929,8 +929,12 @@ var NavigationMenu = React9.forwardRef(({
929
929
  if (!filterByPermissions || !authContext || !rbacContext || scopeLoading || permissionsLoading || !resolvedScope?.organisationId) {
930
930
  return (items || []).filter((item) => !item.meta?.hidden);
931
931
  }
932
- return (items || []).filter((item) => {
933
- if (item.meta?.hidden) return false;
932
+ const getPageIdFromHref = (href) => {
933
+ if (!href) return null;
934
+ const path = href.split("?")[0].split("#")[0].replace(/^\//, "");
935
+ return path || "home";
936
+ };
937
+ const hasItemPermission = (item) => {
934
938
  if (item.permissions && item.permissions.length > 0) {
935
939
  const permissions = item.permissions.filter((p) => typeof p === "string").map((p) => p);
936
940
  if (permissions.length > 0) {
@@ -986,8 +990,43 @@ var NavigationMenu = React9.forwardRef(({
986
990
  }
987
991
  }
988
992
  }
993
+ if (item.href && !item.permissions && !item.roles && !item.accessLevel) {
994
+ const pageId = item.pageId || getPageIdFromHref(item.href);
995
+ if (pageId) {
996
+ const pagePermission = `read:page.${pageId}`;
997
+ const hasPagePermission = permissionMap["*"] === true || permissionMap[pagePermission] === true;
998
+ if (!hasPagePermission) {
999
+ if (auditLog) {
1000
+ console.log(`[NavigationMenu] Filtering out navigation item "${item.label}" - no page permission:`, {
1001
+ itemId: item.id,
1002
+ href: item.href,
1003
+ pageId,
1004
+ permission: pagePermission,
1005
+ hasPermission: hasPagePermission
1006
+ });
1007
+ }
1008
+ return false;
1009
+ }
1010
+ }
1011
+ }
989
1012
  return true;
990
- });
1013
+ };
1014
+ const filterItem = (item) => {
1015
+ if (item.meta?.hidden) return null;
1016
+ if (!hasItemPermission(item)) return null;
1017
+ let filteredChildren;
1018
+ if (item.children && item.children.length > 0) {
1019
+ filteredChildren = item.children.map((child) => filterItem(child)).filter((child) => child !== null);
1020
+ if (filteredChildren.length === 0 && !item.href) {
1021
+ return null;
1022
+ }
1023
+ }
1024
+ return {
1025
+ ...item,
1026
+ children: filteredChildren
1027
+ };
1028
+ };
1029
+ return (items || []).map((item) => filterItem(item)).filter((item) => item !== null);
991
1030
  }, [
992
1031
  items,
993
1032
  filterByPermissions,
@@ -997,7 +1036,8 @@ var NavigationMenu = React9.forwardRef(({
997
1036
  hasAnyPermission,
998
1037
  scopeLoading,
999
1038
  permissionsLoading,
1000
- resolvedScope
1039
+ resolvedScope,
1040
+ auditLog
1001
1041
  ]);
1002
1042
  React9.useEffect(() => {
1003
1043
  if (auditLog && authContext) {
@@ -1379,7 +1419,7 @@ function PaceAppLayout({
1379
1419
  appId: user.user_metadata?.appId || user.app_metadata?.appId
1380
1420
  };
1381
1421
  try {
1382
- const { isSuperAdmin: isSuperAdmin2 } = await import("./api-5I3E47G2.js");
1422
+ const { isSuperAdmin: isSuperAdmin2 } = await import("./api-PIE4JRFS.js");
1383
1423
  const isSuper = await isSuperAdmin2(user.id);
1384
1424
  if (isSuper) {
1385
1425
  return true;
@@ -1499,7 +1539,7 @@ function PaceAppLayout({
1499
1539
  appId: user.user_metadata?.appId || user.app_metadata?.appId
1500
1540
  };
1501
1541
  try {
1502
- const { isSuperAdmin: isSuperAdmin2 } = await import("./api-5I3E47G2.js");
1542
+ const { isSuperAdmin: isSuperAdmin2 } = await import("./api-PIE4JRFS.js");
1503
1543
  const isSuper = await isSuperAdmin2(user.id);
1504
1544
  if (isSuper) {
1505
1545
  if (isMounted) {
@@ -1520,7 +1560,7 @@ function PaceAppLayout({
1520
1560
  return;
1521
1561
  }
1522
1562
  try {
1523
- const { getPermissionMap } = await import("./api-5I3E47G2.js");
1563
+ const { getPermissionMap } = await import("./api-PIE4JRFS.js");
1524
1564
  const permissionMap = await getPermissionMap({
1525
1565
  userId: user.id,
1526
1566
  scope
@@ -4413,4 +4453,4 @@ export {
4413
4453
  PublicPageDiagnostic,
4414
4454
  PublicPageContextChecker
4415
4455
  };
4416
- //# sourceMappingURL=chunk-P72NKAT5.js.map
4456
+ //# sourceMappingURL=chunk-3J5N2T2N.js.map