@coffre/ui 0.6.1 → 0.7.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 (119) hide show
  1. package/dist/chunks/{audit-sentence-CUUMshIp.js → audit-sentence-C1_gRxWW.js} +91 -26
  2. package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
  3. package/dist/chunks/{connected-apps-DTpatjge.js → connected-apps-Bn5rEoV2.js} +4 -4
  4. package/dist/chunks/{connected-apps-DTpatjge.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
  5. package/dist/chunks/{delete-place-SOOYVt6A.js → delete-place-CQCDHkne.js} +4 -4
  6. package/dist/chunks/{delete-place-SOOYVt6A.js.map → delete-place-CQCDHkne.js.map} +1 -1
  7. package/dist/chunks/{directory-DrtdKny2.js → directory-BQNOdze_.js} +22 -19
  8. package/dist/chunks/directory-BQNOdze_.js.map +1 -0
  9. package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
  10. package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
  11. package/dist/chunks/{grants-DDBui9YD.js → grants-CJIBrkod.js} +5 -5
  12. package/dist/chunks/{grants-DDBui9YD.js.map → grants-CJIBrkod.js.map} +1 -1
  13. package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
  14. package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
  15. package/dist/chunks/{offboarding-C7ECW5o0.js → offboarding-CrgwaetA.js} +4 -4
  16. package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
  17. package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
  18. package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
  19. package/dist/chunks/{principal-page-CB6dAABC.js → principal-page-DDmmV1KQ.js} +37 -27
  20. package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
  21. package/dist/chunks/{project-page-BHNUvr2L.js → project-page-BI--vjt3.js} +2 -2
  22. package/dist/chunks/{project-page-BHNUvr2L.js.map → project-page-BI--vjt3.js.map} +1 -1
  23. package/dist/chunks/{queries-DgQo3mC-.js → queries-epz4MIuW.js} +103 -18
  24. package/dist/chunks/queries-epz4MIuW.js.map +1 -0
  25. package/dist/chunks/{references-BQc35Q9g.js → references-DImfw0cz.js} +4 -4
  26. package/dist/chunks/{references-BQc35Q9g.js.map → references-DImfw0cz.js.map} +1 -1
  27. package/dist/chunks/{role-field-BfWRCqzl.js → role-field-C1KhNaIR.js} +2 -2
  28. package/dist/chunks/{role-field-BfWRCqzl.js.map → role-field-C1KhNaIR.js.map} +1 -1
  29. package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
  30. package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
  31. package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
  32. package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
  33. package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
  34. package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
  35. package/dist/chunks/{use-action-DthL5hL8.js → use-action-BB-RcHo1.js} +2 -2
  36. package/dist/chunks/{use-action-DthL5hL8.js.map → use-action-BB-RcHo1.js.map} +1 -1
  37. package/dist/chunks/{use-change-By4cG8bT.js → use-change-CQyDpCqw.js} +323 -31
  38. package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
  39. package/dist/chunks/{use-shell-D6kjSPls.js → use-shell-C_NmvCt_.js} +2 -2
  40. package/dist/chunks/{use-shell-D6kjSPls.js.map → use-shell-C_NmvCt_.js.map} +1 -1
  41. package/dist/index.d.ts +46 -164
  42. package/dist/index.js +143 -129
  43. package/dist/index.js.map +1 -1
  44. package/dist/pages/account.d.ts +1 -1
  45. package/dist/pages/account.js +29 -12
  46. package/dist/pages/account.js.map +1 -1
  47. package/dist/pages/approval.js +1 -1
  48. package/dist/pages/audit.js +96 -90
  49. package/dist/pages/audit.js.map +1 -1
  50. package/dist/pages/device-login.js +1 -1
  51. package/dist/pages/environment.js +949 -412
  52. package/dist/pages/environment.js.map +1 -1
  53. package/dist/pages/login.js +2 -2
  54. package/dist/pages/oauth-authorize.js +1 -1
  55. package/dist/pages/project-access.js +9 -9
  56. package/dist/pages/project-access.js.map +1 -1
  57. package/dist/pages/project-environments.js +112 -64
  58. package/dist/pages/project-environments.js.map +1 -1
  59. package/dist/pages/project-settings.d.ts +1 -1
  60. package/dist/pages/project-settings.js +54 -75
  61. package/dist/pages/project-settings.js.map +1 -1
  62. package/dist/pages/project.js +3 -7
  63. package/dist/pages/project.js.map +1 -1
  64. package/dist/pages/projects.js +50 -77
  65. package/dist/pages/projects.js.map +1 -1
  66. package/dist/pages/service-account.js +284 -160
  67. package/dist/pages/service-account.js.map +1 -1
  68. package/dist/pages/service-accounts.js +4 -4
  69. package/dist/pages/settings.js +5 -5
  70. package/dist/pages/unregistered.js +1 -1
  71. package/dist/pages/user.js +5 -5
  72. package/dist/pages/users.js +4 -4
  73. package/package.json +3 -3
  74. package/src/components/actions-log.tsx +3 -2
  75. package/src/components/command-palette.tsx +4 -5
  76. package/src/components/directory.tsx +7 -14
  77. package/src/components/generate-value.tsx +15 -7
  78. package/src/components/missing.tsx +63 -67
  79. package/src/components/offboarding.tsx +1 -1
  80. package/src/components/personal-tokens.tsx +131 -0
  81. package/src/components/principal-page.tsx +30 -17
  82. package/src/components/regenerate.tsx +72 -0
  83. package/src/components/service-tokens.tsx +5 -14
  84. package/src/components/shell.tsx +79 -75
  85. package/src/components/trusted-workloads.tsx +179 -19
  86. package/src/components/ui.tsx +35 -25
  87. package/src/lib/audit-sentences.ts +100 -12
  88. package/src/lib/bindings.ts +41 -3
  89. package/src/lib/changes.ts +215 -29
  90. package/src/lib/clipboard.ts +40 -0
  91. package/src/lib/copy-attempts.ts +103 -0
  92. package/src/lib/dismissal.ts +24 -0
  93. package/src/lib/generate.ts +3 -146
  94. package/src/lib/optimistic.ts +3 -1
  95. package/src/lib/queries.ts +121 -17
  96. package/src/lib/recipes.ts +63 -0
  97. package/src/lib/reveal.ts +7 -1
  98. package/src/lib/row-reads.ts +64 -0
  99. package/src/lib/secret-edit-batch.ts +64 -5
  100. package/src/options.ts +43 -51
  101. package/src/pages/account.tsx +27 -5
  102. package/src/pages/audit.tsx +38 -31
  103. package/src/pages/environment.tsx +655 -121
  104. package/src/pages/project-access.tsx +1 -1
  105. package/src/pages/project-environments.tsx +92 -45
  106. package/src/pages/project-settings.tsx +9 -20
  107. package/src/pages/project.tsx +1 -5
  108. package/src/pages/projects.tsx +13 -28
  109. package/src/parity.ts +20 -4
  110. package/src/styles/globals.css +143 -131
  111. package/dist/chunks/audit-sentence-CUUMshIp.js.map +0 -1
  112. package/dist/chunks/directory-DrtdKny2.js.map +0 -1
  113. package/dist/chunks/offboarding-C7ECW5o0.js.map +0 -1
  114. package/dist/chunks/principal-page-CB6dAABC.js.map +0 -1
  115. package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
  116. package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
  117. package/dist/chunks/queries-DgQo3mC-.js.map +0 -1
  118. package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
  119. package/dist/chunks/use-change-By4cG8bT.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/ui",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "coffre's pages, for a deployment's own TanStack Start app: its router, and a Vite plugin for its build.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,8 +44,8 @@
44
44
  "@tanstack/router-core": "1.171.15",
45
45
  "lucide-react": "1.47.0",
46
46
  "sonner": "2.0.7",
47
- "@coffre/client": "0.6.1",
48
- "@coffre/core": "0.6.1"
47
+ "@coffre/client": "0.7.0",
48
+ "@coffre/core": "0.7.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@tanstack/react-query": "5.103.1",
@@ -21,8 +21,9 @@ export function ActionsLog({ member }: { member: string }) {
21
21
  initialPageParam: undefined as number | undefined,
22
22
  queryFn: ({ pageParam }) =>
23
23
  uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),
24
+ // A page lists fewer entries where they name many secrets: `more` says whether older ones follow.
24
25
  getNextPageParam: (page) =>
25
- page.ok && page.entries.length === PAGE_SIZE ? page.entries.at(-1)!.seq : undefined,
26
+ page.ok && page.more && page.entries.length > 0 ? page.entries.at(-1)!.seq : undefined,
26
27
  });
27
28
 
28
29
  if (log.isPending) {
@@ -41,7 +42,7 @@ export function ActionsLog({ member }: { member: string }) {
41
42
  <>
42
43
  <section className="card" aria-label="Actions log">
43
44
  {shown.length === 0 ? (
44
- <EmptyState title="Nothing done yet">Every read, write and change they make is listed here.</EmptyState>
45
+ <EmptyState title="Nothing yet" />
45
46
  ) : (
46
47
  <div className="dt-wrap">
47
48
  <table className="dt actions-log stacks stacks-inline">
@@ -92,7 +92,7 @@ export function CommandPalette({
92
92
  value: 'Environments',
93
93
  items: active.flatMap((project) =>
94
94
  project.environments.filter(isActiveAccessibleEnvironment).map((environment) => ({
95
- value: `${project.slug}/${environment.slug} ${environment.name}`,
95
+ value: `${project.slug}/${environment.slug}`,
96
96
  icon: <Layers size={15} />,
97
97
  label: (
98
98
  <span className="mono">
@@ -115,10 +115,9 @@ export function CommandPalette({
115
115
  {
116
116
  value: 'Projects',
117
117
  items: active.map((project) => ({
118
- value: `${project.slug} ${project.name}`,
118
+ value: project.slug,
119
119
  icon: <Folder size={15} />,
120
120
  label: <span className="mono">{project.slug}</span>,
121
- hint: project.name,
122
121
  path: '/projects/$project',
123
122
  run: closing(() =>
124
123
  navigate({ to: '/projects/$project', params: { project: project.slug } }),
@@ -165,9 +164,9 @@ export function CommandPalette({
165
164
  {
166
165
  value: 'audit denials denied refused',
167
166
  icon: <SlashCircle size={15} />,
168
- label: 'Audit, denials only',
167
+ label: 'Audit, denials',
169
168
  path: '/audit',
170
- run: closing(() => navigate({ to: '/audit', search: { decision: 'deny' } })),
169
+ run: closing(() => navigate({ to: '/audit', search: { decision: 'deny', detail: '1' } })),
171
170
  },
172
171
  ],
173
172
  }),
@@ -143,7 +143,7 @@ export function DirectoryTable({
143
143
  <InstanceRole principal={principal} />
144
144
  </td>
145
145
  ) : (
146
- <ServiceCells principal={principal} />
146
+ <ServiceCells principal={principal} adding={state.state === 'pending' && state.kind === 'saving'} />
147
147
  )}
148
148
  <td className="col-actions">
149
149
  {state.state === 'pending' ? (
@@ -198,15 +198,15 @@ const PLATFORM: Record<string, string> = {
198
198
  * it reaches, and whether it is still in use. Access comes with the list; the
199
199
  * bindings and tokens are read per row, as its own page reads them.
200
200
  */
201
- function ServiceCells({ principal }: { principal: DirectoryPrincipal }) {
201
+ function ServiceCells({ principal, adding }: { principal: DirectoryPrincipal; adding: boolean }) {
202
202
  const client = useCoffre();
203
203
  const shell = useShell();
204
204
  const member = memberOf(principal);
205
205
  // As `loadServiceDirectory` read them, so these come from its cache; an account just added is yours.
206
206
  const ways = waysFor(shell, principal.managed !== false);
207
- // Not suspended: an account added here is shown at once, its facts when they come.
208
- const { data: bindings } = useQuery(queries.bindings(client, member, ways.workloads));
209
- const { data: credentials } = useQuery(queries.credentials(client, member, ways.tokens));
207
+ // Not suspended: an account added here is shown at once, its facts once it is made, and not asked for before.
208
+ const { data: bindings } = useQuery({ ...queries.bindings(client, member, ways.workloads), enabled: !adding });
209
+ const { data: credentials } = useQuery({ ...queries.credentials(client, member, ways.tokens), enabled: !adding });
210
210
 
211
211
  const platforms = new Map<string, number>();
212
212
  const bindingList = bindings?.ok === true ? bindings.bindings : [];
@@ -345,15 +345,7 @@ export function PrincipalActions({
345
345
  if (!(capabilities.runsInstance || yours)) return null;
346
346
  if (principal.declared === true) {
347
347
  return (
348
- <Toggletip
349
- label={
350
- <>
351
- The deployment names them an Owner: <span className="mono">owners</span> in the vault's configuration. To
352
- change or remove them, take them off that list and deploy.
353
- </>
354
- }
355
- align="end"
356
- >
348
+ <Toggletip label="Owner defined by the deployment configuration." align="end">
357
349
  <button type="button" className={trigger} aria-label={`Why ${principal.principalId} can't be changed`}>
358
350
  <Lock size={14} />
359
351
  </button>
@@ -488,6 +480,7 @@ function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; op
488
480
  ? [
489
481
  plural(live.grants, 'grant'),
490
482
  plural(live.sessions, 'session'),
483
+ ...(live.tokens > 0 ? [plural(live.tokens, 'personal token')] : []),
491
484
  plural(live.identities, 'linked sign-in account'),
492
485
  ...(features.mcp ? [apps] : []),
493
486
  ]
@@ -3,17 +3,18 @@ import {
3
3
  DEFAULT_RECIPE,
4
4
  ENCODINGS,
5
5
  encodedLength,
6
+ formatRecipe,
6
7
  generate,
7
8
  MAX_BYTES,
8
9
  MIN_BYTES,
9
10
  PAIRS,
10
- pairNameProblem,
11
11
  publicKeyName,
12
12
  type AesSize,
13
13
  type Encoding,
14
14
  type Generated,
15
15
  type Recipe,
16
- } from '../lib/generate';
16
+ } from '@coffre/core/recipe';
17
+ import { pairNameProblem } from '../lib/generate';
17
18
  import type { Companion } from '../lib/secret-edit-batch';
18
19
  import { secretKeyProblem } from '../lib/validation';
19
20
  import { Eye, EyeOff, Shuffle } from './icons';
@@ -22,9 +23,10 @@ import { ErrorLine, Modal } from './ui';
22
23
 
23
24
  /**
24
25
  * What Use hands the row: its value, its name as the dialog left it (only a
25
- * new row's can change), and for a key pair the public key it saves with it.
26
+ * new row's can change), the recipe it was made by, which the row saves
27
+ * with it for Regenerate, and for a key pair the public key it saves too.
26
28
  */
27
- export type GeneratedUse = { value: string; name: string; companion?: Companion };
29
+ export type GeneratedUse = { value: string; name: string; recipe: string; companion?: Companion };
28
30
 
29
31
  type Kind = Recipe['kind'];
30
32
 
@@ -99,7 +101,8 @@ function GenerateForm({
99
101
  const [size, setSize] = useState<AesSize>(256);
100
102
  const [pair, setPair] = useState(0);
101
103
  const [round, setRound] = useState(0);
102
- const [generated, setGenerated] = useState<Generated | null>(null);
104
+ // With the recipe it was made by, which Use saves: never the one picked a moment later.
105
+ const [generated, setGenerated] = useState<(Generated & { recipe: string }) | null>(null);
103
106
  const [error, setError] = useState<string | null>(null);
104
107
  const [privateName, setPrivateName] = useState(name);
105
108
  // Follows the private key's name until it is typed in, or the row it replaces names it.
@@ -118,7 +121,7 @@ function GenerateForm({
118
121
  setGenerated(null);
119
122
  setError(null);
120
123
  generate(recipe).then(
121
- (made) => current && setGenerated(made),
124
+ (made) => current && setGenerated({ ...made, recipe: formatRecipe(recipe) }),
122
125
  (failure: unknown) =>
123
126
  current && setError(failure instanceof Error ? failure.message : 'The browser made no value.'),
124
127
  );
@@ -139,9 +142,10 @@ function GenerateForm({
139
142
  ? {
140
143
  value: generated.value,
141
144
  name: privateName.trim(),
145
+ recipe: generated.recipe,
142
146
  companion: { key: publicKey.trim(), value: generated.publicKey },
143
147
  }
144
- : { value: generated.value, name },
148
+ : { value: generated.value, name, recipe: generated.recipe },
145
149
  );
146
150
  }
147
151
 
@@ -278,6 +282,10 @@ function GenerateForm({
278
282
  />
279
283
  )}
280
284
 
285
+ <p className="hint">
286
+ Saved with its recipe, <span className="mono">{formatRecipe(recipe)}</span>, so Regenerate makes the next one alike.
287
+ </p>
288
+
281
289
  <ErrorLine error={error} />
282
290
 
283
291
  <div className="dialog-actions generate-actions">
@@ -1,18 +1,22 @@
1
- import { useState } from 'react';
2
- import { useQuery } from '@tanstack/react-query';
1
+ import type { MissingKey } from '@coffre/client';
2
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
3
 
4
+ import { dismissMissing, missingList, restoreMissing } from '../lib/changes';
4
5
  import { useCoffre } from '../lib/coffre';
5
- import { affects, queries } from '../lib/queries';
6
- import { useAction } from '../lib/use-action';
6
+ import { dismissWithUndo } from '../lib/dismissal';
7
+ import { changeOptions } from '../lib/optimistic';
8
+ import { queries } from '../lib/queries';
9
+ import { useChangeStatus } from '../lib/use-change';
7
10
  import { Card } from './page';
8
- import { ErrorLine, Timestamp } from './ui';
11
+ import { RowFailure, rowClass } from './row-state';
9
12
 
10
13
  /**
11
14
  * Keys the environment's siblings have and it lacks, by name, whether you
12
- * read them or not (docs/design/environments.md): each with Add, which opens a new row with
13
- * its name, and Dismiss, which the whole team then sees, and below them
14
- * Dismiss all and what was dismissed, each with Restore. Nothing shows when
15
- * nothing is missing or dismissed.
15
+ * read them or not (docs/design/environments.md): each with Add, which opens
16
+ * a new row with its name, and Dismiss, which the whole team then sees, and
17
+ * below them Dismiss all. Nothing shows when nothing is missing, dismissed
18
+ * keys included: they are restored from the CLI (`coffre missing
19
+ * --dismissed`), or by Undo right after dismissing.
16
20
  */
17
21
  export function MissingKeys({
18
22
  project,
@@ -29,82 +33,74 @@ export function MissingKeys({
29
33
  const coffre = useCoffre();
30
34
  const place = { project, environment };
31
35
  const { data } = useQuery(queries.missing(coffre, place));
32
- const { run, pending, error } = useAction();
33
- const [showDismissed, setShowDismissed] = useState(false);
34
- if (data?.ok !== true || (data.missing.length === 0 && data.dismissed.length === 0)) return null;
35
- const { missing, dismissed } = data;
36
- const path = `${project}/${environment}`;
37
- const dismiss = (patch: Record<string, true | null>) => void run(() => coffre.environments.dismiss(path, patch), { affects: affects.secrets(place) });
36
+ const queryClient = useQueryClient();
37
+ // Each call's own promise, which `mutate`'s callbacks are not: they follow only the latest call.
38
+ const dismissKeys = useMutation(changeOptions(queryClient, dismissMissing(coffre, place))).mutateAsync;
39
+ const restoreKeys = useMutation(changeOptions(queryClient, restoreMissing(coffre, place))).mutateAsync;
40
+ const list = missingList(place);
41
+ const { status, dismiss: forget } = useChangeStatus(list.queryKey);
42
+ // What is missing, and only that: the dismissed are not listed.
43
+ const missing = data === undefined ? [] : list.items(data);
44
+ if (missing.length === 0) return null;
45
+ const columns = canWrite ? 3 : 2;
46
+
47
+ // Gone from the list at once, and said so at once, each dismissal with its
48
+ // own Undo. A refused one puts its rows back, saying why beneath them, and
49
+ // its toast says why too (`dismissWithUndo`).
50
+ const dismiss = (entries: MissingKey[]) => void dismissWithUndo(entries, { dismiss: dismissKeys, restore: restoreKeys });
38
51
 
39
52
  return (
40
53
  <>
41
54
  <Card
42
55
  wide
43
56
  labelledBy="missing-keys"
44
- title={missing.length === 0 ? 'Nothing missing' : `${missing.length} ${missing.length === 1 ? 'key' : 'keys'} from other environments ${missing.length === 1 ? "isn't" : "aren't"} here`}
57
+ title={`${missing.length} ${missing.length === 1 ? 'key' : 'keys'} from other environments ${missing.length === 1 ? "isn't" : "aren't"} here`}
45
58
  description="Compared with every other environment of the project, by key name."
46
59
  >
47
60
  <div className="dt-wrap">
48
61
  <table className="dt stacks missing-keys">
49
62
  <tbody>
50
- {missing.map((entry) => (
51
- <tr key={entry.key}>
52
- <td className="mono" data-label="Key">{entry.key}</td>
53
- <td className="cell-muted" data-label="In">
54
- In {entry.in.join(', ')}
55
- {entry.folder !== null && <>, in {entry.folder}/</>}
56
- </td>
57
- {canWrite && (
58
- <td className="col-actions">
59
- <div className="acts">
60
- <button type="button" className="btn btn-sm" onClick={() => onAdd(entry.key)}>
61
- Add
62
- </button>
63
- <button type="button" className="btn btn-sm btn-quiet" disabled={pending} onClick={() => dismiss({ [entry.key]: true })}>
64
- Dismiss
65
- </button>
66
- </div>
67
- </td>
68
- )}
69
- </tr>
70
- ))}
71
- {showDismissed && dismissed.length > 0 && (
72
- <tr className="folder-row">
73
- <th colSpan={canWrite ? 3 : 2} scope="rowgroup">Dismissed</th>
74
- </tr>
75
- )}
76
- {showDismissed && dismissed.map((entry) => (
77
- <tr key={`dismissed:${entry.key}`}>
78
- <td className="mono" data-label="Key">{entry.key}</td>
79
- <td className="cell-muted" data-label="Dismissed">
80
- By {entry.dismissedBy} <Timestamp iso={entry.dismissedAt} display="relative" />; in {entry.in.join(', ')}
81
- </td>
82
- {canWrite && (
83
- <td className="col-actions">
84
- <button type="button" className="btn btn-sm" disabled={pending} onClick={() => dismiss({ [entry.key]: null })}>
85
- Restore
86
- </button>
63
+ {missing.map((entry) => {
64
+ const state = status(entry.key);
65
+ return [
66
+ <tr key={entry.key} className={rowClass(state)}>
67
+ <td className="mono" data-label="Key">{entry.key}</td>
68
+ <td className="cell-muted" data-label="In">
69
+ In {entry.in.join(', ')}
70
+ {entry.folder !== null && <>, in {entry.folder}/</>}
87
71
  </td>
88
- )}
89
- </tr>
90
- ))}
72
+ {canWrite && (
73
+ <td className="col-actions">
74
+ <div className="acts">
75
+ <button type="button" className="btn btn-sm" onClick={() => onAdd(entry.key)}>
76
+ Add
77
+ </button>
78
+ <button type="button" className="btn btn-sm btn-quiet" onClick={() => dismiss([entry])}>
79
+ Dismiss
80
+ </button>
81
+ </div>
82
+ </td>
83
+ )}
84
+ </tr>,
85
+ <RowFailure
86
+ key={`failure:${entry.key}`}
87
+ status={state}
88
+ columns={columns}
89
+ onDismiss={() => state.state === 'failed' && forget(state.mutationId)}
90
+ />,
91
+ ];
92
+ })}
91
93
  </tbody>
92
94
  </table>
93
95
  </div>
94
- {error !== null && <ErrorLine error={error} />}
95
96
  </Card>
96
- <div className="table-actions">
97
- {canWrite && missing.length > 1 && (
98
- <button type="button" className="btn" disabled={pending} onClick={() => dismiss(Object.fromEntries(missing.map((entry) => [entry.key, true])))}>
97
+ {canWrite && missing.length > 1 && (
98
+ <div className="table-actions">
99
+ <button type="button" className="btn" onClick={() => dismiss(missing)}>
99
100
  Dismiss all
100
101
  </button>
101
- )}
102
- {dismissed.length > 0 && (
103
- <button type="button" className="btn btn-quiet" aria-expanded={showDismissed} onClick={() => setShowDismissed((open) => !open)}>
104
- {showDismissed ? 'Hide dismissed' : `Dismissed (${dismissed.length})`}
105
- </button>
106
- )}
107
- </div>
102
+ </div>
103
+ )}
108
104
  </>
109
105
  );
110
106
  }
@@ -42,7 +42,7 @@ export function RemovedNotice({ report }: { report: PrincipalReport }) {
42
42
  )}
43
43
  .{' '}
44
44
  {person
45
- ? 'Their project access, sessions, CLI logins, linked sign-in accounts and connected apps were revoked, so adding them again starts from nothing.'
45
+ ? 'Their project access, sessions, CLI logins, personal tokens, linked sign-in accounts and connected apps were revoked, so adding them again starts from nothing.'
46
46
  : 'Its project access and every token issued to it were revoked, so adding it again starts from nothing.'}
47
47
  </Notice>
48
48
  </div>
@@ -0,0 +1,131 @@
1
+ import type { TokenRow } from '@coffre/client';
2
+ import { credentialScopeInWords } from '@coffre/core/access';
3
+ import { Fragment, type ReactNode } from 'react';
4
+
5
+ import type { Change } from '../lib/optimistic';
6
+ import { useChange, useChangeStatus } from '../lib/use-change';
7
+ import { Key, X } from './icons';
8
+ import { Card } from './page';
9
+ import { RowFailure, RowPending, rowClass } from './row-state';
10
+ import { ConfirmButton, EmptyState, ErrorLine, Timestamp } from './ui';
11
+
12
+ /**
13
+ * Personal tokens, which act as their person within what each reaches:
14
+ * your own on your account page, or a person's on theirs, for whoever runs
15
+ * the instance. Each row says what it is called, what it reaches and when
16
+ * it ends; Revoke stops it at its next request.
17
+ */
18
+ export function PersonalTokensCard<TData>({
19
+ tokens,
20
+ change,
21
+ description,
22
+ empty,
23
+ emptyActions,
24
+ }: {
25
+ tokens: TokenRow[] | { error: string };
26
+ change: Change<TData, TokenRow, TokenRow, unknown>;
27
+ description: ReactNode;
28
+ /** Said when there is none: phrasing, inside the empty state's paragraph. */
29
+ empty?: ReactNode;
30
+ /** Beneath it, what to do about it. */
31
+ emptyActions?: ReactNode;
32
+ }) {
33
+ const revoke = useChange(change);
34
+ const { status, dismiss } = useChangeStatus(change.list.queryKey);
35
+ return (
36
+ <Card labelledBy="personal-tokens" title="Personal tokens" description={description}>
37
+ {'error' in tokens ? (
38
+ <div className="card-body">
39
+ <ErrorLine error={tokens.error} />
40
+ </div>
41
+ ) : tokens.length === 0 ? (
42
+ <EmptyState title="No personal tokens" actions={emptyActions}>
43
+ {empty}
44
+ </EmptyState>
45
+ ) : (
46
+ <div className="dt-wrap">
47
+ <table className="dt stacks stacks-inline">
48
+ <thead>
49
+ <tr>
50
+ <th>Token</th>
51
+ <th>Reaches</th>
52
+ <th className="col-shrink">Last used</th>
53
+ <th className="col-shrink">Expires</th>
54
+ <th className="col-actions">
55
+ <span className="visually-hidden">Actions</span>
56
+ </th>
57
+ </tr>
58
+ </thead>
59
+ <tbody>
60
+ {tokens.map((token) => {
61
+ const state = status(token.id);
62
+ return (
63
+ <Fragment key={token.id}>
64
+ <tr className={rowClass(state)}>
65
+ <td>
66
+ <span className="cell-account">
67
+ <Key size={15} />
68
+ <span className="cell-stack">
69
+ <span>{token.label}</span>
70
+ <small>
71
+ <span className="mono">{token.hint}</span>
72
+ {' · made '}
73
+ <Timestamp iso={token.createdAt} display="relative" />
74
+ </small>
75
+ </span>
76
+ </span>
77
+ </td>
78
+ <td data-label="Reaches">{credentialScopeInWords(token.scope ?? {})}</td>
79
+ <td className="nowrap cell-muted" data-label="Last used">
80
+ {token.lastUsedAt === null ? (
81
+ 'Never'
82
+ ) : (
83
+ <span className="cell-stack">
84
+ <Timestamp iso={token.lastUsedAt} display="relative" />
85
+ {token.lastUsedIp !== null && <small className="mono">{token.lastUsedIp}</small>}
86
+ </span>
87
+ )}
88
+ </td>
89
+ <td className="nowrap cell-muted" data-label="Expires">
90
+ <Timestamp iso={token.expiresAt} display="relative" />
91
+ </td>
92
+ <td className="col-actions">
93
+ {state.state === 'pending' ? (
94
+ <RowPending status={state} />
95
+ ) : (
96
+ <ConfirmButton
97
+ trigger={
98
+ <button className="act">
99
+ <X size={13} />
100
+ Revoke
101
+ </button>
102
+ }
103
+ title={`Revoke “${token.label}”?`}
104
+ body={
105
+ <>
106
+ <span className="mono">{token.hint}</span>, last used{' '}
107
+ {token.lastUsedAt === null ? 'never' : <Timestamp iso={token.lastUsedAt} display="relative" />}.
108
+ Whatever uses it is refused at once.
109
+ </>
110
+ }
111
+ confirmLabel="Revoke token"
112
+ onConfirm={() => revoke(token)}
113
+ />
114
+ )}
115
+ </td>
116
+ </tr>
117
+ <RowFailure
118
+ status={state}
119
+ columns={5}
120
+ onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
121
+ />
122
+ </Fragment>
123
+ );
124
+ })}
125
+ </tbody>
126
+ </table>
127
+ </div>
128
+ )}
129
+ </Card>
130
+ );
131
+ }
@@ -5,7 +5,7 @@ import { INSTANCE_ROLES, ROLE_NAMES, ROLES, scopeInWords, unscoped, type Role }
5
5
  import { useShell } from '../lib/use-shell';
6
6
  import { toast } from 'sonner';
7
7
  import { memberRef, useCoffre } from '../lib/coffre';
8
- import { directoryList } from '../lib/changes';
8
+ import { directoryList, revokeMemberToken } from '../lib/changes';
9
9
  import { affects, hasAppsTab, keys, listsAccess, managedProjects, queries, signInWays } from '../lib/queries';
10
10
  import { useChangeStatus } from '../lib/use-change';
11
11
  import { useMounted } from '../lib/mounted';
@@ -25,7 +25,7 @@ import {
25
25
  type AccessChange,
26
26
  type AccessPlan,
27
27
  } from '../lib/access-plan';
28
- import type { MemberAccess } from '@coffre/client';
28
+ import type { MemberAccess, TokenRow } from '@coffre/client';
29
29
  import type { DirectoryPrincipal, ProjectSummary } from '../shared/models';
30
30
  import { ClosedDoor, PageHeader } from './page';
31
31
  import { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';
@@ -33,6 +33,7 @@ import { GrantRowView, GrantsTable } from './grants';
33
33
  import { ExpiryField } from './expiry-field';
34
34
  import { InstanceRole, KIND, PrincipalActions } from './directory';
35
35
  import { PrincipalReportCards, RemovedNotice } from './offboarding';
36
+ import { PersonalTokensCard } from './personal-tokens';
36
37
  import { PrincipalAvatar } from './principal';
37
38
  import { Tile } from './tile';
38
39
  import { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';
@@ -270,9 +271,7 @@ export function PrincipalAccess({ principalType, principalId }: { principalType:
270
271
  <UnreadAccess member={memberRef(principalType, principalId)} error={error} />
271
272
  ) : rows.length === 0 ? (
272
273
  <EmptyState title="No project access yet">
273
- {editable.length > 0
274
- ? `Edit access gives this ${kind} access to several projects at once.`
275
- : `None of the projects where you manage access has a grant for this ${kind}.`}
274
+ {editable.length > 0 ? undefined : `None of the projects where you manage access has a grant for this ${kind}.`}
276
275
  </EmptyState>
277
276
  ) : (
278
277
  <GrantsTable
@@ -298,7 +297,7 @@ export function PrincipalAccess({ principalType, principalId }: { principalType:
298
297
  to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}
299
298
  params={{ project: project.slug }}
300
299
  >
301
- {project.name}
300
+ {project.slug}
302
301
  </Link>
303
302
  {project.archivedAt !== null && <span className="tag tag-red">Archived</span>}
304
303
  </span>
@@ -315,20 +314,33 @@ export function PrincipalAccess({ principalType, principalId }: { principalType:
315
314
  </div>
316
315
  )}
317
316
 
318
- <p className="hint section-foot">
319
- {held?.managed === true && principalType === 'service'
320
- ? 'Only projects where you may give it access are listed: what you hold there, where the instance lets you.'
321
- : 'Only projects where you manage access are listed.'}
322
- </p>
317
+ {!(held?.managed === true && principalType === 'service') && (
318
+ <p className="hint section-foot">Only projects where you manage access are listed.</p>
319
+ )}
323
320
 
324
321
  </>
325
322
  )}
326
323
 
327
324
  {found !== null && <PrincipalReportCards report={found} />}
325
+ {/* A report from an instance before 0.7, mid-deploy or rolled back, lists none. */}
326
+ {found !== null && !removed && (found.personalTokens ?? []).length > 0 && (
327
+ <MemberPersonalTokens member={memberRef(principalType, principalId)} tokens={found.personalTokens} />
328
+ )}
328
329
  </>
329
330
  );
330
331
  }
331
332
 
333
+ /** A person's personal tokens, for whoever runs the instance, who reads their report and may revoke any of them. */
334
+ function MemberPersonalTokens({ member, tokens }: { member: string; tokens: TokenRow[] }) {
335
+ return (
336
+ <PersonalTokensCard
337
+ tokens={tokens}
338
+ change={revokeMemberToken(useCoffre(), member)}
339
+ description="Tokens they made, each acting as them within what it reaches. Removing them from coffre revokes every one."
340
+ />
341
+ );
342
+ }
343
+
332
344
  /** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */
333
345
  function InstanceRoleNote({ access }: { access: MemberAccess }) {
334
346
  if (access.instanceRole === 'member') return null;
@@ -395,7 +407,8 @@ function EditAccess({
395
407
  const rows = access.map(({ project, grants }) => {
396
408
  const environments = project.environments
397
409
  .filter(
398
- (environment) => environment.details !== null && environment.details.archivedAt === null,
410
+ // Your personal config takes no grant: it is no place to give access to.
411
+ (environment) => environment.details !== null && environment.details.archivedAt === null && !environment.personal,
399
412
  )
400
413
  .map((environment) => environment.slug);
401
414
  const held = planFromGrants(grants, environments);
@@ -473,7 +486,7 @@ function EditAccess({
473
486
  <label className="plan-project" htmlFor={id}>
474
487
  <Tile name={project.slug} />
475
488
  <span className="plan-project-text">
476
- <span className="plan-project-name">{project.name}</span>
489
+ <span className="plan-project-name">{project.slug}</span>
477
490
  {held.level === 'custom' && (
478
491
  <span className="plan-project-held">
479
492
  Holds {grants.map((grant) => projectAccessLabel(grant)).join(', ')}
@@ -502,14 +515,14 @@ function EditAccess({
502
515
  plan.level === 'viewer' ||
503
516
  plan.level === 'developer') && (
504
517
  <ExpiryField
505
- label={`${project.name} expires`}
518
+ label={`${project.slug} expires`}
506
519
  expiresAt={plan.expiresAt}
507
520
  onChange={(expiresAt) => edit({ ...plan, expiresAt })}
508
521
  />
509
522
  )}
510
523
 
511
524
  {plan.level === 'env' && (
512
- <ul className="plan-envs" aria-label={`Environments of ${project.name}`}>
525
+ <ul className="plan-envs" aria-label={`Environments of ${project.slug}`}>
513
526
  {environments.map((slug) => {
514
527
  const current = environmentAccess(plan, slug);
515
528
  return (
@@ -540,7 +553,7 @@ function EditAccess({
540
553
  </select>
541
554
  {current !== null && (
542
555
  <ExpiryField
543
- label={`${slug} of ${project.name} expires`}
556
+ label={`${slug} of ${project.slug} expires`}
544
557
  expiresAt={current.expiresAt}
545
558
  onChange={(expiresAt) =>
546
559
  edit(withEnvironment(plan, slug, { ...current, expiresAt }))
@@ -554,7 +567,7 @@ function EditAccess({
554
567
  )}
555
568
 
556
569
  {changes.length > 0 && (
557
- <ul className="plan-changes" aria-label={`Changes to ${project.name}`}>
570
+ <ul className="plan-changes" aria-label={`Changes to ${project.slug}`}>
558
571
  {changes.map((change) => (
559
572
  <li
560
573
  key={