@coffre/ui 0.8.2 → 0.10.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 (92) hide show
  1. package/dist/chunks/{audit-sentence-C_wMpAqr.js → audit-sentence-Bjhg00cn.js} +73 -6
  2. package/dist/chunks/audit-sentence-Bjhg00cn.js.map +1 -0
  3. package/dist/chunks/{connected-apps-Bn5rEoV2.js → connected-apps-CZI7xxUq.js} +2 -2
  4. package/dist/chunks/{connected-apps-Bn5rEoV2.js.map → connected-apps-CZI7xxUq.js.map} +1 -1
  5. package/dist/chunks/{delete-place-CQCDHkne.js → delete-place-D3UQGl3b.js} +3 -3
  6. package/dist/chunks/{delete-place-CQCDHkne.js.map → delete-place-D3UQGl3b.js.map} +1 -1
  7. package/dist/chunks/{directory-BQNOdze_.js → directory-CyHmxYP-.js} +9 -7
  8. package/dist/chunks/directory-CyHmxYP-.js.map +1 -0
  9. package/dist/chunks/{grants-CJIBrkod.js → grants-CEIdNqJU.js} +4 -4
  10. package/dist/chunks/{grants-CJIBrkod.js.map → grants-CEIdNqJU.js.map} +1 -1
  11. package/dist/chunks/{offboarding-CrgwaetA.js → offboarding-CvGgTmHi.js} +2 -2
  12. package/dist/chunks/{offboarding-CrgwaetA.js.map → offboarding-CvGgTmHi.js.map} +1 -1
  13. package/dist/chunks/{personal-tokens-B8rkT-DI.js → personal-tokens-BX97oX4a.js} +2 -2
  14. package/dist/chunks/{personal-tokens-B8rkT-DI.js.map → personal-tokens-BX97oX4a.js.map} +1 -1
  15. package/dist/chunks/{principal-page-Cv5PheS9.js → principal-page-Bp2O8kIW.js} +92 -76
  16. package/dist/chunks/principal-page-Bp2O8kIW.js.map +1 -0
  17. package/dist/chunks/{project-page-BI--vjt3.js → project-page-CUXV4FDR.js} +2 -2
  18. package/dist/chunks/{project-page-BI--vjt3.js.map → project-page-CUXV4FDR.js.map} +1 -1
  19. package/dist/chunks/protected-YYW3U-Sq.js +22 -0
  20. package/dist/chunks/protected-YYW3U-Sq.js.map +1 -0
  21. package/dist/chunks/{queries-epz4MIuW.js → queries-DEOPOpsT.js} +27 -3
  22. package/dist/chunks/queries-DEOPOpsT.js.map +1 -0
  23. package/dist/chunks/{references-DImfw0cz.js → references-DsXkt064.js} +3 -3
  24. package/dist/chunks/{references-DImfw0cz.js.map → references-DsXkt064.js.map} +1 -1
  25. package/dist/chunks/{role-field-C1KhNaIR.js → role-field-CCUeZd1a.js} +8 -5
  26. package/dist/chunks/role-field-CCUeZd1a.js.map +1 -0
  27. package/dist/chunks/{use-action-BB-RcHo1.js → use-action-COW-XFw8.js} +2 -2
  28. package/dist/chunks/{use-action-BB-RcHo1.js.map → use-action-COW-XFw8.js.map} +1 -1
  29. package/dist/chunks/{use-change-CQyDpCqw.js → use-change-hfqE7baE.js} +231 -66
  30. package/dist/chunks/use-change-hfqE7baE.js.map +1 -0
  31. package/dist/chunks/use-roles-C_Tj5wBH.js +224 -0
  32. package/dist/chunks/use-roles-C_Tj5wBH.js.map +1 -0
  33. package/dist/chunks/{use-shell-C_NmvCt_.js → use-shell-DBLG80kk.js} +2 -2
  34. package/dist/chunks/{use-shell-C_NmvCt_.js.map → use-shell-DBLG80kk.js.map} +1 -1
  35. package/dist/index.d.ts +9 -3
  36. package/dist/index.js +25 -11
  37. package/dist/index.js.map +1 -1
  38. package/dist/pages/account.js +6 -6
  39. package/dist/pages/audit.js +2 -2
  40. package/dist/pages/environment.js +306 -96
  41. package/dist/pages/environment.js.map +1 -1
  42. package/dist/pages/login.js +1 -1
  43. package/dist/pages/project-access.js +78 -45
  44. package/dist/pages/project-access.js.map +1 -1
  45. package/dist/pages/project-environments.js +77 -28
  46. package/dist/pages/project-environments.js.map +1 -1
  47. package/dist/pages/project-settings.js +6 -6
  48. package/dist/pages/project.js +1 -1
  49. package/dist/pages/projects.js +23 -11
  50. package/dist/pages/projects.js.map +1 -1
  51. package/dist/pages/service-account.js +19 -12
  52. package/dist/pages/service-account.js.map +1 -1
  53. package/dist/pages/service-accounts.js +4 -4
  54. package/dist/pages/settings.js +580 -8
  55. package/dist/pages/settings.js.map +1 -1
  56. package/dist/pages/unregistered.js +1 -1
  57. package/dist/pages/user.js +5 -5
  58. package/dist/pages/users.js +4 -4
  59. package/package.json +3 -3
  60. package/src/components/directory.tsx +5 -2
  61. package/src/components/grants.tsx +1 -1
  62. package/src/components/principal-page.tsx +38 -23
  63. package/src/components/protected.tsx +17 -0
  64. package/src/components/role-editor.tsx +582 -0
  65. package/src/components/role-field.tsx +7 -3
  66. package/src/components/scope-picker.tsx +19 -9
  67. package/src/components/shell.tsx +7 -1
  68. package/src/lib/access-plan.ts +35 -36
  69. package/src/lib/audit-sentences.ts +75 -6
  70. package/src/lib/changes.ts +48 -6
  71. package/src/lib/project-access.ts +4 -78
  72. package/src/lib/queries.ts +16 -0
  73. package/src/lib/roles.ts +201 -0
  74. package/src/lib/row-reads.ts +12 -0
  75. package/src/lib/secret-edit-batch.ts +162 -26
  76. package/src/lib/sensitivity.ts +50 -0
  77. package/src/lib/service-setup.ts +20 -8
  78. package/src/lib/use-roles.ts +17 -0
  79. package/src/pages/environment.tsx +295 -61
  80. package/src/pages/project-access.tsx +49 -19
  81. package/src/pages/project-environments.tsx +62 -3
  82. package/src/pages/projects.tsx +3 -1
  83. package/src/pages/settings.tsx +2 -0
  84. package/src/parity.ts +41 -4
  85. package/src/shared/models.ts +2 -9
  86. package/src/styles/globals.css +329 -4
  87. package/dist/chunks/audit-sentence-C_wMpAqr.js.map +0 -1
  88. package/dist/chunks/directory-BQNOdze_.js.map +0 -1
  89. package/dist/chunks/principal-page-Cv5PheS9.js.map +0 -1
  90. package/dist/chunks/queries-epz4MIuW.js.map +0 -1
  91. package/dist/chunks/role-field-C1KhNaIR.js.map +0 -1
  92. package/dist/chunks/use-change-CQyDpCqw.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { ageInDays, byFolder, CoffreError, foldersOf, olderThan, planImport, shownMember, type CoffreClient, type ListedReference } from '@coffre/client';
2
2
  import { parseDotenv } from '@coffre/core/dotenv';
3
3
  import type { Generation } from '@coffre/core/recipe';
4
- import { useEffect, useReducer, useRef, useState, type ReactNode } from 'react';
4
+ import { useEffect, useId, useReducer, useRef, useState, type ReactNode } from 'react';
5
5
  import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
6
6
  import { Link, useNavigate } from '@tanstack/react-router';
7
7
  import { useShell } from '../lib/use-shell';
@@ -20,19 +20,23 @@ import type {
20
20
  Permission,
21
21
  SecretKey,
22
22
  SecretVersion,
23
+ Sensitivity,
23
24
  } from '../shared/models';
24
25
  import { canRevealSecrets } from '../lib/capabilities';
26
+ import { LEVELS, levelsIn, markable, SENSITIVITIES, stricter, waitsForValue } from '../lib/sensitivity';
25
27
  import {
26
28
  companionsOf,
27
29
  hasSecretEditConflict,
30
+ madeSensitive,
28
31
  secretChangeFor,
32
+ valueEdit,
29
33
  type Companion,
30
34
  type SecretChange,
31
35
  type SecretDraft,
32
36
  } from '../lib/secret-edit-batch';
33
37
  import { createCopier } from '../lib/copy-attempts';
34
38
  import { revealIsCurrent, type Reveal } from '../lib/reveal';
35
- import { noReads, revealToggleDisabled, rowReads } from '../lib/row-reads';
39
+ import { noReads, revealToggleDisabled, rowReads, valueToEdit } from '../lib/row-reads';
36
40
  import { sortKeys, type Sort } from '../lib/secret-order';
37
41
  import { inDialog } from '../lib/shortcuts';
38
42
  import { folderProblem, secretKeyProblem } from '../lib/validation';
@@ -51,6 +55,7 @@ import {
51
55
  Tip,
52
56
  } from '../components/ui';
53
57
  import { Card, ClosedDoor, PageHeader } from '../components/page';
58
+ import { ProtectedTag } from '../components/protected';
54
59
  import { SecretReadOnly } from '../components/affordances';
55
60
  import { GenerateValue, type GeneratedUse } from '../components/generate-value';
56
61
  import { RecipeMark, RegenerateSecret } from '../components/regenerate';
@@ -149,6 +154,7 @@ export function EnvironmentPage() {
149
154
  keys={result.keys}
150
155
  parents={result.parents ?? []}
151
156
  personal={result.personal != null}
157
+ guarded={result.protected}
152
158
  rotateAfterDays={result.rotateAfterDays}
153
159
  />
154
160
  );
@@ -163,6 +169,7 @@ function EnvironmentLedger({
163
169
  keys,
164
170
  parents,
165
171
  personal,
172
+ guarded,
166
173
  rotateAfterDays,
167
174
  }: {
168
175
  project: string;
@@ -173,6 +180,8 @@ function EnvironmentLedger({
173
180
  parents: string[];
174
181
  /** Your personal config, `dev@me`: its values yours alone. */
175
182
  personal: boolean;
183
+ /** Protected (docs/design/roles.md): you hold your role's protected column here, a personal config as its parent. */
184
+ guarded: boolean;
176
185
  /** Days a value may go unchanged before it is flagged for rotation; null for no flag. */
177
186
  rotateAfterDays: number | null;
178
187
  }) {
@@ -210,6 +219,14 @@ function EnvironmentLedger({
210
219
  // pending change is in edit mode whether or not it is listed here.
211
220
  const [editing, setEditing] = useState<ReadonlySet<string>>(() => new Set());
212
221
  const [saveError, setSaveError] = useState<string | null>(null);
222
+ // A save that makes keys sensitive, waiting for its confirmation: nobody sees them again, which the row's menu asks too.
223
+ const [hiding, setHiding] = useState<{ keys: string[]; go: () => void } | null>(null);
224
+ // Every key the save writes counts, a key pair's public key included.
225
+ function confirmingSensitive(drafts: readonly SecretDraft[], changes: Record<string, SecretChange>, go: () => void) {
226
+ const keys = madeSensitive(active, drafts, changes);
227
+ if (keys.length === 0) go();
228
+ else setHiding({ keys, go });
229
+ }
213
230
  const [query, setQuery] = useState(Route.useSearch().filter ?? '');
214
231
  const [sort, setSort] = useState<Sort>({ by: 'key', descending: false });
215
232
  // A column's first click sorts it ascending: names A to Z, the oldest values first.
@@ -220,6 +237,8 @@ function EnvironmentLedger({
220
237
  const canWrite = permissions.includes('secret.write');
221
238
  const canArchive = permissions.includes('secret.archive');
222
239
  const canReveal = canRevealSecrets(permissions);
240
+ // What a Contributor does without reading: lists the keys, their history, and keeps a personal config.
241
+ const canList = canReveal || permissions.includes('secret.use');
223
242
 
224
243
  // Listed by folder: those in none first, then each folder by name.
225
244
  const active = byFolder(keys.filter((entry) => !entry.archived)).flatMap(([, entries]) => entries);
@@ -279,8 +298,10 @@ function EnvironmentLedger({
279
298
  ];
280
299
  const unnamed = pendingNames.some((name) => name === '');
281
300
  const invalid = pendingNames.some((name) => name !== '' && secretKeyProblem(name) !== null);
301
+ // A key made more visible, or marked where it holds no value of its own, waits for its value typed.
302
+ const waiting = changedEntries.find((entry) => waitsForValue(entry, secretChangeFor(changes, entry.key)));
282
303
  const pendingCount = drafts.length + changedEntries.length;
283
- const ready = pendingCount > 0 && !unnamed && !invalid && !hasConflict;
304
+ const ready = pendingCount > 0 && !unnamed && !invalid && !hasConflict && waiting === undefined;
284
305
 
285
306
  function patchChange(entry: SecretKey, patch: Partial<SecretChange>) {
286
307
  setChanges((current) => {
@@ -292,7 +313,7 @@ function EnvironmentLedger({
292
313
  }),
293
314
  ...patch,
294
315
  };
295
- const dirty = next.key !== entry.key || next.value !== null || next.archived;
316
+ const dirty = next.key !== entry.key || next.value !== null || next.sensitivity !== undefined || next.archived;
296
317
  if (dirty) return { ...current, [entry.key]: next };
297
318
  const { [entry.key]: _, ...rest } = current;
298
319
  return rest;
@@ -305,14 +326,18 @@ function EnvironmentLedger({
305
326
  */
306
327
  function saveRow(key: string) {
307
328
  const change = secretChangeFor(changes, key);
308
- dropChange(key);
309
- if (change === undefined) return;
310
- sendAlone({ active, drafts: [], changes: { [key]: change } });
329
+ if (change === undefined) return dropChange(key);
330
+ confirmingSensitive([], { [key]: change }, () => {
331
+ dropChange(key);
332
+ sendAlone({ active, drafts: [], changes: { [key]: change } });
333
+ });
311
334
  }
312
335
 
313
336
  function saveDraft(draft: SecretDraft) {
314
- setDrafts((rows) => rows.filter((row) => row.id !== draft.id));
315
- sendAlone({ active, drafts: [draft], changes: {} });
337
+ confirmingSensitive([draft], {}, () => {
338
+ setDrafts((rows) => rows.filter((row) => row.id !== draft.id));
339
+ sendAlone({ active, drafts: [draft], changes: {} });
340
+ });
316
341
  }
317
342
 
318
343
  /** Whether one row's change could go alone: named, well named, and clashing with nothing. */
@@ -325,7 +350,8 @@ function EnvironmentLedger({
325
350
  return (
326
351
  (drafts.length > 0 || Object.keys(changes).length > 0) &&
327
352
  names.every((name) => name !== '' && secretKeyProblem(name) === null) &&
328
- !hasSecretEditConflict(active, drafts, changes)
353
+ !hasSecretEditConflict(active, drafts, changes) &&
354
+ !active.some((entry) => waitsForValue(entry, secretChangeFor(changes, entry.key)))
329
355
  );
330
356
  }
331
357
 
@@ -357,7 +383,7 @@ function EnvironmentLedger({
357
383
 
358
384
  function addDraft(key = '') {
359
385
  // New rows go last, by the button that made them, in the order they were added.
360
- setDrafts((rows) => [...rows, { id: nextDraftId.current++, key, value: '' }]);
386
+ setDrafts((rows) => [...rows, { id: nextDraftId.current++, key, value: '', sensitivity: 'secret' }]);
361
387
  }
362
388
 
363
389
  function discardAll() {
@@ -386,6 +412,10 @@ function EnvironmentLedger({
386
412
  */
387
413
  function saveChanges() {
388
414
  if (!ready) return;
415
+ confirmingSensitive(drafts, changes, sendChanges);
416
+ }
417
+
418
+ function sendChanges() {
389
419
  const batch = { active, drafts, changes };
390
420
  setDrafts([]);
391
421
  setChanges({});
@@ -472,13 +502,15 @@ function EnvironmentLedger({
472
502
  const change = secretChangeFor(changes, entry.key)!;
473
503
  if (change.archived) return { key: entry.key, what: 'archived' };
474
504
  const renamed = change.key.trim() !== entry.key;
475
- if (renamed && change.value !== null) {
476
- return { key: entry.key, what: withCompanion(`→ ${change.key.trim()}, new value`, change.companion) };
477
- }
478
- if (renamed) return { key: entry.key, what: `→ ${change.key.trim()}` };
505
+ // Who sees it, where the edit changes that: beside a new value, or alone, a mark.
506
+ const level = change.sensitivity === undefined || change.sensitivity === entry.sensitivity ? null : change.sensitivity;
507
+ const written = change.value === null
508
+ ? (level === null ? null : `made ${level}`)
509
+ : withCompanion(level === null ? 'new value' : `new value, ${level}`, change.companion);
510
+ if (renamed) return { key: entry.key, what: written === null ? `→ ${change.key.trim()}` : `→ ${change.key.trim()}, ${written}` };
479
511
  // In a fork, a value written over the parent's overrides it.
480
512
  if (entry.parent !== null && entry.parent.state !== 'overridden') return { key: entry.key, what: withCompanion(`overrides ${entry.parent.from}`, change.companion) };
481
- return { key: entry.key, what: withCompanion('new value', change.companion) };
513
+ return { key: entry.key, what: written ?? 'new value' };
482
514
  }),
483
515
  ];
484
516
 
@@ -490,7 +522,9 @@ function EnvironmentLedger({
490
522
  ? 'Two pending edits would end up with the same name. Secret names are unique in an environment.'
491
523
  : invalid
492
524
  ? 'Names are letters, digits and underscores, and cannot start with a digit.'
493
- : null;
525
+ : waiting !== undefined
526
+ ? `${waiting.key} waits for its value: type it again.`
527
+ : null;
494
528
 
495
529
  // Filtering narrows what is listed, never what is saved: a pending edit on
496
530
  // a row the filter hides still counts, and still shows in the bar under the table.
@@ -506,9 +540,10 @@ function EnvironmentLedger({
506
540
  <PageHeader
507
541
  tile={project}
508
542
  title={environment}
543
+ aside={guarded && <ProtectedTag />}
509
544
  actions={personal ? (
510
545
  <DeletePersonal project={project} environment={environment} of={parents[0]!} />
511
- ) : principal?.type === 'user' && canReveal && (
546
+ ) : principal?.type === 'user' && canList && (
512
547
  <Link className="btn btn-sm" to="/projects/$project/$environment" params={{ project, environment: `${environment}@me` }}>
513
548
  <Key size={14} />
514
549
  My own {environment}
@@ -520,7 +555,7 @@ function EnvironmentLedger({
520
555
  <Link className="mono" to="/projects/$project/$environment" params={{ project, environment: parents[0]! }}>
521
556
  {project}/{parents[0]}
522
557
  </Link>
523
- : what you set here, only you read, while you read {parents[0]}; the rest is {parents[0]}'s, as it changes.
558
+ : what you set here is yours alone, while you read or use {parents[0]}; the rest is {parents[0]}'s, as it changes.
524
559
  </span>
525
560
  ) : parents.length > 0 && (
526
561
  <span className="inherits">
@@ -650,11 +685,13 @@ function EnvironmentLedger({
650
685
  canWrite={canWrite}
651
686
  canArchive={canArchive}
652
687
  canReveal={canReveal}
688
+ canList={canList}
653
689
  folders={folders}
654
690
  onMove={(folder) => move({ key: entry.key, folder })}
655
691
  lent={lentBy.get(entry.key) ?? []}
656
692
  // A personal config holds values only: no reference.
657
693
  environments={personal ? [] : readable}
694
+ personal={personal}
658
695
  status={state}
659
696
  // Not while its save is on its way.
660
697
  disabled={state.state === 'pending'}
@@ -698,6 +735,7 @@ function EnvironmentLedger({
698
735
  key={draft.id}
699
736
  draft={draft}
700
737
  existingVersion={versionOf(draft.key)}
738
+ personal={personal}
701
739
  disabled={false}
702
740
  onChange={(patch) =>
703
741
  setDrafts((rows) =>
@@ -725,6 +763,20 @@ function EnvironmentLedger({
725
763
  )}
726
764
  </section>
727
765
 
766
+ <ConfirmDialog
767
+ open={hiding !== null}
768
+ onOpenChange={(open) => !open && setHiding(null)}
769
+ title={hiding?.keys.length === 1 ? <>Make <span className="mono">{hiding.keys[0]}</span> sensitive?</> : `Make ${hiding?.keys.length ?? 0} keys sensitive?`}
770
+ body={`${hiding !== null && hiding.keys.length > 1 ? `${hiding.keys.join(', ')}: n` : 'N'}obody, Owners included, will see ${hiding?.keys.length === 1 ? 'this value' : 'these values'} again. Apps use ${hiding?.keys.length === 1 ? 'it' : 'them'} through the proxy; service accounts still read ${hiding?.keys.length === 1 ? 'it' : 'them'}.`}
771
+ confirmLabel="Make sensitive"
772
+ destructive={false}
773
+ onConfirm={() => {
774
+ const go = hiding?.go;
775
+ setHiding(null);
776
+ go?.();
777
+ }}
778
+ />
779
+
728
780
  {canWrite && (
729
781
  <div className="table-actions">
730
782
  <AddButton onAddSecret={() => addDraft()} onAddFolder={() => setAddingFolder(true)} canAddFolder={settled.length > 0} />
@@ -788,7 +840,7 @@ function EnvironmentLedger({
788
840
  environment={environment}
789
841
  entry={entry}
790
842
  canArchive={canArchive}
791
- canReveal={canReveal}
843
+ canList={canList}
792
844
  status={status(entry.key)}
793
845
  onRestore={() => restoreSecretKey(entry.key)}
794
846
  onDismiss={dismiss}
@@ -1000,6 +1052,7 @@ function ValueField({
1000
1052
  autoFocus,
1001
1053
  onEscape,
1002
1054
  generate,
1055
+ plain = false,
1003
1056
  }: {
1004
1057
  label: string;
1005
1058
  value: string;
@@ -1018,6 +1071,8 @@ function ValueField({
1018
1071
  companion: Companion | undefined;
1019
1072
  onUse: (use: GeneratedUse) => void;
1020
1073
  };
1074
+ /** A plain value, no secret: shown as it is typed. */
1075
+ plain?: boolean;
1021
1076
  }) {
1022
1077
  const [shown, setShown] = useState(false);
1023
1078
  const [generating, setGenerating] = useState(false);
@@ -1037,7 +1092,7 @@ function ValueField({
1037
1092
  };
1038
1093
  const field = {
1039
1094
  className: 'input input-mono',
1040
- masked: !shown,
1095
+ masked: !shown && !plain,
1041
1096
  'aria-label': label,
1042
1097
  placeholder,
1043
1098
  value,
@@ -1099,15 +1154,18 @@ function ValueField({
1099
1154
  <Generate size={14} />
1100
1155
  </button>
1101
1156
  </Tip>
1102
- <button
1103
- type="button"
1104
- className="btn btn-quiet btn-sm btn-icon input-addon"
1105
- aria-label={shown ? 'Mask the value' : 'Show the value'}
1106
- aria-pressed={shown}
1107
- onClick={() => setShown((current) => !current)}
1108
- >
1109
- {shown ? <EyeOff size={14} /> : <Eye size={14} />}
1110
- </button>
1157
+ {/* A plain value shows as it is: nothing to mask. */}
1158
+ {!plain && (
1159
+ <button
1160
+ type="button"
1161
+ className="btn btn-quiet btn-sm btn-icon input-addon"
1162
+ aria-label={shown ? 'Mask the value' : 'Show the value'}
1163
+ aria-pressed={shown}
1164
+ onClick={() => setShown((current) => !current)}
1165
+ >
1166
+ {shown ? <EyeOff size={14} /> : <Eye size={14} />}
1167
+ </button>
1168
+ )}
1111
1169
  <GenerateValue
1112
1170
  open={generating}
1113
1171
  onOpenChange={setGenerating}
@@ -1166,6 +1224,7 @@ function SecretRow({
1166
1224
  canWrite,
1167
1225
  canArchive,
1168
1226
  canReveal,
1227
+ canList,
1169
1228
  folders,
1170
1229
  onMove,
1171
1230
  lent,
@@ -1182,6 +1241,7 @@ function SecretRow({
1182
1241
  versionOf,
1183
1242
  saveReady,
1184
1243
  onMarkArchive,
1244
+ personal,
1185
1245
  }: {
1186
1246
  number: number;
1187
1247
  project: string;
@@ -1199,6 +1259,8 @@ function SecretRow({
1199
1259
  canWrite: boolean;
1200
1260
  canArchive: boolean;
1201
1261
  canReveal: boolean;
1262
+ /** Whether the caller lists the environment: reads it, or uses it as a Contributor does. */
1263
+ canList: boolean;
1202
1264
  /** The folders in use in this environment, offered when moving it. */
1203
1265
  folders: readonly string[];
1204
1266
  onMove: (folder: string | null) => void;
@@ -1223,6 +1285,8 @@ function SecretRow({
1223
1285
  versionOf: (key: string) => number | null;
1224
1286
  saveReady: boolean;
1225
1287
  onMarkArchive: () => void;
1288
+ /** In your personal config, `dev@me`, whose overrides are your own values. */
1289
+ personal: boolean;
1226
1290
  }) {
1227
1291
  const [reads, dispatch] = useReducer(rowReads, noReads);
1228
1292
  const { reveal, revealing, error, copyError } = reads;
@@ -1237,8 +1301,10 @@ function SecretRow({
1237
1301
  // Archiving a key others read through references waits until they are broken (D41).
1238
1302
  const [archiveBlocked, setArchiveBlocked] = useState(false);
1239
1303
  const blockers = archiveBlockers(`${project}/${environment}/${entry.key}`, lent);
1240
- // Making or breaking a reference: its refusal shows under the row, as a reveal's does.
1304
+ // Making or breaking a reference, or marking it: its refusal shows under the row, as a reveal's does.
1241
1305
  const { run: act, error: actError } = useAction();
1306
+ // Made sensitive from the menu, once confirmed: nobody sees its value after.
1307
+ const [hiding, setHiding] = useState(false);
1242
1308
  const { reference, parent } = entry;
1243
1309
  // In a fork (docs/design/forking.md): a key it inherits has no row of its
1244
1310
  // own, one it overrides has, and one it removed is not served.
@@ -1246,14 +1312,25 @@ function SecretRow({
1246
1312
  const removed = parent?.state === 'removed';
1247
1313
  const overridden = parent?.state === 'overridden';
1248
1314
  const own = !inherited && !removed;
1249
- // Inherited from a parent you do not read: its name is yours to know, its value is not.
1250
- const parentHidden = inherited && entry.version === null && reference === null;
1251
- const canRead = canReveal && !removed && !parentHidden;
1315
+ // A sensitive value is shown to nobody, its readers included: no Reveal, no Copy, and an edit starts empty.
1316
+ const sensitive = entry.sensitivity === 'sensitive';
1317
+ // Read where it is held: inherited, on its parent, which a Contributor's dev@me tells of and does not read.
1318
+ const canRead = entry.readable;
1252
1319
  // What a reveal shows: its own version, or, as a reference, its source's.
1253
1320
  const readVersion = reference === null ? entry.version : reference.version;
1254
1321
  // And where that version is held: a reset, an override or a new reference changes it under the same number.
1255
1322
  const readFrom = `${inherited ? parent!.from : '.'}:${reference?.source ?? ''}`;
1256
1323
  const holderPath = `${project}/${environment}/${entry.key}`;
1324
+ // A plain value is no secret: listed as it is, shown inline and copied with no read.
1325
+ const rowPlain = entry.value !== null;
1326
+ // Who sees its value now, and who will once the edit is saved. In a personal config, an override of a key it inherits
1327
+ // starts at that key's level, as the API writes one that says nothing (decision 27).
1328
+ const rowLevel = entry.sensitivity;
1329
+ const level = change.sensitivity ?? rowLevel ?? 'secret';
1330
+ // More visible than it is: the value is typed again, never shown and kept. Not an override in your personal config,
1331
+ // a value of your own, which nobody else sees: what it inherits stays as it is.
1332
+ const loosening = !(personal && inherited) && rowLevel !== null && stricter(rowLevel, level);
1333
+ const from = () => ({ start: editBase?.value ?? '', level: rowLevel });
1257
1334
  // The current value, loaded on request as the starting point for an edit.
1258
1335
  // It is not a change until it is edited: saving it untouched would append a
1259
1336
  // version identical to the one it came from.
@@ -1298,6 +1375,7 @@ function SecretRow({
1298
1375
  }
1299
1376
 
1300
1377
  async function fetchValue(): Promise<string> {
1378
+ if (entry.value !== null) return entry.value;
1301
1379
  const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
1302
1380
  return values[entry.key];
1303
1381
  }
@@ -1342,26 +1420,47 @@ function SecretRow({
1342
1420
  }
1343
1421
 
1344
1422
  // An edit starts from the current value, read the way Reveal reads it, so
1345
- // the audit log shows who opened it. One that cannot be read starts empty.
1423
+ // the audit log shows who opened it. One its editor does not read starts
1424
+ // empty: sensitive, a parent's in a Contributor's dev@me, overridden unread,
1425
+ // or one whose read failed, its reason under the row (`valueToEdit`).
1346
1426
  const [opening, setOpening] = useState(false);
1347
1427
  // Rename opens the same editor, its name field focused rather than its value.
1348
1428
  const [focusName, setFocusName] = useState(false);
1349
1429
  async function startEdit({ name = false } = {}) {
1350
1430
  setFocusName(name);
1351
- if (canRead) {
1352
- setOpening(true);
1353
- const value = await readValue({ show: false });
1354
- setOpening(false);
1355
- if (value === null) return;
1356
- setBase({ value, version: readVersion, from: readFrom, at: Date.now() });
1357
- }
1431
+ setOpening(entry.value === null && canRead);
1432
+ const value = await valueToEdit(entry, () => readValue({ show: false }));
1433
+ setOpening(false);
1434
+ if (value !== null) setBase({ value, version: readVersion, from: readFrom, at: Date.now() });
1358
1435
  setReveal(null);
1359
1436
  onEdit();
1360
1437
  }
1361
1438
 
1439
+ // Who sees it, chosen from its menu: stricter at once, its value kept; more
1440
+ // visible in the editor, which asks for the value typed again.
1441
+ function chooseLevel(next: Sensitivity) {
1442
+ if (entry.sensitivity === null || next === entry.sensitivity) return;
1443
+ if (stricter(entry.sensitivity, next)) {
1444
+ setFocusName(false);
1445
+ setReveal(null);
1446
+ onEdit();
1447
+ onPatch({ sensitivity: next });
1448
+ } else if (next === 'sensitive') setHiding(true);
1449
+ else mark(next);
1450
+ }
1451
+
1452
+ function mark(next: Sensitivity) {
1453
+ setReveal(null);
1454
+ act(() => coffre.secrets.set(`${project}/${environment}`, { [entry.key]: { sensitivity: next } }), {
1455
+ affects: affects.secrets({ project, environment }),
1456
+ onSuccess: () => toast.success(`Made ${entry.key} ${next}`),
1457
+ });
1458
+ }
1459
+
1362
1460
  const leaving = change.archived;
1363
1461
  const renamed = change.key !== entry.key;
1364
- const valueChanged = change.value !== null;
1462
+ // A new value, or a level alone, a mark: either makes a new version.
1463
+ const valueChanged = change.value !== null || change.sensitivity !== undefined;
1365
1464
  const keyProblem = editing ? secretKeyProblem(change.key.trim()) : null;
1366
1465
  const state = leaving
1367
1466
  ? ' is-leaving'
@@ -1412,6 +1511,13 @@ function SecretRow({
1412
1511
  <div className="key-cell">
1413
1512
  <span>{breakAfterUnderscores(entry.key)}</span>
1414
1513
  {generated !== null && <RecipeMark generated={generated} />}
1514
+ {rowPlain && <span className="tag" title={levelsIn(personal && own).plain.hint}>Plain</span>}
1515
+ {sensitive && (
1516
+ <span className="tag" title={levelsIn(personal && own).sensitive.hint}>
1517
+ <Lock size={11} aria-hidden />
1518
+ Sensitive
1519
+ </span>
1520
+ )}
1415
1521
  {leaving && <span className="tag tag-red">Will be archived</span>}
1416
1522
  {parent !== null && <Standing project={project} secretKey={entry.key} parent={parent} />}
1417
1523
  {lent.length > 0 && (
@@ -1437,14 +1543,22 @@ function SecretRow({
1437
1543
  <div className="edit-stack">
1438
1544
  <ValueField
1439
1545
  label={`New value for ${entry.key}`}
1440
- value={change.value ?? editBase?.value ?? ''}
1441
- start={editBase?.value}
1442
- placeholder={canReveal ? 'Value' : 'New value; the current one is hidden from you'}
1546
+ // Made more visible, the field opens empty: the value is typed again.
1547
+ value={change.value ?? (loosening ? '' : editBase?.value ?? '')}
1548
+ start={loosening ? undefined : editBase?.value}
1549
+ placeholder={
1550
+ loosening ? 'Its value, typed again'
1551
+ : editBase !== null ? 'Value'
1552
+ : sensitive ? 'Type a new value'
1553
+ : error !== null ? 'New value; the current one could not be read'
1554
+ : canRead ? 'New value' : 'New value; the current one is hidden from you'
1555
+ }
1556
+ plain={level === 'plain'}
1443
1557
  disabled={disabled}
1444
1558
  autoFocus={!focusName}
1445
1559
  // A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
1446
1560
  onChange={(value) =>
1447
- onPatch({ value: value === (editBase?.value ?? '') ? null : value, companion: undefined, recipe: undefined })
1561
+ onPatch({ ...valueEdit(from(), { value, sensitivity: level }), companion: undefined, recipe: undefined })
1448
1562
  }
1449
1563
  onEscape={onUndo}
1450
1564
  generate={{
@@ -1452,9 +1566,26 @@ function SecretRow({
1452
1566
  name: change.key,
1453
1567
  renamable: false,
1454
1568
  companion: change.companion,
1455
- onUse: ({ value, companion, recipe }) => onPatch({ value, companion, recipe }),
1569
+ // A generated value is never plain.
1570
+ onUse: ({ value, companion, recipe }) => onPatch({ value, companion, recipe, sensitivity: level === 'plain' ? 'secret' : level }),
1456
1571
  }}
1457
1572
  />
1573
+ <SensitivityField
1574
+ name={change.key.trim() === '' ? entry.key : change.key.trim()}
1575
+ value={level}
1576
+ levels={levelsIn(personal)}
1577
+ disabled={disabled}
1578
+ // A value made plain is typed by hand: it drops the recipe of one generated.
1579
+ onChange={(next) => onPatch({
1580
+ ...valueEdit(from(), { value: change.value, sensitivity: next }),
1581
+ ...(next === 'plain' ? { companion: undefined, recipe: undefined } : {}),
1582
+ })}
1583
+ />
1584
+ {waitsForValue(entry, change) && (
1585
+ <span className="edit-note">
1586
+ {loosening ? 'Making it visible takes a new value: type it again.' : 'Type its value: only a value of its own here is marked.'}
1587
+ </span>
1588
+ )}
1458
1589
  <CompanionNote companion={change.companion} versionOf={versionOf} />
1459
1590
  {!overridden && parent !== null && (
1460
1591
  <span className="edit-note">Saved here, over {parent.from}'s value</span>
@@ -1465,6 +1596,8 @@ function SecretRow({
1465
1596
  </span>
1466
1597
  )}
1467
1598
  </div>
1599
+ ) : rowPlain && !leaving ? (
1600
+ <span className="revealed-value plain-value">{entry.value === '' ? '(empty)' : entry.value}</span>
1468
1601
  ) : shown !== null && !leaving ? (
1469
1602
  <div
1470
1603
  className="revealed"
@@ -1481,7 +1614,7 @@ function SecretRow({
1481
1614
  ) : reference !== null ? (
1482
1615
  <ReferenceValue reference={reference} />
1483
1616
  ) : (
1484
- <span className="mask" aria-label="Hidden">
1617
+ <span className="mask" aria-label={sensitive ? 'Never shown' : 'Hidden'}>
1485
1618
  ••••••••••••
1486
1619
  </span>
1487
1620
  )}
@@ -1526,7 +1659,7 @@ function SecretRow({
1526
1659
  takes read there too. */}
1527
1660
  <SecretReadOnly canReveal={canRead}>
1528
1661
  <CopyButton variant="act" copier={copier} onCopy={copyValue} label={`Copy ${entry.key}`} />
1529
- <Tip label={shown === null ? 'Reveal' : 'Hide'}>
1662
+ {!rowPlain && <Tip label={shown === null ? 'Reveal' : 'Hide'}>
1530
1663
  <button
1531
1664
  className="act act-icon act-accent"
1532
1665
  onClick={toggleReveal}
@@ -1541,7 +1674,7 @@ function SecretRow({
1541
1674
  <EyeOff size={15} />
1542
1675
  )}
1543
1676
  </button>
1544
- </Tip>
1677
+ </Tip>}
1545
1678
  </SecretReadOnly>
1546
1679
  {canWrite && (
1547
1680
  <Tip label={inherited ? `Override ${parent!.from}'s` : 'Edit'}>
@@ -1589,7 +1722,7 @@ function SecretRow({
1589
1722
  {status.state === 'pending' ? (
1590
1723
  <RowPending status={status} />
1591
1724
  ) : (
1592
- !removed && (canReveal || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
1725
+ !removed && (canList || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
1593
1726
  <Menu.Root>
1594
1727
  <Menu.Trigger
1595
1728
  className="act act-icon act-quiet"
@@ -1599,7 +1732,7 @@ function SecretRow({
1599
1732
  <MoreHorizontal size={16} />
1600
1733
  </Menu.Trigger>
1601
1734
  <MenuPopup align="end">
1602
- <SecretReadOnly canReveal={canReveal && own}>
1735
+ <SecretReadOnly canReveal={canList && own}>
1603
1736
  <Menu.Item className="menu-item" onClick={() => setHistoryOpen((open) => !open)}>
1604
1737
  <History size={14} />
1605
1738
  {historyOpen ? 'Hide history' : 'Version history'}
@@ -1663,6 +1796,26 @@ function SecretRow({
1663
1796
  Break reference…
1664
1797
  </Menu.Item>
1665
1798
  )}
1799
+ {/* Its own value's level: a reference's is its source's, an inherited one's its parent's. */}
1800
+ {canWrite && !editing && !leaving && markable(entry) && (
1801
+ <>
1802
+ <Menu.Separator className="menu-sep" />
1803
+ <Menu.RadioGroup value={entry.sensitivity} onValueChange={(next: Sensitivity) => chooseLevel(next)}>
1804
+ <Menu.GroupLabel className="menu-label">Who sees it</Menu.GroupLabel>
1805
+ {SENSITIVITIES.map((each) => (
1806
+ <Menu.RadioItem key={each} value={each} className="menu-item menu-item-level" closeOnClick>
1807
+ <span className="menu-item-text">
1808
+ {levelsIn(personal)[each].label}
1809
+ <span className="menu-item-hint">{levelsIn(personal)[each].hint}</span>
1810
+ </span>
1811
+ <Menu.RadioItemIndicator className="menu-check">
1812
+ <Check size={14} />
1813
+ </Menu.RadioItemIndicator>
1814
+ </Menu.RadioItem>
1815
+ ))}
1816
+ </Menu.RadioGroup>
1817
+ </>
1818
+ )}
1666
1819
  {/* An override's way out is Reset, which keeps it; archiving there would be the same, by more. */}
1667
1820
  {canArchive && !leaving && own && !overridden && (
1668
1821
  <>
@@ -1732,6 +1885,20 @@ function SecretRow({
1732
1885
  onConfirm={onMarkArchive}
1733
1886
  />
1734
1887
 
1888
+ <ConfirmDialog
1889
+ open={hiding}
1890
+ onOpenChange={setHiding}
1891
+ title={
1892
+ <>
1893
+ Make <span className="mono">{entry.key}</span> sensitive?
1894
+ </>
1895
+ }
1896
+ body="Nobody, Owners included, will see this value again. Apps use it through the proxy; service accounts still read it."
1897
+ confirmLabel="Make sensitive"
1898
+ destructive={false}
1899
+ onConfirm={() => mark('sensitive')}
1900
+ />
1901
+
1735
1902
  <ConfirmDialog
1736
1903
  open={breaking !== null}
1737
1904
  onOpenChange={(open) => !open && setBreaking(null)}
@@ -1770,7 +1937,7 @@ function SecretRow({
1770
1937
  />
1771
1938
  )}
1772
1939
 
1773
- {historyOpen && canReveal && (
1940
+ {historyOpen && canList && (
1774
1941
  <tr className="detail-row">
1775
1942
  <td colSpan={columns}>
1776
1943
  <VersionHistory
@@ -1892,7 +2059,8 @@ function Standing({ project, secretKey, parent }: { project: string; secretKey:
1892
2059
  case 'inherited':
1893
2060
  return <span className="tag tag-outline">from {from}</span>;
1894
2061
  case 'removed':
1895
- return <span className="tag tag-outline">removed · {from} {parent.held ? 'has it' : 'dropped it'}</span>;
2062
+ // Removed here, a dismissal of the parent's key: which it still holds, or has dropped since, the removal then doing nothing.
2063
+ return <span className="tag tag-outline">removed here · {parent.held ? <>not inherited from {from}</> : <>{from} dropped it too</>}</span>;
1896
2064
  case 'overridden':
1897
2065
  return (
1898
2066
  <>
@@ -1989,6 +2157,51 @@ function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays
1989
2157
  );
1990
2158
  }
1991
2159
 
2160
+ /**
2161
+ * Who sees the value being written, loosest first, and beside it what the
2162
+ * level pointed at, or else the one chosen, means. Native radios: the arrow
2163
+ * keys move the choice, and a screen reader hears one group of three.
2164
+ */
2165
+ function SensitivityField({
2166
+ name,
2167
+ value,
2168
+ levels,
2169
+ disabled,
2170
+ onChange,
2171
+ }: {
2172
+ /** The key it is for, naming the group. */
2173
+ name: string;
2174
+ value: Sensitivity;
2175
+ /** Each level as it is named here (`levelsIn`). */
2176
+ levels: Record<Sensitivity, { label: string; hint: string }>;
2177
+ disabled: boolean;
2178
+ onChange: (level: Sensitivity) => void;
2179
+ }) {
2180
+ const id = useId();
2181
+ const [pointed, setPointed] = useState<Sensitivity | null>(null);
2182
+ return (
2183
+ <div className="edit-note sensitivity-field">
2184
+ <div className="segmented segmented-sm" role="radiogroup" aria-label={`Who sees ${name}`} aria-describedby={`${id}-hint`}>
2185
+ {SENSITIVITIES.map((level) => (
2186
+ <label key={level} onPointerEnter={() => setPointed(level)} onPointerLeave={() => setPointed(null)}>
2187
+ <input
2188
+ type="radio"
2189
+ className="visually-hidden"
2190
+ name={id}
2191
+ value={level}
2192
+ checked={value === level}
2193
+ disabled={disabled}
2194
+ onChange={() => onChange(level)}
2195
+ />
2196
+ {levels[level].label}
2197
+ </label>
2198
+ ))}
2199
+ </div>
2200
+ <span id={`${id}-hint`}>{levels[pointed ?? value].hint}</span>
2201
+ </div>
2202
+ );
2203
+ }
2204
+
1992
2205
  /**
1993
2206
  * A secret being typed, sitting in the table where it will end up.
1994
2207
  *
@@ -2005,6 +2218,7 @@ function DraftRow({
2005
2218
  onSave,
2006
2219
  versionOf,
2007
2220
  saveReady,
2221
+ personal,
2008
2222
  }: {
2009
2223
  draft: SecretDraft;
2010
2224
  existingVersion: number | null;
@@ -2016,6 +2230,8 @@ function DraftRow({
2016
2230
  /** The current version of a key in this environment, for a companion's note. */
2017
2231
  versionOf: (key: string) => number | null;
2018
2232
  saveReady: boolean;
2233
+ /** In your personal config, `dev@me`, whose values are your own. */
2234
+ personal: boolean;
2019
2235
  }) {
2020
2236
  const [touched, setTouched] = useState(false);
2021
2237
  const trimmed = draft.key.trim();
@@ -2062,6 +2278,7 @@ function DraftRow({
2062
2278
  <ValueField
2063
2279
  label={`Value for ${trimmed === '' ? 'the new secret' : trimmed}`}
2064
2280
  value={draft.value}
2281
+ plain={draft.sensitivity === 'plain'}
2065
2282
  placeholder="Value"
2066
2283
  disabled={disabled}
2067
2284
  // A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
@@ -2071,9 +2288,19 @@ function DraftRow({
2071
2288
  name: draft.key,
2072
2289
  renamable: true,
2073
2290
  companion: draft.companion,
2074
- onUse: ({ value, name, companion, recipe }) => onChange({ key: name, value, companion, recipe }),
2291
+ // A generated value is never plain.
2292
+ onUse: ({ value, name, companion, recipe }) =>
2293
+ onChange({ key: name, value, companion, recipe, sensitivity: draft.sensitivity === 'plain' ? 'secret' : draft.sensitivity }),
2075
2294
  }}
2076
2295
  />
2296
+ <SensitivityField
2297
+ name={trimmed === '' ? 'the new secret' : trimmed}
2298
+ value={draft.sensitivity}
2299
+ levels={levelsIn(personal)}
2300
+ disabled={disabled}
2301
+ // A value made plain is typed by hand: it drops the recipe of one generated.
2302
+ onChange={(sensitivity) => onChange(sensitivity === 'plain' ? { sensitivity, companion: undefined, recipe: undefined } : { sensitivity })}
2303
+ />
2077
2304
  <CompanionNote companion={draft.companion} versionOf={versionOf} />
2078
2305
  </div>
2079
2306
  </div>
@@ -2126,7 +2353,7 @@ function ArchivedRow({
2126
2353
  environment,
2127
2354
  entry,
2128
2355
  canArchive,
2129
- canReveal,
2356
+ canList,
2130
2357
  status: state,
2131
2358
  onRestore,
2132
2359
  onDismiss,
@@ -2136,7 +2363,8 @@ function ArchivedRow({
2136
2363
  environment: string;
2137
2364
  entry: SecretKey;
2138
2365
  canArchive: boolean;
2139
- canReveal: boolean;
2366
+ /** Whether the caller lists the environment, as its history takes. */
2367
+ canList: boolean;
2140
2368
  status: ItemStatus;
2141
2369
  onRestore: () => void;
2142
2370
  onDismiss: (mutationId: number) => void;
@@ -2160,7 +2388,7 @@ function ArchivedRow({
2160
2388
  {state.state === 'pending' ? (
2161
2389
  <RowPending status={state} />
2162
2390
  ) : (
2163
- (canReveal || canArchive) && (
2391
+ (canList || canArchive) && (
2164
2392
  <div className="acts">
2165
2393
  <Menu.Root>
2166
2394
  <Menu.Trigger
@@ -2170,7 +2398,7 @@ function ArchivedRow({
2170
2398
  <MoreHorizontal size={16} />
2171
2399
  </Menu.Trigger>
2172
2400
  <MenuPopup align="end">
2173
- <SecretReadOnly canReveal={canReveal}>
2401
+ <SecretReadOnly canReveal={canList}>
2174
2402
  <Menu.Item
2175
2403
  className="menu-item"
2176
2404
  onClick={() => setHistoryOpen((open) => !open)}
@@ -2181,7 +2409,7 @@ function ArchivedRow({
2181
2409
  </SecretReadOnly>
2182
2410
  {canArchive && (
2183
2411
  <>
2184
- {canReveal && <Menu.Separator className="menu-sep" />}
2412
+ {canList && <Menu.Separator className="menu-sep" />}
2185
2413
  <Menu.Item className="menu-item" onClick={onRestore}>
2186
2414
  <RotateBack size={14} />
2187
2415
  Restore
@@ -2309,6 +2537,12 @@ function VersionHistory({
2309
2537
  <td className="cell-mono nowrap">
2310
2538
  v{version.version}{' '}
2311
2539
  {version.current && <span className="tag tag-blue">Current</span>}
2540
+ {version.sensitivity !== 'secret' && (
2541
+ <>
2542
+ {' '}
2543
+ <span className="tag" title={LEVELS[version.sensitivity].hint}>{LEVELS[version.sensitivity].label}</span>
2544
+ </>
2545
+ )}
2312
2546
  </td>
2313
2547
  <td className="nowrap">
2314
2548
  <Timestamp iso={version.createdAt} />