@coffre/ui 0.15.0 → 0.16.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 (139) hide show
  1. package/dist/audit-sentences.d.ts +56 -0
  2. package/dist/audit-sentences.js +886 -0
  3. package/dist/audit-sentences.js.map +1 -0
  4. package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
  5. package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
  6. package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
  7. package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
  8. package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
  9. package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
  10. package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
  11. package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
  12. package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
  13. package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
  14. package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
  15. package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
  16. package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
  17. package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
  18. package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
  19. package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
  20. package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
  21. package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
  22. package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
  23. package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
  24. package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
  25. package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
  26. package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
  27. package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
  28. package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
  29. package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
  30. package/dist/chunks/protected-DEWeOrmI.js +77 -0
  31. package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
  32. package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
  33. package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
  34. package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
  35. package/dist/chunks/references-wTh_DT0M.js.map +1 -0
  36. package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
  37. package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
  38. package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
  39. package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
  40. package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
  41. package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
  42. package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
  43. package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
  44. package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
  45. package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
  46. package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
  47. package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
  48. package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
  49. package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
  50. package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
  51. package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
  52. package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
  53. package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
  54. package/dist/index.d.ts +23 -55
  55. package/dist/index.js +12 -31
  56. package/dist/index.js.map +1 -1
  57. package/dist/pages/account.js +12 -12
  58. package/dist/pages/account.js.map +1 -1
  59. package/dist/pages/approval.js +2 -2
  60. package/dist/pages/audit.js +173 -196
  61. package/dist/pages/audit.js.map +1 -1
  62. package/dist/pages/device-login.js +2 -2
  63. package/dist/pages/environment.js +445 -252
  64. package/dist/pages/environment.js.map +1 -1
  65. package/dist/pages/login.js +6 -15
  66. package/dist/pages/login.js.map +1 -1
  67. package/dist/pages/oauth-authorize.js +2 -2
  68. package/dist/pages/project-access.js +11 -11
  69. package/dist/pages/project-environments.js +359 -28
  70. package/dist/pages/project-environments.js.map +1 -1
  71. package/dist/pages/project-settings.js +8 -8
  72. package/dist/pages/project.js +3 -3
  73. package/dist/pages/projects.js +8 -8
  74. package/dist/pages/service-account.js +19 -16
  75. package/dist/pages/service-account.js.map +1 -1
  76. package/dist/pages/service-accounts.js +6 -7
  77. package/dist/pages/service-accounts.js.map +1 -1
  78. package/dist/pages/settings.d.ts +1 -6
  79. package/dist/pages/settings.js +155 -286
  80. package/dist/pages/settings.js.map +1 -1
  81. package/dist/pages/unregistered.js +2 -2
  82. package/dist/pages/user.js +7 -8
  83. package/dist/pages/user.js.map +1 -1
  84. package/dist/pages/users.js +6 -7
  85. package/dist/pages/users.js.map +1 -1
  86. package/package.json +8 -3
  87. package/src/components/actions-log.tsx +8 -61
  88. package/src/components/directory.tsx +10 -9
  89. package/src/components/grants.tsx +2 -2
  90. package/src/components/icons.tsx +0 -2
  91. package/src/components/offboarding.tsx +9 -16
  92. package/src/components/page.tsx +2 -3
  93. package/src/components/personal-tokens.tsx +5 -2
  94. package/src/components/principal-page.tsx +5 -4
  95. package/src/components/protected.tsx +39 -52
  96. package/src/components/references.tsx +18 -7
  97. package/src/components/role-editor.tsx +68 -99
  98. package/src/components/role-field.tsx +1 -1
  99. package/src/components/trusted-workloads.tsx +6 -5
  100. package/src/components/ui.tsx +5 -0
  101. package/src/lib/audit-proofs.ts +51 -0
  102. package/src/lib/audit-sentences.ts +490 -529
  103. package/src/lib/bindings.ts +6 -0
  104. package/src/lib/changes.ts +3 -1
  105. package/src/lib/coffre.ts +2 -2
  106. package/src/lib/queries.ts +19 -168
  107. package/src/lib/reveal.ts +32 -5
  108. package/src/lib/roles.ts +10 -36
  109. package/src/lib/row-reads.ts +2 -2
  110. package/src/lib/signin-errors.ts +5 -33
  111. package/src/options.ts +3 -19
  112. package/src/pages/account.tsx +1 -1
  113. package/src/pages/audit.tsx +151 -228
  114. package/src/pages/environment.tsx +373 -247
  115. package/src/pages/login.tsx +2 -4
  116. package/src/pages/project-environments.tsx +322 -20
  117. package/src/pages/service-accounts.tsx +1 -1
  118. package/src/pages/settings.tsx +49 -134
  119. package/src/pages/user.tsx +2 -2
  120. package/src/pages/users.tsx +1 -1
  121. package/src/parity.ts +11 -20
  122. package/src/styles/globals.css +107 -273
  123. package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
  124. package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
  125. package/dist/chunks/directory-DrswWQLT.js.map +0 -1
  126. package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
  127. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
  128. package/dist/chunks/grants-C0cb2oii.js.map +0 -1
  129. package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
  130. package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
  131. package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
  132. package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
  133. package/dist/chunks/queries-D1JuimTu.js.map +0 -1
  134. package/dist/chunks/references-D5llUGQL.js.map +0 -1
  135. package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
  136. package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
  137. package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
  138. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
  139. package/src/components/environment-actions.tsx +0 -508
@@ -1,12 +1,10 @@
1
- import { n as affects, x as queries } from "../chunks/queries-D1JuimTu.js";
2
- import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-CGdORVzW.js";
3
- import { G as Pencil, J as RotateBack, K as Plus, M as Info, N as Key, R as Lock, X as Settings, Z as ShieldCheck, _ as Check, i as PageHeader, r as Fact, rt as Trash, t as Card, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
- import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
5
- import { t as PageTabs } from "../chunks/tabs-BmwKfUeK.js";
6
- import { a as columnInWords, c as ordered, d as reachOf, f as roleIdFrom, g as toggle, h as sameDefinition, i as PERMISSION_WORDS, l as projectWide, n as CARD_ROWS, o as impactExamples, p as roleIdProblem, r as GRID_PERMISSIONS, s as impactInWords } from "../chunks/use-roles-BZnJ9Cq0.js";
7
- import { n as ScopeField } from "../chunks/role-field-CoCv8wse.js";
8
- import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
9
- import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
1
+ import { t as affects, y as queries } from "../chunks/queries-D4_o-bz3.js";
2
+ import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-Q_Eczt7m.js";
3
+ import { G as Plus, L as Lock, W as Pencil, _ as Check, i as PageHeader, j as Info, nt as Trash, q as RotateBack, r as Fact, t as Card, u as useCoffre } from "../chunks/page-Cb0ZjGda.js";
4
+ import { t as useShell } from "../chunks/use-shell-DMhLa2sh.js";
5
+ import { a as impactExamples, c as projectWide, d as roleIdProblem, i as columnInWords, m as toggle, n as GRID_PERMISSIONS, o as impactInWords, p as sameDefinition, r as PERMISSION_WORDS, s as ordered, u as roleIdFrom } from "../chunks/use-roles-stcv2QFj.js";
6
+ import { n as ScopeField } from "../chunks/role-field-BiP09qfN.js";
7
+ import { t as useAction } from "../chunks/use-action-BfnN-De2.js";
10
8
  import { useId, useRef, useState } from "react";
11
9
  import { Link } from "@tanstack/react-router";
12
10
  import { toast } from "sonner";
@@ -15,131 +13,90 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
13
  import { useSuspenseQuery } from "@tanstack/react-query";
16
14
  import { CoffreError } from "@coffre/client";
17
15
  //#region src/components/role-editor.tsx
18
- /**
19
- * The instance's project roles, or its global roles (instance roles, in
20
- * the code and the API): a card each, which opens its editor, under what
21
- * switches between the two.
22
- */
23
- function RolesSettings({ kind, switcher }) {
16
+ /** The instance's roles and instance roles, each a card of rows that open its editor. */
17
+ function RolesSettings() {
24
18
  const { data } = useSuspenseQuery(queries.roles(useCoffre()));
25
- if (!data.ok) return /* @__PURE__ */ jsx(ErrorLine, { error: `The roles could not be read. ${data.error}` });
26
- return /* @__PURE__ */ jsx(RoleList, {
27
- kind,
28
- roles: kind === "role" ? data.roles : data.instanceRoles,
29
- editable: data.editable,
30
- switcher
31
- }, kind);
19
+ if (!data.ok) return /* @__PURE__ */ jsx(Card, {
20
+ labelledBy: "roles",
21
+ title: "Roles",
22
+ children: /* @__PURE__ */ jsx("div", {
23
+ className: "card-row",
24
+ children: /* @__PURE__ */ jsx(ErrorLine, { error: `The roles could not be read. ${data.error}` })
25
+ })
26
+ });
27
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RoleList, {
28
+ kind: "role",
29
+ roles: data.roles,
30
+ editable: data.editable
31
+ }), /* @__PURE__ */ jsx(RoleList, {
32
+ kind: "instance-role",
33
+ roles: data.instanceRoles,
34
+ editable: data.editable
35
+ })] });
32
36
  }
33
- function RoleList({ kind, roles, editable, switcher }) {
37
+ function RoleList({ kind, roles, editable }) {
34
38
  const [open, setOpen] = useState(null);
35
39
  const project = kind === "role";
36
40
  const opened = open === null || "making" in open ? null : roles.find((role) => role.id === open.role);
37
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
38
- /* @__PURE__ */ jsxs("div", {
39
- className: "section-actions",
40
- children: [switcher, project && editable && /* @__PURE__ */ jsxs("button", {
41
- className: "btn",
42
- type: "button",
43
- onClick: () => setOpen({ making: true }),
44
- children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New role"]
45
- })]
46
- }),
47
- /* @__PURE__ */ jsxs("div", {
48
- className: "roles-desc",
49
- children: [/* @__PURE__ */ jsx("p", { children: project ? "Granted on a project or environment; a person or service account can hold several." : "One per person, across every project in its scope; assigned on Users." }), roles.some((role) => GRID_PERMISSIONS.some((permission) => reachOf(role, permission) === "unprotected")) && /* @__PURE__ */ jsxs("p", {
50
- className: "role-legend",
51
- "aria-hidden": true,
52
- children: [/* @__PURE__ */ jsx(Lock, { size: 12 }), "Not in protected environments"]
53
- })]
41
+ return /* @__PURE__ */ jsxs(Card, {
42
+ labelledBy: project ? "roles" : "instance-roles",
43
+ title: project ? "Roles" : "Instance roles",
44
+ description: /* @__PURE__ */ jsxs(Fragment$1, { children: [project ? "What a grant gives, on a project or one of its environments. In a protected environment a person holds the second column; a service account always holds the first." : "What a person holds, by their instance role, in every project its scope takes in, before any grant adds to it.", !editable && " Only an Owner of the whole instance edits them."] }),
45
+ actions: project && editable && /* @__PURE__ */ jsxs("button", {
46
+ className: "btn",
47
+ type: "button",
48
+ onClick: () => setOpen({ making: true }),
49
+ children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New role"]
54
50
  }),
55
- /* @__PURE__ */ jsx("ul", {
56
- className: "role-cards",
57
- "aria-label": project ? "Project roles" : "Global roles",
51
+ children: [/* @__PURE__ */ jsx("ul", {
52
+ className: "role-list",
53
+ "aria-label": project ? "Roles" : "Instance roles",
58
54
  children: roles.map((role) => /* @__PURE__ */ jsxs("li", {
59
- className: "role-card",
60
- children: [
61
- /* @__PURE__ */ jsxs("p", {
62
- className: "role-card-title",
63
- children: [role.name, /* @__PURE__ */ jsx(RoleBadges, { role })]
64
- }),
65
- !role.builtin && role.description !== "" && /* @__PURE__ */ jsx("p", {
66
- className: "role-card-desc",
67
- children: role.description
68
- }),
69
- /* @__PURE__ */ jsx(RoleReach, { role }),
70
- /* @__PURE__ */ jsxs("div", {
71
- className: "role-card-foot",
72
- children: [/* @__PURE__ */ jsx("span", {
73
- className: "role-card-count",
74
- children: held(kind, role.grants)
75
- }), /* @__PURE__ */ jsxs("button", {
76
- className: "btn btn-sm",
77
- type: "button",
78
- "aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
79
- onClick: () => setOpen({ role: role.id }),
80
- children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
81
- })]
82
- })
83
- ]
55
+ className: "card-row role-row",
56
+ children: [/* @__PURE__ */ jsxs("div", {
57
+ className: "role-row-text",
58
+ children: [
59
+ /* @__PURE__ */ jsxs("p", {
60
+ className: "card-row-title role-row-title",
61
+ children: [role.name, /* @__PURE__ */ jsx(RoleBadges, { role })]
62
+ }),
63
+ role.description !== "" && /* @__PURE__ */ jsx("p", {
64
+ className: "card-row-desc",
65
+ children: role.description
66
+ }),
67
+ /* @__PURE__ */ jsxs("dl", {
68
+ className: "role-columns",
69
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Holds" }), /* @__PURE__ */ jsx("dd", { children: columnInWords(role.permissions) })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("dt", { children: [/* @__PURE__ */ jsx(Lock, { size: 12 }), "In protected environments"] }), /* @__PURE__ */ jsx("dd", { children: columnInWords(role.protected) })] })]
70
+ })
71
+ ]
72
+ }), /* @__PURE__ */ jsxs("div", {
73
+ className: "role-row-side",
74
+ children: [/* @__PURE__ */ jsx("span", {
75
+ className: "role-row-count",
76
+ children: held(kind, role.grants)
77
+ }), /* @__PURE__ */ jsxs("button", {
78
+ className: "btn btn-sm",
79
+ type: "button",
80
+ "aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
81
+ onClick: () => setOpen({ role: role.id }),
82
+ children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
83
+ })]
84
+ })]
84
85
  }, role.id))
85
- }),
86
- open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
86
+ }), open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
87
87
  kind,
88
88
  role: opened,
89
89
  roles,
90
90
  editable: editable && (opened === null || !opened.fixed),
91
91
  onClose: () => setOpen(null)
92
- }, "making" in open ? "" : `role:${open.role}`)
93
- ] });
92
+ }, "making" in open ? "" : `role:${open.role}`)]
93
+ });
94
94
  }
95
95
  /** "3 grants", "1 person": who a role reaches now. */
96
96
  function held(kind, count) {
97
97
  if (kind === "instance-role") return count === 0 ? "Nobody" : count === 1 ? "1 person" : `${count} people`;
98
98
  return count === 0 ? "No grants" : count === 1 ? "1 grant" : `${count} grants`;
99
99
  }
100
- /**
101
- * What a role can do, on its card: every permission, in the same place on
102
- * every card, held ones solid, the others a dashed outline, and a lock on
103
- * one it holds only outside protected environments. A screen reader hears
104
- * each in full: "Read values: yes, except in protected environments".
105
- */
106
- function RoleReach({ role }) {
107
- return /* @__PURE__ */ jsx("dl", {
108
- className: "role-reach",
109
- children: CARD_ROWS.map((row) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: row.name }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("ul", {
110
- role: "list",
111
- children: row.permissions.map((permission) => {
112
- const reach = reachOf(role, permission);
113
- const { label, short } = PERMISSION_WORDS[permission];
114
- const words = reach === "nowhere" ? "no" : reach === "unprotected" ? "yes, except in protected environments" : "yes";
115
- return /* @__PURE__ */ jsxs("li", {
116
- className: `role-perm role-perm-${reach}`,
117
- title: reach === "unprotected" ? `${label}, not in protected environments` : label,
118
- children: [
119
- /* @__PURE__ */ jsxs("span", {
120
- className: "role-perm-shown",
121
- "aria-hidden": true,
122
- children: [short, reach === "unprotected" && /* @__PURE__ */ jsx(Lock, { size: 11 })]
123
- }),
124
- /* @__PURE__ */ jsxs("span", {
125
- className: "role-perm-widest",
126
- "aria-hidden": true,
127
- children: [short, !projectWide(permission) && /* @__PURE__ */ jsx(Lock, { size: 11 })]
128
- }),
129
- /* @__PURE__ */ jsxs("span", {
130
- className: "visually-hidden",
131
- children: [
132
- label,
133
- ": ",
134
- words
135
- ]
136
- })
137
- ]
138
- }, permission);
139
- })
140
- }) })] }, row.name))
141
- });
142
- }
143
100
  /** Where a role comes from, and whether it is as it shipped. */
144
101
  function RoleBadges({ role }) {
145
102
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -400,7 +357,7 @@ function RoleEditor({ kind, role, roles, editable, onClose }) {
400
357
  }),
401
358
  editable && /* @__PURE__ */ jsxs("p", {
402
359
  className: "hint",
403
- children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? " A global role reaches every project its holder’s scope takes in." : ""]
360
+ children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? " An instance role reaches every project its holder’s scope takes in." : ""]
404
361
  }),
405
362
  role !== null && role.edited && /* @__PURE__ */ jsxs(Notice, {
406
363
  tone: "info",
@@ -625,132 +582,70 @@ function RoleGrid({ name, columns, editable, onChange }) {
625
582
  }
626
583
  //#endregion
627
584
  //#region src/pages/settings.tsx
628
- var Route = pageRoute();
629
- /**
630
- * The instance's settings, a tab each: General, the instance and who
631
- * creates service accounts; Roles, the project roles or the global ones;
632
- * Keys, for whoever runs the instance. Your own settings are under
633
- * Account, at the sidebar's foot.
634
- */
585
+ /** The instance's settings. Your own are under Account, at the sidebar's foot. */
635
586
  function SettingsPage() {
636
- const { tab, roles } = Route.useSearch();
637
- const { capabilities } = useShell();
638
- const current = {
639
- exact: true,
640
- includeSearch: true
641
- };
642
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
643
- /* @__PURE__ */ jsx(PageHeader, { title: "Settings" }),
644
- /* @__PURE__ */ jsx(PageTabs, {
645
- label: "Settings sections",
646
- children: [
647
- /* @__PURE__ */ jsxs(Link, {
648
- to: "/settings",
649
- search: {},
650
- activeOptions: current,
651
- children: [/* @__PURE__ */ jsx(Settings, { size: 15 }), "General"]
652
- }, "general"),
653
- /* @__PURE__ */ jsxs(Link, {
654
- to: "/settings",
655
- search: { tab: "roles" },
656
- activeOptions: { includeSearch: true },
657
- children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 15 }), "Roles"]
658
- }, "roles"),
659
- capabilities.runsInstance && /* @__PURE__ */ jsxs(Link, {
660
- to: "/settings",
661
- search: { tab: "keys" },
662
- activeOptions: current,
663
- children: [/* @__PURE__ */ jsx(Key, { size: 15 }), "Keys"]
664
- }, "keys")
665
- ]
666
- }),
667
- tab === void 0 ? /* @__PURE__ */ jsx(General, {}) : tab === "keys" ? /* @__PURE__ */ jsx(KeysTab, {}) : /* @__PURE__ */ jsx(RolesSettings, {
668
- kind: roles === "global" ? "instance-role" : "role",
669
- switcher: /* @__PURE__ */ jsxs("nav", {
670
- className: "segmented",
671
- "aria-label": "Roles",
672
- children: [/* @__PURE__ */ jsx(Link, {
673
- to: "/settings",
674
- search: { tab: "roles" },
675
- activeOptions: current,
676
- children: "Project roles"
677
- }), /* @__PURE__ */ jsx(Link, {
678
- to: "/settings",
679
- search: {
680
- tab: "roles",
681
- roles: "global"
682
- },
683
- activeOptions: current,
684
- children: "Global roles"
685
- })]
686
- })
687
- })
688
- ] });
689
- }
690
- /** The instance, as its deployment set it up, and who creates service accounts. */
691
- function General() {
692
587
  const { auth, capabilities } = useShell();
693
588
  const client = useCoffre();
694
589
  const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));
590
+ const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.runsInstance));
695
591
  const { data: settings } = useSuspenseQuery(queries.settings(client, capabilities.runsInstance));
696
592
  const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
697
593
  const principals = directory?.ok === true ? directory.principals : null;
698
594
  const users = principals?.filter((entry) => entry.principalType === "user").length ?? 0;
699
595
  const tokens = principals?.filter((entry) => entry.principalType === "service").length ?? 0;
700
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, {
701
- labelledBy: "instance",
702
- title: "Instance",
703
- description: "Set in the deployment's configuration, not here.",
704
- children: /* @__PURE__ */ jsxs("dl", {
705
- className: "facts",
706
- children: [/* @__PURE__ */ jsx(Fact, {
707
- label: "Sign-in",
708
- children: /* @__PURE__ */ jsxs("span", { children: [auth?.signin ? providers.join(", ") : "Cloudflare Access", /* @__PURE__ */ jsx(Toggletip, {
709
- label: auth?.signin ? "coffre’s own sign-in. Only invited members get in." : "Cloudflare Access signs people in, and coffre verifies each request.",
710
- children: /* @__PURE__ */ jsx("button", {
711
- type: "button",
712
- className: "fact-tip",
713
- "aria-label": "About sign-in",
714
- children: /* @__PURE__ */ jsx(Info, { size: 14 })
715
- })
716
- })] })
717
- }), principals !== null && /* @__PURE__ */ jsx(Fact, {
718
- label: "Directory",
719
- children: /* @__PURE__ */ jsxs("span", { children: [
720
- /* @__PURE__ */ jsxs(Link, {
721
- to: "/users",
722
- children: [
723
- users,
724
- " user",
725
- users === 1 ? "" : "s"
726
- ]
727
- }),
728
- " · ",
729
- /* @__PURE__ */ jsxs(Link, {
730
- to: "/service-accounts",
731
- children: [
732
- tokens,
733
- " service account",
734
- tokens === 1 ? "" : "s"
735
- ]
736
- })
737
- ] })
738
- })]
739
- })
740
- }), settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts })] });
596
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
597
+ /* @__PURE__ */ jsx(PageHeader, { title: "Settings" }),
598
+ /* @__PURE__ */ jsx(Card, {
599
+ labelledBy: "instance",
600
+ title: "Instance",
601
+ description: "Set in the deployment's configuration, not here.",
602
+ children: /* @__PURE__ */ jsxs("dl", {
603
+ className: "facts",
604
+ children: [/* @__PURE__ */ jsx(Fact, {
605
+ label: "Sign-in",
606
+ children: /* @__PURE__ */ jsxs("span", { children: [auth?.signin ? providers.join(", ") : "Cloudflare Access", /* @__PURE__ */ jsx(Toggletip, {
607
+ label: auth?.signin ? "coffre’s own sign-in. Only invited members get in." : "Cloudflare Access signs people in, and coffre verifies each request.",
608
+ children: /* @__PURE__ */ jsx("button", {
609
+ type: "button",
610
+ className: "fact-tip",
611
+ "aria-label": "About sign-in",
612
+ children: /* @__PURE__ */ jsx(Info, { size: 14 })
613
+ })
614
+ })] })
615
+ }), principals !== null && /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Fact, {
616
+ label: "Directory",
617
+ children: /* @__PURE__ */ jsxs("span", { children: [
618
+ /* @__PURE__ */ jsxs(Link, {
619
+ to: "/users",
620
+ children: [
621
+ users,
622
+ " user",
623
+ users === 1 ? "" : "s"
624
+ ]
625
+ }),
626
+ " · ",
627
+ /* @__PURE__ */ jsxs(Link, {
628
+ to: "/service-accounts",
629
+ children: [
630
+ tokens,
631
+ " service account",
632
+ tokens === 1 ? "" : "s"
633
+ ]
634
+ })
635
+ ] })
636
+ }) })]
637
+ })
638
+ }),
639
+ /* @__PURE__ */ jsx(RolesSettings, {}),
640
+ settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts }),
641
+ keys?.ok === true && /* @__PURE__ */ jsx(Keys, { keys })
642
+ ] });
741
643
  }
742
644
  /**
743
- * Who creates service accounts without running the instance, and where:
744
- * anyone who holds access, inside this scope, giving one at most what they
745
- * hold there. Narrowed, the rest takes an Admin whose own scope reaches it.
645
+ * Who sets up service accounts without running the instance: anyone who
646
+ * holds access, inside this scope, giving one at most what they hold there.
647
+ * Narrowed, the rest takes an Admin whose own scope reaches it.
746
648
  */
747
- function serviceSetupInWords(scope) {
748
- if (unscoped(scope)) return "Anyone with access, in every project and environment";
749
- const { projects, environments } = scope;
750
- if (projects !== "all" && "only" in projects && projects.only.length === 0 || environments !== "all" && "only" in environments && environments.only.length === 0) return "Admins only";
751
- const where = scopeInWords(scope);
752
- return `Anyone with access, in ${where.charAt(0).toLowerCase()}${where.slice(1)}; elsewhere, Admins`;
753
- }
754
649
  function ServiceSetup({ scope }) {
755
650
  const client = useCoffre();
756
651
  const [open, setOpen] = useState(false);
@@ -764,24 +659,24 @@ function ServiceSetup({ scope }) {
764
659
  return /* @__PURE__ */ jsxs(Card, {
765
660
  labelledBy: "service-setup",
766
661
  title: "Service accounts",
662
+ description: "Anyone who holds access sets up service accounts for CI where this lets them: the account, its tokens and its OIDC trust, giving it at most what they hold. Elsewhere, an Admin whose scope reaches it does.",
663
+ actions: /* @__PURE__ */ jsxs("button", {
664
+ className: "btn",
665
+ type: "button",
666
+ onClick: () => setOpen(true),
667
+ children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
668
+ }),
767
669
  children: [/* @__PURE__ */ jsx("dl", {
768
670
  className: "facts",
769
671
  children: /* @__PURE__ */ jsx(Fact, {
770
- label: "Who creates them",
771
- action: /* @__PURE__ */ jsxs("button", {
772
- className: "btn btn-sm",
773
- type: "button",
774
- onClick: () => setOpen(true),
775
- "aria-label": "Edit who creates service accounts",
776
- children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
777
- }),
778
- children: /* @__PURE__ */ jsx("span", { children: serviceSetupInWords(scope) })
672
+ label: "Set up by people in",
673
+ children: /* @__PURE__ */ jsx("span", { children: unscoped(scope) ? "Every project and environment" : scopeInWords(scope) })
779
674
  })
780
675
  }), /* @__PURE__ */ jsx(Modal, {
781
676
  open,
782
677
  onOpenChange: (next) => next ? setOpen(true) : close(),
783
- title: "Who creates service accounts",
784
- description: "Anyone with access creates service accounts in these projects and environments, giving them at most what they hold there; elsewhere, Admins do. All except prod keeps prod's to Admins.",
678
+ title: "Who sets up service accounts",
679
+ description: "People set up service accounts, and give them what they hold, in these projects and environments. All except prod keeps prod's to Admins.",
785
680
  children: /* @__PURE__ */ jsxs("form", {
786
681
  className: "form",
787
682
  onSubmit: (event) => {
@@ -789,7 +684,7 @@ function ServiceSetup({ scope }) {
789
684
  run(() => client.settings.set({ serviceAccounts: draft }), {
790
685
  affects: affects.settings(),
791
686
  onSuccess: () => {
792
- toast.success("Saved who creates service accounts");
687
+ toast.success("Saved where people set up service accounts");
793
688
  setOpen(false);
794
689
  setError(null);
795
690
  }
@@ -821,65 +716,39 @@ function ServiceSetup({ scope }) {
821
716
  })]
822
717
  });
823
718
  }
824
- function KeysTab() {
825
- const { capabilities } = useShell();
826
- const { data: keys } = useSuspenseQuery(queries.auditKeys(useCoffre(), capabilities.runsInstance));
827
- if (keys === null) return null;
828
- return keys.ok ? /* @__PURE__ */ jsx(Keys, { keys }) : /* @__PURE__ */ jsx(ErrorLine, { error: `The keys could not be read. ${keys.error}` });
829
- }
830
- /** Where a vault key is kept, in words: the deployment's own, or a key service's. */
831
- function keptIn(provider) {
832
- if (provider === "local") return "kept in the deployment's configuration";
833
- if (provider === "aws-kms") return "kept in AWS KMS";
834
- return `kept in ${provider}`;
835
- }
836
- /** A key's identifier by its end, `…3f9a2c`, enough to tell it from another; the whole of it a hover away. */
837
- function KeyId({ id }) {
838
- return /* @__PURE__ */ jsx("span", {
839
- className: "mono",
840
- title: id,
841
- children: id.length <= 8 ? id : `…${id.slice(-6)}`
842
- });
843
- }
844
719
  /**
845
720
  * What the keys you keep are checked against: no secret, so shown. The keys
846
721
  * themselves are checked by `coffre verify keys`, on your machine: a vault
847
722
  * key typed into a web page would be within reach of everything running in it.
848
723
  */
849
724
  function Keys({ keys }) {
850
- const { current, checks } = keys.vault;
851
- const replaced = new Set(checks.map((check) => check.vaultId).filter((id) => id !== current.vaultId)).size;
725
+ const { kek, previous } = keys;
852
726
  return /* @__PURE__ */ jsx(Card, {
853
727
  labelledBy: "keys",
854
728
  title: "Keys",
855
729
  description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
856
- "To check your vault key and app key against these, run ",
730
+ "To check the vault key you keep, or the signing key you gave the vault, run ",
857
731
  /* @__PURE__ */ jsx("code", { children: "coffre verify keys" }),
858
- "."
732
+ ". It reads the key on your machine and sends it nowhere."
859
733
  ] }),
860
734
  children: /* @__PURE__ */ jsxs("dl", {
861
735
  className: "facts",
862
- children: [/* @__PURE__ */ jsxs(Fact, {
863
- label: "Vault key",
864
- children: [/* @__PURE__ */ jsxs("span", { children: [
865
- /* @__PURE__ */ jsx(KeyId, { id: current.vaultId }),
866
- " ",
867
- /* @__PURE__ */ jsxs("span", {
868
- className: "muted",
869
- children: ["· ", keptIn(current.provider)]
870
- })
871
- ] }), replaced > 0 && /* @__PURE__ */ jsxs("span", {
872
- className: "muted",
873
- children: [
874
- replaced,
875
- " earlier vault key",
876
- replaced === 1 ? "" : "s",
877
- " still checkable"
878
- ]
879
- })]
736
+ children: [/* @__PURE__ */ jsx(Fact, {
737
+ label: "Vault ID",
738
+ children: /* @__PURE__ */ jsx("span", {
739
+ className: "mono",
740
+ children: kek.id
741
+ })
880
742
  }), /* @__PURE__ */ jsx(Fact, {
881
- label: "App key",
882
- children: /* @__PURE__ */ jsx(KeyId, { id: keys.app.keyId })
743
+ label: "Vault key",
744
+ children: /* @__PURE__ */ jsxs("span", { children: [
745
+ "Held by ",
746
+ /* @__PURE__ */ jsx("span", {
747
+ className: "mono",
748
+ children: kek.provider
749
+ }),
750
+ previous.length > 0 && `; ${previous.length} earlier vault key${previous.length === 1 ? "" : "s"} still unwrapping what ${previous.length === 1 ? "it" : "they"} wrapped`
751
+ ] })
883
752
  })]
884
753
  })
885
754
  });