@coffre/ui 0.3.0 → 0.4.1

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 (180) 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/connected-apps-CUOyEZXR.js +146 -0
  4. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  5. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  6. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  7. package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
  8. package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
  9. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  10. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  11. package/dist/chunks/grants-CXcmhujY.js +669 -0
  12. package/dist/chunks/grants-CXcmhujY.js.map +1 -0
  13. package/dist/chunks/offboarding-6eAduCsM.js +305 -0
  14. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  15. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  16. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  17. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  18. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  19. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  20. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  21. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
  22. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  23. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  24. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  25. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  26. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  27. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  28. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  29. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  30. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  31. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  32. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  33. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  34. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  35. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  36. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  37. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  38. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  39. package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
  40. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  41. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  42. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  43. package/dist/chunks/validation-D312_NLf.js +87 -0
  44. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  45. package/dist/index.d.ts +385 -31
  46. package/dist/index.js +188 -102
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.d.ts +2 -2
  49. package/dist/pages/account.js +174 -135
  50. package/dist/pages/account.js.map +1 -1
  51. package/dist/pages/approval.d.ts +9 -0
  52. package/dist/pages/approval.js +207 -0
  53. package/dist/pages/approval.js.map +1 -0
  54. package/dist/pages/audit.js +17 -542
  55. package/dist/pages/audit.js.map +1 -1
  56. package/dist/pages/device-login.js +2 -3
  57. package/dist/pages/device-login.js.map +1 -1
  58. package/dist/pages/environment.js +647 -257
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +18 -7
  61. package/dist/pages/login.js.map +1 -1
  62. package/dist/pages/oauth-authorize.d.ts +10 -0
  63. package/dist/pages/oauth-authorize.js +249 -0
  64. package/dist/pages/oauth-authorize.js.map +1 -0
  65. package/dist/pages/project-access.d.ts +6 -0
  66. package/dist/pages/project-access.js +370 -0
  67. package/dist/pages/project-access.js.map +1 -0
  68. package/dist/pages/project-environments.d.ts +4 -0
  69. package/dist/pages/project-environments.js +593 -0
  70. package/dist/pages/project-environments.js.map +1 -0
  71. package/dist/pages/project-settings.d.ts +4 -0
  72. package/dist/pages/project-settings.js +242 -0
  73. package/dist/pages/project-settings.js.map +1 -0
  74. package/dist/pages/project.d.ts +10 -2
  75. package/dist/pages/project.js +57 -934
  76. package/dist/pages/project.js.map +1 -1
  77. package/dist/pages/projects.js +53 -21
  78. package/dist/pages/projects.js.map +1 -1
  79. package/dist/pages/service-account.d.ts +10 -0
  80. package/dist/pages/{token.js → service-account.js} +112 -54
  81. package/dist/pages/service-account.js.map +1 -0
  82. package/dist/pages/service-accounts.d.ts +3 -0
  83. package/dist/pages/service-accounts.js +38 -0
  84. package/dist/pages/service-accounts.js.map +1 -0
  85. package/dist/pages/settings.d.ts +1 -0
  86. package/dist/pages/settings.js +104 -42
  87. package/dist/pages/settings.js.map +1 -1
  88. package/dist/pages/unregistered.js +2 -3
  89. package/dist/pages/unregistered.js.map +1 -1
  90. package/dist/pages/user.d.ts +6 -1
  91. package/dist/pages/user.js +18 -6
  92. package/dist/pages/user.js.map +1 -1
  93. package/dist/pages/users.js +6 -10
  94. package/dist/pages/users.js.map +1 -1
  95. package/package.json +3 -3
  96. package/src/components/actions-log.tsx +117 -0
  97. package/src/components/audit-sentence.tsx +55 -0
  98. package/src/components/command-palette.tsx +4 -4
  99. package/src/components/connected-apps.tsx +138 -0
  100. package/src/components/delete-place.tsx +180 -0
  101. package/src/components/directory.tsx +266 -110
  102. package/src/components/every-project.tsx +287 -0
  103. package/src/components/expiry-field.tsx +42 -0
  104. package/src/components/folders.tsx +219 -0
  105. package/src/components/grants.tsx +11 -4
  106. package/src/components/icons.tsx +2 -0
  107. package/src/components/missing.tsx +110 -0
  108. package/src/components/offboarding.tsx +62 -34
  109. package/src/components/page.tsx +4 -1
  110. package/src/components/principal-page.tsx +154 -108
  111. package/src/components/principal-picker.tsx +5 -5
  112. package/src/components/principal.tsx +4 -4
  113. package/src/components/references.tsx +323 -0
  114. package/src/components/service-tokens.tsx +112 -93
  115. package/src/components/shell.tsx +11 -32
  116. package/src/components/tabs.tsx +18 -0
  117. package/src/components/trusted-workloads.tsx +97 -79
  118. package/src/components/ui.tsx +8 -1
  119. package/src/index.ts +13 -3
  120. package/src/layout.tsx +2 -2
  121. package/src/lib/access-plan.ts +2 -2
  122. package/src/lib/audit-sentences.ts +161 -77
  123. package/src/lib/changes.ts +77 -5
  124. package/src/lib/coffre.ts +3 -2
  125. package/src/lib/one-time.ts +32 -0
  126. package/src/lib/project-access.ts +11 -23
  127. package/src/lib/project-page.ts +14 -0
  128. package/src/lib/queries.ts +126 -32
  129. package/src/lib/search.ts +25 -0
  130. package/src/lib/signin-errors.ts +45 -1
  131. package/src/lib/validation.ts +14 -0
  132. package/src/options.ts +187 -42
  133. package/src/pages/account.tsx +176 -133
  134. package/src/pages/approval.tsx +197 -0
  135. package/src/pages/audit.tsx +9 -61
  136. package/src/pages/environment.tsx +585 -286
  137. package/src/pages/login.tsx +8 -2
  138. package/src/pages/oauth-authorize.tsx +233 -0
  139. package/src/pages/project-access.tsx +219 -0
  140. package/src/pages/project-environments.tsx +582 -0
  141. package/src/pages/project-settings.tsx +259 -0
  142. package/src/pages/project.tsx +52 -879
  143. package/src/pages/projects.tsx +55 -18
  144. package/src/pages/service-account.tsx +50 -0
  145. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  146. package/src/pages/settings.tsx +62 -8
  147. package/src/pages/user.tsx +16 -4
  148. package/src/pages/users.tsx +2 -2
  149. package/src/parity.ts +160 -0
  150. package/src/register.ts +57 -10
  151. package/src/router.tsx +4 -0
  152. package/src/shared/models.ts +6 -2
  153. package/src/styles/globals.css +536 -31
  154. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  155. package/dist/chunks/grants-saMQagmG.js +0 -160
  156. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  157. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  158. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  159. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  160. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  161. package/dist/chunks/page-C5HcNqf2.js +0 -190
  162. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  163. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  164. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  165. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  166. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  167. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  168. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  169. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  170. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  171. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  172. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  173. package/dist/pages/token.d.ts +0 -3
  174. package/dist/pages/token.js.map +0 -1
  175. package/dist/pages/tokens.d.ts +0 -3
  176. package/dist/pages/tokens.js +0 -39
  177. package/dist/pages/tokens.js.map +0 -1
  178. package/dist/project-BqIy8gYR.d.ts +0 -5
  179. package/src/lib/instance.ts +0 -13
  180. 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 }) => {
@@ -1044,34 +1060,72 @@ var audit = {
1044
1060
  return queryClient.fetchQuery(queries.auditEntries(coffre, deps));
1045
1061
  }
1046
1062
  };
1047
- /** `/access`: the access page became the users page, and old links land there. */
1048
- var access = { beforeLoad: () => {
1049
- throw redirect({ to: "/users" });
1050
- } };
1051
1063
  /** `/users`. */
1052
1064
  var users = { loader: ({ context }) => {
1053
1065
  const { coffre, queryClient } = coffreOf(context);
1054
1066
  return loadDirectory(queryClient, coffre);
1055
1067
  } };
1056
- /** `/users/$user`. */
1068
+ /** `/users/$user`, the layout of a user's tabs: who they are to the instance, for owners. */
1057
1069
  var user = { loader: ({ context, params }) => {
1058
1070
  const { coffre, queryClient } = coffreOf(context);
1059
- return loadPrincipal(queryClient, coffre, "user", params.user);
1071
+ return loadMember(queryClient, coffre, memberRef("user", params.user));
1060
1072
  } };
1061
- /** `/tokens`. */
1062
- var tokens = { loader: ({ context }) => {
1073
+ /** `/users/$user/`, their access on every project where you manage it. */
1074
+ var userAccess = { loader: ({ context }) => {
1063
1075
  const { coffre, queryClient } = coffreOf(context);
1064
- return loadDirectory(queryClient, coffre);
1076
+ return loadAccess(queryClient, coffre);
1065
1077
  } };
1066
- /** `/tokens/$token`. */
1067
- var token = { loader: ({ context, params }) => {
1078
+ /** `/users/$user/activity`, for whoever reads the audit log; the others are sent to the first tab. */
1079
+ var userActivity = { loader: async ({ context, params }) => {
1068
1080
  const { coffre, queryClient } = coffreOf(context);
1069
- return loadPrincipal(queryClient, coffre, "service", params.token);
1081
+ if (!(await loadShell(queryClient, coffre)).capabilities.canReadAudit) throw redirect({
1082
+ to: "/users/$user",
1083
+ params
1084
+ });
1085
+ } };
1086
+ /** `/service-accounts`. */
1087
+ var serviceAccounts = { loader: ({ context }) => {
1088
+ const { coffre, queryClient } = coffreOf(context);
1089
+ return loadServiceDirectory(queryClient, coffre);
1090
+ } };
1091
+ /** `/service-accounts/$account`, the layout of a service account's tabs: who it is to the instance, for owners. */
1092
+ var serviceAccount = { loader: ({ context, params }) => {
1093
+ const { coffre, queryClient } = coffreOf(context);
1094
+ return loadMember(queryClient, coffre, memberRef("service", params.account));
1095
+ } };
1096
+ /**
1097
+ * `/service-accounts/$account/`, how it signs in: its trusted workloads and
1098
+ * bearer tokens. Only an owner manages them, and only while it is active;
1099
+ * anyone else is sent to its access.
1100
+ */
1101
+ var serviceAccountSignIn = { loader: async ({ context, params }) => {
1102
+ const { coffre, queryClient } = coffreOf(context);
1103
+ const member = memberRef("service", params.account);
1104
+ const [shell, report] = await Promise.all([loadShell(queryClient, coffre), loadMember(queryClient, coffre, member)]);
1105
+ const ways = signInWays(shell, report);
1106
+ if (ways === null) throw redirect({
1107
+ to: "/service-accounts/$account/access",
1108
+ params
1109
+ });
1110
+ await Promise.all([queryClient.fetchQuery(queries.credentials(coffre, member, ways.tokens)), queryClient.fetchQuery(queries.bindings(coffre, member, ways.workloads))]);
1111
+ } };
1112
+ /** `/service-accounts/$account/access`. */
1113
+ var serviceAccountAccess = { loader: ({ context }) => {
1114
+ const { coffre, queryClient } = coffreOf(context);
1115
+ return loadAccess(queryClient, coffre);
1116
+ } };
1117
+ /** `/service-accounts/$account/activity`, as a user's. */
1118
+ var serviceAccountActivity = { loader: async ({ context, params }) => {
1119
+ const { coffre, queryClient } = coffreOf(context);
1120
+ if (!(await loadShell(queryClient, coffre)).capabilities.canReadAudit) throw redirect({
1121
+ to: "/service-accounts/$account",
1122
+ params
1123
+ });
1070
1124
  } };
1071
1125
  /** `/settings`. */
1072
1126
  var settings = { loader: ({ context }) => {
1073
1127
  const { coffre, queryClient } = coffreOf(context);
1074
- return loadDirectory(queryClient, coffre);
1128
+ return loadSettings(queryClient, coffre);
1075
1129
  } };
1076
1130
  /** `/account`. */
1077
1131
  var account = {
@@ -1092,13 +1146,7 @@ var account = {
1092
1146
  };
1093
1147
  /** `/login`. */
1094
1148
  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
- },
1149
+ validateSearch: loginSearch,
1102
1150
  loader: async ({ context }) => {
1103
1151
  const { coffre, queryClient } = coffreOf(context);
1104
1152
  const shell = await loadShell(queryClient, coffre);
@@ -1141,7 +1189,45 @@ var deviceLogin = {
1141
1189
  return uiResult(() => coffre.deviceLogins.get(code));
1142
1190
  }
1143
1191
  };
1192
+ /**
1193
+ * `/approvals/$approval`: a change an MCP client asked for, which its person
1194
+ * decides here. Its own read: the page shows what the change would do now.
1195
+ */
1196
+ var approval = { loader: async ({ context, params, location }) => {
1197
+ const { coffre, queryClient } = coffreOf(context);
1198
+ const shell = await loadShell(queryClient, coffre);
1199
+ if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
1200
+ if (shell.principal === null) throw redirect({
1201
+ to: "/login",
1202
+ search: { next: location.href }
1203
+ });
1204
+ return uiResult(() => coffre.approvals.get(params.approval));
1205
+ } };
1206
+ /**
1207
+ * `/oauth/authorize`: an MCP client asking to connect. Its parameters go to
1208
+ * the API as sent, which says which it takes; the router keeps them strings,
1209
+ * so a `state` of `1e5` goes back as `1e5`.
1210
+ */
1211
+ var oauthAuthorize = {
1212
+ validateSearch: (search) => stringsOf(search),
1213
+ loaderDeps: ({ search }) => ({ request: search }),
1214
+ loader: async ({ context, deps, location }) => {
1215
+ const { coffre, queryClient } = coffreOf(context);
1216
+ const shell = await loadShell(queryClient, coffre);
1217
+ if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
1218
+ if (shell.principal === null) throw redirect({
1219
+ to: "/login",
1220
+ search: { next: location.href }
1221
+ });
1222
+ const { request } = deps;
1223
+ return {
1224
+ request,
1225
+ email: shell.principal.id,
1226
+ result: await uiResult(() => coffre.oauth.describe(request))
1227
+ };
1228
+ }
1229
+ };
1144
1230
  //#endregion
1145
- export { CoffreProvider, access, account, audit, createRouter, deviceLogin, environment, home, login, project, projects, settings, shell, solo, token, tokens, unregistered, useCoffre, user, users };
1231
+ export { CoffreProvider, 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
1232
 
1147
1233
  //# sourceMappingURL=index.js.map