@marsaude/devtools-shell 0.1.3 → 0.1.5

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.
@@ -641,7 +641,7 @@ const DEVTOOLS_CONFIG = new InjectionToken('DEVTOOLS_CONFIG');
641
641
  /**
642
642
  * Plain localStorage wrapper owned by the package. DevTools-internal keys are
643
643
  * prefixed `DEVTOOLS_`; the *active app session* keys (`JWT_TOKEN`,
644
- * `JWT_REFRESH_TOKEN`, `APP_USER`) are written deliberately so the host patient
644
+ * `JWT_REFRESH_TOKEN`, `EGRET_USER`) are written deliberately so the host patient
645
645
  * app consumes them — that is the only intentional touch-point with the host.
646
646
  */
647
647
  class DevtoolsStorage {
@@ -1562,10 +1562,11 @@ const devtoolsHttpInterceptor = (req, next) => {
1562
1562
  const SESSIONS_KEY = 'DEVTOOLS_SESSIONS';
1563
1563
  const ACTIVE_KEY = 'DEVTOOLS_ACTIVE';
1564
1564
  // The active app session — read by the HOST patient app. This is the ONE
1565
- // intentional touch-point with the host.
1565
+ // intentional touch-point with the host, so these keys MUST match the host's
1566
+ // JwtAuthService exactly and must never change.
1566
1567
  const JWT_TOKEN = 'JWT_TOKEN';
1567
1568
  const JWT_REFRESH_TOKEN = 'JWT_REFRESH_TOKEN';
1568
- const APP_USER = 'APP_USER';
1569
+ const APP_USER = 'EGRET_USER';
1569
1570
  /**
1570
1571
  * Manages the *active app session* that the host patient app consumes, letting
1571
1572
  * the QA switch it between the fixed admin (the DevTools identity) and any saved
@@ -1601,7 +1602,12 @@ class DevtoolsSessionService {
1601
1602
  this.storage.set(SESSIONS_KEY, next);
1602
1603
  return full;
1603
1604
  }
1604
- /** Write a stored session into the host's active-session keys. */
1605
+ /**
1606
+ * Write a stored session into the host's active-session keys and send the user
1607
+ * to '/' (full navigation) so the host app re-reads it from a clean route — it
1608
+ * only reads these keys at bootstrap. Covers both a fresh login and switching
1609
+ * between users.
1610
+ */
1605
1611
  switchTo(id) {
1606
1612
  const session = id === 'admin' ? this.admin() : this._sessions().find((s) => s.id === id) ?? null;
1607
1613
  if (!session)
@@ -1611,6 +1617,12 @@ class DevtoolsSessionService {
1611
1617
  this.storage.set(APP_USER, session.profile ?? null);
1612
1618
  this.activeId.set(id);
1613
1619
  this.storage.set(ACTIVE_KEY, id);
1620
+ try {
1621
+ window.location.href = '/';
1622
+ }
1623
+ catch {
1624
+ /* non-browser env — ignore */
1625
+ }
1614
1626
  return session;
1615
1627
  }
1616
1628
  removeSession(id) {