@jmruthers/pace-core 0.5.53 → 0.5.55
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/README.md +0 -4
- package/dist/{DataTable-7FMFXA7A.js → DataTable-4T627QFJ.js} +11 -11
- package/dist/{PublicLoadingSpinner-Bq_-BeK-.d.ts → PublicLoadingSpinner-SL8WaQN7.d.ts} +2 -21
- package/dist/{api-H5A3H4IR.js → api-LUNF5O6M.js} +3 -3
- package/dist/{appConfig-BVGyuvI7.d.ts → appConfig-DjpeG6P-.d.ts} +9 -1
- package/dist/{appNameResolver-7GHF5ED2.js → appNameResolver-UURKN7NF.js} +2 -2
- package/dist/{audit-BUW3LMJB.js → audit-6TOCAMKO.js} +2 -2
- package/dist/{chunk-MZBUOP4P.js → chunk-5BSLGBYI.js} +4 -3
- package/dist/chunk-5BSLGBYI.js.map +1 -0
- package/dist/{chunk-I5Z3QH5X.js → chunk-66C4BSAY.js} +2 -2
- package/dist/{chunk-I5Z3QH5X.js.map → chunk-66C4BSAY.js.map} +1 -1
- package/dist/{chunk-MYP2EGHX.js → chunk-AJ2KMES7.js} +21 -14
- package/dist/chunk-AJ2KMES7.js.map +1 -0
- package/dist/{chunk-EL2O4IUX.js → chunk-AQFRLC7K.js} +16 -24
- package/dist/{chunk-EL2O4IUX.js.map → chunk-AQFRLC7K.js.map} +1 -1
- package/dist/{chunk-7BNPOCLL.js → chunk-B2WTCLCV.js} +6 -2
- package/dist/chunk-B2WTCLCV.js.map +1 -0
- package/dist/{chunk-WJARTBCT.js → chunk-D7ARGIA3.js} +16 -7
- package/dist/chunk-D7ARGIA3.js.map +1 -0
- package/dist/{chunk-NRK4AIHQ.js → chunk-KBRACSJI.js} +3 -3
- package/dist/{chunk-NYUJ4FJR.js → chunk-KJDPSM64.js} +7 -7
- package/dist/chunk-KJDPSM64.js.map +1 -0
- package/dist/{chunk-GWSBHC4J.js → chunk-KLPVOPRI.js} +261 -38
- package/dist/chunk-KLPVOPRI.js.map +1 -0
- package/dist/{chunk-TRIZ7IB7.js → chunk-MPQDF75X.js} +148 -288
- package/dist/chunk-MPQDF75X.js.map +1 -0
- package/dist/{chunk-MSFACPQQ.js → chunk-PAEM3OWN.js} +11 -11
- package/dist/{chunk-MSFACPQQ.js.map → chunk-PAEM3OWN.js.map} +1 -1
- package/dist/{chunk-GIO7BFE7.js → chunk-RQD3D2CO.js} +66 -169
- package/dist/{chunk-GIO7BFE7.js.map → chunk-RQD3D2CO.js.map} +1 -1
- package/dist/{chunk-YDJW5XTN.js → chunk-STT7INZR.js} +25 -1
- package/dist/chunk-STT7INZR.js.map +1 -0
- package/dist/{chunk-6MTY77WU.js → chunk-TNMXZLDR.js} +3 -3
- package/dist/{chunk-BC3S53OZ.js → chunk-UQE2Y64H.js} +30 -14
- package/dist/chunk-UQE2Y64H.js.map +1 -0
- package/dist/{chunk-22KLBHPS.js → chunk-W66AZIOH.js} +2 -2
- package/dist/chunk-W66AZIOH.js.map +1 -0
- package/dist/{chunk-SS3E6QLB.js → chunk-YNUBMSMV.js} +2 -2
- package/dist/chunk-YNUBMSMV.js.map +1 -0
- package/dist/{chunk-NZ655MWE.js → chunk-ZOD2ZY6X.js} +5 -4
- package/dist/chunk-ZOD2ZY6X.js.map +1 -0
- package/dist/{chunk-74C6SNEC.js → chunk-ZPK5656W.js} +3 -3
- package/dist/{chunk-74C6SNEC.js.map → chunk-ZPK5656W.js.map} +1 -1
- package/dist/components.d.ts +22 -899
- package/dist/components.js +436 -3118
- package/dist/components.js.map +1 -1
- package/dist/file-reference-9xUOnwyt.d.ts +70 -0
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +10 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +49 -9
- package/dist/index.js +190 -25
- package/dist/index.js.map +1 -1
- package/dist/{organisation-CO3Sh3_D.d.ts → organisation-t-vvQC3g.d.ts} +1 -8
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +5 -5
- package/dist/rbac/index.d.ts +65 -46
- package/dist/rbac/index.js +10 -12
- package/dist/styles/core.css +0 -125
- package/dist/types.d.ts +2 -1
- package/dist/types.js +3 -1
- package/dist/types.js.map +1 -1
- package/dist/{usePublicRouteParams-B2OcAsur.d.ts → usePublicRouteParams-CdoFxnJK.d.ts} +1 -1
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +44 -13
- package/dist/utils.js.map +1 -1
- package/docs/FILE_REFERENCE_SYSTEM.md +440 -0
- package/docs/INDEX.md +7 -5
- package/docs/README.md +0 -1
- package/docs/api/README.md +0 -4
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +2 -2
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +12 -12
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +6 -6
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +281 -0
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- 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/NavigationAccessRecord.md +2 -2
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACProviderProps.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/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 +204 -200
- package/docs/api-reference/components.md +141 -163
- package/docs/api-reference/hooks.md +347 -0
- package/docs/core-concepts/rbac-system.md +69 -16
- package/docs/getting-started/examples/basic-auth-app.md +0 -1
- package/docs/implementation-guides/datatable-rbac-usage.md +12 -11
- package/docs/implementation-guides/file-upload-storage.md +733 -0
- package/docs/implementation-guides/inactivity-tracking.md +779 -0
- package/docs/implementation-guides/organisation-security.md +748 -0
- package/docs/implementation-guides/public-pages-advanced.md +1022 -0
- package/docs/migration/MIGRATION_GUIDE.md +684 -0
- package/docs/migration/README.md +13 -2
- package/docs/migration/rbac-migration.md +73 -0
- package/docs/rbac/examples/rbac-rls-integration-example.md +11 -13
- package/docs/style-guide.md +269 -1
- package/package.json +1 -1
- package/src/__tests__/TESTING_GUIDELINES.md +331 -18
- package/src/__tests__/helpers/supabaseMock.ts +99 -0
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +10 -7
- package/src/__tests__/shared.ts +6 -0
- package/src/components/DataTable/components/ActionButtons.tsx +2 -2
- package/src/components/DataTable/components/DataTableCore.tsx +2 -2
- package/src/components/DataTable/components/UnifiedTableBody.tsx +1 -1
- package/src/components/DataTable/utils/debugTools.ts +2 -2
- package/src/components/Dialog/Dialog.test.tsx +12 -2
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +6 -6
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +2 -2
- package/src/components/FileDisplay.tsx +233 -0
- package/src/components/FileUpload.tsx +176 -0
- package/src/components/Footer/Footer.test.tsx +7 -7
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +13 -6
- package/src/components/OrganisationSelector/OrganisationSelector.test.tsx +30 -3
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +1 -1
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +558 -0
- package/src/components/PublicLayout/PublicErrorBoundary.tsx +1 -1
- package/src/components/PublicLayout/PublicPageDebugger.tsx +2 -2
- package/src/components/PublicLayout/PublicPageDiagnostic.tsx +2 -2
- package/src/components/PublicLayout/PublicPageProvider.tsx +2 -2
- package/src/components/Select/Select.test.tsx +50 -15
- package/src/components/SuperAdminGuard.tsx +2 -2
- package/src/components/__tests__/SuperAdminGuard.test.tsx +559 -0
- package/src/components/index.ts +0 -183
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +2 -2
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +1 -1
- package/src/hooks/__tests__/useRBAC.unit.test.ts +191 -138
- package/src/hooks/public/usePublicEvent.ts +2 -2
- package/src/hooks/useAppConfig.ts +3 -3
- package/src/hooks/useComponentPerformance.ts +1 -1
- package/src/hooks/useDataTablePerformance.ts +1 -1
- package/src/hooks/useFileReference.ts +232 -0
- package/src/hooks/useOrganisationPermissions.test.ts +254 -344
- package/src/hooks/useOrganisationPermissions.ts +15 -7
- package/src/hooks/useOrganisationSecurity.test.ts +390 -402
- package/src/hooks/usePerformanceMonitor.ts +1 -1
- package/src/hooks/usePermissionCache.test.ts +264 -395
- package/src/hooks/usePermissionCache.ts +34 -4
- package/src/hooks/useSecureDataAccess.test.ts +486 -0
- package/src/hooks/useSecureDataAccess.ts +4 -1
- package/src/providers/InactivityProvider.tsx +2 -2
- package/src/providers/OrganisationProvider.test.simple.tsx +168 -0
- package/src/providers/OrganisationProvider.test.tsx +168 -0
- package/src/providers/OrganisationProvider.tsx +18 -31
- package/src/providers/UnifiedAuthProvider.test.simple.tsx +205 -0
- package/src/providers/UnifiedAuthProvider.test.tsx +128 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +3 -4
- package/src/providers/__tests__/OrganisationProvider.test.tsx +19 -14
- package/src/rbac/__tests__/integration.authflow.test.tsx +123 -0
- package/src/rbac/__tests__/integration.navigation.test.tsx +72 -0
- package/src/rbac/__tests__/integration.securedata.test.tsx +92 -0
- package/src/rbac/__tests__/integration.smoke.test.tsx +73 -0
- package/src/rbac/__tests__/rbac-core.test.tsx +26 -22
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +411 -0
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +285 -0
- package/src/rbac/__tests__/rbac-functions.test.ts +655 -0
- package/src/rbac/__tests__/rbac-integration.test.ts +532 -0
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +196 -0
- package/src/rbac/api.test.ts +6 -6
- package/src/rbac/api.ts +2 -2
- package/src/rbac/audit.test.ts +485 -0
- package/src/rbac/audit.ts +7 -1
- package/src/rbac/cache-invalidation.ts +318 -0
- package/src/rbac/cache.test.ts +286 -0
- package/src/rbac/components/EnhancedNavigationMenu.test.tsx +559 -0
- package/src/rbac/components/EnhancedNavigationMenu.tsx +29 -23
- package/src/rbac/components/NavigationProvider.test.tsx +449 -0
- package/src/rbac/components/PagePermissionGuard.tsx +4 -4
- package/src/rbac/components/PagePermissionProvider.test.tsx +479 -0
- package/src/rbac/components/SecureDataProvider.test.tsx +511 -0
- package/src/rbac/components/__tests__/PagePermissionGuard.race-condition.test.tsx +159 -430
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +4 -5
- package/src/rbac/components/__tests__/PagePermissionGuard.verification.test.tsx +112 -118
- package/src/rbac/config.test.ts +410 -0
- package/src/rbac/engine.test.simple.ts +237 -0
- package/src/rbac/engine.test.ts +233 -0
- package/src/rbac/engine.ts +37 -41
- package/src/rbac/examples/CompleteRBACExample.tsx +3 -3
- package/src/rbac/examples/EventBasedApp.tsx +4 -4
- package/src/rbac/hooks/useRBAC.simple.test.ts +16 -0
- package/src/rbac/hooks/useRBAC.test.ts +207 -455
- package/src/rbac/hooks/useRBAC.ts +30 -22
- package/src/rbac/permissions.test.ts +128 -0
- package/src/rbac/permissions.ts +56 -141
- package/src/rbac/providers/RBACProvider.tsx +1 -1
- package/src/rbac/secureClient.test.ts +444 -0
- package/src/rbac/security.test.ts +390 -0
- package/src/rbac/security.ts +1 -1
- package/src/rbac/types.test.ts +382 -0
- package/src/rbac/types.ts +2 -2
- package/src/styles/base.css +208 -0
- package/src/styles/core.css +0 -125
- package/src/styles/semantic.css +24 -0
- package/src/types/file-reference.ts +77 -0
- package/src/types/rbac-functions.ts +290 -0
- package/src/types/supabase.ts +10 -28
- package/src/types/unified.ts +4 -1
- package/src/utils/__tests__/bundleAnalysis.unit.test.ts +81 -55
- package/src/utils/__tests__/lazyLoad.unit.test.tsx +21 -12
- package/src/utils/__tests__/organisationContext.unit.test.ts +13 -7
- package/src/utils/__tests__/performanceBudgets.unit.test.ts +3 -3
- package/src/utils/__tests__/sessionTracking.unit.test.ts +32 -12
- package/src/utils/appConfig.ts +1 -1
- package/src/utils/appIdResolver.test.ts +503 -0
- package/src/utils/appIdResolver.ts +1 -1
- package/src/utils/appNameResolver.test.ts +494 -0
- package/src/utils/appNameResolver.ts +3 -2
- package/src/utils/bundleAnalysis.ts +3 -3
- package/src/utils/debugLogger.ts +1 -1
- package/src/utils/file-reference.ts +263 -0
- package/src/utils/formatDate.test.ts +2 -2
- package/src/utils/organisationContext.test.ts +340 -0
- package/src/utils/organisationContext.ts +19 -6
- package/src/utils/performanceBudgets.ts +2 -2
- package/src/utils/permissionUtils.test.ts +393 -0
- package/src/utils/permissionUtils.ts +5 -2
- package/src/utils/secureDataAccess.test.ts +715 -0
- package/src/utils/secureDataAccess.ts +21 -5
- package/src/utils/sessionTracking.ts +34 -4
- package/src/utils/storage/__tests__/helpers.unit.test.ts +328 -0
- package/src/utils/storage/__tests__/index.unit.test.ts +16 -0
- package/src/utils/storage/helpers.ts +20 -25
- package/src/utils/storage/index.ts +29 -1
- package/src/vite-env.d.ts +17 -0
- package/dist/chunk-22KLBHPS.js.map +0 -1
- package/dist/chunk-7BNPOCLL.js.map +0 -1
- package/dist/chunk-BC3S53OZ.js.map +0 -1
- package/dist/chunk-GWSBHC4J.js.map +0 -1
- package/dist/chunk-MYP2EGHX.js.map +0 -1
- package/dist/chunk-MZBUOP4P.js.map +0 -1
- package/dist/chunk-NYUJ4FJR.js.map +0 -1
- package/dist/chunk-NZ655MWE.js.map +0 -1
- package/dist/chunk-SS3E6QLB.js.map +0 -1
- package/dist/chunk-TRIZ7IB7.js.map +0 -1
- package/dist/chunk-WJARTBCT.js.map +0 -1
- package/dist/chunk-YDJW5XTN.js.map +0 -1
- package/docs/print-components/README.md +0 -258
- package/docs/print-components/api-reference.md +0 -636
- package/docs/print-components/examples/README.md +0 -204
- package/docs/print-components/examples/basic-report.tsx +0 -92
- package/docs/print-components/examples/card-catalog.tsx +0 -149
- package/docs/print-components/examples/cover-page-report.tsx +0 -163
- package/docs/print-components/quick-start.md +0 -363
- package/src/components/PrintButton/PrintButton.tsx +0 -321
- package/src/components/PrintButton/PrintButtonGroup.tsx +0 -84
- package/src/components/PrintButton/PrintToolbar.tsx +0 -94
- package/src/components/PrintButton/__tests__/PrintButton.test.tsx +0 -271
- package/src/components/PrintButton/examples/PrintButtonShowcase.tsx +0 -438
- package/src/components/PrintButton/index.ts +0 -33
- package/src/components/PrintButton/types.ts +0 -173
- package/src/components/PrintCard/PrintCard.tsx +0 -154
- package/src/components/PrintCard/PrintCardContent.tsx +0 -57
- package/src/components/PrintCard/PrintCardFooter.tsx +0 -60
- package/src/components/PrintCard/PrintCardGrid.tsx +0 -91
- package/src/components/PrintCard/PrintCardHeader.tsx +0 -78
- package/src/components/PrintCard/PrintCardImage.tsx +0 -81
- package/src/components/PrintCard/examples/PrintCardShowcase.tsx +0 -239
- package/src/components/PrintCard/index.ts +0 -34
- package/src/components/PrintCard/types.ts +0 -171
- package/src/components/PrintDataTable/PrintDataTable.tsx +0 -215
- package/src/components/PrintDataTable/PrintTableGroup.tsx +0 -90
- package/src/components/PrintDataTable/PrintTableRow.tsx +0 -76
- package/src/components/PrintDataTable/index.ts +0 -25
- package/src/components/PrintDataTable/types.ts +0 -67
- package/src/components/PrintFooter/PrintFooter.tsx +0 -183
- package/src/components/PrintFooter/PrintFooterContent.tsx +0 -71
- package/src/components/PrintFooter/PrintFooterInfo.tsx +0 -86
- package/src/components/PrintFooter/PrintPageNumber.tsx +0 -90
- package/src/components/PrintFooter/examples/PrintFooterShowcase.tsx +0 -390
- package/src/components/PrintFooter/index.ts +0 -30
- package/src/components/PrintFooter/types.ts +0 -149
- package/src/components/PrintGrid/PrintGrid.tsx +0 -180
- package/src/components/PrintGrid/PrintGridBreakpoint.tsx +0 -109
- package/src/components/PrintGrid/PrintGridContainer.tsx +0 -128
- package/src/components/PrintGrid/PrintGridItem.tsx +0 -220
- package/src/components/PrintGrid/examples/PrintGridShowcase.tsx +0 -359
- package/src/components/PrintGrid/index.ts +0 -31
- package/src/components/PrintGrid/types.ts +0 -159
- package/src/components/PrintHeader/PrintCoverHeader.tsx +0 -230
- package/src/components/PrintHeader/PrintHeader.tsx +0 -150
- package/src/components/PrintHeader/index.ts +0 -17
- package/src/components/PrintHeader/types.ts +0 -42
- package/src/components/PrintLayout/PrintLayout.tsx +0 -122
- package/src/components/PrintLayout/PrintLayoutContext.tsx +0 -66
- package/src/components/PrintLayout/PrintPageBreak.tsx +0 -52
- package/src/components/PrintLayout/examples/PrintShowcase.tsx +0 -230
- package/src/components/PrintLayout/index.ts +0 -19
- package/src/components/PrintLayout/types.ts +0 -37
- package/src/components/PrintPageBreak/PrintPageBreak.tsx +0 -120
- package/src/components/PrintPageBreak/PrintPageBreakGroup.tsx +0 -90
- package/src/components/PrintPageBreak/PrintPageBreakIndicator.tsx +0 -112
- package/src/components/PrintPageBreak/examples/PrintPageBreakShowcase.tsx +0 -279
- package/src/components/PrintPageBreak/index.ts +0 -23
- package/src/components/PrintPageBreak/types.ts +0 -94
- package/src/components/PrintSection/PrintColumn.tsx +0 -104
- package/src/components/PrintSection/PrintDivider.tsx +0 -101
- package/src/components/PrintSection/PrintSection.tsx +0 -129
- package/src/components/PrintSection/PrintSectionContent.tsx +0 -75
- package/src/components/PrintSection/PrintSectionHeader.tsx +0 -97
- package/src/components/PrintSection/examples/PrintSectionShowcase.tsx +0 -258
- package/src/components/PrintSection/index.ts +0 -33
- package/src/components/PrintSection/types.ts +0 -155
- package/src/components/PrintText/PrintText.tsx +0 -116
- package/src/components/PrintText/index.ts +0 -16
- package/src/components/PrintText/types.ts +0 -24
- package/src/rbac/__tests__/integration.test.tsx +0 -218
- package/src/utils/print/PrintDataProcessor.ts +0 -390
- package/src/utils/print/examples/PrintUtilitiesShowcase.tsx +0 -397
- package/src/utils/print/index.ts +0 -29
- package/src/utils/print/types.ts +0 -196
- package/src/utils/print/usePrintOptimization.ts +0 -272
- /package/dist/{DataTable-7FMFXA7A.js.map → DataTable-4T627QFJ.js.map} +0 -0
- /package/dist/{api-H5A3H4IR.js.map → api-LUNF5O6M.js.map} +0 -0
- /package/dist/{appNameResolver-7GHF5ED2.js.map → appNameResolver-UURKN7NF.js.map} +0 -0
- /package/dist/{audit-BUW3LMJB.js.map → audit-6TOCAMKO.js.map} +0 -0
- /package/dist/{chunk-NRK4AIHQ.js.map → chunk-KBRACSJI.js.map} +0 -0
- /package/dist/{chunk-6MTY77WU.js.map → chunk-TNMXZLDR.js.map} +0 -0
|
@@ -116,26 +116,30 @@ export function useRBAC(pageId?: string): UserRBACContext {
|
|
|
116
116
|
setError(null);
|
|
117
117
|
|
|
118
118
|
try {
|
|
119
|
-
// First resolve app name to app_id
|
|
120
|
-
const { data: appData, error: appError } = await supabase
|
|
121
|
-
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
.eq('is_active', true)
|
|
125
|
-
.single();
|
|
119
|
+
// First resolve app name to app_id using secure RPC function
|
|
120
|
+
const { data: appData, error: appError } = await supabase.rpc('rbac_app_resolve', {
|
|
121
|
+
p_app_name: appName,
|
|
122
|
+
p_user_id: user.id
|
|
123
|
+
});
|
|
126
124
|
|
|
127
|
-
if (appError || !appData) {
|
|
125
|
+
if (appError || !appData || appData.length === 0) {
|
|
128
126
|
console.warn('App not found or inactive:', appName);
|
|
129
127
|
setIsLoading(false);
|
|
130
128
|
return;
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
const
|
|
131
|
+
const app = appData[0];
|
|
132
|
+
if (!app.has_access) {
|
|
133
|
+
console.warn('User does not have access to app:', appName);
|
|
134
|
+
setIsLoading(false);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { data, error: rpcError } = await supabase.rpc('rbac_permissions_get', {
|
|
134
139
|
p_user_id: user.id,
|
|
135
|
-
p_app_id:
|
|
140
|
+
p_app_id: app.app_id,
|
|
136
141
|
p_event_id: selectedEvent?.event_id || null,
|
|
137
|
-
p_organisation_id: selectedOrganisation?.id || null
|
|
138
|
-
p_page_id: pageId || null
|
|
142
|
+
p_organisation_id: selectedOrganisation?.id || null
|
|
139
143
|
});
|
|
140
144
|
|
|
141
145
|
if (rpcError) {
|
|
@@ -175,22 +179,26 @@ export function useRBAC(pageId?: string): UserRBACContext {
|
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
try {
|
|
178
|
-
// First resolve app name to app_id
|
|
179
|
-
const { data: appData, error: appError } = await supabase
|
|
180
|
-
|
|
181
|
-
.
|
|
182
|
-
|
|
183
|
-
.eq('is_active', true)
|
|
184
|
-
.single();
|
|
182
|
+
// First resolve app name to app_id using secure RPC function
|
|
183
|
+
const { data: appData, error: appError } = await supabase.rpc('rbac_app_resolve', {
|
|
184
|
+
p_app_name: appName,
|
|
185
|
+
p_user_id: user.id
|
|
186
|
+
});
|
|
185
187
|
|
|
186
|
-
if (appError || !appData) {
|
|
188
|
+
if (appError || !appData || appData.length === 0) {
|
|
187
189
|
console.warn('App not found or inactive:', appName);
|
|
188
190
|
return false;
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
const
|
|
193
|
+
const app = appData[0];
|
|
194
|
+
if (!app.has_access) {
|
|
195
|
+
console.warn('User does not have access to app:', appName);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const { data, error } = await supabase.rpc('rbac_page_access_check', {
|
|
192
200
|
p_user_id: user.id,
|
|
193
|
-
p_app_id:
|
|
201
|
+
p_app_id: app.app_id,
|
|
194
202
|
p_page_id: targetPageId || pageId || 'default',
|
|
195
203
|
p_operation: operation,
|
|
196
204
|
p_event_id: selectedEvent?.event_id,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview RBAC Permissions Tests
|
|
3
|
+
* @package @jmruthers/pace-core
|
|
4
|
+
* @module RBAC/Permissions/Tests
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*
|
|
7
|
+
* Tests for RBAC permission validation functions and database-driven permissions.
|
|
8
|
+
* Note: Hardcoded permission groups and role mappings have been removed for RBAC compliance.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect } from 'vitest';
|
|
12
|
+
import {
|
|
13
|
+
isValidPermission
|
|
14
|
+
} from './permissions';
|
|
15
|
+
import { Permission } from './types';
|
|
16
|
+
|
|
17
|
+
describe('RBAC Permissions', () => {
|
|
18
|
+
describe('Permission Validation Functions', () => {
|
|
19
|
+
it('validates correct CRUD permission format', () => {
|
|
20
|
+
expect(isValidPermission('read:users')).toBe(true);
|
|
21
|
+
expect(isValidPermission('create:organisation')).toBe(true);
|
|
22
|
+
expect(isValidPermission('update:event.content')).toBe(true);
|
|
23
|
+
expect(isValidPermission('delete:team.members')).toBe(true);
|
|
24
|
+
expect(isValidPermission('read:*')).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('rejects invalid permission format', () => {
|
|
28
|
+
expect(isValidPermission('invalid')).toBe(false);
|
|
29
|
+
expect(isValidPermission('READ:users')).toBe(false); // uppercase not allowed
|
|
30
|
+
expect(isValidPermission('read:')).toBe(false);
|
|
31
|
+
expect(isValidPermission(':users')).toBe(false);
|
|
32
|
+
expect(isValidPermission('read:users*')).toBe(false); // wildcard not at end
|
|
33
|
+
expect(isValidPermission('read:*users')).toBe(false); // wildcard not at end
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('rejects manage permission (not allowed in RBAC)', () => {
|
|
37
|
+
expect(isValidPermission('manage:users')).toBe(false);
|
|
38
|
+
expect(isValidPermission('manage:*')).toBe(false);
|
|
39
|
+
expect(isValidPermission('manage:organisation')).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('validates resource naming conventions', () => {
|
|
43
|
+
// Valid resource names
|
|
44
|
+
expect(isValidPermission('read:users')).toBe(true);
|
|
45
|
+
expect(isValidPermission('create:event.content')).toBe(true);
|
|
46
|
+
expect(isValidPermission('update:team.members')).toBe(true);
|
|
47
|
+
expect(isValidPermission('delete:organisation.settings')).toBe(true);
|
|
48
|
+
|
|
49
|
+
// Invalid resource names
|
|
50
|
+
expect(isValidPermission('read:Users')).toBe(false); // uppercase
|
|
51
|
+
expect(isValidPermission('read:user-settings')).toBe(false); // hyphen not allowed
|
|
52
|
+
expect(isValidPermission('read:user_settings')).toBe(false); // underscore not allowed
|
|
53
|
+
expect(isValidPermission('read:user.settings.')).toBe(false); // trailing dot
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('validates wildcard permissions', () => {
|
|
57
|
+
expect(isValidPermission('read:*')).toBe(true);
|
|
58
|
+
expect(isValidPermission('create:*')).toBe(true);
|
|
59
|
+
expect(isValidPermission('update:*')).toBe(true);
|
|
60
|
+
expect(isValidPermission('delete:*')).toBe(true);
|
|
61
|
+
|
|
62
|
+
// Invalid wildcard usage
|
|
63
|
+
expect(isValidPermission('*:users')).toBe(false);
|
|
64
|
+
expect(isValidPermission('read:*users')).toBe(false);
|
|
65
|
+
expect(isValidPermission('read:users*')).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('Type Safety', () => {
|
|
70
|
+
it('validates Permission type structure', () => {
|
|
71
|
+
const validPermissions: Permission[] = [
|
|
72
|
+
'read:users',
|
|
73
|
+
'create:organisation',
|
|
74
|
+
'update:event.content',
|
|
75
|
+
'delete:team.members',
|
|
76
|
+
'read:*'
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
validPermissions.forEach(permission => {
|
|
80
|
+
expect(typeof permission).toBe('string');
|
|
81
|
+
expect(isValidPermission(permission)).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('rejects invalid Permission types', () => {
|
|
86
|
+
const invalidPermissions = [
|
|
87
|
+
'manage:users',
|
|
88
|
+
'READ:users',
|
|
89
|
+
'read:',
|
|
90
|
+
':users',
|
|
91
|
+
'read:users*',
|
|
92
|
+
'read:*users',
|
|
93
|
+
'invalid'
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
invalidPermissions.forEach(permission => {
|
|
97
|
+
expect(isValidPermission(permission)).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('RBAC Compliance', () => {
|
|
103
|
+
it('only allows CRUD operations', () => {
|
|
104
|
+
const validOperations = ['read', 'create', 'update', 'delete'];
|
|
105
|
+
const invalidOperations = ['manage', 'admin', 'execute', 'view'];
|
|
106
|
+
|
|
107
|
+
validOperations.forEach(operation => {
|
|
108
|
+
expect(isValidPermission(`${operation}:users`)).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
invalidOperations.forEach(operation => {
|
|
112
|
+
expect(isValidPermission(`${operation}:users`)).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('enforces lowercase resource names', () => {
|
|
117
|
+
expect(isValidPermission('read:users')).toBe(true);
|
|
118
|
+
expect(isValidPermission('read:Users')).toBe(false);
|
|
119
|
+
expect(isValidPermission('read:USERS')).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('allows dot notation for hierarchical resources', () => {
|
|
123
|
+
expect(isValidPermission('read:event.content')).toBe(true);
|
|
124
|
+
expect(isValidPermission('update:team.members')).toBe(true);
|
|
125
|
+
expect(isValidPermission('create:organisation.settings')).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
package/src/rbac/permissions.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { Permission } from './types';
|
|
|
15
15
|
// ============================================================================
|
|
16
16
|
|
|
17
17
|
export const GLOBAL_PERMISSIONS = {
|
|
18
|
-
MANAGE_ALL: 'manage:*' as Permission,
|
|
19
18
|
READ_ALL: 'read:*' as Permission,
|
|
20
19
|
CREATE_ALL: 'create:*' as Permission,
|
|
21
20
|
UPDATE_ALL: 'update:*' as Permission,
|
|
@@ -28,33 +27,29 @@ export const GLOBAL_PERMISSIONS = {
|
|
|
28
27
|
|
|
29
28
|
export const ORGANISATION_PERMISSIONS = {
|
|
30
29
|
// Organisation management
|
|
31
|
-
MANAGE_ORGANISATION: 'manage:organisation' as Permission,
|
|
32
30
|
READ_ORGANISATION: 'read:organisation' as Permission,
|
|
33
31
|
UPDATE_ORGANISATION: 'update:organisation' as Permission,
|
|
32
|
+
DELETE_ORGANISATION: 'delete:organisation' as Permission,
|
|
34
33
|
|
|
35
34
|
// User management
|
|
36
|
-
MANAGE_USERS: 'manage:users' as Permission,
|
|
37
35
|
READ_USERS: 'read:users' as Permission,
|
|
38
36
|
CREATE_USERS: 'create:users' as Permission,
|
|
39
37
|
UPDATE_USERS: 'update:users' as Permission,
|
|
40
38
|
DELETE_USERS: 'delete:users' as Permission,
|
|
41
39
|
|
|
42
40
|
// Role management
|
|
43
|
-
MANAGE_ROLES: 'manage:roles' as Permission,
|
|
44
41
|
READ_ROLES: 'read:roles' as Permission,
|
|
45
42
|
CREATE_ROLES: 'create:roles' as Permission,
|
|
46
43
|
UPDATE_ROLES: 'update:roles' as Permission,
|
|
47
44
|
DELETE_ROLES: 'delete:roles' as Permission,
|
|
48
45
|
|
|
49
46
|
// Event management
|
|
50
|
-
MANAGE_EVENTS: 'manage:events' as Permission,
|
|
51
47
|
READ_EVENTS: 'read:events' as Permission,
|
|
52
48
|
CREATE_EVENTS: 'create:events' as Permission,
|
|
53
49
|
UPDATE_EVENTS: 'update:events' as Permission,
|
|
54
50
|
DELETE_EVENTS: 'delete:events' as Permission,
|
|
55
51
|
|
|
56
52
|
// App management
|
|
57
|
-
MANAGE_APPS: 'manage:apps' as Permission,
|
|
58
53
|
READ_APPS: 'read:apps' as Permission,
|
|
59
54
|
CREATE_APPS: 'create:apps' as Permission,
|
|
60
55
|
UPDATE_APPS: 'update:apps' as Permission,
|
|
@@ -67,40 +62,40 @@ export const ORGANISATION_PERMISSIONS = {
|
|
|
67
62
|
|
|
68
63
|
export const EVENT_APP_PERMISSIONS = {
|
|
69
64
|
// Event management
|
|
70
|
-
MANAGE_EVENT: 'manage:event' as Permission,
|
|
71
65
|
READ_EVENT: 'read:event' as Permission,
|
|
66
|
+
CREATE_EVENT: 'create:event' as Permission,
|
|
72
67
|
UPDATE_EVENT: 'update:event' as Permission,
|
|
68
|
+
DELETE_EVENT: 'delete:event' as Permission,
|
|
73
69
|
|
|
74
70
|
// App management
|
|
75
|
-
MANAGE_APP: 'manage:app' as Permission,
|
|
76
71
|
READ_APP: 'read:app' as Permission,
|
|
72
|
+
CREATE_APP: 'create:app' as Permission,
|
|
77
73
|
UPDATE_APP: 'update:app' as Permission,
|
|
74
|
+
DELETE_APP: 'delete:app' as Permission,
|
|
78
75
|
|
|
79
76
|
// Team management
|
|
80
|
-
MANAGE_TEAM: 'manage:team' as Permission,
|
|
81
77
|
READ_TEAM: 'read:team' as Permission,
|
|
82
78
|
CREATE_TEAM: 'create:team' as Permission,
|
|
83
79
|
UPDATE_TEAM: 'update:team' as Permission,
|
|
84
80
|
DELETE_TEAM: 'delete:team' as Permission,
|
|
85
81
|
|
|
86
82
|
// Team members
|
|
87
|
-
MANAGE_TEAM_MEMBERS: 'manage:team.members' as Permission,
|
|
88
83
|
READ_TEAM_MEMBERS: 'read:team.members' as Permission,
|
|
89
84
|
CREATE_TEAM_MEMBERS: 'create:team.members' as Permission,
|
|
90
85
|
UPDATE_TEAM_MEMBERS: 'update:team.members' as Permission,
|
|
91
86
|
DELETE_TEAM_MEMBERS: 'delete:team.members' as Permission,
|
|
92
87
|
|
|
93
88
|
// Event content
|
|
94
|
-
MANAGE_EVENT_CONTENT: 'manage:event.content' as Permission,
|
|
95
89
|
READ_EVENT_CONTENT: 'read:event.content' as Permission,
|
|
96
90
|
CREATE_EVENT_CONTENT: 'create:event.content' as Permission,
|
|
97
91
|
UPDATE_EVENT_CONTENT: 'update:event.content' as Permission,
|
|
98
92
|
DELETE_EVENT_CONTENT: 'delete:event.content' as Permission,
|
|
99
93
|
|
|
100
94
|
// Event settings
|
|
101
|
-
MANAGE_EVENT_SETTINGS: 'manage:event.settings' as Permission,
|
|
102
95
|
READ_EVENT_SETTINGS: 'read:event.settings' as Permission,
|
|
96
|
+
CREATE_EVENT_SETTINGS: 'create:event.settings' as Permission,
|
|
103
97
|
UPDATE_EVENT_SETTINGS: 'update:event.settings' as Permission,
|
|
98
|
+
DELETE_EVENT_SETTINGS: 'delete:event.settings' as Permission,
|
|
104
99
|
} as const;
|
|
105
100
|
|
|
106
101
|
// ============================================================================
|
|
@@ -110,131 +105,43 @@ export const EVENT_APP_PERMISSIONS = {
|
|
|
110
105
|
export const PAGE_PERMISSIONS = {
|
|
111
106
|
// General page access
|
|
112
107
|
READ_PAGE: 'read:page' as Permission,
|
|
113
|
-
|
|
108
|
+
CREATE_PAGE: 'create:page' as Permission,
|
|
109
|
+
UPDATE_PAGE: 'update:page' as Permission,
|
|
110
|
+
DELETE_PAGE: 'delete:page' as Permission,
|
|
114
111
|
|
|
115
112
|
// Admin pages
|
|
116
113
|
READ_ADMIN: 'read:admin' as Permission,
|
|
117
|
-
|
|
114
|
+
CREATE_ADMIN: 'create:admin' as Permission,
|
|
115
|
+
UPDATE_ADMIN: 'update:admin' as Permission,
|
|
116
|
+
DELETE_ADMIN: 'delete:admin' as Permission,
|
|
118
117
|
|
|
119
118
|
// Dashboard pages
|
|
120
119
|
READ_DASHBOARD: 'read:dashboard' as Permission,
|
|
121
|
-
|
|
120
|
+
CREATE_DASHBOARD: 'create:dashboard' as Permission,
|
|
121
|
+
UPDATE_DASHBOARD: 'update:dashboard' as Permission,
|
|
122
|
+
DELETE_DASHBOARD: 'delete:dashboard' as Permission,
|
|
122
123
|
|
|
123
124
|
// Settings pages
|
|
124
125
|
READ_SETTINGS: 'read:settings' as Permission,
|
|
125
|
-
|
|
126
|
+
CREATE_SETTINGS: 'create:settings' as Permission,
|
|
127
|
+
UPDATE_SETTINGS: 'update:settings' as Permission,
|
|
128
|
+
DELETE_SETTINGS: 'delete:settings' as Permission,
|
|
126
129
|
|
|
127
130
|
// Reports pages
|
|
128
131
|
READ_REPORTS: 'read:reports' as Permission,
|
|
129
|
-
|
|
132
|
+
CREATE_REPORTS: 'create:reports' as Permission,
|
|
133
|
+
UPDATE_REPORTS: 'update:reports' as Permission,
|
|
134
|
+
DELETE_REPORTS: 'delete:reports' as Permission,
|
|
130
135
|
} as const;
|
|
131
136
|
|
|
132
137
|
// ============================================================================
|
|
133
|
-
// PERMISSION GROUPS
|
|
138
|
+
// PERMISSION GROUPS - REMOVED
|
|
134
139
|
// ============================================================================
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
GLOBAL_PERMISSIONS.READ_ALL,
|
|
141
|
-
GLOBAL_PERMISSIONS.CREATE_ALL,
|
|
142
|
-
GLOBAL_PERMISSIONS.UPDATE_ALL,
|
|
143
|
-
GLOBAL_PERMISSIONS.DELETE_ALL,
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
// Organisation admin permissions
|
|
147
|
-
ORG_ADMIN: [
|
|
148
|
-
ORGANISATION_PERMISSIONS.MANAGE_ORGANISATION,
|
|
149
|
-
ORGANISATION_PERMISSIONS.READ_ORGANISATION,
|
|
150
|
-
ORGANISATION_PERMISSIONS.UPDATE_ORGANISATION,
|
|
151
|
-
ORGANISATION_PERMISSIONS.MANAGE_USERS,
|
|
152
|
-
ORGANISATION_PERMISSIONS.READ_USERS,
|
|
153
|
-
ORGANISATION_PERMISSIONS.CREATE_USERS,
|
|
154
|
-
ORGANISATION_PERMISSIONS.UPDATE_USERS,
|
|
155
|
-
ORGANISATION_PERMISSIONS.DELETE_USERS,
|
|
156
|
-
ORGANISATION_PERMISSIONS.MANAGE_ROLES,
|
|
157
|
-
ORGANISATION_PERMISSIONS.READ_ROLES,
|
|
158
|
-
ORGANISATION_PERMISSIONS.CREATE_ROLES,
|
|
159
|
-
ORGANISATION_PERMISSIONS.UPDATE_ROLES,
|
|
160
|
-
ORGANISATION_PERMISSIONS.DELETE_ROLES,
|
|
161
|
-
ORGANISATION_PERMISSIONS.MANAGE_EVENTS,
|
|
162
|
-
ORGANISATION_PERMISSIONS.READ_EVENTS,
|
|
163
|
-
ORGANISATION_PERMISSIONS.CREATE_EVENTS,
|
|
164
|
-
ORGANISATION_PERMISSIONS.UPDATE_EVENTS,
|
|
165
|
-
ORGANISATION_PERMISSIONS.DELETE_EVENTS,
|
|
166
|
-
ORGANISATION_PERMISSIONS.MANAGE_APPS,
|
|
167
|
-
ORGANISATION_PERMISSIONS.READ_APPS,
|
|
168
|
-
ORGANISATION_PERMISSIONS.CREATE_APPS,
|
|
169
|
-
ORGANISATION_PERMISSIONS.UPDATE_APPS,
|
|
170
|
-
ORGANISATION_PERMISSIONS.DELETE_APPS,
|
|
171
|
-
],
|
|
172
|
-
|
|
173
|
-
// Event admin permissions
|
|
174
|
-
EVENT_ADMIN: [
|
|
175
|
-
EVENT_APP_PERMISSIONS.MANAGE_EVENT,
|
|
176
|
-
EVENT_APP_PERMISSIONS.READ_EVENT,
|
|
177
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT,
|
|
178
|
-
EVENT_APP_PERMISSIONS.MANAGE_APP,
|
|
179
|
-
EVENT_APP_PERMISSIONS.READ_APP,
|
|
180
|
-
EVENT_APP_PERMISSIONS.UPDATE_APP,
|
|
181
|
-
EVENT_APP_PERMISSIONS.MANAGE_TEAM,
|
|
182
|
-
EVENT_APP_PERMISSIONS.READ_TEAM,
|
|
183
|
-
EVENT_APP_PERMISSIONS.CREATE_TEAM,
|
|
184
|
-
EVENT_APP_PERMISSIONS.UPDATE_TEAM,
|
|
185
|
-
EVENT_APP_PERMISSIONS.DELETE_TEAM,
|
|
186
|
-
EVENT_APP_PERMISSIONS.MANAGE_TEAM_MEMBERS,
|
|
187
|
-
EVENT_APP_PERMISSIONS.READ_TEAM_MEMBERS,
|
|
188
|
-
EVENT_APP_PERMISSIONS.CREATE_TEAM_MEMBERS,
|
|
189
|
-
EVENT_APP_PERMISSIONS.UPDATE_TEAM_MEMBERS,
|
|
190
|
-
EVENT_APP_PERMISSIONS.DELETE_TEAM_MEMBERS,
|
|
191
|
-
EVENT_APP_PERMISSIONS.MANAGE_EVENT_CONTENT,
|
|
192
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_CONTENT,
|
|
193
|
-
EVENT_APP_PERMISSIONS.CREATE_EVENT_CONTENT,
|
|
194
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT_CONTENT,
|
|
195
|
-
EVENT_APP_PERMISSIONS.DELETE_EVENT_CONTENT,
|
|
196
|
-
EVENT_APP_PERMISSIONS.MANAGE_EVENT_SETTINGS,
|
|
197
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_SETTINGS,
|
|
198
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT_SETTINGS,
|
|
199
|
-
],
|
|
200
|
-
|
|
201
|
-
// Planner permissions
|
|
202
|
-
PLANNER: [
|
|
203
|
-
EVENT_APP_PERMISSIONS.READ_EVENT,
|
|
204
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT,
|
|
205
|
-
EVENT_APP_PERMISSIONS.READ_APP,
|
|
206
|
-
EVENT_APP_PERMISSIONS.UPDATE_APP,
|
|
207
|
-
EVENT_APP_PERMISSIONS.READ_TEAM,
|
|
208
|
-
EVENT_APP_PERMISSIONS.CREATE_TEAM,
|
|
209
|
-
EVENT_APP_PERMISSIONS.UPDATE_TEAM,
|
|
210
|
-
EVENT_APP_PERMISSIONS.READ_TEAM_MEMBERS,
|
|
211
|
-
EVENT_APP_PERMISSIONS.CREATE_TEAM_MEMBERS,
|
|
212
|
-
EVENT_APP_PERMISSIONS.UPDATE_TEAM_MEMBERS,
|
|
213
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_CONTENT,
|
|
214
|
-
EVENT_APP_PERMISSIONS.CREATE_EVENT_CONTENT,
|
|
215
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT_CONTENT,
|
|
216
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_SETTINGS,
|
|
217
|
-
EVENT_APP_PERMISSIONS.UPDATE_EVENT_SETTINGS,
|
|
218
|
-
],
|
|
219
|
-
|
|
220
|
-
// Participant permissions
|
|
221
|
-
PARTICIPANT: [
|
|
222
|
-
EVENT_APP_PERMISSIONS.READ_EVENT,
|
|
223
|
-
EVENT_APP_PERMISSIONS.READ_APP,
|
|
224
|
-
EVENT_APP_PERMISSIONS.READ_TEAM,
|
|
225
|
-
EVENT_APP_PERMISSIONS.READ_TEAM_MEMBERS,
|
|
226
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_CONTENT,
|
|
227
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_SETTINGS,
|
|
228
|
-
],
|
|
229
|
-
|
|
230
|
-
// Viewer permissions
|
|
231
|
-
VIEWER: [
|
|
232
|
-
EVENT_APP_PERMISSIONS.READ_EVENT,
|
|
233
|
-
EVENT_APP_PERMISSIONS.READ_APP,
|
|
234
|
-
EVENT_APP_PERMISSIONS.READ_TEAM,
|
|
235
|
-
EVENT_APP_PERMISSIONS.READ_EVENT_CONTENT,
|
|
236
|
-
],
|
|
237
|
-
} as const;
|
|
140
|
+
// NOTE: Hardcoded permission groups have been removed to ensure RBAC compliance.
|
|
141
|
+
// Permissions must be queried from the rbac_page_permissions database table.
|
|
142
|
+
// This ensures organizations can customize their own page-level permissions.
|
|
143
|
+
// The permission string constants above can still be used for TypeScript
|
|
144
|
+
// type safety and autocomplete, but actual permission grants come from the database.
|
|
238
145
|
|
|
239
146
|
// ============================================================================
|
|
240
147
|
// PERMISSION VALIDATION
|
|
@@ -247,36 +154,44 @@ export const PERMISSION_GROUPS = {
|
|
|
247
154
|
* @returns True if valid, false otherwise
|
|
248
155
|
*/
|
|
249
156
|
export function isValidPermission(permission: string): permission is Permission {
|
|
250
|
-
// Allow wildcard only at the end:
|
|
157
|
+
// Allow wildcard only at the end: read:* or read:events
|
|
251
158
|
// But not: read:events* or read:*events
|
|
252
159
|
// Also reject uppercase operations and resource names
|
|
253
|
-
|
|
160
|
+
// NOTE: Only CRUD operations are allowed (read, create, update, delete)
|
|
161
|
+
// Resource names must be lowercase letters, numbers, and dots only
|
|
162
|
+
// Cannot start or end with dots, cannot have consecutive dots
|
|
163
|
+
const pattern = /^(read|create|update|delete):[a-z0-9]+(\.[a-z0-9]+)*$|^(read|create|update|delete):\*$/;
|
|
254
164
|
return pattern.test(permission);
|
|
255
165
|
}
|
|
256
166
|
|
|
257
167
|
/**
|
|
258
|
-
* Get all permissions for a role
|
|
168
|
+
* Get all permissions for a role - REMOVED
|
|
169
|
+
*
|
|
170
|
+
* @deprecated This function has been removed to ensure RBAC compliance.
|
|
171
|
+
* Permissions must be queried from the rbac_page_permissions database table,
|
|
172
|
+
* not hardcoded in application code. This allows organizations to customize
|
|
173
|
+
* their own page-level permissions as required by the RBAC specification.
|
|
174
|
+
*
|
|
175
|
+
* To get permissions for a role, query the database:
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const { data } = await supabase
|
|
178
|
+
* .from('rbac_page_permissions')
|
|
179
|
+
* .select('operation, allowed')
|
|
180
|
+
* .eq('role_name', roleName)
|
|
181
|
+
* .eq('organisation_id', organisationId)
|
|
182
|
+
* .eq('allowed', true);
|
|
183
|
+
* ```
|
|
259
184
|
*
|
|
260
185
|
* @param role - Role name
|
|
261
|
-
* @returns
|
|
186
|
+
* @returns Empty array (function deprecated)
|
|
262
187
|
*/
|
|
263
188
|
export function getPermissionsForRole(role: string): Permission[] {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return [...PERMISSION_GROUPS.EVENT_ADMIN];
|
|
271
|
-
case 'planner':
|
|
272
|
-
return [...PERMISSION_GROUPS.PLANNER];
|
|
273
|
-
case 'participant':
|
|
274
|
-
return [...PERMISSION_GROUPS.PARTICIPANT];
|
|
275
|
-
case 'viewer':
|
|
276
|
-
return [...PERMISSION_GROUPS.VIEWER];
|
|
277
|
-
default:
|
|
278
|
-
return [];
|
|
279
|
-
}
|
|
189
|
+
console.warn(
|
|
190
|
+
'[RBAC] getPermissionsForRole() is deprecated. ' +
|
|
191
|
+
'Permissions must be queried from rbac_page_permissions table. ' +
|
|
192
|
+
`Called with role: ${role}`
|
|
193
|
+
);
|
|
194
|
+
return [];
|
|
280
195
|
}
|
|
281
196
|
|
|
282
197
|
// ============================================================================
|
|
@@ -388,7 +388,7 @@ export function RBACProvider({
|
|
|
388
388
|
return;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
const { data, error } = await supabaseClient.rpc('
|
|
391
|
+
const { data, error } = await supabaseClient.rpc('rbac_permissions_get', {
|
|
392
392
|
p_user_id: user.id,
|
|
393
393
|
p_app_id: appData.id,
|
|
394
394
|
p_event_id: eventId || null,
|