@coffre/ui 0.4.5 → 0.5.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 (117) hide show
  1. package/dist/chunks/{affordances-DAvsVz7u.js → affordances-Bqdevf7w.js} +10 -5
  2. package/dist/chunks/affordances-Bqdevf7w.js.map +1 -0
  3. package/dist/chunks/{audit-sentence-BhHmvQX_.js → audit-sentence-Cm5nby5k.js} +115 -8
  4. package/dist/chunks/audit-sentence-Cm5nby5k.js.map +1 -0
  5. package/dist/chunks/{connected-apps-AZsX9Zvv.js → connected-apps-DTNS7YmY.js} +2 -2
  6. package/dist/chunks/{connected-apps-AZsX9Zvv.js.map → connected-apps-DTNS7YmY.js.map} +1 -1
  7. package/dist/chunks/{delete-place-D6LIZkg9.js → delete-place-CIaOq0mt.js} +3 -3
  8. package/dist/chunks/{delete-place-D6LIZkg9.js.map → delete-place-CIaOq0mt.js.map} +1 -1
  9. package/dist/chunks/{directory-B6FuiCir.js → directory-DSVt5Tya.js} +54 -60
  10. package/dist/chunks/directory-DSVt5Tya.js.map +1 -0
  11. package/dist/chunks/{folders-DvSqBhuu.js → folders-CoGK9oqg.js} +2 -2
  12. package/dist/chunks/{folders-DvSqBhuu.js.map → folders-CoGK9oqg.js.map} +1 -1
  13. package/dist/chunks/grants-CRU7yZhL.js +164 -0
  14. package/dist/chunks/grants-CRU7yZhL.js.map +1 -0
  15. package/dist/chunks/{offboarding-CLJaNTcD.js → offboarding-DVBSiJRZ.js} +7 -3
  16. package/dist/chunks/offboarding-DVBSiJRZ.js.map +1 -0
  17. package/dist/chunks/{principal-page-UtNWKCf8.js → principal-page-BEBr_zW7.js} +350 -91
  18. package/dist/chunks/principal-page-BEBr_zW7.js.map +1 -0
  19. package/dist/chunks/{project-page-C4cEaRFa.js → project-page-B3TZ5_ig.js} +2 -2
  20. package/dist/chunks/{project-page-C4cEaRFa.js.map → project-page-B3TZ5_ig.js.map} +1 -1
  21. package/dist/chunks/{queries-Dew8mIeo.js → queries-DE5nK2y4.js} +132 -54
  22. package/dist/chunks/queries-DE5nK2y4.js.map +1 -0
  23. package/dist/chunks/{references-DWDnXNoW.js → references-uv4Mli9z.js} +4 -3
  24. package/dist/chunks/{references-DWDnXNoW.js.map → references-uv4Mli9z.js.map} +1 -1
  25. package/dist/chunks/role-field-DWhkRY6n.js +192 -0
  26. package/dist/chunks/role-field-DWhkRY6n.js.map +1 -0
  27. package/dist/chunks/use-action-BRgvbUWt.js +49 -0
  28. package/dist/chunks/use-action-BRgvbUWt.js.map +1 -0
  29. package/dist/chunks/{use-change-C4bGRhHY.js → use-change-BJ3dCFHb.js} +40 -14
  30. package/dist/chunks/use-change-BJ3dCFHb.js.map +1 -0
  31. package/dist/chunks/{use-shell-Dkv89nW1.js → use-shell-BO4ZTr1y.js} +2 -2
  32. package/dist/chunks/{use-shell-Dkv89nW1.js.map → use-shell-BO4ZTr1y.js.map} +1 -1
  33. package/dist/chunks/validation-DiHIwZRA.js +37 -0
  34. package/dist/chunks/validation-DiHIwZRA.js.map +1 -0
  35. package/dist/index.d.ts +116 -88
  36. package/dist/index.js +40 -21
  37. package/dist/index.js.map +1 -1
  38. package/dist/pages/account.js +8 -7
  39. package/dist/pages/account.js.map +1 -1
  40. package/dist/pages/approval.js +53 -21
  41. package/dist/pages/approval.js.map +1 -1
  42. package/dist/pages/audit.js +2 -2
  43. package/dist/pages/environment.js +8 -7
  44. package/dist/pages/environment.js.map +1 -1
  45. package/dist/pages/login.js +2 -2
  46. package/dist/pages/login.js.map +1 -1
  47. package/dist/pages/project-access.js +7 -7
  48. package/dist/pages/project-environments.js +26 -21
  49. package/dist/pages/project-environments.js.map +1 -1
  50. package/dist/pages/project-settings.js +9 -8
  51. package/dist/pages/project-settings.js.map +1 -1
  52. package/dist/pages/project.js +1 -1
  53. package/dist/pages/projects.js +8 -13
  54. package/dist/pages/projects.js.map +1 -1
  55. package/dist/pages/service-account.js +294 -88
  56. package/dist/pages/service-account.js.map +1 -1
  57. package/dist/pages/service-accounts.js +7 -7
  58. package/dist/pages/service-accounts.js.map +1 -1
  59. package/dist/pages/settings.js +91 -9
  60. package/dist/pages/settings.js.map +1 -1
  61. package/dist/pages/unregistered.d.ts +1 -1
  62. package/dist/pages/unregistered.js +4 -4
  63. package/dist/pages/unregistered.js.map +1 -1
  64. package/dist/pages/user.d.ts +2 -0
  65. package/dist/pages/user.js +21 -3
  66. package/dist/pages/user.js.map +1 -1
  67. package/dist/pages/users.js +4 -4
  68. package/package.json +3 -3
  69. package/src/components/affordances.ts +7 -3
  70. package/src/components/command-palette.tsx +2 -0
  71. package/src/components/directory.tsx +58 -63
  72. package/src/components/grants.tsx +9 -9
  73. package/src/components/offboarding.tsx +3 -1
  74. package/src/components/principal-page.tsx +124 -74
  75. package/src/components/role-field.tsx +183 -0
  76. package/src/components/scope-picker.tsx +73 -0
  77. package/src/components/service-tokens.tsx +20 -9
  78. package/src/components/shell.tsx +6 -10
  79. package/src/components/trusted-workloads.tsx +121 -42
  80. package/src/index.ts +1 -0
  81. package/src/lib/approval.ts +23 -0
  82. package/src/lib/audit-sentences.ts +109 -3
  83. package/src/lib/bindings.ts +33 -10
  84. package/src/lib/capabilities.ts +28 -8
  85. package/src/lib/changes.ts +22 -13
  86. package/src/lib/project-access.ts +21 -0
  87. package/src/lib/queries.ts +121 -44
  88. package/src/lib/service-setup.ts +41 -0
  89. package/src/lib/validation.ts +7 -0
  90. package/src/options.ts +31 -11
  91. package/src/pages/account.tsx +3 -2
  92. package/src/pages/approval.tsx +18 -17
  93. package/src/pages/login.tsx +1 -1
  94. package/src/pages/project-environments.tsx +12 -15
  95. package/src/pages/project-settings.tsx +3 -3
  96. package/src/pages/projects.tsx +1 -5
  97. package/src/pages/service-account.tsx +7 -5
  98. package/src/pages/service-accounts.tsx +8 -4
  99. package/src/pages/settings.tsx +80 -4
  100. package/src/pages/unregistered.tsx +3 -3
  101. package/src/pages/user.tsx +24 -1
  102. package/src/parity.ts +5 -1
  103. package/src/register.ts +3 -1
  104. package/src/shared/models.ts +8 -4
  105. package/src/styles/globals.css +111 -28
  106. package/dist/chunks/affordances-DAvsVz7u.js.map +0 -1
  107. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +0 -1
  108. package/dist/chunks/directory-B6FuiCir.js.map +0 -1
  109. package/dist/chunks/grants-9kIV6uZ7.js +0 -669
  110. package/dist/chunks/grants-9kIV6uZ7.js.map +0 -1
  111. package/dist/chunks/offboarding-CLJaNTcD.js.map +0 -1
  112. package/dist/chunks/principal-page-UtNWKCf8.js.map +0 -1
  113. package/dist/chunks/queries-Dew8mIeo.js.map +0 -1
  114. package/dist/chunks/use-change-C4bGRhHY.js.map +0 -1
  115. package/dist/chunks/validation-DvPinn8V.js +0 -87
  116. package/dist/chunks/validation-DvPinn8V.js.map +0 -1
  117. package/src/components/every-project.tsx +0 -287
@@ -13,10 +13,9 @@ import type { GrantRow, ProjectSummary } from '../shared/models';
13
13
  import { ArchiveBlocked, archiveBlockers } from '../components/references';
14
14
  import { hasEnvironmentDetails, isActiveAccessibleEnvironment, type ProjectEnvironment } from '../lib/project-environments';
15
15
  import { environmentSlugProblem } from '../lib/validation';
16
- import { ConfirmDialog, EmptyState, MenuPopup, Modal, Timestamp } from '../components/ui';
16
+ import { ConfirmDialog, EmptyState, MenuPopup, Modal, Notice, Timestamp } from '../components/ui';
17
17
  import { DeletePlaceDialog } from '../components/delete-place';
18
18
  import { PrincipalAvatar } from '../components/principal';
19
- import { ReachedBy, reaching, useEveryProject } from '../components/every-project';
20
19
  import { Archive, ChevronRight, MoreHorizontal, Pencil, Plus, RotateBack, Trash } from '../components/icons';
21
20
  import { pageRoute } from '../lib/page-route';
22
21
  import { useProject } from '../lib/project-page';
@@ -181,7 +180,7 @@ function EnvironmentCard({
181
180
  const [renaming, setRenaming] = useState(false);
182
181
  const [confirming, setConfirming] = useState(false);
183
182
  const [deleting, setDeleting] = useState(false);
184
- const { instanceRole } = useShell();
183
+ const { capabilities } = useShell();
185
184
  const [slug, setSlug] = useState(environment.slug);
186
185
  const [name, setName] = useState(environment.name);
187
186
  const coffre = useCoffre();
@@ -193,7 +192,6 @@ function EnvironmentCard({
193
192
  const { data: lent } = useQuery({ ...queries.references(coffre, place), enabled: archiving });
194
193
  const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
195
194
  const asking = archiving && lent === undefined;
196
- const everyProject = useEveryProject();
197
195
  const { status, dismiss } = useChangeStatus(keys.projects);
198
196
  const state = status(environmentId(project, environment.slug));
199
197
  const pending = state.state === 'pending';
@@ -202,16 +200,13 @@ function EnvironmentCard({
202
200
  const secretCount = details?.secretCount ?? null;
203
201
  const opens = details !== null && !isArchived && environment.accessible && !pending;
204
202
  const manageable = isAdmin && details !== null;
205
- // Deleting is for instance owners, and only once the environment is archived.
206
- const deletable = manageable && isArchived && instanceRole !== 'user';
203
+ // Deleting is for those who run the instance, and only once the environment is archived.
204
+ const deletable = manageable && isArchived && capabilities.runsInstance;
207
205
  const slugError = slug === '' ? null : environmentSlugProblem(slug);
208
206
  const lastChange = useLastChange(project, environment.slug, opens);
209
207
  const holders = holdersOf(grants, environment.slug);
210
- // A new slug brings in whoever holds it in every project: said before the rename is saved.
211
- const gainedBy =
212
- slug === environment.slug || slugError !== null
213
- ? []
214
- : reaching(everyProject, slug).filter((grant) => grant.place !== '*');
208
+ // Scopes match environments by slug: a new one is said to move them before the rename is saved.
209
+ const reslugged = slug !== environment.slug && slug !== '' && slugError === null;
215
210
 
216
211
  return (
217
212
  <div
@@ -365,7 +360,12 @@ function EnvironmentCard({
365
360
  />
366
361
  </label>
367
362
 
368
- <ReachedBy grants={gainedBy} lead={`As ${project}/${slug}, it is reached by`} />
363
+ {reslugged && (
364
+ <Notice tone="info">
365
+ Instance roles scoped to <span className="mono">{environment.slug}</span> stop reaching it; those scoped
366
+ to <span className="mono">{slug}</span> start.
367
+ </Notice>
368
+ )}
369
369
 
370
370
  <div className="dialog-actions">
371
371
  <button className="btn" type="button" onClick={() => setRenaming(false)}>
@@ -463,7 +463,6 @@ function NewEnvironment({ project, sources }: { project: string; sources: string
463
463
  : [];
464
464
  const create = useChange(createEnvironment(coffre, project));
465
465
  const slugError = slug === '' ? null : environmentSlugProblem(slug);
466
- const reachedBy = reaching(useEveryProject(), slugError === null && slug !== '' ? slug : null);
467
466
 
468
467
  function close() {
469
468
  setOpen(false);
@@ -561,8 +560,6 @@ function NewEnvironment({ project, sources }: { project: string; sources: string
561
560
  </label>
562
561
  )}
563
562
 
564
- <ReachedBy grants={reachedBy} lead="As soon as it exists, it is reached by" />
565
-
566
563
  <div className="dialog-actions">
567
564
  <button className="btn" type="button" onClick={close}>
568
565
  Cancel
@@ -145,7 +145,7 @@ function DangerZone({ project }: { project: ProjectSummary }) {
145
145
  const [deleting, setDeleting] = useState(false);
146
146
  const coffre = useCoffre();
147
147
  const router = useRouter();
148
- const { instanceRole } = useShell();
148
+ const { capabilities } = useShell();
149
149
  const { pending, error, run } = useAction();
150
150
  const isArchived = project.archivedAt !== null;
151
151
  // What archiving it would stop, asked once the dialog opens (D41); Archive waits for the answer.
@@ -153,8 +153,8 @@ function DangerZone({ project }: { project: ProjectSummary }) {
153
153
  const { data: lent } = useQuery({ ...queries.references(coffre, project.slug), enabled: archiving });
154
154
  const blockers = archiving && lent?.ok === true ? archiveBlockers(project.slug, lent.references) : [];
155
155
  const asking = archiving && lent === undefined;
156
- // Deleting is for instance owners, and only once the project is archived.
157
- const canDelete = isArchived && instanceRole !== 'user';
156
+ // Deleting is for those who run the instance, and only once the project is archived.
157
+ const canDelete = isArchived && capabilities.runsInstance;
158
158
 
159
159
  return (
160
160
  <Card labelledBy="danger-zone" title="Danger zone" tone="danger">
@@ -24,7 +24,6 @@ import {
24
24
  ProjectEmptyStateCopy,
25
25
  RootAdminOnly,
26
26
  } from '../components/affordances';
27
- import { ReachedBy, reaching, useEveryProject } from '../components/every-project';
28
27
 
29
28
  export function ProjectsPage() {
30
29
  const { data: result, refetch } = useSuspenseQuery(queries.projects(useCoffre()));
@@ -286,7 +285,6 @@ function NewProject() {
286
285
  const [open, setOpen] = useState(false);
287
286
  const create = useChange(createProject(useCoffre()));
288
287
  const slugError = slug === '' ? null : slugProblem(slug);
289
- const reachedBy = reaching(useEveryProject(), null);
290
288
 
291
289
  function close() {
292
290
  setOpen(false);
@@ -303,7 +301,7 @@ function NewProject() {
303
301
  open={open}
304
302
  onOpenChange={(next) => (next ? setOpen(true) : close())}
305
303
  title="New project"
306
- description="A project holds environments. You become its owner."
304
+ description="A project holds environments."
307
305
  >
308
306
  <form
309
307
  className="form"
@@ -344,8 +342,6 @@ function NewProject() {
344
342
  />
345
343
  </label>
346
344
 
347
- <ReachedBy grants={reachedBy} lead="As soon as it exists, it is reached by" />
348
-
349
345
  <div className="dialog-actions">
350
346
  <button className="btn" type="button" onClick={close}>
351
347
  Cancel
@@ -6,7 +6,7 @@ import { ServiceTokens } from '../components/service-tokens';
6
6
  import { TrustedWorkloads } from '../components/trusted-workloads';
7
7
  import { Notice } from '../components/ui';
8
8
  import { memberRef, useCoffre } from '../lib/coffre';
9
- import { queries, signInWays } from '../lib/queries';
9
+ import { listsAccess, queries, signInWays } from '../lib/queries';
10
10
  import { useShell } from '../lib/use-shell';
11
11
  import { pageRoute } from '../lib/page-route';
12
12
  import type { serviceAccount } from '../options';
@@ -24,17 +24,19 @@ export function ServiceAccountSignInPage() {
24
24
  const client = useCoffre();
25
25
  const shell = useShell();
26
26
  const member = memberRef('service', account);
27
- const { data: report } = useSuspenseQuery(queries.report(client, member, shell.capabilities.canManageGrants));
27
+ const { data: access } = useSuspenseQuery(queries.memberAccess(client, member, listsAccess(shell)));
28
28
  // Nothing to issue once it is removed, which its loader sent elsewhere; its layout then shows no such tab.
29
- const ways = signInWays(shell, report) ?? { tokens: false, workloads: false };
29
+ const ways = signInWays(shell, access) ?? { tokens: false, workloads: false };
30
30
  const { data: credentials } = useSuspenseQuery(queries.credentials(client, member, ways.tokens));
31
31
  const { data: bindings } = useSuspenseQuery(queries.bindings(client, member, ways.workloads));
32
+ // What a new token or binding reaches, unless narrowed: everything the account holds, which its manager reaches.
33
+ const grants = access?.ok === true ? access.grants : [];
32
34
  return (
33
35
  <>
34
36
  {bindings !== null &&
35
- (bindings.ok ? <TrustedWorkloads serviceId={account} bindings={bindings.bindings} /> : <Notice tone="bad">{bindings.error}</Notice>)}
37
+ (bindings.ok ? <TrustedWorkloads serviceId={account} bindings={bindings.bindings} grants={grants} /> : <Notice tone="bad">{bindings.error}</Notice>)}
36
38
  {credentials !== null &&
37
- (credentials.ok ? <ServiceTokens serviceId={account} tokens={credentials.tokens} /> : <Notice tone="bad">{credentials.error}</Notice>)}
39
+ (credentials.ok ? <ServiceTokens serviceId={account} tokens={credentials.tokens} grants={grants} /> : <Notice tone="bad">{credentials.error}</Notice>)}
38
40
  </>
39
41
  );
40
42
  }
@@ -2,15 +2,15 @@ import { useSuspenseQuery } from '@tanstack/react-query';
2
2
 
3
3
  import { DirectoryTable } from '../components/directory';
4
4
  import { useCoffre } from '../lib/coffre';
5
- import { queries } from '../lib/queries';
5
+ import { listsServices, queries } from '../lib/queries';
6
6
  import { useShell } from '../lib/use-shell';
7
7
  import { ClosedDoor, PageHeader } from '../components/page';
8
8
  import { RemovedList } from '../components/offboarding';
9
9
  import { Key } from '../components/icons';
10
10
 
11
11
  export function ServiceAccountsPage() {
12
- const { capabilities } = useShell();
13
- const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));
12
+ const shell = useShell();
13
+ const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), listsServices(shell)));
14
14
 
15
15
  if (!result.ok) {
16
16
  return (
@@ -26,7 +26,11 @@ export function ServiceAccountsPage() {
26
26
  <>
27
27
  <PageHeader
28
28
  title="Service accounts"
29
- description="Identities for CI and other automation."
29
+ description={
30
+ shell.capabilities.canManageGrants
31
+ ? 'Identities for CI and other automation.'
32
+ : 'Identities for CI and other automation: those you manage, which hold nothing you do not.'
33
+ }
30
34
  />
31
35
  <DirectoryTable
32
36
  principalType="service"
@@ -1,12 +1,17 @@
1
+ import { useState } from 'react';
1
2
  import type { RouteOutput } from '@coffre/client';
3
+ import { scopeInWords, unscoped, type Scope } from '@coffre/core/access';
2
4
  import { useSuspenseQuery } from '@tanstack/react-query';
3
5
  import { Link } from '@tanstack/react-router';
6
+ import { toast } from 'sonner';
4
7
  import { useCoffre } from '../lib/coffre';
5
- import { queries } from '../lib/queries';
8
+ import { affects, queries } from '../lib/queries';
9
+ import { useAction } from '../lib/use-action';
6
10
  import { useShell } from '../lib/use-shell';
7
11
  import { Card, Fact, PageHeader } from '../components/page';
8
- import { Toggletip } from '../components/ui';
9
- import { Info } from '../components/icons';
12
+ import { ScopeField } from '../components/role-field';
13
+ import { ErrorLine, Modal, Spinner, Toggletip } from '../components/ui';
14
+ import { Info, Pencil } from '../components/icons';
10
15
 
11
16
  /** The instance's settings. Your own are under Account, at the sidebar's foot. */
12
17
 
@@ -14,7 +19,8 @@ export function SettingsPage() {
14
19
  const { auth, capabilities } = useShell();
15
20
  const client = useCoffre();
16
21
  const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));
17
- const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.canManageGrants));
22
+ const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.runsInstance));
23
+ const { data: settings } = useSuspenseQuery(queries.settings(client, capabilities.runsInstance));
18
24
  const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
19
25
 
20
26
  const principals = directory?.ok === true ? directory.principals : null;
@@ -75,11 +81,81 @@ export function SettingsPage() {
75
81
  </dl>
76
82
  </Card>
77
83
 
84
+ {settings?.ok === true && <ServiceSetup scope={settings.serviceAccounts} />}
78
85
  {keys?.ok === true && <Keys keys={keys} />}
79
86
  </>
80
87
  );
81
88
  }
82
89
 
90
+ /**
91
+ * Who sets up service accounts without running the instance: anyone who
92
+ * holds access, inside this scope, giving one at most what they hold there.
93
+ * Narrowed, the rest takes an Admin whose own scope reaches it.
94
+ */
95
+ function ServiceSetup({ scope }: { scope: Scope }) {
96
+ const client = useCoffre();
97
+ const [open, setOpen] = useState(false);
98
+ const [draft, setDraft] = useState(scope);
99
+ const { pending, error, setError, run } = useAction();
100
+ const close = () => {
101
+ setOpen(false);
102
+ setDraft(scope);
103
+ setError(null);
104
+ };
105
+ return (
106
+ <Card
107
+ labelledBy="service-setup"
108
+ title="Service accounts"
109
+ 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."
110
+ actions={
111
+ <button className="btn" type="button" onClick={() => setOpen(true)}>
112
+ <Pencil size={14} />
113
+ Edit
114
+ </button>
115
+ }
116
+ >
117
+ <dl className="facts">
118
+ <Fact label="Set up by people in">
119
+ <span>{unscoped(scope) ? 'Every project and environment' : scopeInWords(scope)}</span>
120
+ </Fact>
121
+ </dl>
122
+ <Modal
123
+ open={open}
124
+ onOpenChange={(next) => (next ? setOpen(true) : close())}
125
+ title="Who sets up service accounts"
126
+ 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."
127
+ >
128
+ <form
129
+ className="form"
130
+ onSubmit={(event) => {
131
+ event.preventDefault();
132
+ run(() => client.settings.set({ serviceAccounts: draft }), {
133
+ affects: affects.settings(),
134
+ onSuccess: () => {
135
+ toast.success('Saved where people set up service accounts');
136
+ setOpen(false);
137
+ setError(null);
138
+ },
139
+ });
140
+ }}
141
+ >
142
+ <ScopeField legend="Where" scope={draft} onChange={setDraft} />
143
+ <ErrorLine error={error} />
144
+ <div className="dialog-actions">
145
+ <button className="btn" type="button" onClick={close}>
146
+ Cancel
147
+ </button>
148
+ <button className="btn btn-primary" type="submit" disabled={pending}>
149
+ {pending && <Spinner />}
150
+ Save
151
+ </button>
152
+ </div>
153
+ </form>
154
+ </Modal>
155
+ </Card>
156
+ );
157
+ }
158
+
83
159
  /**
84
160
  * What the keys you keep are checked against: no secret, so shown. The keys
85
161
  * themselves are checked by `coffre verify keys`, on your machine: a vault
@@ -6,7 +6,7 @@ import { User } from '../components/icons';
6
6
  /**
7
7
  * Cloudflare Access has authenticated this person, but Coffre has not
8
8
  * registered them as a member. Keep this deliberately actionless: registration is
9
- * an owner decision, not a self-service privilege escalation path.
9
+ * an admin's decision, not a self-service privilege escalation path.
10
10
  */
11
11
  export function UnregisteredPage() {
12
12
  const { principal, accessTampered } = useShell();
@@ -24,7 +24,7 @@ export function UnregisteredPage() {
24
24
  )}{' '}
25
25
  was changed outside coffre, so the vault refuses it and you have no access.
26
26
  </p>
27
- <p>To start over, ask a coffre owner to remove you under Users and add you again.</p>
27
+ <p>To start over, ask a coffre admin to remove you under Users and add you again.</p>
28
28
  </ClosedDoor>
29
29
  );
30
30
  }
@@ -46,7 +46,7 @@ export function UnregisteredPage() {
46
46
  , but coffre has not added you.
47
47
  </p>
48
48
  <p>
49
- Ask a coffre owner or root admin to add your Access email under Users.
49
+ Ask a coffre admin or root admin to add your Access email under Users.
50
50
  </p>
51
51
  </ClosedDoor>
52
52
  );
@@ -1,7 +1,13 @@
1
+ import { useSuspenseQuery } from '@tanstack/react-query';
2
+
1
3
  import { ActionsLog } from '../components/actions-log';
4
+ import { ConnectedAppsCard } from '../components/connected-apps';
2
5
  import { PrincipalAccess, PrincipalLayout } from '../components/principal-page';
3
- import { memberRef } from '../lib/coffre';
6
+ import { disconnectMemberApp } from '../lib/changes';
7
+ import { memberRef, useCoffre } from '../lib/coffre';
4
8
  import { pageRoute } from '../lib/page-route';
9
+ import { queries } from '../lib/queries';
10
+ import { useShell } from '../lib/use-shell';
5
11
  import type { user } from '../options';
6
12
 
7
13
  const Route = pageRoute<typeof user>();
@@ -16,6 +22,23 @@ export function UserAccessPage() {
16
22
  return <PrincipalAccess principalType="user" principalId={Route.useParams().user} />;
17
23
  }
18
24
 
25
+ /** The MCP clients they connected, for an owner, who may disconnect any of them. */
26
+ export function UserAppsPage() {
27
+ const client = useCoffre();
28
+ const member = memberRef('user', Route.useParams().user);
29
+ const { data: report } = useSuspenseQuery(queries.report(client, member, useShell().capabilities.runsInstance));
30
+ // Their layout says why there is no report.
31
+ if (report?.ok !== true || report.report === null) return null;
32
+ return (
33
+ <ConnectedAppsCard
34
+ apps={report.report.apps}
35
+ change={disconnectMemberApp(client, member)}
36
+ description="AI assistants and other MCP clients they connected. Removing them from coffre disconnects every one."
37
+ empty="They have connected none."
38
+ />
39
+ );
40
+ }
41
+
19
42
  /** Everything they did, from the audit log. */
20
43
  export function UserActivityPage() {
21
44
  return <ActionsLog member={memberRef('user', Route.useParams().user)} />;
package/src/parity.ts CHANGED
@@ -110,6 +110,9 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
110
110
  { does: '⋯ › Remove…: what removing would revoke, before it does', in: 'components/directory.tsx', call: 'members.get' },
111
111
  ],
112
112
  },
113
+ 'GET /members/:member/access': {
114
+ ui: [{ does: "a user's or service account's page › Access: their role and the grants you manage, in one read", in: 'components/principal-page.tsx', call: 'members.access' }],
115
+ },
113
116
  'PUT /members/:member': {
114
117
  ui: [
115
118
  { does: 'Users › Add user; Service accounts › Add service account', in: 'components/directory.tsx', call: 'members.add' },
@@ -134,7 +137,6 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
134
137
  { does: 'a project › Users, Service accounts › Add user, Add service account', in: 'pages/project-access.tsx', call: 'access.set' },
135
138
  { does: 'a grant › Revoke', in: 'components/grants.tsx', call: 'access.set' },
136
139
  { does: "a user's or service account's page › Edit access", in: 'components/principal-page.tsx', call: 'access.set' },
137
- { does: "an owner, on a user's or service account's Access tab › Grant on every project, and its Revoke", in: 'components/every-project.tsx', call: 'access.set' },
138
140
  ],
139
141
  },
140
142
  'GET /sessions': { ui: [{ does: 'Account › Sessions', in: 'pages/account.tsx', call: 'sessions.list' }] },
@@ -156,5 +158,7 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
156
158
  ],
157
159
  },
158
160
  'GET /audit/verification': { ui: [{ does: "Audit: the log's seal, verified on every visit", in: 'pages/audit.tsx', call: 'audit.verify' }] },
161
+ 'GET /settings': { ui: [{ does: 'Settings › Service accounts: where people set them up', in: 'pages/settings.tsx', call: 'settings.get' }] },
162
+ 'PUT /settings': { ui: [{ does: 'Settings › Service accounts › Edit', in: 'pages/settings.tsx', call: 'settings.set' }] },
159
163
  'GET /audit/keys': { ui: [{ does: 'Settings › Keys: what the keys you keep are checked against', in: 'pages/settings.tsx', call: 'audit.keys' }] },
160
164
  };
package/src/register.ts CHANGED
@@ -35,6 +35,7 @@ import {
35
35
  user,
36
36
  userAccess,
37
37
  userActivity,
38
+ userApps,
38
39
  users,
39
40
  type CoffreContext,
40
41
  } from './options';
@@ -52,7 +53,7 @@ import { ServiceAccountAccessPage, ServiceAccountActivityPage, ServiceAccountLay
52
53
  import { ServiceAccountsPage } from './pages/service-accounts';
53
54
  import { SettingsPage } from './pages/settings';
54
55
  import { UnregisteredPage } from './pages/unregistered';
55
- import { UserAccessPage, UserActivityPage, UserLayout } from './pages/user';
56
+ import { UserAccessPage, UserActivityPage, UserAppsPage, UserLayout } from './pages/user';
56
57
  import { UsersPage } from './pages/users';
57
58
 
58
59
  const root = createRootRouteWithContext<CoffreContext>()({});
@@ -88,6 +89,7 @@ const routeTree = root.addChildren([
88
89
  userPage.addChildren([
89
90
  createRoute({ ...tab(userPage, '/'), ...userAccess, component: UserAccessPage }),
90
91
  createRoute({ ...tab(userPage, '/activity'), ...userActivity, component: UserActivityPage }),
92
+ createRoute({ ...tab(userPage, '/apps'), ...userApps, component: UserAppsPage }),
91
93
  ]),
92
94
  createRoute({ ...under('/service-accounts'), ...serviceAccounts, component: ServiceAccountsPage }),
93
95
  serviceAccountPage.addChildren([
@@ -25,8 +25,12 @@ export type GrantRow = {
25
25
  role: string;
26
26
  roleName: string;
27
27
  permissions: Permission[];
28
- /** `every-project`: held on every project, or on `environmentSlug` in every project; only owners change it, elsewhere. */
29
- scope: 'project' | 'environment' | 'every-project';
28
+ /**
29
+ * `instance-role`: no grant, but their instance role reaching the
30
+ * project, which `role` and `roleName` name; it is changed on their page
31
+ * in Users, not here.
32
+ */
33
+ scope: 'project' | 'environment' | 'instance-role';
30
34
  environmentSlug: string | null;
31
35
  expiresAt: string | null;
32
36
  };
@@ -40,8 +44,8 @@ export type RoleRow = {
40
44
  assignableToEnvironment: boolean;
41
45
  };
42
46
 
43
- export type DirectoryPrincipal = Pick<Member, 'principalType' | 'principalId' | 'instanceRole' | 'isRootAdmin'> &
44
- Partial<Pick<Member, 'tampered'>> & {
47
+ export type DirectoryPrincipal = Pick<Member, 'principalType' | 'principalId' | 'instanceRole' | 'scope' | 'isRootAdmin'> &
48
+ Partial<Pick<Member, 'tampered' | 'managed'>> & {
45
49
  /** Where it has access, when the list said; a member just added has none yet. */
46
50
  grants?: { project: string; environment: string | null }[];
47
51
  };
@@ -1249,6 +1249,79 @@ a.crumb-link:hover {
1249
1249
  background-repeat: no-repeat;
1250
1250
  }
1251
1251
 
1252
+ /* An instance role's scope: two filters, each All, Only or All except, and the names it lists. */
1253
+ .scope-field {
1254
+ margin: 0;
1255
+ padding: 0;
1256
+ border: 0;
1257
+ gap: 0.5rem;
1258
+ }
1259
+
1260
+ .scope-field > legend {
1261
+ margin-bottom: 0.375rem;
1262
+ padding: 0;
1263
+ }
1264
+
1265
+ .scope-row {
1266
+ display: flex;
1267
+ flex-wrap: wrap;
1268
+ align-items: center;
1269
+ gap: 0.375rem 0.5rem;
1270
+ }
1271
+
1272
+ .scope-label {
1273
+ width: 6.25rem;
1274
+ color: var(--ink-2);
1275
+ font-size: 0.8125rem;
1276
+ }
1277
+
1278
+ .scope-row > .select {
1279
+ width: auto;
1280
+ }
1281
+
1282
+ .scope-names {
1283
+ display: flex;
1284
+ flex: 1 1 9rem;
1285
+ flex-wrap: wrap;
1286
+ align-items: center;
1287
+ gap: 0.25rem;
1288
+ min-width: 0;
1289
+ }
1290
+
1291
+ .scope-chip {
1292
+ padding-right: 0.15rem;
1293
+ color: var(--ink-2);
1294
+ }
1295
+
1296
+ .scope-chip button {
1297
+ display: inline-flex;
1298
+ padding: 0.125rem;
1299
+ border: 0;
1300
+ border-radius: var(--radius-sm);
1301
+ background: none;
1302
+ color: var(--ink-3);
1303
+ cursor: pointer;
1304
+ }
1305
+
1306
+ .scope-chip button:hover {
1307
+ color: var(--ink);
1308
+ }
1309
+
1310
+ .input.scope-input {
1311
+ flex: 1 1 4rem;
1312
+ width: auto;
1313
+ min-width: 4rem;
1314
+ height: 1.875rem;
1315
+ font-size: 0.8125rem;
1316
+ }
1317
+
1318
+ /* Where a person's instance role applies, beside it in a list. */
1319
+ .role-scope {
1320
+ margin-left: 0.4rem;
1321
+ color: var(--ink-3);
1322
+ font-size: 0.8125rem;
1323
+ }
1324
+
1252
1325
  .input-group {
1253
1326
  position: relative;
1254
1327
  display: flex;
@@ -1446,6 +1519,24 @@ a.crumb-link:hover {
1446
1519
  font-size: 0.875rem;
1447
1520
  }
1448
1521
 
1522
+ /* Checkboxes under one label: the events a trust binding accepts. */
1523
+ .checks {
1524
+ margin: 0;
1525
+ padding: 0;
1526
+ border: 0;
1527
+ }
1528
+
1529
+ .checks legend {
1530
+ padding: 0;
1531
+ margin-bottom: 0.375rem;
1532
+ }
1533
+
1534
+ .checks-row {
1535
+ display: flex;
1536
+ flex-wrap: wrap;
1537
+ gap: 0.5rem 1.25rem;
1538
+ }
1539
+
1449
1540
  /* A trust binding's claims, what a run's ID token must carry, in full. */
1450
1541
  .claims summary {
1451
1542
  color: var(--ink-2);
@@ -1856,13 +1947,6 @@ a.crumb-link:hover {
1856
1947
  width: 4.75rem;
1857
1948
  }
1858
1949
 
1859
- /* Where a revoke would be, for a grant on every project: lined up with one. */
1860
- .grants .every-project-note {
1861
- padding: 0 0.5rem;
1862
- font-size: 0.8125rem;
1863
- white-space: nowrap;
1864
- }
1865
-
1866
1950
  .grants td {
1867
1951
  overflow-wrap: anywhere;
1868
1952
  }
@@ -2416,6 +2500,11 @@ tr.row-failure > td:first-child {
2416
2500
  gap: 0.75rem;
2417
2501
  }
2418
2502
 
2503
+ /* Someone's access that could not be read, in place of its rows. */
2504
+ .unread-access {
2505
+ padding: 1rem;
2506
+ }
2507
+
2419
2508
  /* A row that opens a page, said at its end. */
2420
2509
  .col-open {
2421
2510
  vertical-align: middle;
@@ -2777,26 +2866,6 @@ span.env-link {
2777
2866
  margin-top: 0.75rem;
2778
2867
  }
2779
2868
 
2780
- /* A member's grants on every project, above their access project by project. */
2781
- .every-project-list {
2782
- display: flex;
2783
- flex-wrap: wrap;
2784
- gap: 0.5rem 1rem;
2785
- margin: 0;
2786
- padding: 0;
2787
- list-style: none;
2788
- }
2789
-
2790
- .every-project-list li {
2791
- display: flex;
2792
- align-items: center;
2793
- gap: 0.5rem;
2794
- }
2795
-
2796
- .every-project .hint {
2797
- margin-top: 0.5rem;
2798
- }
2799
-
2800
2869
  /* Environments as cards in a grid: each one a door into its secrets. */
2801
2870
  .env-grid {
2802
2871
  display: grid;
@@ -3470,6 +3539,10 @@ a.env-card-name:hover {
3470
3539
  font-weight: 600;
3471
3540
  }
3472
3541
 
3542
+ .notice p + p {
3543
+ margin-top: 0.375rem;
3544
+ }
3545
+
3473
3546
  .notice-bad {
3474
3547
  border-color: color-mix(in oklab, var(--red) 30%, var(--border));
3475
3548
  background: var(--red-wash);
@@ -4201,7 +4274,17 @@ a.env-card-name:hover {
4201
4274
  padding-bottom: 1rem;
4202
4275
  }
4203
4276
 
4204
- /* The approval page: a value the person types, and a token shown once. */
4277
+ /* The approval page: what coffre says an ID is, a value the person types, and a token shown once. */
4278
+ .approval-note {
4279
+ color: var(--ink-2);
4280
+ font-size: 0.8125rem;
4281
+ }
4282
+
4283
+ .approval-warn {
4284
+ color: var(--amber);
4285
+ font-weight: 550;
4286
+ }
4287
+
4205
4288
  .approval-field {
4206
4289
  margin: 0 1.5rem 1rem;
4207
4290
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"affordances-DAvsVz7u.js","names":[],"sources":["../../src/components/affordances.ts"],"sourcesContent":["import {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { UiCapabilities } from '../lib/capabilities';\n\ntype AdministrationItemsProps = {\n capabilities: UiCapabilities;\n users: ReactNode;\n audit: ReactNode;\n};\n\n/** The shared ordering and visibility rule for administration destinations. */\nexport function AdministrationItems({\n capabilities,\n users,\n audit,\n}: AdministrationItemsProps): ReactElement {\n return createElement(\n Fragment,\n null,\n ...administrationEntries(capabilities, { users: [users], audit: [audit] }),\n );\n}\n\n/** The same rule, for destinations kept as data (the command palette's). */\nexport function administrationEntries<T>(\n capabilities: UiCapabilities,\n { users, audit }: { users: T[]; audit: T[] },\n): T[] {\n return [\n ...(capabilities.canManageGrants ? users : []),\n ...(capabilities.canReadAudit ? audit : []),\n ];\n}\n\n/** Project creation exists before a grantable resource, so it is owner-only. */\nexport function RootAdminOnly({\n capabilities,\n children,\n}: {\n capabilities: UiCapabilities;\n children: ReactNode;\n}): ReactNode {\n return capabilities.canCreateProject ? children : null;\n}\n\n/** Empty project copy must distinguish an empty instance from archived-only state. */\nexport function ProjectEmptyStateCopy({\n capabilities,\n hasArchivedProjects,\n}: {\n capabilities: UiCapabilities;\n hasArchivedProjects: boolean;\n}): ReactNode {\n if (hasArchivedProjects) {\n return capabilities.canCreateProject\n ? 'No active projects. Start a new one, or restore one from the archive below.'\n : 'No active projects. Your archived projects appear below.';\n }\n\n if (capabilities.canCreateProject) {\n return 'No projects exist yet. Start the first one with New project.';\n }\n\n return createElement(\n Fragment,\n null,\n 'No project is visible to you. Someone holding ',\n createElement('span', { className: 'mono' }, 'grant.manage'),\n ' on a project can add you.',\n );\n}\n\n/** Reveal- and history-shaped controls require secret.read in this environment. */\nexport function SecretReadOnly({\n canReveal,\n children,\n}: {\n canReveal: boolean;\n children: ReactNode;\n}): ReactNode {\n return canReveal ? children : null;\n}\n"],"mappings":";;;AAeA,SAAgB,oBAAoB,EAClC,cACA,OACA,SACyC;CACzC,OAAO,cACL,UACA,MACA,GAAG,sBAAsB,cAAc;EAAE,OAAO,CAAC,KAAK;EAAG,OAAO,CAAC,KAAK;CAAE,CAAC,CAC3E;AACF;;AAGA,SAAgB,sBACd,cACA,EAAE,OAAO,SACJ;CACL,OAAO,CACL,GAAI,aAAa,kBAAkB,QAAQ,CAAC,GAC5C,GAAI,aAAa,eAAe,QAAQ,CAAC,CAC3C;AACF;;AAGA,SAAgB,cAAc,EAC5B,cACA,YAIY;CACZ,OAAO,aAAa,mBAAmB,WAAW;AACpD;;AAGA,SAAgB,sBAAsB,EACpC,cACA,uBAIY;CACZ,IAAI,qBACF,OAAO,aAAa,mBAChB,gFACA;CAGN,IAAI,aAAa,kBACf,OAAO;CAGT,OAAO,cACL,UACA,MACA,kDACA,cAAc,QAAQ,EAAE,WAAW,OAAO,GAAG,cAAc,GAC3D,4BACF;AACF;;AAGA,SAAgB,eAAe,EAC7B,WACA,YAIY;CACZ,OAAO,YAAY,WAAW;AAChC"}