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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Curt Phillips
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # cursedauth
2
+
3
+ The **app side** of "sign in through the accounts service". Mount it in a Bun + Hono
4
+ app and the app has sessions, multi-account switching, an account menu, and a gate —
5
+ without a password surface of its own.
6
+
7
+ ```ts
8
+ import { createSsoConsumer, createUserSessionStore, mountGatedApp } from "cursedauth";
9
+
10
+ const sessions = createUserSessionStore({
11
+ cookieName: "flix_session",
12
+ dbPath: `${dataDir}/sessions.sqlite`,
13
+ sessionSecret,
14
+ sessionTtlSeconds: 60 * 60 * 24 * 30,
15
+ });
16
+ const sso = createSsoConsumer({
17
+ app: "flix",
18
+ authUrl: "https://auth.example.com",
19
+ publicUrl: "https://flix.example.com",
20
+ registeredAudiences: ["flix", "flix-local"],
21
+ sessions,
22
+ db,
23
+ });
24
+ mountGatedApp(app, { gate: sso, mountPublic: (a) => sso.mountSsoRoutes(a), mount: routes });
25
+ ```
26
+
27
+ ## What it is not
28
+
29
+ It is **the consumer**, never the provider. It holds no password, mints no grant, and
30
+ has no user table beyond a local snapshot of whoever has signed in *here* — so
31
+ request-time auth never calls out, and the accounts service being down breaks new
32
+ logins and nothing else. The provider is a separate service reached over HTTPS at
33
+ `authUrl`; this package's only knowledge of it is that URL and its public key.
34
+
35
+ ## Subpaths
36
+
37
+ | import | side | what |
38
+ |---|---|---|
39
+ | `cursedauth` | server | the barrel: consumer, sessions, gate, census |
40
+ | `cursedauth/sso-consumer` | server | the six routes and `requireUser` |
41
+ | `cursedauth/user-sessions` | server | signed cookies + a sessions table, per app |
42
+ | `cursedauth/mount-gated` | server | mount public routes before the gate, gated ones after |
43
+ | `cursedauth/content-census` | server | answer "what has this account made here?" by COUNT |
44
+ | `cursedauth/account-slots` | both | several accounts signed in on one browser |
45
+ | `cursedauth/auth` | browser | `startSsoSignIn`, `useSsoAutoSignIn`, session hooks |
46
+ | `cursedauth/account-ui` | browser | the account menu |
47
+ | `cursedauth/account-slot-client` | browser | slot switching in the page |
48
+
49
+ 🔴 The barrel reaches `bun:sqlite`. A browser bundle imports the three browser
50
+ subpaths and never the root.
51
+
52
+ ## Where it came from, and what was cut
53
+
54
+ Extracted 2026-09-14 from the previous generation's `satellite-kit`, which was the
55
+ whole application platform — build, vite, dev-runner, smokes, backups, launchd
56
+ agents, route manifests, metrics, mail — with identity inside it. Only identity
57
+ came here.
58
+
59
+ Measured before the cut. Seeding the closure from the subpaths apps import and
60
+ following relative imports:
61
+
62
+ | seeded from | files | what pulled the tail in |
63
+ |---|---|---|
64
+ | the 8 subpaths **including the root barrel** | 65 | the root IS the whole satellite server: metrics, engagement, mail, binary store |
65
+ | **the 7 identity subpaths only** | 25 | — |
66
+ | what this package ships | **21** | see the three cuts below |
67
+
68
+ `@aws-sdk/client-ses` was the dependency the extraction was told to prune. It never
69
+ had to be pruned: it enters through `mailer.ts`, which is reachable only from the
70
+ root satellite-server barrel, not from `sso-consumer` or `user-sessions`. This
71
+ package's external surface is `hono`, `react`, `react-dom`, `bun:sqlite` and node
72
+ builtins — nothing else, and no runtime `dependencies` block at all.
73
+
74
+ Three things were deliberately left behind:
75
+
76
+ - **`fleet/registry.ts` + `fleet/directory.ts` (936 lines)** — a fleet-wide table of
77
+ every app compiled into the shared library, and the `/api/fleet/directory` route
78
+ that served it. Every app carried a roster of every other app, so adding one meant
79
+ editing the platform. The one thing the consumer genuinely needed from it is now
80
+ `SsoConsumerOptions.registeredAudiences`: an app declares its own doors.
81
+ - **`ipGeo.ts`** — a machine-wide 375 MB IP→city snapshot, defaulted-on, living
82
+ outside any repo. `placeLookup` is still injectable; unset, a session row records
83
+ the city the edge headers already carry.
84
+ - **`ownerAuth.server.ts`** — single-principal password auth (argon2, one owner).
85
+ Nothing here signs in that way, and keeping it would have made `cursedbelt` a
86
+ runtime dependency of an auth library for one re-exported type. The SSO path used
87
+ exactly one function from it; that is `src/secureRequest.ts`, with its own suite.
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The account menu every satellite puts in its header — who you are, and the
3
+ * three things you can do about it.
4
+ *
5
+ * ── Why it exists (2026-08-10, owner report) ────────────────────────────────
6
+ * "I logged out for someone to log in and there wasn't a way to change users."
7
+ * Both halves of that were true, and neither was one app's bug:
8
+ *
9
+ * 1. **Sign out did not sign you out.** Every app ended its OWN cookie and
10
+ * stopped there; auth's session outlived it. The next press of "Sign in" —
11
+ * or the automatic hop on the next page load — traded that surviving
12
+ * session for a fresh grant and returned the SAME person, with no password
13
+ * asked for. There was no sequence of clicks that made a satellite forget
14
+ * you.
15
+ * 2. **Nothing offered to change users.** Even reaching the accounts app by
16
+ * hand did not help: `/sso/authorize` had exactly one answer for a browser
17
+ * with a live session, and it was a grant for that session's user.
18
+ *
19
+ * The fix is one door at each end — `?switch=1` → `prompt=login` at authorize,
20
+ * and `/api/auth/sso/signout` → `/sso/logout` for a sign-out that reaches
21
+ * auth's own session — and THIS is the thing that puts them in front of a
22
+ * person. Eight apps had hand-rolled a name-and-a-dropdown by then, all
23
+ * slightly differently and all with the same two gaps, which is why the menu
24
+ * itself is now shared rather than each app growing two more buttons.
25
+ *
26
+ * ── Why it ships its own stylesheet ─────────────────────────────────────────
27
+ * Same reason as `FleetDirectory`, which it sits beside in every header: the
28
+ * satellites keep per-app Tailwind `@source` lists, so a widget from this
29
+ * package styled with utility classes renders correctly in whichever apps
30
+ * remembered to add a line and silently unstyled in the rest. The machinery is
31
+ * shared with the directory (`../ui/popover`) so the two cannot drift into
32
+ * different ideas of dark mode, or dismiss differently, 8px apart.
33
+ */
34
+ import { type ReactNode } from "react";
35
+ /** The popover's ideal width in px, matching `min(17rem, …)` in {@link STYLES}
36
+ * below — see `anchoredLeft` in `../ui/popover` for why the real number has to
37
+ * be known in JS and not only in CSS.
38
+ *
39
+ * 🔴 It said 240 while the stylesheet had been widened to 17rem, and the
40
+ * comment above it still named the old 15rem. The off-screen clamp is
41
+ * arithmetic over THIS number, so it reserved 240px for a 272px panel and
42
+ * pushed the last 32px of the account menu off the right edge of every screen
43
+ * — the exact defect the clamp exists to prevent, hiding behind a comment that
44
+ * described a width the CSS no longer had. Exported, with {@link STYLES}, so
45
+ * `../ui/panelWidth.test.ts` can assert the two against each other instead of
46
+ * a sentence here promising they match. */
47
+ export declare const PANEL_WIDTH = 272;
48
+ export declare const STYLES = "\n.sam{--sam-panel:#ffffff;--sam-border:#d9dde3;--sam-text:#1a1d21;--sam-muted:#68707c;\n --sam-hover:#f2f4f7;--sam-danger:#b42318;--sam-accent:#4f6ef7;--sam-shadow:0 12px 32px rgba(16,18,22,.16);\n font:14px/1.5 ui-sans-serif,system-ui,-apple-system,sans-serif;color:var(--sam-text)}\n.sam[data-dark=\"true\"]{--sam-panel:#181b21;--sam-border:#2c313a;--sam-text:#e6e9ee;--sam-muted:#8b93a1;\n --sam-hover:#22262e;--sam-danger:#f97066;--sam-accent:#7f97ff;--sam-shadow:0 12px 32px rgba(0,0,0,.5)}\n/* \uD83D\uDD34 `min-width:0` is what makes `.sam-who`'s ellipsis (below) REACHABLE, and\n without it that rule is dead CSS \u2014 measured on live roms, 2026-09-08.\n\n A flex item's `min-width` defaults to `auto`, i.e. its min-content width, and\n `.sam-who` is `white-space:nowrap` \u2014 so the launcher's min-content size is the\n WHOLE name, however long. Flex could not shrink it, the name never truncated,\n and the launcher simply overflowed its slot. Where it overflowed was decided by\n the host header's `justify-content`: roms right-aligns its account controls, so\n the overflow travelled LEFT and painted the account button on top of the app\n title \u2014 79px of overlap at 320px, 39px at 360px, and the button's own avatar\n starting at x=-26, off the side of the screen. `document.scrollWidth` was\n unchanged throughout, which is why nothing anywhere reported it: the row does\n not push the page wide, it collides inside itself.\n\n With these two declarations the ellipsis finally does its job \u2014 the name gives\n up as much width as the row needs and gives up the last of it entirely, leaving\n the avatar and its caret, which is the right phone-shaped answer for an account\n control anyway. Nothing changes at a width that already fit (measured: 430px\n identical before and after), because flex only shrinks an item that has to.\n `max-width:100%` keeps the wrapper from being the new floor now that the\n launcher inside it can shrink.\n\n The header that found it asserts the outcome rather than this mechanism \u2014\n apps/roms/__smoke/headerFit.spec.ts, which measures real boxes in a real\n browser at four phone widths. It is the only kind of check that can see this. */\n.sam-wrap{position:relative;display:inline-block;min-width:0;max-width:100%}\n.sam-launch{display:inline-flex;align-items:center;gap:7px;max-width:min(14rem,100%);height:34px;\n min-width:0;padding:0 8px 0 4px;\n border:1px solid transparent;border-radius:999px;background:transparent;color:inherit;cursor:pointer;\n font:inherit;font-size:13px}\n@media (pointer:coarse){.sam-launch{height:44px}}\n/* The circle. --sam-av is the ONE size knob: the ring, the glyph and the initials all\n derive from it, so the launcher and the panel head cannot drift apart. */\n.sam-av{--sam-av:26px;flex:none;display:inline-flex;align-items:center;justify-content:center;\n width:var(--sam-av);height:var(--sam-av);border-radius:50%;overflow:hidden;\n background:color-mix(in srgb,var(--sam-accent,#4f6ef7) 16%,transparent);\n color:var(--sam-accent,#4f6ef7);font-size:calc(var(--sam-av) * .42);font-weight:650;\n line-height:1;letter-spacing:.02em;user-select:none}\n.sam-av img{width:100%;height:100%;object-fit:cover;display:block}\n.sam-head .sam-av{--sam-av:40px}\n.sam-launch:hover,.sam-launch[aria-expanded=\"true\"]{background:var(--sam-hover);border-color:var(--sam-border)}\n/* `min-width:0` for the same reason as `.sam-launch` above, one level down: this\n is itself a flex item, so its `auto` minimum is the un-wrappable name and the\n ellipsis below it could never fire. All three levels of the chain have to\n allow shrinking or none of them does \u2014 the launcher stops overflowing its\n header while the LABEL goes on overflowing the launcher, which is a collision\n that has merely moved one control to the right. Measured: the first attempt at\n this fix did exactly that, and headerFit.spec.ts is what said so. */\n.sam-who{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.sam-caret{flex:none;opacity:.6;font-size:10px}\n/* \uD83D\uDD34 `left` and `top` are BOTH set inline by usePopoverPosition, and the panel\n is PORTALED to <body> \u2014 see `anchoredTop`. `fixed` because the panel is no\n longer inside the launcher, and NO default `top`, because a hardcoded\n \"always below\" is what put the fleet launcher's panel off the bottom of the\n screen (E22, 2026-09-09). This menu shares the control, so it shares the fix. */\n.sam-pop{position:fixed;right:auto;z-index:2147482000;width:min(17rem,calc(100vw - 32px));\n background:var(--sam-panel);border:1px solid var(--sam-border);border-radius:12px;box-shadow:var(--sam-shadow);\n padding:6px;display:flex;flex-direction:column;gap:1px}\n.sam-head{display:flex;align-items:center;gap:10px;padding:8px 8px 10px;\n border-bottom:1px solid var(--sam-border);margin-bottom:5px}\n.sam-head-text{min-width:0;flex:1}\n.sam-name{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.sam-sub{font-size:11.5px;color:var(--sam-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n/* \uD83D\uDD34 44px, the designer's number for a menu row (2026-08-19). display:flex rather\n than block so the min-height actually centres the label instead of leaving it\n glued to the top of a taller box. */\n.sam-item{display:flex;align-items:center;width:100%;min-height:44px;text-align:left;\n padding:7px 10px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;\n font-size:13px;cursor:pointer;text-decoration:none}\n.sam-item:hover{background:var(--sam-hover)}\n.sam-item[data-tone=\"danger\"]{color:var(--sam-danger)}\n.sam-hint{font-size:11px;color:var(--sam-muted);padding:1px 8px 4px}\n.sam-rule{height:1px;background:var(--sam-border);margin:5px 0}\n.sam-label{font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;\n color:var(--sam-muted);padding:4px 8px 3px}\n/* One row per other account: a big target that SWITCHES, plus a small one that\n opens a second window. Grid rather than flex so the switch button gets every\n pixel the open button does not, and long addresses ellipsize instead of\n pushing the \u29C9 off the panel. */\n.sam-acct{display:grid;grid-template-columns:1fr auto;align-items:stretch;gap:1px;border-radius:8px}\n.sam-acct:hover{background:var(--sam-hover)}\n.sam-acct .sam-item{display:block;border-radius:8px 0 0 8px;padding-top:6px;padding-bottom:6px}\n.sam-acct-who{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.sam-acct-sub{display:block;font-size:11px;color:var(--sam-muted);overflow:hidden;\n text-overflow:ellipsis;white-space:nowrap}\n.sam-open{flex:none;width:44px;border:0;border-radius:0 8px 8px 0;background:transparent;\n color:var(--sam-muted);cursor:pointer;font:inherit;font-size:13px}\n.sam-open:hover{background:var(--sam-hover);color:var(--sam-text)}\n.sam-badge{font-size:10px;font-weight:600;color:var(--sam-muted);border:1px solid var(--sam-border);\n border-radius:5px;padding:0 4px;margin-left:6px;vertical-align:1px}\n";
49
+ export interface AccountMenuProps {
50
+ /** What to call the signed-in person — `user.name || user.email`. */
51
+ name: string;
52
+ /** Shown under the name in the panel when it adds something the name does
53
+ * not already say (i.e. skipped when it IS the name). */
54
+ email?: string;
55
+ /**
56
+ * The accounts origin the SERVER advertises (`session.accountsUrl`).
57
+ *
58
+ * Empty or absent means this app is not an SSO door — the local vault
59
+ * daemon and the owner-password apps answer exactly that, on purpose. The
60
+ * three SSO items then render nothing at all, because there is no accounts
61
+ * satellite to manage anything at, nobody to switch to, and no second
62
+ * session to end. Such an app passes `onSignOut` and gets a menu with its
63
+ * own sign-out in it.
64
+ */
65
+ accountsUrl?: string | null;
66
+ /**
67
+ * App-specific entries, rendered above the account block. For the things
68
+ * only that app has — "Lock the vault", "Engine settings".
69
+ *
70
+ * A render prop rather than plain children so an item can dismiss the menu
71
+ * it lives in. Wrapping the children in a click handler here would do the
72
+ * same job and be a lint suppression plus a guess about which clicks meant
73
+ * "done"; handing the caller `close` costs one argument and guesses nothing.
74
+ * `.sam-item` is the class to put on each entry.
75
+ */
76
+ children?: (close: () => void) => ReactNode;
77
+ /**
78
+ * Replaces the GLOBAL sign-out. Pass it only when this app is not an SSO
79
+ * door: the whole point of the shared menu is that "Sign out" means the same
80
+ * thing everywhere, and an app that overrides it re-opens the gap this
81
+ * component exists to close. To run app cleanup and still leave properly,
82
+ * use `onLeave`.
83
+ */
84
+ onSignOut?: () => void | Promise<void>;
85
+ /**
86
+ * Run immediately before this browser stops being this person's — on BOTH
87
+ * "Switch user" and "Sign out".
88
+ *
89
+ * For the app-local state that a session cookie does not cover: notes holds
90
+ * decrypted secrets in memory and locks them here. Both doors need it and
91
+ * for the same reason, so it is one hook rather than two — a cleanup wired
92
+ * to sign-out alone would leak the moment somebody switched instead.
93
+ *
94
+ * Synchronous on purpose: what follows is a full-page navigation, so a
95
+ * promise would be abandoned mid-flight. Anything that must survive belongs
96
+ * on the server.
97
+ */
98
+ onLeave?: () => void;
99
+ /** Overrides for the consumer's mounted paths. Defaults are correct for
100
+ * every app that mounts `cursedauth/sso-consumer` normally. */
101
+ startPath?: string;
102
+ signOutPath?: string;
103
+ /**
104
+ * The other accounts this browser holds, if the app already has them.
105
+ *
106
+ * Optional because the menu can ask for itself: with this absent it reads
107
+ * `/api/auth/session` the first time it is OPENED, so eighteen apps inherit
108
+ * the switcher without threading a prop through eighteen headers. An app
109
+ * that already has the data (it made that same call to render its shell)
110
+ * passes it and saves the round trip.
111
+ */
112
+ accounts?: BrowserAccount[];
113
+ /** Where the menu asks, when `accounts` is not given. */
114
+ sessionPath?: string;
115
+ /**
116
+ * This account's id — what the shared profile picture is keyed on.
117
+ *
118
+ * Optional, and when it is absent the menu asks `/api/auth/session` for it. That is
119
+ * the whole reason eighteen apps inherited the picture with no per-app edit: the
120
+ * owner's ask was *"only have to set it once"*, and a required prop would have made
121
+ * it "set it once and then wire it eighteen times". An app that already holds the
122
+ * session (most of them do — they rendered a name from it) passes it and saves the
123
+ * request.
124
+ */
125
+ userId?: string;
126
+ }
127
+ /** One account signed in on this browser, as `/api/auth/session` reports it. */
128
+ export interface BrowserAccount {
129
+ slot: number;
130
+ id: string;
131
+ email: string;
132
+ name: string;
133
+ }
134
+ /**
135
+ * Forget what the probe learned.
136
+ *
137
+ * Exported for tests, and named for what it is rather than hidden behind an underscore:
138
+ * a page-lifetime cache is correct in a browser (the session can only change through a
139
+ * navigation, which remounts everything) and wrong in a test file, where ten renders share
140
+ * one module. Without this, the second test's fetch mock is never called and its
141
+ * assertions wait on the FIRST test's answer.
142
+ */
143
+ export declare function resetAccountSessionProbe(): void;
144
+ /** Forget the fetched pictures. Exported for the same reason as its session sibling. */
145
+ export declare function resetAccountPictureProbe(): void;
146
+ /**
147
+ * The header account menu. Renders a name button; the panel carries whatever
148
+ * the app passed as `children`, then the account block.
149
+ */
150
+ export declare function AccountMenu({ name, email, accountsUrl, children, onSignOut, onLeave, startPath, signOutPath, accounts, sessionPath, userId, }: AccountMenuProps): import("react").JSX.Element;
151
+ export { AccountNotice, type AccountNoticeProps } from "./AccountNotice";
152
+ export { useAccountNotice, type AccountNoticeState } from "./accountNotice.state";
153
+ //# sourceMappingURL=AccountMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountMenu.d.ts","sourceRoot":"","sources":["../../src/account/AccountMenu.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAQ,KAAK,SAAS,EAAiC,MAAM,OAAO,CAAC;AA4B5E;;;;;;;;;;;4CAW4C;AAC5C,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,MAAM,ugOAgGlB,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;8DAC0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IAC5C;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;oEACgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAkDD,wFAAwF;AACxF,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AA0ED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC3B,IAAI,EACJ,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,EACP,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAA0B,EAC1B,MAAM,GACN,EAAE,gBAAgB,+BAsRlB;AAOD,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}