cursedauth 0.1.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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/account/AccountMenu.d.ts +153 -0
- package/dist/account/AccountMenu.d.ts.map +1 -0
- package/dist/account/AccountMenu.js +388 -0
- package/dist/account/AccountMenu.js.map +1 -0
- package/dist/account/AccountNotice.d.ts +35 -0
- package/dist/account/AccountNotice.d.ts.map +1 -0
- package/dist/account/AccountNotice.js +133 -0
- package/dist/account/AccountNotice.js.map +1 -0
- package/dist/account/accountNotice.state.d.ts +20 -0
- package/dist/account/accountNotice.state.d.ts.map +1 -0
- package/dist/account/accountNotice.state.js +55 -0
- package/dist/account/accountNotice.state.js.map +1 -0
- package/dist/account/avatar.d.ts +37 -0
- package/dist/account/avatar.d.ts.map +1 -0
- package/dist/account/avatar.js +47 -0
- package/dist/account/avatar.js.map +1 -0
- package/dist/accountSlot.client.d.ts +113 -0
- package/dist/accountSlot.client.d.ts.map +1 -0
- package/dist/accountSlot.client.js +330 -0
- package/dist/accountSlot.client.js.map +1 -0
- package/dist/accountSlots.d.ts +192 -0
- package/dist/accountSlots.d.ts.map +1 -0
- package/dist/accountSlots.js +274 -0
- package/dist/accountSlots.js.map +1 -0
- package/dist/auth.d.ts +167 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +310 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.server.d.ts +35 -0
- package/dist/auth.server.d.ts.map +1 -0
- package/dist/auth.server.js +67 -0
- package/dist/auth.server.js.map +1 -0
- package/dist/clientDescription.d.ts +186 -0
- package/dist/clientDescription.d.ts.map +1 -0
- package/dist/clientDescription.js +278 -0
- package/dist/clientDescription.js.map +1 -0
- package/dist/constantTime.d.ts +35 -0
- package/dist/constantTime.d.ts.map +1 -0
- package/dist/constantTime.js +46 -0
- package/dist/constantTime.js.map +1 -0
- package/dist/contentCensus.d.ts +59 -0
- package/dist/contentCensus.d.ts.map +1 -0
- package/dist/contentCensus.js +55 -0
- package/dist/contentCensus.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/mountGatedApp.d.ts +128 -0
- package/dist/mountGatedApp.d.ts.map +1 -0
- package/dist/mountGatedApp.js +107 -0
- package/dist/mountGatedApp.js.map +1 -0
- package/dist/runtimeMode.d.ts +28 -0
- package/dist/runtimeMode.d.ts.map +1 -0
- package/dist/runtimeMode.js +37 -0
- package/dist/runtimeMode.js.map +1 -0
- package/dist/secureRequest.d.ts +22 -0
- package/dist/secureRequest.d.ts.map +1 -0
- package/dist/secureRequest.js +27 -0
- package/dist/secureRequest.js.map +1 -0
- package/dist/sso.d.ts +373 -0
- package/dist/sso.d.ts.map +1 -0
- package/dist/sso.js +420 -0
- package/dist/sso.js.map +1 -0
- package/dist/ssoAutoSignIn.d.ts +272 -0
- package/dist/ssoAutoSignIn.d.ts.map +1 -0
- package/dist/ssoAutoSignIn.js +431 -0
- package/dist/ssoAutoSignIn.js.map +1 -0
- package/dist/ssoConsumer.server.d.ts +295 -0
- package/dist/ssoConsumer.server.d.ts.map +1 -0
- package/dist/ssoConsumer.server.js +972 -0
- package/dist/ssoConsumer.server.js.map +1 -0
- package/dist/stageIdentity.d.ts +72 -0
- package/dist/stageIdentity.d.ts.map +1 -0
- package/dist/stageIdentity.js +74 -0
- package/dist/stageIdentity.js.map +1 -0
- package/dist/ui/popover.d.ts +190 -0
- package/dist/ui/popover.d.ts.map +1 -0
- package/dist/ui/popover.js +351 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/userSessions.d.ts +205 -0
- package/dist/userSessions.d.ts.map +1 -0
- package/dist/userSessions.js +419 -0
- package/dist/userSessions.js.map +1 -0
- package/package.json +115 -0
- package/src/account/AccountMenu.tsx +729 -0
- package/src/account/AccountNotice.tsx +223 -0
- package/src/account/accountNotice.state.ts +66 -0
- package/src/account/avatar.ts +50 -0
- package/src/accountSlot.client.ts +362 -0
- package/src/accountSlots.ts +305 -0
- package/src/auth.server.ts +89 -0
- package/src/auth.ts +515 -0
- package/src/clientDescription.ts +366 -0
- package/src/constantTime.ts +45 -0
- package/src/contentCensus.ts +106 -0
- package/src/index.ts +58 -0
- package/src/mountGatedApp.ts +240 -0
- package/src/runtimeMode.ts +37 -0
- package/src/secureRequest.ts +25 -0
- package/src/sso.ts +767 -0
- package/src/ssoAutoSignIn.ts +544 -0
- package/src/ssoConsumer.server.ts +1260 -0
- package/src/stageIdentity.ts +76 -0
- package/src/ui/popover.ts +390 -0
- package/src/userSessions.ts +678 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The account menu every satellite puts in its header — who you are, and the
|
|
4
|
+
* three things you can do about it.
|
|
5
|
+
*
|
|
6
|
+
* ── Why it exists (2026-08-10, owner report) ────────────────────────────────
|
|
7
|
+
* "I logged out for someone to log in and there wasn't a way to change users."
|
|
8
|
+
* Both halves of that were true, and neither was one app's bug:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Sign out did not sign you out.** Every app ended its OWN cookie and
|
|
11
|
+
* stopped there; auth's session outlived it. The next press of "Sign in" —
|
|
12
|
+
* or the automatic hop on the next page load — traded that surviving
|
|
13
|
+
* session for a fresh grant and returned the SAME person, with no password
|
|
14
|
+
* asked for. There was no sequence of clicks that made a satellite forget
|
|
15
|
+
* you.
|
|
16
|
+
* 2. **Nothing offered to change users.** Even reaching the accounts app by
|
|
17
|
+
* hand did not help: `/sso/authorize` had exactly one answer for a browser
|
|
18
|
+
* with a live session, and it was a grant for that session's user.
|
|
19
|
+
*
|
|
20
|
+
* The fix is one door at each end — `?switch=1` → `prompt=login` at authorize,
|
|
21
|
+
* and `/api/auth/sso/signout` → `/sso/logout` for a sign-out that reaches
|
|
22
|
+
* auth's own session — and THIS is the thing that puts them in front of a
|
|
23
|
+
* person. Eight apps had hand-rolled a name-and-a-dropdown by then, all
|
|
24
|
+
* slightly differently and all with the same two gaps, which is why the menu
|
|
25
|
+
* itself is now shared rather than each app growing two more buttons.
|
|
26
|
+
*
|
|
27
|
+
* ── Why it ships its own stylesheet ─────────────────────────────────────────
|
|
28
|
+
* Same reason as `FleetDirectory`, which it sits beside in every header: the
|
|
29
|
+
* satellites keep per-app Tailwind `@source` lists, so a widget from this
|
|
30
|
+
* package styled with utility classes renders correctly in whichever apps
|
|
31
|
+
* remembered to add a line and silently unstyled in the rest. The machinery is
|
|
32
|
+
* shared with the directory (`../ui/popover`) so the two cannot drift into
|
|
33
|
+
* different ideas of dark mode, or dismiss differently, 8px apart.
|
|
34
|
+
*/
|
|
35
|
+
import { lazy, Suspense, useEffect, useState } from "react";
|
|
36
|
+
import { createPortal } from "react-dom";
|
|
37
|
+
import { accountWindowUrl, currentAccountSlot, setExpectedAccount, slotUrl, } from "../accountSlot.client";
|
|
38
|
+
import { startSsoSignIn, startSsoSignOut } from "../ssoAutoSignIn";
|
|
39
|
+
import { useHostDark, useInjectedStyles, usePopover, useScrim } from "../ui/popover";
|
|
40
|
+
import { useAccountNotice } from "./accountNotice.state";
|
|
41
|
+
/**
|
|
42
|
+
* 🔴 LAZY, and that is a byte budget rather than a preference. The banner carries
|
|
43
|
+
* a ~4 KB scoped stylesheet and renders nothing until an account goes wrong, so
|
|
44
|
+
* importing it directly here put it in nineteen apps' ENTRY chunks —
|
|
45
|
+
* `test:gates:artifacts` caught it as `notes` at 581.07 KB against 578. The
|
|
46
|
+
* WATCHING stays eager (`useAccountNotice`), because a component that is not
|
|
47
|
+
* mounted cannot hear the event that would make it appear; only the markup and
|
|
48
|
+
* the styles wait. `Suspense` falls back to nothing: there is no spinner worth
|
|
49
|
+
* showing for a banner nobody asked for.
|
|
50
|
+
*/
|
|
51
|
+
const AccountNotice = lazy(() => import("./AccountNotice").then((m) => ({ default: m.AccountNotice })));
|
|
52
|
+
import { accountAvatarUrl, accountInitials } from "./avatar";
|
|
53
|
+
const STYLE_ID = "sam-style";
|
|
54
|
+
/** The popover's ideal width in px, matching `min(17rem, …)` in {@link STYLES}
|
|
55
|
+
* below — see `anchoredLeft` in `../ui/popover` for why the real number has to
|
|
56
|
+
* be known in JS and not only in CSS.
|
|
57
|
+
*
|
|
58
|
+
* 🔴 It said 240 while the stylesheet had been widened to 17rem, and the
|
|
59
|
+
* comment above it still named the old 15rem. The off-screen clamp is
|
|
60
|
+
* arithmetic over THIS number, so it reserved 240px for a 272px panel and
|
|
61
|
+
* pushed the last 32px of the account menu off the right edge of every screen
|
|
62
|
+
* — the exact defect the clamp exists to prevent, hiding behind a comment that
|
|
63
|
+
* described a width the CSS no longer had. Exported, with {@link STYLES}, so
|
|
64
|
+
* `../ui/panelWidth.test.ts` can assert the two against each other instead of
|
|
65
|
+
* a sentence here promising they match. */
|
|
66
|
+
export const PANEL_WIDTH = 272;
|
|
67
|
+
export const STYLES = `
|
|
68
|
+
.sam{--sam-panel:#ffffff;--sam-border:#d9dde3;--sam-text:#1a1d21;--sam-muted:#68707c;
|
|
69
|
+
--sam-hover:#f2f4f7;--sam-danger:#b42318;--sam-accent:#4f6ef7;--sam-shadow:0 12px 32px rgba(16,18,22,.16);
|
|
70
|
+
font:14px/1.5 ui-sans-serif,system-ui,-apple-system,sans-serif;color:var(--sam-text)}
|
|
71
|
+
.sam[data-dark="true"]{--sam-panel:#181b21;--sam-border:#2c313a;--sam-text:#e6e9ee;--sam-muted:#8b93a1;
|
|
72
|
+
--sam-hover:#22262e;--sam-danger:#f97066;--sam-accent:#7f97ff;--sam-shadow:0 12px 32px rgba(0,0,0,.5)}
|
|
73
|
+
/* 🔴 \`min-width:0\` is what makes \`.sam-who\`'s ellipsis (below) REACHABLE, and
|
|
74
|
+
without it that rule is dead CSS — measured on live roms, 2026-09-08.
|
|
75
|
+
|
|
76
|
+
A flex item's \`min-width\` defaults to \`auto\`, i.e. its min-content width, and
|
|
77
|
+
\`.sam-who\` is \`white-space:nowrap\` — so the launcher's min-content size is the
|
|
78
|
+
WHOLE name, however long. Flex could not shrink it, the name never truncated,
|
|
79
|
+
and the launcher simply overflowed its slot. Where it overflowed was decided by
|
|
80
|
+
the host header's \`justify-content\`: roms right-aligns its account controls, so
|
|
81
|
+
the overflow travelled LEFT and painted the account button on top of the app
|
|
82
|
+
title — 79px of overlap at 320px, 39px at 360px, and the button's own avatar
|
|
83
|
+
starting at x=-26, off the side of the screen. \`document.scrollWidth\` was
|
|
84
|
+
unchanged throughout, which is why nothing anywhere reported it: the row does
|
|
85
|
+
not push the page wide, it collides inside itself.
|
|
86
|
+
|
|
87
|
+
With these two declarations the ellipsis finally does its job — the name gives
|
|
88
|
+
up as much width as the row needs and gives up the last of it entirely, leaving
|
|
89
|
+
the avatar and its caret, which is the right phone-shaped answer for an account
|
|
90
|
+
control anyway. Nothing changes at a width that already fit (measured: 430px
|
|
91
|
+
identical before and after), because flex only shrinks an item that has to.
|
|
92
|
+
\`max-width:100%\` keeps the wrapper from being the new floor now that the
|
|
93
|
+
launcher inside it can shrink.
|
|
94
|
+
|
|
95
|
+
The header that found it asserts the outcome rather than this mechanism —
|
|
96
|
+
apps/roms/__smoke/headerFit.spec.ts, which measures real boxes in a real
|
|
97
|
+
browser at four phone widths. It is the only kind of check that can see this. */
|
|
98
|
+
.sam-wrap{position:relative;display:inline-block;min-width:0;max-width:100%}
|
|
99
|
+
.sam-launch{display:inline-flex;align-items:center;gap:7px;max-width:min(14rem,100%);height:34px;
|
|
100
|
+
min-width:0;padding:0 8px 0 4px;
|
|
101
|
+
border:1px solid transparent;border-radius:999px;background:transparent;color:inherit;cursor:pointer;
|
|
102
|
+
font:inherit;font-size:13px}
|
|
103
|
+
@media (pointer:coarse){.sam-launch{height:44px}}
|
|
104
|
+
/* The circle. --sam-av is the ONE size knob: the ring, the glyph and the initials all
|
|
105
|
+
derive from it, so the launcher and the panel head cannot drift apart. */
|
|
106
|
+
.sam-av{--sam-av:26px;flex:none;display:inline-flex;align-items:center;justify-content:center;
|
|
107
|
+
width:var(--sam-av);height:var(--sam-av);border-radius:50%;overflow:hidden;
|
|
108
|
+
background:color-mix(in srgb,var(--sam-accent,#4f6ef7) 16%,transparent);
|
|
109
|
+
color:var(--sam-accent,#4f6ef7);font-size:calc(var(--sam-av) * .42);font-weight:650;
|
|
110
|
+
line-height:1;letter-spacing:.02em;user-select:none}
|
|
111
|
+
.sam-av img{width:100%;height:100%;object-fit:cover;display:block}
|
|
112
|
+
.sam-head .sam-av{--sam-av:40px}
|
|
113
|
+
.sam-launch:hover,.sam-launch[aria-expanded="true"]{background:var(--sam-hover);border-color:var(--sam-border)}
|
|
114
|
+
/* \`min-width:0\` for the same reason as \`.sam-launch\` above, one level down: this
|
|
115
|
+
is itself a flex item, so its \`auto\` minimum is the un-wrappable name and the
|
|
116
|
+
ellipsis below it could never fire. All three levels of the chain have to
|
|
117
|
+
allow shrinking or none of them does — the launcher stops overflowing its
|
|
118
|
+
header while the LABEL goes on overflowing the launcher, which is a collision
|
|
119
|
+
that has merely moved one control to the right. Measured: the first attempt at
|
|
120
|
+
this fix did exactly that, and headerFit.spec.ts is what said so. */
|
|
121
|
+
.sam-who{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
122
|
+
.sam-caret{flex:none;opacity:.6;font-size:10px}
|
|
123
|
+
/* 🔴 \`left\` and \`top\` are BOTH set inline by usePopoverPosition, and the panel
|
|
124
|
+
is PORTALED to <body> — see \`anchoredTop\`. \`fixed\` because the panel is no
|
|
125
|
+
longer inside the launcher, and NO default \`top\`, because a hardcoded
|
|
126
|
+
"always below" is what put the fleet launcher's panel off the bottom of the
|
|
127
|
+
screen (E22, 2026-09-09). This menu shares the control, so it shares the fix. */
|
|
128
|
+
.sam-pop{position:fixed;right:auto;z-index:2147482000;width:min(17rem,calc(100vw - 32px));
|
|
129
|
+
background:var(--sam-panel);border:1px solid var(--sam-border);border-radius:12px;box-shadow:var(--sam-shadow);
|
|
130
|
+
padding:6px;display:flex;flex-direction:column;gap:1px}
|
|
131
|
+
.sam-head{display:flex;align-items:center;gap:10px;padding:8px 8px 10px;
|
|
132
|
+
border-bottom:1px solid var(--sam-border);margin-bottom:5px}
|
|
133
|
+
.sam-head-text{min-width:0;flex:1}
|
|
134
|
+
.sam-name{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
135
|
+
.sam-sub{font-size:11.5px;color:var(--sam-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
136
|
+
/* 🔴 44px, the designer's number for a menu row (2026-08-19). display:flex rather
|
|
137
|
+
than block so the min-height actually centres the label instead of leaving it
|
|
138
|
+
glued to the top of a taller box. */
|
|
139
|
+
.sam-item{display:flex;align-items:center;width:100%;min-height:44px;text-align:left;
|
|
140
|
+
padding:7px 10px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;
|
|
141
|
+
font-size:13px;cursor:pointer;text-decoration:none}
|
|
142
|
+
.sam-item:hover{background:var(--sam-hover)}
|
|
143
|
+
.sam-item[data-tone="danger"]{color:var(--sam-danger)}
|
|
144
|
+
.sam-hint{font-size:11px;color:var(--sam-muted);padding:1px 8px 4px}
|
|
145
|
+
.sam-rule{height:1px;background:var(--sam-border);margin:5px 0}
|
|
146
|
+
.sam-label{font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;
|
|
147
|
+
color:var(--sam-muted);padding:4px 8px 3px}
|
|
148
|
+
/* One row per other account: a big target that SWITCHES, plus a small one that
|
|
149
|
+
opens a second window. Grid rather than flex so the switch button gets every
|
|
150
|
+
pixel the open button does not, and long addresses ellipsize instead of
|
|
151
|
+
pushing the ⧉ off the panel. */
|
|
152
|
+
.sam-acct{display:grid;grid-template-columns:1fr auto;align-items:stretch;gap:1px;border-radius:8px}
|
|
153
|
+
.sam-acct:hover{background:var(--sam-hover)}
|
|
154
|
+
.sam-acct .sam-item{display:block;border-radius:8px 0 0 8px;padding-top:6px;padding-bottom:6px}
|
|
155
|
+
.sam-acct-who{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
156
|
+
.sam-acct-sub{display:block;font-size:11px;color:var(--sam-muted);overflow:hidden;
|
|
157
|
+
text-overflow:ellipsis;white-space:nowrap}
|
|
158
|
+
.sam-open{flex:none;width:44px;border:0;border-radius:0 8px 8px 0;background:transparent;
|
|
159
|
+
color:var(--sam-muted);cursor:pointer;font:inherit;font-size:13px}
|
|
160
|
+
.sam-open:hover{background:var(--sam-hover);color:var(--sam-text)}
|
|
161
|
+
.sam-badge{font-size:10px;font-weight:600;color:var(--sam-muted);border:1px solid var(--sam-border);
|
|
162
|
+
border-radius:5px;padding:0 4px;margin-left:6px;vertical-align:1px}
|
|
163
|
+
`;
|
|
164
|
+
const SESSION_PATH = "/api/auth/session";
|
|
165
|
+
/**
|
|
166
|
+
* The accounts this browser holds, fetched once per menu opening.
|
|
167
|
+
*
|
|
168
|
+
* Never throws and never renders an error: a switcher that cannot list the
|
|
169
|
+
* other accounts degrades to the menu that shipped before it existed, which is
|
|
170
|
+
* a working menu. There is nothing here worth interrupting somebody over —
|
|
171
|
+
* they came to press "Sign out".
|
|
172
|
+
*/
|
|
173
|
+
/**
|
|
174
|
+
* One in-flight request per path per page, shared by every instance.
|
|
175
|
+
*
|
|
176
|
+
* The menu reads the session at MOUNT now (it used to wait for the panel to open) because
|
|
177
|
+
* the profile picture is drawn in the CLOSED launcher — a menu that learns who it belongs
|
|
178
|
+
* to only once you click it would paint initials and then swap to a face. A module-level
|
|
179
|
+
* cache is what keeps that from becoming N requests when a page renders the menu twice.
|
|
180
|
+
*/
|
|
181
|
+
const sessionProbes = new Map();
|
|
182
|
+
/**
|
|
183
|
+
* Forget what the probe learned.
|
|
184
|
+
*
|
|
185
|
+
* Exported for tests, and named for what it is rather than hidden behind an underscore:
|
|
186
|
+
* a page-lifetime cache is correct in a browser (the session can only change through a
|
|
187
|
+
* navigation, which remounts everything) and wrong in a test file, where ten renders share
|
|
188
|
+
* one module. Without this, the second test's fetch mock is never called and its
|
|
189
|
+
* assertions wait on the FIRST test's answer.
|
|
190
|
+
*/
|
|
191
|
+
export function resetAccountSessionProbe() {
|
|
192
|
+
sessionProbes.clear();
|
|
193
|
+
}
|
|
194
|
+
function probeSession(path) {
|
|
195
|
+
const existing = sessionProbes.get(path);
|
|
196
|
+
if (existing)
|
|
197
|
+
return existing;
|
|
198
|
+
const probe = fetch(path, { credentials: "same-origin" })
|
|
199
|
+
.then((res) => (res.ok ? res.json() : null))
|
|
200
|
+
.catch(() => null);
|
|
201
|
+
sessionProbes.set(path, probe);
|
|
202
|
+
return probe;
|
|
203
|
+
}
|
|
204
|
+
function useBrowserAccounts(sessionPath, provided, providedUserId) {
|
|
205
|
+
const [fetched, setFetched] = useState(null);
|
|
206
|
+
// Nothing left to learn: the caller handed over both halves.
|
|
207
|
+
const complete = Boolean(provided && providedUserId);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (complete)
|
|
210
|
+
return;
|
|
211
|
+
let live = true;
|
|
212
|
+
void probeSession(sessionPath).then((body) => {
|
|
213
|
+
if (live && body)
|
|
214
|
+
setFetched(body);
|
|
215
|
+
});
|
|
216
|
+
return () => {
|
|
217
|
+
live = false;
|
|
218
|
+
};
|
|
219
|
+
}, [complete, sessionPath]);
|
|
220
|
+
return {
|
|
221
|
+
accounts: provided ?? fetched?.accounts ?? [],
|
|
222
|
+
// The tab is the authority on its own slot; the server's answer is only a
|
|
223
|
+
// fallback for a tab that has not installed the client module.
|
|
224
|
+
slot: currentAccountSlot() || (fetched?.slot ?? 0),
|
|
225
|
+
slotsFull: fetched?.slotsFull ?? false,
|
|
226
|
+
...((providedUserId ?? fetched?.user?.id)
|
|
227
|
+
? { userId: providedUserId ?? fetched?.user?.id }
|
|
228
|
+
: {}),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* One picture fetch per URL per page, shared by every instance — the launcher and the panel
|
|
233
|
+
* head are two `AccountAvatar`s of the same person.
|
|
234
|
+
*/
|
|
235
|
+
const pictureProbes = new Map();
|
|
236
|
+
/** Forget the fetched pictures. Exported for the same reason as its session sibling. */
|
|
237
|
+
export function resetAccountPictureProbe() {
|
|
238
|
+
pictureProbes.clear();
|
|
239
|
+
}
|
|
240
|
+
function probePicture(src) {
|
|
241
|
+
const existing = pictureProbes.get(src);
|
|
242
|
+
if (existing)
|
|
243
|
+
return existing;
|
|
244
|
+
const probe = fetch(src, { cache: "no-cache" })
|
|
245
|
+
// 🔴 A NON-EMPTY blob, not `res.ok`. "This account has no picture" answers **204**
|
|
246
|
+
// (see `apps/auth/src/server/avatars.ts`: a 404 is a browser console line on every
|
|
247
|
+
// signed-in page in the fleet), and 204 is `ok` with a zero-byte body. Reading `ok`
|
|
248
|
+
// here would mint an object URL for nothing and draw a broken circle.
|
|
249
|
+
.then((res) => (res.status === 200 ? res.blob() : null))
|
|
250
|
+
.then((blob) => (blob && blob.size > 0 ? blob : null))
|
|
251
|
+
.catch(() => null);
|
|
252
|
+
pictureProbes.set(src, probe);
|
|
253
|
+
return probe;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The circle: the account's picture, or its initials.
|
|
257
|
+
*
|
|
258
|
+
* 🔴 It FETCHES the bytes rather than pointing an `<img>` at them, and that is not a style
|
|
259
|
+
* choice — it is what a browser smoke found on the first deploy (2026-08-22). Most accounts
|
|
260
|
+
* have no picture, and back then `GET /avatar/:id` answered **404** for those: a 404 on an
|
|
261
|
+
* `<img>` is a `Failed to load resource` in the console **on every signed-in page of every
|
|
262
|
+
* app in the fleet**. `routeCheck` fails a route that logs a console error, correctly, so
|
|
263
|
+
* nine of life's nine signed-in routes went red at once.
|
|
264
|
+
*
|
|
265
|
+
* That route has answered **204** since 2026-08-22 (`apps/auth/src/server/avatars.ts`), so
|
|
266
|
+
* the 404 above is HISTORY — but the fetch is not. A 204 is silent for a `fetch` and is
|
|
267
|
+
* `net::ERR_ABORTED` for an `<img>`, which cannot decode a zero-byte body. So the server's
|
|
268
|
+
* status and this client's fetch are two halves of ONE decision, and changing either half
|
|
269
|
+
* alone re-opens the bug in the other. `AccountMenu.test.tsx` pins both halves.
|
|
270
|
+
*
|
|
271
|
+
* The response is `no-cache` with an ETag, so this is one conditional request per page that
|
|
272
|
+
* usually answers 304 — and changing your picture shows up everywhere on the next load
|
|
273
|
+
* rather than whenever a max-age happened to run out.
|
|
274
|
+
*/
|
|
275
|
+
function AccountAvatar({ name, email, accountsUrl, userId, }) {
|
|
276
|
+
const src = accountAvatarUrl(accountsUrl, userId);
|
|
277
|
+
const [picture, setPicture] = useState(null);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
setPicture(null);
|
|
280
|
+
if (!src)
|
|
281
|
+
return;
|
|
282
|
+
let live = true;
|
|
283
|
+
let objectUrl = null;
|
|
284
|
+
void probePicture(src).then((blob) => {
|
|
285
|
+
if (!live || !blob)
|
|
286
|
+
return;
|
|
287
|
+
objectUrl = URL.createObjectURL(blob);
|
|
288
|
+
setPicture(objectUrl);
|
|
289
|
+
});
|
|
290
|
+
return () => {
|
|
291
|
+
live = false;
|
|
292
|
+
// The blob stays in the page's memory until it is revoked, and a header that
|
|
293
|
+
// remounts on every navigation would leak one copy per navigation.
|
|
294
|
+
if (objectUrl)
|
|
295
|
+
URL.revokeObjectURL(objectUrl);
|
|
296
|
+
};
|
|
297
|
+
}, [src]);
|
|
298
|
+
return (_jsx("span", { className: "sam-av", "aria-hidden": "true", children: picture ? _jsx("img", { src: picture, alt: "" }) : accountInitials(name, email) }));
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The header account menu. Renders a name button; the panel carries whatever
|
|
302
|
+
* the app passed as `children`, then the account block.
|
|
303
|
+
*/
|
|
304
|
+
export function AccountMenu({ name, email, accountsUrl, children, onSignOut, onLeave, startPath, signOutPath, accounts, sessionPath = SESSION_PATH, userId, }) {
|
|
305
|
+
useInjectedStyles(STYLE_ID, STYLES);
|
|
306
|
+
const dark = useHostDark();
|
|
307
|
+
const { open, close, toggle, wrapRef, panelRef, position } = usePopover(PANEL_WIDTH);
|
|
308
|
+
// The dim behind the panel — shared with the app switcher it sits beside, so the two
|
|
309
|
+
// cannot end up with different ideas of what "open over the page" looks like.
|
|
310
|
+
useScrim(open, close, dark);
|
|
311
|
+
const sso = Boolean(accountsUrl);
|
|
312
|
+
const browser = useBrowserAccounts(sessionPath, accounts, userId);
|
|
313
|
+
/**
|
|
314
|
+
* 🔴 Tell the request layer who this page was drawn for (2026-08-23).
|
|
315
|
+
*
|
|
316
|
+
* This one line is what gives nineteen apps the account-drift guard with no
|
|
317
|
+
* per-app edit, and this component is where it belongs for a reason that is
|
|
318
|
+
* not convenience: the menu is the thing on screen that NAMES the account, so
|
|
319
|
+
* the id it renders and the id every request asserts are by construction the
|
|
320
|
+
* same id. Anywhere else they could drift apart, which is the class of bug
|
|
321
|
+
* being closed. See `accountSlots.ts`.
|
|
322
|
+
*/
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
setExpectedAccount(browser.userId ?? null);
|
|
325
|
+
}, [browser.userId]);
|
|
326
|
+
const [notice, setNotice] = useAccountNotice();
|
|
327
|
+
const others = browser.accounts.filter((row) => row.slot !== browser.slot);
|
|
328
|
+
const several = browser.accounts.length > 1;
|
|
329
|
+
/**
|
|
330
|
+
* Make THIS tab that account.
|
|
331
|
+
*
|
|
332
|
+
* A full navigation rather than a state change: the slot is resolved from
|
|
333
|
+
* the URL at boot, so the honest way to change it is to load the page as
|
|
334
|
+
* that account. It also means the tab's `sessionStorage` and its patched
|
|
335
|
+
* `fetch` are rebuilt together, instead of drifting apart.
|
|
336
|
+
*/
|
|
337
|
+
const switchTo = (slot) => {
|
|
338
|
+
close();
|
|
339
|
+
onLeave?.();
|
|
340
|
+
const here = `${globalThis.location?.pathname ?? "/"}${globalThis.location?.search ?? ""}`;
|
|
341
|
+
globalThis.location?.assign(slotUrl(here, slot));
|
|
342
|
+
};
|
|
343
|
+
return (_jsxs("span", { className: "sam sam-wrap", "data-dark": dark ? "true" : "false", ref: wrapRef, children: [notice ? (_jsx(Suspense, { fallback: null, children: _jsx(AccountNotice, { notice: notice, onDismiss: () => setNotice(null), ...(accountsUrl ? { accountsUrl } : {}), ...(startPath ? { startPath } : {}), signedInAs: name }) })) : null, _jsxs("button", { type: "button", className: "sam-launch", "aria-expanded": open, "aria-haspopup": "true", "aria-label": `Signed in as ${name}`, onClick: toggle, children: [_jsx(AccountAvatar, { name: name, ...(email ? { email } : {}), ...(accountsUrl ? { accountsUrl } : {}), ...(browser.userId ? { userId: browser.userId } : {}) }), _jsx("span", { className: "sam-who", children: name }), _jsx("span", { className: "sam-caret", "aria-hidden": "true", children: "\u25BE" })] }), open &&
|
|
344
|
+
typeof document !== "undefined" &&
|
|
345
|
+
createPortal(
|
|
346
|
+
// 🔴 PORTALED to <body> for the same reason as the app switcher beside
|
|
347
|
+
// it: a header or sidebar that establishes a stacking context renders
|
|
348
|
+
// this panel UNDERNEATH itself no matter how large the z-index. The two
|
|
349
|
+
// controls share `usePopover`, so they share the escape too.
|
|
350
|
+
//
|
|
351
|
+
// `sam` travels with the panel — the palette variables and the dark
|
|
352
|
+
// rule are defined on `.sam`, which is no longer an ancestor.
|
|
353
|
+
_jsxs("div", { ref: panelRef, className: "sam sam-pop", "data-dark": dark ? "true" : "false", "data-placement": position?.placement ?? "below", role: "menu", style: position
|
|
354
|
+
? { left: `${Math.round(position.left)}px`, top: `${Math.round(position.top)}px` }
|
|
355
|
+
: { left: 0, top: 0, visibility: "hidden" }, children: [_jsxs("div", { className: "sam-head", children: [_jsx(AccountAvatar, { name: name, ...(email ? { email } : {}), ...(accountsUrl ? { accountsUrl } : {}), ...(browser.userId ? { userId: browser.userId } : {}) }), _jsxs("div", { className: "sam-head-text", children: [_jsxs("div", { className: "sam-name", children: [name, several ? _jsxs("span", { className: "sam-badge", children: ["Account ", browser.slot + 1] }) : null] }), email && email !== name ? _jsx("div", { className: "sam-sub", children: email }) : null] })] }), children?.(close), sso ? (_jsxs(_Fragment, { children: [others.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "sam-rule" }), _jsx("div", { className: "sam-label", children: "Also signed in here" }), others.map((account) => (_jsxs("div", { className: "sam-acct", children: [_jsxs("button", { type: "button", className: "sam-item", onClick: () => switchTo(account.slot), children: [_jsx("span", { className: "sam-acct-who", children: account.name || account.email }), account.name && account.name !== account.email ? (_jsx("span", { className: "sam-acct-sub", children: account.email })) : null] }), _jsx("button", { type: "button", className: "sam-open", title: `Open a new window as ${account.name || account.email}`, "aria-label": `Open a new window as ${account.name || account.email}`, onClick: () => {
|
|
356
|
+
close();
|
|
357
|
+
globalThis.open?.(accountWindowUrl(account.slot), "_blank", "noopener");
|
|
358
|
+
}, children: "\u29C9" })] }, account.id))), _jsx("div", { className: "sam-rule" })] })) : null, _jsx("a", { className: "sam-item", href: accountsUrl ?? "#", onClick: close, children: "Manage account" }), _jsx("a", { className: "sam-item", href: `${accountsUrl ?? ""}#/account/picture`, onClick: close, children: "Change your picture" }), browser.slotsFull ? (_jsx("p", { className: "sam-hint", children: "This browser is holding all the accounts it can. Sign one out to add another." })) : (_jsx("button", { type: "button", className: "sam-item", onClick: () => {
|
|
359
|
+
close();
|
|
360
|
+
startSsoSignIn({ addAccount: true, ...(startPath ? { startPath } : {}) });
|
|
361
|
+
}, children: "Add another account" })), _jsx("button", { type: "button", className: "sam-item", onClick: () => {
|
|
362
|
+
close();
|
|
363
|
+
onLeave?.();
|
|
364
|
+
startSsoSignIn({ switchUser: true, ...(startPath ? { startPath } : {}) });
|
|
365
|
+
}, children: "Switch user" }), _jsx("p", { className: "sam-hint", children: "Add keeps everyone signed in. Switch replaces this tab's account." })] })) : null, sso || onSignOut ? (_jsx("button", { type: "button", className: "sam-item", "data-tone": "danger", onClick: () => {
|
|
366
|
+
close();
|
|
367
|
+
onLeave?.();
|
|
368
|
+
if (onSignOut) {
|
|
369
|
+
void onSignOut();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
startSsoSignOut(signOutPath ? { signOutPath } : {});
|
|
373
|
+
}, children: several ? `Sign out ${name}` : "Sign out" })) : null, sso && several ? (_jsx("button", { type: "button", className: "sam-item", "data-tone": "danger", onClick: () => {
|
|
374
|
+
close();
|
|
375
|
+
onLeave?.();
|
|
376
|
+
startSsoSignOut({ allAccounts: true, ...(signOutPath ? { signOutPath } : {}) });
|
|
377
|
+
}, children: "Sign out of all accounts" })) : null, sso ? (_jsx("p", { className: "sam-hint", children: several
|
|
378
|
+
? "Signing out leaves this account only; the others stay signed in."
|
|
379
|
+
: "Ends your session here and at accounts." })) : null] }), document.body)] }));
|
|
380
|
+
}
|
|
381
|
+
/* Re-exported through the menu's own subpath, deliberately: `account-ui` is
|
|
382
|
+
* already the one import every app header has, and a second entry point for a
|
|
383
|
+
* banner the menu mounts for you would invite an app to mount it twice. Auth
|
|
384
|
+
* itself is the only caller that wants it standalone — it has no AccountMenu,
|
|
385
|
+
* because it IS the accounts app. */
|
|
386
|
+
export { AccountNotice } from "./AccountNotice";
|
|
387
|
+
export { useAccountNotice } from "./accountNotice.state";
|
|
388
|
+
//# sourceMappingURL=AccountMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountMenu.js","sourceRoot":"","sources":["../../src/account/AccountMenu.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,IAAI,EAAkB,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,GACP,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,iBAAiB,E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AAC,CAAC,IAAI,EAMP,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CACjB,iBACC,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,UAAU,eACV,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE;gCACb,KAAK,EAAE,CAAC;gCACR,OAAO,EAAE,EAAE,CAAC;gCACZ,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;4BACjF,CAAC,yCAGO,CACT,CAAC,CAAC,CAAC,IAAI,EACP,GAAG,CAAC,CAAC,CAAC,CACN,YAAG,SAAS,EAAC,UAAU,YACrB,OAAO;gCACP,CAAC,CAAC,kEAAkE;gCACpE,CAAC,CAAC,yCAAyC,GACzC,CACJ,CAAC,CAAC,CAAC,IAAI,IACH,EACN,QAAQ,CAAC,IAAI,CACb,IACI,CACP,CAAC;AACH,CAAC;AAED;;;;qCAIqC;AACrC,OAAO,EAAE,aAAa,EAA2B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAA2B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AccountNoticeState } from "./accountNotice.state";
|
|
2
|
+
export interface AccountNoticeProps {
|
|
3
|
+
/** What went wrong, from `useAccountNotice`. Never null — `AccountMenu` only
|
|
4
|
+
* fetches this module once there IS something to say. */
|
|
5
|
+
notice: AccountNoticeState;
|
|
6
|
+
/** Put the banner away. */
|
|
7
|
+
onDismiss: () => void;
|
|
8
|
+
/** The accounts satellite origin, when this app is an SSO consumer. Decides
|
|
9
|
+
* whether "sign back in as…" is offered at all — a single-owner door has no
|
|
10
|
+
* hop to make. */
|
|
11
|
+
accountsUrl?: string | null;
|
|
12
|
+
/** This app's SSO start route, for the switch-back hop. */
|
|
13
|
+
startPath?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Who is still signed in here, for the refused-switch message.
|
|
16
|
+
*
|
|
17
|
+
* 🔴 It names them because the owner's report was two complaints, not one:
|
|
18
|
+
* the switch failed silently AND *"the account is still on
|
|
19
|
+
* curtwphillips@gmail.com in the top right header"*, which read as a second
|
|
20
|
+
* bug. Saying whose session survived is what makes the header's name stop
|
|
21
|
+
* looking wrong.
|
|
22
|
+
*/
|
|
23
|
+
signedInAs?: string;
|
|
24
|
+
/** Test seam. Real callers never pass this. */
|
|
25
|
+
onReload?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The banner itself — the LAZY half.
|
|
29
|
+
*
|
|
30
|
+
* 🔴 It does no watching: `useAccountNotice` in `accountNotice.state.ts` does
|
|
31
|
+
* that, eagerly and cheaply, and this module is only fetched once it has
|
|
32
|
+
* something to report. See that file for the byte budget this split answers.
|
|
33
|
+
*/
|
|
34
|
+
export declare function AccountNotice({ accountsUrl, startPath, signedInAs, notice, onDismiss, onReload, }: AccountNoticeProps): import("react").JSX.Element;
|
|
35
|
+
//# sourceMappingURL=AccountNotice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountNotice.d.ts","sourceRoot":"","sources":["../../src/account/AccountNotice.tsx"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAsDhE,MAAM,WAAW,kBAAkB;IAClC;8DAC0D;IAC1D,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;uBAEmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,GACR,EAAE,kBAAkB,+BAqFpB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The one place a satellite tells you something went wrong ABOUT YOUR ACCOUNT —
|
|
4
|
+
* not about your data, not about a request, about who you are (2026-08-23).
|
|
5
|
+
*
|
|
6
|
+
* ── Two failures, one surface ───────────────────────────────────────────────
|
|
7
|
+
* Both are the owner's, both from the same walkthrough, and both were silent:
|
|
8
|
+
*
|
|
9
|
+
* 1. **A refused account switch.** *"I am auto directed back to family site as
|
|
10
|
+
* the user I was already. I see no indication that it did not work except
|
|
11
|
+
* the URL showing a query string with an ssoError field … there should be an
|
|
12
|
+
* indicator such as a toast popup tells me the action failed in a user
|
|
13
|
+
* friendly way … but it seems weird the url is going to keep saying I do not
|
|
14
|
+
* have access while I click around the app clearly having access."*
|
|
15
|
+
* 2. **The account moved underneath an open page.** *"The app let me stay for
|
|
16
|
+
* curtwphillips@gmail.com but the request treated me as a different user. I
|
|
17
|
+
* was allowed to keep using the UI for auth manage users area."* See
|
|
18
|
+
* `accountSlots.ts` for the mechanism and why the server answers 409.
|
|
19
|
+
*
|
|
20
|
+
* They are one surface because they are one sentence to a person — *the account
|
|
21
|
+
* you think you are using is not the account you are using* — and because
|
|
22
|
+
* putting them anywhere else would mean putting them in eighteen apps.
|
|
23
|
+
*
|
|
24
|
+
* ── 🔴 Why this is rendered BY `AccountMenu` ────────────────────────────────
|
|
25
|
+
* `useSsoErrorNotice` — the hook that already existed for failure (1) — was
|
|
26
|
+
* adopted by exactly ONE app of nineteen. So the owner's own bug report was
|
|
27
|
+
* "fixed" for `family` and left standing everywhere else, which is precisely the
|
|
28
|
+
* per-app drift this workstream exists to end. A hook cannot fix that; something
|
|
29
|
+
* that is ALREADY mounted can. `AccountMenu` is in nineteen app headers, it is
|
|
30
|
+
* where the account lives, and it renders this as a sibling — so every app got
|
|
31
|
+
* both notices with no per-app edit, no new provider and no import.
|
|
32
|
+
*
|
|
33
|
+
* ── Why its own stylesheet, again ───────────────────────────────────────────
|
|
34
|
+
* Same reason as `AccountMenu` and `FleetDirectory` beside it: the satellites
|
|
35
|
+
* keep per-app Tailwind `@source` lists, so a shared widget styled with utility
|
|
36
|
+
* classes renders correctly in whichever apps remembered to add a line and
|
|
37
|
+
* silently unstyled in the rest. `DESIGN.md` §3 wants a filled, high-contrast
|
|
38
|
+
* capsule and §5 wants 44px targets; both are literals here for that reason.
|
|
39
|
+
*/
|
|
40
|
+
import { useCallback } from "react";
|
|
41
|
+
import { currentExpectedAccount, setExpectedAccount } from "../accountSlot.client";
|
|
42
|
+
import { startSsoSignIn } from "../ssoAutoSignIn";
|
|
43
|
+
import { useHostDark, useInjectedStyles } from "../ui/popover";
|
|
44
|
+
const STYLE_ID = "san-style";
|
|
45
|
+
/*
|
|
46
|
+
* 🔴 The width cap is `DESIGN.md` §1 ("a strict readability width of 750px–850px
|
|
47
|
+
* … Center this content block"), and the two action buttons are §6's action-row
|
|
48
|
+
* grouping: a filled primary and a text-only secondary, side by side at the end
|
|
49
|
+
* of the row. `min-height:44px` on both is §5, unconditionally rather than
|
|
50
|
+
* behind a `pointer:coarse` query — this banner is most likely to be read on a
|
|
51
|
+
* phone, and a 44px button on a desktop is not a defect.
|
|
52
|
+
*/
|
|
53
|
+
const STYLES = `
|
|
54
|
+
.san{--san-bg:#fffaf0;--san-border:#e8b339;--san-text:#41320a;--san-muted:#6d5a2a;
|
|
55
|
+
--san-accent:#8a5a00;--san-btn:#8a5a00;--san-btn-text:#ffffff;--san-shadow:0 10px 30px rgba(16,18,22,.18);
|
|
56
|
+
position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:2147483000;
|
|
57
|
+
width:min(52rem,calc(100vw - 24px));box-sizing:border-box;
|
|
58
|
+
display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;
|
|
59
|
+
padding:12px 14px;border:1px solid var(--san-border);border-radius:12px;
|
|
60
|
+
background:var(--san-bg);color:var(--san-text);box-shadow:var(--san-shadow);
|
|
61
|
+
font:13px/1.5 ui-sans-serif,system-ui,-apple-system,sans-serif}
|
|
62
|
+
.san[data-dark="true"]{--san-bg:#241d0c;--san-border:#7a5c1a;--san-text:#f4e6c4;--san-muted:#c9b489;
|
|
63
|
+
--san-accent:#f0c04a;--san-btn:#f0c04a;--san-btn-text:#241d0c;--san-shadow:0 10px 30px rgba(0,0,0,.55)}
|
|
64
|
+
.san-glyph{flex:none;display:inline-flex;align-items:center;justify-content:center;
|
|
65
|
+
width:28px;height:28px;border-radius:50%;font-size:15px;font-weight:700;
|
|
66
|
+
background:color-mix(in srgb,var(--san-accent) 20%,transparent);color:var(--san-accent)}
|
|
67
|
+
.san-text{flex:1 1 22rem;min-width:0}
|
|
68
|
+
.san-title{font-weight:650;font-size:13.5px}
|
|
69
|
+
/* §4: secondary metadata stays at 12px+ and readable, never a thin grey whisper. */
|
|
70
|
+
.san-body{font-size:12.5px;color:var(--san-muted);margin-top:2px;overflow-wrap:anywhere}
|
|
71
|
+
.san-who{font-weight:650;color:var(--san-text)}
|
|
72
|
+
.san-actions{flex:none;display:flex;align-items:center;gap:8px;margin-left:auto}
|
|
73
|
+
.san-btn{display:inline-flex;align-items:center;justify-content:center;min-height:44px;
|
|
74
|
+
padding:0 14px;border-radius:9px;border:1px solid transparent;cursor:pointer;
|
|
75
|
+
font:inherit;font-size:13px;font-weight:600;white-space:nowrap}
|
|
76
|
+
.san-btn[data-variant="primary"]{background:var(--san-btn);color:var(--san-btn-text)}
|
|
77
|
+
.san-btn[data-variant="primary"]:hover{filter:brightness(1.08)}
|
|
78
|
+
.san-btn[data-variant="ghost"]{background:transparent;color:var(--san-text);
|
|
79
|
+
border-color:color-mix(in srgb,var(--san-border) 70%,transparent)}
|
|
80
|
+
.san-btn[data-variant="ghost"]:hover{background:color-mix(in srgb,var(--san-accent) 12%,transparent)}
|
|
81
|
+
.san-btn:focus-visible{outline:2px solid var(--san-accent);outline-offset:2px}
|
|
82
|
+
/* §5 again: on a phone the two buttons stack full-width rather than being squeezed
|
|
83
|
+
into a row narrow enough to mis-tap. */
|
|
84
|
+
@media (max-width:560px){
|
|
85
|
+
.san{gap:8px 10px}
|
|
86
|
+
.san-actions{margin-left:0;width:100%;display:grid;grid-template-columns:1fr;gap:8px}
|
|
87
|
+
.san-btn{width:100%}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
/** The person-readable name of whoever the request actually resolved to. */
|
|
91
|
+
const nameOf = (actual) => actual.name?.trim() || actual.email || "another account";
|
|
92
|
+
/**
|
|
93
|
+
* The banner itself — the LAZY half.
|
|
94
|
+
*
|
|
95
|
+
* 🔴 It does no watching: `useAccountNotice` in `accountNotice.state.ts` does
|
|
96
|
+
* that, eagerly and cheaply, and this module is only fetched once it has
|
|
97
|
+
* something to report. See that file for the byte budget this split answers.
|
|
98
|
+
*/
|
|
99
|
+
export function AccountNotice({ accountsUrl, startPath, signedInAs, notice, onDismiss, onReload, }) {
|
|
100
|
+
useInjectedStyles(STYLE_ID, STYLES);
|
|
101
|
+
const dark = useHostDark();
|
|
102
|
+
/**
|
|
103
|
+
* Become the account this browser actually holds.
|
|
104
|
+
*
|
|
105
|
+
* 🔴 The expectation is cleared FIRST. It names a user who is no longer here,
|
|
106
|
+
* and a reload issues its own requests — leaving it set would refuse the very
|
|
107
|
+
* page load that is meant to resolve the conflict.
|
|
108
|
+
*/
|
|
109
|
+
const continueAsActual = useCallback(() => {
|
|
110
|
+
setExpectedAccount(null);
|
|
111
|
+
onDismiss();
|
|
112
|
+
if (onReload)
|
|
113
|
+
onReload();
|
|
114
|
+
else
|
|
115
|
+
globalThis.location?.reload();
|
|
116
|
+
}, [onReload, onDismiss]);
|
|
117
|
+
/** Ask the accounts satellite for the credential form, so the person can come
|
|
118
|
+
* back as whoever they thought they were. */
|
|
119
|
+
const signInAgain = useCallback(() => {
|
|
120
|
+
setExpectedAccount(null);
|
|
121
|
+
startSsoSignIn({
|
|
122
|
+
startPath: startPath ?? "/api/auth/sso/start",
|
|
123
|
+
switchUser: true,
|
|
124
|
+
});
|
|
125
|
+
}, [startPath]);
|
|
126
|
+
if (notice.kind === "sso-error") {
|
|
127
|
+
return (_jsxs("div", { className: "san", "data-dark": dark ? "true" : "false", role: "alert", children: [_jsx("span", { className: "san-glyph", "aria-hidden": "true", children: "!" }), _jsxs("span", { className: "san-text", children: [_jsx("span", { className: "san-title", children: "That account switch did not go through" }), _jsxs("span", { className: "san-body", children: [notice.message, ". You are still signed in", signedInAs ? (_jsxs(_Fragment, { children: [" as ", _jsx("span", { className: "san-who", children: signedInAs })] })) : (" as before"), ", and nothing has changed."] })] }), _jsx("span", { className: "san-actions", children: _jsx("button", { type: "button", className: "san-btn", "data-variant": "primary", onClick: onDismiss, children: "Got it" }) })] }));
|
|
128
|
+
}
|
|
129
|
+
const actual = notice.detail.actual;
|
|
130
|
+
const expected = notice.detail.expected || currentExpectedAccount() || "another account";
|
|
131
|
+
return (_jsxs("div", { className: "san", "data-dark": dark ? "true" : "false", role: "alert", children: [_jsx("span", { className: "san-glyph", "aria-hidden": "true", children: "!" }), _jsxs("span", { className: "san-text", children: [_jsx("span", { className: "san-title", children: "This page is showing the wrong account" }), _jsxs("span", { className: "san-body", children: ["It was opened as ", _jsx("span", { className: "san-who", children: expected }), ", but this browser is now signed in here as ", _jsx("span", { className: "san-who", children: nameOf(actual) }), " \u2014 so anything you change would be saved as them. Nothing has been changed."] })] }), _jsxs("span", { className: "san-actions", children: [_jsxs("button", { type: "button", className: "san-btn", "data-variant": "primary", onClick: continueAsActual, children: ["Continue as ", nameOf(actual)] }), accountsUrl ? (_jsx("button", { type: "button", className: "san-btn", "data-variant": "ghost", onClick: signInAgain, children: "Sign back in" })) : null] })] }));
|
|
132
|
+
}
|
|
133
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MAAM,kBAEvC,EACP,gBAAM,SAAS,EAAC,UAAU,aACzB,eAAM,SAAS,EAAC,WAAW,uDAA8C,EACzE,gBAAM,SAAS,EAAC,UAAU,kCACR,eAAM,SAAS,EAAC,SAAS,YAAE,QAAQ,GAAQ,kDAC1C,eAAM,SAAS,EAAC,SAAS,YAAE,MAAM,CAAC,MAAM,CAAC,GAAQ,wFAE7D,IACD,EACP,gBAAM,SAAS,EAAC,aAAa,aAC5B,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,kBAAc,SAAS,EAAC,OAAO,EAAE,gBAAgB,6BAC5E,MAAM,CAAC,MAAM,CAAC,IACnB,EACR,WAAW,CAAC,CAAC,CAAC,CACd,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,kBAAc,OAAO,EAAC,OAAO,EAAE,WAAW,6BAE1E,CACT,CAAC,CAAC,CAAC,IAAI,IACF,IACF,CACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AccountDriftBody } from "../accountSlots";
|
|
2
|
+
/** What went wrong with the account, if anything. */
|
|
3
|
+
export type AccountNoticeState = {
|
|
4
|
+
kind: "drift";
|
|
5
|
+
detail: AccountDriftBody;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "sso-error";
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Watch for the two ways an account goes wrong. Returns null almost always.
|
|
12
|
+
*
|
|
13
|
+
* A hook rather than a component so the cost of watching is a `useState` and one
|
|
14
|
+
* listener — no styles, no markup, nothing in the entry chunk but this file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useAccountNotice(): [
|
|
17
|
+
AccountNoticeState | null,
|
|
18
|
+
(next: AccountNoticeState | null) => void
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=accountNotice.state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountNotice.state.d.ts","sourceRoot":"","sources":["../../src/account/accountNotice.state.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAC3B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI;IACnC,kBAAkB,GAAG,IAAI;IACzB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI;CACzC,CAwBA"}
|