@jmruthers/pace-core 0.5.189 → 0.5.191
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/core-usage-manifest.json +0 -4
- package/dist/{AuthService-B-cd2MA4.d.ts → AuthService-CbP_utw2.d.ts} +7 -3
- package/dist/{DataTable-IVYljGJ6.d.ts → DataTable-Be6dH_dR.d.ts} +1 -1
- package/dist/{DataTable-GUFUNZ3N.js → DataTable-WKRZD47S.js} +8 -8
- package/dist/{PublicPageProvider-B8HaLe69.d.ts → PublicPageProvider-ULXC_u6U.d.ts} +84 -25
- package/dist/{UnifiedAuthProvider-BG0AL5eE.d.ts → UnifiedAuthProvider-BYA9qB-o.d.ts} +4 -3
- package/dist/{UnifiedAuthProvider-643PUAIM.js → UnifiedAuthProvider-FTSG5XH7.js} +4 -2
- package/dist/{api-YP7XD5L6.js → api-IHKALJZD.js} +4 -2
- package/dist/{chunk-VGZZXKBR.js → chunk-6LTQQAT6.js} +351 -157
- package/dist/chunk-6LTQQAT6.js.map +1 -0
- package/dist/{chunk-MX64ZF6I.js → chunk-6TQDD426.js} +15 -15
- package/dist/chunk-6TQDD426.js.map +1 -0
- package/dist/{chunk-YHCN776L.js → chunk-G37KK66H.js} +2 -75
- package/dist/chunk-G37KK66H.js.map +1 -0
- package/dist/{chunk-THRPYOFK.js → chunk-HW3OVDUF.js} +5 -5
- package/dist/chunk-HW3OVDUF.js.map +1 -0
- package/dist/{chunk-F2IMUDXZ.js → chunk-I7PSE6JW.js} +75 -2
- package/dist/chunk-I7PSE6JW.js.map +1 -0
- package/dist/{chunk-IM4QE42D.js → chunk-LOMZXPSN.js} +141 -326
- package/dist/chunk-LOMZXPSN.js.map +1 -0
- package/dist/chunk-OETXORNB.js +614 -0
- package/dist/chunk-OETXORNB.js.map +1 -0
- package/dist/{chunk-HESYZWZW.js → chunk-QWWZ5CAQ.js} +2 -2
- package/dist/{chunk-HEHYGYOX.js → chunk-ROXMHMY2.js} +403 -46
- package/dist/chunk-ROXMHMY2.js.map +1 -0
- package/dist/{chunk-2UUZZJFT.js → chunk-ULHIJK66.js} +228 -177
- package/dist/{chunk-2UUZZJFT.js.map → chunk-ULHIJK66.js.map} +1 -1
- package/dist/{chunk-YGPFYGA6.js → chunk-VKB2CO4Z.js} +838 -503
- package/dist/chunk-VKB2CO4Z.js.map +1 -0
- package/dist/{chunk-3GOZZZYH.js → chunk-VRGWKHDB.js} +238 -301
- package/dist/chunk-VRGWKHDB.js.map +1 -0
- package/dist/{chunk-UCQSRW7Z.js → chunk-XNYQOL3Z.js} +431 -384
- package/dist/chunk-XNYQOL3Z.js.map +1 -0
- package/dist/{chunk-DDM4CCYT.js → chunk-XYXSXPUK.js} +79 -59
- package/dist/chunk-XYXSXPUK.js.map +1 -0
- package/dist/{chunk-SAUPYVLF.js → chunk-ZSAAAMVR.js} +1 -1
- package/dist/chunk-ZSAAAMVR.js.map +1 -0
- package/dist/components.d.ts +5 -6
- package/dist/components.js +19 -19
- package/dist/components.js.map +1 -1
- package/dist/{database.generated-DI89OQeI.d.ts → database.generated-CzIvgcPu.d.ts} +165 -201
- package/dist/eslint-rules/pace-core-compliance.cjs +0 -2
- package/dist/{file-reference-D037xOFK.d.ts → file-reference-BavO2eQj.d.ts} +13 -10
- package/dist/hooks.d.ts +20 -15
- package/dist/hooks.js +14 -8
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +17 -15
- package/dist/index.js +86 -81
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +3 -3
- package/dist/providers.js +3 -1
- package/dist/rbac/index.d.ts +77 -13
- package/dist/rbac/index.js +12 -9
- package/dist/{types-Bwgl--Xo.d.ts → types-CEpcvwwF.d.ts} +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.js +1 -1
- package/dist/{usePublicRouteParams-CTDELQ7H.d.ts → usePublicRouteParams-TZe0gy-4.d.ts} +17 -10
- package/dist/utils.d.ts +8 -8
- package/dist/utils.js +16 -16
- package/docs/README.md +2 -2
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +2 -2
- package/docs/api/classes/Logger.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +2 -2
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +2 -2
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +5 -5
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +2 -2
- package/docs/api/classes/SecureSupabaseClient.md +25 -20
- package/docs/api/classes/StorageUtils.md +7 -4
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/enums/LogLevel.md +1 -1
- package/docs/api/enums/RBACErrorCode.md +1 -1
- package/docs/api/enums/RPCFunction.md +1 -1
- package/docs/api/interfaces/AddressFieldProps.md +1 -1
- package/docs/api/interfaces/AddressFieldRef.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/AutocompleteOptions.md +1 -1
- package/docs/api/interfaces/AvatarProps.md +1 -1
- package/docs/api/interfaces/BadgeProps.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CalendarProps.md +20 -6
- 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/ComplianceResult.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +9 -9
- package/docs/api/interfaces/DataRecord.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/DatabaseComplianceResult.md +1 -1
- package/docs/api/interfaces/DatabaseIssue.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventAppRoleData.md +1 -1
- package/docs/api/interfaces/ExportColumn.md +1 -1
- package/docs/api/interfaces/ExportOptions.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +62 -16
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +2 -2
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +26 -12
- package/docs/api/interfaces/FileUploadProps.md +30 -19
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/FormFieldProps.md +1 -1
- package/docs/api/interfaces/FormProps.md +1 -1
- package/docs/api/interfaces/GrantEventAppRoleParams.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/LoggerConfig.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +10 -10
- package/docs/api/interfaces/NavigationContextType.md +9 -9
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +7 -7
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +8 -8
- package/docs/api/interfaces/PagePermissionContextType.md +8 -8
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +7 -7
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/ParsedAddress.md +2 -2
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/ProgressProps.md +3 -11
- package/docs/api/interfaces/ProtectedRouteProps.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/QuickFix.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
- package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
- package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +2 -2
- package/docs/api/interfaces/RBACContext.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPerformanceMetrics.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckResult.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
- package/docs/api/interfaces/RBACResult.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantParams.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeParams.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateParams.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
- package/docs/api/interfaces/RBACRolesListParams.md +1 -1
- package/docs/api/interfaces/RBACRolesListResult.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
- package/docs/api/interfaces/ResourcePermissions.md +1 -1
- package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +8 -8
- package/docs/api/interfaces/RoleBasedRouterProps.md +10 -10
- package/docs/api/interfaces/RoleManagementResult.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +10 -10
- package/docs/api/interfaces/RouteConfig.md +10 -10
- package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +9 -9
- package/docs/api/interfaces/SecureDataProviderProps.md +8 -8
- package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/SetupIssue.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +4 -4
- package/docs/api/interfaces/StorageFileInfo.md +7 -7
- package/docs/api/interfaces/StorageFileMetadata.md +25 -14
- package/docs/api/interfaces/StorageListOptions.md +22 -9
- package/docs/api/interfaces/StorageListResult.md +4 -4
- package/docs/api/interfaces/StorageUploadOptions.md +21 -8
- package/docs/api/interfaces/StorageUploadResult.md +6 -6
- package/docs/api/interfaces/StorageUrlOptions.md +19 -6
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/TabsContentProps.md +1 -1
- package/docs/api/interfaces/TabsListProps.md +1 -1
- package/docs/api/interfaces/TabsProps.md +1 -1
- package/docs/api/interfaces/TabsTriggerProps.md +1 -1
- package/docs/api/interfaces/TextareaProps.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 +53 -53
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
- package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
- package/docs/api/interfaces/UseFormDialogReturn.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 +2 -2
- 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/UsePublicFileDisplayOptions.md +2 -2
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +5 -5
- package/docs/api/interfaces/UseResolvedScopeReturn.md +4 -4
- package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +165 -106
- package/docs/api-reference/components.md +15 -7
- package/docs/api-reference/providers.md +2 -2
- package/docs/api-reference/rpc-functions.md +1 -0
- package/docs/best-practices/README.md +1 -1
- package/docs/best-practices/deployment.md +8 -8
- package/docs/getting-started/examples/README.md +2 -2
- package/docs/getting-started/installation-guide.md +4 -4
- package/docs/getting-started/quick-start.md +3 -3
- package/docs/migration/MIGRATION_GUIDE.md +3 -3
- package/docs/migration/README.md +18 -0
- package/docs/migration/database-changes-december-2025.md +767 -0
- package/docs/migration/person-scoped-profiles-migration-guide.md +472 -0
- package/docs/rbac/compliance/compliance-guide.md +2 -2
- package/docs/rbac/event-based-apps.md +2 -2
- package/docs/rbac/getting-started.md +2 -2
- package/docs/rbac/quick-start.md +2 -2
- package/docs/security/README.md +4 -4
- package/docs/standards/07-rbac-and-rls-standard.md +430 -7
- package/docs/troubleshooting/README.md +2 -2
- package/docs/troubleshooting/migration.md +3 -3
- package/package.json +1 -3
- package/scripts/check-pace-core-compliance.cjs +1 -1
- package/scripts/check-pace-core-compliance.js +1 -1
- package/src/__tests__/fixtures/supabase.ts +301 -0
- package/src/__tests__/public-recipe-view.test.ts +19 -19
- package/src/__tests__/rls-policies.test.ts +210 -74
- package/src/components/AddressField/AddressField.test.tsx +42 -0
- package/src/components/AddressField/AddressField.tsx +71 -60
- package/src/components/AddressField/README.md +7 -6
- package/src/components/Alert/Alert.test.tsx +50 -10
- package/src/components/Alert/Alert.tsx +5 -3
- package/src/components/Avatar/Avatar.test.tsx +95 -43
- package/src/components/Avatar/Avatar.tsx +16 -16
- package/src/components/Button/Button.test.tsx +2 -1
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/Calendar/Calendar.test.tsx +53 -37
- package/src/components/Calendar/Calendar.tsx +409 -82
- package/src/components/Card/Card.test.tsx +7 -4
- package/src/components/Card/Card.tsx +3 -6
- package/src/components/Checkbox/Checkbox.tsx +2 -2
- package/src/components/DataTable/components/ActionButtons.tsx +5 -5
- package/src/components/DataTable/components/BulkOperationsDropdown.tsx +2 -2
- package/src/components/DataTable/components/ColumnFilter.tsx +1 -1
- package/src/components/DataTable/components/ColumnVisibilityDropdown.tsx +3 -3
- package/src/components/DataTable/components/DataTableBody.tsx +12 -12
- package/src/components/DataTable/components/DataTableCore.tsx +3 -3
- package/src/components/DataTable/components/DataTableToolbar.tsx +5 -5
- package/src/components/DataTable/components/DraggableColumnHeader.tsx +3 -3
- package/src/components/DataTable/components/EditableRow.tsx +2 -2
- package/src/components/DataTable/components/EmptyState.tsx +3 -3
- package/src/components/DataTable/components/GroupHeader.tsx +2 -2
- package/src/components/DataTable/components/GroupingDropdown.tsx +1 -1
- package/src/components/DataTable/components/ImportModal.tsx +4 -4
- package/src/components/DataTable/components/LoadingState.tsx +1 -1
- package/src/components/DataTable/components/PaginationControls.tsx +11 -11
- package/src/components/DataTable/components/UnifiedTableBody.tsx +9 -9
- package/src/components/DataTable/components/ViewRowModal.tsx +2 -2
- package/src/components/DataTable/components/__tests__/AccessDeniedPage.test.tsx +11 -37
- package/src/components/DataTable/components/__tests__/DataTableToolbar.test.tsx +157 -0
- package/src/components/DataTable/components/__tests__/LoadingState.test.tsx +2 -1
- package/src/components/DataTable/components/__tests__/VirtualizedDataTable.test.tsx +128 -0
- package/src/components/DataTable/core/__tests__/ActionManager.test.ts +19 -0
- package/src/components/DataTable/core/__tests__/ColumnFactory.test.ts +51 -0
- package/src/components/DataTable/core/__tests__/ColumnManager.test.ts +84 -0
- package/src/components/DataTable/core/__tests__/DataManager.test.ts +14 -0
- package/src/components/DataTable/core/__tests__/DataTableContext.test.tsx +136 -0
- package/src/components/DataTable/core/__tests__/LocalDataAdapter.test.ts +16 -0
- package/src/components/DataTable/core/__tests__/PluginRegistry.test.ts +18 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +28 -7
- package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +30 -1
- package/src/components/DataTable/utils/hierarchicalUtils.ts +38 -10
- package/src/components/DatePickerWithTimezone/DatePickerWithTimezone.test.tsx +8 -3
- package/src/components/DatePickerWithTimezone/DatePickerWithTimezone.tsx +4 -4
- package/src/components/Dialog/Dialog.tsx +2 -2
- package/src/components/EventSelector/EventSelector.tsx +7 -7
- package/src/components/FileDisplay/FileDisplay.tsx +291 -179
- package/src/components/FileUpload/FileUpload.tsx +7 -4
- package/src/components/Header/Header.test.tsx +28 -0
- package/src/components/Header/Header.tsx +22 -9
- package/src/components/InactivityWarningModal/InactivityWarningModal.tsx +2 -2
- package/src/components/LoadingSpinner/LoadingSpinner.test.tsx +19 -14
- package/src/components/LoadingSpinner/LoadingSpinner.tsx +5 -5
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +127 -1
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +42 -22
- package/src/components/PaceAppLayout/PaceAppLayout.integration.test.tsx +4 -0
- package/src/components/PaceAppLayout/PaceAppLayout.performance.test.tsx +3 -0
- package/src/components/PaceAppLayout/PaceAppLayout.security.test.tsx +3 -0
- package/src/components/PaceAppLayout/PaceAppLayout.test.tsx +16 -6
- package/src/components/PaceAppLayout/PaceAppLayout.tsx +37 -3
- package/src/components/PaceAppLayout/test-setup.tsx +1 -0
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +66 -45
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +6 -4
- package/src/components/Progress/Progress.test.tsx +18 -19
- package/src/components/Progress/Progress.tsx +31 -32
- package/src/components/PublicLayout/PublicLayout.test.tsx +6 -6
- package/src/components/PublicLayout/PublicPageProvider.tsx +5 -3
- package/src/components/Select/Select.test.tsx +4 -1
- package/src/components/Select/Select.tsx +65 -20
- package/src/components/Switch/Switch.test.tsx +2 -1
- package/src/components/Switch/Switch.tsx +1 -1
- package/src/components/Toast/Toast.tsx +1 -1
- package/src/components/Tooltip/Tooltip.test.tsx +8 -2
- package/src/components/UserMenu/UserMenu.tsx +3 -3
- package/src/eslint-rules/pace-core-compliance.cjs +0 -2
- package/src/eslint-rules/pace-core-compliance.js +0 -2
- package/src/hooks/__tests__/hooks.integration.test.tsx +4 -1
- package/src/hooks/__tests__/useAppConfig.unit.test.ts +76 -5
- package/src/hooks/__tests__/useDataTableState.test.ts +76 -0
- package/src/hooks/__tests__/useFileUrl.unit.test.ts +25 -69
- package/src/hooks/__tests__/useFileUrlCache.test.ts +129 -0
- package/src/hooks/__tests__/usePreventTabReload.test.ts +88 -0
- package/src/hooks/__tests__/usePublicEvent.simple.test.ts +1 -1
- package/src/hooks/__tests__/usePublicEvent.test.ts +608 -0
- package/src/hooks/__tests__/useQueryCache.test.ts +144 -0
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +67 -24
- package/src/hooks/index.ts +1 -1
- package/src/hooks/public/usePublicEvent.ts +10 -10
- package/src/hooks/public/usePublicFileDisplay.ts +173 -87
- package/src/hooks/useAppConfig.ts +24 -5
- package/src/hooks/useFileDisplay.ts +298 -36
- package/src/hooks/useFileReference.ts +56 -11
- package/src/hooks/useFileUrl.ts +1 -1
- package/src/hooks/useInactivityTracker.ts +16 -7
- package/src/hooks/usePermissionCache.test.ts +85 -8
- package/src/hooks/useQueryCache.ts +27 -6
- package/src/hooks/useSecureDataAccess.test.ts +87 -42
- package/src/hooks/useSecureDataAccess.ts +95 -48
- package/src/providers/__tests__/OrganisationProvider.test.tsx +27 -21
- package/src/providers/services/EventServiceProvider.tsx +37 -17
- package/src/providers/services/InactivityServiceProvider.tsx +4 -4
- package/src/providers/services/OrganisationServiceProvider.tsx +8 -1
- package/src/providers/services/UnifiedAuthProvider.tsx +115 -29
- package/src/rbac/__tests__/auth-rbac.e2e.test.tsx +451 -0
- package/src/rbac/__tests__/engine.comprehensive.test.ts +12 -0
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +8 -0
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +4 -0
- package/src/rbac/api.ts +240 -36
- package/src/rbac/cache-invalidation.ts +21 -7
- package/src/rbac/compliance/quick-fix-suggestions.ts +1 -1
- package/src/rbac/components/NavigationGuard.tsx +23 -63
- package/src/rbac/components/NavigationProvider.test.tsx +52 -23
- package/src/rbac/components/NavigationProvider.tsx +13 -11
- package/src/rbac/components/PagePermissionGuard.tsx +77 -203
- package/src/rbac/components/PagePermissionProvider.tsx +13 -11
- package/src/rbac/components/PermissionEnforcer.tsx +24 -62
- package/src/rbac/components/RoleBasedRouter.tsx +14 -12
- package/src/rbac/components/SecureDataProvider.tsx +13 -11
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +104 -41
- package/src/rbac/components/__tests__/NavigationProvider.test.tsx +49 -12
- package/src/rbac/components/__tests__/PagePermissionGuard.race-condition.test.tsx +22 -1
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +161 -82
- package/src/rbac/components/__tests__/PagePermissionGuard.verification.test.tsx +22 -1
- package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +77 -30
- package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +39 -5
- package/src/rbac/components/__tests__/SecureDataProvider.test.tsx +47 -4
- package/src/rbac/engine.ts +4 -2
- package/src/rbac/hooks/__tests__/useSecureSupabase.test.ts +144 -52
- package/src/rbac/hooks/index.ts +3 -0
- package/src/rbac/hooks/useCan.test.ts +101 -53
- package/src/rbac/hooks/usePermissions.ts +108 -41
- package/src/rbac/hooks/useRBAC.test.ts +11 -3
- package/src/rbac/hooks/useRBAC.ts +83 -40
- package/src/rbac/hooks/useResolvedScope.test.ts +189 -63
- package/src/rbac/hooks/useResolvedScope.ts +128 -70
- package/src/rbac/hooks/useSecureSupabase.ts +36 -19
- package/src/rbac/hooks/useSuperAdminBypass.ts +126 -0
- package/src/rbac/request-deduplication.ts +1 -1
- package/src/rbac/secureClient.ts +72 -12
- package/src/rbac/security.ts +29 -23
- package/src/rbac/types.ts +10 -0
- package/src/rbac/utils/__tests__/contextValidator.test.ts +150 -0
- package/src/rbac/utils/__tests__/deep-equal.test.ts +53 -0
- package/src/rbac/utils/__tests__/eventContext.test.ts +8 -3
- package/src/rbac/utils/__tests__/eventContext.unit.test.ts +74 -12
- package/src/rbac/utils/contextValidator.ts +288 -0
- package/src/rbac/utils/eventContext.ts +52 -3
- package/src/services/AuthService.ts +37 -8
- package/src/services/EventService.ts +165 -21
- package/src/services/OrganisationService.ts +125 -137
- package/src/services/__tests__/EventService.test.ts +26 -21
- package/src/services/__tests__/OrganisationService.pagination.test.ts +34 -8
- package/src/services/__tests__/OrganisationService.test.ts +218 -86
- package/src/types/database.generated.ts +166 -201
- package/src/types/file-reference.ts +13 -10
- package/src/types/supabase.ts +2 -2
- package/src/utils/__tests__/secureDataAccess.unit.test.ts +3 -2
- package/src/utils/app/appNameResolver.test.ts +346 -73
- package/src/utils/context/superAdminOverride.ts +58 -0
- package/src/utils/file-reference/index.ts +65 -37
- package/src/utils/google-places/googlePlacesUtils.test.ts +98 -0
- package/src/utils/google-places/googlePlacesUtils.ts +1 -1
- package/src/utils/google-places/loadGoogleMapsScript.test.ts +83 -0
- package/src/utils/google-places/types.ts +1 -1
- package/src/utils/request-deduplication.ts +4 -4
- package/src/utils/security/secureDataAccess.test.ts +1 -1
- package/src/utils/security/secureDataAccess.ts +7 -4
- package/src/utils/storage/README.md +1 -1
- package/src/utils/storage/helpers.test.ts +1 -1
- package/src/utils/storage/helpers.ts +38 -19
- package/src/utils/storage/types.ts +15 -8
- package/src/utils/validation/__tests__/csrf.test.ts +105 -0
- package/src/utils/validation/__tests__/sqlInjectionProtection.test.ts +92 -0
- package/src/vite-env.d.ts +2 -2
- package/dist/chunk-3GOZZZYH.js.map +0 -1
- package/dist/chunk-DDM4CCYT.js.map +0 -1
- package/dist/chunk-E7UAOUMY.js +0 -75
- package/dist/chunk-E7UAOUMY.js.map +0 -1
- package/dist/chunk-F2IMUDXZ.js.map +0 -1
- package/dist/chunk-HEHYGYOX.js.map +0 -1
- package/dist/chunk-IM4QE42D.js.map +0 -1
- package/dist/chunk-MX64ZF6I.js.map +0 -1
- package/dist/chunk-SAUPYVLF.js.map +0 -1
- package/dist/chunk-THRPYOFK.js.map +0 -1
- package/dist/chunk-UCQSRW7Z.js.map +0 -1
- package/dist/chunk-VGZZXKBR.js.map +0 -1
- package/dist/chunk-YGPFYGA6.js.map +0 -1
- package/dist/chunk-YHCN776L.js.map +0 -1
- /package/dist/{DataTable-GUFUNZ3N.js.map → DataTable-WKRZD47S.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-643PUAIM.js.map → UnifiedAuthProvider-FTSG5XH7.js.map} +0 -0
- /package/dist/{api-YP7XD5L6.js.map → api-IHKALJZD.js.map} +0 -0
- /package/dist/{chunk-HESYZWZW.js.map → chunk-QWWZ5CAQ.js.map} +0 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEventService,
|
|
3
|
+
useUnifiedAuth
|
|
4
|
+
} from "./chunk-6LTQQAT6.js";
|
|
5
|
+
import {
|
|
6
|
+
ContextValidator,
|
|
7
|
+
isSuperAdmin
|
|
8
|
+
} from "./chunk-ROXMHMY2.js";
|
|
9
|
+
import {
|
|
10
|
+
getCurrentAppName,
|
|
11
|
+
performanceBudgetMonitor
|
|
12
|
+
} from "./chunk-I7PSE6JW.js";
|
|
13
|
+
import {
|
|
14
|
+
createLogger,
|
|
15
|
+
logger
|
|
16
|
+
} from "./chunk-PWLANIRT.js";
|
|
17
|
+
|
|
18
|
+
// src/hooks/useEvents.ts
|
|
19
|
+
import { useMemo, useRef } from "react";
|
|
20
|
+
function useEvents() {
|
|
21
|
+
const eventService = useEventService();
|
|
22
|
+
const rawEvents = eventService.getEvents();
|
|
23
|
+
const selectedEvent = eventService.getSelectedEvent();
|
|
24
|
+
const isLoading = eventService.isLoading();
|
|
25
|
+
const error = eventService.getError();
|
|
26
|
+
const prevEventsRef = useRef([]);
|
|
27
|
+
const prevEventsIdsRef = useRef("");
|
|
28
|
+
const currentEventsIds = rawEvents.map((e) => e.event_id || e.id).join(",");
|
|
29
|
+
const eventsChanged = currentEventsIds !== prevEventsIdsRef.current;
|
|
30
|
+
if (eventsChanged) {
|
|
31
|
+
prevEventsRef.current = rawEvents;
|
|
32
|
+
prevEventsIdsRef.current = currentEventsIds;
|
|
33
|
+
}
|
|
34
|
+
const events = useMemo(() => {
|
|
35
|
+
return prevEventsRef.current;
|
|
36
|
+
}, [currentEventsIds]);
|
|
37
|
+
const setSelectedEventCallback = useMemo(
|
|
38
|
+
() => (event) => eventService.setSelectedEvent(event),
|
|
39
|
+
[eventService]
|
|
40
|
+
);
|
|
41
|
+
const refreshEventsCallback = useMemo(
|
|
42
|
+
() => () => eventService.refreshEvents(),
|
|
43
|
+
[eventService]
|
|
44
|
+
);
|
|
45
|
+
const clearEventSelectionCallback = useMemo(
|
|
46
|
+
() => () => eventService.clearEventSelection(),
|
|
47
|
+
[eventService]
|
|
48
|
+
);
|
|
49
|
+
return useMemo(() => ({
|
|
50
|
+
events,
|
|
51
|
+
selectedEvent,
|
|
52
|
+
isLoading,
|
|
53
|
+
error,
|
|
54
|
+
setSelectedEvent: setSelectedEventCallback,
|
|
55
|
+
refreshEvents: refreshEventsCallback,
|
|
56
|
+
clearEventSelection: clearEventSelectionCallback
|
|
57
|
+
}), [events, selectedEvent?.event_id, isLoading, error?.message, setSelectedEventCallback, refreshEventsCallback, clearEventSelectionCallback]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/rbac/hooks/useResolvedScope.ts
|
|
61
|
+
import { useEffect, useState, useRef as useRef2, useMemo as useMemo2 } from "react";
|
|
62
|
+
var log = createLogger("useResolvedScope");
|
|
63
|
+
var appConfigCache = /* @__PURE__ */ new Map();
|
|
64
|
+
var CACHE_TTL = 5 * 60 * 1e3;
|
|
65
|
+
function useResolvedScope({
|
|
66
|
+
supabase,
|
|
67
|
+
selectedOrganisationId,
|
|
68
|
+
selectedEventId
|
|
69
|
+
}) {
|
|
70
|
+
const [resolvedScope, setResolvedScope] = useState(null);
|
|
71
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
72
|
+
const [error, setError] = useState(null);
|
|
73
|
+
const stableScopeRef = useRef2({
|
|
74
|
+
organisationId: "",
|
|
75
|
+
appId: "",
|
|
76
|
+
eventId: void 0
|
|
77
|
+
});
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (resolvedScope) {
|
|
80
|
+
const newScope = {
|
|
81
|
+
organisationId: resolvedScope.organisationId || "",
|
|
82
|
+
appId: resolvedScope.appId || "",
|
|
83
|
+
eventId: resolvedScope.eventId
|
|
84
|
+
};
|
|
85
|
+
if (stableScopeRef.current.organisationId !== newScope.organisationId || stableScopeRef.current.eventId !== newScope.eventId || stableScopeRef.current.appId !== newScope.appId) {
|
|
86
|
+
stableScopeRef.current = {
|
|
87
|
+
organisationId: newScope.organisationId,
|
|
88
|
+
appId: newScope.appId,
|
|
89
|
+
eventId: newScope.eventId
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
stableScopeRef.current = { organisationId: "", appId: "", eventId: void 0 };
|
|
94
|
+
}
|
|
95
|
+
}, [resolvedScope]);
|
|
96
|
+
const appName = getCurrentAppName();
|
|
97
|
+
const stableScope = stableScopeRef.current;
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
let cancelled = false;
|
|
100
|
+
const resolveScope = async () => {
|
|
101
|
+
if (!supabase && !selectedOrganisationId && !selectedEventId) {
|
|
102
|
+
if (!cancelled) {
|
|
103
|
+
setResolvedScope(null);
|
|
104
|
+
setIsLoading(false);
|
|
105
|
+
setError(null);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
setIsLoading(true);
|
|
110
|
+
setError(null);
|
|
111
|
+
try {
|
|
112
|
+
const appName2 = getCurrentAppName();
|
|
113
|
+
let appId = void 0;
|
|
114
|
+
let appConfig = null;
|
|
115
|
+
if (supabase && appName2) {
|
|
116
|
+
try {
|
|
117
|
+
const cached = appConfigCache.get(appName2);
|
|
118
|
+
const now = Date.now();
|
|
119
|
+
if (cached && now - cached.timestamp < CACHE_TTL) {
|
|
120
|
+
appId = cached.appId;
|
|
121
|
+
appConfig = cached.appConfig;
|
|
122
|
+
} else {
|
|
123
|
+
const { data: app, error: error2 } = await supabase.from("rbac_apps").select("id, name, requires_event, is_active").eq("name", appName2).eq("is_active", true).single();
|
|
124
|
+
if (error2) {
|
|
125
|
+
const { data: inactiveApp } = await supabase.from("rbac_apps").select("id, name, is_active").eq("name", appName2).single();
|
|
126
|
+
if (inactiveApp) {
|
|
127
|
+
log.error(`App "${appName2}" exists but is inactive (is_active: ${inactiveApp.is_active})`);
|
|
128
|
+
appId = void 0;
|
|
129
|
+
} else {
|
|
130
|
+
log.error(`App "${appName2}" not found in rbac_apps table`);
|
|
131
|
+
appId = void 0;
|
|
132
|
+
}
|
|
133
|
+
} else if (app) {
|
|
134
|
+
appId = app.id;
|
|
135
|
+
appConfig = { requires_event: app.requires_event ?? false };
|
|
136
|
+
appConfigCache.set(appName2, { appId, appConfig, timestamp: now });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} catch (error2) {
|
|
140
|
+
log.error("Unexpected error resolving app config:", error2);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const initialScope = {
|
|
144
|
+
organisationId: appConfig?.requires_event ? void 0 : selectedOrganisationId || void 0,
|
|
145
|
+
eventId: selectedEventId || void 0,
|
|
146
|
+
appId
|
|
147
|
+
};
|
|
148
|
+
const validation = await ContextValidator.resolveRequiredContext(
|
|
149
|
+
initialScope,
|
|
150
|
+
appConfig,
|
|
151
|
+
appName2 || void 0,
|
|
152
|
+
supabase
|
|
153
|
+
);
|
|
154
|
+
if (!validation.isValid) {
|
|
155
|
+
if (appName2 === "PORTAL" || appName2 === "ADMIN") {
|
|
156
|
+
if (!cancelled) {
|
|
157
|
+
const optionalContextScope = {
|
|
158
|
+
organisationId: void 0,
|
|
159
|
+
eventId: void 0,
|
|
160
|
+
appId: appId || void 0
|
|
161
|
+
// appId might be undefined if query failed, that's OK
|
|
162
|
+
};
|
|
163
|
+
setResolvedScope(optionalContextScope);
|
|
164
|
+
setError(null);
|
|
165
|
+
setIsLoading(false);
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (appConfig?.requires_event && selectedEventId) {
|
|
170
|
+
if (!cancelled) {
|
|
171
|
+
const eventScope = {
|
|
172
|
+
organisationId: void 0,
|
|
173
|
+
// Will be derived from event during permission check
|
|
174
|
+
eventId: selectedEventId,
|
|
175
|
+
appId: appId || void 0
|
|
176
|
+
};
|
|
177
|
+
setResolvedScope(eventScope);
|
|
178
|
+
setError(null);
|
|
179
|
+
setIsLoading(false);
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!cancelled) {
|
|
184
|
+
setResolvedScope(null);
|
|
185
|
+
setError(validation.error || new Error("Context validation failed"));
|
|
186
|
+
setIsLoading(false);
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (!cancelled) {
|
|
191
|
+
setResolvedScope(validation.resolvedScope);
|
|
192
|
+
setError(null);
|
|
193
|
+
setIsLoading(false);
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (!cancelled) {
|
|
197
|
+
setError(err);
|
|
198
|
+
setIsLoading(false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
resolveScope();
|
|
203
|
+
return () => {
|
|
204
|
+
cancelled = true;
|
|
205
|
+
};
|
|
206
|
+
}, [selectedOrganisationId, selectedEventId, supabase]);
|
|
207
|
+
const allowsOptionalContexts = appName === "PORTAL" || appName === "ADMIN";
|
|
208
|
+
const hasValidScope = allowsOptionalContexts ? true : stableScope.appId || stableScope.organisationId;
|
|
209
|
+
const finalScope = useMemo2(() => {
|
|
210
|
+
if (!hasValidScope) {
|
|
211
|
+
return allowsOptionalContexts ? {} : null;
|
|
212
|
+
}
|
|
213
|
+
const scope = {};
|
|
214
|
+
if (stableScope.organisationId) {
|
|
215
|
+
scope.organisationId = stableScope.organisationId;
|
|
216
|
+
}
|
|
217
|
+
if (stableScope.eventId) {
|
|
218
|
+
scope.eventId = stableScope.eventId;
|
|
219
|
+
}
|
|
220
|
+
if (stableScope.appId) {
|
|
221
|
+
scope.appId = stableScope.appId;
|
|
222
|
+
}
|
|
223
|
+
return scope;
|
|
224
|
+
}, [hasValidScope, allowsOptionalContexts, stableScope.organisationId, stableScope.eventId, stableScope.appId]);
|
|
225
|
+
return {
|
|
226
|
+
resolvedScope: finalScope,
|
|
227
|
+
isLoading,
|
|
228
|
+
error
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/components/ErrorBoundary/ErrorBoundary.tsx
|
|
233
|
+
import { Component } from "react";
|
|
234
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
235
|
+
var ErrorBoundary = class extends Component {
|
|
236
|
+
constructor(props) {
|
|
237
|
+
super(props);
|
|
238
|
+
this.retryTimeoutId = null;
|
|
239
|
+
this.reportError = (errorId, componentName) => {
|
|
240
|
+
if (import.meta.env.MODE === "production") {
|
|
241
|
+
logger.warn("ErrorBoundary", "Error reporting would be triggered in production:", { errorId, componentName });
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
this.handleRetry = () => {
|
|
245
|
+
const { maxRetries = 3 } = this.props;
|
|
246
|
+
const { retryCount } = this.state;
|
|
247
|
+
if (retryCount < maxRetries) {
|
|
248
|
+
logger.debug("ErrorBoundary", `Retrying component render (attempt ${retryCount + 1}/${maxRetries})`);
|
|
249
|
+
this.setState((prevState) => ({
|
|
250
|
+
hasError: false,
|
|
251
|
+
error: void 0,
|
|
252
|
+
errorInfo: void 0,
|
|
253
|
+
errorId: void 0,
|
|
254
|
+
retryCount: prevState.retryCount + 1
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
this.state = {
|
|
259
|
+
hasError: false,
|
|
260
|
+
retryCount: 0
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
static getDerivedStateFromError(error) {
|
|
264
|
+
const errorId = `error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
265
|
+
return {
|
|
266
|
+
hasError: true,
|
|
267
|
+
error,
|
|
268
|
+
errorId
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
componentDidCatch(error, errorInfo) {
|
|
272
|
+
const { componentName = "Unknown Component", onError, enableReporting = true } = this.props;
|
|
273
|
+
const errorId = this.state.errorId;
|
|
274
|
+
this.setState({ errorInfo });
|
|
275
|
+
logger.error("ErrorBoundary", `[${componentName}] Caught error ${errorId}:`, error, errorInfo);
|
|
276
|
+
performanceBudgetMonitor.measure("ERROR_BOUNDARY_TRIGGER", 1, {
|
|
277
|
+
componentName,
|
|
278
|
+
errorId,
|
|
279
|
+
errorMessage: error.message,
|
|
280
|
+
stack: error.stack?.substring(0, 200)
|
|
281
|
+
// Truncated stack trace
|
|
282
|
+
});
|
|
283
|
+
if (enableReporting) {
|
|
284
|
+
this.reportError(errorId, componentName);
|
|
285
|
+
}
|
|
286
|
+
if (onError) {
|
|
287
|
+
onError(error, errorInfo, errorId);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
componentWillUnmount() {
|
|
291
|
+
if (this.retryTimeoutId) {
|
|
292
|
+
clearTimeout(this.retryTimeoutId);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
render() {
|
|
296
|
+
if (this.state.hasError) {
|
|
297
|
+
const {
|
|
298
|
+
componentName = "Component",
|
|
299
|
+
fallback,
|
|
300
|
+
enableRetry = true,
|
|
301
|
+
maxRetries = 3
|
|
302
|
+
} = this.props;
|
|
303
|
+
const { retryCount, errorId } = this.state;
|
|
304
|
+
if (fallback) {
|
|
305
|
+
return fallback;
|
|
306
|
+
}
|
|
307
|
+
return /* @__PURE__ */ jsx(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
role: "alert",
|
|
311
|
+
className: "p-6 bg-destructive/10 border border-destructive/20 rounded-lg",
|
|
312
|
+
"data-error-boundary": errorId,
|
|
313
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
314
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-destructive", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }) }),
|
|
315
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
316
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-destructive", children: [
|
|
317
|
+
"Error in ",
|
|
318
|
+
componentName
|
|
319
|
+
] }),
|
|
320
|
+
/* @__PURE__ */ jsx("p", { className: "text-destructive/80", children: this.state.error?.message || "An unexpected error occurred." }),
|
|
321
|
+
enableRetry && retryCount < maxRetries && /* @__PURE__ */ jsxs("div", { className: "flex gap-3 mb-4", children: [
|
|
322
|
+
/* @__PURE__ */ jsxs(
|
|
323
|
+
"button",
|
|
324
|
+
{
|
|
325
|
+
onClick: this.handleRetry,
|
|
326
|
+
className: "px-4 py-2 bg-destructive text-destructive-foreground rounded-md hover:bg-destructive/90 transition-colors text-sm font-medium",
|
|
327
|
+
children: [
|
|
328
|
+
"Retry (",
|
|
329
|
+
retryCount + 1,
|
|
330
|
+
"/",
|
|
331
|
+
maxRetries,
|
|
332
|
+
")"
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
"button",
|
|
338
|
+
{
|
|
339
|
+
onClick: () => window.location.reload(),
|
|
340
|
+
className: "px-4 py-2 bg-sec-600 text-main-50 rounded-md hover:bg-sec-700 transition-colors text-sm font-medium",
|
|
341
|
+
children: "Reload Page"
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }),
|
|
345
|
+
retryCount >= maxRetries && /* @__PURE__ */ jsxs("div", { className: "mb-4 p-3 bg-acc-50 border border-acc-200 rounded-md", children: [
|
|
346
|
+
/* @__PURE__ */ jsx("p", { className: "text-acc-800", children: "Maximum retry attempts reached. Please reload the page or contact support." }),
|
|
347
|
+
/* @__PURE__ */ jsx(
|
|
348
|
+
"button",
|
|
349
|
+
{
|
|
350
|
+
onClick: () => window.location.reload(),
|
|
351
|
+
className: "mt-2 px-3 py-1 bg-acc-600 text-main-50 rounded text-sm hover:bg-acc-700",
|
|
352
|
+
children: "Reload Page"
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
] }),
|
|
356
|
+
import.meta.env.MODE === "development" && this.state.error && /* @__PURE__ */ jsxs("details", { className: "text-sm text-destructive/70", children: [
|
|
357
|
+
/* @__PURE__ */ jsx("summary", { className: "cursor-pointer font-medium mb-2", children: "Error Details (Development)" }),
|
|
358
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-destructive/5 p-3 rounded border", children: [
|
|
359
|
+
/* @__PURE__ */ jsxs("p", { className: "font-mono", children: [
|
|
360
|
+
"Error ID: ",
|
|
361
|
+
errorId
|
|
362
|
+
] }),
|
|
363
|
+
/* @__PURE__ */ jsxs("pre", { className: "whitespace-pre-wrap text-xs overflow-auto max-h-32", children: [
|
|
364
|
+
this.state.error.toString(),
|
|
365
|
+
this.state.errorInfo?.componentStack
|
|
366
|
+
] })
|
|
367
|
+
] })
|
|
368
|
+
] })
|
|
369
|
+
] })
|
|
370
|
+
] })
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
return this.props.children;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/components/PublicLayout/PublicPageProvider.tsx
|
|
379
|
+
import { createContext, useContext, useMemo as useMemo3 } from "react";
|
|
380
|
+
import { createClient } from "@supabase/supabase-js";
|
|
381
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
382
|
+
var PublicPageContext = createContext(void 0);
|
|
383
|
+
function PublicPageProvider({ children, appName }) {
|
|
384
|
+
const getEnvVar = (key) => {
|
|
385
|
+
if (typeof import.meta !== "undefined" && import.meta.env) {
|
|
386
|
+
const env = import.meta.env;
|
|
387
|
+
return env[key];
|
|
388
|
+
}
|
|
389
|
+
if (typeof process !== "undefined" && process.env) {
|
|
390
|
+
return process.env[key];
|
|
391
|
+
}
|
|
392
|
+
return void 0;
|
|
393
|
+
};
|
|
394
|
+
const supabaseUrl = getEnvVar("VITE_SUPABASE_URL") || getEnvVar("NEXT_PUBLIC_SUPABASE_URL") || null;
|
|
395
|
+
const supabaseKey = getEnvVar("VITE_SUPABASE_PUBLISHABLE_KEY") || getEnvVar("NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY") || getEnvVar("VITE_SUPABASE_ANON_KEY") || getEnvVar("NEXT_PUBLIC_SUPABASE_ANON_KEY") || null;
|
|
396
|
+
const supabase = useMemo3(() => {
|
|
397
|
+
if (!supabaseUrl || !supabaseKey) {
|
|
398
|
+
logger.warn("PublicPageProvider", "Missing Supabase environment variables. Please ensure VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY are set in your environment.");
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
const client = createClient(supabaseUrl, supabaseKey);
|
|
402
|
+
logger.info("PublicPageProvider", "Supabase client created successfully for public pages");
|
|
403
|
+
return client;
|
|
404
|
+
}, [supabaseUrl, supabaseKey]);
|
|
405
|
+
const contextValue = {
|
|
406
|
+
isPublicPage: true,
|
|
407
|
+
supabase,
|
|
408
|
+
appName: appName || null,
|
|
409
|
+
environment: {
|
|
410
|
+
supabaseUrl,
|
|
411
|
+
supabaseKey
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
return /* @__PURE__ */ jsx2(PublicPageContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx2(ErrorBoundary, { componentName: "PublicPageProvider", children }) });
|
|
415
|
+
}
|
|
416
|
+
function usePublicPageContext() {
|
|
417
|
+
const context = useContext(PublicPageContext);
|
|
418
|
+
if (!context) {
|
|
419
|
+
throw new Error("usePublicPageContext must be used within a PublicPageProvider");
|
|
420
|
+
}
|
|
421
|
+
return context;
|
|
422
|
+
}
|
|
423
|
+
function useIsPublicPage() {
|
|
424
|
+
const context = useContext(PublicPageContext);
|
|
425
|
+
return context !== void 0;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// src/hooks/useAppConfig.ts
|
|
429
|
+
import { useMemo as useMemo4, useContext as useContext2 } from "react";
|
|
430
|
+
function useAppConfig() {
|
|
431
|
+
const isPublicPage = useIsPublicPage();
|
|
432
|
+
const publicPageContext = useContext2(PublicPageContext);
|
|
433
|
+
const hasPublicContext = publicPageContext !== void 0;
|
|
434
|
+
const contextAppName = publicPageContext?.appName || null;
|
|
435
|
+
const getNodeEnvVar = (key) => typeof process !== "undefined" && process.env ? process.env[key] : void 0;
|
|
436
|
+
if (isPublicPage) {
|
|
437
|
+
const getAppName = () => {
|
|
438
|
+
if (!hasPublicContext) {
|
|
439
|
+
return "PACE";
|
|
440
|
+
}
|
|
441
|
+
if (contextAppName) {
|
|
442
|
+
return contextAppName;
|
|
443
|
+
}
|
|
444
|
+
if (typeof import.meta !== "undefined" && import.meta.env) {
|
|
445
|
+
const env = import.meta.env;
|
|
446
|
+
return env.VITE_APP_NAME || env.NEXT_PUBLIC_APP_NAME || "PACE";
|
|
447
|
+
}
|
|
448
|
+
if (typeof import.meta !== "undefined" && import.meta.env) {
|
|
449
|
+
return import.meta.env.VITE_APP_NAME || import.meta.env.NEXT_PUBLIC_APP_NAME || "PACE";
|
|
450
|
+
}
|
|
451
|
+
const nodeEnvAppName = getNodeEnvVar("VITE_APP_NAME") || getNodeEnvVar("NEXT_PUBLIC_APP_NAME");
|
|
452
|
+
if (nodeEnvAppName) {
|
|
453
|
+
return nodeEnvAppName;
|
|
454
|
+
}
|
|
455
|
+
return "PACE";
|
|
456
|
+
};
|
|
457
|
+
return useMemo4(() => ({
|
|
458
|
+
supportsDirectAccess: false,
|
|
459
|
+
// Public pages don't support direct access
|
|
460
|
+
requiresEvent: true,
|
|
461
|
+
// Public pages always require an event
|
|
462
|
+
isLoading: false,
|
|
463
|
+
appName: getAppName()
|
|
464
|
+
}), [contextAppName, hasPublicContext]);
|
|
465
|
+
}
|
|
466
|
+
try {
|
|
467
|
+
const { appConfig, appName } = useUnifiedAuth();
|
|
468
|
+
return useMemo4(() => ({
|
|
469
|
+
supportsDirectAccess: !(appConfig?.requires_event ?? true),
|
|
470
|
+
requiresEvent: appConfig?.requires_event ?? true,
|
|
471
|
+
isLoading: appConfig === null,
|
|
472
|
+
appName
|
|
473
|
+
}), [appConfig?.requires_event, appName]);
|
|
474
|
+
} catch (error) {
|
|
475
|
+
return useMemo4(() => ({
|
|
476
|
+
supportsDirectAccess: false,
|
|
477
|
+
requiresEvent: true,
|
|
478
|
+
isLoading: false,
|
|
479
|
+
appName: contextAppName || getNodeEnvVar("VITE_APP_NAME") || getNodeEnvVar("NEXT_PUBLIC_APP_NAME") || "PACE"
|
|
480
|
+
}), [contextAppName]);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/rbac/hooks/useSuperAdminBypass.ts
|
|
485
|
+
import { useEffect as useEffect2, useMemo as useMemo5, useRef as useRef3, useState as useState2 } from "react";
|
|
486
|
+
|
|
487
|
+
// src/utils/context/superAdminOverride.ts
|
|
488
|
+
var log2 = createLogger("superAdminOverride");
|
|
489
|
+
async function setSuperAdminOverrideFlag({
|
|
490
|
+
supabase,
|
|
491
|
+
enabled,
|
|
492
|
+
reason = "client_request"
|
|
493
|
+
}) {
|
|
494
|
+
if (!supabase) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const { error } = await supabase.rpc("set_super_admin_override", {
|
|
499
|
+
p_enabled: enabled,
|
|
500
|
+
p_reason: reason
|
|
501
|
+
});
|
|
502
|
+
if (error) {
|
|
503
|
+
log2.error("Failed to toggle super admin override", {
|
|
504
|
+
enabled,
|
|
505
|
+
reason,
|
|
506
|
+
error: error.message
|
|
507
|
+
});
|
|
508
|
+
} else {
|
|
509
|
+
log2.debug("Super admin override flag updated", { enabled, reason });
|
|
510
|
+
}
|
|
511
|
+
} catch (rpcError) {
|
|
512
|
+
log2.error("Unexpected error toggling super admin override", {
|
|
513
|
+
enabled,
|
|
514
|
+
reason,
|
|
515
|
+
error: rpcError instanceof Error ? rpcError.message : rpcError
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// src/rbac/hooks/useSuperAdminBypass.ts
|
|
521
|
+
var log3 = createLogger("useSuperAdminBypass");
|
|
522
|
+
function useSafeUnifiedAuth() {
|
|
523
|
+
try {
|
|
524
|
+
return useUnifiedAuth();
|
|
525
|
+
} catch (error) {
|
|
526
|
+
log3.debug("useSuperAdminBypass", "UnifiedAuthProvider not available, falling back to defaults", {
|
|
527
|
+
error: error instanceof Error ? error.message : error
|
|
528
|
+
});
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function useSuperAdminBypass() {
|
|
533
|
+
const authContext = useSafeUnifiedAuth();
|
|
534
|
+
const user = authContext?.user ?? null;
|
|
535
|
+
const supabase = authContext?.supabase ?? null;
|
|
536
|
+
const metadataHint = Boolean(user?.app_metadata?.is_super_admin) || Boolean(user?.user_metadata?.is_super_admin);
|
|
537
|
+
const [isSuperAdminState, setIsSuperAdminState] = useState2(metadataHint);
|
|
538
|
+
const [hasVerified, setHasVerified] = useState2(!user?.id);
|
|
539
|
+
const [isLoading, setIsLoading] = useState2(!!user?.id);
|
|
540
|
+
const [error, setError] = useState2(null);
|
|
541
|
+
const lastOverrideValueRef = useRef3(null);
|
|
542
|
+
useEffect2(() => {
|
|
543
|
+
if (!user?.id) {
|
|
544
|
+
setIsSuperAdminState(false);
|
|
545
|
+
setHasVerified(true);
|
|
546
|
+
setIsLoading(false);
|
|
547
|
+
setError(null);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
let cancelled = false;
|
|
551
|
+
setIsLoading(true);
|
|
552
|
+
setError(null);
|
|
553
|
+
isSuperAdmin(user.id).then((result) => {
|
|
554
|
+
if (cancelled) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
setIsSuperAdminState(result);
|
|
558
|
+
setHasVerified(true);
|
|
559
|
+
}).catch((err) => {
|
|
560
|
+
if (cancelled) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const normalisedError = err instanceof Error ? err : new Error("Failed to resolve super admin status");
|
|
564
|
+
setError(normalisedError);
|
|
565
|
+
setIsSuperAdminState(false);
|
|
566
|
+
setHasVerified(false);
|
|
567
|
+
log3.error("Unable to verify super admin status", normalisedError);
|
|
568
|
+
}).finally(() => {
|
|
569
|
+
if (!cancelled) {
|
|
570
|
+
setIsLoading(false);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
return () => {
|
|
574
|
+
cancelled = true;
|
|
575
|
+
};
|
|
576
|
+
}, [user?.id]);
|
|
577
|
+
const shouldBypass = hasVerified && isSuperAdminState;
|
|
578
|
+
useEffect2(() => {
|
|
579
|
+
if (!supabase) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (lastOverrideValueRef.current === shouldBypass) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
lastOverrideValueRef.current = shouldBypass;
|
|
586
|
+
setSuperAdminOverrideFlag({
|
|
587
|
+
supabase,
|
|
588
|
+
enabled: shouldBypass,
|
|
589
|
+
reason: "pace-core-super-admin-bypass"
|
|
590
|
+
}).catch(() => {
|
|
591
|
+
});
|
|
592
|
+
}, [supabase, shouldBypass]);
|
|
593
|
+
return useMemo5(
|
|
594
|
+
() => ({
|
|
595
|
+
isSuperAdmin: shouldBypass,
|
|
596
|
+
isLoading,
|
|
597
|
+
error
|
|
598
|
+
}),
|
|
599
|
+
[shouldBypass, isLoading, error]
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export {
|
|
604
|
+
useEvents,
|
|
605
|
+
useResolvedScope,
|
|
606
|
+
ErrorBoundary,
|
|
607
|
+
PublicPageContext,
|
|
608
|
+
PublicPageProvider,
|
|
609
|
+
usePublicPageContext,
|
|
610
|
+
useIsPublicPage,
|
|
611
|
+
useAppConfig,
|
|
612
|
+
useSuperAdminBypass
|
|
613
|
+
};
|
|
614
|
+
//# sourceMappingURL=chunk-OETXORNB.js.map
|