@coffre/ui 0.14.7 → 0.16.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.
- package/dist/audit-sentences.d.ts +56 -0
- package/dist/audit-sentences.js +886 -0
- package/dist/audit-sentences.js.map +1 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
- package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-6sMSgQ9U.js} +5 -5
- package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
- package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-T469tSN9.js} +5 -5
- package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-T469tSN9.js.map} +1 -1
- package/dist/chunks/{directory-BM8yoiJN.js → directory-B_gVf7UL.js} +13 -12
- package/dist/chunks/{directory-BM8yoiJN.js.map → directory-B_gVf7UL.js.map} +1 -1
- package/dist/chunks/{folders-D3A1NGpt.js → folders-CVYauIDz.js} +3 -3
- package/dist/chunks/{folders-D3A1NGpt.js.map → folders-CVYauIDz.js.map} +1 -1
- package/dist/chunks/{grants-CjVmOgb2.js → grants-Dn_EW2XW.js} +6 -6
- package/dist/chunks/{grants-CjVmOgb2.js.map → grants-Dn_EW2XW.js.map} +1 -1
- package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-fbBRzi9z.js} +3 -3
- package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
- package/dist/chunks/{offboarding-DbozhPym.js → offboarding-CXM464J_.js} +19 -13
- package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
- package/dist/chunks/{page-JTORvh-N.js → page-Cb0ZjGda.js} +2 -2
- package/dist/chunks/{page-JTORvh-N.js.map → page-Cb0ZjGda.js.map} +1 -1
- package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-CSHMlRHy.js} +7 -7
- package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
- package/dist/chunks/{principal-DFBswTBr.js → principal-BKJxbAtE.js} +2 -2
- package/dist/chunks/{principal-DFBswTBr.js.map → principal-BKJxbAtE.js.map} +1 -1
- package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-COPmTDVW.js} +20 -17
- package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
- package/dist/chunks/{project-page-BjwEoXfU.js → project-page-g5_n46Nz.js} +3 -3
- package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-g5_n46Nz.js.map} +1 -1
- package/dist/chunks/{protected-y7KVhtHd.js → protected-DEWeOrmI.js} +7 -7
- package/dist/chunks/{protected-y7KVhtHd.js.map → protected-DEWeOrmI.js.map} +1 -1
- package/dist/chunks/{queries-2jdgTwfZ.js → queries-D4_o-bz3.js} +11 -88
- package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
- package/dist/chunks/{references-CRT2BsOS.js → references-wTh_DT0M.js} +27 -23
- package/dist/chunks/references-wTh_DT0M.js.map +1 -0
- package/dist/chunks/{role-field-DswIpPqY.js → role-field-BiP09qfN.js} +4 -4
- package/dist/chunks/{role-field-DswIpPqY.js.map → role-field-BiP09qfN.js.map} +1 -1
- package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYhtmUkc.js} +3 -3
- package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYhtmUkc.js.map} +1 -1
- package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
- package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
- package/dist/chunks/{theme-Ck45wzWB.js → theme-imSolE1q.js} +3 -3
- package/dist/chunks/{theme-Ck45wzWB.js.map → theme-imSolE1q.js.map} +1 -1
- package/dist/chunks/{ui-D-blFWfx.js → ui-Q_Eczt7m.js} +7 -3
- package/dist/chunks/{ui-D-blFWfx.js.map → ui-Q_Eczt7m.js.map} +1 -1
- package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BfnN-De2.js} +3 -3
- package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BfnN-De2.js.map} +1 -1
- package/dist/chunks/{use-change-BC4xo02c.js → use-change-Cc0X4sF3.js} +6 -4
- package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
- package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-stcv2QFj.js} +3 -3
- package/dist/chunks/{use-roles-DswiNxBk.js.map → use-roles-stcv2QFj.js.map} +1 -1
- package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-DMhLa2sh.js} +3 -3
- package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-DMhLa2sh.js.map} +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.js +7 -7
- package/dist/pages/account.js +11 -11
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +163 -152
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +67 -35
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +6 -15
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +12 -12
- package/dist/pages/project-settings.js +8 -8
- package/dist/pages/project.js +3 -3
- package/dist/pages/projects.js +8 -8
- package/dist/pages/service-account.js +19 -15
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +5 -5
- package/dist/pages/settings.js +26 -37
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -7
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +5 -5
- package/package.json +8 -3
- package/src/components/directory.tsx +5 -4
- package/src/components/offboarding.tsx +9 -9
- package/src/components/personal-tokens.tsx +5 -2
- package/src/components/principal-page.tsx +4 -3
- package/src/components/references.tsx +18 -7
- package/src/components/trusted-workloads.tsx +6 -5
- package/src/components/ui.tsx +5 -0
- package/src/lib/audit-proofs.ts +51 -0
- package/src/lib/audit-sentences.ts +473 -509
- package/src/lib/bindings.ts +6 -0
- package/src/lib/changes.ts +3 -1
- package/src/lib/coffre.ts +2 -2
- package/src/lib/queries.ts +9 -94
- package/src/lib/reveal.ts +32 -5
- package/src/lib/row-reads.ts +2 -2
- package/src/lib/signin-errors.ts +5 -33
- package/src/pages/audit.tsx +145 -182
- package/src/pages/environment.tsx +21 -20
- package/src/pages/login.tsx +2 -4
- package/src/pages/settings.tsx +6 -10
- package/src/pages/user.tsx +2 -2
- package/src/parity.ts +0 -2
- package/src/styles/globals.css +18 -2
- package/dist/chunks/audit-sentence-JgJEwQEC.js +0 -969
- package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
- package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
- package/dist/chunks/personal-tokens-zWZOzLIC.js.map +0 -1
- package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
- package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
- package/dist/chunks/references-CRT2BsOS.js.map +0 -1
- package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
- package/dist/chunks/use-change-BC4xo02c.js.map +0 -1
package/src/pages/audit.tsx
CHANGED
|
@@ -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 {
|
|
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,7 +14,7 @@ import {
|
|
|
13
14
|
who,
|
|
14
15
|
type Part,
|
|
15
16
|
} from '../lib/audit-sentences';
|
|
16
|
-
import { absolute, EmptyState, Notice,
|
|
17
|
+
import { absolute, EmptyState, Notice, Timestamp, Toggletip } from '../components/ui';
|
|
17
18
|
import { memberName, Sentence } from '../components/audit-sentence';
|
|
18
19
|
import { ClosedDoor, PageHeader } from '../components/page';
|
|
19
20
|
import {
|
|
@@ -21,7 +22,6 @@ import {
|
|
|
21
22
|
AlertTriangle,
|
|
22
23
|
ChevronRight,
|
|
23
24
|
Clock,
|
|
24
|
-
Info,
|
|
25
25
|
Ledger,
|
|
26
26
|
ShieldCheck,
|
|
27
27
|
SlashCircle,
|
|
@@ -36,34 +36,15 @@ const Route = pageRoute<typeof audit>();
|
|
|
36
36
|
export function AuditPage() {
|
|
37
37
|
const search = Route.useSearch();
|
|
38
38
|
const client = useCoffre();
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// The walk from the first entry, when someone asks for it: how far it has got. Its verdict takes the badge's place.
|
|
48
|
-
const [walked, setWalked] = useState<{ through: number | null } | null>(null);
|
|
49
|
-
const [walkFailed, setWalkFailed] = useState<string | null>(null);
|
|
50
|
-
const walkWhole = async () => {
|
|
51
|
-
setWalked({ through: null });
|
|
52
|
-
setWalkFailed(null);
|
|
53
|
-
setWhole(null);
|
|
54
|
-
let verdict: ChainResult;
|
|
55
|
-
try {
|
|
56
|
-
verdict = chainResult(await client.audit.verifyWhole((stretch) => setWalked({ through: stretch.through })), true);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
verdict = chainUnknown(error);
|
|
59
|
-
}
|
|
60
|
-
// A walk that could not run says nothing of the log: the verdict from the newest checkpoint stands.
|
|
61
|
-
if (verdict.integrity === 'unknown') setWalkFailed(verdict.problem);
|
|
62
|
-
else if (verdict.integrity !== 'owners-only') setWhole(verdict);
|
|
63
|
-
setWalked(null);
|
|
64
|
-
};
|
|
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]);
|
|
65
47
|
const { decision, actorId } = search;
|
|
66
|
-
const detail = search.detail === '1';
|
|
67
48
|
const deniedOnly = decision === 'deny';
|
|
68
49
|
|
|
69
50
|
if (!result.ok) {
|
|
@@ -74,8 +55,25 @@ export function AuditPage() {
|
|
|
74
55
|
);
|
|
75
56
|
}
|
|
76
57
|
|
|
77
|
-
const
|
|
78
|
-
const
|
|
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');
|
|
79
77
|
const shown = lines(result.entries);
|
|
80
78
|
const filters = { decision, actorId };
|
|
81
79
|
|
|
@@ -86,41 +84,44 @@ export function AuditPage() {
|
|
|
86
84
|
actions={
|
|
87
85
|
// One region for every state, so each change of it is announced.
|
|
88
86
|
<div className="chain-live" aria-live="polite" aria-atomic="true">
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
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()}
|
|
96
93
|
/>
|
|
97
94
|
</div>
|
|
98
95
|
}
|
|
99
96
|
/>
|
|
100
97
|
|
|
101
|
-
{
|
|
98
|
+
{failed.length > 0 && (
|
|
102
99
|
<div style={{ marginBottom: '1.25rem' }}>
|
|
103
100
|
<Notice tone="bad">
|
|
104
101
|
<strong>Treat this as an incident.</strong>{' '}
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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.
|
|
124
125
|
</Notice>
|
|
125
126
|
</div>
|
|
126
127
|
)}
|
|
@@ -197,7 +198,7 @@ export function AuditPage() {
|
|
|
197
198
|
</thead>
|
|
198
199
|
<tbody>
|
|
199
200
|
{shown.map((batch) => (
|
|
200
|
-
<Line key={batch[0]!.seq} batch={batch} filters={filters} detail={search.detail}
|
|
201
|
+
<Line key={batch[0]!.seq} batch={batch} filters={filters} detail={search.detail} proof={proof} />
|
|
201
202
|
))}
|
|
202
203
|
</tbody>
|
|
203
204
|
</table>
|
|
@@ -221,23 +222,23 @@ function Line({
|
|
|
221
222
|
batch,
|
|
222
223
|
filters,
|
|
223
224
|
detail,
|
|
224
|
-
|
|
225
|
+
proof,
|
|
225
226
|
}: {
|
|
226
227
|
batch: Entry[];
|
|
227
228
|
filters: Filters;
|
|
228
229
|
detail: '1' | undefined;
|
|
229
|
-
|
|
230
|
+
proof: (entry: Entry) => Proof;
|
|
230
231
|
}) {
|
|
231
|
-
const
|
|
232
|
-
const
|
|
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');
|
|
233
236
|
const lead = batch[0]!;
|
|
234
237
|
const sentence = describe(batch);
|
|
235
238
|
const seqs = batch.map((entry) => entry.seq);
|
|
236
239
|
const each = batch.flatMap(perSecret);
|
|
237
240
|
const grouped = each.length > 1;
|
|
238
241
|
const [unit, units] = each.length === batch.length ? ['entry', 'entries'] : ['secret', 'secrets'];
|
|
239
|
-
// A read of several breaks at its first secret's row.
|
|
240
|
-
const breakRow = each.findIndex((entry) => entry.seq === breakAt);
|
|
241
242
|
const [first, last] = [Math.min(...seqs), Math.max(...seqs)];
|
|
242
243
|
|
|
243
244
|
return (
|
|
@@ -250,8 +251,7 @@ function Line({
|
|
|
250
251
|
decided={decidedBy(batch)}
|
|
251
252
|
filters={filters}
|
|
252
253
|
detail={detail}
|
|
253
|
-
|
|
254
|
-
marked={breaksInside}
|
|
254
|
+
proof={shown}
|
|
255
255
|
toggle={
|
|
256
256
|
grouped ? (
|
|
257
257
|
<button
|
|
@@ -280,8 +280,7 @@ function Line({
|
|
|
280
280
|
decided={decidedBy([entry])}
|
|
281
281
|
filters={filters}
|
|
282
282
|
detail={detail}
|
|
283
|
-
|
|
284
|
-
marked={false}
|
|
283
|
+
proof={proof(entry)}
|
|
285
284
|
child
|
|
286
285
|
/>
|
|
287
286
|
);
|
|
@@ -298,8 +297,7 @@ function Row({
|
|
|
298
297
|
decided,
|
|
299
298
|
filters,
|
|
300
299
|
detail,
|
|
301
|
-
|
|
302
|
-
marked,
|
|
300
|
+
proof,
|
|
303
301
|
toggle,
|
|
304
302
|
child = false,
|
|
305
303
|
}: {
|
|
@@ -310,23 +308,21 @@ function Row({
|
|
|
310
308
|
decided: string;
|
|
311
309
|
filters: Filters;
|
|
312
310
|
detail: '1' | undefined;
|
|
313
|
-
/**
|
|
314
|
-
|
|
315
|
-
/** A batch holding it, closed or open. */
|
|
316
|
-
marked: boolean;
|
|
311
|
+
/** Its own, or a batch's: its worst entry's. */
|
|
312
|
+
proof: Proof;
|
|
317
313
|
toggle?: ReactNode;
|
|
318
314
|
child?: boolean;
|
|
319
315
|
}) {
|
|
320
316
|
const actor = who(entry);
|
|
321
317
|
const classes = [
|
|
322
318
|
refused && 'is-denied',
|
|
323
|
-
|
|
319
|
+
proof === 'failed' && 'is-break',
|
|
324
320
|
child && 'is-child',
|
|
325
321
|
entry.detail && 'is-detail',
|
|
326
322
|
entry.action === 'vault.tampered' && 'is-tampered',
|
|
327
323
|
].filter(Boolean);
|
|
328
324
|
return (
|
|
329
|
-
<tr className={classes.length === 0 ? undefined : classes.join(' ')}>
|
|
325
|
+
<tr className={classes.length === 0 ? undefined : classes.join(' ')} data-proof={proof}>
|
|
330
326
|
<td className="n" data-label="Sequence">
|
|
331
327
|
{seq}
|
|
332
328
|
</td>
|
|
@@ -365,7 +361,8 @@ function Row({
|
|
|
365
361
|
{toggle}
|
|
366
362
|
{entry.action === 'vault.tampered' && <AlertTriangle size={13} />}
|
|
367
363
|
<Sentence parts={parts} />
|
|
368
|
-
{
|
|
364
|
+
{proof === 'failed' && <BreakMark />}
|
|
365
|
+
{proof === 'unproven' && <span className="unproven-mark">not proven</span>}
|
|
369
366
|
</span>
|
|
370
367
|
</td>
|
|
371
368
|
<td className="nowrap" data-label="Decided by">
|
|
@@ -379,146 +376,112 @@ function Row({
|
|
|
379
376
|
);
|
|
380
377
|
}
|
|
381
378
|
|
|
382
|
-
/**
|
|
379
|
+
/** An entry that is not what the vault signed, said in words as well as in red. */
|
|
383
380
|
function BreakMark() {
|
|
384
381
|
return (
|
|
385
382
|
<span className="break-mark">
|
|
386
383
|
<AlertTriangle size={11} />
|
|
387
|
-
|
|
384
|
+
not as signed
|
|
388
385
|
</span>
|
|
389
386
|
);
|
|
390
387
|
}
|
|
391
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
|
+
|
|
392
397
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* This replaced a card with a "Verify chain" button on it. A green result you
|
|
396
|
-
* have to ask for is reassurance rather than evidence: it is checked when
|
|
397
|
-
* someone is already feeling confident, and not on the morning it would have
|
|
398
|
-
* 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.
|
|
399
400
|
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* 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.
|
|
407
407
|
*/
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
onWalk,
|
|
408
|
+
function ProofStatus({
|
|
409
|
+
head,
|
|
410
|
+
counts,
|
|
411
|
+
pruned,
|
|
412
|
+
checking,
|
|
413
|
+
onCheck,
|
|
415
414
|
}: {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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;
|
|
423
422
|
}) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
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.
|
|
434
432
|
return (
|
|
435
|
-
<
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
</button>
|
|
443
|
-
</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>
|
|
444
440
|
);
|
|
445
441
|
}
|
|
446
442
|
|
|
447
|
-
if (
|
|
443
|
+
if (head === null) {
|
|
448
444
|
return (
|
|
449
445
|
<div className="chain">
|
|
450
446
|
<Toggletip
|
|
451
447
|
align="end"
|
|
452
|
-
label=
|
|
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."
|
|
453
449
|
>
|
|
454
450
|
<button type="button" className="chain-flag chain-flag-warn">
|
|
455
451
|
<AlertTriangle size={14} />
|
|
456
|
-
|
|
452
|
+
Not proven
|
|
457
453
|
</button>
|
|
458
454
|
</Toggletip>
|
|
459
|
-
|
|
460
|
-
Retry
|
|
461
|
-
</button>
|
|
455
|
+
{again}
|
|
462
456
|
</div>
|
|
463
457
|
);
|
|
464
458
|
}
|
|
465
459
|
|
|
466
|
-
|
|
467
|
-
return (
|
|
468
|
-
<span className="chain-flag chain-flag-bad">
|
|
469
|
-
<AlertTriangle size={14} />
|
|
470
|
-
{chain.failedAtSeq === null ? 'Log does not verify' : `Log broken at ${chain.failedAtSeq}`}
|
|
471
|
-
</span>
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const signed = chain.checkpoint === null ? null : `${absolute(chain.checkpoint.signedAt, false)} UTC`;
|
|
476
|
-
const verified = chain.whole
|
|
477
|
-
? `Audit log verified from its first entry by the app and vault keys${signed === null ? ', not signed yet' : `, last signature at ${signed}`}.`
|
|
478
|
-
: signed === null
|
|
479
|
-
? 'Audit log verified by the app and vault keys, not signed yet.'
|
|
480
|
-
: `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.`;
|
|
460
|
+
const signed = `${absolute(head.signedAt, false)} UTC`;
|
|
481
461
|
return (
|
|
482
462
|
<div className="chain">
|
|
483
|
-
{
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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
|
+
</>
|
|
492
475
|
)}
|
|
493
|
-
{
|
|
476
|
+
{pruned && counts.unproven === 0 && again}
|
|
477
|
+
{counts.proven > 0 && (
|
|
494
478
|
<Toggletip
|
|
495
479
|
align="end"
|
|
496
|
-
label={`
|
|
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.`}
|
|
497
481
|
>
|
|
498
|
-
<button type="button" className="chain-note" role="status">
|
|
499
|
-
{chain.remaining.toLocaleString('en')} newer {chain.remaining === 1 ? 'entry' : 'entries'} to verify
|
|
500
|
-
</button>
|
|
501
|
-
</Toggletip>
|
|
502
|
-
)}
|
|
503
|
-
{walkFailed !== null && (
|
|
504
|
-
<Toggletip align="end" label={`coffre could not walk the whole log: ${walkFailed}. The verdict beside it, from the newest checkpoint, stands.`}>
|
|
505
|
-
<button type="button" className="chain-flag chain-flag-warn">
|
|
506
|
-
<AlertTriangle size={14} />
|
|
507
|
-
Whole log not checked
|
|
508
|
-
</button>
|
|
509
|
-
</Toggletip>
|
|
510
|
-
)}
|
|
511
|
-
{!chain.whole && chain.remaining === 0 && (
|
|
512
|
-
<button type="button" className="btn btn-sm" onClick={onWalk}>
|
|
513
|
-
Verify whole log
|
|
514
|
-
</button>
|
|
515
|
-
)}
|
|
516
|
-
{/* No seal over a log verified only in part: what is left could be anything. */}
|
|
517
|
-
{chain.remaining === 0 && (
|
|
518
|
-
<Toggletip align="end" label={verified}>
|
|
519
482
|
<button type="button" className="chain-seal">
|
|
520
483
|
<ShieldCheck size={14} />
|
|
521
|
-
|
|
484
|
+
Proven
|
|
522
485
|
</button>
|
|
523
486
|
</Toggletip>
|
|
524
487
|
)}
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
type SecretDraft,
|
|
36
36
|
} from '../lib/secret-edit-batch';
|
|
37
37
|
import { createCopier } from '../lib/copy-attempts';
|
|
38
|
-
import { revealIsCurrent, type Reveal } from '../lib/reveal';
|
|
38
|
+
import { revealIsCurrent, stampedRead, type Read, type Reveal } from '../lib/reveal';
|
|
39
39
|
import { noReads, revealToggleDisabled, rowReads, valueToEdit } from '../lib/row-reads';
|
|
40
40
|
import { sortKeys, type Sort } from '../lib/secret-order';
|
|
41
41
|
import { inDialog } from '../lib/shortcuts';
|
|
@@ -1305,6 +1305,7 @@ function SecretRow({
|
|
|
1305
1305
|
const { reveal, revealing, error, copyError } = reads;
|
|
1306
1306
|
const setReveal = (next: Reveal | null) => dispatch({ type: 'set-reveal', reveal: next });
|
|
1307
1307
|
const coffre = useCoffre();
|
|
1308
|
+
const queryClient = useQueryClient();
|
|
1308
1309
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
1309
1310
|
const [moving, setMoving] = useState(false);
|
|
1310
1311
|
const [referring, setReferring] = useState(false);
|
|
@@ -1333,8 +1334,8 @@ function SecretRow({
|
|
|
1333
1334
|
const canRead = entry.readable;
|
|
1334
1335
|
// What a reveal shows: its own version, or, as a reference, its source's.
|
|
1335
1336
|
const readVersion = reference === null ? entry.version : reference.version;
|
|
1336
|
-
// And
|
|
1337
|
-
const readFrom =
|
|
1337
|
+
// And the secret it is held in: a reset, an override or a new reference changes it, maybe under the same number.
|
|
1338
|
+
const readFrom = entry.secret;
|
|
1338
1339
|
const holderPath = `${project}/${environment}/${entry.key}`;
|
|
1339
1340
|
// A plain value is no secret: listed as it is, shown inline and copied with no read.
|
|
1340
1341
|
const rowPlain = entry.value !== null;
|
|
@@ -1373,26 +1374,26 @@ function SecretRow({
|
|
|
1373
1374
|
if (!editing) setBase(null);
|
|
1374
1375
|
}, [editing]);
|
|
1375
1376
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1377
|
+
// A value read is stamped with the version it opened, after the listing has caught up with it (`stampedRead`).
|
|
1378
|
+
async function readValue({ show = true } = {}): Promise<Reveal | null> {
|
|
1379
|
+
if (shown !== null) return shown;
|
|
1378
1380
|
dispatch({ type: 'read-started' });
|
|
1379
1381
|
try {
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
return value;
|
|
1382
|
+
const read = await stampedRead({ version: readVersion, from: readFrom }, fetchValue, () =>
|
|
1383
|
+
queryClient.refetchQueries({ queryKey: queryKeys.secrets({ project, environment }) }),
|
|
1384
|
+
);
|
|
1385
|
+
dispatch({ type: 'read-succeeded', reveal: show ? read : null });
|
|
1386
|
+
return read;
|
|
1386
1387
|
} catch (failure) {
|
|
1387
1388
|
dispatch({ type: 'read-failed', message: readFailureMessage(failure) });
|
|
1388
1389
|
return null;
|
|
1389
1390
|
}
|
|
1390
1391
|
}
|
|
1391
1392
|
|
|
1392
|
-
async function fetchValue(): Promise<
|
|
1393
|
-
if (entry.value !== null) return entry.value;
|
|
1394
|
-
const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
|
|
1395
|
-
return values[entry.key];
|
|
1393
|
+
async function fetchValue(): Promise<Read> {
|
|
1394
|
+
if (entry.value !== null) return { value: entry.value, version: readVersion, from: readFrom };
|
|
1395
|
+
const { values, versions, secrets } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
|
|
1396
|
+
return { value: values[entry.key], version: versions[entry.key], from: secrets[entry.key] };
|
|
1396
1397
|
}
|
|
1397
1398
|
|
|
1398
1399
|
function toggleReveal() {
|
|
@@ -1414,7 +1415,7 @@ function SecretRow({
|
|
|
1414
1415
|
const text =
|
|
1415
1416
|
shown !== null
|
|
1416
1417
|
? shown.value
|
|
1417
|
-
: fetchValue().
|
|
1418
|
+
: fetchValue().then(({ value }) => value, (failure: unknown) => {
|
|
1418
1419
|
read.failed = true;
|
|
1419
1420
|
read.failure = failure;
|
|
1420
1421
|
throw failure;
|
|
@@ -1444,9 +1445,9 @@ function SecretRow({
|
|
|
1444
1445
|
async function startEdit({ name = false } = {}) {
|
|
1445
1446
|
setFocusName(name);
|
|
1446
1447
|
setOpening(entry.value === null && canRead);
|
|
1447
|
-
const value = await valueToEdit(entry, () => readValue({ show: false }));
|
|
1448
|
+
const value = await valueToEdit(entry, () => readValue({ show: false }), (listed) => ({ value: listed, version: readVersion, from: readFrom, at: Date.now() }));
|
|
1448
1449
|
setOpening(false);
|
|
1449
|
-
if (value !== null) setBase(
|
|
1450
|
+
if (value !== null) setBase(value);
|
|
1450
1451
|
setReveal(null);
|
|
1451
1452
|
onEdit();
|
|
1452
1453
|
}
|
|
@@ -2153,7 +2154,7 @@ function SortHeader({
|
|
|
2153
2154
|
*/
|
|
2154
2155
|
function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays: number | null }) {
|
|
2155
2156
|
const { reference } = entry;
|
|
2156
|
-
const made = reference === null
|
|
2157
|
+
const made = reference?.createdBy == null || reference.createdAt === null
|
|
2157
2158
|
? undefined
|
|
2158
2159
|
: `Reference made by ${shownMember(reference.createdBy).replace(/^user:/, '')} on ${reference.createdAt.slice(0, 10)}`;
|
|
2159
2160
|
if (entry.updatedAt === null) {
|
|
@@ -2169,7 +2170,7 @@ function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays
|
|
|
2169
2170
|
{by.split('@')[0]}
|
|
2170
2171
|
</span>
|
|
2171
2172
|
) : (
|
|
2172
|
-
<span className="written-by cell-muted" title={`Its source's current version. ${made}`}>
|
|
2173
|
+
<span className="written-by cell-muted" title={made === undefined ? "Its source's current version" : `Its source's current version. ${made}`}>
|
|
2173
2174
|
source
|
|
2174
2175
|
</span>
|
|
2175
2176
|
)}
|
package/src/pages/login.tsx
CHANGED
|
@@ -66,10 +66,8 @@ function ProviderLoginPage({
|
|
|
66
66
|
const search = Route.useSearch();
|
|
67
67
|
const { next } = search;
|
|
68
68
|
// Shown once: a reload is a clean retry.
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const already = (once.with ?? '').split(',').map(label).filter((name): name is string => name !== undefined);
|
|
72
|
-
const message = signinErrorMessage(once.error, { providers: already, via: once.via === undefined ? undefined : label(once.via) });
|
|
69
|
+
const { error } = useOneTime(search, ['error']);
|
|
70
|
+
const message = signinErrorMessage(error);
|
|
73
71
|
const [leaving, setLeaving] = useState<string | null>(null);
|
|
74
72
|
const query = next === undefined ? '' : `?next=${encodeURIComponent(next)}`;
|
|
75
73
|
|