@coffre/ui 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/audit-sentences.d.ts +56 -0
  2. package/dist/audit-sentences.js +886 -0
  3. package/dist/audit-sentences.js.map +1 -0
  4. package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
  5. package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
  6. package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
  7. package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
  8. package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
  9. package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
  10. package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
  11. package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
  12. package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
  13. package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
  14. package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
  15. package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
  16. package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
  17. package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
  18. package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
  19. package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
  20. package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
  21. package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
  22. package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
  23. package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
  24. package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
  25. package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
  26. package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
  27. package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
  28. package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
  29. package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
  30. package/dist/chunks/protected-DEWeOrmI.js +77 -0
  31. package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
  32. package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
  33. package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
  34. package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
  35. package/dist/chunks/references-wTh_DT0M.js.map +1 -0
  36. package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
  37. package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
  38. package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
  39. package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
  40. package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
  41. package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
  42. package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
  43. package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
  44. package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
  45. package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
  46. package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
  47. package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
  48. package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
  49. package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
  50. package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
  51. package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
  52. package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
  53. package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
  54. package/dist/index.d.ts +23 -55
  55. package/dist/index.js +12 -31
  56. package/dist/index.js.map +1 -1
  57. package/dist/pages/account.js +12 -12
  58. package/dist/pages/account.js.map +1 -1
  59. package/dist/pages/approval.js +2 -2
  60. package/dist/pages/audit.js +173 -196
  61. package/dist/pages/audit.js.map +1 -1
  62. package/dist/pages/device-login.js +2 -2
  63. package/dist/pages/environment.js +445 -252
  64. package/dist/pages/environment.js.map +1 -1
  65. package/dist/pages/login.js +6 -15
  66. package/dist/pages/login.js.map +1 -1
  67. package/dist/pages/oauth-authorize.js +2 -2
  68. package/dist/pages/project-access.js +11 -11
  69. package/dist/pages/project-environments.js +359 -28
  70. package/dist/pages/project-environments.js.map +1 -1
  71. package/dist/pages/project-settings.js +8 -8
  72. package/dist/pages/project.js +3 -3
  73. package/dist/pages/projects.js +8 -8
  74. package/dist/pages/service-account.js +19 -16
  75. package/dist/pages/service-account.js.map +1 -1
  76. package/dist/pages/service-accounts.js +6 -7
  77. package/dist/pages/service-accounts.js.map +1 -1
  78. package/dist/pages/settings.d.ts +1 -6
  79. package/dist/pages/settings.js +155 -286
  80. package/dist/pages/settings.js.map +1 -1
  81. package/dist/pages/unregistered.js +2 -2
  82. package/dist/pages/user.js +7 -8
  83. package/dist/pages/user.js.map +1 -1
  84. package/dist/pages/users.js +6 -7
  85. package/dist/pages/users.js.map +1 -1
  86. package/package.json +8 -3
  87. package/src/components/actions-log.tsx +8 -61
  88. package/src/components/directory.tsx +10 -9
  89. package/src/components/grants.tsx +2 -2
  90. package/src/components/icons.tsx +0 -2
  91. package/src/components/offboarding.tsx +9 -16
  92. package/src/components/page.tsx +2 -3
  93. package/src/components/personal-tokens.tsx +5 -2
  94. package/src/components/principal-page.tsx +5 -4
  95. package/src/components/protected.tsx +39 -52
  96. package/src/components/references.tsx +18 -7
  97. package/src/components/role-editor.tsx +68 -99
  98. package/src/components/role-field.tsx +1 -1
  99. package/src/components/trusted-workloads.tsx +6 -5
  100. package/src/components/ui.tsx +5 -0
  101. package/src/lib/audit-proofs.ts +51 -0
  102. package/src/lib/audit-sentences.ts +490 -529
  103. package/src/lib/bindings.ts +6 -0
  104. package/src/lib/changes.ts +3 -1
  105. package/src/lib/coffre.ts +2 -2
  106. package/src/lib/queries.ts +19 -168
  107. package/src/lib/reveal.ts +32 -5
  108. package/src/lib/roles.ts +10 -36
  109. package/src/lib/row-reads.ts +2 -2
  110. package/src/lib/signin-errors.ts +5 -33
  111. package/src/options.ts +3 -19
  112. package/src/pages/account.tsx +1 -1
  113. package/src/pages/audit.tsx +151 -228
  114. package/src/pages/environment.tsx +373 -247
  115. package/src/pages/login.tsx +2 -4
  116. package/src/pages/project-environments.tsx +322 -20
  117. package/src/pages/service-accounts.tsx +1 -1
  118. package/src/pages/settings.tsx +49 -134
  119. package/src/pages/user.tsx +2 -2
  120. package/src/pages/users.tsx +1 -1
  121. package/src/parity.ts +11 -20
  122. package/src/styles/globals.css +107 -273
  123. package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
  124. package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
  125. package/dist/chunks/directory-DrswWQLT.js.map +0 -1
  126. package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
  127. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
  128. package/dist/chunks/grants-C0cb2oii.js.map +0 -1
  129. package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
  130. package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
  131. package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
  132. package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
  133. package/dist/chunks/queries-D1JuimTu.js.map +0 -1
  134. package/dist/chunks/references-D5llUGQL.js.map +0 -1
  135. package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
  136. package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
  137. package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
  138. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
  139. package/src/components/environment-actions.tsx +0 -508
@@ -1,9 +1,10 @@
1
1
  import { type AuditEntryView } from '@coffre/client';
2
- import { useState, type ReactNode } from 'react';
2
+ import { useEffect, useRef, useState, type ReactNode } from 'react';
3
3
  import { useSuspenseQuery } from '@tanstack/react-query';
4
4
  import { Link } from '@tanstack/react-router';
5
5
  import { useCoffre } from '../lib/coffre';
6
- import { chainUnknown, queries, shownChain, wholeTrees, withTrees, type AuditSearch, type ChainResult } from '../lib/queries';
6
+ import { queries, type AuditSearch } from '../lib/queries';
7
+ import { proofOf, remember, shownProofs, type Head, type Proof, type Proved } from '../lib/audit-proofs';
7
8
  import {
8
9
  decidedBy,
9
10
  describe,
@@ -13,16 +14,14 @@ import {
13
14
  who,
14
15
  type Part,
15
16
  } from '../lib/audit-sentences';
16
- import { absolute, EmptyState, Notice, Spinner, Timestamp, Toggletip } from '../components/ui';
17
+ import { absolute, EmptyState, Notice, Timestamp, Toggletip } from '../components/ui';
17
18
  import { memberName, Sentence } from '../components/audit-sentence';
18
- import { ReadsLag } from '../components/actions-log';
19
19
  import { ClosedDoor, PageHeader } from '../components/page';
20
20
  import {
21
21
  Activity,
22
22
  AlertTriangle,
23
23
  ChevronRight,
24
24
  Clock,
25
- Info,
26
25
  Ledger,
27
26
  ShieldCheck,
28
27
  SlashCircle,
@@ -37,40 +36,15 @@ const Route = pageRoute<typeof audit>();
37
36
  export function AuditPage() {
38
37
  const search = Route.useSearch();
39
38
  const client = useCoffre();
40
- const { data: result } = useSuspenseQuery(queries.auditEntries(client, search));
41
- // Loaded with the entries: the page arrives with its badge.
42
- const verification = useSuspenseQuery(queries.auditChain(client));
43
- // The walk from the first entry, once someone ran it, beside the check from the newest checkpoint, which
44
- // the page reuses for `FRESH_MS` and asks again after that, after a change made here, or on Retry:
45
- // `shownChain` says which the page shows, until the page is left.
46
- const [whole, setWhole] = useState<ChainResult | null>(null);
47
- const chain = shownChain(verification.data, whole);
48
- // The walk from the first entry, when someone asks for it: how far it has got. Its verdict takes the badge's place.
49
- const [walked, setWalked] = useState<{ through: number | null } | null>(null);
50
- const [walkFailed, setWalkFailed] = useState<string | null>(null);
51
- const walkWhole = async () => {
52
- setWalked({ through: null });
53
- setWalkFailed(null);
54
- setWhole(null);
55
- let verdict: ChainResult;
56
- try {
57
- // 0.15's log, where the instance keeps it, checked again as on a visit, from its newest checkpoint, beside the walk
58
- // (R42). Nothing walks it whole on a request: its cost is the database's to shape.
59
- // And the reads the pages list, held to the uses the log sealed (T166): the whole log's check alone reads them.
60
- const trees = Promise.allSettled([wholeTrees(client)]);
61
- const chain = await client.audit.verifyWhole((stretch) => setWalked({ through: stretch.through }));
62
- verdict = withTrees(chain, true, (await trees)[0]);
63
- } catch (error) {
64
- verdict = chainUnknown(error);
65
- }
66
- // A walk that could not run, or was refused, says nothing of the log: the verdict from the newest checkpoint stands.
67
- if (verdict.integrity === 'unknown') setWalkFailed(verdict.problem);
68
- else if (verdict.integrity === 'owners-only') setWalkFailed('the request was refused (HTTP 403)');
69
- else setWhole(verdict);
70
- setWalked(null);
71
- };
39
+ const entries = useSuspenseQuery(queries.auditEntries(client, search));
40
+ const result = entries.data;
41
+ // What this page has seen proven, by head, while it is open: see `shownProofs`.
42
+ const proved = useRef<Proved>(new Map());
43
+ const proofs = result.ok ? shownProofs(proved.current, result.head, result.entries) : new Map<number, Proof>();
44
+ useEffect(() => {
45
+ if (result.ok) remember(proved.current, result.head, result.entries);
46
+ }, [result]);
72
47
  const { decision, actorId } = search;
73
- const detail = search.detail === '1';
74
48
  const deniedOnly = decision === 'deny';
75
49
 
76
50
  if (!result.ok) {
@@ -81,8 +55,25 @@ export function AuditPage() {
81
55
  );
82
56
  }
83
57
 
84
- const broken = chain?.integrity === 'broken' ? chain : null;
85
- const breakAt = broken?.failedAtSeq ?? null;
58
+ const proof = (entry: Entry) => proofs.get(entry.seq) ?? entry.proof;
59
+ const failed = result.entries.filter((entry) => proof(entry) === 'failed');
60
+ const counts = {
61
+ failed: failed.length,
62
+ unproven: result.entries.filter((entry) => proof(entry) === 'unproven').length,
63
+ proven: result.entries.filter((entry) => proof(entry) === 'proven').length,
64
+ };
65
+ const signed = result.head === null ? null : `${absolute(result.head.signedAt, false)} UTC`;
66
+ const holes = result.holes ?? [];
67
+ // Kept entries are never pruned, so a kept one missing is removed; an aging
68
+ // one may have been pruned while the page read the log.
69
+ const gone = (kind: 'kept' | 'aging') => {
70
+ const found = holes.filter((hole) => hole[kind] > 0);
71
+ const count = found.reduce((sum, hole) => sum + hole[kind], 0);
72
+ const places = found.length === 1 ? where(found[0]!) : `, in ${found.length} places`;
73
+ return { count, places, entries: `${count.toLocaleString('en')} ${count === 1 ? 'entry' : 'entries'}` };
74
+ };
75
+ const removed = gone('kept');
76
+ const pruned = gone('aging');
86
77
  const shown = lines(result.entries);
87
78
  const filters = { decision, actorId };
88
79
 
@@ -93,41 +84,44 @@ export function AuditPage() {
93
84
  actions={
94
85
  // One region for every state, so each change of it is announced.
95
86
  <div className="chain-live" aria-live="polite" aria-atomic="true">
96
- <ChainStatus
97
- chain={chain}
98
- walked={walked}
99
- walkFailed={walkFailed}
100
- retrying={verification.isFetching}
101
- onRetry={() => void verification.refetch()}
102
- onWalk={() => void walkWhole()}
87
+ <ProofStatus
88
+ head={result.head}
89
+ counts={counts}
90
+ pruned={pruned.count > 0}
91
+ checking={entries.isFetching}
92
+ onCheck={() => void entries.refetch()}
103
93
  />
104
94
  </div>
105
95
  }
106
96
  />
107
97
 
108
- {broken !== null && (
98
+ {failed.length > 0 && (
109
99
  <div style={{ marginBottom: '1.25rem' }}>
110
100
  <Notice tone="bad">
111
101
  <strong>Treat this as an incident.</strong>{' '}
112
- {broken.failedAtSeq === null
113
- ? `The log does not verify, found by the ${broken.author}'s check: ${broken.reason}.`
114
- : `The log breaks at entry ${broken.failedAtSeq}, found by the ${broken.author}'s check: ${broken.reason}.`}{' '}
115
- {broken.through !== null && `Every entry through ${broken.through} holds. `}
116
- Something with direct access to the database has changed what it records
117
- {broken.failedAtSeq === null ? '' : `, and nothing from entry ${broken.failedAtSeq} on can be relied on`} until
118
- that is explained.
119
- {breakAt !== null && !result.entries.some((entry) => breaksAt(entry, breakAt)) && (
120
- <>
121
- {' '}Entry {breakAt} is not among the entries below
122
- {detail ? (
123
- <>
124
- ; <code>coffre audit</code> lists them all.
125
- </>
126
- ) : (
127
- ': it may be detail, which Everything lists.'
128
- )}
129
- </>
130
- )}
102
+ {failed.length === 1 ? `Entry ${failed[0]!.seq} is` : `${failed.length} entries below are`} not what the vault
103
+ signed{signed === null ? '' : ` in the head it signed at ${signed}`}. Something with direct access to the
104
+ database has changed what the log records, and {failed.length === 1 ? 'that entry' : 'those entries'} can’t be
105
+ relied on until that is explained.
106
+ </Notice>
107
+ </div>
108
+ )}
109
+
110
+ {removed.count > 0 && (
111
+ <div style={{ marginBottom: '1.25rem' }}>
112
+ <Notice tone="bad">
113
+ <strong>Treat this as an incident.</strong> The log lacks {removed.entries} the vault’s head numbers
114
+ {removed.places}. Nothing prunes these entries: something with direct access to the database removed them.
115
+ </Notice>
116
+ </div>
117
+ )}
118
+
119
+ {pruned.count > 0 && (
120
+ <div style={{ marginBottom: '1.25rem' }}>
121
+ <Notice tone="warn">
122
+ The log lacks {pruned.entries} the vault’s head numbers{pruned.places}, all of the kind it prunes with
123
+ age. A prune while the page read the log does this, and checking again settles it; entries that stay missing
124
+ were removed by something with direct access to the database.
131
125
  </Notice>
132
126
  </div>
133
127
  )}
@@ -161,8 +155,6 @@ export function AuditPage() {
161
155
  )}
162
156
  </div>
163
157
 
164
- <ReadsLag reads={result.reads} omitted={result.readsOmitted} />
165
-
166
158
  <section className="card card-wide" aria-label="Audit entries">
167
159
  {shown.length === 0 ? (
168
160
  <EmptyState title={deniedOnly ? 'No denials recorded' : 'Nothing recorded yet'}>
@@ -206,7 +198,7 @@ export function AuditPage() {
206
198
  </thead>
207
199
  <tbody>
208
200
  {shown.map((batch) => (
209
- <Line key={entryKey(batch[0]!)} batch={batch} filters={filters} detail={search.detail} breakAt={breakAt} />
201
+ <Line key={batch[0]!.seq} batch={batch} filters={filters} detail={search.detail} proof={proof} />
210
202
  ))}
211
203
  </tbody>
212
204
  </table>
@@ -221,16 +213,6 @@ export function AuditPage() {
221
213
  type Entry = AuditEntryView;
222
214
  type Filters = { decision?: 'deny'; actorId?: string };
223
215
 
224
- /** Where the chain breaks is an entry of 0.14's: 0.15's sealed log numbers its changes apart, and says no entry of its own. */
225
- function breaksAt(entry: Entry, seq: number): boolean {
226
- return entry.log !== '0.15' && entry.seq === seq;
227
- }
228
-
229
- /** An entry by its log and number: 0.14's chain and 0.15's sealed log each number theirs. */
230
- function entryKey(entry: Pick<Entry, 'log' | 'seq'>): string {
231
- return `${entry.log}:${entry.seq}`;
232
- }
233
-
234
216
  /**
235
217
  * One action: an entry, or a batch of them under one operation, which opens
236
218
  * to each; a read of several secrets, logged as one entry, opens to each
@@ -240,23 +222,23 @@ function Line({
240
222
  batch,
241
223
  filters,
242
224
  detail,
243
- breakAt,
225
+ proof,
244
226
  }: {
245
227
  batch: Entry[];
246
228
  filters: Filters;
247
229
  detail: '1' | undefined;
248
- breakAt: number | null;
230
+ proof: (entry: Entry) => Proof;
249
231
  }) {
250
- const breaksInside = breakAt !== null && batch.some((entry) => breaksAt(entry, breakAt));
251
- const [open, setOpen] = useState(breaksInside);
232
+ const proofs = batch.map(proof);
233
+ const shown = proofOf(proofs);
234
+ // A batch with an entry that fails opens on it.
235
+ const [open, setOpen] = useState(shown === 'failed');
252
236
  const lead = batch[0]!;
253
237
  const sentence = describe(batch);
254
238
  const seqs = batch.map((entry) => entry.seq);
255
239
  const each = batch.flatMap(perSecret);
256
240
  const grouped = each.length > 1;
257
241
  const [unit, units] = each.length === batch.length ? ['entry', 'entries'] : ['secret', 'secrets'];
258
- // A read of several breaks at its first secret's row.
259
- const breakRow = each.findIndex((entry) => breakAt !== null && breaksAt(entry, breakAt));
260
242
  const [first, last] = [Math.min(...seqs), Math.max(...seqs)];
261
243
 
262
244
  return (
@@ -269,8 +251,7 @@ function Line({
269
251
  decided={decidedBy(batch)}
270
252
  filters={filters}
271
253
  detail={detail}
272
- breaks={breaksInside && !grouped}
273
- marked={breaksInside}
254
+ proof={shown}
274
255
  toggle={
275
256
  grouped ? (
276
257
  <button
@@ -291,7 +272,7 @@ function Line({
291
272
  const one = describe([entry]);
292
273
  return (
293
274
  <Row
294
- key={`${entryKey(entry)}:${i}`}
275
+ key={`${entry.seq}:${i}`}
295
276
  entry={entry}
296
277
  seq={String(entry.seq)}
297
278
  parts={one.parts}
@@ -299,8 +280,7 @@ function Line({
299
280
  decided={decidedBy([entry])}
300
281
  filters={filters}
301
282
  detail={detail}
302
- breaks={i === breakRow}
303
- marked={false}
283
+ proof={proof(entry)}
304
284
  child
305
285
  />
306
286
  );
@@ -317,8 +297,7 @@ function Row({
317
297
  decided,
318
298
  filters,
319
299
  detail,
320
- breaks,
321
- marked,
300
+ proof,
322
301
  toggle,
323
302
  child = false,
324
303
  }: {
@@ -329,27 +308,23 @@ function Row({
329
308
  decided: string;
330
309
  filters: Filters;
331
310
  detail: '1' | undefined;
332
- /** The entry where verification stopped. */
333
- breaks: boolean;
334
- /** A batch holding it, closed or open. */
335
- marked: boolean;
311
+ /** Its own, or a batch's: its worst entry's. */
312
+ proof: Proof;
336
313
  toggle?: ReactNode;
337
314
  child?: boolean;
338
315
  }) {
339
316
  const actor = who(entry);
340
317
  const classes = [
341
318
  refused && 'is-denied',
342
- (breaks || marked) && 'is-break',
319
+ proof === 'failed' && 'is-break',
343
320
  child && 'is-child',
344
321
  entry.detail && 'is-detail',
345
- (entry.action === 'vault.tampered' || entry.forged === true) && 'is-tampered',
322
+ entry.action === 'vault.tampered' && 'is-tampered',
346
323
  ].filter(Boolean);
347
324
  return (
348
- <tr className={classes.length === 0 ? undefined : classes.join(' ')}>
349
- <td className="n" data-label="Sequence" title={entry.log === '0.15' ? `Entry ${entry.seq} of the sealed log, which numbers its own` : undefined}>
325
+ <tr className={classes.length === 0 ? undefined : classes.join(' ')} data-proof={proof}>
326
+ <td className="n" data-label="Sequence">
350
327
  {seq}
351
- {/* 0.15's sealed log numbers its changes and uses apart from 0.14's chain: a read, a sign-in, is recorded there alone. */}
352
- {entry.log === '0.15' && <small className="n-log">sealed</small>}
353
328
  </td>
354
329
  <td className="nowrap cell-mono" data-label="When (UTC)">
355
330
  <Timestamp iso={entry.occurredAt} precise />
@@ -369,8 +344,8 @@ function Row({
369
344
  )}
370
345
  </span>
371
346
  {entry.run !== null && (
372
- // The run its issuer named when the credential was exchanged: what it asserted, kept in its sign-in, #exchangeSeq.
373
- <small className="actor-run" title={entry.run.log === '0.15' ? `Signed in at change ${entry.run.exchangeSeq} of the sealed log` : `Exchanged in entry ${entry.run.exchangeSeq}`}>
347
+ // The run its issuer named when the credential was exchanged: what it asserted, kept in entry #exchangeSeq.
348
+ <small className="actor-run" title={`Exchanged in entry ${entry.run.exchangeSeq}`}>
374
349
  {runLabel(entry.run)}
375
350
  </small>
376
351
  )}
@@ -384,14 +359,11 @@ function Row({
384
359
  <td className="cell-sentence" data-label="What they did">
385
360
  <span className="sentence">
386
361
  {toggle}
387
- {(entry.action === 'vault.tampered' || entry.forged === true) && <AlertTriangle size={13} />}
362
+ {entry.action === 'vault.tampered' && <AlertTriangle size={13} />}
388
363
  <Sentence parts={parts} />
389
- {breaks && <BreakMark />}
364
+ {proof === 'failed' && <BreakMark />}
365
+ {proof === 'unproven' && <span className="unproven-mark">not proven</span>}
390
366
  </span>
391
- {entry.forged === true && (
392
- // An entry of the sealed log the vault does not vouch for: written, or edited, around coffre.
393
- <small className="actor-run">Forged: the vault does not vouch for this entry</small>
394
- )}
395
367
  </td>
396
368
  <td className="nowrap" data-label="Decided by">
397
369
  <span className={refused ? 'decided decided-refused' : 'decided'}>
@@ -404,161 +376,112 @@ function Row({
404
376
  );
405
377
  }
406
378
 
407
- /** The entry the log breaks at, said in words as well as in red. */
379
+ /** An entry that is not what the vault signed, said in words as well as in red. */
408
380
  function BreakMark() {
409
381
  return (
410
382
  <span className="break-mark">
411
383
  <AlertTriangle size={11} />
412
- breaks here
384
+ not as signed
413
385
  </span>
414
386
  );
415
387
  }
416
388
 
389
+ /** Where a hole is, between the entries found around it. */
390
+ function where(hole: { above: number | null; below: number | null }): string {
391
+ if (hole.above !== null && hole.below !== null) return ` between entries ${hole.below} and ${hole.above}`;
392
+ if (hole.below !== null) return ` after entry ${hole.below}`;
393
+ if (hole.above !== null) return ` before entry ${hole.above}`;
394
+ return '';
395
+ }
396
+
417
397
  /**
418
- * Whether the log still verifies, beside the title.
419
- *
420
- * This replaced a card with a "Verify chain" button on it. A green result you
421
- * have to ask for is reassurance rather than evidence: it is checked when
422
- * someone is already feeling confident, and not on the morning it would have
423
- * mattered. Recomputing on load makes the claim continuous.
398
+ * What the entries shown prove, beside the title: rendered with the page,
399
+ * from the answer that listed them, never a loading state.
424
400
  *
425
- * On load it checks what was written since the newest checkpoint, which
426
- * vouches for everything before, so it is quick however long the log. The
427
- * walk from the first entry, which checks again what the checkpoints vouch
428
- * for, is there to ask for, a stretch a request, with how far it has got.
429
- * The check on load is rendered with the page, never a loading state; a
430
- * check that could not run says so and offers to run again, rather than
431
- * passing for a broken log.
401
+ * The vault vouches for a head of the log in the page's own call, and the
402
+ * server proves each entry shown against it from the tiles. So the claim is
403
+ * about what is on screen, every time it is shown, however long the log.
404
+ * An entry past the head is not proven: signed since the vault's read, or
405
+ * put there by a writer, which the page cannot tell apart; checking again,
406
+ * against a newer head, settles the first.
432
407
  */
433
- function ChainStatus({
434
- chain,
435
- walked,
436
- walkFailed,
437
- retrying,
438
- onRetry,
439
- onWalk,
408
+ function ProofStatus({
409
+ head,
410
+ counts,
411
+ pruned,
412
+ checking,
413
+ onCheck,
440
414
  }: {
441
- chain: ChainResult;
442
- walked: { through: number | null } | null;
443
- walkFailed: string | null;
444
- /** The check on load is being asked again. */
445
- retrying: boolean;
446
- onRetry: () => void;
447
- onWalk: () => void;
415
+ head: Head;
416
+ counts: Record<Proof, number>;
417
+ /** The log lacks entries a prune may have taken while the page read it, which checking again settles. */
418
+ pruned: boolean;
419
+ /** The page is being asked again. */
420
+ checking: boolean;
421
+ onCheck: () => void;
448
422
  }) {
449
- if (walked !== null) {
450
- return (
451
- <span className="chain-note" role="status">
452
- <Spinner size={14} />
453
- {walked.through === null ? 'Verifying from the first entry…' : `Verified through ${walked.through.toLocaleString('en')}…`}
454
- </span>
455
- );
456
- }
457
-
458
- if (chain.integrity === 'owners-only') {
423
+ const plural = (n: number) => `${n.toLocaleString('en')} ${n === 1 ? 'entry' : 'entries'}`;
424
+ const again = (
425
+ <button type="button" className="btn btn-sm" disabled={checking} onClick={onCheck}>
426
+ Check again
427
+ </button>
428
+ );
429
+ if (counts.failed > 0) {
430
+ // A failure stands, but the rows past the head or a prune's gap beside
431
+ // it are still settled by checking again.
459
432
  return (
460
- <Toggletip
461
- align="end"
462
- label="Only auditors, admins and owners of the whole instance can check the log: it takes every entry, and you see only your projects'."
463
- >
464
- <button type="button" className="chain-note">
465
- <Info size={14} />
466
- Verified by owners
467
- </button>
468
- </Toggletip>
433
+ <div className="chain">
434
+ <span className="chain-flag chain-flag-bad">
435
+ <AlertTriangle size={14} />
436
+ {plural(counts.failed)} not as signed
437
+ </span>
438
+ {(counts.unproven > 0 || pruned) && again}
439
+ </div>
469
440
  );
470
441
  }
471
442
 
472
- if (chain.integrity === 'unknown') {
443
+ if (head === null) {
473
444
  return (
474
445
  <div className="chain">
475
446
  <Toggletip
476
447
  align="end"
477
- label={`coffre could not check the log: ${chain.problem}. The entries below are unverified.`}
448
+ label="The vault vouched for no head of the log: it has signed none yet, or the one in the database is not one it signed. No entry below is proven."
478
449
  >
479
450
  <button type="button" className="chain-flag chain-flag-warn">
480
451
  <AlertTriangle size={14} />
481
- Couldn’t verify
452
+ Not proven
482
453
  </button>
483
454
  </Toggletip>
484
- <button type="button" className="btn btn-sm" disabled={retrying} onClick={onRetry}>
485
- Retry
486
- </button>
455
+ {again}
487
456
  </div>
488
457
  );
489
458
  }
490
459
 
491
- if (chain.integrity === 'broken') {
492
- return (
493
- <span className="chain-flag chain-flag-bad">
494
- <AlertTriangle size={14} />
495
- {chain.failedAtSeq === null ? 'Log does not verify' : `Log broken at ${chain.failedAtSeq}`}
496
- </span>
497
- );
498
- }
499
-
500
- const signed = chain.checkpoint === null ? null : `${absolute(chain.checkpoint.signedAt, false)} UTC`;
501
- const verified = chain.whole
502
- ? `Audit log verified from its first entry by the app and vault keys${signed === null ? ', not signed yet' : `, last signature at ${signed}`}.`
503
- : signed === null
504
- ? 'Audit log verified by the app and vault keys, not signed yet.'
505
- : `What was written since the last checkpoint verified by the app and vault keys; the checkpoint, signed at ${signed}, vouches for everything before it, as each was checked when it was written.`;
506
- // 0.15's log, where it is kept: its newest checkpoint and every entry since, on a visit and after a walk alike. Its own
507
- // numbers are not the entries' above: it is named by when its newest checkpoint was signed.
508
- const trees = chain.trees;
509
- const sealed = trees?.checkpoint == null ? null : `its checkpoint of ${absolute(new Date(trees.checkpoint.at).toISOString(), false)} UTC`;
510
- const sealedLog = trees === null ? '' : ` The sealed log: ${sealed === null ? 'nothing sealed yet' : sealed}, and every entry since, verified.`;
511
- // Not known whether it holds: no seal over it, as over a log verified in part.
512
- const unchecked = chain.treesFailed !== null;
460
+ const signed = `${absolute(head.signedAt, false)} UTC`;
513
461
  return (
514
462
  <div className="chain">
515
- {chain.pending > 0 && (
516
- <Toggletip
517
- align="end"
518
- label="Keys released through KMS whose outcome the vault has not logged yet. Each settles within seconds, or is logged as failed."
519
- >
520
- <button type="button" className="chain-note" role="status">
521
- {chain.pending} key operation{chain.pending === 1 ? '' : 's'} in flight
522
- </button>
523
- </Toggletip>
463
+ {counts.unproven > 0 && (
464
+ <>
465
+ <Toggletip
466
+ align="end"
467
+ label={`Past the head the vault signed at ${signed}, of ${head.size.toLocaleString('en')} entries: signed since, or put there by something with direct access to the database. Checking again, against a newer head, settles the first.`}
468
+ >
469
+ <button type="button" className="chain-note">
470
+ {plural(counts.unproven)} not proven
471
+ </button>
472
+ </Toggletip>
473
+ {again}
474
+ </>
524
475
  )}
525
- {chain.remaining > 0 && (
476
+ {pruned && counts.unproven === 0 && again}
477
+ {counts.proven > 0 && (
526
478
  <Toggletip
527
479
  align="end"
528
- label={`Verified through entry ${chain.through?.toLocaleString('en') ?? 'none'}. The checkpoints are catching up with the log, a stretch every five minutes, and a check goes no further than they have.`}
480
+ label={`Each entry below the vault’s head, signed at ${signed}, is proven against it: what it records is what the vault signed, where it signed it.`}
529
481
  >
530
- <button type="button" className="chain-note" role="status">
531
- {chain.remaining.toLocaleString('en')} newer {chain.remaining === 1 ? 'entry' : 'entries'} to verify
532
- </button>
533
- </Toggletip>
534
- )}
535
- {walkFailed !== null && (
536
- <Toggletip align="end" label={`coffre could not walk the whole log: ${walkFailed}. The verdict beside it, from the newest checkpoint, stands.`}>
537
- <button type="button" className="chain-flag chain-flag-warn">
538
- <AlertTriangle size={14} />
539
- Whole log not checked
540
- </button>
541
- </Toggletip>
542
- )}
543
- {unchecked && (
544
- <Toggletip align="end" label={`${chain.treesFailed}. The rest of the log's verdict stands.`}>
545
- <button type="button" className="chain-flag chain-flag-warn">
546
- <AlertTriangle size={14} />
547
- {chain.treesBehind && chain.trees !== null ? `Sealed log not checked to the head (${chain.trees.pending.toLocaleString('en')}+ entries pending)` : 'Sealed log not checked'}
548
- </button>
549
- </Toggletip>
550
- )}
551
- {!chain.whole && chain.remaining === 0 && (
552
- <button type="button" className="btn btn-sm" onClick={onWalk}>
553
- Verify whole log
554
- </button>
555
- )}
556
- {/* No seal over a log verified only in part: what is left could be anything. */}
557
- {chain.remaining === 0 && !unchecked && (
558
- <Toggletip align="end" label={`${verified}${sealedLog}`}>
559
482
  <button type="button" className="chain-seal">
560
483
  <ShieldCheck size={14} />
561
- Verified
484
+ Proven
562
485
  </button>
563
486
  </Toggletip>
564
487
  )}