@jmruthers/pace-core 0.5.148 → 0.5.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DataTable-SXRT3OPO.js → DataTable-6G3KTRE2.js} +3 -3
- package/dist/{chunk-CZ6XCEJN.js → chunk-I63KPRGZ.js} +31 -29
- package/dist/chunk-I63KPRGZ.js.map +1 -0
- package/dist/{chunk-UHB4HVCJ.js → chunk-NRDKCKSX.js} +15 -27
- package/dist/chunk-NRDKCKSX.js.map +1 -0
- package/dist/{chunk-IUJDN47M.js → chunk-RF6SUNXB.js} +2 -2
- package/dist/{chunk-Y3U4OEN3.js → chunk-XXFXL7A5.js} +2 -2
- package/dist/components.js +3 -3
- package/dist/index.js +4 -4
- package/dist/rbac/index.js +2 -2
- package/dist/utils.js +1 -1
- package/docs/api/classes/ColumnFactory.md +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/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/interfaces/AggregateConfig.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 +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +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/EventAppRoleData.md +1 -1
- package/docs/api/interfaces/EventLogoProps.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 +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/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/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/ProtectedRouteProps.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/RBACLogger.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 +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RoleManagementResult.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/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/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 +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/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UseResourcePermissionsOptions.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 +2 -2
- package/docs/rbac/RBAC_LOGIN_SAFETY_FIX.md +95 -0
- package/docs/troubleshooting/DEBUG_NETWORK_ERROR.md +152 -0
- package/docs/troubleshooting/FIX_SUPABASE_CORS.md +184 -0
- package/package.json +1 -1
- package/src/components/NavigationMenu/NavigationMenu.tsx +16 -38
- package/src/rbac/hooks/useRBAC.ts +35 -29
- package/dist/chunk-CZ6XCEJN.js.map +0 -1
- package/dist/chunk-UHB4HVCJ.js.map +0 -1
- /package/dist/{DataTable-SXRT3OPO.js.map → DataTable-6G3KTRE2.js.map} +0 -0
- /package/dist/{chunk-IUJDN47M.js.map → chunk-RF6SUNXB.js.map} +0 -0
- /package/dist/{chunk-Y3U4OEN3.js.map → chunk-XXFXL7A5.js.map} +0 -0
package/docs/api/modules.md
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# RBAC Login Safety Fix - v0.5.148
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
After RBAC changes, users reported login failures. Investigation revealed:
|
|
6
|
+
1. **CORS error** - Network/infrastructure issue (separate from RBAC)
|
|
7
|
+
2. **Potential hook errors** - `useOrganisations()` might throw when called before authentication
|
|
8
|
+
|
|
9
|
+
## Root Cause
|
|
10
|
+
|
|
11
|
+
`useRBAC` hook calls `useOrganisations()` unconditionally (required by React hooks rules). If `useOrganisations()` throws an error when there's no authenticated user, it could break the login flow.
|
|
12
|
+
|
|
13
|
+
## Fix Applied
|
|
14
|
+
|
|
15
|
+
Wrapped `useOrganisations()` call in try-catch, similar to how `useEvents()` is handled:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Safely get organisation context - may not be available during login
|
|
19
|
+
let selectedOrganisation: { id: string } | null = null;
|
|
20
|
+
let orgContextReady = false;
|
|
21
|
+
let orgLoading = false;
|
|
22
|
+
try {
|
|
23
|
+
const orgContext = useOrganisations();
|
|
24
|
+
selectedOrganisation = orgContext.selectedOrganisation;
|
|
25
|
+
orgContextReady = orgContext.isContextReady;
|
|
26
|
+
orgLoading = orgContext.isLoading;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// Organisation provider not available or user not authenticated - this is OK
|
|
29
|
+
logger.debug('[useRBAC] Organisation provider not available, continuing without organisation context', error);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Safety Guarantees
|
|
34
|
+
|
|
35
|
+
1. ✅ **`useRBAC` never throws** - All hook calls are wrapped in try-catch
|
|
36
|
+
2. ✅ **Safe during login** - Returns empty state when unauthenticated
|
|
37
|
+
3. ✅ **Early returns** - Exits immediately if no user/session
|
|
38
|
+
4. ✅ **No logging noise** - Only logs when authenticated
|
|
39
|
+
5. ✅ **No network calls** - Doesn't make RPC calls when unauthenticated
|
|
40
|
+
|
|
41
|
+
## Verification
|
|
42
|
+
|
|
43
|
+
### When Unauthenticated:
|
|
44
|
+
- `useRBAC` returns safely with empty state
|
|
45
|
+
- No errors thrown
|
|
46
|
+
- No network calls made
|
|
47
|
+
- Login flow proceeds normally
|
|
48
|
+
|
|
49
|
+
### When Authenticated:
|
|
50
|
+
- `useRBAC` loads organisation context
|
|
51
|
+
- Waits for organisation context before loading RBAC
|
|
52
|
+
- Loads permissions correctly
|
|
53
|
+
|
|
54
|
+
## CORS Error (Separate Issue)
|
|
55
|
+
|
|
56
|
+
The CORS error is **NOT caused by RBAC**. It's a network/infrastructure issue:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
|
|
60
|
+
at https://srqhjwivpohjcjqikjry.supabase.co/auth/v1/token?grant_type=password
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### To Fix CORS:
|
|
64
|
+
1. Check Supabase Dashboard → Settings → API → CORS
|
|
65
|
+
2. Add `localhost:8087` to allowed origins
|
|
66
|
+
3. Or use wildcard `*` for development
|
|
67
|
+
4. Check network/proxy settings
|
|
68
|
+
5. Verify browser isn't blocking requests
|
|
69
|
+
|
|
70
|
+
## Testing
|
|
71
|
+
|
|
72
|
+
1. **Before login**:
|
|
73
|
+
- Open browser console
|
|
74
|
+
- Navigate to login page
|
|
75
|
+
- Verify no RBAC errors
|
|
76
|
+
- Verify login form displays
|
|
77
|
+
|
|
78
|
+
2. **During login**:
|
|
79
|
+
- Enter credentials
|
|
80
|
+
- Click login
|
|
81
|
+
- Verify no RBAC errors in console
|
|
82
|
+
- If CORS error appears, it's a Supabase config issue (not RBAC)
|
|
83
|
+
|
|
84
|
+
3. **After login**:
|
|
85
|
+
- Verify RBAC loads correctly
|
|
86
|
+
- Check console for RBAC loading logs
|
|
87
|
+
- Verify permissions load
|
|
88
|
+
|
|
89
|
+
## Summary
|
|
90
|
+
|
|
91
|
+
- ✅ **RBAC is now safe** - Wrapped in try-catch, won't break login
|
|
92
|
+
- ✅ **No interference** - Early returns prevent any action when unauthenticated
|
|
93
|
+
- ⚠️ **CORS is separate** - Infrastructure issue, needs Supabase config fix
|
|
94
|
+
- ✅ **Ready for testing** - Should work correctly now
|
|
95
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Debugging NetworkError / CORS Error
|
|
2
|
+
|
|
3
|
+
## The Real Issue
|
|
4
|
+
|
|
5
|
+
If pace-cake works fine with the same Supabase instance, then **CORS is already configured correctly**. The "CORS request did not succeed" error message is often misleading - it usually means the request failed for another reason, not necessarily CORS policy.
|
|
6
|
+
|
|
7
|
+
## How to Debug
|
|
8
|
+
|
|
9
|
+
### Step 1: Check Network Tab in Browser DevTools
|
|
10
|
+
|
|
11
|
+
1. Open browser DevTools (F12 or Cmd+Option+I)
|
|
12
|
+
2. Go to **Network** tab
|
|
13
|
+
3. Clear the network log
|
|
14
|
+
4. Try to log in
|
|
15
|
+
5. Look for the failed request to `/auth/v1/token`
|
|
16
|
+
|
|
17
|
+
**What to check:**
|
|
18
|
+
- **Status code**: What HTTP status code is returned? (200, 401, 500, etc.)
|
|
19
|
+
- **Request headers**: Are the headers correct?
|
|
20
|
+
- **Response**: What does the response say?
|
|
21
|
+
- **Timing**: Does the request timeout or fail immediately?
|
|
22
|
+
|
|
23
|
+
### Step 2: Check Console for Real Error
|
|
24
|
+
|
|
25
|
+
The browser console might show the actual error. Look for:
|
|
26
|
+
- Network timeout
|
|
27
|
+
- Connection refused
|
|
28
|
+
- SSL/TLS errors
|
|
29
|
+
- Proxy errors
|
|
30
|
+
- Request cancelled
|
|
31
|
+
|
|
32
|
+
### Step 3: Compare with pace-cake
|
|
33
|
+
|
|
34
|
+
Since pace-cake works:
|
|
35
|
+
1. **Check pace-cake's network tab** - What does a successful login request look like?
|
|
36
|
+
2. **Compare request headers** - Are they the same?
|
|
37
|
+
3. **Compare Supabase client setup** - Is it identical?
|
|
38
|
+
|
|
39
|
+
### Step 4: Check for Differences
|
|
40
|
+
|
|
41
|
+
**Compare pace-trac vs pace-cake:**
|
|
42
|
+
|
|
43
|
+
1. **Supabase client creation**:
|
|
44
|
+
```typescript
|
|
45
|
+
// pace-trac - check this matches pace-cake
|
|
46
|
+
const supabase = createClient(url, key, {
|
|
47
|
+
auth: {
|
|
48
|
+
autoRefreshToken: true,
|
|
49
|
+
persistSession: true,
|
|
50
|
+
detectSessionInUrl: true
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. **setupRBAC call**:
|
|
56
|
+
```typescript
|
|
57
|
+
// Should be identical
|
|
58
|
+
setupRBAC(supabase);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. **Provider setup**:
|
|
62
|
+
```typescript
|
|
63
|
+
// Should match pace-cake exactly
|
|
64
|
+
<UnifiedAuthProvider supabaseClient={supabase} appName={APP_NAME}>
|
|
65
|
+
<OrganisationProvider>
|
|
66
|
+
<App />
|
|
67
|
+
</OrganisationProvider>
|
|
68
|
+
</UnifiedAuthProvider>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Step 5: Check Browser/Network Issues
|
|
72
|
+
|
|
73
|
+
**Common causes of "CORS request did not succeed":**
|
|
74
|
+
|
|
75
|
+
1. **Browser extension blocking requests**
|
|
76
|
+
- Try incognito/private mode
|
|
77
|
+
- Disable extensions one by one
|
|
78
|
+
|
|
79
|
+
2. **Network/proxy issues**
|
|
80
|
+
- Check if corporate proxy is blocking
|
|
81
|
+
- Try different network (mobile hotspot)
|
|
82
|
+
- Check firewall settings
|
|
83
|
+
|
|
84
|
+
3. **DNS issues**
|
|
85
|
+
- Can you reach `srqhjwivpohjcjqikjry.supabase.co`?
|
|
86
|
+
- Try pinging the domain
|
|
87
|
+
|
|
88
|
+
4. **SSL/TLS issues**
|
|
89
|
+
- Check browser console for SSL errors
|
|
90
|
+
- Verify certificate is valid
|
|
91
|
+
|
|
92
|
+
### Step 6: Check pace-trac Specific Issues
|
|
93
|
+
|
|
94
|
+
**Things that might be different in pace-trac:**
|
|
95
|
+
|
|
96
|
+
1. **Port number**: Are you using a different port than pace-cake?
|
|
97
|
+
- pace-cake might use `localhost:3000`
|
|
98
|
+
- pace-trac uses `localhost:8087`
|
|
99
|
+
- But if CORS is configured with wildcard, this shouldn't matter
|
|
100
|
+
|
|
101
|
+
2. **Environment variables**: Are they correct?
|
|
102
|
+
```bash
|
|
103
|
+
# Check these match pace-cake
|
|
104
|
+
VITE_SUPABASE_URL=...
|
|
105
|
+
VITE_SUPABASE_ANON_KEY=...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3. **Vite configuration**: Any proxy or network settings?
|
|
109
|
+
```typescript
|
|
110
|
+
// vite.config.ts - check for any proxy settings
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Most Likely Causes
|
|
114
|
+
|
|
115
|
+
Based on "pace-cake works but pace-trac doesn't":
|
|
116
|
+
|
|
117
|
+
1. **Different port** - But CORS should allow both if configured correctly
|
|
118
|
+
2. **Browser session issue** - Try clearing cache/cookies
|
|
119
|
+
3. **Network timing** - Something interfering with the request
|
|
120
|
+
4. **Code difference** - Something in pace-trac setup is different
|
|
121
|
+
|
|
122
|
+
## Quick Fixes to Try
|
|
123
|
+
|
|
124
|
+
1. **Clear browser cache and cookies**
|
|
125
|
+
2. **Try incognito/private mode**
|
|
126
|
+
3. **Try different browser**
|
|
127
|
+
4. **Restart dev server**
|
|
128
|
+
5. **Check if pace-cake still works** (verify Supabase is up)
|
|
129
|
+
|
|
130
|
+
## If Still Failing
|
|
131
|
+
|
|
132
|
+
**Check the actual network request details:**
|
|
133
|
+
- Right-click the failed request in Network tab
|
|
134
|
+
- Select "Copy" → "Copy as cURL"
|
|
135
|
+
- Compare with pace-cake's successful request
|
|
136
|
+
- Look for differences in headers, URL, or body
|
|
137
|
+
|
|
138
|
+
**Check console for actual error:**
|
|
139
|
+
- The "CORS request did not succeed" might be masking the real error
|
|
140
|
+
- Look for other error messages before/after
|
|
141
|
+
- Check if there are multiple failed requests
|
|
142
|
+
|
|
143
|
+
## Summary
|
|
144
|
+
|
|
145
|
+
Since pace-cake works, this is likely:
|
|
146
|
+
- ✅ **NOT a CORS configuration issue** (already configured)
|
|
147
|
+
- ✅ **NOT an RBAC issue** (RBAC doesn't interfere with auth)
|
|
148
|
+
- ⚠️ **Likely a network/browser issue** specific to pace-trac
|
|
149
|
+
- ⚠️ **Or a code difference** between pace-trac and pace-cake
|
|
150
|
+
|
|
151
|
+
**Next step**: Check Network tab in DevTools to see the actual error, not just the CORS message.
|
|
152
|
+
|