@le-space/build-journey 0.12.11 → 0.12.13

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/README.md CHANGED
@@ -27,7 +27,16 @@ Plain ES modules, no DOM, no network; runs in a browser and in Node.
27
27
  - `substeps({ stations, station, current, facts, done })`: the small steps,
28
28
  each `done`, `active` or `next`.
29
29
  - `flowNow({ stations, station, facts, fetchPct })`: the path through the
30
- places and what it carries.
30
+ places, what it carries, and its `kind`: `data` (pieces, drawn as dots),
31
+ `key` (the passphrase that seals, the key that unlocks a VM) or `report`
32
+ (an attestation report), drawn as a key or a shield travelling alone.
33
+ - `marksNow({ stations, station, facts, builder, done })`: what happened
34
+ where, as icons on the places with a note under each: the hardware's
35
+ measurement at the node and the browser's check of it (`ok` false when it
36
+ is not one the app pins), the key that seals the image in the node, the
37
+ fetch's connections each checked, the STORE signed in the browser and
38
+ stored on Aleph, and a start station's VM measured, checked and unlocked.
39
+ Only what a report says happened, or what happens now (`now`, blinking).
31
40
  - `fetchPercent`, `fetchRate` (MiB/s).
32
41
  - `evidence(facts, builder, links)`: the rows to check, with links: source
33
42
  commit, plain image SHA-256 (its STORE), expected measurement (where the
@@ -61,7 +70,8 @@ Plain ES modules, no DOM, no network; runs in a browser and in Node.
61
70
  ```
62
71
 
63
72
  Stations with their LEDs, the small steps of the current one, the animated
64
- picture of what flows where, the evidence with links and the hardware behind
73
+ picture of what flows where (with keys, checks and measurements where they
74
+ happen), the evidence with links and the hardware behind
65
75
  it, the total bar with the time left and when it ends, a slim bar when
66
76
  minimised, the finale, and when it stopped: where, and `reason`. While it
67
77
  runs it holds a Wake Lock (`wakeLock={false}` when the app holds one), asks
@@ -90,8 +100,11 @@ Keys (`{var}` the values handed in):
90
100
  - `attested` `{count}`, `mib` `{got, size}`, `rate` `{rate}`, `attempt` `{n, of}`,
91
101
  `retryNote`, `fetched` `{pct}`
92
102
  - `flowTitle`, `flow.program|report|passphrase|pieces|image` (a start:
93
- `instance|vmReport|backup`), `places.<key>` (`browser relay node aleph`, and
103
+ `instance|vmReport|unlockKey|backup`), `places.<key>` (`browser relay node aleph`, and
94
104
  any the app adds)
105
+ - `marks.measuring|measured|attested|mismatch|sealing|sealed|lanes` `{count}`
106
+ `|signing|signed|stored` (a start: `vmMeasuring|vmMeasured|vmAttested|unlocking|unlocked`):
107
+ the notes on the picture; on a narrow screen they stand as a list under it
95
108
  - `evidenceTitle`, `evidence.commit|plain|expected|vprogram|node|relay|measured|cid|store|instance|vmMeasured`,
96
109
  `matches`, `evidenceNone`, `evidenceNoneStopped`, `hardwareTitle`, `hardware.sev|epyc`
97
110
  - `share` `{pct}`, `left` `{minutes}`, `endsAt` `{time}`, `keepOpen`, `cameBack` `{seconds}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/build-journey",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "description": "The build of a sealed image (@le-space/sealed-image) as a journey in stations: a pure model (stations, facts, time left, small steps, flow, evidence) and a Svelte 5 view of it, with each app's words, stations and pins handed in.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  fetchRate,
23
23
  flowNow,
24
24
  journey,
25
+ marksNow,
25
26
  minutes,
26
27
  onPath,
27
28
  pathOf,
@@ -105,6 +106,17 @@
105
106
  );
106
107
  const steps = $derived(substeps({ stations: all, station: current, facts, done: view.done }));
107
108
  const flow = $derived(flowNow({ stations: all, station: current, facts, fetchPct }));
109
+ // A key or a report travels alone, drawn as itself; pieces as dots.
110
+ const carried = $derived(flow.kind === 'key' || flow.kind === 'report');
111
+ // What happened where: keys, checks, measurements, signatures (marksNow).
112
+ const marks = $derived(marksNow({ stations: all, station: current, facts, builder, done: view.done }));
113
+ /** The marks of a place, and the one whose words stand under it: what happens now, else the latest. @param {string} p */
114
+ const marksAt = (p) => marks.filter((m) => m.at === p);
115
+ /** @param {string} p */
116
+ const noteAt = (p) => {
117
+ const here = marksAt(p);
118
+ return here.find((m) => m.now) ?? here[here.length - 1];
119
+ };
108
120
  const fetched = $derived(current === 'fetch' ? (fetchPercent(facts) ?? fetchPct) : null);
109
121
  const rate = $derived(fetchRate(facts, now));
110
122
  const ends = $derived(new Date(j.ends).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' }));
@@ -382,26 +394,72 @@
382
394
  />
383
395
  {/if}
384
396
  {/each}
385
- {#key pathD}
386
- {#each [0, 0.6, 1.2] as delay (delay)}
387
- <circle r="6" class="packet" opacity="0"
388
- ><set attributeName="opacity" to="1" begin="{delay}s" /><animateMotion
389
- dur="1.8s"
390
- begin="{delay}s"
391
- repeatCount="indefinite"
392
- path={pathD}
393
- /></circle
394
- >
395
- {/each}
397
+ {#key pathD + flow.kind}
398
+ {#if !carried}
399
+ {#each [0, 0.6, 1.2] as delay (delay)}
400
+ <circle r="6" class="packet" opacity="0"
401
+ ><set attributeName="opacity" to="1" begin="{delay}s" /><animateMotion
402
+ dur="1.8s"
403
+ begin="{delay}s"
404
+ repeatCount="indefinite"
405
+ path={pathD}
406
+ /></circle
407
+ >
408
+ {/each}
409
+ {/if}
396
410
  {/key}
397
411
  {#each Object.entries(places) as [p, [cx, cy]] (p)}
412
+ {@const note = noteAt(p)}
398
413
  <g class="place" class:hot={flow.path.includes(p)}>
399
414
  <rect x={cx - 86} y={cy - 18} width="172" height="36" rx="10" />
400
415
  <circle cx={cx - 70} {cy} r="5" class="lamp" class:blink={flow.path.includes(p)} />
401
416
  <text x={cx - 58} y={cy + 5}>{text(`places.${p}`)}</text>
417
+ {#each marksAt(p) as m, i (m.kind)}
418
+ <g
419
+ transform="translate({cx + 72 - i * 27} {cy - 18})"
420
+ data-testid="{testid}-mark-{p}-{m.kind}"
421
+ data-state={m.now ? 'now' : m.ok === false ? 'bad' : 'done'}
422
+ >
423
+ <g class="mark {m.kind}" class:live={m.now} class:failed={m.ok === false}>
424
+ <title>{text(m.label, m.vars)}</title>
425
+ <circle r="11" />
426
+ {@render icon(m.kind)}
427
+ </g>
428
+ </g>
429
+ {/each}
430
+ {#if note && text(note.label, note.vars)}
431
+ <text class="note" class:live={note.now} class:failed={note.ok === false} x={cx} y={cy + 34} text-anchor="middle"
432
+ >{text(note.label, note.vars)}{note.ok === true ? ' ✓' : note.ok === false ? ' ✗' : ''}</text
433
+ >
434
+ {/if}
402
435
  </g>
403
436
  {/each}
437
+ {#if carried}
438
+ <!-- A key or a report travels alone, as itself, above the places. -->
439
+ {#key pathD + flow.kind}
440
+ <g class="carrier {flow.kind}" data-testid="{testid}-carrier" data-kind={flow.kind} opacity="0"
441
+ ><set attributeName="opacity" to="1" begin="0s" /><circle r="13" />{@render icon(flow.kind === 'key' ? 'key' : 'attest')}<animateMotion
442
+ dur="2.4s"
443
+ repeatCount="indefinite"
444
+ path={pathD}
445
+ /></g
446
+ >
447
+ {/key}
448
+ {/if}
404
449
  </svg>
450
+ {#if marks.length}
451
+ <!-- The same notes as words, for a narrow screen and for a screen reader. -->
452
+ <ul class="marks-list" data-testid="{testid}-marks">
453
+ {#each marks as m (m.at + m.kind)}
454
+ {#if text(m.label, m.vars)}
455
+ <li class:live={m.now} class:failed={m.ok === false} data-kind={m.kind}>
456
+ <svg viewBox="-12 -12 24 24" aria-hidden="true" class="mark {m.kind}"><circle r="11" />{@render icon(m.kind)}</svg>
457
+ <span>{text(`places.${m.at}`)}: {text(m.label, m.vars)}{m.ok === true ? ' ✓' : m.ok === false ? ' ✗' : ''}</span>
458
+ </li>
459
+ {/if}
460
+ {/each}
461
+ </ul>
462
+ {/if}
405
463
  {#if flow.share != null}<span class="bar"
406
464
  ><span class="fill" style="width: {Math.round(flow.share * 100)}%"></span></span
407
465
  >{/if}
@@ -461,6 +519,22 @@
461
519
  </div>
462
520
  {/if}
463
521
 
522
+ {#snippet icon(/** @type {string} */ kind)}
523
+ <g class="glyph">
524
+ {#if kind === 'key'}
525
+ <circle cx="-3" cy="0" r="3.2" /><path d="M0.2 0H6.5M4.2 0v3M6.5 0v2.4" />
526
+ {:else if kind === 'attest'}
527
+ <path d="M0 -6.5L5.2 -4.4V0.4C5.2 3.6 2.6 5.6 0 6.6C-2.6 5.6 -5.2 3.6 -5.2 0.4V-4.4Z" /><path d="M-2.3 0.2L-0.6 1.9L2.5 -1.4" />
528
+ {:else if kind === 'measure'}
529
+ <path d="M-5.6 3A5.8 5.8 0 1 1 5.6 3" /><path d="M0 2.2L3 -3" /><circle cx="0" cy="2.2" r="1" />
530
+ {:else if kind === 'sign'}
531
+ <path d="M-4.6 4.6L-3.9 1.6L2.6 -4.9L4.9 -2.6L-1.6 3.9Z" />
532
+ {:else}
533
+ <path d="M-4.2 0.2L-1.2 3.2L4.6 -3" />
534
+ {/if}
535
+ </g>
536
+ {/snippet}
537
+
464
538
  <style>
465
539
  .bj-overlay {
466
540
  position: fixed;
@@ -717,6 +791,104 @@
717
791
  fill: #f5c76b;
718
792
  filter: drop-shadow(0 0 4px #f5c76b);
719
793
  }
794
+ .carrier circle,
795
+ .mark > circle {
796
+ fill: #0f2a2e;
797
+ stroke: #f5c76b;
798
+ stroke-width: 1.6;
799
+ }
800
+ .carrier.key circle {
801
+ filter: drop-shadow(0 0 6px #f5c76b);
802
+ }
803
+ .carrier.report circle {
804
+ stroke: #5eead4;
805
+ filter: drop-shadow(0 0 6px #5eead4);
806
+ }
807
+ .glyph * {
808
+ fill: none;
809
+ stroke: #f6f2ea;
810
+ stroke-width: 1.5;
811
+ stroke-linecap: round;
812
+ stroke-linejoin: round;
813
+ }
814
+ .carrier.key .glyph *,
815
+ .mark.key .glyph *,
816
+ .mark.sign .glyph * {
817
+ stroke: #f5c76b;
818
+ }
819
+ .carrier.report .glyph *,
820
+ .mark.attest .glyph *,
821
+ .mark.measure .glyph *,
822
+ .mark.store .glyph * {
823
+ stroke: #5eead4;
824
+ }
825
+ .mark > circle {
826
+ stroke: rgba(94, 234, 212, 0.7);
827
+ }
828
+ .mark.key > circle,
829
+ .mark.sign > circle {
830
+ stroke: rgba(245, 199, 107, 0.8);
831
+ }
832
+ .mark {
833
+ transform-box: fill-box;
834
+ transform-origin: center;
835
+ animation: pop 0.5s ease-out both;
836
+ }
837
+ .mark.live > circle {
838
+ animation: blink 1.2s ease-in-out infinite;
839
+ }
840
+ .mark.failed > circle {
841
+ stroke: #f87171;
842
+ }
843
+ .mark.failed .glyph * {
844
+ stroke: #f87171;
845
+ }
846
+ .place .note {
847
+ fill: rgba(94, 234, 212, 0.95);
848
+ font-size: 12px;
849
+ font-weight: 600;
850
+ }
851
+ .place .note.live {
852
+ fill: #f5c76b;
853
+ }
854
+ .place .note.failed {
855
+ fill: #f87171;
856
+ }
857
+ .marks-list {
858
+ display: none;
859
+ list-style: none;
860
+ margin: 0;
861
+ padding: 0;
862
+ flex-direction: column;
863
+ gap: 0.35rem;
864
+ font-size: 0.85rem;
865
+ color: rgba(94, 234, 212, 0.95);
866
+ }
867
+ .marks-list li {
868
+ display: flex;
869
+ align-items: center;
870
+ gap: 0.5rem;
871
+ }
872
+ .marks-list li.live {
873
+ color: #f5c76b;
874
+ }
875
+ .marks-list li.failed {
876
+ color: #f87171;
877
+ }
878
+ .marks-list svg {
879
+ width: 22px;
880
+ height: 22px;
881
+ flex: none;
882
+ overflow: visible;
883
+ }
884
+ @media (max-width: 640px) {
885
+ .marks-list {
886
+ display: flex;
887
+ }
888
+ .place .note {
889
+ display: none;
890
+ }
891
+ }
720
892
  .place rect {
721
893
  fill: #133a3f;
722
894
  stroke: rgba(246, 242, 234, 0.2);
@@ -1055,10 +1227,13 @@
1055
1227
  .shimmer,
1056
1228
  .done .circle,
1057
1229
  .led.blink,
1058
- .lamp.blink {
1230
+ .lamp.blink,
1231
+ .mark,
1232
+ .mark.live > circle {
1059
1233
  animation: none;
1060
1234
  }
1061
1235
  .packet,
1236
+ .carrier,
1062
1237
  .spark {
1063
1238
  display: none;
1064
1239
  }
package/src/model.mjs CHANGED
@@ -22,8 +22,19 @@
22
22
 
23
23
  /**
24
24
  * What flows where right now: the path (place keys in order), what it
25
- * carries, and how far it is (0–1) when that is known.
26
- * @typedef {{ path: string[], what: string, share: number | null }} Flow
25
+ * carries, how far it is (0–1) when that is known, and its kind: `data`
26
+ * (pieces), `key` (a secret on its way, drawn as a key) or `report` (an
27
+ * attestation report, drawn as a shield).
28
+ * @typedef {{ path: string[], what: string, share: number | null, kind?: 'data' | 'key' | 'report' }} Flow
29
+ */
30
+
31
+ /**
32
+ * Something that happened at a place, for the picture: a key arrived or
33
+ * signed (`key`, `sign`), a report was checked (`attest`), the hardware
34
+ * measured (`measure`), Aleph stored (`store`). `label` is a text key
35
+ * (`marks.<…>`) with `vars`; `ok` false when the check failed; `now` while
36
+ * it is happening.
37
+ * @typedef {{ at: string, kind: 'key' | 'sign' | 'attest' | 'measure' | 'store', label: string, vars?: Record<string, any>, ok?: boolean, now?: boolean }} Mark
27
38
  */
28
39
 
29
40
  /**
@@ -33,7 +44,8 @@
33
44
  * key: string,
34
45
  * typical: number,
35
46
  * steps?: (f: Facts) => [string, boolean][],
36
- * flow?: (f: Facts) => Flow
47
+ * flow?: (f: Facts) => Flow,
48
+ * marks?: (f: Facts, current: boolean) => Mark[]
37
49
  * }} Station
38
50
  */
39
51
 
@@ -62,8 +74,10 @@ export const START_STEPS = Object.freeze(['measure', 'instance', 'network', 'unl
62
74
  /**
63
75
  * A station after the build: the VM started from the sealed image. Its small
64
76
  * steps follow `facts.vmStep` (one of START_STEPS); its flow shows the order
65
- * for the VM, the VM's report, and at `ready` the restore from `restoreFrom`
66
- * when given (a place key, e.g. 'filecoin').
77
+ * for the VM, the VM's report, once the browser has checked it the key that
78
+ * unlocks the VM, and at `ready` the restore from `restoreFrom` when given (a
79
+ * place key, e.g. 'filecoin'). Its marks: the VM's measurement, checked in
80
+ * the browser, and the key in the VM.
67
81
  * @param {{ key?: string, typical?: number, restoreFrom?: string | null }} [o]
68
82
  * @returns {Station}
69
83
  */
@@ -78,10 +92,26 @@ export function startStation({ key = 'start', typical = 600, restoreFrom = null
78
92
  ]),
79
93
  flow: (f) =>
80
94
  f.vmStep === 'unlock'
81
- ? { path: ['node', 'relay', 'browser'], what: 'vmReport', share: null }
95
+ ? f.vmMeasurement
96
+ ? { path: ['browser', 'relay', 'node'], what: 'unlockKey', share: null, kind: 'key' }
97
+ : { path: ['node', 'relay', 'browser'], what: 'vmReport', share: null, kind: 'report' }
82
98
  : f.vmStep === 'ready' && restoreFrom
83
- ? { path: [restoreFrom, 'node'], what: 'backup', share: null }
84
- : { path: ['browser', 'aleph', 'node'], what: 'instance', share: null }
99
+ ? { path: [restoreFrom, 'node'], what: 'backup', share: null, kind: 'data' }
100
+ : { path: ['browser', 'aleph', 'node'], what: 'instance', share: null, kind: 'data' },
101
+ marks: (f, current) => {
102
+ const at = f.vmStep ? START_STEPS.indexOf(f.vmStep) : -1;
103
+ /** @type {Mark[]} */
104
+ const out = [];
105
+ if (f.vmMeasurement) {
106
+ out.push({ at: 'node', kind: 'measure', label: 'marks.vmMeasured', ok: true });
107
+ out.push({ at: 'browser', kind: 'attest', label: 'marks.vmAttested', ok: true });
108
+ } else if (current && f.vmStep === 'unlock')
109
+ out.push({ at: 'node', kind: 'measure', label: 'marks.vmMeasuring', now: true });
110
+ if (at > START_STEPS.indexOf('unlock')) out.push({ at: 'node', kind: 'key', label: 'marks.unlocked' });
111
+ else if (current && f.vmStep === 'unlock' && f.vmMeasurement)
112
+ out.push({ at: 'node', kind: 'key', label: 'marks.unlocking', now: true });
113
+ return out;
114
+ }
85
115
  };
86
116
  }
87
117
 
@@ -243,14 +273,52 @@ export function substeps({ stations = BUILD_STATIONS, station, current = station
243
273
  export function flowNow({ stations = BUILD_STATIONS, station, facts = {}, fetchPct = null }) {
244
274
  const own = stations.find((x) => x.key === station)?.flow;
245
275
  if (own) return own(facts);
246
- if (station === 'wake') return { path: ['browser', 'aleph', 'node'], what: 'program', share: null };
247
- if (station === 'check') return { path: ['node', 'relay', 'browser'], what: 'report', share: null };
248
- if (station === 'seal') return { path: ['browser', 'relay', 'node'], what: 'passphrase', share: null };
276
+ if (station === 'wake') return { path: ['browser', 'aleph', 'node'], what: 'program', share: null, kind: 'data' };
277
+ if (station === 'check') return { path: ['node', 'relay', 'browser'], what: 'report', share: null, kind: 'report' };
278
+ if (station === 'seal') return { path: ['browser', 'relay', 'node'], what: 'passphrase', share: null, kind: 'key' };
249
279
  if (station === 'fetch') {
250
280
  const pct = fetchPercent(facts) ?? fetchPct;
251
- return { path: ['node', 'relay', 'browser'], what: 'pieces', share: pct == null ? null : pct / 100 };
281
+ return { path: ['node', 'relay', 'browser'], what: 'pieces', share: pct == null ? null : pct / 100, kind: 'data' };
282
+ }
283
+ return { path: ['browser', 'aleph'], what: 'image', share: facts.processed ? 1 : null, kind: 'data' };
284
+ }
285
+
286
+ /**
287
+ * What happened where so far, for the picture: the hardware's measurement at
288
+ * the node and the browser's check of it, the key that seals the image in the
289
+ * node, the connections of the fetch each checked, the STORE signed in the
290
+ * browser and stored on Aleph; then what a station of the app's own adds.
291
+ * Only what a report says happened, or what happens in the current station
292
+ * (`now`). One mark per place and kind, the latest wins.
293
+ * @param {{ stations?: Station[], station: string, facts?: Facts, builder?: BuilderPin, done?: boolean }} a
294
+ * @returns {Mark[]}
295
+ */
296
+ export function marksNow({ stations = BUILD_STATIONS, station, facts: f = {}, builder = null, done = false }) {
297
+ const at = done ? stations.length : Math.max(0, indexOf(stations, station));
298
+ const past = (/** @type {string} */ key) => indexOf(stations, key) >= 0 && indexOf(stations, key) < at;
299
+ const here = (/** @type {string} */ key) => !done && key === station;
300
+ /** @type {Mark[]} */
301
+ const out = [];
302
+ if (f.measurement) {
303
+ const ok = !builder?.measurements?.length || builder.measurements.includes(f.measurement);
304
+ out.push({ at: 'node', kind: 'measure', label: 'marks.measured', ok });
305
+ out.push({ at: 'browser', kind: 'attest', label: ok ? 'marks.attested' : 'marks.mismatch', ok });
306
+ } else if (here('check')) out.push({ at: 'node', kind: 'measure', label: 'marks.measuring', now: true });
307
+ if (f.cid || past('seal')) out.push({ at: 'node', kind: 'key', label: 'marks.sealed' });
308
+ else if (here('seal')) out.push({ at: 'node', kind: 'key', label: 'marks.sealing', now: true });
309
+ if (f.attested && (here('fetch') || past('fetch')))
310
+ out.push({ at: 'browser', kind: 'attest', label: 'marks.lanes', vars: { count: f.attested }, ok: true, now: here('fetch') });
311
+ if (f.storeHash) out.push({ at: 'browser', kind: 'sign', label: 'marks.signed' });
312
+ else if (here('store')) out.push({ at: 'browser', kind: 'sign', label: 'marks.signing', now: true });
313
+ if (f.processed) out.push({ at: 'aleph', kind: 'store', label: 'marks.stored', ok: true });
314
+ for (const s of stations) if (s.marks && (s.key === station || past(s.key))) out.push(...s.marks(f, here(s.key)));
315
+ /** @type {Map<string, Mark>} */
316
+ const latest = new Map();
317
+ for (const m of out) {
318
+ latest.delete(`${m.at} ${m.kind}`);
319
+ latest.set(`${m.at} ${m.kind}`, m);
252
320
  }
253
- return { path: ['browser', 'aleph'], what: 'image', share: facts.processed ? 1 : null };
321
+ return [...latest.values()];
254
322
  }
255
323
 
256
324
  /**