@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
@@ -0,0 +1,323 @@
1
+ import { useEffect, useId, useState } from 'react';
2
+ import { useQuery } from '@tanstack/react-query';
3
+ import { Link } from '@tanstack/react-router';
4
+ import type { ListedReference, ReferenceView, SecretKey } from '@coffre/client';
5
+
6
+ import { useCoffre } from '../lib/coffre';
7
+ import { queries } from '../lib/queries';
8
+ import { useAction } from '../lib/use-action';
9
+ import { secretKeyProblem } from '../lib/validation';
10
+ import { ArrowRight } from './icons';
11
+ import { Card } from './page';
12
+ import { ConfirmDialog, ErrorLine, Modal, Notice, Timestamp } from './ui';
13
+
14
+ /**
15
+ * References: a secret read live through another (docs/design/environments.md).
16
+ * The vault makes and checks each one; these only show them.
17
+ */
18
+
19
+ /** Why a reference does not read, in a few words; null while it does. */
20
+ export function referenceProblem(state: ReferenceView['state']): string | null {
21
+ switch (state) {
22
+ case 'live':
23
+ return null;
24
+ case 'broken':
25
+ return 'Broken';
26
+ case 'replaced':
27
+ return 'No value';
28
+ case 'source_archived':
29
+ return 'Source archived';
30
+ case 'source_deleted':
31
+ return 'Source deleted';
32
+ case 'source_is_reference':
33
+ return 'Source is a reference';
34
+ case 'source_empty':
35
+ return 'Source has no value';
36
+ }
37
+ }
38
+
39
+ /** A secret's path as a link to it, when you can open it there. */
40
+ function SecretPath({ path, open }: { path: string; open: boolean }) {
41
+ const [project, environment, key] = path.split('/') as [string, string, string];
42
+ if (!open) {
43
+ return (
44
+ <span className="mono" title="You can't open the source">
45
+ {path}
46
+ </span>
47
+ );
48
+ }
49
+ return (
50
+ <Link className="mono" to="/projects/$project/$environment" params={{ project, environment }} search={{ filter: key }}>
51
+ {path}
52
+ </Link>
53
+ );
54
+ }
55
+
56
+ /**
57
+ * What a key that is a reference shows where its value would be: what it
58
+ * reads, and, when it does not read, why. Reading it is a reveal like any
59
+ * other, logged as a read of the source.
60
+ */
61
+ export function ReferenceValue({ reference }: { reference: NonNullable<SecretKey['reference']> }) {
62
+ const problem = referenceProblem(reference.state);
63
+ return (
64
+ <span className="reference-value">
65
+ <ArrowRight size={13} aria-label="A reference to" />
66
+ <SecretPath path={reference.source} open={reference.canOpenSource} />
67
+ {problem !== null && (
68
+ <span className="tag tag-red" title={reference.endedBy === null ? undefined : `By ${reference.endedBy}`}>
69
+ {problem}
70
+ </span>
71
+ )}
72
+ </span>
73
+ );
74
+ }
75
+
76
+ /**
77
+ * The references that read a secret from elsewhere, under its row: where
78
+ * each is held, who made it, who reads through it, and Break for those who
79
+ * may.
80
+ */
81
+ export function LentReferences({ references, onBreak }: { references: ListedReference[]; onBreak: (reference: ListedReference) => void }) {
82
+ return (
83
+ <ul className="lent-references" aria-label="Read through references">
84
+ {references.map((reference) => (
85
+ <li key={reference.id}>
86
+ <span>
87
+ Read through <SecretPath path={reference.holder} open={false} />, made by {reference.createdBy.replace(/^user:/, '')}{' '}
88
+ <Timestamp iso={reference.createdAt} display="relative" />
89
+ {reference.readers !== null && (
90
+ <span className="cell-muted">
91
+ {' '}
92
+ · {reference.readers.length === 0 ? 'no one reads it by a grant' : `${reference.readers.length} ${reference.readers.length === 1 ? 'person reads' : 'people read'} it: ${reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}`}
93
+ </span>
94
+ )}
95
+ </span>
96
+ {reference.canBreak && (
97
+ <button type="button" className="btn btn-sm btn-danger-outline" onClick={() => onBreak(reference)}>
98
+ Break
99
+ </button>
100
+ )}
101
+ </li>
102
+ ))}
103
+ </ul>
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Make a key a reference to a secret you read, by path: whoever reads its
109
+ * environment reads that secret through it, as it changes. Paths you can
110
+ * read are offered as you type.
111
+ */
112
+ export function MakeReference({
113
+ open,
114
+ onOpenChange,
115
+ holder,
116
+ environments,
117
+ onMake,
118
+ }: {
119
+ open: boolean;
120
+ onOpenChange: (open: boolean) => void;
121
+ /** `billing/prod/DATABASE_URL`. */
122
+ holder: string;
123
+ /** `market/prod`, each environment you read. */
124
+ environments: readonly string[];
125
+ onMake: (source: string) => void;
126
+ }) {
127
+ const [source, setSource] = useState('');
128
+ const listId = useId();
129
+ useEffect(() => {
130
+ if (open) setSource('');
131
+ }, [open]);
132
+ const [project, environment, key] = source.split('/');
133
+ const problem =
134
+ source === '' ? null
135
+ : source.split('/').length !== 3 || project === '' || environment === '' ? 'A secret, as project/environment/KEY.'
136
+ : secretKeyProblem(key!);
137
+ const holderEnvironment = holder.split('/').slice(0, 2).join('/');
138
+
139
+ return (
140
+ <Modal
141
+ open={open}
142
+ onOpenChange={onOpenChange}
143
+ title={`Make ${holder.split('/')[2]} a reference`}
144
+ description={`Whoever can read ${holderEnvironment} will read the secret you name, as it changes, even without access to its project. It takes your own read on that secret.`}
145
+ >
146
+ <form
147
+ className="form"
148
+ onSubmit={(event) => {
149
+ event.preventDefault();
150
+ if (problem !== null || source === '') return;
151
+ onMake(source);
152
+ onOpenChange(false);
153
+ }}
154
+ >
155
+ <label className="field">
156
+ <span className="label">Secret to read</span>
157
+ <input
158
+ className="input input-mono"
159
+ autoFocus
160
+ spellCheck={false}
161
+ autoComplete="off"
162
+ list={listId}
163
+ placeholder="market/prod/DATABASE_URL"
164
+ value={source}
165
+ aria-invalid={problem !== null}
166
+ onChange={(event) => setSource(event.target.value)}
167
+ />
168
+ <datalist id={listId}>
169
+ {environments.map((each) => (
170
+ <option key={each} value={`${each}/`} />
171
+ ))}
172
+ </datalist>
173
+ <span className={`hint${problem !== null ? ' edit-note-error' : ''}`}>
174
+ {problem ?? 'A reference cannot point at a reference: name the secret it reads.'}
175
+ </span>
176
+ </label>
177
+ <div className="dialog-actions">
178
+ <button className="btn" type="button" onClick={() => onOpenChange(false)}>
179
+ Cancel
180
+ </button>
181
+ <button className="btn btn-primary" type="submit" disabled={source === '' || problem !== null}>
182
+ Make reference
183
+ </button>
184
+ </div>
185
+ </form>
186
+ </Modal>
187
+ );
188
+ }
189
+
190
+ /**
191
+ * A project's secrets that others read through references held elsewhere,
192
+ * and who: on its access tab, beside the grants, since "who can read this"
193
+ * includes them. Those who may break one, its source's access managers or
194
+ * whoever writes where it is held, do it here.
195
+ */
196
+ export function ReferencesInto({ project }: { project: string }) {
197
+ const coffre = useCoffre();
198
+ const { data } = useQuery(queries.references(coffre, project));
199
+ const { run, error } = useAction();
200
+ const [breaking, setBreaking] = useState<ListedReference | null>(null);
201
+ const into = data?.ok === true ? data.references.filter((reference) => reference.source.startsWith(`${project}/`)) : [];
202
+ if (into.length === 0) return null;
203
+ return (
204
+ <Card
205
+ labelledBy="references-into"
206
+ title="Also readable through references"
207
+ description={`Secrets of ${project} that others read through references held elsewhere. Who reads a reference's environment reads its source, with no grant here.`}
208
+ >
209
+ <div className="dt-wrap">
210
+ <table className="dt stacks">
211
+ <thead>
212
+ <tr>
213
+ <th>Secret</th>
214
+ <th>Read through</th>
215
+ <th>Readers</th>
216
+ <th className="col-actions">
217
+ <span className="visually-hidden">Actions</span>
218
+ </th>
219
+ </tr>
220
+ </thead>
221
+ <tbody>
222
+ {into.map((reference) => (
223
+ <tr key={reference.id}>
224
+ <td className="mono" data-label="Secret">{reference.source}</td>
225
+ <td data-label="Read through">
226
+ <span className="cell-stack">
227
+ <span className="mono">{reference.holder}</span>
228
+ <small className="cell-muted">
229
+ Made by {reference.createdBy.replace(/^user:/, '')} <Timestamp iso={reference.createdAt} display="relative" />
230
+ </small>
231
+ </span>
232
+ </td>
233
+ <td data-label="Readers">
234
+ {reference.readers === null
235
+ ? '—'
236
+ : reference.readers.length === 0
237
+ ? <span className="cell-muted">No one, by a grant</span>
238
+ : reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}
239
+ </td>
240
+ <td className="col-actions">
241
+ {reference.canBreak && (
242
+ <button type="button" className="btn btn-sm btn-danger-outline" onClick={() => setBreaking(reference)}>
243
+ Break
244
+ </button>
245
+ )}
246
+ </td>
247
+ </tr>
248
+ ))}
249
+ </tbody>
250
+ </table>
251
+ </div>
252
+ {error !== null && <ErrorLine error={error} />}
253
+ <ConfirmDialog
254
+ open={breaking !== null}
255
+ onOpenChange={(open) => !open && setBreaking(null)}
256
+ title="Break this reference?"
257
+ body={breaking === null ? '' : `Whoever reads ${breaking.holder.split('/').slice(0, 2).join('/')} stops reading ${breaking.source} through it, and a run there refuses until ${breaking.holder.split('/')[2]} gets a value.`}
258
+ confirmLabel="Break"
259
+ onConfirm={() => {
260
+ const path = breaking!.holder;
261
+ void run(() => coffre.references.break(path), { affects: [['references']] });
262
+ }}
263
+ />
264
+ </Card>
265
+ );
266
+ }
267
+
268
+ /**
269
+ * The references that archiving `path` would stop, a project, an
270
+ * environment or a key: those reading a secret in it, held outside it in a
271
+ * place not archived itself (D58). Archiving is refused while any read
272
+ * (D41); the server decides, and this shows the dialog what it will say.
273
+ */
274
+ export function archiveBlockers(path: string, references: readonly ListedReference[]): ListedReference[] {
275
+ const within = (secret: string) => secret === path || secret.startsWith(`${path}/`);
276
+ return references.filter((reference) => reference.state === 'live' && !reference.holderArchived && within(reference.source) && !within(reference.holder));
277
+ }
278
+
279
+ /**
280
+ * What an archive dialog shows while references read what it would
281
+ * archive: each, and Break for those who may break it. Archive waits until
282
+ * none is left.
283
+ */
284
+ export function ArchiveBlocked({ references }: { references: readonly ListedReference[] }) {
285
+ const coffre = useCoffre();
286
+ const { run, error, pending } = useAction();
287
+ if (references.length === 0) return null;
288
+ const many = references.length > 1;
289
+ return (
290
+ <div className="archive-blocked">
291
+ <Notice tone="bad">
292
+ {many ? `${references.length} references read it` : 'A reference reads it'} from elsewhere. Break{' '}
293
+ {many ? 'them' : 'it'} first: archiving would stop {many ? 'those reads' : 'that read'}.
294
+ </Notice>
295
+ <ul className="archive-blockers" aria-label="References that read it">
296
+ {references.map((reference) => (
297
+ <li key={reference.id}>
298
+ <span className="cell-stack">
299
+ <span className="mono">{reference.holder}</span>
300
+ <small>
301
+ reads <span className="mono">{reference.source}</span>
302
+ </small>
303
+ </span>
304
+ {reference.canBreak ? (
305
+ <button
306
+ type="button"
307
+ className="btn btn-sm btn-danger-outline"
308
+ disabled={pending}
309
+ onClick={() => void run(() => coffre.references.break(reference.holder), { affects: [['references'], ['secrets']] })}
310
+ >
311
+ Break
312
+ </button>
313
+ ) : (
314
+ <small className="cell-muted">{`${reference.source.split('/')[0]}'s access managers, or whoever writes ${reference.holder.split('/').slice(0, 2).join('/')}, can break it`}</small>
315
+ )}
316
+ </li>
317
+ ))}
318
+ </ul>
319
+ <p className="hint">Once broken, a run where it is held refuses until that key gets a value of its own.</p>
320
+ {error !== null && <ErrorLine error={error} />}
321
+ </div>
322
+ );
323
+ }
@@ -13,7 +13,8 @@ import { Key, Plus, X } from './icons';
13
13
  const LIFETIMES = [30, 90, 180, 365] as const;
14
14
 
15
15
  /**
16
- * The bearer tokens a service presents to the API. A value exists in exactly
16
+ * The bearer tokens a service account presents to the API, for CI without
17
+ * OIDC. A value exists in exactly
17
18
  * one place, this dialog, for as long as it stays open: coffre keeps a hash.
18
19
  */
19
20
  export function ServiceTokens({ serviceId, tokens }: { serviceId: string; tokens: ServiceTokenRow[] }) {
@@ -22,100 +23,118 @@ export function ServiceTokens({ serviceId, tokens }: { serviceId: string; tokens
22
23
  const { status, dismiss } = useChangeStatus(change.list.queryKey);
23
24
 
24
25
  return (
25
- <Card
26
- labelledBy="service-tokens"
27
- title="Credentials"
28
- description="Bearer tokens this service presents to the API. Each is shown once, when it is issued; coffre keeps only a hash."
29
- actions={<IssueToken serviceId={serviceId} />}
30
- >
31
- {tokens.length === 0 ? (
32
- <EmptyState title="No live credentials">
33
- Nothing can act as this service until a token is issued.
34
- </EmptyState>
35
- ) : (
36
- <div className="dt-wrap">
37
- <table className="dt">
38
- <thead>
39
- <tr>
40
- <th>Token</th>
41
- <th className="col-shrink">Issued (UTC)</th>
42
- <th className="col-shrink">Last used</th>
43
- <th className="col-shrink">Expires</th>
44
- <th className="col-actions">
45
- <span className="visually-hidden">Actions</span>
46
- </th>
47
- </tr>
48
- </thead>
49
- <tbody>
50
- {tokens.map((token) => {
51
- const state = status(token.id);
52
- return (
53
- <Fragment key={token.id}>
54
- <tr className={rowClass(state)}>
55
- <td>
56
- <span className="cell-account">
57
- <Key size={15} />
58
- <span className="cell-stack">
59
- <span>{token.label ?? 'Unlabelled'}</span>
60
- <small className="mono">{token.hint}</small>
26
+ <>
27
+ <Card
28
+ labelledBy="service-tokens"
29
+ title="Bearer tokens"
30
+ description="For CI without OIDC: tokens this service account presents to the API. Each is shown once, when it is issued; coffre keeps only a hash."
31
+ >
32
+ {tokens.length === 0 ? (
33
+ <EmptyState title="No bearer tokens">
34
+ None is needed for CI that signs in with OIDC; issue one for CI that cannot.
35
+ </EmptyState>
36
+ ) : (
37
+ <div className="dt-wrap">
38
+ <table className="dt">
39
+ <thead>
40
+ <tr>
41
+ <th>Token</th>
42
+ <th className="col-shrink">Issued (UTC)</th>
43
+ <th className="col-shrink">Last used</th>
44
+ <th className="col-shrink">Expires</th>
45
+ <th className="col-actions">
46
+ <span className="visually-hidden">Actions</span>
47
+ </th>
48
+ </tr>
49
+ </thead>
50
+ <tbody>
51
+ {tokens.map((token) => {
52
+ const state = status(token.id);
53
+ return (
54
+ <Fragment key={token.id}>
55
+ <tr className={rowClass(state)}>
56
+ <td>
57
+ <span className="cell-account">
58
+ <Key size={15} />
59
+ <span className="cell-stack">
60
+ <span>{token.label ?? 'Unlabelled'}</span>
61
+ <small className="mono">{token.hint}</small>
62
+ </span>
61
63
  </span>
62
- </span>
63
- </td>
64
- <td className="nowrap">
65
- <span className="cell-stack">
66
- <Timestamp iso={token.createdAt} />
67
- <small>by {token.createdBy}</small>
68
- </span>
69
- </td>
70
- <td className="nowrap cell-muted">
71
- {token.lastUsedAt === null ? (
72
- 'Never'
73
- ) : (
64
+ </td>
65
+ <td className="nowrap">
74
66
  <span className="cell-stack">
75
- <Timestamp iso={token.lastUsedAt} display="relative" />
76
- {token.lastUsedIp !== null && <small className="mono">{token.lastUsedIp}</small>}
67
+ <Timestamp iso={token.createdAt} />
68
+ <small>by {token.createdBy}</small>
77
69
  </span>
78
- )}
79
- </td>
80
- <td className="nowrap cell-muted">
81
- <Timestamp iso={token.expiresAt} display="relative" />
82
- </td>
83
- <td className="col-actions">
84
- {state.state === 'pending' ? (
85
- <RowPending status={state} />
86
- ) : (
87
- <ConfirmButton
88
- trigger={
89
- <button className="act">
90
- <X size={13} />
91
- Revoke
92
- </button>
93
- }
94
- title={
95
- <>
96
- Revoke <span className="mono">{token.hint}</span>?
97
- </>
98
- }
99
- body="Whatever uses it is refused from its next request. Issue a new token first if the service should keep working."
100
- confirmLabel="Revoke token"
101
- onConfirm={() => revoke(token)}
102
- />
103
- )}
104
- </td>
105
- </tr>
106
- <RowFailure
107
- status={state}
108
- columns={5}
109
- onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
110
- />
111
- </Fragment>
112
- );
113
- })}
114
- </tbody>
115
- </table>
116
- </div>
117
- )}
118
- </Card>
70
+ </td>
71
+ <td className="nowrap cell-muted">
72
+ {token.lastUsedAt === null ? (
73
+ 'Never'
74
+ ) : (
75
+ <span className="cell-stack">
76
+ <Timestamp iso={token.lastUsedAt} display="relative" />
77
+ {token.lastUsedIp !== null && <small className="mono">{token.lastUsedIp}</small>}
78
+ </span>
79
+ )}
80
+ </td>
81
+ <td className="nowrap cell-muted">
82
+ <Timestamp iso={token.expiresAt} display="relative" />
83
+ </td>
84
+ <td className="col-actions">
85
+ {state.state === 'pending' ? (
86
+ <RowPending status={state} />
87
+ ) : (
88
+ <ConfirmButton
89
+ trigger={
90
+ <button className="act">
91
+ <X size={13} />
92
+ Revoke
93
+ </button>
94
+ }
95
+ title={
96
+ <>
97
+ Revoke <span className="mono">{token.hint}</span>?
98
+ </>
99
+ }
100
+ body={
101
+ <>
102
+ {token.label ?? 'Unlabelled'},{' '}
103
+ {token.lastUsedAt === null ? (
104
+ 'never used'
105
+ ) : (
106
+ <>
107
+ last used <Timestamp iso={token.lastUsedAt} display="relative" />
108
+ </>
109
+ )}
110
+ .{' '}
111
+ Whatever uses it is refused from its next request. Issue a new token first if the
112
+ service account should keep working.
113
+ </>
114
+ }
115
+ confirmLabel="Revoke token"
116
+ onConfirm={() => revoke(token)}
117
+ />
118
+ )}
119
+ </td>
120
+ </tr>
121
+ <RowFailure
122
+ status={state}
123
+ columns={5}
124
+ onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
125
+ />
126
+ </Fragment>
127
+ );
128
+ })}
129
+ </tbody>
130
+ </table>
131
+ </div>
132
+ )}
133
+ </Card>
134
+ <div className="table-actions">
135
+ <IssueToken serviceId={serviceId} />
136
+ </div>
137
+ </>
119
138
  );
120
139
  }
121
140
 
@@ -136,7 +155,7 @@ function IssueToken({ serviceId }: { serviceId: string }) {
136
155
 
137
156
  return (
138
157
  <>
139
- <button className="btn btn-sm" onClick={() => setOpen(true)}>
158
+ <button className="btn" onClick={() => setOpen(true)}>
140
159
  <Plus size={14} />
141
160
  Issue token
142
161
  </button>
@@ -8,9 +8,8 @@ import {
8
8
  import { Link, useNavigate, useRouterState } from '@tanstack/react-router';
9
9
  import { Dialog } from '@base-ui/react/dialog';
10
10
  import { Menu } from '@base-ui/react/menu';
11
- import type { InstanceState } from '@coffre/client';
11
+ import { PROJECT_PAGES } from '@coffre/core/pages';
12
12
  import type { ProjectSummary } from '../shared/models';
13
- import { pendingMigrations, UPGRADE_DOC } from '../lib/instance';
14
13
  import type { UiCapabilities } from '../lib/capabilities';
15
14
  import { isActiveAccessibleEnvironment } from '../lib/project-environments';
16
15
  import { useMounted } from '../lib/mounted';
@@ -19,7 +18,7 @@ import { AdministrationItems } from './affordances';
19
18
  import { CommandPalette } from './command-palette';
20
19
  import { ThemeMenuItems } from './theme';
21
20
  import { Tile } from './tile';
22
- import { MenuPopup, Notice, Tip } from './ui';
21
+ import { MenuPopup, Tip } from './ui';
23
22
  import {
24
23
  Check,
25
24
  ChevronsUpDown,
@@ -45,7 +44,6 @@ type ShellProps = {
45
44
  principal: Principal;
46
45
  instanceRole: InstanceRole;
47
46
  capabilities: UiCapabilities;
48
- instance: InstanceState | null;
49
47
  children: ReactNode;
50
48
  };
51
49
 
@@ -71,26 +69,6 @@ function roleLabel(principal: Principal, instanceRole: InstanceRole): string {
71
69
  return 'Member';
72
70
  }
73
71
 
74
- /**
75
- * Above every page, for owners and root admins, while the database is behind
76
- * the code this instance runs: what to run, and where the steps are.
77
- */
78
- function MigrationBanner({ instance }: { instance: InstanceState | null }) {
79
- const pending = pendingMigrations(instance);
80
- if (pending.length === 0) return null;
81
- return (
82
- <div className="migration-banner">
83
- <Notice tone="info">
84
- <strong>Database migrations pending:</strong> run <code>coffre migrate</code> to apply{' '}
85
- <span className="mono">{pending.join(', ')}</span>, which coffre {instance?.version} ships.{' '}
86
- <a href={UPGRADE_DOC} target="_blank" rel="noreferrer">
87
- How to upgrade
88
- </a>
89
- </Notice>
90
- </div>
91
- );
92
- }
93
-
94
72
  /** The product's mark and name, for the pages you see before signing in. */
95
73
  export function Brand() {
96
74
  return (
@@ -112,7 +90,7 @@ export function Brand() {
112
90
  * navigation lives outside the pages themselves. Everywhere else the page's
113
91
  * own title says where you are, so the bar leaves it out rather than repeat it.
114
92
  */
115
- export function Shell({ projects, principal, instanceRole, capabilities, instance, children }: ShellProps) {
93
+ export function Shell({ projects, principal, instanceRole, capabilities, children }: ShellProps) {
116
94
  const { portal } = usePreferences();
117
95
  const pathname = useRouterState({ select: (state) => state.location.pathname });
118
96
  const [drawerOpen, setDrawerOpen] = useState(false);
@@ -220,7 +198,6 @@ export function Shell({ projects, principal, instanceRole, capabilities, instanc
220
198
  </header>
221
199
 
222
200
  <main className="content" id="content">
223
- <MigrationBanner instance={instance} />
224
201
  {children}
225
202
  </main>
226
203
  </div>
@@ -268,7 +245,7 @@ function Sidebar({
268
245
  users={
269
246
  <>
270
247
  <NavLink to="/users" label="Users" icon={<Users size={16} />} collapsed={collapsed} />
271
- <NavLink to="/tokens" label="Tokens" icon={<Key size={16} />} collapsed={collapsed} />
248
+ <NavLink to="/service-accounts" label="Service accounts" icon={<Key size={16} />} collapsed={collapsed} />
272
249
  </>
273
250
  }
274
251
  audit={
@@ -330,7 +307,7 @@ function NavLink({
330
307
  icon,
331
308
  collapsed,
332
309
  }: {
333
- to: '/projects' | '/users' | '/tokens' | '/audit' | '/settings';
310
+ to: '/projects' | '/users' | '/service-accounts' | '/audit' | '/settings';
334
311
  label: string;
335
312
  icon: ReactNode;
336
313
  collapsed: boolean;
@@ -412,20 +389,22 @@ function Breadcrumbs({
412
389
  projects: ProjectSummary[];
413
390
  canListPrincipals: boolean;
414
391
  }) {
415
- const [section, projectSlug, environmentSlug] = pathname
392
+ const [section, projectSlug, place] = pathname
416
393
  .split('/')
417
394
  .filter((segment) => segment !== '')
418
395
  .map(decodeURIComponent);
396
+ // A project's tab sits where an environment would, and no environment takes its name.
397
+ const environmentSlug = place !== undefined && (PROJECT_PAGES as readonly string[]).includes(place) ? undefined : place;
419
398
 
420
399
  // A user's or token's own page sits under its list, like an environment
421
400
  // under its project. Someone who manages one project's access reaches the
422
401
  // page without being able to open the list, so the root is then just a label.
423
- if ((section === 'users' || section === 'tokens') && projectSlug !== undefined) {
424
- const label = <span>{section === 'users' ? 'Users' : 'Tokens'}</span>;
402
+ if ((section === 'users' || section === 'service-accounts') && projectSlug !== undefined) {
403
+ const label = <span>{section === 'users' ? 'Users' : 'Service accounts'}</span>;
425
404
  return (
426
405
  <nav className="crumbs" aria-label="Breadcrumb">
427
406
  {canListPrincipals ? (
428
- <Link className="crumb-link crumb-root" to={section === 'users' ? '/users' : '/tokens'}>
407
+ <Link className="crumb-link crumb-root" to={section === 'users' ? '/users' : '/service-accounts'}>
429
408
  {label}
430
409
  </Link>
431
410
  ) : (