@coffre/ui 0.2.0 → 0.4.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 (177) hide show
  1. package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
  2. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
  3. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  4. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  5. package/dist/chunks/{directory-CSjWWUQ1.js → directory-zr3ek7Mc.js} +175 -60
  6. package/dist/chunks/directory-zr3ek7Mc.js.map +1 -0
  7. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  8. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  9. package/dist/chunks/grants-Cw1FyGID.js +669 -0
  10. package/dist/chunks/grants-Cw1FyGID.js.map +1 -0
  11. package/dist/chunks/offboarding-CE6d7um1.js +305 -0
  12. package/dist/chunks/offboarding-CE6d7um1.js.map +1 -0
  13. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  14. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  15. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  16. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  17. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  18. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  19. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-DhjO76GH.js} +245 -251
  20. package/dist/chunks/principal-page-DhjO76GH.js.map +1 -0
  21. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  22. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  23. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  24. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  25. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  26. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  27. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  28. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  29. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  30. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  31. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  32. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  33. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  34. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  35. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  36. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  37. package/dist/chunks/{use-change-c6CeLRin.js → use-change-DUiGO19U.js} +52 -21
  38. package/dist/chunks/use-change-DUiGO19U.js.map +1 -0
  39. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  40. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  41. package/dist/chunks/validation-D312_NLf.js +87 -0
  42. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  43. package/dist/index.d.ts +361 -27
  44. package/dist/index.js +188 -98
  45. package/dist/index.js.map +1 -1
  46. package/dist/pages/account.d.ts +2 -2
  47. package/dist/pages/account.js +297 -135
  48. package/dist/pages/account.js.map +1 -1
  49. package/dist/pages/approval.d.ts +9 -0
  50. package/dist/pages/approval.js +207 -0
  51. package/dist/pages/approval.js.map +1 -0
  52. package/dist/pages/audit.js +17 -542
  53. package/dist/pages/audit.js.map +1 -1
  54. package/dist/pages/device-login.js +2 -3
  55. package/dist/pages/device-login.js.map +1 -1
  56. package/dist/pages/environment.js +647 -257
  57. package/dist/pages/environment.js.map +1 -1
  58. package/dist/pages/login.js +18 -7
  59. package/dist/pages/login.js.map +1 -1
  60. package/dist/pages/oauth-authorize.d.ts +10 -0
  61. package/dist/pages/oauth-authorize.js +249 -0
  62. package/dist/pages/oauth-authorize.js.map +1 -0
  63. package/dist/pages/project-access.d.ts +6 -0
  64. package/dist/pages/project-access.js +370 -0
  65. package/dist/pages/project-access.js.map +1 -0
  66. package/dist/pages/project-environments.d.ts +4 -0
  67. package/dist/pages/project-environments.js +593 -0
  68. package/dist/pages/project-environments.js.map +1 -0
  69. package/dist/pages/project-settings.d.ts +4 -0
  70. package/dist/pages/project-settings.js +242 -0
  71. package/dist/pages/project-settings.js.map +1 -0
  72. package/dist/pages/project.d.ts +10 -2
  73. package/dist/pages/project.js +57 -934
  74. package/dist/pages/project.js.map +1 -1
  75. package/dist/pages/projects.js +53 -21
  76. package/dist/pages/projects.js.map +1 -1
  77. package/dist/pages/service-account.d.ts +10 -0
  78. package/dist/pages/{token.js → service-account.js} +115 -56
  79. package/dist/pages/service-account.js.map +1 -0
  80. package/dist/pages/service-accounts.d.ts +3 -0
  81. package/dist/pages/service-accounts.js +38 -0
  82. package/dist/pages/service-accounts.js.map +1 -0
  83. package/dist/pages/settings.d.ts +1 -0
  84. package/dist/pages/settings.js +104 -42
  85. package/dist/pages/settings.js.map +1 -1
  86. package/dist/pages/unregistered.js +2 -3
  87. package/dist/pages/unregistered.js.map +1 -1
  88. package/dist/pages/user.d.ts +6 -1
  89. package/dist/pages/user.js +18 -6
  90. package/dist/pages/user.js.map +1 -1
  91. package/dist/pages/users.js +6 -10
  92. package/dist/pages/users.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/components/actions-log.tsx +117 -0
  95. package/src/components/audit-sentence.tsx +55 -0
  96. package/src/components/command-palette.tsx +4 -4
  97. package/src/components/delete-place.tsx +180 -0
  98. package/src/components/directory.tsx +259 -110
  99. package/src/components/every-project.tsx +287 -0
  100. package/src/components/expiry-field.tsx +42 -0
  101. package/src/components/folders.tsx +219 -0
  102. package/src/components/grants.tsx +11 -4
  103. package/src/components/icons.tsx +2 -0
  104. package/src/components/missing.tsx +110 -0
  105. package/src/components/offboarding.tsx +61 -33
  106. package/src/components/page.tsx +4 -1
  107. package/src/components/principal-page.tsx +136 -106
  108. package/src/components/principal-picker.tsx +5 -5
  109. package/src/components/principal.tsx +4 -4
  110. package/src/components/references.tsx +323 -0
  111. package/src/components/service-tokens.tsx +115 -95
  112. package/src/components/shell.tsx +11 -32
  113. package/src/components/tabs.tsx +18 -0
  114. package/src/components/trusted-workloads.tsx +97 -79
  115. package/src/components/ui.tsx +8 -1
  116. package/src/index.ts +13 -2
  117. package/src/layout.tsx +2 -2
  118. package/src/lib/access-plan.ts +2 -2
  119. package/src/lib/audit-sentences.ts +161 -77
  120. package/src/lib/changes.ts +56 -5
  121. package/src/lib/coffre.ts +3 -2
  122. package/src/lib/one-time.ts +32 -0
  123. package/src/lib/project-access.ts +11 -23
  124. package/src/lib/project-page.ts +14 -0
  125. package/src/lib/queries.ts +126 -32
  126. package/src/lib/search.ts +25 -0
  127. package/src/lib/signin-errors.ts +45 -1
  128. package/src/lib/validation.ts +14 -0
  129. package/src/options.ts +187 -35
  130. package/src/pages/account.tsx +274 -129
  131. package/src/pages/approval.tsx +197 -0
  132. package/src/pages/audit.tsx +9 -61
  133. package/src/pages/environment.tsx +585 -286
  134. package/src/pages/login.tsx +8 -2
  135. package/src/pages/oauth-authorize.tsx +233 -0
  136. package/src/pages/project-access.tsx +219 -0
  137. package/src/pages/project-environments.tsx +582 -0
  138. package/src/pages/project-settings.tsx +259 -0
  139. package/src/pages/project.tsx +52 -879
  140. package/src/pages/projects.tsx +55 -18
  141. package/src/pages/service-account.tsx +50 -0
  142. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  143. package/src/pages/settings.tsx +62 -8
  144. package/src/pages/user.tsx +16 -4
  145. package/src/pages/users.tsx +2 -2
  146. package/src/parity.ts +160 -0
  147. package/src/register.ts +58 -9
  148. package/src/router.tsx +4 -0
  149. package/src/shared/models.ts +6 -2
  150. package/src/styles/globals.css +536 -31
  151. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  152. package/dist/chunks/grants-saMQagmG.js +0 -160
  153. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  154. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  155. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  156. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  157. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  158. package/dist/chunks/page-C5HcNqf2.js +0 -190
  159. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  160. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  161. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  162. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  163. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  164. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  165. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  166. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  167. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  168. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  169. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  170. package/dist/pages/token.d.ts +0 -3
  171. package/dist/pages/token.js.map +0 -1
  172. package/dist/pages/tokens.d.ts +0 -3
  173. package/dist/pages/tokens.js +0 -39
  174. package/dist/pages/tokens.js.map +0 -1
  175. package/dist/project-BqIy8gYR.d.ts +0 -5
  176. package/src/lib/instance.ts +0 -13
  177. package/src/pages/token.tsx +0 -34
package/dist/index.js CHANGED
@@ -1,36 +1,24 @@
1
1
  import { n as isActiveAccessibleEnvironment } from "./chunks/project-environments-lEzFHUt4.js";
2
2
  import { t as useMounted } from "./chunks/mounted-jJmqqV_n.js";
3
- import { _ as rememberSidebar, c as Notice, d as Tip, g as browserPreferences, h as PreferencesContext, o as MenuPopup, p as TooltipProvider, v as rememberTheme, y as usePreferences } from "./chunks/ui-DixXLQvQ.js";
3
+ import { _ as rememberSidebar, d as Tip, g as browserPreferences, h as PreferencesContext, o as MenuPopup, p as TooltipProvider, v as rememberTheme, y as usePreferences } from "./chunks/ui-DJje3gST.js";
4
4
  import { a as administrationEntries, t as AdministrationItems } from "./chunks/affordances-DAvsVz7u.js";
5
- import { D as Moon, E as Monitor, F as Settings, G as X, L as SignOut, P as Search, R as SlashCircle, T as Menu$1, U as UserCog, W as Users, a as Check, b as Ledger, c as ChevronsUpDown, k as PanelLeft, m as GitHub, p as Folder, r as AlertTriangle, v as Key, w as Mark, y as Layers, z as Sun } from "./chunks/icons-D-PfAfnH.js";
6
- import { n as ThemeMenuItems, r as ThemeToggle } from "./chunks/theme-B2vQolVR.js";
7
- import { d as Tile, l as uiResult, n as ClosedDoor, u as useCoffre } from "./chunks/page-C5HcNqf2.js";
8
- import { n as LiveRegion } from "./chunks/row-state-0PsrEzOL.js";
9
- import { a as loadPrincipal, i as loadDirectory, n as createQueryClient, o as loadProject, s as loadShell, u as queries } from "./chunks/queries-CQ81o4so.js";
10
- import { t as useShell } from "./chunks/use-shell-jxd7Tzd-.js";
5
+ import { A as Key, E as GitHub, I as Mark, K as Search, L as Menu$1, M as Ledger, R as Monitor, T as Folder, V as PanelLeft, X as SlashCircle, Y as SignOut, Z as Sun, _ as Check, b as ChevronsUpDown, d as Tile, it as X, j as Layers, l as uiResult, m as AlertTriangle, n as ClosedDoor, nt as UserCog, q as Settings, rt as Users, s as memberRef, u as useCoffre, z as Moon } from "./chunks/page-DvsgZ2Hd.js";
6
+ import { n as ThemeMenuItems, r as ThemeToggle } from "./chunks/theme-DJuz-xLM.js";
7
+ import { n as LiveRegion } from "./chunks/row-state-DOPUsjQK.js";
8
+ import { a as loadDirectory, c as loadServiceDirectory, f as projectOf, g as signInWays, i as loadAccess, l as loadSettings, n as createQueryClient, o as loadMember, p as queries, s as loadProject, u as loadShell } from "./chunks/queries-DVR_i3rA.js";
9
+ import { t as useShell } from "./chunks/use-shell-rNKfGjdj.js";
10
+ import { t as loginSearch } from "./chunks/signin-errors--ykMFuqN.js";
11
11
  import { useEffect, useMemo, useRef, useState } from "react";
12
12
  import { Link, Outlet, createRouter as createRouter$1, redirect, useNavigate, useRouter, useRouterState } from "@tanstack/react-router";
13
13
  import { Toaster } from "sonner";
14
14
  import { Dialog } from "@base-ui/react/dialog";
15
15
  import { Menu } from "@base-ui/react/menu";
16
- import { NO_MIDDLEWARE } from "@coffre/core/pages";
16
+ import { NO_MIDDLEWARE, PROJECT_PAGES } from "@coffre/core/pages";
17
17
  import { Autocomplete } from "@base-ui/react/autocomplete";
18
18
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
19
  import { createClient } from "@coffre/client";
20
20
  import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
21
21
  import { getGlobalStartContext } from "@tanstack/react-start";
22
- //#region src/lib/instance.ts
23
- /** Where an owner reads how to upgrade: update the CLI, deploy, then migrate. */
24
- var UPGRADE_DOC = "https://github.com/erwinkn/coffre/blob/main/docs/deploy.md#upgrading";
25
- /**
26
- * The migrations this instance's code ships and its database lacks. Only
27
- * owners and root admins are told an instance's state; for anyone else it
28
- * is null, and nothing is pending as far as they can tell.
29
- */
30
- function pendingMigrations(instance) {
31
- return instance === null ? [] : instance.migrations.known.slice(instance.migrations.applied);
32
- }
33
- //#endregion
34
22
  //#region src/components/command-palette.tsx
35
23
  /**
36
24
  * Every word of the query appears somewhere in the command's value, so
@@ -129,11 +117,11 @@ function CommandPalette({ projects, capabilities }) {
129
117
  path: "/users",
130
118
  run: closing(() => navigate({ to: "/users" }))
131
119
  }, {
132
- value: "tokens service accounts machines ci directory",
120
+ value: "service accounts tokens machines ci oidc directory",
133
121
  icon: /* @__PURE__ */ jsx(Key, { size: 15 }),
134
- label: "Tokens",
135
- path: "/tokens",
136
- run: closing(() => navigate({ to: "/tokens" }))
122
+ label: "Service accounts",
123
+ path: "/service-accounts",
124
+ run: closing(() => navigate({ to: "/service-accounts" }))
137
125
  }],
138
126
  audit: [{
139
127
  value: "audit log history reads",
@@ -300,41 +288,6 @@ function roleLabel(principal, instanceRole) {
300
288
  if (instanceRole === "owner") return "Owner";
301
289
  return "Member";
302
290
  }
303
- /**
304
- * Above every page, for owners and root admins, while the database is behind
305
- * the code this instance runs: what to run, and where the steps are.
306
- */
307
- function MigrationBanner({ instance }) {
308
- const pending = pendingMigrations(instance);
309
- if (pending.length === 0) return null;
310
- return /* @__PURE__ */ jsx("div", {
311
- className: "migration-banner",
312
- children: /* @__PURE__ */ jsxs(Notice, {
313
- tone: "info",
314
- children: [
315
- /* @__PURE__ */ jsx("strong", { children: "Database migrations pending:" }),
316
- " run ",
317
- /* @__PURE__ */ jsx("code", { children: "coffre migrate" }),
318
- " to apply",
319
- " ",
320
- /* @__PURE__ */ jsx("span", {
321
- className: "mono",
322
- children: pending.join(", ")
323
- }),
324
- ", which coffre ",
325
- instance?.version,
326
- " ships.",
327
- " ",
328
- /* @__PURE__ */ jsx("a", {
329
- href: UPGRADE_DOC,
330
- target: "_blank",
331
- rel: "noreferrer",
332
- children: "How to upgrade"
333
- })
334
- ]
335
- })
336
- });
337
- }
338
291
  /** The product's mark and name, for the pages you see before signing in. */
339
292
  function Brand() {
340
293
  return /* @__PURE__ */ jsxs("span", {
@@ -356,7 +309,7 @@ function Brand() {
356
309
  * navigation lives outside the pages themselves. Everywhere else the page's
357
310
  * own title says where you are, so the bar leaves it out rather than repeat it.
358
311
  */
359
- function Shell({ projects, principal, instanceRole, capabilities, instance, children }) {
312
+ function Shell({ projects, principal, instanceRole, capabilities, children }) {
360
313
  const { portal } = usePreferences();
361
314
  const pathname = useRouterState({ select: (state) => state.location.pathname });
362
315
  const [drawerOpen, setDrawerOpen] = useState(false);
@@ -451,10 +404,10 @@ function Shell({ projects, principal, instanceRole, capabilities, instance, chil
451
404
  })]
452
405
  })
453
406
  ]
454
- }), /* @__PURE__ */ jsxs("main", {
407
+ }), /* @__PURE__ */ jsx("main", {
455
408
  className: "content",
456
409
  id: "content",
457
- children: [/* @__PURE__ */ jsx(MigrationBanner, { instance }), children]
410
+ children
458
411
  })]
459
412
  })]
460
413
  });
@@ -496,8 +449,8 @@ function Sidebar({ principal, instanceRole, capabilities, collapsed = false, clo
496
449
  icon: /* @__PURE__ */ jsx(Users, { size: 16 }),
497
450
  collapsed
498
451
  }), /* @__PURE__ */ jsx(NavLink, {
499
- to: "/tokens",
500
- label: "Tokens",
452
+ to: "/service-accounts",
453
+ label: "Service accounts",
501
454
  icon: /* @__PURE__ */ jsx(Key, { size: 16 }),
502
455
  collapsed
503
456
  })] }),
@@ -615,16 +568,17 @@ function AccountMenu({ principal, instanceRole, collapsed }) {
615
568
  * switches: one click on `prod` lists its siblings. Absent everywhere else.
616
569
  */
617
570
  function Breadcrumbs({ pathname, projects, canListPrincipals }) {
618
- const [section, projectSlug, environmentSlug] = pathname.split("/").filter((segment) => segment !== "").map(decodeURIComponent);
619
- if ((section === "users" || section === "tokens") && projectSlug !== void 0) {
620
- const label = /* @__PURE__ */ jsx("span", { children: section === "users" ? "Users" : "Tokens" });
571
+ const [section, projectSlug, place] = pathname.split("/").filter((segment) => segment !== "").map(decodeURIComponent);
572
+ const environmentSlug = place !== void 0 && PROJECT_PAGES.includes(place) ? void 0 : place;
573
+ if ((section === "users" || section === "service-accounts") && projectSlug !== void 0) {
574
+ const label = /* @__PURE__ */ jsx("span", { children: section === "users" ? "Users" : "Service accounts" });
621
575
  return /* @__PURE__ */ jsxs("nav", {
622
576
  className: "crumbs",
623
577
  "aria-label": "Breadcrumb",
624
578
  children: [
625
579
  canListPrincipals ? /* @__PURE__ */ jsx(Link, {
626
580
  className: "crumb-link crumb-root",
627
- to: section === "users" ? "/users" : "/tokens",
581
+ to: section === "users" ? "/users" : "/service-accounts",
628
582
  children: label
629
583
  }) : /* @__PURE__ */ jsx("span", {
630
584
  className: "crumb-link crumb-root",
@@ -837,7 +791,7 @@ function CoffreProvider({ children }) {
837
791
  }
838
792
  /** coffre's shell: the nav, around the signed-in pages. */
839
793
  function ShellLayout() {
840
- const { principal, instanceRole, projects, capabilities, instance } = useShell();
794
+ const { principal, instanceRole, projects, capabilities } = useShell();
841
795
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("a", {
842
796
  className: "skip-link",
843
797
  href: "#content",
@@ -847,7 +801,6 @@ function ShellLayout() {
847
801
  principal,
848
802
  instanceRole,
849
803
  capabilities,
850
- instance,
851
804
  children: /* @__PURE__ */ jsx(Outlet, {})
852
805
  })] });
853
806
  }
@@ -935,6 +888,29 @@ function requestPage() {
935
888
  return context;
936
889
  }
937
890
  //#endregion
891
+ //#region src/lib/search.ts
892
+ /**
893
+ * The router's search, every value a string as the URL has it. TanStack's
894
+ * default reads what looks like JSON or a number as such, so `state=1e5`
895
+ * would come back as `100000` and `code=0123` as `123`; the server's
896
+ * canonical redirect would then rewrite the URL. Here a page's
897
+ * `validateSearch` gets strings, and the URL comes back as it went.
898
+ */
899
+ function parseSearch(searchStr) {
900
+ return Object.fromEntries(new URLSearchParams(searchStr));
901
+ }
902
+ /** The inverse of `parseSearch`: each value that is set, as text. */
903
+ function stringifySearch(search) {
904
+ const query = new URLSearchParams();
905
+ for (const [name, value] of Object.entries(search)) if (value !== void 0) query.set(name, String(value));
906
+ const text = query.toString();
907
+ return text === "" ? "" : `?${text}`;
908
+ }
909
+ /** The string values of a search, as a page that takes them as given reads them. */
910
+ function stringsOf(search) {
911
+ return Object.fromEntries(Object.entries(search).filter((entry) => typeof entry[1] === "string"));
912
+ }
913
+ //#endregion
938
914
  //#region src/router.tsx
939
915
  /**
940
916
  * The deployment's router, around its route tree, which holds coffre's
@@ -966,6 +942,8 @@ function createRouter(routeTree) {
966
942
  scrollRestoration: true,
967
943
  defaultNotFoundComponent: NotFound,
968
944
  defaultErrorComponent: RouteError,
945
+ parseSearch,
946
+ stringifySearch,
969
947
  ssr: { nonce: page?.cspNonce },
970
948
  context
971
949
  });
@@ -1015,20 +993,58 @@ var projects = { loader: ({ context }) => {
1015
993
  const { coffre, queryClient } = coffreOf(context);
1016
994
  return queryClient.fetchQuery(queries.projects(coffre));
1017
995
  } };
1018
- /** `/projects/$project`. */
1019
- var project = {
1020
- validateSearch: (search) => ({ tab: search.tab === "users" || search.tab === "tokens" || search.tab === "settings" ? search.tab : void 0 }),
1021
- loader: ({ context, params }) => {
1022
- const { coffre, queryClient } = coffreOf(context);
1023
- return loadProject(queryClient, coffre, params.project);
1024
- }
1025
- };
996
+ /**
997
+ * `/projects/$project`, the layout of a project's tabs: its header, and the
998
+ * tabs its visitor may open. Each tab is a page under it that reads its own.
999
+ */
1000
+ var project = { loader: ({ context }) => {
1001
+ const { coffre, queryClient } = coffreOf(context);
1002
+ return queryClient.fetchQuery(queries.projects(coffre));
1003
+ } };
1004
+ /** `/projects/$project/`, its environments, and who can open each when you manage its access. */
1005
+ var projectEnvironments = { loader: ({ context, params }) => {
1006
+ const { coffre, queryClient } = coffreOf(context);
1007
+ return loadProject(queryClient, coffre, params.project);
1008
+ } };
1009
+ /** `/projects/$project/users`: who holds access, and what others read of it through references. */
1010
+ var projectUsers = { loader: async ({ context, params }) => {
1011
+ const { coffre, queryClient } = coffreOf(context);
1012
+ if (!await projectTab(context, params.project, "grant.manage")) return;
1013
+ await Promise.all([queryClient.fetchQuery(queries.grants(coffre, params.project)), queryClient.fetchQuery(queries.references(coffre, params.project))]);
1014
+ } };
1015
+ /** `/projects/$project/service-accounts`. */
1016
+ var projectServiceAccounts = { loader: async ({ context, params }) => {
1017
+ const { coffre, queryClient } = coffreOf(context);
1018
+ if (await projectTab(context, params.project, "grant.manage")) await queryClient.fetchQuery(queries.grants(coffre, params.project));
1019
+ } };
1020
+ /** `/projects/$project/settings`: the project itself, which its layout read. */
1021
+ var projectSettings = { loader: async ({ context, params }) => {
1022
+ await projectTab(context, params.project, "project.manage");
1023
+ } };
1024
+ /**
1025
+ * Whether a project's tab reads anything: not for a project its visitor
1026
+ * cannot see, whose layout shows a closed door instead; and a tab they may
1027
+ * not open sends them to the first, so a link someone shared still lands
1028
+ * somewhere useful.
1029
+ */
1030
+ async function projectTab(context, slug, permission) {
1031
+ const { coffre, queryClient } = coffreOf(context);
1032
+ const found = projectOf(await queryClient.fetchQuery(queries.projects(coffre)), slug);
1033
+ if (!found.ok) return false;
1034
+ if (!found.project.permissions.includes(permission)) throw redirect({
1035
+ to: "/projects/$project",
1036
+ params: { project: slug }
1037
+ });
1038
+ return true;
1039
+ }
1026
1040
  /** `/projects/$project/$environment`. */
1027
1041
  var environment = {
1028
1042
  validateSearch: (search) => ({ filter: typeof search.filter === "string" && search.filter !== "" ? search.filter : void 0 }),
1029
- loader: ({ context, params }) => {
1043
+ loader: async ({ context, params }) => {
1030
1044
  const { coffre, queryClient } = coffreOf(context);
1031
- return queryClient.fetchQuery(queries.secrets(coffre, params));
1045
+ const secrets = await queryClient.fetchQuery(queries.secrets(coffre, params));
1046
+ if (secrets.ok) await Promise.all([queryClient.fetchQuery(queries.references(coffre, `${params.project}/${params.environment}`)), queryClient.fetchQuery(queries.missing(coffre, params))]);
1047
+ return secrets;
1032
1048
  }
1033
1049
  };
1034
1050
  /** `/audit`. */
@@ -1036,7 +1052,7 @@ var audit = {
1036
1052
  validateSearch: (search) => ({
1037
1053
  decision: search.decision === "deny" ? "deny" : void 0,
1038
1054
  actorId: typeof search.actorId === "string" && search.actorId !== "" ? search.actorId : void 0,
1039
- detail: search.detail === "1" || search.detail === 1 ? "1" : void 0
1055
+ detail: search.detail === "1" ? "1" : void 0
1040
1056
  }),
1041
1057
  loaderDeps: ({ search }) => search,
1042
1058
  loader: ({ context, deps }) => {
@@ -1053,25 +1069,67 @@ var users = { loader: ({ context }) => {
1053
1069
  const { coffre, queryClient } = coffreOf(context);
1054
1070
  return loadDirectory(queryClient, coffre);
1055
1071
  } };
1056
- /** `/users/$user`. */
1072
+ /** `/users/$user`, the layout of a user's tabs: who they are to the instance, for owners. */
1057
1073
  var user = { loader: ({ context, params }) => {
1058
1074
  const { coffre, queryClient } = coffreOf(context);
1059
- return loadPrincipal(queryClient, coffre, "user", params.user);
1075
+ return loadMember(queryClient, coffre, memberRef("user", params.user));
1060
1076
  } };
1061
- /** `/tokens`. */
1062
- var tokens = { loader: ({ context }) => {
1077
+ /** `/users/$user/`, their access on every project where you manage it. */
1078
+ var userAccess = { loader: ({ context }) => {
1063
1079
  const { coffre, queryClient } = coffreOf(context);
1064
- return loadDirectory(queryClient, coffre);
1080
+ return loadAccess(queryClient, coffre);
1065
1081
  } };
1066
- /** `/tokens/$token`. */
1067
- var token = { loader: ({ context, params }) => {
1082
+ /** `/users/$user/activity`, for whoever reads the audit log; the others are sent to the first tab. */
1083
+ var userActivity = { loader: async ({ context, params }) => {
1068
1084
  const { coffre, queryClient } = coffreOf(context);
1069
- return loadPrincipal(queryClient, coffre, "service", params.token);
1085
+ if (!(await loadShell(queryClient, coffre)).capabilities.canReadAudit) throw redirect({
1086
+ to: "/users/$user",
1087
+ params
1088
+ });
1089
+ } };
1090
+ /** `/service-accounts`. */
1091
+ var serviceAccounts = { loader: ({ context }) => {
1092
+ const { coffre, queryClient } = coffreOf(context);
1093
+ return loadServiceDirectory(queryClient, coffre);
1094
+ } };
1095
+ /** `/service-accounts/$account`, the layout of a service account's tabs: who it is to the instance, for owners. */
1096
+ var serviceAccount = { loader: ({ context, params }) => {
1097
+ const { coffre, queryClient } = coffreOf(context);
1098
+ return loadMember(queryClient, coffre, memberRef("service", params.account));
1099
+ } };
1100
+ /**
1101
+ * `/service-accounts/$account/`, how it signs in: its trusted workloads and
1102
+ * bearer tokens. Only an owner manages them, and only while it is active;
1103
+ * anyone else is sent to its access.
1104
+ */
1105
+ var serviceAccountSignIn = { loader: async ({ context, params }) => {
1106
+ const { coffre, queryClient } = coffreOf(context);
1107
+ const member = memberRef("service", params.account);
1108
+ const [shell, report] = await Promise.all([loadShell(queryClient, coffre), loadMember(queryClient, coffre, member)]);
1109
+ const ways = signInWays(shell, report);
1110
+ if (ways === null) throw redirect({
1111
+ to: "/service-accounts/$account/access",
1112
+ params
1113
+ });
1114
+ await Promise.all([queryClient.fetchQuery(queries.credentials(coffre, member, ways.tokens)), queryClient.fetchQuery(queries.bindings(coffre, member, ways.workloads))]);
1115
+ } };
1116
+ /** `/service-accounts/$account/access`. */
1117
+ var serviceAccountAccess = { loader: ({ context }) => {
1118
+ const { coffre, queryClient } = coffreOf(context);
1119
+ return loadAccess(queryClient, coffre);
1120
+ } };
1121
+ /** `/service-accounts/$account/activity`, as a user's. */
1122
+ var serviceAccountActivity = { loader: async ({ context, params }) => {
1123
+ const { coffre, queryClient } = coffreOf(context);
1124
+ if (!(await loadShell(queryClient, coffre)).capabilities.canReadAudit) throw redirect({
1125
+ to: "/service-accounts/$account",
1126
+ params
1127
+ });
1070
1128
  } };
1071
1129
  /** `/settings`. */
1072
1130
  var settings = { loader: ({ context }) => {
1073
1131
  const { coffre, queryClient } = coffreOf(context);
1074
- return loadDirectory(queryClient, coffre);
1132
+ return loadSettings(queryClient, coffre);
1075
1133
  } };
1076
1134
  /** `/account`. */
1077
1135
  var account = {
@@ -1092,13 +1150,7 @@ var account = {
1092
1150
  };
1093
1151
  /** `/login`. */
1094
1152
  var login = {
1095
- validateSearch: (search) => {
1096
- const out = {};
1097
- const { next, error } = search;
1098
- if (typeof next === "string" && next.startsWith("/") && !next.startsWith("//")) out.next = next;
1099
- if (typeof error === "string" && /^[a-z_]{1,40}$/.test(error)) out.error = error;
1100
- return out;
1101
- },
1153
+ validateSearch: loginSearch,
1102
1154
  loader: async ({ context }) => {
1103
1155
  const { coffre, queryClient } = coffreOf(context);
1104
1156
  const shell = await loadShell(queryClient, coffre);
@@ -1141,7 +1193,45 @@ var deviceLogin = {
1141
1193
  return uiResult(() => coffre.deviceLogins.get(code));
1142
1194
  }
1143
1195
  };
1196
+ /**
1197
+ * `/approvals/$approval`: a change an MCP client asked for, which its person
1198
+ * decides here. Its own read: the page shows what the change would do now.
1199
+ */
1200
+ var approval = { loader: async ({ context, params, location }) => {
1201
+ const { coffre, queryClient } = coffreOf(context);
1202
+ const shell = await loadShell(queryClient, coffre);
1203
+ if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
1204
+ if (shell.principal === null) throw redirect({
1205
+ to: "/login",
1206
+ search: { next: location.href }
1207
+ });
1208
+ return uiResult(() => coffre.approvals.get(params.approval));
1209
+ } };
1210
+ /**
1211
+ * `/oauth/authorize`: an MCP client asking to connect. Its parameters go to
1212
+ * the API as sent, which says which it takes; the router keeps them strings,
1213
+ * so a `state` of `1e5` goes back as `1e5`.
1214
+ */
1215
+ var oauthAuthorize = {
1216
+ validateSearch: (search) => stringsOf(search),
1217
+ loaderDeps: ({ search }) => ({ request: search }),
1218
+ loader: async ({ context, deps, location }) => {
1219
+ const { coffre, queryClient } = coffreOf(context);
1220
+ const shell = await loadShell(queryClient, coffre);
1221
+ if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
1222
+ if (shell.principal === null) throw redirect({
1223
+ to: "/login",
1224
+ search: { next: location.href }
1225
+ });
1226
+ const { request } = deps;
1227
+ return {
1228
+ request,
1229
+ email: shell.principal.id,
1230
+ result: await uiResult(() => coffre.oauth.describe(request))
1231
+ };
1232
+ }
1233
+ };
1144
1234
  //#endregion
1145
- export { CoffreProvider, access, account, audit, createRouter, deviceLogin, environment, home, login, project, projects, settings, shell, solo, token, tokens, unregistered, useCoffre, user, users };
1235
+ export { CoffreProvider, access, account, approval, audit, createRouter, deviceLogin, environment, home, login, oauthAuthorize, project, projectEnvironments, projectServiceAccounts, projectSettings, projectUsers, projects, serviceAccount, serviceAccountAccess, serviceAccountActivity, serviceAccountSignIn, serviceAccounts, settings, shell, solo, unregistered, useCoffre, user, userAccess, userActivity, users };
1146
1236
 
1147
1237
  //# sourceMappingURL=index.js.map