@stevederico/skateboard-ui 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ 1.5.1
4
+
5
+ Rename noProtectedRoutes to authOverlay
6
+ Guard unauthenticated Settings UI
7
+ Skip 401 redirect in authOverlay mode
8
+
3
9
  1.5.0
4
10
 
5
11
  Add AuthOverlay component
6
12
  Add useAuthGate hook
7
13
  Add auth overlay state
8
- Add noProtectedRoutes support
14
+ Add authOverlay support
9
15
  Add JSDoc comments
10
16
  Update README documentation
11
17
 
@@ -7,7 +7,7 @@ import { isAuthenticated, apiRequest, getAppKey, getConstants } from './Utilitie
7
7
  *
8
8
  * Checks client-side auth via isAuthenticated(), then validates the
9
9
  * session with the backend via /me. Redirects to /signin if invalid.
10
- * Bypassed when constants.noProtectedRoutes is true (for lazy auth).
10
+ * Bypassed when constants.authOverlay is true (for lazy auth).
11
11
  * Bypassed when constants.noLogin is true (no auth required).
12
12
  *
13
13
  * @returns {JSX.Element} Outlet if authenticated, Navigate to /signin otherwise
@@ -21,7 +21,7 @@ import { isAuthenticated, apiRequest, getAppKey, getConstants } from './Utilitie
21
21
  */
22
22
  const ProtectedRoute = () => {
23
23
  const constants = getConstants();
24
- const skipProtection = constants.noProtectedRoutes === true;
24
+ const skipProtection = constants.authOverlay === true;
25
25
  const [status, setStatus] = useState(skipProtection ? 'valid' : 'checking');
26
26
 
27
27
  useEffect(() => {
package/README.md CHANGED
@@ -97,7 +97,7 @@ const constants = {
97
97
 
98
98
  // Optional: Authentication
99
99
  noLogin: false, // Set true to disable authentication
100
- noProtectedRoutes: false, // Set true to allow unauthenticated access to /app routes (use with useAuthGate)
100
+ authOverlay: false, // Set true to allow unauthenticated access to /app routes (use with useAuthGate)
101
101
 
102
102
  // Optional: Payments (Stripe)
103
103
  stripeProducts: [
@@ -397,11 +397,11 @@ Let users explore `/app` without signing in — prompt them only when they perfo
397
397
 
398
398
  ### Setup
399
399
 
400
- Set `noProtectedRoutes: true` in your constants to allow unauthenticated access to `/app` routes:
400
+ Set `authOverlay: true` in your constants to allow unauthenticated access to `/app` routes:
401
401
 
402
402
  ```json
403
403
  {
404
- "noProtectedRoutes": true
404
+ "authOverlay": true
405
405
  }
406
406
  ```
407
407
 
package/SettingsView.jsx CHANGED
@@ -54,7 +54,7 @@ export default function SettingsView() {
54
54
  {/* Main content */}
55
55
  <div className="flex flex-col items-center p-4 gap-4">
56
56
  {/* User Card */}
57
- {(constants.noLogin === false || typeof constants.noLogin === 'undefined') && (
57
+ {(constants.noLogin === false || typeof constants.noLogin === 'undefined') && state.user && (
58
58
  <div className="w-full max-w-lg bg-accent rounded-2xl p-5">
59
59
  <div className="flex items-center gap-4">
60
60
  <Avatar size="lg">
@@ -113,7 +113,7 @@ export default function SettingsView() {
113
113
  </div>
114
114
 
115
115
  {/* Billing */}
116
- {(constants.noLogin === false || typeof constants.noLogin === 'undefined') && (
116
+ {(constants.noLogin === false || typeof constants.noLogin === 'undefined') && state.user && (
117
117
  <div className="w-full max-w-lg bg-accent rounded-2xl p-5">
118
118
  <div className="flex items-center justify-between">
119
119
  <div>
package/Utilities.js CHANGED
@@ -723,10 +723,12 @@ export async function apiRequest(endpoint, options = {}) {
723
723
  if (timeoutId) clearTimeout(timeoutId);
724
724
  }
725
725
 
726
- // Handle 401 (redirect to signout)
726
+ // Handle 401 (redirect to signout, unless authOverlay mode)
727
727
  if (response.status === 401) {
728
- window.location.href = '/signout';
729
- throw new Error('Unauthorized - Redirecting to Sign Out');
728
+ if (getConstants().authOverlay !== true) {
729
+ window.location.href = '/signout';
730
+ }
731
+ throw new Error('Unauthorized');
730
732
  }
731
733
 
732
734
  // Handle 403 CSRF token failures with auto-retry
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stevederico/skateboard-ui",
3
3
  "private": false,
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./AppSidebar": {