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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -0
  3. package/dist/account/AccountMenu.d.ts +153 -0
  4. package/dist/account/AccountMenu.d.ts.map +1 -0
  5. package/dist/account/AccountMenu.js +388 -0
  6. package/dist/account/AccountMenu.js.map +1 -0
  7. package/dist/account/AccountNotice.d.ts +35 -0
  8. package/dist/account/AccountNotice.d.ts.map +1 -0
  9. package/dist/account/AccountNotice.js +133 -0
  10. package/dist/account/AccountNotice.js.map +1 -0
  11. package/dist/account/accountNotice.state.d.ts +20 -0
  12. package/dist/account/accountNotice.state.d.ts.map +1 -0
  13. package/dist/account/accountNotice.state.js +55 -0
  14. package/dist/account/accountNotice.state.js.map +1 -0
  15. package/dist/account/avatar.d.ts +37 -0
  16. package/dist/account/avatar.d.ts.map +1 -0
  17. package/dist/account/avatar.js +47 -0
  18. package/dist/account/avatar.js.map +1 -0
  19. package/dist/accountSlot.client.d.ts +113 -0
  20. package/dist/accountSlot.client.d.ts.map +1 -0
  21. package/dist/accountSlot.client.js +330 -0
  22. package/dist/accountSlot.client.js.map +1 -0
  23. package/dist/accountSlots.d.ts +192 -0
  24. package/dist/accountSlots.d.ts.map +1 -0
  25. package/dist/accountSlots.js +274 -0
  26. package/dist/accountSlots.js.map +1 -0
  27. package/dist/auth.d.ts +167 -0
  28. package/dist/auth.d.ts.map +1 -0
  29. package/dist/auth.js +310 -0
  30. package/dist/auth.js.map +1 -0
  31. package/dist/auth.server.d.ts +35 -0
  32. package/dist/auth.server.d.ts.map +1 -0
  33. package/dist/auth.server.js +67 -0
  34. package/dist/auth.server.js.map +1 -0
  35. package/dist/clientDescription.d.ts +186 -0
  36. package/dist/clientDescription.d.ts.map +1 -0
  37. package/dist/clientDescription.js +278 -0
  38. package/dist/clientDescription.js.map +1 -0
  39. package/dist/constantTime.d.ts +35 -0
  40. package/dist/constantTime.d.ts.map +1 -0
  41. package/dist/constantTime.js +46 -0
  42. package/dist/constantTime.js.map +1 -0
  43. package/dist/contentCensus.d.ts +59 -0
  44. package/dist/contentCensus.d.ts.map +1 -0
  45. package/dist/contentCensus.js +55 -0
  46. package/dist/contentCensus.js.map +1 -0
  47. package/dist/index.d.ts +25 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +24 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/mountGatedApp.d.ts +128 -0
  52. package/dist/mountGatedApp.d.ts.map +1 -0
  53. package/dist/mountGatedApp.js +107 -0
  54. package/dist/mountGatedApp.js.map +1 -0
  55. package/dist/runtimeMode.d.ts +28 -0
  56. package/dist/runtimeMode.d.ts.map +1 -0
  57. package/dist/runtimeMode.js +37 -0
  58. package/dist/runtimeMode.js.map +1 -0
  59. package/dist/secureRequest.d.ts +22 -0
  60. package/dist/secureRequest.d.ts.map +1 -0
  61. package/dist/secureRequest.js +27 -0
  62. package/dist/secureRequest.js.map +1 -0
  63. package/dist/sso.d.ts +373 -0
  64. package/dist/sso.d.ts.map +1 -0
  65. package/dist/sso.js +420 -0
  66. package/dist/sso.js.map +1 -0
  67. package/dist/ssoAutoSignIn.d.ts +272 -0
  68. package/dist/ssoAutoSignIn.d.ts.map +1 -0
  69. package/dist/ssoAutoSignIn.js +431 -0
  70. package/dist/ssoAutoSignIn.js.map +1 -0
  71. package/dist/ssoConsumer.server.d.ts +295 -0
  72. package/dist/ssoConsumer.server.d.ts.map +1 -0
  73. package/dist/ssoConsumer.server.js +972 -0
  74. package/dist/ssoConsumer.server.js.map +1 -0
  75. package/dist/stageIdentity.d.ts +72 -0
  76. package/dist/stageIdentity.d.ts.map +1 -0
  77. package/dist/stageIdentity.js +74 -0
  78. package/dist/stageIdentity.js.map +1 -0
  79. package/dist/ui/popover.d.ts +190 -0
  80. package/dist/ui/popover.d.ts.map +1 -0
  81. package/dist/ui/popover.js +351 -0
  82. package/dist/ui/popover.js.map +1 -0
  83. package/dist/userSessions.d.ts +205 -0
  84. package/dist/userSessions.d.ts.map +1 -0
  85. package/dist/userSessions.js +419 -0
  86. package/dist/userSessions.js.map +1 -0
  87. package/package.json +115 -0
  88. package/src/account/AccountMenu.tsx +729 -0
  89. package/src/account/AccountNotice.tsx +223 -0
  90. package/src/account/accountNotice.state.ts +66 -0
  91. package/src/account/avatar.ts +50 -0
  92. package/src/accountSlot.client.ts +362 -0
  93. package/src/accountSlots.ts +305 -0
  94. package/src/auth.server.ts +89 -0
  95. package/src/auth.ts +515 -0
  96. package/src/clientDescription.ts +366 -0
  97. package/src/constantTime.ts +45 -0
  98. package/src/contentCensus.ts +106 -0
  99. package/src/index.ts +58 -0
  100. package/src/mountGatedApp.ts +240 -0
  101. package/src/runtimeMode.ts +37 -0
  102. package/src/secureRequest.ts +25 -0
  103. package/src/sso.ts +767 -0
  104. package/src/ssoAutoSignIn.ts +544 -0
  105. package/src/ssoConsumer.server.ts +1260 -0
  106. package/src/stageIdentity.ts +76 -0
  107. package/src/ui/popover.ts +390 -0
  108. package/src/userSessions.ts +678 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * The header-popover machinery the account widgets share — style
3
+ * injection, host dark mode, viewport anchoring, dismissal.
4
+ *
5
+ * ── Why these four live together, and why here ──────────────────────────────
6
+ * `FleetDirectory` grew all four first, for a reason that applies to any UI
7
+ * this package renders INTO an app rather than beside it: the satellites split
8
+ * between barrel-bundling and barrel-excluding Vite configs and keep per-app
9
+ * Tailwind `@source` lists, so a widget styled with utility classes renders
10
+ * correctly in whichever apps remembered to add a line and silently unstyled in
11
+ * the rest. "Unstyled" is not a visible failure to the person who shipped it.
12
+ * One scoped stylesheet, injected once, keyed on its own variables, renders
13
+ * identically everywhere and costs no per-app wiring.
14
+ *
15
+ * The moment a SECOND widget needed the same four (`AccountMenu`, 2026-08-10),
16
+ * copying them would have meant two dark-mode readers that could disagree about
17
+ * what dark means while sitting 8px apart in the same header. So they moved
18
+ * here, and `FleetDirectory` imports them like anybody else.
19
+ */
20
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
21
+ /**
22
+ * Inject a scoped stylesheet once per document, keyed on `id`.
23
+ *
24
+ * Idempotent by the id check, which is what makes it safe to call from every
25
+ * instance of a widget — a header renders one launcher, an account page may
26
+ * render another, and neither should care whether the other already ran.
27
+ */
28
+ export function useInjectedStyles(id, css) {
29
+ useEffect(() => {
30
+ if (typeof document === "undefined" || document.getElementById(id))
31
+ return;
32
+ const el = document.createElement("style");
33
+ el.id = id;
34
+ el.textContent = css;
35
+ document.head.appendChild(el);
36
+ }, [id, css]);
37
+ }
38
+ /**
39
+ * Follow the host app's dark mode without owning a theme of our own.
40
+ *
41
+ * ── 🔴 The rung that was missing, and the bug it caused ─────────────────────────────────
42
+ * A flix user, 2026-08-25: *"the square button looks like it's in dark mode even though he
43
+ * was in light mode, and so did the pill with user initials and user name."*
44
+ *
45
+ * The order below was: explicit attribute, then the `dark` CLASS, then the OS preference.
46
+ * cursedbelt's theme store expresses LIGHT by REMOVING the class (`classList.toggle('dark',
47
+ * scheme === 'dark')` — `theme.css`'s contract, and right for `dark:` utilities), and it
48
+ * sets no attribute. So a host in light mode looked exactly like a host that had never
49
+ * chosen: nothing matched, and the fall-through asked the OPERATING SYSTEM — which for
50
+ * this reader was dark. Every popover in the header therefore rendered dark over a light
51
+ * app. The class is a positive signal for dark and carries no signal at all for light,
52
+ * which is the whole defect.
53
+ *
54
+ * The missing rung is `color-scheme` on the root, which the same applier sets to the
55
+ * RESOLVED value in both directions. It is a web-platform property rather than a
56
+ * cursedbelt invention — it is what tells native scrollbars and form controls which way to
57
+ * paint — so reading it also covers any host that themes itself properly without using
58
+ * this design system at all. `prefers-color-scheme` stays as the last resort, for a host
59
+ * that has genuinely expressed nothing.
60
+ *
61
+ * 🔴 `style` is in the observed attribute list for the same reason: the applier writes
62
+ * `documentElement.style.colorScheme`, so leaving it out would read the value once and
63
+ * then never notice the theme being toggled.
64
+ */
65
+ export function useHostDark() {
66
+ const [dark, setDark] = useState(false);
67
+ useEffect(() => {
68
+ if (typeof document === "undefined")
69
+ return;
70
+ const read = () => {
71
+ const root = document.documentElement;
72
+ const attr = root.getAttribute("data-theme") ?? root.getAttribute("data-color-scheme");
73
+ if (attr === "dark")
74
+ return true;
75
+ if (attr === "light")
76
+ return false;
77
+ if (root.classList.contains("dark"))
78
+ return true;
79
+ // The resolved scheme, in BOTH directions — see the header.
80
+ const scheme = root.style.colorScheme || getComputedStyle(root).colorScheme;
81
+ if (scheme === "dark")
82
+ return true;
83
+ if (scheme === "light")
84
+ return false;
85
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? false;
86
+ };
87
+ setDark(read());
88
+ const observer = new MutationObserver(() => setDark(read()));
89
+ observer.observe(document.documentElement, {
90
+ attributes: true,
91
+ attributeFilter: ["class", "data-theme", "data-color-scheme", "style"],
92
+ });
93
+ return () => observer.disconnect();
94
+ }, []);
95
+ return dark;
96
+ }
97
+ /**
98
+ * Breathing room kept between a popover and the edge of the screen. Matches the
99
+ * `calc(100vw - 32px)` cap in each widget's stylesheet — 16px a side.
100
+ *
101
+ * 🔴 **16, not 12** (2026-08-22, unit 34-life). The owner's designer asked for it by
102
+ * number — *"a minimum padding safe-zone of 16px relative to the screen edge"* — and it
103
+ * is the same figure every Radix surface in cursedbelt already passes as
104
+ * `collisionPadding` since unit 11. Two floating-surface systems in one header disagreeing
105
+ * by 4px is exactly the drift this queue exists to end, so they now agree.
106
+ */
107
+ const VIEWPORT_MARGIN = 16;
108
+ /**
109
+ * Where a popover's left edge goes, in coordinates relative to its launcher.
110
+ *
111
+ * 🔴 **This exists because `right: 0` is wrong on a phone.** The panel is
112
+ * positioned against a ~30px launcher button, so right-aligning it puts its LEFT
113
+ * edge at `button.right - panelWidth`. On a 393px-wide iPhone with the button two
114
+ * thirds across the header, that is roughly **-90px**: the panel hangs off the
115
+ * side of the screen and its entire content is unreadable. (Reported from a real
116
+ * iPhone against flix, 2026-08-09.) A `max-width` cannot fix it; the width was
117
+ * already clamped, and it was the OFFSET that was off-screen.
118
+ *
119
+ * So the edge is clamped into the viewport instead: right-aligned to the button
120
+ * when that fits, pushed in from whichever side it would otherwise overhang when
121
+ * it does not.
122
+ *
123
+ * 🔴 **Returned relative to the launcher, and that is now the LEGACY axis.** The
124
+ * comment here used to explain that a `position: fixed` panel "is not available,
125
+ * since a sticky app header with `backdrop-filter` becomes the containing block
126
+ * for fixed descendants". That is true of a panel rendered INSIDE the launcher —
127
+ * and it is exactly why {@link anchoredLeftInViewport} plus a portal to `body`
128
+ * replaced it (2026-09-09, E22). Once the panel is a child of `body` there is no
129
+ * transformed ancestor to resolve against, so viewport coordinates are simply
130
+ * correct. This relative form is kept because it is pure, tested, and is the
131
+ * arithmetic the viewport form is built out of.
132
+ *
133
+ * Pure and exported so the arithmetic can be tested without a browser.
134
+ */
135
+ export function anchoredLeft(anchor, viewportWidth, panelWidth, margin = VIEWPORT_MARGIN) {
136
+ return anchoredLeftInViewport(anchor, viewportWidth, panelWidth, margin) - anchor.left;
137
+ }
138
+ /**
139
+ * The same clamp, in VIEWPORT coordinates — what a portaled `position: fixed`
140
+ * panel needs. {@link anchoredLeft} is this minus `anchor.left`.
141
+ */
142
+ export function anchoredLeftInViewport(anchor, viewportWidth, panelWidth, margin = VIEWPORT_MARGIN) {
143
+ const width = Math.min(panelWidth, viewportWidth - margin * 2);
144
+ const rightAligned = anchor.right - width;
145
+ // `Math.max` LAST so that a viewport narrower than the panel still starts at
146
+ // the left margin rather than at a negative "keep the right margin" answer.
147
+ return Math.max(margin, Math.min(rightAligned, viewportWidth - margin - width));
148
+ }
149
+ /**
150
+ * The gap between a launcher and its panel. Was `calc(100% + 6px)` in each
151
+ * widget's stylesheet until the panel stopped being positioned by CSS at all.
152
+ */
153
+ export const POPOVER_GAP = 6;
154
+ /**
155
+ * Where a popover's TOP edge goes, in viewport coordinates, and which side it
156
+ * chose.
157
+ *
158
+ * 🔴 **This exists because the fleet launcher is at the BOTTOM-LEFT corner.**
159
+ * The owner, 2026-09-09: *"The icon is on the bottom left corner and the popup it
160
+ * opens is going under it outside of view plus behind the sidebar. Its position
161
+ * calculation makes it completely unusable."*
162
+ *
163
+ * There was no vertical calculation at all. `anchoredLeft` solved the horizontal
164
+ * axis in August (a phone pushed the panel off the side); the vertical axis was
165
+ * a single CSS line, `top: calc(100% + 6px)` — *always* below the launcher. That
166
+ * is right for a header at the top of the page and unusable for a launcher at the
167
+ * bottom, where "below" is past the fold. A `max-height` cannot fix it, for the
168
+ * same reason a `max-width` could not fix the phone bug: the panel was the right
169
+ * size and in the wrong PLACE.
170
+ *
171
+ * So: below when it fits, flipped above when it does not, and when neither side
172
+ * fits (a panel taller than the viewport) the roomier side wins and the result is
173
+ * clamped to the margins so the top of the panel is always reachable.
174
+ *
175
+ * Pure and exported so the arithmetic can be tested without a browser.
176
+ */
177
+ export function anchoredTop(anchor, viewportHeight, panelHeight, gap = POPOVER_GAP, margin = VIEWPORT_MARGIN) {
178
+ const below = anchor.bottom + gap;
179
+ const above = anchor.top - gap - panelHeight;
180
+ if (below + panelHeight <= viewportHeight - margin)
181
+ return { top: below, placement: "below" };
182
+ if (above >= margin)
183
+ return { top: above, placement: "above" };
184
+ // Neither side fits. Prefer the side with more room, then clamp — a panel
185
+ // taller than the viewport scrolls internally (`max-height` in the widget's
186
+ // stylesheet), so what matters is that its TOP is on screen.
187
+ const roomBelow = viewportHeight - margin - below;
188
+ const roomAbove = anchor.top - gap - margin;
189
+ const lowest = Math.max(margin, viewportHeight - margin - panelHeight);
190
+ return roomAbove > roomBelow
191
+ ? { top: margin, placement: "above" }
192
+ : { top: Math.min(below, lowest), placement: "below" };
193
+ }
194
+ /**
195
+ * Measure launcher and panel, and place the panel on screen.
196
+ *
197
+ * 🔴 **A scroll listener is REQUIRED here**, where the old left-only hook
198
+ * correctly did without one. That hook positioned the panel absolutely inside the
199
+ * launcher, so it travelled with it and only a resize could move it. A portaled
200
+ * `position: fixed` panel does not travel with anything: scroll the page and the
201
+ * launcher moves out from under a panel that stayed put. `capture: true` so a
202
+ * scrolling CONTAINER (a sidebar's own overflow, which is where this bug was
203
+ * reported) is heard too — those events do not bubble.
204
+ *
205
+ * The panel is measured, not assumed: whether it fits below depends on its real
206
+ * rendered height, and the entry list is variable-length.
207
+ */
208
+ export function usePopoverPosition(open, wrapRef, panelRef, panelWidth) {
209
+ const [pos, setPos] = useState(null);
210
+ // Layout, not effect: an ordinary effect measures AFTER the browser has
211
+ // painted, so the panel would be seen at the wrong place for one frame and
212
+ // then jump. This runs before that paint.
213
+ useLayoutEffect(() => {
214
+ if (!open || typeof window === "undefined") {
215
+ setPos(null);
216
+ return;
217
+ }
218
+ const measure = () => {
219
+ const anchor = wrapRef.current?.getBoundingClientRect();
220
+ if (!anchor)
221
+ return;
222
+ // Before the first paint the panel has no box; fall back to its CSS cap
223
+ // so the FIRST placement is already right rather than briefly below.
224
+ const height = panelRef.current?.offsetHeight || 0;
225
+ const { top, placement } = anchoredTop(anchor, window.innerHeight, height);
226
+ setPos({
227
+ left: anchoredLeftInViewport(anchor, window.innerWidth, panelWidth),
228
+ top,
229
+ placement,
230
+ });
231
+ };
232
+ measure();
233
+ // A second pass once the panel has a real height — the first ran before it
234
+ // was laid out, so `offsetHeight` was 0 and "fits below" was answered for a
235
+ // zero-height panel.
236
+ const raf = requestAnimationFrame(measure);
237
+ window.addEventListener("resize", measure);
238
+ window.addEventListener("orientationchange", measure);
239
+ window.addEventListener("scroll", measure, true);
240
+ return () => {
241
+ cancelAnimationFrame(raf);
242
+ window.removeEventListener("resize", measure);
243
+ window.removeEventListener("orientationchange", measure);
244
+ window.removeEventListener("scroll", measure, true);
245
+ };
246
+ }, [open, wrapRef, panelRef, panelWidth]);
247
+ return pos;
248
+ }
249
+ /**
250
+ * Close on a click outside the wrapper or on Escape — the two dismissals a
251
+ * person expects from anything that opened over the page.
252
+ *
253
+ * `mousedown`, not `click`: a menu item that navigates must not be able to fire
254
+ * its own dismissal after the navigation has already begun.
255
+ *
256
+ * 🔴 `panelRef` is not optional decoration. Once the panel is PORTALED to `body`
257
+ * it is no longer a descendant of the wrapper, so a wrapper-only containment test
258
+ * calls every click inside the panel an outside click — the menu would close on
259
+ * the way to any item it contains.
260
+ */
261
+ export function useDismissOnOutside(open, wrapRef, close, panelRef) {
262
+ useEffect(() => {
263
+ if (!open)
264
+ return;
265
+ const onDown = (e) => {
266
+ const target = e.target;
267
+ if (wrapRef.current?.contains(target))
268
+ return;
269
+ if (panelRef?.current?.contains(target))
270
+ return;
271
+ close();
272
+ };
273
+ const onKey = (e) => {
274
+ if (e.key === "Escape")
275
+ close();
276
+ };
277
+ document.addEventListener("mousedown", onDown);
278
+ document.addEventListener("keydown", onKey);
279
+ return () => {
280
+ document.removeEventListener("mousedown", onDown);
281
+ document.removeEventListener("keydown", onKey);
282
+ };
283
+ }, [open, wrapRef, close, panelRef]);
284
+ }
285
+ const SCRIM_ID = "sk-popover-scrim";
286
+ const SCRIM_STYLE_ID = "sk-popover-scrim-style";
287
+ /** One below the panels' `z-index: 2147482000`, so it dims the page and nothing else. */
288
+ const SCRIM_CSS = `
289
+ #${SCRIM_ID}{position:fixed;inset:0;z-index:2147481999;background:rgba(16,18,22,.28);
290
+ animation:sk-scrim-in .12s ease-out}
291
+ #${SCRIM_ID}[data-dark="true"]{background:rgba(0,0,0,.46)}
292
+ @keyframes sk-scrim-in{from{opacity:0}to{opacity:1}}
293
+ @media (prefers-reduced-motion:reduce){#${SCRIM_ID}{animation:none}}
294
+ `;
295
+ /**
296
+ * The dimmed backdrop behind an open header popover.
297
+ *
298
+ * 🔴 Why it exists (owner's designer, 2026-08-19, on the "Your Apps" menu):
299
+ * *"The secondary app dropdown menu completely masks the main layout content underneath
300
+ * without dimmed backdrops or absolute separation … foreground elements fight background
301
+ * data for active user focus."* Elevation alone did not settle it — the page behind is
302
+ * flat high-contrast text at the same weight as the menu's own.
303
+ *
304
+ * 🔴 Built imperatively on `document.body` rather than as a React node, and that is the
305
+ * point: `position: fixed` inside the launcher resolves against the nearest ancestor with
306
+ * a `backdrop-filter` — which a sticky app header usually has — so a JSX scrim would dim
307
+ * the header and leave the page it was meant to dim untouched. `body` has no such
308
+ * ancestor. (A portal would work too and would cost this package a `react-dom` dependency
309
+ * it does not otherwise have.)
310
+ *
311
+ * It is inert to the keyboard and hidden from assistive tech: Escape and the existing
312
+ * outside-click dismissal are the real doors, and this is decoration plus a wide target.
313
+ */
314
+ export function useScrim(open, close, dark) {
315
+ useInjectedStyles(SCRIM_STYLE_ID, SCRIM_CSS);
316
+ useEffect(() => {
317
+ if (!open || typeof document === "undefined")
318
+ return;
319
+ const el = document.createElement("div");
320
+ el.id = SCRIM_ID;
321
+ el.setAttribute("aria-hidden", "true");
322
+ el.dataset.dark = dark ? "true" : "false";
323
+ // `mousedown` for the same reason `useDismissOnOutside` uses it: a click that
324
+ // began on a menu item must not be able to dismiss the menu mid-navigation.
325
+ el.addEventListener("mousedown", close);
326
+ document.body.appendChild(el);
327
+ return () => {
328
+ el.removeEventListener("mousedown", close);
329
+ el.remove();
330
+ };
331
+ }, [open, close, dark]);
332
+ }
333
+ /** The open/close state, both refs, both dismissals and the panel's placement —
334
+ * everything a launcher needs but the panel's contents. Saves each widget
335
+ * re-deriving the same lines and, more usefully, keeps them placing and
336
+ * dismissing identically.
337
+ *
338
+ * 🔴 `panelRef` must be attached to the portaled panel. It is what lets the
339
+ * placement read the panel's real height, and what stops a click inside the
340
+ * panel reading as a click outside the launcher. */
341
+ export function usePopover(panelWidth) {
342
+ const [open, setOpen] = useState(false);
343
+ const wrapRef = useRef(null);
344
+ const panelRef = useRef(null);
345
+ const close = useCallback(() => setOpen(false), []);
346
+ const toggle = useCallback(() => setOpen((v) => !v), []);
347
+ useDismissOnOutside(open, wrapRef, close, panelRef);
348
+ const position = usePopoverPosition(open, wrapRef, panelRef, panelWidth);
349
+ return { open, close, toggle, wrapRef, panelRef, position };
350
+ }
351
+ //# sourceMappingURL=popover.js.map
@@ -0,0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AC,CAAC;QAC9B,OAAO,GAAG,EAAE;YACX,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YAC3C,EAAE,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;qDAOqD;AACrD,MAAM,UAAU,UAAU,CAAwB,UAAkB;IACnE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAW,IAAI,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACzE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,205 @@
1
+ import { type PlaceLookup } from "./clientDescription";
2
+ export interface UserSessionStoreOptions {
3
+ /** Per-app cookie name, e.g. "hobbies_session" — never shared across apps. */
4
+ cookieName: string;
5
+ dbPath: string;
6
+ sessionSecret: string;
7
+ sessionTtlSeconds: number;
8
+ /**
9
+ * Where an address is, for the `place` stamped on a new session row.
10
+ *
11
+ * 🔴 There is NO default here, and that is the one deliberate behaviour
12
+ * change this module carries out of the previous generation. It used to
13
+ * default to a machine-wide 375MB IP→city snapshot kept outside any repo;
14
+ * this generation has two roots and nothing else, so a library may not
15
+ * reach for a file it did not put there. Unset, the row records whatever
16
+ * the edge headers said (`cf-ipcity` and friends) — which is what every
17
+ * request behind Cloudflare already carries — or nothing.
18
+ *
19
+ * Pass a lookup to restore city-from-address; `null` and unset are the
20
+ * same thing and both are safe in a test.
21
+ */
22
+ placeLookup?: PlaceLookup | null;
23
+ now?: () => number;
24
+ }
25
+ /**
26
+ * One live session, as anything outside this module may see it.
27
+ *
28
+ * Deliberately without the row id — see the header. Times are ms epoch so the
29
+ * shape survives a JSON hop between two satellites without a date parser at
30
+ * each end.
31
+ */
32
+ export interface SessionRecord {
33
+ /** Stable public name for this session: `sha256(id)`, first 24 hex chars.
34
+ * What a revoke-one call names, and the only id that crosses the wire. */
35
+ handle: string;
36
+ userId: string;
37
+ createdAt: number;
38
+ /** Last request this session made, throttled to the minute — see `TOUCH`. */
39
+ lastSeenAt: number;
40
+ expiresAt: number;
41
+ /** The user-agent verbatim, bounded, never parsed here. `""` for a session
42
+ * minted before this column existed, or by a client that sent none. */
43
+ userAgent: string;
44
+ /** Best-effort client address, or `""`. Never used to authorize anything. */
45
+ ip: string;
46
+ /**
47
+ * Where the address was, when the session was created — `"Austin, Texas,
48
+ * US"`, or `""`.
49
+ *
50
+ * Stamped at sign-in and never refreshed, deliberately: the row answers
51
+ * "where was I when I signed in on this thing", and a value that moved with
52
+ * the session's later requests would make an old row disagree with the alert
53
+ * that was mailed about it. Added 2026-08-25 with the same owner ask that
54
+ * put the city in the security alerts.
55
+ */
56
+ place: string;
57
+ /** Is this the session the request asking the question is holding? Only ever
58
+ * true when `list` was given that request — "you are on this one" is the
59
+ * difference between signing someone else out and signing yourself out. */
60
+ current: boolean;
61
+ }
62
+ /** Who is signed in at one slot of this browser. */
63
+ export interface SlotOccupant {
64
+ slot: number;
65
+ userId: string;
66
+ }
67
+ /** How a new session differs from the store's defaults. */
68
+ export interface SignInOptions {
69
+ /**
70
+ * Which slot to put it in. Defaults to the slot the request names — which
71
+ * for every existing caller is 0, the bare cookie name.
72
+ */
73
+ slot?: number;
74
+ /**
75
+ * Lifetime for THIS session, overriding the store's default.
76
+ *
77
+ * This is what "remember me" buys, and it is a property of the session
78
+ * rather than of the store because the two answers have to coexist: the
79
+ * owner's own browser keeps a month-long session while a shared machine
80
+ * gets the short default. The row's `expires_at`, the cookie's embedded
81
+ * expiry and the cookie's `Max-Age` are all derived from this one number,
82
+ * so they cannot disagree.
83
+ */
84
+ ttlSeconds?: number;
85
+ }
86
+ /** A minted session and everything the caller needs to install it. */
87
+ export interface SignedIn {
88
+ /** The `Set-Cookie` header value, already slot- and lifetime-correct. */
89
+ cookie: string;
90
+ /** Where it landed — the caller has to tell the browser, via `?authuser=`. */
91
+ slot: number;
92
+ expiresAt: number;
93
+ }
94
+ export interface UserSessionStore {
95
+ /** The cookie name this store was built with (for tests and smokes). */
96
+ cookieName: string;
97
+ /**
98
+ * Mint a session for a user; returns the cookie VALUE.
99
+ *
100
+ * `req` is optional and every caller that has one should pass it: it is what
101
+ * stamps the device and address onto the row, and a session that cannot say
102
+ * where it came from is one the owner cannot recognise on the list. Omitting
103
+ * it is legal (a CLI-minted session, a test) and lands as `""`, never as a
104
+ * guess.
105
+ */
106
+ create(userId: string, req?: Request, options?: SignInOptions): string;
107
+ /**
108
+ * Mint a session AND the `Set-Cookie` that installs it, together.
109
+ *
110
+ * 🔴 Prefer this over `create` + `sessionCookie` for anything slot- or
111
+ * lifetime-aware. Those two are separate calls that each have to be told the
112
+ * same slot and the same TTL, and the failure when they are not told the
113
+ * same thing is silent: a session minted into slot 2 with a cookie written
114
+ * to slot 0 evicts the account the person was already using and signs them
115
+ * in as somebody else in the tab they did not touch.
116
+ */
117
+ signIn(userId: string, req: Request, options?: SignInOptions): SignedIn;
118
+ /** Which slot this request is acting as. Never throws; garbage means 0. */
119
+ slotOf(req: Request): number;
120
+ /**
121
+ * The account id this request's PAGE believes it is acting as, or null when
122
+ * it did not say. Only ever compared against the resolved user — never a
123
+ * credential, never a selector. See {@link ACCOUNT_USER_HEADER}.
124
+ */
125
+ expectedUserOf(req: Request): string | null;
126
+ /** The user id this request's cookie proves, or null. */
127
+ userIdOf(req: Request): string | null;
128
+ /**
129
+ * Every slot of this browser that holds a live session, slot order.
130
+ *
131
+ * This is the account switcher's whole data source, and the reason it can
132
+ * offer a one-click swap with no password: an account with a live session
133
+ * here is one this browser has already proved it may act as.
134
+ */
135
+ signedInSlots(req: Request): SlotOccupant[];
136
+ /**
137
+ * The slot already holding `userId` in this browser, or null.
138
+ *
139
+ * 🔴 Signing in as somebody who is already signed in must REUSE their slot,
140
+ * never take a second one. Otherwise every re-hop of an app that is already
141
+ * open burns a slot, and five visits leave no room for the second account
142
+ * the feature exists to hold.
143
+ */
144
+ slotForUser(req: Request, userId: string): number | null;
145
+ /**
146
+ * Where a NEW account should go: their existing slot, else the lowest empty
147
+ * one, else null when all {@link MAX_ACCOUNT_SLOTS} are taken.
148
+ *
149
+ * Null is a real answer the caller must render, not an error — "sign out of
150
+ * one of these first" is the only honest response, and silently evicting
151
+ * somebody's session to make room is the thing that must not happen.
152
+ */
153
+ slotToAdd(req: Request, userId: string): number | null;
154
+ /** End the session this request carries, in the slot it names. */
155
+ revoke(req: Request): void;
156
+ /**
157
+ * End the session at ONE named slot of this browser; true if there was one.
158
+ *
159
+ * Distinct from `revoke` because the switcher acts on a slot the request is
160
+ * NOT on — "remove that other account" is a button pressed from this tab
161
+ * about a different tab's session.
162
+ */
163
+ revokeAt(req: Request, slot: number): boolean;
164
+ /**
165
+ * End EVERY slot's session in this browser; returns the slots that held one.
166
+ *
167
+ * The shared-machine exit. Distinct from `revokeAllForUser`, which ends one
168
+ * account everywhere, where this ends every account in one place.
169
+ */
170
+ revokeEverySlot(req: Request): number[];
171
+ /** End every session of a user (delete / temp password). */
172
+ revokeAllForUser(userId: string): void;
173
+ /** End every OTHER session of a user (their own password change). */
174
+ revokeOthersForUser(userId: string, req: Request): void;
175
+ /**
176
+ * Every live session of one user, newest first.
177
+ *
178
+ * Expired rows are never returned — the sweep is opportunistic, so the query
179
+ * filters rather than trusting the table to be clean.
180
+ */
181
+ listForUser(userId: string, req?: Request): SessionRecord[];
182
+ /**
183
+ * End ONE session, named by its handle, and say whether it existed.
184
+ *
185
+ * 🔴 The user id is REQUIRED and is part of the match, not a courtesy. A
186
+ * handle is shown on a screen and travels between apps; scoping the delete
187
+ * to the account it was listed under means a stray, stale or guessed handle
188
+ * can only ever end a session of the person it was already about.
189
+ */
190
+ revokeByHandle(userId: string, handle: string): boolean;
191
+ /**
192
+ * `Set-Cookie` for a fresh value, TLS-aware.
193
+ *
194
+ * `Max-Age` is read out of the VALUE's own embedded expiry rather than from
195
+ * the store's default, so a remember-me session's cookie outlives the
196
+ * default the same way its row does. A value that cannot be read falls back
197
+ * to the store default — a cookie slightly too short is a re-login, where
198
+ * one too long is a dead cookie sent on every request forever.
199
+ */
200
+ sessionCookie(value: string, req: Request, slot?: number): string;
201
+ /** `Set-Cookie` that ends the browser's copy, for one slot. */
202
+ clearedCookie(req: Request, slot?: number): string;
203
+ }
204
+ export declare function createUserSessionStore(options: UserSessionStoreOptions): UserSessionStore;
205
+ //# sourceMappingURL=userSessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userSessions.d.ts","sourceRoot":"","sources":["../src/userSessions.ts"],"names":[],"mappings":"AA8EA,OAAO,EAKN,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,uBAAuB;IACvC,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,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