merge: t2db.40 sources and signing into pg/foundation
Resolves against t2db.36: captures carry both event_type and unsigned (proto field 10), the State Store serves sources and event types from the Postgres EDA store, the capture row shows event type and signature together, and the staterpc sentinels map both ways from one table.
This commit is contained in:
63 files changed
+3839
-1753
No files matched your search
@@ -3,7 +3,9 @@ import { useMediaQuery } from "@vueuse/core";
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ago } from "@/lib/format";
|
||||
import { captureSignature } from "./capture-signature";
|
||||
import CapturePayload from "./CapturePayload.vue";
|
||||
import { selected } from "./state";
|
||||
|
||||
@@ -36,6 +38,8 @@ const stacked = useMediaQuery("(max-width: 1099px)");
|
||||
|
||||
const cap = computed(() => (stacked.value || !props.maxHeight ? undefined : `${props.maxHeight}px`));
|
||||
|
||||
const signature = computed(() => (selected.value ? captureSignature(selected.value) : null));
|
||||
|
||||
const meta = computed(() => {
|
||||
const capture = selected.value;
|
||||
if (!capture) return "";
|
||||
@@ -54,7 +58,10 @@ watch(selected, () => {
|
||||
<div v-if="selected" ref="pane" class="min-w-0">
|
||||
<Card class="flex flex-col" :style="cap ? { maxHeight: cap } : undefined">
|
||||
<CardHeader>
|
||||
<CardTitle class="font-mono">{{ selected.source || "Unknown source" }}</CardTitle>
|
||||
<CardTitle class="flex items-center gap-2 font-mono">
|
||||
{{ selected.source || "Unknown source" }}
|
||||
<Badge v-if="signature" :variant="signature.kind">{{ signature.label }}</Badge>
|
||||
</CardTitle>
|
||||
<CardDescription>{{ meta }}</CardDescription>
|
||||
</CardHeader>
|
||||
<!-- Stacked there is no sibling to be bound by, so the panel caps itself
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TableCell, TableRow } from "@/components/ui/table";
|
||||
import { ago } from "@/lib/format";
|
||||
import { eventTypes } from "./event-type-state";
|
||||
import { captureIdentity } from "./event-types";
|
||||
import { captureSignature } from "./capture-signature";
|
||||
import { selected, type Capture } from "./state";
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ const props = defineProps<{ capture: Capture }>();
|
||||
|
||||
const identity = computed(() => captureIdentity(props.capture, eventTypes.value));
|
||||
|
||||
const signature = computed(() => captureSignature(props.capture));
|
||||
const isSelected = computed(() => selected.value?.id === props.capture.id);
|
||||
|
||||
// The name is set here because role="button" makes the cells presentational:
|
||||
@@ -46,9 +48,12 @@ function open(): void {
|
||||
<TableCell :title="props.capture.received_at || ''">{{ ago(props.capture.received_at) }}</TableCell>
|
||||
<!-- An unidentified capture is never dispatched. -->
|
||||
<TableCell>
|
||||
<Badge :variant="identity.identified ? 'ok' : 'warn'" class="max-w-40">
|
||||
<span class="truncate">{{ identity.label }}</span>
|
||||
</Badge>
|
||||
<div class="flex items-center gap-1">
|
||||
<Badge :variant="identity.identified ? 'ok' : 'warn'" class="max-w-40">
|
||||
<span class="truncate">{{ identity.label }}</span>
|
||||
</Badge>
|
||||
<Badge :variant="signature.kind">{{ signature.label }}</Badge>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell class="font-mono">{{ props.capture.content_type || "—" }}</TableCell>
|
||||
<TableCell class="text-right">
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* How a capture may dispatch: signed by its source's secret, taken on a
|
||||
* source approved for unsigned events, or neither -- in which case nothing
|
||||
* starts from it.
|
||||
*/
|
||||
export interface CaptureSignature {
|
||||
label: "Signed" | "Unsigned" | "Unverified";
|
||||
kind: "ok" | "warn" | "idle";
|
||||
}
|
||||
|
||||
export function captureSignature(capture: { authenticated?: boolean; unsigned?: boolean }): CaptureSignature {
|
||||
if (capture.unsigned) return { label: "Unsigned", kind: "warn" };
|
||||
if (capture.authenticated) return { label: "Signed", kind: "ok" };
|
||||
return { label: "Unverified", kind: "idle" };
|
||||
}
|
||||
@@ -28,6 +28,7 @@ export interface Capture {
|
||||
authenticated?: boolean;
|
||||
/** The event type it was identified as on arrival; empty is unidentified. */
|
||||
event_type?: string;
|
||||
unsigned?: boolean;
|
||||
}
|
||||
|
||||
interface CapturesResponse {
|
||||
|
||||
Reference in new issue
Block a user