@pylonsync/sync 0.3.142 → 0.3.144
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/package.json +1 -1
- package/src/index.ts +27 -9
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1113,6 +1113,19 @@ export class SyncEngine {
|
|
|
1113
1113
|
return;
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
|
+
// Session mutated server-side. Fires for select-org / clear-org
|
|
1117
|
+
// / session revoke — every tab connected as this user gets the
|
|
1118
|
+
// envelope (cross-machine too via the cluster bus). Trigger
|
|
1119
|
+
// a fresh /api/auth/me read which updates the cached session
|
|
1120
|
+
// AND, on tenant flip, resets the replica so stale rows from
|
|
1121
|
+
// the previous tenant disappear. App code calling
|
|
1122
|
+
// /api/auth/select-org via raw fetch no longer needs the
|
|
1123
|
+
// manual `notifySessionChanged()` step.
|
|
1124
|
+
if (msg.type === "session-changed") {
|
|
1125
|
+
void this.refreshResolvedSession();
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1116
1129
|
// Reactive query push: the server-side ReactiveRegistry re-ran
|
|
1117
1130
|
// a subscribed handler and the result hash changed. Route to
|
|
1118
1131
|
// the handler registered by `subscribeReactive` so the React
|
|
@@ -1679,16 +1692,21 @@ export class SyncEngine {
|
|
|
1679
1692
|
}
|
|
1680
1693
|
|
|
1681
1694
|
/**
|
|
1682
|
-
* Public alias for `refreshResolvedSession`.
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1695
|
+
* Public alias for `refreshResolvedSession`. Almost never needed by
|
|
1696
|
+
* app code today — the server pushes a `session-changed` envelope
|
|
1697
|
+
* over WS whenever the session is mutated (select-org, clear-org,
|
|
1698
|
+
* session revoke, even from other tabs / admin tools / server
|
|
1699
|
+
* actions), and the engine's WS handler refreshes automatically.
|
|
1700
|
+
*
|
|
1701
|
+
* Kept as an escape hatch for the rare case where you mutated the
|
|
1702
|
+
* session via a path that doesn't go through the framework's auth
|
|
1703
|
+
* surface (e.g. directly writing to the SessionStore from a Rust
|
|
1704
|
+
* plugin that bypassed `notify_session_changed`).
|
|
1686
1705
|
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1689
|
-
*
|
|
1690
|
-
*
|
|
1691
|
-
* escape hatch for code that talks to /api/auth/* via its own client.
|
|
1706
|
+
* The `selectOrg` / `clearOrg` / `signOut` helpers below remain as
|
|
1707
|
+
* convenience wrappers that combine the HTTP call with an immediate
|
|
1708
|
+
* local refresh — useful when the same tab needs the new state
|
|
1709
|
+
* before the WS round-trip lands.
|
|
1692
1710
|
*/
|
|
1693
1711
|
notifySessionChanged(): Promise<void> {
|
|
1694
1712
|
return this.refreshResolvedSession();
|