@jmruthers/pace-core 0.5.76 → 0.5.78
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.
- package/CHANGELOG.md +8 -0
- package/dist/{RBACService-C4udt_Zp.d.ts → AuthService-Df3IozMG.d.ts} +10 -118
- package/dist/{DataTable-ntgmhO2W.d.ts → DataTable-BE0OXZKQ.d.ts} +9 -2
- package/dist/{DataTable-4GAVPIEG.js → DataTable-ETGVF4Y5.js} +50 -13
- package/dist/{PublicLoadingSpinner-BiNER8F5.d.ts → PublicLoadingSpinner-CnUaz0vG.d.ts} +5 -2
- package/dist/{UnifiedAuthProvider-Bj6YCf7c.d.ts → UnifiedAuthProvider-B391Aqum.d.ts} +42 -45
- package/dist/{UnifiedAuthProvider-3NKDOSOK.js → UnifiedAuthProvider-P5SOJAQ6.js} +4 -5
- package/dist/{api-DDMUKIUD.js → api-KG4A2X7P.js} +9 -3
- package/dist/{audit-6TOCAMKO.js → audit-65VNHEV2.js} +2 -2
- package/dist/{chunk-K34IM5CT.js → chunk-2OGV6IRV.js} +196 -626
- package/dist/chunk-2OGV6IRV.js.map +1 -0
- package/dist/{chunk-NTNILOBC.js → chunk-5BO3MI5Y.js} +4 -4
- package/dist/{chunk-XLZ7U46Z.js → chunk-CVMVPYAL.js} +9 -60
- package/dist/chunk-CVMVPYAL.js.map +1 -0
- package/dist/{chunk-URUTVZ7N.js → chunk-FL4ZCQLD.js} +2 -2
- package/dist/{chunk-LW7MMEAQ.js → chunk-FT2M4R4F.js} +2 -2
- package/dist/{chunk-5BSLGBYI.js → chunk-JCQZ6LA7.js} +2 -8
- package/dist/{chunk-5BSLGBYI.js.map → chunk-JCQZ6LA7.js.map} +1 -1
- package/dist/{chunk-KHJS6VIA.js → chunk-LRQ6RBJC.js} +157 -112
- package/dist/chunk-LRQ6RBJC.js.map +1 -0
- package/dist/{chunk-WN6XJWOS.js → chunk-MNJXXD6C.js} +274 -743
- package/dist/chunk-MNJXXD6C.js.map +1 -0
- package/dist/{chunk-KK73ZB4E.js → chunk-PTR5PMPE.js} +153 -132
- package/dist/chunk-PTR5PMPE.js.map +1 -0
- package/dist/{chunk-B2WTCLCV.js → chunk-Q7APDV6H.js} +18 -8
- package/dist/chunk-Q7APDV6H.js.map +1 -0
- package/dist/{chunk-A4FUBC7B.js → chunk-QGVSOUJ2.js} +2 -4
- package/dist/{chunk-A4FUBC7B.js.map → chunk-QGVSOUJ2.js.map} +1 -1
- package/dist/{chunk-FGMFQSHX.js → chunk-S63MFSY6.js} +500 -551
- package/dist/chunk-S63MFSY6.js.map +1 -0
- package/dist/{chunk-AFGTSUAD.js → chunk-VSOKOFRF.js} +4 -4
- package/dist/chunk-WUXCWRL6.js +20 -0
- package/dist/chunk-WUXCWRL6.js.map +1 -0
- package/dist/{chunk-Y6TXWPJO.js → chunk-YVVGHRGI.js} +105 -31
- package/dist/chunk-YVVGHRGI.js.map +1 -0
- package/dist/{chunk-M5IWZRBT.js → chunk-ZMNXIJP4.js} +2187 -981
- package/dist/chunk-ZMNXIJP4.js.map +1 -0
- package/dist/components.d.ts +6 -6
- package/dist/components.js +14 -18
- package/dist/components.js.map +1 -1
- package/dist/{database-C3Szpi5J.d.ts → database-BXAfr2Y_.d.ts} +18 -0
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +8 -9
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +19 -27
- package/dist/index.js +21 -29
- package/dist/index.js.map +1 -1
- package/dist/{organisation-BtshODVF.d.ts → organisation-D6qRDtbF.d.ts} +1 -1
- package/dist/providers.d.ts +7 -21
- package/dist/providers.js +3 -10
- package/dist/rbac/index.d.ts +71 -221
- package/dist/rbac/index.js +15 -16
- package/dist/{types-CGX9Vyf5.d.ts → types-BDg1mAGG.d.ts} +36 -6
- package/dist/types.d.ts +3 -3
- package/dist/types.js +61 -18
- package/dist/types.js.map +1 -1
- package/dist/{unified-CM7T0aTK.d.ts → unified-DQ4VcT7H.d.ts} +1 -1
- package/dist/{usePublicRouteParams-B-CumWRc.d.ts → usePublicRouteParams-BlgwXweB.d.ts} +3 -3
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +52 -9
- package/dist/utils.js.map +1 -1
- package/docs/CONTENT_AUDIT_REPORT.md +253 -0
- package/docs/DOCUMENTATION_AUDIT.md +172 -0
- package/docs/README.md +142 -147
- package/docs/STYLE_GUIDE.md +37 -0
- package/docs/api/classes/ColumnFactory.md +17 -17
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +4 -4
- package/docs/api/classes/MissingUserContextError.md +4 -4
- package/docs/api/classes/OrganisationContextRequiredError.md +4 -4
- package/docs/api/classes/PermissionDeniedError.md +5 -5
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +8 -8
- package/docs/api/classes/RBACCache.md +35 -5
- package/docs/api/classes/RBACEngine.md +49 -20
- package/docs/api/classes/RBACError.md +4 -4
- package/docs/api/classes/RBACNotInitializedError.md +4 -4
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +4 -4
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +11 -0
- package/docs/api/interfaces/DataTableAction.md +65 -29
- package/docs/api/interfaces/DataTableColumn.md +36 -23
- package/docs/api/interfaces/DataTableProps.md +80 -38
- package/docs/api/interfaces/DataTableToolbarButton.md +7 -7
- package/docs/api/interfaces/EmptyStateConfig.md +5 -5
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +11 -11
- package/docs/api/interfaces/NavigationContextType.md +9 -9
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +7 -7
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +16 -3
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +94 -521
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +16 -16
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +251 -269
- package/docs/api-reference/components.md +193 -0
- package/docs/api-reference/hooks.md +265 -0
- package/docs/api-reference/providers.md +6 -0
- package/docs/api-reference/types.md +6 -0
- package/docs/api-reference/utilities.md +207 -0
- package/docs/architecture/README.md +6 -0
- package/docs/{database-schema-requirements.md → architecture/database-schema-requirements.md} +6 -0
- package/docs/architecture/rbac-security-architecture.md +258 -0
- package/docs/architecture/services.md +9 -1
- package/docs/best-practices/README.md +6 -0
- package/docs/best-practices/accessibility.md +6 -0
- package/docs/{common-patterns.md → best-practices/common-patterns.md} +6 -0
- package/docs/best-practices/deployment.md +6 -0
- package/docs/best-practices/performance.md +475 -2
- package/docs/best-practices/security.md +6 -0
- package/docs/best-practices/testing.md +6 -0
- package/docs/core-concepts/authentication.md +6 -0
- package/docs/core-concepts/events.md +6 -0
- package/docs/core-concepts/organisations.md +6 -0
- package/docs/core-concepts/permissions.md +6 -0
- package/docs/core-concepts/rbac-system.md +8 -0
- package/docs/documentation-index.md +121 -182
- package/docs/{consuming-app-vite-config.md → getting-started/consuming-app-vite-config.md} +6 -0
- package/docs/getting-started/documentation-index.md +40 -0
- package/docs/getting-started/examples/README.md +878 -35
- package/docs/{faq.md → getting-started/faq.md} +7 -1
- package/docs/getting-started/installation-guide.md +6 -0
- package/docs/{quick-reference.md → getting-started/quick-reference.md} +6 -0
- package/docs/implementation-guides/app-layout.md +6 -0
- package/docs/implementation-guides/authentication.md +1021 -0
- package/docs/implementation-guides/component-styling.md +6 -0
- package/docs/implementation-guides/data-tables.md +1264 -2076
- package/docs/implementation-guides/dynamic-colors.md +6 -0
- package/docs/implementation-guides/event-theming-summary.md +6 -0
- package/docs/{file-reference-system.md → implementation-guides/file-reference-system.md} +6 -0
- package/docs/implementation-guides/file-upload-storage.md +6 -0
- package/docs/implementation-guides/forms.md +6 -0
- package/docs/implementation-guides/inactivity-tracking.md +6 -0
- package/docs/implementation-guides/navigation.md +6 -0
- package/docs/implementation-guides/organisation-security.md +6 -0
- package/docs/implementation-guides/permission-enforcement.md +6 -0
- package/docs/implementation-guides/public-pages-advanced.md +6 -0
- package/docs/implementation-guides/public-pages.md +6 -0
- package/docs/migration/MIGRATION_GUIDE.md +827 -351
- package/docs/migration/README.md +7 -1
- package/docs/migration/organisation-context-timing-fix.md +6 -0
- package/docs/migration/rbac-migration.md +44 -1
- package/docs/migration/service-architecture.md +6 -0
- package/docs/migration/v0.4.15-tailwind-scanning.md +6 -0
- package/docs/migration/v0.4.16-css-first-approach.md +6 -0
- package/docs/migration/v0.4.17-source-path-fix.md +6 -0
- package/docs/rbac/README-rbac-rls-integration.md +6 -0
- package/docs/rbac/README.md +6 -0
- package/docs/rbac/advanced-patterns.md +6 -0
- package/docs/rbac/api-reference.md +7 -1
- package/docs/rbac/breaking-changes-v3.md +222 -0
- package/docs/rbac/examples/rbac-rls-integration-example.md +6 -0
- package/docs/rbac/examples.md +6 -0
- package/docs/rbac/getting-started.md +6 -0
- package/docs/rbac/migration-guide.md +260 -0
- package/docs/rbac/quick-start.md +70 -13
- package/docs/rbac/rbac-rls-integration.md +6 -0
- package/docs/rbac/super-admin-guide.md +6 -0
- package/docs/rbac/troubleshooting.md +6 -0
- package/docs/security/README.md +6 -0
- package/docs/security/checklist.md +6 -0
- package/docs/styles/README.md +7 -1
- package/docs/{usage.md → styles/usage.md} +6 -0
- package/docs/testing/README.md +6 -0
- package/docs/{visual-testing.md → testing/visual-testing.md} +6 -0
- package/docs/troubleshooting/README.md +387 -5
- package/docs/troubleshooting/cake-page-permission-guard-issue-summary.md +6 -0
- package/docs/troubleshooting/common-issues.md +6 -0
- package/docs/troubleshooting/database-view-compatibility.md +6 -0
- package/docs/troubleshooting/organisation-context-setup.md +6 -0
- package/docs/troubleshooting/react-hooks-issue-analysis.md +6 -0
- package/docs/troubleshooting/styling-issues.md +6 -0
- package/docs/troubleshooting/tailwind-content-scanning.md +6 -0
- package/package.json +1 -1
- package/src/__tests__/helpers/__tests__/test-providers.test.tsx +2 -1
- package/src/__tests__/helpers/test-providers.tsx +3 -53
- package/src/components/DataTable/DataTable.test.tsx +319 -0
- package/src/components/DataTable/DataTable.tsx +32 -11
- package/src/components/DataTable/__tests__/{DataTable.comprehensive.test.tsx → DataTable.comprehensive.test.tsx.skip} +6 -4
- package/src/components/DataTable/__tests__/{DataTable.test.tsx → DataTable.test.tsx.skip} +6 -4
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +31 -9
- package/src/components/DataTable/__tests__/a11y.basic.test.tsx +601 -0
- package/src/components/DataTable/__tests__/keyboard.test.tsx +615 -0
- package/src/components/DataTable/__tests__/pagination.modes.test.tsx +639 -0
- package/src/components/DataTable/__tests__/ssr.strict-mode.test.tsx.skip +330 -0
- package/src/components/DataTable/components/AccessDeniedPage.tsx +2 -2
- package/src/components/DataTable/components/ActionButtons.tsx +88 -104
- package/src/components/DataTable/components/DataTableCore.tsx +309 -337
- package/src/components/DataTable/components/DataTableErrorBoundary.tsx +4 -2
- package/src/components/DataTable/components/DataTableModals.tsx +22 -1
- package/src/components/DataTable/components/EditableRow.tsx +69 -84
- package/src/components/DataTable/components/EmptyState.tsx +5 -1
- package/src/components/DataTable/components/ImportModal.tsx +65 -36
- package/src/components/DataTable/components/PaginationControls.tsx +40 -100
- package/src/components/DataTable/components/UnifiedTableBody.tsx +125 -148
- package/src/components/DataTable/context/DataTableContext.tsx +1 -1
- package/src/components/DataTable/core/ColumnFactory.ts +5 -0
- package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +12 -10
- package/src/components/DataTable/examples/HierarchicalExample.tsx +1 -1
- package/src/components/DataTable/examples/InitialPageSizeExample.tsx +1 -0
- package/src/components/DataTable/examples/PerformanceExample.tsx +1 -0
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +1 -5
- package/src/components/DataTable/hooks/__tests__/useColumnVisibilityPersistence.test.ts +167 -0
- package/src/components/DataTable/hooks/index.ts +7 -0
- package/src/components/DataTable/hooks/useColumnOrderPersistence.ts +32 -15
- package/src/components/DataTable/hooks/useColumnVisibilityPersistence.ts +102 -0
- package/src/components/DataTable/hooks/useDataTableConfiguration.ts +89 -0
- package/src/components/DataTable/hooks/useDataTableDataPipeline.ts +117 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +71 -27
- package/src/components/DataTable/hooks/useDataTableState.ts +39 -11
- package/src/components/DataTable/hooks/useEffectiveColumnOrder.ts +33 -0
- package/src/components/DataTable/hooks/useHierarchicalState.ts +15 -1
- package/src/components/DataTable/hooks/useKeyboardNavigation.ts +447 -0
- package/src/components/DataTable/hooks/useServerSideDataEffect.ts +94 -0
- package/src/components/DataTable/hooks/useTableColumns.ts +10 -7
- package/src/components/DataTable/hooks/useTableHandlers.ts +174 -0
- package/src/components/DataTable/index.ts +12 -3
- package/src/components/DataTable/types.ts +129 -9
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +159 -22
- package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +111 -0
- package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +15 -29
- package/src/components/DataTable/utils/a11yUtils.ts +244 -0
- package/src/components/DataTable/utils/debugTools.ts +609 -0
- package/src/components/DataTable/utils/exportUtils.ts +114 -16
- package/src/components/DataTable/utils/flexibleImport.ts +202 -32
- package/src/components/DataTable/utils/hierarchicalUtils.ts +1 -1
- package/src/components/DataTable/utils/index.ts +2 -0
- package/src/components/DataTable/utils/paginationUtils.ts +350 -0
- package/src/components/DataTable/utils/rowUtils.ts +6 -5
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +19 -24
- package/src/components/NavigationMenu/NavigationMenu.tsx +19 -8
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +1 -23
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +56 -6
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +137 -13
- package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +1 -1
- package/src/components/Select/Select.tsx +1 -0
- package/src/components/examples/PermissionExample.tsx +173 -0
- package/src/examples/CorrectPublicPageImplementation.tsx +301 -0
- package/src/examples/PublicEventPage.tsx +274 -0
- package/src/examples/PublicPageApp.tsx +308 -0
- package/src/examples/PublicPageUsageExample.tsx +216 -0
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +12 -1
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +129 -17
- package/src/hooks/__tests__/useRBAC.unit.test.ts +151 -846
- package/src/hooks/useOrganisationPermissions.test.ts +42 -18
- package/src/hooks/useOrganisationPermissions.ts +12 -6
- package/src/hooks/useOrganisationSecurity.test.ts +138 -85
- package/src/hooks/useOrganisationSecurity.ts +41 -10
- package/src/index.ts +0 -1
- package/src/providers/AuthProvider.simplified.tsx +880 -0
- package/src/providers/UnifiedAuthProvider.test.simple.tsx +8 -8
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +29 -19
- package/src/providers/index.ts +0 -1
- package/src/providers/services/EventServiceProvider.tsx +19 -15
- package/src/providers/services/InactivityServiceProvider.tsx +19 -15
- package/src/providers/services/OrganisationServiceProvider.tsx +19 -15
- package/src/providers/services/UnifiedAuthProvider.tsx +156 -127
- package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +1 -1
- package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +3 -3
- package/src/rbac/README.md +1 -1
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +25 -27
- package/src/rbac/__tests__/auth-rbac-security.integration.test.tsx +313 -0
- package/src/rbac/__tests__/engine.comprehensive.test.ts +114 -348
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +28 -110
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +33 -85
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +2 -2
- package/src/rbac/adapters.tsx +26 -69
- package/src/rbac/api.test.ts +90 -27
- package/src/rbac/api.ts +61 -10
- package/src/rbac/audit.test.ts +33 -38
- package/src/rbac/audit.ts +21 -6
- package/src/rbac/cache.ts +33 -1
- package/src/rbac/components/NavigationGuard.tsx +11 -11
- package/src/rbac/components/NavigationProvider.test.tsx +11 -5
- package/src/rbac/components/NavigationProvider.tsx +37 -13
- package/src/rbac/components/PagePermissionGuard.tsx +111 -50
- package/src/rbac/components/PagePermissionProvider.tsx +5 -5
- package/src/rbac/components/PermissionEnforcer.tsx +11 -11
- package/src/rbac/components/RoleBasedRouter.tsx +5 -5
- package/src/rbac/components/SecureDataProvider.tsx +5 -5
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +8 -8
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +14 -14
- package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +12 -12
- package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +6 -6
- package/src/rbac/engine.test.simple.ts +19 -13
- package/src/rbac/engine.test.ts +1 -0
- package/src/rbac/engine.ts +330 -766
- package/src/rbac/errors.ts +156 -0
- package/src/rbac/hooks/usePermissions.ts +32 -10
- package/src/rbac/hooks/useRBAC.test.ts +126 -512
- package/src/rbac/hooks/useRBAC.ts +147 -193
- package/src/rbac/hooks/useResolvedScope.ts +12 -0
- package/src/rbac/index.ts +7 -4
- package/src/rbac/security.ts +109 -18
- package/src/rbac/types.ts +12 -1
- package/src/services/AuthService.ts +2 -15
- package/src/services/EventService.ts +43 -46
- package/src/services/OrganisationService.ts +51 -31
- package/src/services/__tests__/AuthService.test.ts +1 -1
- package/src/services/__tests__/EventService.test.ts +1 -1
- package/src/services/__tests__/OrganisationService.test.ts +1 -1
- package/src/services/base/BaseService.ts +8 -0
- package/src/styles/base.css +208 -0
- package/src/styles/semantic.css +24 -0
- package/src/types/database.generated.ts +7347 -0
- package/src/types/database.ts +20 -0
- package/src/utils/logger.ts +179 -0
- package/src/utils/organisationContext.ts +11 -4
- package/src/utils/storage/__tests__/helpers.unit.test.ts +6 -2
- package/dist/appNameResolver-UURKN7NF.js +0 -22
- package/dist/audit-6TOCAMKO.js.map +0 -1
- package/dist/chunk-B2WTCLCV.js.map +0 -1
- package/dist/chunk-FGMFQSHX.js.map +0 -1
- package/dist/chunk-K34IM5CT.js.map +0 -1
- package/dist/chunk-KHJS6VIA.js.map +0 -1
- package/dist/chunk-KK73ZB4E.js.map +0 -1
- package/dist/chunk-M5IWZRBT.js.map +0 -1
- package/dist/chunk-ULBI5JGB.js +0 -109
- package/dist/chunk-ULBI5JGB.js.map +0 -1
- package/dist/chunk-WN6XJWOS.js.map +0 -1
- package/dist/chunk-XLZ7U46Z.js.map +0 -1
- package/dist/chunk-Y6TXWPJO.js.map +0 -1
- package/docs/DOCUMENTATION_CHECKLIST.md +0 -281
- package/docs/TERMINOLOGY.md +0 -231
- package/docs/api/interfaces/RBACContextType.md +0 -468
- package/docs/api/interfaces/RBACProviderProps.md +0 -107
- package/docs/best-practices/performance-expansion.md +0 -473
- package/docs/breaking-changes.md +0 -179
- package/docs/consuming-app-example.md +0 -290
- package/docs/documentation-templates.md +0 -539
- package/docs/examples/navigation-menu-auth-fix.md +0 -344
- package/docs/getting-started/examples/basic-auth-app.md +0 -520
- package/docs/getting-started/examples/full-featured-app.md +0 -616
- package/docs/getting-started/quick-start.md +0 -376
- package/docs/implementation-guides/datatable-filtering.md +0 -313
- package/docs/implementation-guides/datatable-rbac-usage.md +0 -317
- package/docs/implementation-guides/hierarchical-datatable.md +0 -850
- package/docs/implementation-guides/large-datasets.md +0 -281
- package/docs/implementation-guides/performance.md +0 -403
- package/docs/migration/quick-migration-guide.md +0 -320
- package/docs/migration-guide.md +0 -193
- package/docs/migration-guides/unified-auth-provider-mandatory-timeouts.md +0 -226
- package/docs/performance/README.md +0 -551
- package/docs/style-guide.md +0 -964
- package/docs/troubleshooting/authentication-issues.md +0 -334
- package/docs/troubleshooting/debugging.md +0 -1117
- package/docs/troubleshooting/migration.md +0 -918
- package/src/__tests__/hooks/usePermissions.test.ts +0 -261
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +0 -574
- package/src/hooks/__tests__/ServiceHooks.test.tsx +0 -613
- package/src/hooks/services/__tests__/useServiceHooks.test.tsx +0 -137
- package/src/hooks/services/usePermissions.ts +0 -70
- package/src/hooks/services/useRBACService.ts +0 -30
- package/src/hooks/usePermissionCheck.ts +0 -150
- package/src/providers/__tests__/ServiceProviders.test.tsx +0 -477
- package/src/providers/services/RBACServiceProvider.tsx +0 -79
- package/src/rbac/__tests__/integration.authflow.test.tsx +0 -119
- package/src/rbac/__tests__/integration.navigation.test.tsx +0 -69
- package/src/rbac/__tests__/integration.securedata.test.tsx +0 -92
- package/src/rbac/__tests__/integration.smoke.test.tsx +0 -73
- package/src/rbac/providers/RBACProvider.tsx +0 -645
- package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +0 -688
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +0 -1186
- package/src/rbac/providers/index.ts +0 -11
- package/src/services/RBACService.ts +0 -522
- package/src/services/__tests__/RBACService.test.ts +0 -492
- package/src/services/interfaces/IRBACService.ts +0 -62
- package/src/utils/appNameResolver.test 2.ts +0 -494
- /package/dist/{DataTable-4GAVPIEG.js.map → DataTable-ETGVF4Y5.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-3NKDOSOK.js.map → UnifiedAuthProvider-P5SOJAQ6.js.map} +0 -0
- /package/dist/{api-DDMUKIUD.js.map → api-KG4A2X7P.js.map} +0 -0
- /package/dist/{appNameResolver-UURKN7NF.js.map → audit-65VNHEV2.js.map} +0 -0
- /package/dist/{chunk-NTNILOBC.js.map → chunk-5BO3MI5Y.js.map} +0 -0
- /package/dist/{chunk-URUTVZ7N.js.map → chunk-FL4ZCQLD.js.map} +0 -0
- /package/dist/{chunk-LW7MMEAQ.js.map → chunk-FT2M4R4F.js.map} +0 -0
- /package/dist/{chunk-AFGTSUAD.js.map → chunk-VSOKOFRF.js.map} +0 -0
- /package/docs/{app.css.example → styles/app.css.example} +0 -0
package/docs/migration/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Migration Guide
|
|
2
8
|
|
|
3
9
|
> **🔄 Upgrade and Migration** | [Unified Migration Guide](./MIGRATION_GUIDE.md) | [RBAC Migration](./rbac-migration.md)
|
|
@@ -464,7 +470,7 @@ import '@jmruthers/pace-core/src/styles/core.css';
|
|
|
464
470
|
## 📚 Additional Resources
|
|
465
471
|
|
|
466
472
|
- **[RBAC Migration Guide](./rbac-migration.md)** - Detailed RBAC migration
|
|
467
|
-
- **[
|
|
473
|
+
- **[Migration Guide](./MIGRATION_GUIDE.md)** - Complete migration reference
|
|
468
474
|
- **[Common Issues](../troubleshooting/common-issues.md)** - Troubleshooting migration issues
|
|
469
475
|
- **[API Reference](../api-reference/)** - Complete API documentation
|
|
470
476
|
|
|
@@ -1,10 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# RBAC Migration Guide
|
|
2
8
|
|
|
3
9
|
Migrate from the legacy RBAC system to the new PACE Core RBAC module.
|
|
4
10
|
|
|
5
11
|
## Overview
|
|
6
12
|
|
|
7
|
-
The new RBAC system provides improved performance, better type safety, and enhanced security features. This guide will help you migrate from the old
|
|
13
|
+
The new RBAC system provides improved performance, better type safety, and enhanced security features. This guide will help you migrate from the old RBAC system to the new `@jmruthers/pace-core/rbac` module.
|
|
14
|
+
|
|
15
|
+
## ⚠️ Recent Changes
|
|
16
|
+
|
|
17
|
+
### v0.4.2: Service Provider Refactoring
|
|
18
|
+
|
|
19
|
+
**Service Instance Management**: All service providers now use `useRef` instead of `useMemo` with dependencies to prevent unnecessary recreation on auth state changes. This fixes React StrictMode issues and "Request aborted" errors.
|
|
20
|
+
|
|
21
|
+
**Loading State Initialization**: All services now start with `isLoading = false` to prevent UI blocking issues. Loading states are only set to `true` when actively fetching data.
|
|
22
|
+
|
|
23
|
+
**Removed `enableRBAC` Prop**: RBAC is now always enabled. The `enableRBAC` prop has been removed from `UnifiedAuthProvider`.
|
|
24
|
+
|
|
25
|
+
### v0.4.1: Hook Name Changes
|
|
26
|
+
|
|
27
|
+
**IMPORTANT**: The provider hook has been renamed to avoid confusion:
|
|
28
|
+
|
|
29
|
+
- **Old**: `useRBAC()` from `RBACProvider` context
|
|
30
|
+
- **New**: `useRBACContext()` from `RBACProvider` context
|
|
31
|
+
|
|
32
|
+
This prevents confusion with the main `useRBAC()` hook from the RBAC module:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// For RBAC provider context (legacy)
|
|
36
|
+
import { useRBACContext } from '@jmruthers/pace-core/rbac/providers';
|
|
37
|
+
|
|
38
|
+
// For new RBAC system (recommended)
|
|
39
|
+
import { useRBAC } from '@jmruthers/pace-core/rbac';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Deprecated APIs
|
|
43
|
+
|
|
44
|
+
The following are deprecated and will be removed in a future version:
|
|
45
|
+
|
|
46
|
+
- `RBACService` class - Use RBACEngine instead
|
|
47
|
+
- `useRBACService` hook - Use `useRBAC()` instead
|
|
48
|
+
- `usePermissionCheck` hook - Use `useCan()` instead
|
|
49
|
+
|
|
50
|
+
See deprecation warnings in code for migration instructions.
|
|
8
51
|
|
|
9
52
|
## Breaking Changes
|
|
10
53
|
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Migration Guide: v0.4.15 Tailwind Content Scanning
|
|
2
8
|
|
|
3
9
|
This guide helps you migrate to pace-core v0.4.15+ which includes source files for proper Tailwind v4 content scanning.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Migration Guide: v0.4.16 CSS-First Approach
|
|
2
8
|
|
|
3
9
|
This guide helps you migrate to pace-core v0.4.16+ which uses Tailwind v4's CSS-first approach with `@source` directives for automatic content scanning.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# RBAC-RLS Integration: Dynamic Permission Enforcement
|
|
2
8
|
|
|
3
9
|
> **🚨 Critical Architecture Fix** - This integration solves the fundamental disconnect between configurable RBAC permissions and hardcoded RLS policies that was breaking core functionality.
|
package/docs/rbac/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# RBAC API Reference
|
|
2
8
|
|
|
3
9
|
Complete API documentation for the PACE Core RBAC system.
|
|
@@ -847,7 +853,7 @@ interface PermissionCheck {
|
|
|
847
853
|
pageId?: UUID;
|
|
848
854
|
}
|
|
849
855
|
|
|
850
|
-
type PermissionMap = Record<
|
|
856
|
+
type PermissionMap = Record<Permission | '*', boolean>;
|
|
851
857
|
```
|
|
852
858
|
|
|
853
859
|
### Role Types
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Breaking Changes in v3.0.0
|
|
8
|
+
|
|
9
|
+
This document describes all breaking changes in pace-core v3.0.0, specifically related to the auth/RBAC system.
|
|
10
|
+
|
|
11
|
+
## Summary
|
|
12
|
+
|
|
13
|
+
The auth/RBAC system has been significantly enhanced with mandatory security validation, comprehensive audit logging, and improved rate limiting. These changes improve security but require migration for existing code.
|
|
14
|
+
|
|
15
|
+
## Breaking Changes
|
|
16
|
+
|
|
17
|
+
### 1. Mandatory SecurityContext in RBACEngine
|
|
18
|
+
|
|
19
|
+
**Changed**: `SecurityContext` parameter is now required in `RBACEngine.isPermitted()`
|
|
20
|
+
|
|
21
|
+
**Before**:
|
|
22
|
+
```typescript
|
|
23
|
+
await engine.isPermitted({ userId, scope, permission });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**After**:
|
|
27
|
+
```typescript
|
|
28
|
+
await engine.isPermitted(
|
|
29
|
+
{ userId, scope, permission },
|
|
30
|
+
{ userId, organisationId, timestamp: new Date() }
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Migration**: Use the API layer's `isPermitted()` function which automatically creates the security context:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { isPermitted } from '@jmruthers/pace-core/rbac';
|
|
38
|
+
|
|
39
|
+
// No changes needed - API handles security context automatically
|
|
40
|
+
await isPermitted({ userId, scope, permission });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Enhanced Rate Limiting
|
|
44
|
+
|
|
45
|
+
**Changed**: Rate limiting is now mandatory and enforced on all permission checks
|
|
46
|
+
|
|
47
|
+
**Before**: Optional rate limiting that always returned true
|
|
48
|
+
|
|
49
|
+
**After**: Mandatory rate limiting with configurable limits (default: 100 requests/minute)
|
|
50
|
+
|
|
51
|
+
**Impact**: High-traffic applications may need to increase the limit:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { setupRBAC } from '@jmruthers/pace-core/rbac';
|
|
55
|
+
|
|
56
|
+
setupRBAC(supabase, {
|
|
57
|
+
maxPermissionChecksPerMinute: 200 // Customize as needed
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Comprehensive Audit Logging
|
|
62
|
+
|
|
63
|
+
**Changed**: All permission checks are now audited, including those without organisation context
|
|
64
|
+
|
|
65
|
+
**Before**: Audit events only emitted when organisationId was present
|
|
66
|
+
|
|
67
|
+
**After**: All permission checks are audited with special handling for events without organisation context
|
|
68
|
+
|
|
69
|
+
**Impact**: The `rbac_audit_events` table now includes:
|
|
70
|
+
- Events without organisation context (using null UUID fallback)
|
|
71
|
+
- Metadata flag `no_organisation_context: true` for tracking
|
|
72
|
+
- More comprehensive security monitoring
|
|
73
|
+
|
|
74
|
+
### 4. Optional organisationId in SecurityContext
|
|
75
|
+
|
|
76
|
+
**Changed**: `organisationId` is now optional in `SecurityContext` interface
|
|
77
|
+
|
|
78
|
+
**Before**:
|
|
79
|
+
```typescript
|
|
80
|
+
interface SecurityContext {
|
|
81
|
+
userId: UUID;
|
|
82
|
+
organisationId: UUID; // Required
|
|
83
|
+
timestamp: Date;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**After**:
|
|
88
|
+
```typescript
|
|
89
|
+
interface SecurityContext {
|
|
90
|
+
userId: UUID;
|
|
91
|
+
organisationId?: UUID; // Optional
|
|
92
|
+
timestamp: Date;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Impact**: No breaking change for consumers - the field is now optional.
|
|
97
|
+
|
|
98
|
+
### 5. Input Validation is Mandatory
|
|
99
|
+
|
|
100
|
+
**Changed**: Input validation is now always performed, not conditional on securityContext presence
|
|
101
|
+
|
|
102
|
+
**Before**: Input validation only performed if securityContext was provided
|
|
103
|
+
|
|
104
|
+
**After**: Input validation is mandatory for all permission checks
|
|
105
|
+
|
|
106
|
+
**Impact**: Invalid inputs will trigger security events and deny access.
|
|
107
|
+
|
|
108
|
+
**Required validations**:
|
|
109
|
+
- User ID must be valid UUID
|
|
110
|
+
- Permission must match `operation:resource` pattern
|
|
111
|
+
- Scope must include at least one valid identifier
|
|
112
|
+
|
|
113
|
+
## Non-Breaking Changes
|
|
114
|
+
|
|
115
|
+
### Enhanced Security Event Logging
|
|
116
|
+
|
|
117
|
+
Security events are now logged with more detail:
|
|
118
|
+
- Timestamp
|
|
119
|
+
- User agent
|
|
120
|
+
- IP address (when available)
|
|
121
|
+
- Context information
|
|
122
|
+
|
|
123
|
+
### Improved Rate Limiting
|
|
124
|
+
|
|
125
|
+
Rate limiting now uses sliding window algorithm instead of simple counters:
|
|
126
|
+
- More accurate limiting
|
|
127
|
+
- Automatic cleanup of expired entries
|
|
128
|
+
- Memory-efficient implementation
|
|
129
|
+
|
|
130
|
+
## Migration Timeline
|
|
131
|
+
|
|
132
|
+
### Deprecation Period (v2.0.0 - v2.9.0)
|
|
133
|
+
|
|
134
|
+
- All changes marked as deprecated
|
|
135
|
+
- Warnings in console
|
|
136
|
+
- Backward compatibility maintained
|
|
137
|
+
|
|
138
|
+
### Breaking Changes (v3.0.0)
|
|
139
|
+
|
|
140
|
+
- SecurityContext mandatory
|
|
141
|
+
- Rate limiting mandatory
|
|
142
|
+
- All breaking changes enforced
|
|
143
|
+
|
|
144
|
+
### Support Period
|
|
145
|
+
|
|
146
|
+
- Migration guide available
|
|
147
|
+
- Community support provided
|
|
148
|
+
- Automated migration tools (where possible)
|
|
149
|
+
|
|
150
|
+
## Upgrade Instructions
|
|
151
|
+
|
|
152
|
+
1. **Update Dependencies**:
|
|
153
|
+
```bash
|
|
154
|
+
npm install @jmruthers/pace-core@^3.0.0
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
2. **Review Breaking Changes**: Read this document and the migration guide
|
|
158
|
+
|
|
159
|
+
3. **Update Code**: Apply migration patterns from the [Migration Guide](./migration-guide.md)
|
|
160
|
+
|
|
161
|
+
4. **Test**: Run your test suite and verify all permission checks work
|
|
162
|
+
|
|
163
|
+
5. **Monitor**: Check logs for security events and rate limiting
|
|
164
|
+
|
|
165
|
+
## Compatibility Matrix
|
|
166
|
+
|
|
167
|
+
| Feature | v2.0.0 | v3.0.0 |
|
|
168
|
+
|---------|--------|--------|
|
|
169
|
+
| Optional SecurityContext | ✅ | ❌ |
|
|
170
|
+
| Rate Limiting | Optional | Mandatory |
|
|
171
|
+
| Input Validation | Conditional | Always |
|
|
172
|
+
| Audit Logging | Partial | Complete |
|
|
173
|
+
| Type Safety | Basic | Enhanced |
|
|
174
|
+
|
|
175
|
+
## Frequently Asked Questions
|
|
176
|
+
|
|
177
|
+
### Q: Why is SecurityContext now mandatory?
|
|
178
|
+
|
|
179
|
+
**A**: To ensure all permission checks go through proper security validation, rate limiting, and audit logging. This prevents security vulnerabilities where validation is skipped.
|
|
180
|
+
|
|
181
|
+
### Q: Will rate limiting affect my app's performance?
|
|
182
|
+
|
|
183
|
+
**A**: The default limit of 100 requests/minute is generous for most applications. High-traffic apps can increase this limit or implement caching to reduce permission check frequency.
|
|
184
|
+
|
|
185
|
+
### Q: How do I handle events without organisation context?
|
|
186
|
+
|
|
187
|
+
**A**: Use the `no_organisation_context` metadata flag in audit queries:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const { data } = await supabase
|
|
191
|
+
.from('rbac_audit_events')
|
|
192
|
+
.select('*')
|
|
193
|
+
.eq('metadata->no_organisation_context', true);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Q: Can I disable rate limiting?
|
|
197
|
+
|
|
198
|
+
**A**: No. Rate limiting is mandatory for security. However, you can increase the limit if needed.
|
|
199
|
+
|
|
200
|
+
### Q: Will existing code break?
|
|
201
|
+
|
|
202
|
+
**A**: Only if you're calling `RBACEngine.isPermitted()` directly. Using the API layer's `isPermitted()` function maintains backward compatibility.
|
|
203
|
+
|
|
204
|
+
## Getting Help
|
|
205
|
+
|
|
206
|
+
- **Migration Guide**: See [Migration Guide](./migration-guide.md)
|
|
207
|
+
- **API Reference**: See [API Reference](./api-reference.md)
|
|
208
|
+
- **Troubleshooting**: See [Troubleshooting Guide](./troubleshooting.md)
|
|
209
|
+
- **Issues**: Open an issue on the project repository
|
|
210
|
+
|
|
211
|
+
## Changelog
|
|
212
|
+
|
|
213
|
+
Full changelog for v3.0.0:
|
|
214
|
+
|
|
215
|
+
- ✅ Made SecurityContext mandatory in RBACEngine
|
|
216
|
+
- ✅ Implemented real rate limiting with sliding window algorithm
|
|
217
|
+
- ✅ Enhanced audit logging to include all permission checks
|
|
218
|
+
- ✅ Made organisationId optional in SecurityContext
|
|
219
|
+
- ✅ Added comprehensive input validation
|
|
220
|
+
- ✅ Improved security event logging
|
|
221
|
+
- ✅ Added metadata flags for tracking events without organisation context
|
|
222
|
+
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# RBAC-RLS Integration Example
|
|
2
8
|
|
|
3
9
|
This example demonstrates how to use the new RBAC-RLS integration system to solve the critical architectural issue where RBAC permissions and RLS policies were disconnected.
|
package/docs/rbac/examples.md
CHANGED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastUpdated: 2025-10-29T22:43:00+11:00
|
|
3
|
+
version: 0.5.76
|
|
4
|
+
reviewedBy: content-audit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# RBAC Migration Guide - Breaking Changes
|
|
8
|
+
|
|
9
|
+
This guide helps you migrate to the new mandatory security validation in the RBAC system.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The RBAC system now requires mandatory security validation for all permission checks. This ensures all operations go through proper security validation, rate limiting, and audit logging.
|
|
14
|
+
|
|
15
|
+
## What Changed
|
|
16
|
+
|
|
17
|
+
### Before (v2.0.0 and earlier)
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// SecurityContext was optional
|
|
21
|
+
const hasPermission = await engine.isPermitted({
|
|
22
|
+
userId,
|
|
23
|
+
scope,
|
|
24
|
+
permission
|
|
25
|
+
}); // No securityContext parameter
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### After (v3.0.0)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// SecurityContext is now mandatory
|
|
32
|
+
const hasPermission = await engine.isPermitted({
|
|
33
|
+
userId,
|
|
34
|
+
scope,
|
|
35
|
+
permission
|
|
36
|
+
}, {
|
|
37
|
+
userId,
|
|
38
|
+
organisationId: scope.organisationId,
|
|
39
|
+
timestamp: new Date()
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Migration Options
|
|
44
|
+
|
|
45
|
+
### Option 1: Use the API Layer (Recommended)
|
|
46
|
+
|
|
47
|
+
The easiest migration path is to use the `isPermitted()` function from the API layer, which automatically creates the security context:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { isPermitted } from '@jmruthers/pace-core/rbac';
|
|
51
|
+
|
|
52
|
+
// No changes needed - API creates security context automatically
|
|
53
|
+
const hasPermission = await isPermitted({
|
|
54
|
+
userId,
|
|
55
|
+
scope,
|
|
56
|
+
permission
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Option 2: Create Security Context Manually
|
|
61
|
+
|
|
62
|
+
If you're calling the engine directly, create a security context:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { RBACEngine, setupRBAC } from '@jmruthers/pace-core/rbac';
|
|
66
|
+
|
|
67
|
+
// Setup RBAC once
|
|
68
|
+
setupRBAC(supabase);
|
|
69
|
+
|
|
70
|
+
// Create security context
|
|
71
|
+
const securityContext = {
|
|
72
|
+
userId,
|
|
73
|
+
organisationId: scope.organisationId,
|
|
74
|
+
timestamp: new Date()
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Use with engine
|
|
78
|
+
const engine = getRBACEngine();
|
|
79
|
+
const hasPermission = await engine.isPermitted({
|
|
80
|
+
userId,
|
|
81
|
+
scope,
|
|
82
|
+
permission
|
|
83
|
+
}, securityContext);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Breaking Changes
|
|
87
|
+
|
|
88
|
+
### 1. SecurityContext Now Required
|
|
89
|
+
|
|
90
|
+
**Impact**: All direct calls to `RBACEngine.isPermitted()` must provide security context.
|
|
91
|
+
|
|
92
|
+
**Migration**: Use the API layer's `isPermitted()` function instead of calling the engine directly.
|
|
93
|
+
|
|
94
|
+
### 2. organisationId Now Optional in SecurityContext
|
|
95
|
+
|
|
96
|
+
**Impact**: Events without organisation context (e.g., global admin operations) are now properly logged.
|
|
97
|
+
|
|
98
|
+
**Migration**: No action needed if you're using the API layer. If creating security context manually, you can omit `organisationId`:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const securityContext = {
|
|
102
|
+
userId,
|
|
103
|
+
// organisationId is now optional
|
|
104
|
+
timestamp: new Date()
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Enhanced Features
|
|
109
|
+
|
|
110
|
+
### 1. Mandatory Rate Limiting
|
|
111
|
+
|
|
112
|
+
All permission checks now go through rate limiting. By default, users are limited to 100 permission checks per minute.
|
|
113
|
+
|
|
114
|
+
To configure rate limits:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { setupRBAC } from '@jmruthers/pace-core/rbac';
|
|
118
|
+
|
|
119
|
+
setupRBAC(supabase, {
|
|
120
|
+
maxPermissionChecksPerMinute: 200 // Increase for high-traffic apps
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Comprehensive Audit Logging
|
|
125
|
+
|
|
126
|
+
All permission checks are now audited, including:
|
|
127
|
+
- Super admin bypasses
|
|
128
|
+
- Operations without organisation context
|
|
129
|
+
- Failed authentication attempts
|
|
130
|
+
|
|
131
|
+
Audit events are stored in the `rbac_audit_events` table with the following structure:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
{
|
|
135
|
+
event_type: 'permission_check' | 'permission_denied' | 'role_granted' | 'role_denied' | 'rls_denied',
|
|
136
|
+
user_id: UUID,
|
|
137
|
+
organisation_id: UUID, // May be null UUID for global operations
|
|
138
|
+
event_id?: string,
|
|
139
|
+
app_id?: UUID,
|
|
140
|
+
page_id?: UUID,
|
|
141
|
+
permission?: string,
|
|
142
|
+
decision?: boolean,
|
|
143
|
+
source: 'api' | 'ui' | 'middleware' | 'rls',
|
|
144
|
+
bypass?: boolean,
|
|
145
|
+
duration_ms?: number,
|
|
146
|
+
metadata: {
|
|
147
|
+
cache_hit?: boolean,
|
|
148
|
+
cache_source?: 'memory' | 'database' | 'rpc',
|
|
149
|
+
no_organisation_context?: boolean
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 3. Input Validation
|
|
155
|
+
|
|
156
|
+
All inputs are now validated before processing:
|
|
157
|
+
- User ID format (must be valid UUID)
|
|
158
|
+
- Permission format (must match `operation:resource` pattern)
|
|
159
|
+
- Scope format (must include at least one valid identifier)
|
|
160
|
+
|
|
161
|
+
Invalid inputs trigger security events and return false (deny access).
|
|
162
|
+
|
|
163
|
+
## Security Improvements
|
|
164
|
+
|
|
165
|
+
### Rate Limiting
|
|
166
|
+
|
|
167
|
+
The system now implements in-memory rate limiting with a sliding window algorithm:
|
|
168
|
+
|
|
169
|
+
- **Window**: 1 minute
|
|
170
|
+
- **Default limit**: 100 requests per minute per user
|
|
171
|
+
- **Automatic cleanup**: Expired entries are cleared every 5 minutes
|
|
172
|
+
|
|
173
|
+
To implement distributed rate limiting, migrate to Redis or Supabase Edge Functions.
|
|
174
|
+
|
|
175
|
+
### Security Event Logging
|
|
176
|
+
|
|
177
|
+
Security events are now logged even without organisation context:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// These events are now audited:
|
|
181
|
+
// 1. Super admin bypasses (bypass: true)
|
|
182
|
+
// 2. Permission denied events
|
|
183
|
+
// 3. Invalid input events
|
|
184
|
+
// 4. Rate limit exceeded events
|
|
185
|
+
// 5. Suspicious activity events
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Migration Checklist
|
|
189
|
+
|
|
190
|
+
- [ ] Update all calls to `RBACEngine.isPermitted()` to use API layer
|
|
191
|
+
- [ ] Remove optional securityContext parameters from code
|
|
192
|
+
- [ ] Configure rate limits for your application's needs
|
|
193
|
+
- [ ] Update audit log queries to handle events without organisation context
|
|
194
|
+
- [ ] Test permission checks with various user roles
|
|
195
|
+
- [ ] Monitor rate limiting to ensure no false positives
|
|
196
|
+
|
|
197
|
+
## Backward Compatibility
|
|
198
|
+
|
|
199
|
+
The API layer maintains backward compatibility:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// This still works - API creates security context automatically
|
|
203
|
+
import { isPermitted } from '@jmruthers/pace-core/rbac';
|
|
204
|
+
|
|
205
|
+
const hasPermission = await isPermitted({
|
|
206
|
+
userId,
|
|
207
|
+
scope,
|
|
208
|
+
permission
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Common Issues
|
|
213
|
+
|
|
214
|
+
### Issue: Rate Limit Exceeded
|
|
215
|
+
|
|
216
|
+
**Symptom**: `rate_limit_exceeded` security events in logs.
|
|
217
|
+
|
|
218
|
+
**Solution**: Increase the rate limit or implement caching for frequently accessed permissions.
|
|
219
|
+
|
|
220
|
+
### Issue: Invalid Input
|
|
221
|
+
|
|
222
|
+
**Symptom**: Permission checks returning false with `invalid_input` events.
|
|
223
|
+
|
|
224
|
+
**Solution**: Ensure all UUIDs are valid and permission strings match the `operation:resource` pattern.
|
|
225
|
+
|
|
226
|
+
### Issue: Missing Organisation Context
|
|
227
|
+
|
|
228
|
+
**Symptom**: Warnings in console about missing organisation context.
|
|
229
|
+
|
|
230
|
+
**Solution**: Either provide organisation context or update your queries to filter by `no_organisation_context` metadata flag.
|
|
231
|
+
|
|
232
|
+
## Testing Your Migration
|
|
233
|
+
|
|
234
|
+
1. **Test with all user roles**:
|
|
235
|
+
- Super admin
|
|
236
|
+
- Organisation admin
|
|
237
|
+
- Event admin
|
|
238
|
+
- Regular users
|
|
239
|
+
|
|
240
|
+
2. **Test rate limiting**:
|
|
241
|
+
- Make more than 100 permission checks in a minute
|
|
242
|
+
- Verify rate limit exceeded events are logged
|
|
243
|
+
|
|
244
|
+
3. **Test audit logging**:
|
|
245
|
+
- Check `rbac_audit_events` table
|
|
246
|
+
- Verify all permission checks are logged
|
|
247
|
+
- Verify events without organisation context are flagged
|
|
248
|
+
|
|
249
|
+
4. **Test error handling**:
|
|
250
|
+
- Invalid UUIDs
|
|
251
|
+
- Malformed permission strings
|
|
252
|
+
- Missing required fields
|
|
253
|
+
|
|
254
|
+
## Support
|
|
255
|
+
|
|
256
|
+
For questions or issues with the migration, please:
|
|
257
|
+
1. Check the [Troubleshooting Guide](./troubleshooting.md)
|
|
258
|
+
2. Review the [API Reference](./api-reference.md)
|
|
259
|
+
3. Open an issue on the project repository
|
|
260
|
+
|