@palbase/web 1.8.0 → 1.9.0
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/{analytics-facade-DfJ420F5.d.cts → analytics-facade-DFd5LB3_.d.cts} +17 -4
- package/dist/{analytics-facade-CgURkjpP.d.ts → analytics-facade-DsvKx5A5.d.ts} +17 -4
- package/dist/{chunk-AWVNDAMG.js → chunk-I3ZMB7XM.js} +33 -6
- package/dist/chunk-I3ZMB7XM.js.map +1 -0
- package/dist/index.cjs +31 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internal.cjs +32 -5
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +1 -1
- package/dist/next/client.cjs +32 -5
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +32 -5
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +2 -2
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +1 -1
- package/dist/{pb-C1v9ErPy.d.ts → pb-CDVMy1l1.d.ts} +1 -1
- package/dist/{pb-BwQwp411.d.cts → pb-D_fuhafL.d.cts} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AWVNDAMG.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -489,6 +489,8 @@ var PalbeAuth = class {
|
|
|
489
489
|
// suppresses AuthClient's TOKEN_REFRESHED during re-signIn
|
|
490
490
|
signedInState = false;
|
|
491
491
|
// dedupes AuthClient's repeated SIGNED_OUT events
|
|
492
|
+
hydratingUser = false;
|
|
493
|
+
// guards hydrateUser() to a single boot fetch
|
|
492
494
|
stateListeners = /* @__PURE__ */ new Set();
|
|
493
495
|
eventListeners = /* @__PURE__ */ new Set();
|
|
494
496
|
userListeners = /* @__PURE__ */ new Set();
|
|
@@ -541,13 +543,37 @@ var PalbeAuth = class {
|
|
|
541
543
|
if (changed) for (const cb of this.userListeners) this.safeInvoke(() => cb(user));
|
|
542
544
|
return user;
|
|
543
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Restore the user after a session was rehydrated from storage (page reload).
|
|
548
|
+
* Hydration in buildRuntime restores the TOKENS synchronously, but the access
|
|
549
|
+
* token JWT does not carry emailVerified/createdAt, so the full AuthUser can't
|
|
550
|
+
* be reconstructed offline — this fetches GET /auth/user once and announces
|
|
551
|
+
* `signedIn`, so the app no longer has to `await pb.auth.refreshUser()` itself
|
|
552
|
+
* on boot. Idempotent (runs once), browser-safe (no-op when not signed in or
|
|
553
|
+
* a user is already cached), and never throws (a boot-time network failure
|
|
554
|
+
* must not break app startup — isSignedIn stays true, the app can retry).
|
|
555
|
+
*/
|
|
556
|
+
hydrateUser() {
|
|
557
|
+
if (this.hydratingUser || this.cachedUser || !this.isSignedIn) return;
|
|
558
|
+
this.hydratingUser = true;
|
|
559
|
+
void this.refreshUser().then((user) => {
|
|
560
|
+
if (this.isSignedIn) {
|
|
561
|
+
this.signedInState = true;
|
|
562
|
+
this.emitState({ status: "signedIn", user });
|
|
563
|
+
}
|
|
564
|
+
}).catch(() => {
|
|
565
|
+
}).finally(() => {
|
|
566
|
+
this.hydratingUser = false;
|
|
567
|
+
});
|
|
568
|
+
}
|
|
544
569
|
// ── listeners ──────────────────────────────────────────
|
|
545
570
|
/**
|
|
546
571
|
* Subscribe to signed-in/signed-out state. Fires immediately with the
|
|
547
|
-
* current snapshot (iOS parity).
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
572
|
+
* current snapshot (iOS parity). A restored session (page reload) hydrates
|
|
573
|
+
* the user asynchronously via `hydrateUser()` (fired once at boot), so the
|
|
574
|
+
* FIRST snapshot may report signedOut for a tick even when `isSignedIn` is
|
|
575
|
+
* true; the listener then fires again with `signedIn` once the user lands.
|
|
576
|
+
* Rely on `isSignedIn` for the session truth if you need it synchronously.
|
|
551
577
|
*/
|
|
552
578
|
onAuthStateChange(callback) {
|
|
553
579
|
this.stateListeners.add(callback);
|
|
@@ -7557,7 +7583,7 @@ function localStorageSessionStorage(key = DEFAULT_KEY) {
|
|
|
7557
7583
|
}
|
|
7558
7584
|
|
|
7559
7585
|
// src/version.ts
|
|
7560
|
-
var VERSION = "1.
|
|
7586
|
+
var VERSION = "1.9.0";
|
|
7561
7587
|
|
|
7562
7588
|
// src/internal.ts
|
|
7563
7589
|
function getRuntime() {
|