@jmruthers/pace-core 0.5.21 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ULP6OIQE.js → chunk-2XPPF7PE.js} +77 -4
- package/dist/chunk-2XPPF7PE.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/rbac/index.js +1 -1
- 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 +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- 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/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 +1 -1
- 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 +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/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 +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- 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 +3 -3
- package/package.json +1 -1
- package/src/rbac/components/PagePermissionGuard.tsx +97 -3
- package/dist/chunk-ULP6OIQE.js.map +0 -1
package/docs/api/modules.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[@jmruthers/pace-core - v0.5.
|
|
1
|
+
[@jmruthers/pace-core - v0.5.22](README.md) / Exports
|
|
2
2
|
|
|
3
|
-
# @jmruthers/pace-core - v0.5.
|
|
3
|
+
# @jmruthers/pace-core - v0.5.22
|
|
4
4
|
|
|
5
5
|
**`File`**
|
|
6
6
|
|
|
@@ -5058,7 +5058,7 @@ React element with permission enforcement
|
|
|
5058
5058
|
|
|
5059
5059
|
#### Defined in
|
|
5060
5060
|
|
|
5061
|
-
[packages/core/src/rbac/components/PagePermissionGuard.tsx:
|
|
5061
|
+
[packages/core/src/rbac/components/PagePermissionGuard.tsx:602](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/components/PagePermissionGuard.tsx#L602)
|
|
5062
5062
|
|
|
5063
5063
|
___
|
|
5064
5064
|
|
package/package.json
CHANGED
|
@@ -131,6 +131,23 @@ const PagePermissionGuardComponent = ({
|
|
|
131
131
|
// Generate a unique instance ID for debugging
|
|
132
132
|
const instanceId = useMemo(() => Math.random().toString(36).substr(2, 9), []);
|
|
133
133
|
|
|
134
|
+
// Track render count for debugging
|
|
135
|
+
const renderCountRef = useRef(0);
|
|
136
|
+
renderCountRef.current += 1;
|
|
137
|
+
|
|
138
|
+
console.log(`[PagePermissionGuard] RENDER #${renderCountRef.current} for ${pageName}:${operation}`, {
|
|
139
|
+
instanceId,
|
|
140
|
+
timestamp: new Date().toISOString()
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Track component lifecycle
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
console.log(`[PagePermissionGuard] MOUNTED: ${pageName}:${operation}`, { instanceId });
|
|
146
|
+
return () => {
|
|
147
|
+
console.log(`[PagePermissionGuard] UNMOUNTED: ${pageName}:${operation}`, { instanceId });
|
|
148
|
+
};
|
|
149
|
+
}, [pageName, operation, instanceId]);
|
|
150
|
+
|
|
134
151
|
const { user, selectedOrganisationId, selectedEventId, supabase } = useUnifiedAuth();
|
|
135
152
|
const [hasChecked, setHasChecked] = useState(false);
|
|
136
153
|
const [checkError, setCheckError] = useState<Error | null>(null);
|
|
@@ -358,6 +375,18 @@ const PagePermissionGuardComponent = ({
|
|
|
358
375
|
true // Use cache
|
|
359
376
|
);
|
|
360
377
|
|
|
378
|
+
// Debug useCan results
|
|
379
|
+
console.log(`[PagePermissionGuard] useCan result for ${pageName}:${operation}`, {
|
|
380
|
+
instanceId,
|
|
381
|
+
can,
|
|
382
|
+
canIsLoading,
|
|
383
|
+
canError: !!canError,
|
|
384
|
+
userId: user?.id,
|
|
385
|
+
stableScope,
|
|
386
|
+
permission,
|
|
387
|
+
effectivePageId
|
|
388
|
+
});
|
|
389
|
+
|
|
361
390
|
// Combine loading states - we're loading if either scope is resolving OR permission check is loading
|
|
362
391
|
const isLoading = !resolvedScope || canIsLoading;
|
|
363
392
|
const error = checkError || canError;
|
|
@@ -432,29 +461,92 @@ const PagePermissionGuardComponent = ({
|
|
|
432
461
|
});
|
|
433
462
|
}, [isLoading, hasChecked, resolvedScope, checkError, can, shouldShowAccessDenied, shouldShowContent, permissionKey, instanceId]);
|
|
434
463
|
|
|
464
|
+
// CRITICAL DEBUG: Log every render decision with full context
|
|
465
|
+
const renderDecision = {
|
|
466
|
+
instanceId,
|
|
467
|
+
timestamp: new Date().toISOString(),
|
|
468
|
+
renderCount: renderCountRef.current,
|
|
469
|
+
// State values
|
|
470
|
+
isLoading,
|
|
471
|
+
hasValidScope,
|
|
472
|
+
hasValidUser,
|
|
473
|
+
hasChecked,
|
|
474
|
+
checkError: !!checkError,
|
|
475
|
+
can,
|
|
476
|
+
// Calculated values
|
|
477
|
+
shouldShowAccessDenied,
|
|
478
|
+
shouldShowContent,
|
|
479
|
+
// Render conditions
|
|
480
|
+
willShowLoading: isLoading || !hasValidScope || !hasValidUser || !hasChecked,
|
|
481
|
+
willShowError: checkError && !can,
|
|
482
|
+
willShowDenied: shouldShowAccessDenied,
|
|
483
|
+
willShowContent: shouldShowContent,
|
|
484
|
+
// Raw data for debugging
|
|
485
|
+
resolvedScope: resolvedScope ? {
|
|
486
|
+
organisationId: resolvedScope.organisationId,
|
|
487
|
+
eventId: resolvedScope.eventId,
|
|
488
|
+
appId: resolvedScope.appId
|
|
489
|
+
} : null,
|
|
490
|
+
user: user ? { id: user.id, email: user.email } : null
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
console.log('[PagePermissionGuard] RENDER DECISION:', renderDecision);
|
|
494
|
+
|
|
495
|
+
// CRITICAL: If we have permission but shouldShowContent is false, this is the bug!
|
|
496
|
+
if (can && !shouldShowContent) {
|
|
497
|
+
console.error('[PagePermissionGuard] CRITICAL BUG DETECTED: Has permission but shouldShowContent is false!', {
|
|
498
|
+
...renderDecision,
|
|
499
|
+
bug: 'PERMISSION_GRANTED_BUT_CONTENT_NOT_SHOWING'
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// CRITICAL: If shouldShowContent is true but we're not rendering content, this is the bug!
|
|
504
|
+
if (shouldShowContent && !(isLoading || !hasValidScope || !hasValidUser || !hasChecked) && !(checkError && !can) && !shouldShowAccessDenied) {
|
|
505
|
+
console.log('[PagePermissionGuard] SHOULD RENDER CONTENT - This is the correct path!', {
|
|
506
|
+
...renderDecision,
|
|
507
|
+
status: 'CONTENT_SHOULD_BE_RENDERED'
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
435
511
|
// Show loading state - if we're still loading or don't have valid state
|
|
436
512
|
if (isLoading || !hasValidScope || !hasValidUser || !hasChecked) {
|
|
513
|
+
console.log('[PagePermissionGuard] RENDERING: LOADING STATE');
|
|
437
514
|
return <div key={`loading-${permissionKey}`}>{loading}</div>;
|
|
438
515
|
}
|
|
439
516
|
|
|
440
517
|
// Show error state - only if we have an error AND no permission
|
|
441
518
|
if (checkError && !can) {
|
|
519
|
+
console.log('[PagePermissionGuard] RENDERING: ERROR STATE');
|
|
442
520
|
return <div key={`error-${permissionKey}`}>{fallback}</div>;
|
|
443
521
|
}
|
|
444
522
|
|
|
445
523
|
// Show access denied - if permission check is complete and user doesn't have permission
|
|
446
524
|
if (shouldShowAccessDenied) {
|
|
525
|
+
console.log('[PagePermissionGuard] RENDERING: ACCESS DENIED STATE');
|
|
447
526
|
return <div key={`denied-${permissionKey}`}>{fallback}</div>;
|
|
448
527
|
}
|
|
449
528
|
|
|
450
529
|
// Show protected content - if permission check is complete and user has permission
|
|
451
530
|
if (shouldShowContent) {
|
|
452
|
-
|
|
531
|
+
console.log('[PagePermissionGuard] RENDERING: CONTENT STATE - SHOWING CHILDREN');
|
|
532
|
+
console.log('[PagePermissionGuard] CONTENT RENDER SUCCESS - This should fix the Access Denied issue!');
|
|
533
|
+
|
|
534
|
+
// Add a visual indicator in development to confirm content is rendering
|
|
535
|
+
const contentWithDebug = process.env.NODE_ENV === 'development' ? (
|
|
536
|
+
<div style={{ border: '2px solid green', padding: '4px', margin: '4px' }}>
|
|
537
|
+
<div style={{ background: 'lightgreen', padding: '2px', fontSize: '12px', marginBottom: '4px' }}>
|
|
538
|
+
✅ PagePermissionGuard: Content Rendered Successfully
|
|
539
|
+
</div>
|
|
540
|
+
{children}
|
|
541
|
+
</div>
|
|
542
|
+
) : children;
|
|
543
|
+
|
|
544
|
+
return <div key={`content-${permissionKey}`}>{contentWithDebug}</div>;
|
|
453
545
|
}
|
|
454
546
|
|
|
455
547
|
// Fallback: This should never happen, but just in case
|
|
456
548
|
// If we get here, something went wrong with our state logic
|
|
457
|
-
console.
|
|
549
|
+
console.error('[PagePermissionGuard] CRITICAL: UNEXPECTED STATE - FALLING BACK TO LOADING', {
|
|
458
550
|
instanceId,
|
|
459
551
|
isLoading,
|
|
460
552
|
hasValidScope,
|
|
@@ -463,7 +555,9 @@ const PagePermissionGuardComponent = ({
|
|
|
463
555
|
checkError: !!checkError,
|
|
464
556
|
can,
|
|
465
557
|
shouldShowAccessDenied,
|
|
466
|
-
shouldShowContent
|
|
558
|
+
shouldShowContent,
|
|
559
|
+
resolvedScope,
|
|
560
|
+
user: user ? { id: user.id, email: user.email } : null
|
|
467
561
|
});
|
|
468
562
|
return <div key={`fallback-${permissionKey}`}>{loading}</div>;
|
|
469
563
|
}
|