web-manager 4.1.2 → 4.1.3

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 CHANGED
@@ -354,6 +354,35 @@ unsubscribe();
354
354
  Add these classes to elements for automatic auth functionality:
355
355
  - `.auth-signout-btn` - Sign out button (shows confirmation dialog)
356
356
 
357
+ **⚠️ Auth State Timing**:
358
+
359
+ On fresh page loads, Firebase Auth needs time to restore the user session from IndexedDB/localStorage. Methods like `auth.isAuthenticated()`, `auth.getUser()`, and `auth.getIdToken()` may return `null`/`false` if called before auth state is determined.
360
+
361
+ **Problem:**
362
+ ```javascript
363
+ // ❌ May fail on page load - auth state not yet determined
364
+ await Manager.dom().ready();
365
+ const token = await auth.getIdToken(); // Could throw if currentUser is null
366
+ ```
367
+
368
+ **Solution:** Use `auth.listen({ once: true })` to wait for auth state:
369
+ ```javascript
370
+ // ✅ Wait for auth state to be determined first
371
+ auth.listen({ once: true }, async (result) => {
372
+ if (result.user) {
373
+ const token = await auth.getIdToken(); // Safe - user is authenticated
374
+ }
375
+ });
376
+ ```
377
+
378
+ **When this matters:**
379
+ - Pages making authenticated API calls immediately on load
380
+ - OAuth callback pages
381
+ - Deep links requiring authentication
382
+
383
+ **When NOT needed:**
384
+ - User-triggered actions (button clicks) - auth state is always determined by then
385
+
357
386
  ### Data Binding System
358
387
 
359
388
  Reactive DOM updates with `data-wm-bind` attributes:
@@ -81,8 +81,8 @@ class Utilities {
81
81
  const timeout = options.timeout !== undefined ? options.timeout : 5000;
82
82
 
83
83
  const $notification = document.createElement('div');
84
- $notification.className = `alert alert-${type} alert-dismissible fade show position-fixed top-0 start-50 translate-middle-x mt-5`;
85
- $notification.style.zIndex = '9999';
84
+ $notification.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
85
+ $notification.style.cssText = 'z-index: 9999; top: 1rem; left: 50%; transform: translateX(-50%);';
86
86
  $notification.innerHTML = `
87
87
  ${text}
88
88
  <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
@@ -137,22 +137,27 @@ class Utilities {
137
137
  if (/edg/i.test(ua)) {
138
138
  return 'edge';
139
139
  }
140
+
140
141
  // Opera before Chrome (Opera includes "Chrome" in UA)
141
142
  if (/opera|opr/i.test(ua)) {
142
143
  return 'opera';
143
144
  }
145
+
144
146
  // Brave before Chrome (Brave includes "Chrome" in UA)
145
147
  if (navigator.brave || /brave/i.test(ua)) {
146
148
  return 'brave';
147
149
  }
150
+
148
151
  // Chrome (including Chromium-based browsers)
149
152
  if (/chrome|chromium|crios/i.test(ua)) {
150
153
  return 'chrome';
151
154
  }
155
+
152
156
  // Firefox
153
157
  if (/firefox|fxios/i.test(ua)) {
154
158
  return 'firefox';
155
159
  }
160
+
156
161
  // Safari last (most browsers include "Safari" in UA)
157
162
  if (/safari/i.test(ua)) {
158
163
  return 'safari';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",