@jmruthers/pace-core 0.2.7 → 0.5.1
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/dist/{DataTable-EEUDXPE5.js → DataTable-GX3XERFJ.js} +8 -4
- package/dist/{DataTable-C1AEm9Cx.d.ts → DataTable-ltTFXHS3.d.ts} +3 -1
- package/dist/{chunk-VYG4AXYW.js → chunk-5EL3KHOQ.js} +2 -2
- package/dist/{chunk-ETEJVKYK.js → chunk-6CR3MRZN.js} +1426 -62
- package/dist/chunk-6CR3MRZN.js.map +1 -0
- package/dist/chunk-AUE24LVR.js +268 -0
- package/dist/chunk-AUE24LVR.js.map +1 -0
- package/dist/chunk-COBPIXXQ.js +379 -0
- package/dist/chunk-COBPIXXQ.js.map +1 -0
- package/dist/{chunk-EWKPTNPO.js → chunk-GSNM5D6H.js} +388 -86
- package/dist/chunk-GSNM5D6H.js.map +1 -0
- package/dist/{chunk-2V3Y6YBC.js → chunk-OEGRKULD.js} +1 -42
- package/dist/chunk-OEGRKULD.js.map +1 -0
- package/dist/chunk-OYRY44Q2.js +62 -0
- package/dist/chunk-OYRY44Q2.js.map +1 -0
- package/dist/{chunk-RRUYHORU.js → chunk-T3XIA4AJ.js} +297 -433
- package/dist/chunk-T3XIA4AJ.js.map +1 -0
- package/dist/{chunk-HEMJ4SUJ.js → chunk-TGDCLPP2.js} +11 -7
- package/dist/{chunk-HEMJ4SUJ.js.map → chunk-TGDCLPP2.js.map} +1 -1
- package/dist/{chunk-HNDFPXUU.js → chunk-U6JDHVC2.js} +6 -4
- package/dist/{chunk-HNDFPXUU.js.map → chunk-U6JDHVC2.js.map} +1 -1
- package/dist/{chunk-TIVL4UQ7.js → chunk-XJK2J4N6.js} +6 -4
- package/dist/{chunk-TIVL4UQ7.js.map → chunk-XJK2J4N6.js.map} +1 -1
- package/dist/components.d.ts +2 -2
- package/dist/components.js +21 -20
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +7 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -25
- package/dist/index.js.map +1 -1
- package/dist/providers.js +8 -7
- package/dist/rbac/index.d.ts +806 -806
- package/dist/rbac/index.js +937 -1179
- package/dist/rbac/index.js.map +1 -1
- package/dist/{types-DiRQsGJs.d.ts → types-BRDU7N6w.d.ts} +12 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +6 -6
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.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/DataTableAction.md +21 -8
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +46 -33
- package/docs/api/interfaces/DataTableToolbarButton.md +7 -7
- package/docs/api/interfaces/EmptyStateConfig.md +5 -5
- package/docs/api/interfaces/EventContextType.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.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/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +2 -2
- 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 +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- 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/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/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- 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/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +3 -3
- package/package.json +5 -2
- package/src/__tests__/REBUILD_PLAN.md +223 -0
- package/src/__tests__/TESTING_GUIDELINES.md +341 -0
- package/src/__tests__/fixtures/mocks.ts +93 -0
- package/src/__tests__/helpers/component-test-utils.tsx +145 -0
- package/src/__tests__/helpers/test-utils.tsx +117 -0
- package/src/__tests__/integration/UserProfile.test.tsx +128 -0
- package/src/__tests__/setup.ts +37 -225
- package/src/__tests__/templates/component.test.template.tsx +97 -75
- package/src/__tests__/templates/hook.test.template.ts +173 -0
- package/src/__tests__/types/test.types.ts +106 -0
- package/src/components/Alert/Alert.test.tsx +496 -0
- package/src/components/Avatar/Avatar.test.tsx +484 -0
- package/src/components/Button/Button.test.tsx +662 -0
- package/src/components/Card/Card.test.tsx +593 -0
- package/src/components/Checkbox/Checkbox.test.tsx +461 -0
- package/src/components/DataTable/DataTable.tsx +9 -1
- package/src/components/DataTable/components/AccessDeniedPage.tsx +168 -0
- package/src/components/DataTable/components/ActionButtons.tsx +18 -1
- package/src/components/DataTable/components/DataTableCore.tsx +97 -11
- package/src/components/DataTable/components/DataTableToolbar.tsx +22 -10
- package/src/components/DataTable/components/UnifiedTableBody.tsx +33 -4
- package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +1 -0
- package/src/components/DataTable/examples/HierarchicalExample.tsx +3 -0
- package/src/components/DataTable/examples/InitialPageSizeExample.tsx +3 -0
- package/src/components/DataTable/examples/PerformanceExample.tsx +3 -0
- package/src/components/DataTable/types.ts +39 -1
- package/src/components/Dialog/Dialog.test.tsx +1139 -0
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +752 -0
- package/src/components/FileUpload/FileUpload.test.tsx +665 -0
- package/src/hooks/useCounter.test.ts +135 -0
- package/src/rbac/index.ts +3 -3
- package/dist/chunk-2V3Y6YBC.js.map +0 -1
- package/dist/chunk-BEZRLNK3.js +0 -1744
- package/dist/chunk-BEZRLNK3.js.map +0 -1
- package/dist/chunk-ETEJVKYK.js.map +0 -1
- package/dist/chunk-EWKPTNPO.js.map +0 -1
- package/dist/chunk-OHXGNT3K.js +0 -21
- package/dist/chunk-OHXGNT3K.js.map +0 -1
- package/dist/chunk-RRUYHORU.js.map +0 -1
- package/src/__tests__/README.md +0 -404
- package/src/__tests__/debug-provider.unit.test.tsx +0 -67
- package/src/__tests__/e2e/workflows.test.tsx +0 -373
- package/src/__tests__/hybridPermissions.unit.test.tsx +0 -474
- package/src/__tests__/index.integration.test.ts +0 -491
- package/src/__tests__/mocks/MockAuthProvider-standalone.tsx +0 -47
- package/src/__tests__/mocks/MockAuthProvider.tsx +0 -63
- package/src/__tests__/mocks/enhancedSupabaseMock.ts +0 -252
- package/src/__tests__/mocks/index.test.ts +0 -23
- package/src/__tests__/mocks/index.ts +0 -16
- package/src/__tests__/mocks/mockAuth.ts +0 -155
- package/src/__tests__/mocks/mockSupabase.ts +0 -83
- package/src/__tests__/mocks/mockSupabaseClient.ts +0 -63
- package/src/__tests__/mocks/providers.tsx +0 -22
- package/src/__tests__/patterns/__tests__/testPatterns.test.ts +0 -394
- package/src/__tests__/patterns/testPatterns.ts +0 -124
- package/src/__tests__/performance/componentPerformance.performance.test.ts +0 -27
- package/src/__tests__/performance/index.ts +0 -24
- package/src/__tests__/performance/performanceValidation.performance.test.ts +0 -15
- package/src/__tests__/security/security.unit.test.tsx +0 -7
- package/src/__tests__/security/securityValidation.security.test.tsx +0 -153
- package/src/__tests__/setupTests.d.ts +0 -1
- package/src/__tests__/shared/componentTestUtils.tsx +0 -475
- package/src/__tests__/shared/errorHandlingTestUtils.ts +0 -107
- package/src/__tests__/shared/index.ts +0 -81
- package/src/__tests__/shared/integrationTestUtils.tsx +0 -375
- package/src/__tests__/shared/performanceTestUtils.tsx +0 -476
- package/src/__tests__/shared/testUtils.optimized.tsx +0 -685
- package/src/__tests__/simple.test.tsx +0 -20
- package/src/__tests__/test-utils/dataFactories.ts +0 -60
- package/src/__tests__/test-utils/index.ts +0 -6
- package/src/__tests__/typeSafety.unit.test.ts +0 -65
- package/src/__tests__/unifiedAuth.unit.test.tsx +0 -151
- package/src/__tests__/utils/accessibilityHelpers.ts +0 -254
- package/src/__tests__/utils/assertions.ts +0 -50
- package/src/__tests__/utils/deterministicHelpers.ts +0 -31
- package/src/__tests__/utils/edgeCaseConfig.test.ts +0 -75
- package/src/__tests__/utils/edgeCaseConfig.ts +0 -98
- package/src/__tests__/utils/mockHelpers.ts +0 -149
- package/src/__tests__/utils/mockLoader.ts +0 -101
- package/src/__tests__/utils/performanceHelpers.ts +0 -55
- package/src/__tests__/utils/performanceTestHelpers.ts +0 -68
- package/src/__tests__/utils/testDataFactories.ts +0 -28
- package/src/__tests__/utils/testIsolation.ts +0 -67
- package/src/__tests__/utils/visualTestHelpers.ts +0 -20
- package/src/__tests__/visual/__snapshots__/componentSnapshots.visual.test.tsx.snap +0 -68
- package/src/__tests__/visual/__snapshots__/componentVisuals.visual.test.tsx.snap +0 -14
- package/src/__tests__/visual/__snapshots__/visualRegression.test.tsx.snap +0 -217
- package/src/__tests__/visual/__snapshots__/visualRegression.visual.test.tsx.snap +0 -24
- package/src/__tests__/visual/componentSnapshots.visual.test.tsx +0 -33
- package/src/__tests__/visual/componentVisuals.visual.test.tsx +0 -12
- package/src/__tests__/visual/visualRegression.visual.test.tsx +0 -20
- package/src/components/Alert/__tests__/Alert.unit.test.tsx +0 -381
- package/src/components/Avatar/__tests__/Avatar.unit.test.tsx +0 -232
- package/src/components/Button/__tests__/Button.accessibility.test.tsx +0 -131
- package/src/components/Button/__tests__/Button.comprehensive.test.tsx +0 -721
- package/src/components/Button/__tests__/Button.unit.test.tsx +0 -189
- package/src/components/Button/__tests__/EventSelector.integration.test.tsx +0 -285
- package/src/components/Card/__tests__/Card.accessibility.test.tsx +0 -394
- package/src/components/Card/__tests__/Card.comprehensive.test.tsx +0 -599
- package/src/components/Card/__tests__/Card.integration.test.tsx +0 -673
- package/src/components/Card/__tests__/Card.performance.test.tsx +0 -546
- package/src/components/Card/__tests__/Card.unit.test.tsx +0 -330
- package/src/components/Card/__tests__/Card.visual.test.tsx +0 -599
- package/src/components/Card/__tests__/README.md +0 -211
- package/src/components/Checkbox/__tests__/Checkbox.unit.test.tsx +0 -520
- package/src/components/DataTable/__tests__/DataTable.errorHandling.test.tsx +0 -251
- package/src/components/DataTable/__tests__/DataTable.hierarchical.test.tsx +0 -680
- package/src/components/DataTable/__tests__/DataTable.infinite-loop.test.tsx +0 -323
- package/src/components/DataTable/__tests__/DataTable.integration.test.tsx +0 -716
- package/src/components/DataTable/__tests__/DataTable.performance.test.tsx +0 -589
- package/src/components/DataTable/__tests__/DataTable.permissions.test.tsx +0 -316
- package/src/components/DataTable/__tests__/DataTable.regressionFixes.test.tsx +0 -546
- package/src/components/DataTable/__tests__/DataTable.selection.controlled.test.tsx +0 -386
- package/src/components/DataTable/__tests__/DataTable.selection.test.tsx +0 -338
- package/src/components/DataTable/__tests__/DataTable.sorting.test.tsx +0 -321
- package/src/components/DataTable/__tests__/DataTable.userWorkflows.test.tsx +0 -320
- package/src/components/DataTable/__tests__/DataTable.workflowValidation.test.tsx +0 -583
- package/src/components/DataTable/__tests__/DataTable.workflows.test.tsx +0 -711
- package/src/components/DataTable/__tests__/performance-regression.test.tsx +0 -777
- package/src/components/DataTable/__tests__/performance.test.tsx +0 -365
- package/src/components/DataTable/components/__tests__/ActionButtons.unit.test.tsx +0 -150
- package/src/components/DataTable/components/__tests__/BulkOperationsDropdown.test.tsx +0 -224
- package/src/components/DataTable/components/__tests__/ColumnVisibilityDropdown.unit.test.tsx +0 -244
- package/src/components/DataTable/components/__tests__/DataTable.accessibility.test.tsx +0 -629
- package/src/components/DataTable/components/__tests__/DataTable.integration.test.tsx +0 -470
- package/src/components/DataTable/components/__tests__/DataTable.performance.test.tsx +0 -160
- package/src/components/DataTable/components/__tests__/DataTable.real.test.tsx +0 -251
- package/src/components/DataTable/components/__tests__/DataTable.security.test.tsx +0 -171
- package/src/components/DataTable/components/__tests__/DataTable.unit.test.tsx +0 -290
- package/src/components/DataTable/components/__tests__/DataTableBody.unit.test.tsx +0 -147
- package/src/components/DataTable/components/__tests__/DataTableErrorBoundary.unit.test.tsx +0 -182
- package/src/components/DataTable/components/__tests__/DataTableModals.unit.test.tsx +0 -123
- package/src/components/DataTable/components/__tests__/EditableRow.unit.test.tsx +0 -660
- package/src/components/DataTable/components/__tests__/EmptyState.unit.test.tsx +0 -256
- package/src/components/DataTable/components/__tests__/ExpandButton.test.tsx +0 -498
- package/src/components/DataTable/components/__tests__/FilterRow.unit.test.tsx +0 -112
- package/src/components/DataTable/components/__tests__/FilteringToggle.unit.test.tsx +0 -133
- package/src/components/DataTable/components/__tests__/GroupHeader.unit.test.tsx +0 -172
- package/src/components/DataTable/components/__tests__/GroupingDropdown.unit.test.tsx +0 -222
- package/src/components/DataTable/components/__tests__/ImportModal.unit.test.tsx +0 -780
- package/src/components/DataTable/components/__tests__/LoadingState.unit.test.tsx +0 -65
- package/src/components/DataTable/components/__tests__/PaginationControls.unit.test.tsx +0 -634
- package/src/components/DataTable/components/__tests__/StateComponents.unit.test.tsx +0 -48
- package/src/components/DataTable/components/__tests__/UnifiedTableBody.hierarchical.test.tsx +0 -541
- package/src/components/DataTable/components/__tests__/ViewRowModal.unit.test.tsx +0 -228
- package/src/components/DataTable/components/__tests__/VirtualizedDataTable.unit.test.tsx +0 -568
- package/src/components/DataTable/core/__tests__/ActionManager.unit.test.ts +0 -405
- package/src/components/DataTable/core/__tests__/ArchitectureIntegration.unit.test.tsx +0 -445
- package/src/components/DataTable/core/__tests__/ColumnFactory.unit.test.ts +0 -288
- package/src/components/DataTable/core/__tests__/ColumnManager.unit.test.ts +0 -623
- package/src/components/DataTable/core/__tests__/DataManager.unit.test.ts +0 -431
- package/src/components/DataTable/core/__tests__/DataTableContext.unit.test.tsx +0 -433
- package/src/components/DataTable/core/__tests__/LocalDataAdapter.unit.test.ts +0 -422
- package/src/components/DataTable/core/__tests__/PluginRegistry.unit.test.tsx +0 -207
- package/src/components/DataTable/core/__tests__/StateManager.unit.test.ts +0 -278
- package/src/components/DataTable/examples/__tests__/PerformanceExample.unit.test.tsx +0 -281
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.unit.test.ts +0 -407
- package/src/components/DataTable/hooks/__tests__/useColumnReordering.unit.test.ts +0 -679
- package/src/components/DataTable/utils/__tests__/debugTools.unit.test.ts +0 -267
- package/src/components/DataTable/utils/__tests__/errorHandling.unit.test.ts +0 -467
- package/src/components/DataTable/utils/__tests__/exportUtils.unit.test.ts +0 -380
- package/src/components/DataTable/utils/__tests__/flexibleImport.unit.test.ts +0 -233
- package/src/components/DataTable/utils/__tests__/performanceUtils.unit.test.ts +0 -414
- package/src/components/Dialog/__tests__/Dialog.accessibility.test.tsx +0 -521
- package/src/components/Dialog/__tests__/Dialog.auto-size.example.tsx +0 -157
- package/src/components/Dialog/__tests__/Dialog.enhanced.test.tsx +0 -538
- package/src/components/Dialog/__tests__/Dialog.unit.test.tsx +0 -1373
- package/src/components/Dialog/examples/__tests__/SmartDialogExample.unit.test.tsx +0 -151
- package/src/components/Dialog/utils/__tests__/safeHtml.unit.test.ts +0 -611
- package/src/components/ErrorBoundary/__tests__/ErrorBoundary.accessibility.test.tsx +0 -517
- package/src/components/ErrorBoundary/__tests__/ErrorBoundary.integration.test.tsx +0 -572
- package/src/components/ErrorBoundary/__tests__/ErrorBoundary.unit.test.tsx +0 -579
- package/src/components/EventSelector/__tests__/EventSelector.test.tsx +0 -528
- package/src/components/FileUpload/__tests__/FileUpload.integration.test.tsx +0 -992
- package/src/components/FileUpload/__tests__/FileUpload.real.test.tsx +0 -927
- package/src/components/FileUpload/__tests__/FileUpload.test.tsx +0 -855
- package/src/components/FileUpload/__tests__/FileUpload.unit.test.tsx +0 -1311
- package/src/components/FileUpload/__tests__/FileUpload.unmocked.test.tsx +0 -937
- package/src/components/Footer/__tests__/Footer.accessibility.test.tsx +0 -359
- package/src/components/Footer/__tests__/Footer.integration.test.tsx +0 -353
- package/src/components/Footer/__tests__/Footer.performance.test.tsx +0 -309
- package/src/components/Footer/__tests__/Footer.unit.test.tsx +0 -309
- package/src/components/Footer/__tests__/Footer.visual.test.tsx +0 -335
- package/src/components/Form/__tests__/Form.accessibility.test.tsx +0 -820
- package/src/components/Form/__tests__/Form.unit.test.tsx +0 -305
- package/src/components/Form/__tests__/FormErrorSummary.unit.test.tsx +0 -285
- package/src/components/Form/__tests__/FormFieldset.unit.test.tsx +0 -241
- package/src/components/Header/__tests__/Header.accessibility.test.tsx +0 -382
- package/src/components/Header/__tests__/Header.comprehensive.test.tsx +0 -509
- package/src/components/Header/__tests__/Header.unit.test.tsx +0 -335
- package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +0 -196
- package/src/components/InactivityWarningModal/__tests__/InactivityWarningModal.unit.test.tsx +0 -224
- package/src/components/Input/__tests__/Input.accessibility.test.tsx +0 -632
- package/src/components/Input/__tests__/Input.unit.test.tsx +0 -1121
- package/src/components/Label/__tests__/Label.accessibility.test.tsx +0 -239
- package/src/components/Label/__tests__/Label.unit.test.tsx +0 -331
- package/src/components/LoadingSpinner/__tests__/LoadingSpinner.accessibility.test.tsx +0 -116
- package/src/components/LoadingSpinner/__tests__/LoadingSpinner.unit.test.tsx +0 -144
- package/src/components/LoginForm/__tests__/LoginForm.accessibility.test.tsx +0 -201
- package/src/components/LoginForm/__tests__/LoginForm.unit.test.tsx +0 -119
- package/src/components/NavigationMenu/__tests__/NavigationMenu.accessibility.test.tsx +0 -378
- package/src/components/NavigationMenu/__tests__/NavigationMenu.enhanced.test.tsx +0 -768
- package/src/components/NavigationMenu/__tests__/NavigationMenu.integration.test.tsx +0 -576
- package/src/components/NavigationMenu/__tests__/NavigationMenu.performance.test.tsx +0 -585
- package/src/components/NavigationMenu/__tests__/NavigationMenu.real.component.test.tsx +0 -783
- package/src/components/NavigationMenu/__tests__/NavigationMenu.security.enhanced.test.tsx +0 -810
- package/src/components/NavigationMenu/__tests__/NavigationMenu.security.test.tsx +0 -494
- package/src/components/NavigationMenu/__tests__/NavigationMenu.unit.test.tsx +0 -331
- package/src/components/NavigationMenu/__tests__/NavigationMenu.userWorkflows.test.tsx +0 -347
- package/src/components/NavigationMenu/__tests__/NavigationMenu.workflows.test.tsx +0 -584
- package/src/components/OrganisationSelector/__tests__/OrganisationSelector.unit.test.tsx +0 -664
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +0 -288
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +0 -893
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +0 -629
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +0 -782
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.unit.test.tsx +0 -904
- package/src/components/PaceLoginPage/__tests__/PaceLoginPage.accessibility.test.tsx +0 -463
- package/src/components/PaceLoginPage/__tests__/PaceLoginPage.integration.test.tsx +0 -586
- package/src/components/PaceLoginPage/__tests__/PaceLoginPage.unit.test.tsx +0 -533
- package/src/components/PasswordReset/__tests__/PasswordChangeForm.accessibility.test.tsx +0 -408
- package/src/components/PasswordReset/__tests__/PasswordChangeForm.unit.test.tsx +0 -561
- package/src/components/PasswordReset/__tests__/PasswordReset.integration.test.tsx +0 -304
- package/src/components/PasswordReset/__tests__/PasswordResetForm.accessibility.test.tsx +0 -20
- package/src/components/PasswordReset/__tests__/PasswordResetForm.unit.test.tsx +0 -523
- package/src/components/PasswordReset/__tests__/__mocks__/UnifiedAuthProvider.ts +0 -29
- package/src/components/Print/__tests__/Print.comprehensive.test.tsx +0 -331
- package/src/components/PrintButton/__tests__/PrintButton.unit.test.tsx +0 -429
- package/src/components/PrintButton/__tests__/PrintButtonGroup.unit.test.tsx +0 -277
- package/src/components/PrintButton/__tests__/PrintToolbar.unit.test.tsx +0 -264
- package/src/components/PrintCard/__tests__/PrintCard.unit.test.tsx +0 -233
- package/src/components/PrintCard/__tests__/PrintCardContent.test.tsx +0 -284
- package/src/components/PrintCard/__tests__/PrintCardGrid.unit.test.tsx +0 -214
- package/src/components/PrintCard/__tests__/PrintCardImage.unit.test.tsx +0 -264
- package/src/components/PrintDataTable/__tests__/PrintDataTable.unit.test.tsx +0 -361
- package/src/components/PrintDataTable/__tests__/PrintTableGroup.unit.test.tsx +0 -314
- package/src/components/PrintDataTable/__tests__/PrintTableRow.unit.test.tsx +0 -362
- package/src/components/PrintFooter/__tests__/PrintFooter.unit.test.tsx +0 -500
- package/src/components/PrintFooter/__tests__/PrintFooterContent.unit.test.tsx +0 -321
- package/src/components/PrintFooter/__tests__/PrintFooterInfo.unit.test.tsx +0 -335
- package/src/components/PrintFooter/__tests__/PrintPageNumber.unit.test.tsx +0 -340
- package/src/components/PrintGrid/__tests__/PrintGrid.unit.test.tsx +0 -340
- package/src/components/PrintGrid/__tests__/PrintGridBreakpoint.unit.test.tsx +0 -261
- package/src/components/PrintGrid/__tests__/PrintGridContainer.unit.test.tsx +0 -338
- package/src/components/PrintGrid/__tests__/PrintGridItem.unit.test.tsx +0 -338
- package/src/components/PrintHeader/__tests__/PrintCoverHeader.unit.test.tsx +0 -309
- package/src/components/PrintHeader/__tests__/PrintHeader.unit.test.tsx +0 -202
- package/src/components/PrintLayout/__tests__/PrintLayout.unit.test.tsx +0 -238
- package/src/components/PrintPageBreak/__tests__/PrintPageBreak.unit.test.tsx +0 -263
- package/src/components/PrintPageBreak/__tests__/PrintPageBreakGroup.unit.test.tsx +0 -239
- package/src/components/PrintPageBreak/__tests__/PrintPageBreakIndicator.unit.test.tsx +0 -235
- package/src/components/PrintSection/__tests__/PrintColumn.unit.test.tsx +0 -385
- package/src/components/PrintSection/__tests__/PrintDivider.unit.test.tsx +0 -373
- package/src/components/PrintSection/__tests__/PrintSection.unit.test.tsx +0 -390
- package/src/components/PrintSection/__tests__/PrintSectionContent.unit.test.tsx +0 -321
- package/src/components/PrintSection/__tests__/PrintSectionHeader.unit.test.tsx +0 -334
- package/src/components/PrintText/__tests__/PrintText.unit.test.tsx +0 -351
- package/src/components/Progress/__tests__/Progress.accessibility.test.tsx +0 -240
- package/src/components/Progress/__tests__/Progress.unit.test.tsx +0 -242
- package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +0 -761
- package/src/components/PublicLayout/__tests__/PublicErrorBoundary.simplified.test.tsx +0 -228
- package/src/components/PublicLayout/__tests__/PublicErrorBoundary.test.tsx +0 -228
- package/src/components/PublicLayout/__tests__/PublicLoadingSpinner.test.tsx +0 -459
- package/src/components/PublicLayout/__tests__/PublicPageFooter.test.tsx +0 -362
- package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +0 -522
- package/src/components/PublicLayout/__tests__/PublicPageLayout.test.tsx +0 -599
- package/src/components/PublicLayout/__tests__/PublicPageProvider.test.tsx +0 -513
- package/src/components/RBAC/__tests__/PagePermissionGuard.unit.test.tsx +0 -683
- package/src/components/RBAC/__tests__/RBAC.integration.test.tsx +0 -573
- package/src/components/RBAC/__tests__/RBACGuard.unit.test.tsx +0 -467
- package/src/components/RBAC/__tests__/RBACProvider.accessibility.test.tsx +0 -475
- package/src/components/RBAC/__tests__/RBACProvider.advanced.test.tsx +0 -569
- package/src/components/RBAC/__tests__/RBACProvider.integration.test.tsx +0 -352
- package/src/components/RBAC/__tests__/RBACProvider.unit.test.tsx +0 -128
- package/src/components/RBAC/__tests__/RoleBasedContent.unit.test.tsx +0 -657
- package/src/components/Select/__tests__/SearchableSelect.unit.test.tsx +0 -437
- package/src/components/Select/__tests__/Select.accessibility.test.tsx +0 -1202
- package/src/components/Select/__tests__/Select.actual.test.tsx +0 -774
- package/src/components/Select/__tests__/Select.comprehensive.test.tsx +0 -837
- package/src/components/Select/__tests__/Select.enhanced.test.tsx +0 -1101
- package/src/components/Select/__tests__/Select.integration.test.tsx +0 -772
- package/src/components/Select/__tests__/Select.performance.test.tsx +0 -695
- package/src/components/Select/__tests__/Select.real-world.test.tsx +0 -1046
- package/src/components/Select/__tests__/Select.search-algorithms.test.tsx +0 -968
- package/src/components/Select/__tests__/Select.unit.test.tsx +0 -647
- package/src/components/Select/__tests__/Select.utils.test.tsx +0 -890
- package/src/components/Table/__tests__/Table.accessibility.test.tsx +0 -233
- package/src/components/Table/__tests__/Table.unit.test.tsx +0 -235
- package/src/components/Toast/__tests__/Toast.accessibility.test.tsx +0 -238
- package/src/components/Toast/__tests__/Toast.integration.test.tsx +0 -699
- package/src/components/Toast/__tests__/Toast.unit.test.tsx +0 -750
- package/src/components/Tooltip/__tests__/Tooltip.accessibility.test.tsx +0 -121
- package/src/components/Tooltip/__tests__/Tooltip.unit.test.tsx +0 -185
- package/src/components/UserMenu/__tests__/UserMenu.accessibility.test.tsx +0 -139
- package/src/components/UserMenu/__tests__/UserMenu.integration.test.tsx +0 -188
- package/src/components/UserMenu/__tests__/UserMenu.unit.test.tsx +0 -458
- package/src/components/__tests__/EdgeCaseTesting.enhanced.test.tsx +0 -524
- package/src/components/__tests__/ErrorTesting.enhanced.test.tsx +0 -455
- package/src/components/__tests__/SuperAdminGuard.test.tsx +0 -456
- package/src/components/__tests__/SuperAdminGuard.unit.test.tsx +0 -456
- package/src/components/examples/__tests__/PermissionExample.unit.test.tsx +0 -360
- package/src/hooks/__tests__/hooks.integration.test.tsx +0 -575
- package/src/hooks/__tests__/useApiFetch.unit.test.ts +0 -115
- package/src/hooks/__tests__/useComponentPerformance.unit.test.tsx +0 -133
- package/src/hooks/__tests__/useDebounce.unit.test.ts +0 -82
- package/src/hooks/__tests__/useFocusTrap.unit.test.tsx +0 -293
- package/src/hooks/__tests__/useInactivityTracker.unit.test.ts +0 -385
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +0 -286
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +0 -838
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +0 -627
- package/src/hooks/__tests__/useRBAC.unit.test.ts +0 -911
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +0 -537
- package/src/hooks/__tests__/useToast.unit.test.tsx +0 -62
- package/src/hooks/__tests__/useZodForm.unit.test.tsx +0 -37
- package/src/hooks/public/__tests__/usePublicEvent.test.tsx +0 -397
- package/src/hooks/public/__tests__/usePublicEventLogo.test.tsx +0 -690
- package/src/hooks/public/__tests__/usePublicRouteParams.test.tsx +0 -449
- package/src/providers/__tests__/EventProvider.unit.test.tsx +0 -768
- package/src/providers/__tests__/OrganisationProvider.basic.test.tsx +0 -116
- package/src/providers/__tests__/OrganisationProvider.unit.test.tsx +0 -1312
- package/src/providers/__tests__/UnifiedAuthProvider.inactivity.test.tsx +0 -601
- package/src/providers/__tests__/UnifiedAuthProvider.unit.test.tsx +0 -683
- package/src/providers/__tests__/index.unit.test.ts +0 -78
- package/src/rbac/__tests__/PagePermissionGuard.test.tsx +0 -673
- package/src/rbac/__tests__/README.md +0 -170
- package/src/rbac/__tests__/RoleBasedRouter.test.tsx +0 -709
- package/src/rbac/__tests__/TestContext.tsx +0 -72
- package/src/rbac/__tests__/__mocks__/cache.ts +0 -144
- package/src/rbac/__tests__/__mocks__/supabase.ts +0 -152
- package/src/rbac/__tests__/adapters-hooks-comprehensive.test.tsx +0 -782
- package/src/rbac/__tests__/adapters-hooks.test.tsx +0 -561
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +0 -963
- package/src/rbac/__tests__/adapters.test.tsx +0 -444
- package/src/rbac/__tests__/api.test.ts +0 -620
- package/src/rbac/__tests__/audit-observability-comprehensive.test.ts +0 -792
- package/src/rbac/__tests__/audit-observability.test.ts +0 -549
- package/src/rbac/__tests__/audit.test.ts +0 -616
- package/src/rbac/__tests__/build-contract-compliance-simple.test.ts +0 -230
- package/src/rbac/__tests__/cache-invalidation-comprehensive.test.ts +0 -889
- package/src/rbac/__tests__/cache-invalidation.test.ts +0 -457
- package/src/rbac/__tests__/cache.test.ts +0 -458
- package/src/rbac/__tests__/components-navigation-guard.enhanced.test.tsx +0 -859
- package/src/rbac/__tests__/components-navigation-guard.test.tsx +0 -895
- package/src/rbac/__tests__/components-navigation-provider.test.tsx +0 -692
- package/src/rbac/__tests__/components-page-permission-guard.test.tsx +0 -673
- package/src/rbac/__tests__/components-page-permission-provider.test.tsx +0 -614
- package/src/rbac/__tests__/components-permission-enforcer.enhanced.fixed.test.tsx +0 -836
- package/src/rbac/__tests__/components-permission-enforcer.enhanced.test.tsx +0 -837
- package/src/rbac/__tests__/components-permission-enforcer.test.tsx +0 -825
- package/src/rbac/__tests__/components-role-based-router.test.tsx +0 -709
- package/src/rbac/__tests__/components-secure-data-provider.test.tsx +0 -607
- package/src/rbac/__tests__/config.test.ts +0 -583
- package/src/rbac/__tests__/core-logic-unit.test.ts +0 -190
- package/src/rbac/__tests__/core-permission-logic-comprehensive.test.ts +0 -1467
- package/src/rbac/__tests__/core-permission-logic-fixed.test.ts +0 -151
- package/src/rbac/__tests__/core-permission-logic-simple.test.ts +0 -968
- package/src/rbac/__tests__/core-permission-logic.test.ts +0 -966
- package/src/rbac/__tests__/edge-cases-comprehensive.test.ts +0 -988
- package/src/rbac/__tests__/edge-cases.test.ts +0 -654
- package/src/rbac/__tests__/engine.test.ts +0 -361
- package/src/rbac/__tests__/engine.unit.test.ts +0 -361
- package/src/rbac/__tests__/hooks.enhanced.test.tsx +0 -979
- package/src/rbac/__tests__/hooks.fixed.test.tsx +0 -475
- package/src/rbac/__tests__/hooks.test.tsx +0 -385
- package/src/rbac/__tests__/index.test.ts +0 -269
- package/src/rbac/__tests__/integration.enhanced.test.tsx +0 -824
- package/src/rbac/__tests__/page-permission-guard-super-admin.test.tsx +0 -261
- package/src/rbac/__tests__/performance.enhanced.test.tsx +0 -724
- package/src/rbac/__tests__/permissions.test.ts +0 -383
- package/src/rbac/__tests__/requires-event.test.ts +0 -330
- package/src/rbac/__tests__/scope-isolation-comprehensive.test.ts +0 -1349
- package/src/rbac/__tests__/scope-isolation.test.ts +0 -755
- package/src/rbac/__tests__/secure-client-rls-comprehensive.test.ts +0 -592
- package/src/rbac/__tests__/secure-client-rls.test.ts +0 -377
- package/src/rbac/__tests__/security.test.ts +0 -296
- package/src/rbac/__tests__/setup.ts +0 -228
- package/src/rbac/__tests__/test-utils-enhanced.tsx +0 -400
- package/src/rbac/__tests__/types.test.ts +0 -685
- package/src/rbac/components/__tests__/EnhancedNavigationMenu.test.tsx +0 -631
- package/src/rbac/components/__tests__/NavigationProvider.test.tsx +0 -667
- package/src/rbac/components/__tests__/PagePermissionProvider.test.tsx +0 -647
- package/src/rbac/components/__tests__/SecureDataProvider.test.tsx +0 -496
- package/src/rbac/testing/__tests__/index.test.tsx +0 -342
- package/src/rbac/utils/__tests__/eventContext.test.ts +0 -428
- package/src/rbac/utils/__tests__/eventContext.unit.test.ts +0 -428
- package/src/styles/__tests__/styles.unit.test.ts +0 -164
- package/src/test-dom-cleanup.test.tsx +0 -38
- package/src/theming/__tests__/README.md +0 -335
- package/src/theming/__tests__/runtime.accessibility.test.ts +0 -474
- package/src/theming/__tests__/runtime.error.test.ts +0 -616
- package/src/theming/__tests__/runtime.integration.test.ts +0 -376
- package/src/theming/__tests__/runtime.performance.test.ts +0 -411
- package/src/theming/__tests__/runtime.unit.test.ts +0 -470
- package/src/types/__tests__/database.unit.test.ts +0 -489
- package/src/types/__tests__/guards.unit.test.ts +0 -146
- package/src/types/__tests__/index.unit.test.ts +0 -77
- package/src/types/__tests__/organisation.unit.test.ts +0 -713
- package/src/types/__tests__/rbac.unit.test.ts +0 -621
- package/src/types/__tests__/security.unit.test.ts +0 -347
- package/src/types/__tests__/supabase.unit.test.ts +0 -658
- package/src/types/__tests__/theme.unit.test.ts +0 -218
- package/src/types/__tests__/unified.unit.test.ts +0 -537
- package/src/types/__tests__/validation.unit.test.ts +0 -616
- package/src/utils/__tests__/appConfig.unit.test.ts +0 -55
- package/src/utils/__tests__/appNameResolver.unit.test.ts +0 -137
- package/src/utils/__tests__/audit.unit.test.ts +0 -69
- package/src/utils/__tests__/auth-utils.unit.test.ts +0 -70
- package/src/utils/__tests__/bundleAnalysis.unit.test.ts +0 -317
- package/src/utils/__tests__/cn.unit.test.ts +0 -34
- package/src/utils/__tests__/deviceFingerprint.unit.test.ts +0 -480
- package/src/utils/__tests__/dynamicUtils.unit.test.ts +0 -322
- package/src/utils/__tests__/formatDate.unit.test.ts +0 -109
- package/src/utils/__tests__/formatting.unit.test.ts +0 -66
- package/src/utils/__tests__/index.unit.test.ts +0 -251
- package/src/utils/__tests__/lazyLoad.unit.test.tsx +0 -304
- package/src/utils/__tests__/organisationContext.unit.test.ts +0 -192
- package/src/utils/__tests__/performanceBudgets.unit.test.ts +0 -259
- package/src/utils/__tests__/permissionTypes.unit.test.ts +0 -250
- package/src/utils/__tests__/permissionUtils.unit.test.ts +0 -362
- package/src/utils/__tests__/sanitization.unit.test.ts +0 -346
- package/src/utils/__tests__/schemaUtils.unit.test.ts +0 -441
- package/src/utils/__tests__/secureDataAccess.unit.test.ts +0 -334
- package/src/utils/__tests__/secureErrors.unit.test.ts +0 -377
- package/src/utils/__tests__/secureStorage.unit.test.ts +0 -293
- package/src/utils/__tests__/security.unit.test.ts +0 -127
- package/src/utils/__tests__/securityMonitor.unit.test.ts +0 -280
- package/src/utils/__tests__/sessionTracking.unit.test.ts +0 -370
- package/src/utils/__tests__/validation.unit.test.ts +0 -84
- package/src/utils/__tests__/validationUtils.unit.test.ts +0 -571
- package/src/utils/print/__tests__/PrintDataProcessor.unit.test.ts +0 -219
- package/src/utils/print/__tests__/usePrintOptimization.unit.test.tsx +0 -353
- package/src/utils/storage/__tests__/config.unit.test.ts +0 -206
- package/src/utils/storage/__tests__/helpers.unit.test.ts +0 -648
- package/src/utils/storage/__tests__/index.unit.test.ts +0 -167
- package/src/utils/storage/__tests__/types.unit.test.ts +0 -441
- package/src/validation/__tests__/common.unit.test.ts +0 -101
- package/src/validation/__tests__/csrf.unit.test.ts +0 -302
- package/src/validation/__tests__/passwordSchema.unit.test.ts +0 -98
- package/src/validation/__tests__/sqlInjectionProtection.unit.test.ts +0 -466
- /package/dist/{DataTable-EEUDXPE5.js.map → DataTable-GX3XERFJ.js.map} +0 -0
- /package/dist/{chunk-VYG4AXYW.js.map → chunk-5EL3KHOQ.js.map} +0 -0
package/dist/rbac/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
2
|
import { D as Database } from '../database-C3Szpi5J.js';
|
|
3
|
-
import React__default, { ReactNode } from 'react';
|
|
4
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import React__default, { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* RBAC (Role-Based Access Control) Types - Build Contract Compliant
|
|
@@ -692,950 +692,950 @@ declare class RBACEngine {
|
|
|
692
692
|
*/
|
|
693
693
|
declare function createRBACEngine(supabase: SupabaseClient<Database>): RBACEngine;
|
|
694
694
|
|
|
695
|
+
interface PagePermissionContextType {
|
|
696
|
+
/** Check if user has permission for a page */
|
|
697
|
+
hasPagePermission: (pageName: string, operation: string, pageId?: string, scope?: Scope) => boolean;
|
|
698
|
+
/** Get all page permissions for current user */
|
|
699
|
+
getPagePermissions: () => Record<string, string[]>;
|
|
700
|
+
/** Check if page permission checking is enabled */
|
|
701
|
+
isEnabled: boolean;
|
|
702
|
+
/** Check if strict mode is enabled */
|
|
703
|
+
isStrictMode: boolean;
|
|
704
|
+
/** Check if audit logging is enabled */
|
|
705
|
+
isAuditLogEnabled: boolean;
|
|
706
|
+
/** Get page access history */
|
|
707
|
+
getPageAccessHistory: () => PageAccessRecord[];
|
|
708
|
+
/** Clear page access history */
|
|
709
|
+
clearPageAccessHistory: () => void;
|
|
710
|
+
}
|
|
711
|
+
interface PageAccessRecord {
|
|
712
|
+
pageName: string;
|
|
713
|
+
operation: string;
|
|
714
|
+
userId: UUID;
|
|
715
|
+
scope: Scope;
|
|
716
|
+
allowed: boolean;
|
|
717
|
+
timestamp: string;
|
|
718
|
+
pageId?: string;
|
|
719
|
+
}
|
|
720
|
+
interface PagePermissionProviderProps {
|
|
721
|
+
/** Child components */
|
|
722
|
+
children: React__default.ReactNode;
|
|
723
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
724
|
+
strictMode?: boolean;
|
|
725
|
+
/** Enable audit logging (default: true) */
|
|
726
|
+
auditLog?: boolean;
|
|
727
|
+
/** Callback when page access is attempted */
|
|
728
|
+
onPageAccess?: (pageName: string, operation: string, allowed: boolean, record: PageAccessRecord) => void;
|
|
729
|
+
/** Callback when strict mode violation occurs */
|
|
730
|
+
onStrictModeViolation?: (pageName: string, operation: string, record: PageAccessRecord) => void;
|
|
731
|
+
/** Maximum number of access records to keep in history */
|
|
732
|
+
maxHistorySize?: number;
|
|
733
|
+
}
|
|
695
734
|
/**
|
|
696
|
-
*
|
|
697
|
-
* @package @jmruthers/pace-core
|
|
698
|
-
* @module RBAC/Hooks
|
|
699
|
-
* @since 1.0.0
|
|
700
|
-
*
|
|
701
|
-
* This module provides React hooks for RBAC functionality.
|
|
702
|
-
*/
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* Hook to get user's permissions in a scope
|
|
706
|
-
*
|
|
707
|
-
* @param userId - User ID
|
|
708
|
-
* @param scope - Permission scope
|
|
709
|
-
* @returns Permission data and loading state
|
|
710
|
-
*
|
|
711
|
-
* @example
|
|
712
|
-
* ```tsx
|
|
713
|
-
* function MyComponent() {
|
|
714
|
-
* const { permissions, isLoading, error } = usePermissions(
|
|
715
|
-
* 'user-123',
|
|
716
|
-
* { organisationId: 'org-456' }
|
|
717
|
-
* );
|
|
735
|
+
* PagePermissionProvider - Manages page-level permissions across the app
|
|
718
736
|
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
737
|
+
* This provider ensures that all pages are properly protected and provides
|
|
738
|
+
* centralized page permission management with strict enforcement.
|
|
721
739
|
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
* {permissions['page-1']?.includes('read') && <ReadButton />}
|
|
725
|
-
* {permissions['page-1']?.includes('manage') && <ManageButton />}
|
|
726
|
-
* </div>
|
|
727
|
-
* );
|
|
728
|
-
* }
|
|
729
|
-
* ```
|
|
740
|
+
* @param props - Provider props
|
|
741
|
+
* @returns React element with page permission context
|
|
730
742
|
*/
|
|
731
|
-
declare function
|
|
743
|
+
declare function PagePermissionProvider({ children, strictMode, auditLog, onPageAccess, onStrictModeViolation, maxHistorySize }: PagePermissionProviderProps): react_jsx_runtime.JSX.Element;
|
|
732
744
|
/**
|
|
733
|
-
* Hook to
|
|
734
|
-
*
|
|
735
|
-
* @param userId - User ID
|
|
736
|
-
* @param scope - Permission scope
|
|
737
|
-
* @param permission - Permission to check
|
|
738
|
-
* @param pageId - Optional page ID
|
|
739
|
-
* @param useCache - Whether to use cached results (default: true)
|
|
740
|
-
* @returns Permission check result and loading state
|
|
741
|
-
*
|
|
742
|
-
* @example
|
|
743
|
-
* ```tsx
|
|
744
|
-
* function MyComponent() {
|
|
745
|
-
* const { can, isLoading } = useCan(
|
|
746
|
-
* 'user-123',
|
|
747
|
-
* { organisationId: 'org-456' },
|
|
748
|
-
* 'manage:events',
|
|
749
|
-
* 'page-789'
|
|
750
|
-
* );
|
|
751
|
-
*
|
|
752
|
-
* if (isLoading) return <div>Checking permission...</div>;
|
|
745
|
+
* Hook to use page permission context
|
|
753
746
|
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* {can ? <AdminPanel /> : <AccessDenied />}
|
|
757
|
-
* </div>
|
|
758
|
-
* );
|
|
759
|
-
* }
|
|
760
|
-
* ```
|
|
747
|
+
* @returns Page permission context
|
|
748
|
+
* @throws Error if used outside of PagePermissionProvider
|
|
761
749
|
*/
|
|
762
|
-
declare function
|
|
750
|
+
declare function usePagePermissions(): PagePermissionContextType;
|
|
751
|
+
|
|
752
|
+
interface PagePermissionGuardProps {
|
|
753
|
+
/** Name of the page being protected */
|
|
754
|
+
pageName: string;
|
|
755
|
+
/** Operation being performed on the page */
|
|
756
|
+
operation: 'read' | 'create' | 'update' | 'delete';
|
|
757
|
+
/** Content to render when user has permission */
|
|
758
|
+
children: React__default.ReactNode;
|
|
759
|
+
/** Content to render when user lacks permission */
|
|
760
|
+
fallback?: React__default.ReactNode;
|
|
761
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
762
|
+
strictMode?: boolean;
|
|
763
|
+
/** Force audit logging for this page access (default: true) */
|
|
764
|
+
auditLog?: boolean;
|
|
765
|
+
/** Custom page ID for permission checking */
|
|
766
|
+
pageId?: string;
|
|
767
|
+
/** Custom scope for permission checking */
|
|
768
|
+
scope?: Scope;
|
|
769
|
+
/** Callback when access is denied */
|
|
770
|
+
onDenied?: (pageName: string, operation: string) => void;
|
|
771
|
+
/** Loading state content */
|
|
772
|
+
loading?: React__default.ReactNode;
|
|
773
|
+
}
|
|
763
774
|
/**
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
* @param userId - User ID
|
|
767
|
-
* @param scope - Permission scope
|
|
768
|
-
* @returns Access level and loading state
|
|
769
|
-
*
|
|
770
|
-
* @example
|
|
771
|
-
* ```tsx
|
|
772
|
-
* function MyComponent() {
|
|
773
|
-
* const { accessLevel, isLoading } = useAccessLevel(
|
|
774
|
-
* 'user-123',
|
|
775
|
-
* { organisationId: 'org-456' }
|
|
776
|
-
* );
|
|
775
|
+
* PagePermissionGuard - Enforces page-level permissions
|
|
777
776
|
*
|
|
778
|
-
*
|
|
777
|
+
* This component ensures that users can only access pages they have permission for.
|
|
778
|
+
* It integrates with the existing RBAC system and provides strict enforcement to
|
|
779
|
+
* prevent apps from bypassing permission checks.
|
|
779
780
|
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
* {accessLevel === 'super' && <SuperAdminPanel />}
|
|
783
|
-
* {accessLevel === 'admin' && <AdminPanel />}
|
|
784
|
-
* {accessLevel === 'planner' && <PlannerPanel />}
|
|
785
|
-
* </div>
|
|
786
|
-
* );
|
|
787
|
-
* }
|
|
788
|
-
* ```
|
|
781
|
+
* @param props - Component props
|
|
782
|
+
* @returns React element with permission enforcement
|
|
789
783
|
*/
|
|
790
|
-
declare function
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
784
|
+
declare function PagePermissionGuard({ pageName, operation, children, fallback, strictMode, auditLog, pageId, scope, onDenied, loading }: PagePermissionGuardProps): react_jsx_runtime.JSX.Element;
|
|
785
|
+
|
|
786
|
+
interface DataAccessRecord {
|
|
787
|
+
table: string;
|
|
788
|
+
operation: string;
|
|
789
|
+
userId: UUID;
|
|
790
|
+
scope: Scope;
|
|
791
|
+
allowed: boolean;
|
|
792
|
+
timestamp: string;
|
|
793
|
+
query?: string;
|
|
794
|
+
filters?: Record<string, any>;
|
|
795
|
+
}
|
|
796
|
+
interface SecureDataContextType {
|
|
797
|
+
/** Check if data access is allowed for a table and operation */
|
|
798
|
+
isDataAccessAllowed: (table: string, operation: string, scope?: Scope) => boolean;
|
|
799
|
+
/** Get all data access permissions for current user */
|
|
800
|
+
getDataAccessPermissions: () => Record<string, string[]>;
|
|
801
|
+
/** Check if secure data access is enabled */
|
|
802
|
+
isEnabled: boolean;
|
|
803
|
+
/** Check if strict mode is enabled */
|
|
804
|
+
isStrictMode: boolean;
|
|
805
|
+
/** Check if audit logging is enabled */
|
|
806
|
+
isAuditLogEnabled: boolean;
|
|
807
|
+
/** Get data access history */
|
|
808
|
+
getDataAccessHistory: () => DataAccessRecord[];
|
|
809
|
+
/** Clear data access history */
|
|
810
|
+
clearDataAccessHistory: () => void;
|
|
811
|
+
/** Validate data access attempt */
|
|
812
|
+
validateDataAccess: (table: string, operation: string, scope?: Scope) => boolean;
|
|
813
|
+
}
|
|
814
|
+
interface SecureDataProviderProps {
|
|
815
|
+
/** Child components */
|
|
816
|
+
children: React__default.ReactNode;
|
|
817
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
818
|
+
strictMode?: boolean;
|
|
819
|
+
/** Enable audit logging (default: true) */
|
|
820
|
+
auditLog?: boolean;
|
|
821
|
+
/** Callback when data access is attempted */
|
|
822
|
+
onDataAccess?: (table: string, operation: string, allowed: boolean, record: DataAccessRecord) => void;
|
|
823
|
+
/** Callback when strict mode violation occurs */
|
|
824
|
+
onStrictModeViolation?: (table: string, operation: string, record: DataAccessRecord) => void;
|
|
825
|
+
/** Maximum number of access records to keep in history */
|
|
826
|
+
maxHistorySize?: number;
|
|
827
|
+
/** Enable RLS enforcement (default: true) */
|
|
828
|
+
enforceRLS?: boolean;
|
|
829
|
+
}
|
|
796
830
|
/**
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* @param userId - User ID
|
|
800
|
-
* @param scope - Permission scope
|
|
801
|
-
* @param permissions - Array of permissions to check
|
|
802
|
-
* @param pageId - Optional page ID
|
|
803
|
-
* @param useCache - Whether to use cached results (default: true)
|
|
804
|
-
* @returns Object with permission results and loading state
|
|
831
|
+
* SecureDataProvider - Prevents direct Supabase access and enforces secure data patterns
|
|
805
832
|
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
* function MyComponent() {
|
|
809
|
-
* const { permissions, isLoading } = useMultiplePermissions(
|
|
810
|
-
* 'user-123',
|
|
811
|
-
* { organisationId: 'org-456' },
|
|
812
|
-
* ['read:events', 'manage:events', 'delete:events']
|
|
813
|
-
* );
|
|
833
|
+
* This provider ensures that all data access goes through the secure RBAC system
|
|
834
|
+
* and prevents apps from bypassing data access controls.
|
|
814
835
|
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
* {permissions['read:events'] && <ReadButton />}
|
|
818
|
-
* {permissions['manage:events'] && <ManageButton />}
|
|
819
|
-
* {permissions['delete:events'] && <DeleteButton />}
|
|
820
|
-
* </div>
|
|
821
|
-
* );
|
|
822
|
-
* }
|
|
823
|
-
* ```
|
|
836
|
+
* @param props - Provider props
|
|
837
|
+
* @returns React element with secure data context
|
|
824
838
|
*/
|
|
825
|
-
declare function
|
|
826
|
-
permissions: Record<Permission, boolean>;
|
|
827
|
-
isLoading: boolean;
|
|
828
|
-
error: Error | null;
|
|
829
|
-
refetch: () => Promise<void>;
|
|
830
|
-
};
|
|
839
|
+
declare function SecureDataProvider({ children, strictMode, auditLog, onDataAccess, onStrictModeViolation, maxHistorySize, enforceRLS }: SecureDataProviderProps): react_jsx_runtime.JSX.Element;
|
|
831
840
|
/**
|
|
832
|
-
* Hook to
|
|
841
|
+
* Hook to use secure data context
|
|
833
842
|
*
|
|
834
|
-
* @
|
|
843
|
+
* @returns Secure data context
|
|
844
|
+
* @throws Error if used outside of SecureDataProvider
|
|
845
|
+
*/
|
|
846
|
+
declare function useSecureData(): SecureDataContextType;
|
|
847
|
+
|
|
848
|
+
interface PermissionEnforcerProps {
|
|
849
|
+
/** Permissions required for access */
|
|
850
|
+
permissions: Permission[];
|
|
851
|
+
/** Operation being performed */
|
|
852
|
+
operation: string;
|
|
853
|
+
/** Content to render when user has permission */
|
|
854
|
+
children: React__default.ReactNode;
|
|
855
|
+
/** Content to render when user lacks permission */
|
|
856
|
+
fallback?: React__default.ReactNode;
|
|
857
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
858
|
+
strictMode?: boolean;
|
|
859
|
+
/** Force audit logging for this operation (default: true) */
|
|
860
|
+
auditLog?: boolean;
|
|
861
|
+
/** Custom scope for permission checking */
|
|
862
|
+
scope?: Scope;
|
|
863
|
+
/** Callback when access is denied */
|
|
864
|
+
onDenied?: (permissions: Permission[], operation: string) => void;
|
|
865
|
+
/** Loading state content */
|
|
866
|
+
loading?: React__default.ReactNode;
|
|
867
|
+
/** Require all permissions (AND) or any permission (OR) */
|
|
868
|
+
requireAll?: boolean;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* PermissionEnforcer - Enforces permissions for operations
|
|
872
|
+
*
|
|
873
|
+
* This component ensures that users can only perform operations they have permission for.
|
|
874
|
+
* It integrates with the existing RBAC system and provides strict enforcement to
|
|
875
|
+
* prevent apps from bypassing permission checks.
|
|
876
|
+
*
|
|
877
|
+
* @param props - Component props
|
|
878
|
+
* @returns React element with permission enforcement
|
|
879
|
+
*/
|
|
880
|
+
declare function PermissionEnforcer({ permissions, operation, children, fallback, strictMode, auditLog, scope, onDenied, loading, requireAll }: PermissionEnforcerProps): react_jsx_runtime.JSX.Element;
|
|
881
|
+
|
|
882
|
+
interface RouteConfig {
|
|
883
|
+
/** Route path */
|
|
884
|
+
path: string;
|
|
885
|
+
/** React component to render */
|
|
886
|
+
component: React__default.ComponentType;
|
|
887
|
+
/** Permissions required for this route */
|
|
888
|
+
permissions: Permission[];
|
|
889
|
+
/** Roles that can access this route */
|
|
890
|
+
roles?: string[];
|
|
891
|
+
/** Minimum access level required */
|
|
892
|
+
accessLevel?: AccessLevel;
|
|
893
|
+
/** Page ID for permission checking */
|
|
894
|
+
pageId?: string;
|
|
895
|
+
/** Enable strict mode for this route */
|
|
896
|
+
strictMode?: boolean;
|
|
897
|
+
/** Route metadata */
|
|
898
|
+
meta?: {
|
|
899
|
+
title?: string;
|
|
900
|
+
description?: string;
|
|
901
|
+
requiresAuth?: boolean;
|
|
902
|
+
hidden?: boolean;
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
interface RouteAccessRecord {
|
|
906
|
+
route: string;
|
|
907
|
+
permissions: Permission[];
|
|
908
|
+
userId: UUID;
|
|
909
|
+
scope: Scope;
|
|
910
|
+
allowed: boolean;
|
|
911
|
+
timestamp: string;
|
|
912
|
+
pageId?: string;
|
|
913
|
+
roles?: string[];
|
|
914
|
+
accessLevel?: AccessLevel;
|
|
915
|
+
}
|
|
916
|
+
interface RoleBasedRouterContextType {
|
|
917
|
+
/** Get all accessible routes for current user */
|
|
918
|
+
getAccessibleRoutes: () => RouteConfig[];
|
|
919
|
+
/** Check if user can access a specific route */
|
|
920
|
+
canAccessRoute: (path: string) => boolean;
|
|
921
|
+
/** Get route configuration for a path */
|
|
922
|
+
getRouteConfig: (path: string) => RouteConfig | null;
|
|
923
|
+
/** Get route access history */
|
|
924
|
+
getRouteAccessHistory: () => RouteAccessRecord[];
|
|
925
|
+
/** Clear route access history */
|
|
926
|
+
clearRouteAccessHistory: () => void;
|
|
927
|
+
/** Check if strict mode is enabled */
|
|
928
|
+
isStrictMode: boolean;
|
|
929
|
+
/** Check if audit logging is enabled */
|
|
930
|
+
isAuditLogEnabled: boolean;
|
|
931
|
+
}
|
|
932
|
+
interface RoleBasedRouterProps {
|
|
933
|
+
/** Route configuration */
|
|
934
|
+
routes: RouteConfig[];
|
|
935
|
+
/** Fallback route for unauthorized access */
|
|
936
|
+
fallbackRoute?: string;
|
|
937
|
+
/** Child components */
|
|
938
|
+
children: React__default.ReactNode;
|
|
939
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
940
|
+
strictMode?: boolean;
|
|
941
|
+
/** Enable audit logging (default: true) */
|
|
942
|
+
auditLog?: boolean;
|
|
943
|
+
/** Callback when route access is attempted */
|
|
944
|
+
onRouteAccess?: (route: string, allowed: boolean, record: RouteAccessRecord) => void;
|
|
945
|
+
/** Callback when strict mode violation occurs */
|
|
946
|
+
onStrictModeViolation?: (route: string, record: RouteAccessRecord) => void;
|
|
947
|
+
/** Maximum number of access records to keep in history */
|
|
948
|
+
maxHistorySize?: number;
|
|
949
|
+
/** Custom unauthorized component */
|
|
950
|
+
unauthorizedComponent?: React__default.ComponentType<{
|
|
951
|
+
route: string;
|
|
952
|
+
reason: string;
|
|
953
|
+
}>;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* RoleBasedRouter - Centralized routing control with role-based protection
|
|
957
|
+
*
|
|
958
|
+
* This component ensures that all routes are properly protected and provides
|
|
959
|
+
* centralized routing control to prevent apps from bypassing route protection.
|
|
960
|
+
*
|
|
961
|
+
* @param props - Router props
|
|
962
|
+
* @returns React element with role-based routing
|
|
963
|
+
*/
|
|
964
|
+
declare function RoleBasedRouter({ routes, fallbackRoute, children, strictMode, auditLog, onRouteAccess, onStrictModeViolation, maxHistorySize, unauthorizedComponent: UnauthorizedComponent }: RoleBasedRouterProps): react_jsx_runtime.JSX.Element;
|
|
965
|
+
/**
|
|
966
|
+
* Hook to use role-based router context
|
|
967
|
+
*
|
|
968
|
+
* @returns Role-based router context
|
|
969
|
+
* @throws Error if used outside of RoleBasedRouter
|
|
970
|
+
*/
|
|
971
|
+
declare function useRoleBasedRouter(): RoleBasedRouterContextType;
|
|
972
|
+
|
|
973
|
+
interface NavigationItem {
|
|
974
|
+
/** Unique identifier for the navigation item */
|
|
975
|
+
id: string;
|
|
976
|
+
/** Display label for the navigation item */
|
|
977
|
+
label: string;
|
|
978
|
+
/** Navigation path/URL */
|
|
979
|
+
path: string;
|
|
980
|
+
/** Permissions required for this navigation item */
|
|
981
|
+
permissions: Permission[];
|
|
982
|
+
/** Roles that can access this navigation item */
|
|
983
|
+
roles?: string[];
|
|
984
|
+
/** Minimum access level required */
|
|
985
|
+
accessLevel?: 'viewer' | 'participant' | 'planner' | 'admin' | 'super';
|
|
986
|
+
/** Page ID for permission checking */
|
|
987
|
+
pageId?: string;
|
|
988
|
+
/** Enable strict mode for this navigation item */
|
|
989
|
+
strictMode?: boolean;
|
|
990
|
+
/** Navigation item metadata */
|
|
991
|
+
meta?: {
|
|
992
|
+
icon?: string;
|
|
993
|
+
description?: string;
|
|
994
|
+
hidden?: boolean;
|
|
995
|
+
order?: number;
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
interface NavigationAccessRecord {
|
|
999
|
+
navigationItem: string;
|
|
1000
|
+
permissions: Permission[];
|
|
1001
|
+
userId: UUID;
|
|
1002
|
+
scope: Scope;
|
|
1003
|
+
allowed: boolean;
|
|
1004
|
+
timestamp: string;
|
|
1005
|
+
pageId?: string;
|
|
1006
|
+
roles?: string[];
|
|
1007
|
+
accessLevel?: string;
|
|
1008
|
+
}
|
|
1009
|
+
interface NavigationContextType {
|
|
1010
|
+
/** Check if user has permission for a navigation item */
|
|
1011
|
+
hasNavigationPermission: (item: NavigationItem) => boolean;
|
|
1012
|
+
/** Get all navigation permissions for current user */
|
|
1013
|
+
getNavigationPermissions: () => Record<string, string[]>;
|
|
1014
|
+
/** Get filtered navigation items based on permissions */
|
|
1015
|
+
getFilteredNavigationItems: (items: NavigationItem[]) => NavigationItem[];
|
|
1016
|
+
/** Check if navigation permission checking is enabled */
|
|
1017
|
+
isEnabled: boolean;
|
|
1018
|
+
/** Check if strict mode is enabled */
|
|
1019
|
+
isStrictMode: boolean;
|
|
1020
|
+
/** Check if audit logging is enabled */
|
|
1021
|
+
isAuditLogEnabled: boolean;
|
|
1022
|
+
/** Get navigation access history */
|
|
1023
|
+
getNavigationAccessHistory: () => NavigationAccessRecord[];
|
|
1024
|
+
/** Clear navigation access history */
|
|
1025
|
+
clearNavigationAccessHistory: () => void;
|
|
1026
|
+
}
|
|
1027
|
+
interface NavigationProviderProps {
|
|
1028
|
+
/** Child components */
|
|
1029
|
+
children: React__default.ReactNode;
|
|
1030
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1031
|
+
strictMode?: boolean;
|
|
1032
|
+
/** Enable audit logging (default: true) */
|
|
1033
|
+
auditLog?: boolean;
|
|
1034
|
+
/** Callback when navigation access is attempted */
|
|
1035
|
+
onNavigationAccess?: (item: NavigationItem, allowed: boolean, record: NavigationAccessRecord) => void;
|
|
1036
|
+
/** Callback when strict mode violation occurs */
|
|
1037
|
+
onStrictModeViolation?: (item: NavigationItem, record: NavigationAccessRecord) => void;
|
|
1038
|
+
/** Maximum number of access records to keep in history */
|
|
1039
|
+
maxHistorySize?: number;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* NavigationProvider - Manages navigation-level permissions across the app
|
|
1043
|
+
*
|
|
1044
|
+
* This provider ensures that all navigation items are properly protected and provides
|
|
1045
|
+
* centralized navigation permission management with strict enforcement.
|
|
1046
|
+
*
|
|
1047
|
+
* @param props - Provider props
|
|
1048
|
+
* @returns React element with navigation permission context
|
|
1049
|
+
*/
|
|
1050
|
+
declare function NavigationProvider({ children, strictMode, auditLog, onNavigationAccess, onStrictModeViolation, maxHistorySize }: NavigationProviderProps): react_jsx_runtime.JSX.Element;
|
|
1051
|
+
/**
|
|
1052
|
+
* Hook to use navigation permission context
|
|
1053
|
+
*
|
|
1054
|
+
* @returns Navigation permission context
|
|
1055
|
+
* @throws Error if used outside of NavigationProvider
|
|
1056
|
+
*/
|
|
1057
|
+
declare function useNavigationPermissions(): NavigationContextType;
|
|
1058
|
+
|
|
1059
|
+
interface NavigationGuardProps {
|
|
1060
|
+
/** Navigation item being protected */
|
|
1061
|
+
navigationItem: NavigationItem;
|
|
1062
|
+
/** Content to render when user has permission */
|
|
1063
|
+
children: React__default.ReactNode;
|
|
1064
|
+
/** Content to render when user lacks permission */
|
|
1065
|
+
fallback?: React__default.ReactNode;
|
|
1066
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1067
|
+
strictMode?: boolean;
|
|
1068
|
+
/** Force audit logging for this navigation access (default: true) */
|
|
1069
|
+
auditLog?: boolean;
|
|
1070
|
+
/** Custom scope for permission checking */
|
|
1071
|
+
scope?: Scope;
|
|
1072
|
+
/** Callback when access is denied */
|
|
1073
|
+
onDenied?: (item: NavigationItem) => void;
|
|
1074
|
+
/** Loading state content */
|
|
1075
|
+
loading?: React__default.ReactNode;
|
|
1076
|
+
/** Require all permissions (AND) or any permission (OR) */
|
|
1077
|
+
requireAll?: boolean;
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* NavigationGuard - Enforces navigation-level permissions
|
|
1081
|
+
*
|
|
1082
|
+
* This component ensures that users can only access navigation items they have permission for.
|
|
1083
|
+
* It integrates with the existing RBAC system and provides strict enforcement to
|
|
1084
|
+
* prevent apps from bypassing navigation permission checks.
|
|
1085
|
+
*
|
|
1086
|
+
* @param props - Component props
|
|
1087
|
+
* @returns React element with navigation permission enforcement
|
|
1088
|
+
*/
|
|
1089
|
+
declare function NavigationGuard({ navigationItem, children, fallback, strictMode, auditLog, scope, onDenied, loading, requireAll }: NavigationGuardProps): react_jsx_runtime.JSX.Element;
|
|
1090
|
+
|
|
1091
|
+
interface EnhancedNavigationMenuProps {
|
|
1092
|
+
/** Navigation items to display */
|
|
1093
|
+
items: NavigationItem[];
|
|
1094
|
+
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1095
|
+
strictMode?: boolean;
|
|
1096
|
+
/** Enable audit logging (default: true) */
|
|
1097
|
+
auditLog?: boolean;
|
|
1098
|
+
/** Callback when navigation access is attempted */
|
|
1099
|
+
onNavigationAccess?: (item: NavigationItem, allowed: boolean) => void;
|
|
1100
|
+
/** Callback when strict mode violation occurs */
|
|
1101
|
+
onStrictModeViolation?: (item: NavigationItem) => void;
|
|
1102
|
+
/** Custom className for the navigation menu */
|
|
1103
|
+
className?: string;
|
|
1104
|
+
/** Custom className for navigation items */
|
|
1105
|
+
itemClassName?: string;
|
|
1106
|
+
/** Custom className for active navigation items */
|
|
1107
|
+
activeItemClassName?: string;
|
|
1108
|
+
/** Custom className for disabled navigation items */
|
|
1109
|
+
disabledItemClassName?: string;
|
|
1110
|
+
/** Show/hide navigation items that user doesn't have permission for */
|
|
1111
|
+
hideUnauthorizedItems?: boolean;
|
|
1112
|
+
/** Custom render function for navigation items */
|
|
1113
|
+
renderItem?: (item: NavigationItem, isAuthorized: boolean) => React__default.ReactNode;
|
|
1114
|
+
/** Current active path for highlighting */
|
|
1115
|
+
activePath?: string;
|
|
1116
|
+
/** Navigation item click handler */
|
|
1117
|
+
onItemClick?: (item: NavigationItem) => void;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* EnhancedNavigationMenu - Secure navigation menu with RBAC integration
|
|
1121
|
+
*
|
|
1122
|
+
* This component provides a navigation menu that automatically filters items based on
|
|
1123
|
+
* user permissions and enforces strict security controls.
|
|
1124
|
+
*
|
|
1125
|
+
* @param props - Component props
|
|
1126
|
+
* @returns React element with enhanced navigation menu
|
|
1127
|
+
*/
|
|
1128
|
+
declare function EnhancedNavigationMenu({ items, strictMode, auditLog, onNavigationAccess, onStrictModeViolation, className, itemClassName, activeItemClassName, disabledItemClassName, hideUnauthorizedItems, renderItem, activePath, onItemClick }: EnhancedNavigationMenuProps): react_jsx_runtime.JSX.Element;
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* RBAC React Hooks
|
|
1132
|
+
* @package @jmruthers/pace-core
|
|
1133
|
+
* @module RBAC/Hooks
|
|
1134
|
+
* @since 1.0.0
|
|
1135
|
+
*
|
|
1136
|
+
* This module provides React hooks for RBAC functionality.
|
|
1137
|
+
*/
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Hook to get user's permissions in a scope
|
|
1141
|
+
*
|
|
1142
|
+
* @param userId - User ID
|
|
835
1143
|
* @param scope - Permission scope
|
|
836
|
-
* @
|
|
837
|
-
* @param pageId - Optional page ID
|
|
838
|
-
* @returns True if user has any permission and loading state
|
|
1144
|
+
* @returns Permission data and loading state
|
|
839
1145
|
*
|
|
840
1146
|
* @example
|
|
841
1147
|
* ```tsx
|
|
842
1148
|
* function MyComponent() {
|
|
843
|
-
* const {
|
|
1149
|
+
* const { permissions, isLoading, error } = usePermissions(
|
|
844
1150
|
* 'user-123',
|
|
845
|
-
* { organisationId: 'org-456' }
|
|
846
|
-
* ['read:events', 'manage:events']
|
|
1151
|
+
* { organisationId: 'org-456' }
|
|
847
1152
|
* );
|
|
848
1153
|
*
|
|
1154
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
1155
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
1156
|
+
*
|
|
849
1157
|
* return (
|
|
850
1158
|
* <div>
|
|
851
|
-
* {
|
|
1159
|
+
* {permissions['page-1']?.includes('read') && <ReadButton />}
|
|
1160
|
+
* {permissions['page-1']?.includes('manage') && <ManageButton />}
|
|
852
1161
|
* </div>
|
|
853
1162
|
* );
|
|
854
1163
|
* }
|
|
855
1164
|
* ```
|
|
856
1165
|
*/
|
|
857
|
-
declare function
|
|
858
|
-
hasAny: boolean;
|
|
859
|
-
isLoading: boolean;
|
|
860
|
-
error: Error | null;
|
|
861
|
-
refetch: () => Promise<void>;
|
|
862
|
-
};
|
|
1166
|
+
declare function usePermissions(userId: UUID, scope: Scope): UsePermissionsReturn;
|
|
863
1167
|
/**
|
|
864
|
-
* Hook to check if user has
|
|
1168
|
+
* Hook to check if user has a specific permission
|
|
865
1169
|
*
|
|
866
1170
|
* @param userId - User ID
|
|
867
1171
|
* @param scope - Permission scope
|
|
868
|
-
* @param
|
|
1172
|
+
* @param permission - Permission to check
|
|
869
1173
|
* @param pageId - Optional page ID
|
|
870
|
-
* @
|
|
1174
|
+
* @param useCache - Whether to use cached results (default: true)
|
|
1175
|
+
* @returns Permission check result and loading state
|
|
871
1176
|
*
|
|
872
1177
|
* @example
|
|
873
1178
|
* ```tsx
|
|
874
1179
|
* function MyComponent() {
|
|
875
|
-
* const {
|
|
1180
|
+
* const { can, isLoading } = useCan(
|
|
876
1181
|
* 'user-123',
|
|
877
1182
|
* { organisationId: 'org-456' },
|
|
878
|
-
*
|
|
1183
|
+
* 'manage:events',
|
|
1184
|
+
* 'page-789'
|
|
879
1185
|
* );
|
|
880
1186
|
*
|
|
1187
|
+
* if (isLoading) return <div>Checking permission...</div>;
|
|
1188
|
+
*
|
|
881
1189
|
* return (
|
|
882
1190
|
* <div>
|
|
883
|
-
* {
|
|
1191
|
+
* {can ? <AdminPanel /> : <AccessDenied />}
|
|
884
1192
|
* </div>
|
|
885
1193
|
* );
|
|
886
1194
|
* }
|
|
887
1195
|
* ```
|
|
888
1196
|
*/
|
|
889
|
-
declare function
|
|
890
|
-
hasAll: boolean;
|
|
891
|
-
isLoading: boolean;
|
|
892
|
-
error: Error | null;
|
|
893
|
-
refetch: () => Promise<void>;
|
|
894
|
-
};
|
|
1197
|
+
declare function useCan(userId: UUID, scope: Scope, permission: Permission, pageId?: UUID, useCache?: boolean): UseCanReturn;
|
|
895
1198
|
/**
|
|
896
|
-
* Hook to
|
|
897
|
-
*
|
|
898
|
-
* This hook only reads from the core cache and does not perform
|
|
899
|
-
* any bespoke caching as per the contract requirements.
|
|
1199
|
+
* Hook to get user's access level in a scope
|
|
900
1200
|
*
|
|
901
1201
|
* @param userId - User ID
|
|
902
1202
|
* @param scope - Permission scope
|
|
903
|
-
* @returns
|
|
1203
|
+
* @returns Access level and loading state
|
|
904
1204
|
*
|
|
905
1205
|
* @example
|
|
906
1206
|
* ```tsx
|
|
907
1207
|
* function MyComponent() {
|
|
908
|
-
* const {
|
|
1208
|
+
* const { accessLevel, isLoading } = useAccessLevel(
|
|
909
1209
|
* 'user-123',
|
|
910
1210
|
* { organisationId: 'org-456' }
|
|
911
1211
|
* );
|
|
912
1212
|
*
|
|
913
|
-
* if (isLoading) return <div>Loading
|
|
914
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
1213
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
915
1214
|
*
|
|
916
1215
|
* return (
|
|
917
1216
|
* <div>
|
|
918
|
-
* {
|
|
919
|
-
* {
|
|
1217
|
+
* {accessLevel === 'super' && <SuperAdminPanel />}
|
|
1218
|
+
* {accessLevel === 'admin' && <AdminPanel />}
|
|
1219
|
+
* {accessLevel === 'planner' && <PlannerPanel />}
|
|
920
1220
|
* </div>
|
|
921
1221
|
* );
|
|
922
1222
|
* }
|
|
923
1223
|
* ```
|
|
924
1224
|
*/
|
|
925
|
-
declare function
|
|
926
|
-
|
|
1225
|
+
declare function useAccessLevel(userId: UUID, scope: Scope): {
|
|
1226
|
+
accessLevel: AccessLevel | null;
|
|
927
1227
|
isLoading: boolean;
|
|
928
1228
|
error: Error | null;
|
|
929
1229
|
refetch: () => Promise<void>;
|
|
930
1230
|
};
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
* RBAC Adapters
|
|
934
|
-
* @package @jmruthers/pace-core
|
|
935
|
-
* @module RBAC/Adapters
|
|
936
|
-
* @since 1.0.0
|
|
937
|
-
*
|
|
938
|
-
* This module provides adapters for different frameworks and server runtimes.
|
|
939
|
-
*/
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* Permission Guard Component
|
|
943
|
-
*
|
|
944
|
-
* A React component that conditionally renders children based on permissions.
|
|
945
|
-
* Can auto-infer userId from context if not provided.
|
|
946
|
-
*
|
|
947
|
-
* @example
|
|
948
|
-
* ```tsx
|
|
949
|
-
* // With explicit userId and scope
|
|
950
|
-
* <PermissionGuard
|
|
951
|
-
* userId="user-123"
|
|
952
|
-
* scope={{ organisationId: 'org-456' }}
|
|
953
|
-
* permission="manage:events"
|
|
954
|
-
* pageId="page-789"
|
|
955
|
-
* fallback={<AccessDenied />}
|
|
956
|
-
* >
|
|
957
|
-
* <AdminPanel />
|
|
958
|
-
* </PermissionGuard>
|
|
959
|
-
*
|
|
960
|
-
* // With context inference (requires auth context)
|
|
961
|
-
* <PermissionGuard
|
|
962
|
-
* permission="manage:events"
|
|
963
|
-
* scope={{ organisationId: 'org-456' }}
|
|
964
|
-
* fallback={<AccessDenied />}
|
|
965
|
-
* >
|
|
966
|
-
* <AdminPanel />
|
|
967
|
-
* </PermissionGuard>
|
|
968
|
-
* ```
|
|
969
|
-
*/
|
|
970
|
-
declare function PermissionGuard({ userId, scope, permission, pageId, children, fallback, onDenied, loading, strictMode, auditLog, enforceAudit, }: {
|
|
971
|
-
userId?: UUID;
|
|
972
|
-
scope: {
|
|
973
|
-
organisationId: UUID;
|
|
974
|
-
eventId?: string;
|
|
975
|
-
appId?: UUID;
|
|
976
|
-
};
|
|
977
|
-
permission: Permission;
|
|
978
|
-
pageId?: UUID;
|
|
979
|
-
children: ReactNode;
|
|
980
|
-
fallback?: ReactNode;
|
|
981
|
-
onDenied?: () => void;
|
|
982
|
-
loading?: ReactNode;
|
|
983
|
-
strictMode?: boolean;
|
|
984
|
-
auditLog?: boolean;
|
|
985
|
-
enforceAudit?: boolean;
|
|
986
|
-
}): React__default.ReactNode;
|
|
987
1231
|
/**
|
|
988
|
-
*
|
|
1232
|
+
* Hook to check multiple permissions at once
|
|
989
1233
|
*
|
|
990
|
-
*
|
|
991
|
-
*
|
|
1234
|
+
* @param userId - User ID
|
|
1235
|
+
* @param scope - Permission scope
|
|
1236
|
+
* @param permissions - Array of permissions to check
|
|
1237
|
+
* @param pageId - Optional page ID
|
|
1238
|
+
* @param useCache - Whether to use cached results (default: true)
|
|
1239
|
+
* @returns Object with permission results and loading state
|
|
992
1240
|
*
|
|
993
1241
|
* @example
|
|
994
1242
|
* ```tsx
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
* >
|
|
1002
|
-
* <AdminPanel />
|
|
1003
|
-
* </AccessLevelGuard>
|
|
1004
|
-
*
|
|
1005
|
-
* // With context inference (requires auth context)
|
|
1006
|
-
* <AccessLevelGuard
|
|
1007
|
-
* minLevel="admin"
|
|
1008
|
-
* scope={{ organisationId: 'org-456' }}
|
|
1009
|
-
* fallback={<AccessDenied />}
|
|
1010
|
-
* >
|
|
1011
|
-
* <AdminPanel />
|
|
1012
|
-
* </AccessLevelGuard>
|
|
1013
|
-
* ```
|
|
1014
|
-
*/
|
|
1015
|
-
declare function AccessLevelGuard({ userId, scope, minLevel, children, fallback, loading, }: {
|
|
1016
|
-
userId?: UUID;
|
|
1017
|
-
scope: {
|
|
1018
|
-
organisationId: UUID;
|
|
1019
|
-
eventId?: string;
|
|
1020
|
-
appId?: UUID;
|
|
1021
|
-
};
|
|
1022
|
-
minLevel: 'viewer' | 'participant' | 'planner' | 'admin' | 'super';
|
|
1023
|
-
children: ReactNode;
|
|
1024
|
-
fallback?: ReactNode;
|
|
1025
|
-
loading?: ReactNode;
|
|
1026
|
-
}): React__default.ReactNode;
|
|
1027
|
-
/**
|
|
1028
|
-
* Permission Guard for Server Handlers
|
|
1029
|
-
*
|
|
1030
|
-
* Wraps a server handler with permission checking.
|
|
1031
|
-
*
|
|
1032
|
-
* @param config - Permission guard configuration
|
|
1033
|
-
* @param handler - Handler function to wrap
|
|
1034
|
-
* @returns Wrapped handler function
|
|
1035
|
-
*
|
|
1036
|
-
* @example
|
|
1037
|
-
* ```typescript
|
|
1038
|
-
* const protectedHandler = withPermissionGuard(
|
|
1039
|
-
* { permission: 'manage:events', pageId: 'page-789' },
|
|
1040
|
-
* async (req, res) => {
|
|
1041
|
-
* // Handler logic here
|
|
1042
|
-
* res.json({ success: true });
|
|
1043
|
-
* }
|
|
1044
|
-
* );
|
|
1045
|
-
* ```
|
|
1046
|
-
*/
|
|
1047
|
-
declare function withPermissionGuard<T extends any[]>(config: {
|
|
1048
|
-
permission: Permission;
|
|
1049
|
-
pageId?: UUID;
|
|
1050
|
-
}, handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1051
|
-
/**
|
|
1052
|
-
* Access Level Guard for Server Handlers
|
|
1053
|
-
*
|
|
1054
|
-
* Wraps a server handler with access level checking.
|
|
1055
|
-
*
|
|
1056
|
-
* @param minLevel - Minimum access level required
|
|
1057
|
-
* @param handler - Handler function to wrap
|
|
1058
|
-
* @returns Wrapped handler function
|
|
1059
|
-
*
|
|
1060
|
-
* @example
|
|
1061
|
-
* ```typescript
|
|
1062
|
-
* const adminHandler = withAccessLevelGuard(
|
|
1063
|
-
* 'admin',
|
|
1064
|
-
* async (req, res) => {
|
|
1065
|
-
* // Admin-only logic here
|
|
1066
|
-
* res.json({ success: true });
|
|
1067
|
-
* }
|
|
1068
|
-
* );
|
|
1069
|
-
* ```
|
|
1070
|
-
*/
|
|
1071
|
-
declare function withAccessLevelGuard<T extends any[]>(minLevel: 'viewer' | 'participant' | 'planner' | 'admin' | 'super', handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1072
|
-
/**
|
|
1073
|
-
* Role Guard for Server Handlers
|
|
1074
|
-
*
|
|
1075
|
-
* Wraps a server handler with role-based access control.
|
|
1076
|
-
* This is the primary middleware for routing protection as specified in the contract.
|
|
1077
|
-
*
|
|
1078
|
-
* @param config - Role guard configuration
|
|
1079
|
-
* @param handler - Handler function to wrap
|
|
1080
|
-
* @returns Wrapped handler function
|
|
1081
|
-
*
|
|
1082
|
-
* @example
|
|
1083
|
-
* ```typescript
|
|
1084
|
-
* const adminHandler = withRoleGuard(
|
|
1085
|
-
* {
|
|
1086
|
-
* globalRoles: ['super_admin'],
|
|
1087
|
-
* organisationRoles: ['org_admin', 'leader'],
|
|
1088
|
-
* eventAppRoles: ['event_admin', 'planner']
|
|
1089
|
-
* },
|
|
1090
|
-
* async (req, res) => {
|
|
1091
|
-
* // Admin-only logic here
|
|
1092
|
-
* res.json({ success: true });
|
|
1093
|
-
* }
|
|
1094
|
-
* );
|
|
1095
|
-
* ```
|
|
1096
|
-
*/
|
|
1097
|
-
declare function withRoleGuard<T extends any[]>(config: {
|
|
1098
|
-
globalRoles?: string[];
|
|
1099
|
-
organisationRoles?: string[];
|
|
1100
|
-
eventAppRoles?: string[];
|
|
1101
|
-
requireAll?: boolean;
|
|
1102
|
-
}, handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1103
|
-
/**
|
|
1104
|
-
* Next.js Middleware for RBAC
|
|
1105
|
-
*
|
|
1106
|
-
* Middleware that checks permissions before allowing access to pages.
|
|
1107
|
-
*
|
|
1108
|
-
* @param config - Middleware configuration
|
|
1109
|
-
* @returns Next.js middleware function
|
|
1110
|
-
*
|
|
1111
|
-
* @example
|
|
1112
|
-
* ```typescript
|
|
1113
|
-
* // middleware.ts
|
|
1114
|
-
* import { createRBACMiddleware } from '@jmruthers/pace-core/rbac';
|
|
1115
|
-
*
|
|
1116
|
-
* export default createRBACMiddleware({
|
|
1117
|
-
* protectedRoutes: [
|
|
1118
|
-
* { path: '/admin', permission: 'manage:admin' },
|
|
1119
|
-
* { path: '/events', permission: 'read:events' },
|
|
1120
|
-
* ],
|
|
1121
|
-
* fallbackUrl: '/access-denied',
|
|
1122
|
-
* });
|
|
1123
|
-
* ```
|
|
1124
|
-
*/
|
|
1125
|
-
declare function createRBACMiddleware(config: {
|
|
1126
|
-
protectedRoutes: Array<{
|
|
1127
|
-
path: string;
|
|
1128
|
-
permission: Permission;
|
|
1129
|
-
pageId?: UUID;
|
|
1130
|
-
}>;
|
|
1131
|
-
fallbackUrl?: string;
|
|
1132
|
-
}): (req: {
|
|
1133
|
-
nextUrl: {
|
|
1134
|
-
pathname: string;
|
|
1135
|
-
};
|
|
1136
|
-
user?: {
|
|
1137
|
-
id: string;
|
|
1138
|
-
};
|
|
1139
|
-
organisationId?: string;
|
|
1140
|
-
}, res: {
|
|
1141
|
-
redirect: (url: string) => void;
|
|
1142
|
-
}, next: () => void) => Promise<void>;
|
|
1143
|
-
/**
|
|
1144
|
-
* Express Middleware for RBAC
|
|
1243
|
+
* function MyComponent() {
|
|
1244
|
+
* const { permissions, isLoading } = useMultiplePermissions(
|
|
1245
|
+
* 'user-123',
|
|
1246
|
+
* { organisationId: 'org-456' },
|
|
1247
|
+
* ['read:events', 'manage:events', 'delete:events']
|
|
1248
|
+
* );
|
|
1145
1249
|
*
|
|
1146
|
-
*
|
|
1250
|
+
* return (
|
|
1251
|
+
* <div>
|
|
1252
|
+
* {permissions['read:events'] && <ReadButton />}
|
|
1253
|
+
* {permissions['manage:events'] && <ManageButton />}
|
|
1254
|
+
* {permissions['delete:events'] && <DeleteButton />}
|
|
1255
|
+
* </div>
|
|
1256
|
+
* );
|
|
1257
|
+
* }
|
|
1258
|
+
* ```
|
|
1259
|
+
*/
|
|
1260
|
+
declare function useMultiplePermissions(userId: UUID, scope: Scope, permissions: Permission[], pageId?: UUID, useCache?: boolean): {
|
|
1261
|
+
permissions: Record<Permission, boolean>;
|
|
1262
|
+
isLoading: boolean;
|
|
1263
|
+
error: Error | null;
|
|
1264
|
+
refetch: () => Promise<void>;
|
|
1265
|
+
};
|
|
1266
|
+
/**
|
|
1267
|
+
* Hook to check if user has any of the specified permissions
|
|
1147
1268
|
*
|
|
1148
|
-
* @param
|
|
1149
|
-
* @
|
|
1269
|
+
* @param userId - User ID
|
|
1270
|
+
* @param scope - Permission scope
|
|
1271
|
+
* @param permissions - Array of permissions to check
|
|
1272
|
+
* @param pageId - Optional page ID
|
|
1273
|
+
* @returns True if user has any permission and loading state
|
|
1150
1274
|
*
|
|
1151
1275
|
* @example
|
|
1152
|
-
* ```
|
|
1153
|
-
*
|
|
1276
|
+
* ```tsx
|
|
1277
|
+
* function MyComponent() {
|
|
1278
|
+
* const { hasAny, isLoading } = useHasAnyPermission(
|
|
1279
|
+
* 'user-123',
|
|
1280
|
+
* { organisationId: 'org-456' },
|
|
1281
|
+
* ['read:events', 'manage:events']
|
|
1282
|
+
* );
|
|
1154
1283
|
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1284
|
+
* return (
|
|
1285
|
+
* <div>
|
|
1286
|
+
* {hasAny ? <EventContent /> : <AccessDenied />}
|
|
1287
|
+
* </div>
|
|
1288
|
+
* );
|
|
1289
|
+
* }
|
|
1159
1290
|
* ```
|
|
1160
1291
|
*/
|
|
1161
|
-
declare function
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
};
|
|
1168
|
-
organisationId?: string;
|
|
1169
|
-
eventId?: string;
|
|
1170
|
-
appId?: string;
|
|
1171
|
-
}, res: {
|
|
1172
|
-
status: (code: number) => {
|
|
1173
|
-
json: (data: object) => void;
|
|
1174
|
-
};
|
|
1175
|
-
}, next: () => void) => Promise<void>;
|
|
1292
|
+
declare function useHasAnyPermission(userId: UUID, scope: Scope, permissions: Permission[], pageId?: UUID): {
|
|
1293
|
+
hasAny: boolean;
|
|
1294
|
+
isLoading: boolean;
|
|
1295
|
+
error: Error | null;
|
|
1296
|
+
refetch: () => Promise<void>;
|
|
1297
|
+
};
|
|
1176
1298
|
/**
|
|
1177
|
-
*
|
|
1299
|
+
* Hook to check if user has all of the specified permissions
|
|
1178
1300
|
*
|
|
1179
1301
|
* @param userId - User ID
|
|
1180
1302
|
* @param scope - Permission scope
|
|
1181
|
-
* @param
|
|
1303
|
+
* @param permissions - Array of permissions to check
|
|
1182
1304
|
* @param pageId - Optional page ID
|
|
1183
|
-
* @returns True if
|
|
1305
|
+
* @returns True if user has all permissions and loading state
|
|
1306
|
+
*
|
|
1307
|
+
* @example
|
|
1308
|
+
* ```tsx
|
|
1309
|
+
* function MyComponent() {
|
|
1310
|
+
* const { hasAll, isLoading } = useHasAllPermissions(
|
|
1311
|
+
* 'user-123',
|
|
1312
|
+
* { organisationId: 'org-456' },
|
|
1313
|
+
* ['read:events', 'manage:events']
|
|
1314
|
+
* );
|
|
1315
|
+
*
|
|
1316
|
+
* return (
|
|
1317
|
+
* <div>
|
|
1318
|
+
* {hasAll ? <FullAccessPanel /> : <LimitedAccessPanel />}
|
|
1319
|
+
* </div>
|
|
1320
|
+
* );
|
|
1321
|
+
* }
|
|
1322
|
+
* ```
|
|
1184
1323
|
*/
|
|
1185
|
-
declare function
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1324
|
+
declare function useHasAllPermissions(userId: UUID, scope: Scope, permissions: Permission[], pageId?: UUID): {
|
|
1325
|
+
hasAll: boolean;
|
|
1326
|
+
isLoading: boolean;
|
|
1327
|
+
error: Error | null;
|
|
1328
|
+
refetch: () => Promise<void>;
|
|
1329
|
+
};
|
|
1190
1330
|
/**
|
|
1191
|
-
*
|
|
1331
|
+
* Hook to read cached permissions (contract requirement)
|
|
1332
|
+
*
|
|
1333
|
+
* This hook only reads from the core cache and does not perform
|
|
1334
|
+
* any bespoke caching as per the contract requirements.
|
|
1192
1335
|
*
|
|
1193
1336
|
* @param userId - User ID
|
|
1194
1337
|
* @param scope - Permission scope
|
|
1195
|
-
* @
|
|
1196
|
-
*
|
|
1197
|
-
* @
|
|
1338
|
+
* @returns Cached permission data and loading state
|
|
1339
|
+
*
|
|
1340
|
+
* @example
|
|
1341
|
+
* ```tsx
|
|
1342
|
+
* function MyComponent() {
|
|
1343
|
+
* const { permissions, isLoading, error } = useCachedPermissions(
|
|
1344
|
+
* 'user-123',
|
|
1345
|
+
* { organisationId: 'org-456' }
|
|
1346
|
+
* );
|
|
1347
|
+
*
|
|
1348
|
+
* if (isLoading) return <div>Loading cached permissions...</div>;
|
|
1349
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
1350
|
+
*
|
|
1351
|
+
* return (
|
|
1352
|
+
* <div>
|
|
1353
|
+
* {permissions['page-1']?.includes('read') && <ReadButton />}
|
|
1354
|
+
* {permissions['page-1']?.includes('manage') && <ManageButton />}
|
|
1355
|
+
* </div>
|
|
1356
|
+
* );
|
|
1357
|
+
* }
|
|
1358
|
+
* ```
|
|
1198
1359
|
*/
|
|
1199
|
-
declare function
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1360
|
+
declare function useCachedPermissions(userId: UUID, scope: Scope): {
|
|
1361
|
+
permissions: PermissionMap;
|
|
1362
|
+
isLoading: boolean;
|
|
1363
|
+
error: Error | null;
|
|
1364
|
+
refetch: () => Promise<void>;
|
|
1365
|
+
};
|
|
1204
1366
|
|
|
1205
|
-
interface PagePermissionContextType {
|
|
1206
|
-
/** Check if user has permission for a page */
|
|
1207
|
-
hasPagePermission: (pageName: string, operation: string, pageId?: string, scope?: Scope) => boolean;
|
|
1208
|
-
/** Get all page permissions for current user */
|
|
1209
|
-
getPagePermissions: () => Record<string, string[]>;
|
|
1210
|
-
/** Check if page permission checking is enabled */
|
|
1211
|
-
isEnabled: boolean;
|
|
1212
|
-
/** Check if strict mode is enabled */
|
|
1213
|
-
isStrictMode: boolean;
|
|
1214
|
-
/** Check if audit logging is enabled */
|
|
1215
|
-
isAuditLogEnabled: boolean;
|
|
1216
|
-
/** Get page access history */
|
|
1217
|
-
getPageAccessHistory: () => PageAccessRecord[];
|
|
1218
|
-
/** Clear page access history */
|
|
1219
|
-
clearPageAccessHistory: () => void;
|
|
1220
|
-
}
|
|
1221
|
-
interface PageAccessRecord {
|
|
1222
|
-
pageName: string;
|
|
1223
|
-
operation: string;
|
|
1224
|
-
userId: UUID;
|
|
1225
|
-
scope: Scope;
|
|
1226
|
-
allowed: boolean;
|
|
1227
|
-
timestamp: string;
|
|
1228
|
-
pageId?: string;
|
|
1229
|
-
}
|
|
1230
|
-
interface PagePermissionProviderProps {
|
|
1231
|
-
/** Child components */
|
|
1232
|
-
children: React__default.ReactNode;
|
|
1233
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1234
|
-
strictMode?: boolean;
|
|
1235
|
-
/** Enable audit logging (default: true) */
|
|
1236
|
-
auditLog?: boolean;
|
|
1237
|
-
/** Callback when page access is attempted */
|
|
1238
|
-
onPageAccess?: (pageName: string, operation: string, allowed: boolean, record: PageAccessRecord) => void;
|
|
1239
|
-
/** Callback when strict mode violation occurs */
|
|
1240
|
-
onStrictModeViolation?: (pageName: string, operation: string, record: PageAccessRecord) => void;
|
|
1241
|
-
/** Maximum number of access records to keep in history */
|
|
1242
|
-
maxHistorySize?: number;
|
|
1243
|
-
}
|
|
1244
1367
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1368
|
+
* RBAC Adapters
|
|
1369
|
+
* @package @jmruthers/pace-core
|
|
1370
|
+
* @module RBAC/Adapters
|
|
1371
|
+
* @since 1.0.0
|
|
1249
1372
|
*
|
|
1250
|
-
*
|
|
1251
|
-
* @returns React element with page permission context
|
|
1373
|
+
* This module provides adapters for different frameworks and server runtimes.
|
|
1252
1374
|
*/
|
|
1253
|
-
|
|
1375
|
+
|
|
1254
1376
|
/**
|
|
1255
|
-
*
|
|
1377
|
+
* Permission Guard Component
|
|
1256
1378
|
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1379
|
+
* A React component that conditionally renders children based on permissions.
|
|
1380
|
+
* Can auto-infer userId from context if not provided.
|
|
1381
|
+
*
|
|
1382
|
+
* @example
|
|
1383
|
+
* ```tsx
|
|
1384
|
+
* // With explicit userId and scope
|
|
1385
|
+
* <PermissionGuard
|
|
1386
|
+
* userId="user-123"
|
|
1387
|
+
* scope={{ organisationId: 'org-456' }}
|
|
1388
|
+
* permission="manage:events"
|
|
1389
|
+
* pageId="page-789"
|
|
1390
|
+
* fallback={<AccessDenied />}
|
|
1391
|
+
* >
|
|
1392
|
+
* <AdminPanel />
|
|
1393
|
+
* </PermissionGuard>
|
|
1394
|
+
*
|
|
1395
|
+
* // With context inference (requires auth context)
|
|
1396
|
+
* <PermissionGuard
|
|
1397
|
+
* permission="manage:events"
|
|
1398
|
+
* scope={{ organisationId: 'org-456' }}
|
|
1399
|
+
* fallback={<AccessDenied />}
|
|
1400
|
+
* >
|
|
1401
|
+
* <AdminPanel />
|
|
1402
|
+
* </PermissionGuard>
|
|
1403
|
+
* ```
|
|
1259
1404
|
*/
|
|
1260
|
-
declare function
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
fallback?:
|
|
1271
|
-
|
|
1405
|
+
declare function PermissionGuard({ userId, scope, permission, pageId, children, fallback, onDenied, loading, strictMode, auditLog, enforceAudit, }: {
|
|
1406
|
+
userId?: UUID;
|
|
1407
|
+
scope: {
|
|
1408
|
+
organisationId: UUID;
|
|
1409
|
+
eventId?: string;
|
|
1410
|
+
appId?: UUID;
|
|
1411
|
+
};
|
|
1412
|
+
permission: Permission;
|
|
1413
|
+
pageId?: UUID;
|
|
1414
|
+
children: ReactNode;
|
|
1415
|
+
fallback?: ReactNode;
|
|
1416
|
+
onDenied?: () => void;
|
|
1417
|
+
loading?: ReactNode;
|
|
1272
1418
|
strictMode?: boolean;
|
|
1273
|
-
/** Force audit logging for this page access (default: true) */
|
|
1274
1419
|
auditLog?: boolean;
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
/** Custom scope for permission checking */
|
|
1278
|
-
scope?: Scope;
|
|
1279
|
-
/** Callback when access is denied */
|
|
1280
|
-
onDenied?: (pageName: string, operation: string) => void;
|
|
1281
|
-
/** Loading state content */
|
|
1282
|
-
loading?: React__default.ReactNode;
|
|
1283
|
-
}
|
|
1420
|
+
enforceAudit?: boolean;
|
|
1421
|
+
}): React__default.ReactNode;
|
|
1284
1422
|
/**
|
|
1285
|
-
*
|
|
1423
|
+
* Access Level Guard Component
|
|
1286
1424
|
*
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* prevent apps from bypassing permission checks.
|
|
1425
|
+
* A React component that conditionally renders children based on access level.
|
|
1426
|
+
* Can auto-infer userId from context if not provided.
|
|
1290
1427
|
*
|
|
1291
|
-
* @
|
|
1292
|
-
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* ```tsx
|
|
1430
|
+
* // With explicit userId and scope
|
|
1431
|
+
* <AccessLevelGuard
|
|
1432
|
+
* userId="user-123"
|
|
1433
|
+
* scope={{ organisationId: 'org-456' }}
|
|
1434
|
+
* minLevel="admin"
|
|
1435
|
+
* fallback={<AccessDenied />}
|
|
1436
|
+
* >
|
|
1437
|
+
* <AdminPanel />
|
|
1438
|
+
* </AccessLevelGuard>
|
|
1439
|
+
*
|
|
1440
|
+
* // With context inference (requires auth context)
|
|
1441
|
+
* <AccessLevelGuard
|
|
1442
|
+
* minLevel="admin"
|
|
1443
|
+
* scope={{ organisationId: 'org-456' }}
|
|
1444
|
+
* fallback={<AccessDenied />}
|
|
1445
|
+
* >
|
|
1446
|
+
* <AdminPanel />
|
|
1447
|
+
* </AccessLevelGuard>
|
|
1448
|
+
* ```
|
|
1293
1449
|
*/
|
|
1294
|
-
declare function
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
interface SecureDataContextType {
|
|
1307
|
-
/** Check if data access is allowed for a table and operation */
|
|
1308
|
-
isDataAccessAllowed: (table: string, operation: string, scope?: Scope) => boolean;
|
|
1309
|
-
/** Get all data access permissions for current user */
|
|
1310
|
-
getDataAccessPermissions: () => Record<string, string[]>;
|
|
1311
|
-
/** Check if secure data access is enabled */
|
|
1312
|
-
isEnabled: boolean;
|
|
1313
|
-
/** Check if strict mode is enabled */
|
|
1314
|
-
isStrictMode: boolean;
|
|
1315
|
-
/** Check if audit logging is enabled */
|
|
1316
|
-
isAuditLogEnabled: boolean;
|
|
1317
|
-
/** Get data access history */
|
|
1318
|
-
getDataAccessHistory: () => DataAccessRecord[];
|
|
1319
|
-
/** Clear data access history */
|
|
1320
|
-
clearDataAccessHistory: () => void;
|
|
1321
|
-
/** Validate data access attempt */
|
|
1322
|
-
validateDataAccess: (table: string, operation: string, scope?: Scope) => boolean;
|
|
1323
|
-
}
|
|
1324
|
-
interface SecureDataProviderProps {
|
|
1325
|
-
/** Child components */
|
|
1326
|
-
children: React__default.ReactNode;
|
|
1327
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1328
|
-
strictMode?: boolean;
|
|
1329
|
-
/** Enable audit logging (default: true) */
|
|
1330
|
-
auditLog?: boolean;
|
|
1331
|
-
/** Callback when data access is attempted */
|
|
1332
|
-
onDataAccess?: (table: string, operation: string, allowed: boolean, record: DataAccessRecord) => void;
|
|
1333
|
-
/** Callback when strict mode violation occurs */
|
|
1334
|
-
onStrictModeViolation?: (table: string, operation: string, record: DataAccessRecord) => void;
|
|
1335
|
-
/** Maximum number of access records to keep in history */
|
|
1336
|
-
maxHistorySize?: number;
|
|
1337
|
-
/** Enable RLS enforcement (default: true) */
|
|
1338
|
-
enforceRLS?: boolean;
|
|
1339
|
-
}
|
|
1450
|
+
declare function AccessLevelGuard({ userId, scope, minLevel, children, fallback, loading, }: {
|
|
1451
|
+
userId?: UUID;
|
|
1452
|
+
scope: {
|
|
1453
|
+
organisationId: UUID;
|
|
1454
|
+
eventId?: string;
|
|
1455
|
+
appId?: UUID;
|
|
1456
|
+
};
|
|
1457
|
+
minLevel: 'viewer' | 'participant' | 'planner' | 'admin' | 'super';
|
|
1458
|
+
children: ReactNode;
|
|
1459
|
+
fallback?: ReactNode;
|
|
1460
|
+
loading?: ReactNode;
|
|
1461
|
+
}): React__default.ReactNode;
|
|
1340
1462
|
/**
|
|
1341
|
-
*
|
|
1463
|
+
* Permission Guard for Server Handlers
|
|
1342
1464
|
*
|
|
1343
|
-
*
|
|
1344
|
-
* and prevents apps from bypassing data access controls.
|
|
1465
|
+
* Wraps a server handler with permission checking.
|
|
1345
1466
|
*
|
|
1346
|
-
* @param
|
|
1347
|
-
* @
|
|
1467
|
+
* @param config - Permission guard configuration
|
|
1468
|
+
* @param handler - Handler function to wrap
|
|
1469
|
+
* @returns Wrapped handler function
|
|
1470
|
+
*
|
|
1471
|
+
* @example
|
|
1472
|
+
* ```typescript
|
|
1473
|
+
* const protectedHandler = withPermissionGuard(
|
|
1474
|
+
* { permission: 'manage:events', pageId: 'page-789' },
|
|
1475
|
+
* async (req, res) => {
|
|
1476
|
+
* // Handler logic here
|
|
1477
|
+
* res.json({ success: true });
|
|
1478
|
+
* }
|
|
1479
|
+
* );
|
|
1480
|
+
* ```
|
|
1348
1481
|
*/
|
|
1349
|
-
declare function
|
|
1482
|
+
declare function withPermissionGuard<T extends any[]>(config: {
|
|
1483
|
+
permission: Permission;
|
|
1484
|
+
pageId?: UUID;
|
|
1485
|
+
}, handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1350
1486
|
/**
|
|
1351
|
-
*
|
|
1487
|
+
* Access Level Guard for Server Handlers
|
|
1352
1488
|
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1489
|
+
* Wraps a server handler with access level checking.
|
|
1490
|
+
*
|
|
1491
|
+
* @param minLevel - Minimum access level required
|
|
1492
|
+
* @param handler - Handler function to wrap
|
|
1493
|
+
* @returns Wrapped handler function
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```typescript
|
|
1497
|
+
* const adminHandler = withAccessLevelGuard(
|
|
1498
|
+
* 'admin',
|
|
1499
|
+
* async (req, res) => {
|
|
1500
|
+
* // Admin-only logic here
|
|
1501
|
+
* res.json({ success: true });
|
|
1502
|
+
* }
|
|
1503
|
+
* );
|
|
1504
|
+
* ```
|
|
1355
1505
|
*/
|
|
1356
|
-
declare function
|
|
1357
|
-
|
|
1358
|
-
interface PermissionEnforcerProps {
|
|
1359
|
-
/** Permissions required for access */
|
|
1360
|
-
permissions: Permission[];
|
|
1361
|
-
/** Operation being performed */
|
|
1362
|
-
operation: string;
|
|
1363
|
-
/** Content to render when user has permission */
|
|
1364
|
-
children: React__default.ReactNode;
|
|
1365
|
-
/** Content to render when user lacks permission */
|
|
1366
|
-
fallback?: React__default.ReactNode;
|
|
1367
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1368
|
-
strictMode?: boolean;
|
|
1369
|
-
/** Force audit logging for this operation (default: true) */
|
|
1370
|
-
auditLog?: boolean;
|
|
1371
|
-
/** Custom scope for permission checking */
|
|
1372
|
-
scope?: Scope;
|
|
1373
|
-
/** Callback when access is denied */
|
|
1374
|
-
onDenied?: (permissions: Permission[], operation: string) => void;
|
|
1375
|
-
/** Loading state content */
|
|
1376
|
-
loading?: React__default.ReactNode;
|
|
1377
|
-
/** Require all permissions (AND) or any permission (OR) */
|
|
1378
|
-
requireAll?: boolean;
|
|
1379
|
-
}
|
|
1506
|
+
declare function withAccessLevelGuard<T extends any[]>(minLevel: 'viewer' | 'participant' | 'planner' | 'admin' | 'super', handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1380
1507
|
/**
|
|
1381
|
-
*
|
|
1508
|
+
* Role Guard for Server Handlers
|
|
1382
1509
|
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
* prevent apps from bypassing permission checks.
|
|
1510
|
+
* Wraps a server handler with role-based access control.
|
|
1511
|
+
* This is the primary middleware for routing protection as specified in the contract.
|
|
1386
1512
|
*
|
|
1387
|
-
* @param
|
|
1388
|
-
* @
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
hidden?: boolean;
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
interface RouteAccessRecord {
|
|
1416
|
-
route: string;
|
|
1417
|
-
permissions: Permission[];
|
|
1418
|
-
userId: UUID;
|
|
1419
|
-
scope: Scope;
|
|
1420
|
-
allowed: boolean;
|
|
1421
|
-
timestamp: string;
|
|
1422
|
-
pageId?: string;
|
|
1423
|
-
roles?: string[];
|
|
1424
|
-
accessLevel?: AccessLevel;
|
|
1425
|
-
}
|
|
1426
|
-
interface RoleBasedRouterContextType {
|
|
1427
|
-
/** Get all accessible routes for current user */
|
|
1428
|
-
getAccessibleRoutes: () => RouteConfig[];
|
|
1429
|
-
/** Check if user can access a specific route */
|
|
1430
|
-
canAccessRoute: (path: string) => boolean;
|
|
1431
|
-
/** Get route configuration for a path */
|
|
1432
|
-
getRouteConfig: (path: string) => RouteConfig | null;
|
|
1433
|
-
/** Get route access history */
|
|
1434
|
-
getRouteAccessHistory: () => RouteAccessRecord[];
|
|
1435
|
-
/** Clear route access history */
|
|
1436
|
-
clearRouteAccessHistory: () => void;
|
|
1437
|
-
/** Check if strict mode is enabled */
|
|
1438
|
-
isStrictMode: boolean;
|
|
1439
|
-
/** Check if audit logging is enabled */
|
|
1440
|
-
isAuditLogEnabled: boolean;
|
|
1441
|
-
}
|
|
1442
|
-
interface RoleBasedRouterProps {
|
|
1443
|
-
/** Route configuration */
|
|
1444
|
-
routes: RouteConfig[];
|
|
1445
|
-
/** Fallback route for unauthorized access */
|
|
1446
|
-
fallbackRoute?: string;
|
|
1447
|
-
/** Child components */
|
|
1448
|
-
children: React__default.ReactNode;
|
|
1449
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1450
|
-
strictMode?: boolean;
|
|
1451
|
-
/** Enable audit logging (default: true) */
|
|
1452
|
-
auditLog?: boolean;
|
|
1453
|
-
/** Callback when route access is attempted */
|
|
1454
|
-
onRouteAccess?: (route: string, allowed: boolean, record: RouteAccessRecord) => void;
|
|
1455
|
-
/** Callback when strict mode violation occurs */
|
|
1456
|
-
onStrictModeViolation?: (route: string, record: RouteAccessRecord) => void;
|
|
1457
|
-
/** Maximum number of access records to keep in history */
|
|
1458
|
-
maxHistorySize?: number;
|
|
1459
|
-
/** Custom unauthorized component */
|
|
1460
|
-
unauthorizedComponent?: React__default.ComponentType<{
|
|
1461
|
-
route: string;
|
|
1462
|
-
reason: string;
|
|
1463
|
-
}>;
|
|
1464
|
-
}
|
|
1513
|
+
* @param config - Role guard configuration
|
|
1514
|
+
* @param handler - Handler function to wrap
|
|
1515
|
+
* @returns Wrapped handler function
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
* ```typescript
|
|
1519
|
+
* const adminHandler = withRoleGuard(
|
|
1520
|
+
* {
|
|
1521
|
+
* globalRoles: ['super_admin'],
|
|
1522
|
+
* organisationRoles: ['org_admin', 'leader'],
|
|
1523
|
+
* eventAppRoles: ['event_admin', 'planner']
|
|
1524
|
+
* },
|
|
1525
|
+
* async (req, res) => {
|
|
1526
|
+
* // Admin-only logic here
|
|
1527
|
+
* res.json({ success: true });
|
|
1528
|
+
* }
|
|
1529
|
+
* );
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
declare function withRoleGuard<T extends any[]>(config: {
|
|
1533
|
+
globalRoles?: string[];
|
|
1534
|
+
organisationRoles?: string[];
|
|
1535
|
+
eventAppRoles?: string[];
|
|
1536
|
+
requireAll?: boolean;
|
|
1537
|
+
}, handler: (...args: T) => Promise<any>): (...args: T) => Promise<any>;
|
|
1465
1538
|
/**
|
|
1466
|
-
*
|
|
1539
|
+
* Next.js Middleware for RBAC
|
|
1467
1540
|
*
|
|
1468
|
-
*
|
|
1469
|
-
* centralized routing control to prevent apps from bypassing route protection.
|
|
1541
|
+
* Middleware that checks permissions before allowing access to pages.
|
|
1470
1542
|
*
|
|
1471
|
-
* @param
|
|
1472
|
-
* @returns
|
|
1473
|
-
*/
|
|
1474
|
-
declare function RoleBasedRouter({ routes, fallbackRoute, children, strictMode, auditLog, onRouteAccess, onStrictModeViolation, maxHistorySize, unauthorizedComponent: UnauthorizedComponent }: RoleBasedRouterProps): react_jsx_runtime.JSX.Element;
|
|
1475
|
-
/**
|
|
1476
|
-
* Hook to use role-based router context
|
|
1543
|
+
* @param config - Middleware configuration
|
|
1544
|
+
* @returns Next.js middleware function
|
|
1477
1545
|
*
|
|
1478
|
-
* @
|
|
1479
|
-
*
|
|
1546
|
+
* @example
|
|
1547
|
+
* ```typescript
|
|
1548
|
+
* // middleware.ts
|
|
1549
|
+
* import { createRBACMiddleware } from '@jmruthers/pace-core/rbac';
|
|
1550
|
+
*
|
|
1551
|
+
* export default createRBACMiddleware({
|
|
1552
|
+
* protectedRoutes: [
|
|
1553
|
+
* { path: '/admin', permission: 'manage:admin' },
|
|
1554
|
+
* { path: '/events', permission: 'read:events' },
|
|
1555
|
+
* ],
|
|
1556
|
+
* fallbackUrl: '/access-denied',
|
|
1557
|
+
* });
|
|
1558
|
+
* ```
|
|
1480
1559
|
*/
|
|
1481
|
-
declare function
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
permissions: Permission[];
|
|
1492
|
-
/** Roles that can access this navigation item */
|
|
1493
|
-
roles?: string[];
|
|
1494
|
-
/** Minimum access level required */
|
|
1495
|
-
accessLevel?: 'viewer' | 'participant' | 'planner' | 'admin' | 'super';
|
|
1496
|
-
/** Page ID for permission checking */
|
|
1497
|
-
pageId?: string;
|
|
1498
|
-
/** Enable strict mode for this navigation item */
|
|
1499
|
-
strictMode?: boolean;
|
|
1500
|
-
/** Navigation item metadata */
|
|
1501
|
-
meta?: {
|
|
1502
|
-
icon?: string;
|
|
1503
|
-
description?: string;
|
|
1504
|
-
hidden?: boolean;
|
|
1505
|
-
order?: number;
|
|
1560
|
+
declare function createRBACMiddleware(config: {
|
|
1561
|
+
protectedRoutes: Array<{
|
|
1562
|
+
path: string;
|
|
1563
|
+
permission: Permission;
|
|
1564
|
+
pageId?: UUID;
|
|
1565
|
+
}>;
|
|
1566
|
+
fallbackUrl?: string;
|
|
1567
|
+
}): (req: {
|
|
1568
|
+
nextUrl: {
|
|
1569
|
+
pathname: string;
|
|
1506
1570
|
};
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
timestamp: string;
|
|
1515
|
-
pageId?: string;
|
|
1516
|
-
roles?: string[];
|
|
1517
|
-
accessLevel?: string;
|
|
1518
|
-
}
|
|
1519
|
-
interface NavigationContextType {
|
|
1520
|
-
/** Check if user has permission for a navigation item */
|
|
1521
|
-
hasNavigationPermission: (item: NavigationItem) => boolean;
|
|
1522
|
-
/** Get all navigation permissions for current user */
|
|
1523
|
-
getNavigationPermissions: () => Record<string, string[]>;
|
|
1524
|
-
/** Get filtered navigation items based on permissions */
|
|
1525
|
-
getFilteredNavigationItems: (items: NavigationItem[]) => NavigationItem[];
|
|
1526
|
-
/** Check if navigation permission checking is enabled */
|
|
1527
|
-
isEnabled: boolean;
|
|
1528
|
-
/** Check if strict mode is enabled */
|
|
1529
|
-
isStrictMode: boolean;
|
|
1530
|
-
/** Check if audit logging is enabled */
|
|
1531
|
-
isAuditLogEnabled: boolean;
|
|
1532
|
-
/** Get navigation access history */
|
|
1533
|
-
getNavigationAccessHistory: () => NavigationAccessRecord[];
|
|
1534
|
-
/** Clear navigation access history */
|
|
1535
|
-
clearNavigationAccessHistory: () => void;
|
|
1536
|
-
}
|
|
1537
|
-
interface NavigationProviderProps {
|
|
1538
|
-
/** Child components */
|
|
1539
|
-
children: React__default.ReactNode;
|
|
1540
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1541
|
-
strictMode?: boolean;
|
|
1542
|
-
/** Enable audit logging (default: true) */
|
|
1543
|
-
auditLog?: boolean;
|
|
1544
|
-
/** Callback when navigation access is attempted */
|
|
1545
|
-
onNavigationAccess?: (item: NavigationItem, allowed: boolean, record: NavigationAccessRecord) => void;
|
|
1546
|
-
/** Callback when strict mode violation occurs */
|
|
1547
|
-
onStrictModeViolation?: (item: NavigationItem, record: NavigationAccessRecord) => void;
|
|
1548
|
-
/** Maximum number of access records to keep in history */
|
|
1549
|
-
maxHistorySize?: number;
|
|
1550
|
-
}
|
|
1571
|
+
user?: {
|
|
1572
|
+
id: string;
|
|
1573
|
+
};
|
|
1574
|
+
organisationId?: string;
|
|
1575
|
+
}, res: {
|
|
1576
|
+
redirect: (url: string) => void;
|
|
1577
|
+
}, next: () => void) => Promise<void>;
|
|
1551
1578
|
/**
|
|
1552
|
-
*
|
|
1579
|
+
* Express Middleware for RBAC
|
|
1553
1580
|
*
|
|
1554
|
-
*
|
|
1555
|
-
* centralized navigation permission management with strict enforcement.
|
|
1581
|
+
* Middleware that checks permissions for Express routes.
|
|
1556
1582
|
*
|
|
1557
|
-
* @param
|
|
1558
|
-
* @returns
|
|
1559
|
-
*/
|
|
1560
|
-
declare function NavigationProvider({ children, strictMode, auditLog, onNavigationAccess, onStrictModeViolation, maxHistorySize }: NavigationProviderProps): react_jsx_runtime.JSX.Element;
|
|
1561
|
-
/**
|
|
1562
|
-
* Hook to use navigation permission context
|
|
1583
|
+
* @param config - Middleware configuration
|
|
1584
|
+
* @returns Express middleware function
|
|
1563
1585
|
*
|
|
1564
|
-
* @
|
|
1565
|
-
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```typescript
|
|
1588
|
+
* import { createRBACExpressMiddleware } from '@jmruthers/pace-core/rbac';
|
|
1589
|
+
*
|
|
1590
|
+
* app.use(createRBACExpressMiddleware({
|
|
1591
|
+
* permission: 'read:api',
|
|
1592
|
+
* pageId: 'api-page-123',
|
|
1593
|
+
* }));
|
|
1594
|
+
* ```
|
|
1566
1595
|
*/
|
|
1567
|
-
declare function
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
/** Callback when access is denied */
|
|
1583
|
-
onDenied?: (item: NavigationItem) => void;
|
|
1584
|
-
/** Loading state content */
|
|
1585
|
-
loading?: React__default.ReactNode;
|
|
1586
|
-
/** Require all permissions (AND) or any permission (OR) */
|
|
1587
|
-
requireAll?: boolean;
|
|
1588
|
-
}
|
|
1596
|
+
declare function createRBACExpressMiddleware(config: {
|
|
1597
|
+
permission: Permission;
|
|
1598
|
+
pageId?: UUID;
|
|
1599
|
+
}): (req: {
|
|
1600
|
+
user?: {
|
|
1601
|
+
id: string;
|
|
1602
|
+
};
|
|
1603
|
+
organisationId?: string;
|
|
1604
|
+
eventId?: string;
|
|
1605
|
+
appId?: string;
|
|
1606
|
+
}, res: {
|
|
1607
|
+
status: (code: number) => {
|
|
1608
|
+
json: (data: object) => void;
|
|
1609
|
+
};
|
|
1610
|
+
}, next: () => void) => Promise<void>;
|
|
1589
1611
|
/**
|
|
1590
|
-
*
|
|
1591
|
-
*
|
|
1592
|
-
* This component ensures that users can only access navigation items they have permission for.
|
|
1593
|
-
* It integrates with the existing RBAC system and provides strict enforcement to
|
|
1594
|
-
* prevent apps from bypassing navigation permission checks.
|
|
1612
|
+
* Check if a user has a permission (synchronous cache check only)
|
|
1595
1613
|
*
|
|
1596
|
-
* @param
|
|
1597
|
-
* @
|
|
1614
|
+
* @param userId - User ID
|
|
1615
|
+
* @param scope - Permission scope
|
|
1616
|
+
* @param permission - Permission to check
|
|
1617
|
+
* @param pageId - Optional page ID
|
|
1618
|
+
* @returns True if permission is cached and granted
|
|
1598
1619
|
*/
|
|
1599
|
-
declare function
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
/** Enable strict mode to prevent bypassing (default: true) */
|
|
1605
|
-
strictMode?: boolean;
|
|
1606
|
-
/** Enable audit logging (default: true) */
|
|
1607
|
-
auditLog?: boolean;
|
|
1608
|
-
/** Callback when navigation access is attempted */
|
|
1609
|
-
onNavigationAccess?: (item: NavigationItem, allowed: boolean) => void;
|
|
1610
|
-
/** Callback when strict mode violation occurs */
|
|
1611
|
-
onStrictModeViolation?: (item: NavigationItem) => void;
|
|
1612
|
-
/** Custom className for the navigation menu */
|
|
1613
|
-
className?: string;
|
|
1614
|
-
/** Custom className for navigation items */
|
|
1615
|
-
itemClassName?: string;
|
|
1616
|
-
/** Custom className for active navigation items */
|
|
1617
|
-
activeItemClassName?: string;
|
|
1618
|
-
/** Custom className for disabled navigation items */
|
|
1619
|
-
disabledItemClassName?: string;
|
|
1620
|
-
/** Show/hide navigation items that user doesn't have permission for */
|
|
1621
|
-
hideUnauthorizedItems?: boolean;
|
|
1622
|
-
/** Custom render function for navigation items */
|
|
1623
|
-
renderItem?: (item: NavigationItem, isAuthorized: boolean) => React__default.ReactNode;
|
|
1624
|
-
/** Current active path for highlighting */
|
|
1625
|
-
activePath?: string;
|
|
1626
|
-
/** Navigation item click handler */
|
|
1627
|
-
onItemClick?: (item: NavigationItem) => void;
|
|
1628
|
-
}
|
|
1620
|
+
declare function hasPermissionCached(userId: UUID, scope: {
|
|
1621
|
+
organisationId: UUID;
|
|
1622
|
+
eventId?: string;
|
|
1623
|
+
appId?: UUID;
|
|
1624
|
+
}, _permission: Permission, _pageId?: UUID): boolean;
|
|
1629
1625
|
/**
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
* This component provides a navigation menu that automatically filters items based on
|
|
1633
|
-
* user permissions and enforces strict security controls.
|
|
1626
|
+
* Check if a user has any of the specified permissions (synchronous cache check only)
|
|
1634
1627
|
*
|
|
1635
|
-
* @param
|
|
1636
|
-
* @
|
|
1628
|
+
* @param userId - User ID
|
|
1629
|
+
* @param scope - Permission scope
|
|
1630
|
+
* @param permissions - Array of permissions to check
|
|
1631
|
+
* @param pageId - Optional page ID
|
|
1632
|
+
* @returns True if any permission is cached and granted
|
|
1637
1633
|
*/
|
|
1638
|
-
declare function
|
|
1634
|
+
declare function hasAnyPermissionCached(userId: UUID, scope: {
|
|
1635
|
+
organisationId: UUID;
|
|
1636
|
+
eventId?: string;
|
|
1637
|
+
appId?: UUID;
|
|
1638
|
+
}, permissions: Permission[], pageId?: UUID): boolean;
|
|
1639
1639
|
|
|
1640
1640
|
/**
|
|
1641
1641
|
* RBAC Main API Functions
|