Warn about releases and artifacts by others

- Add an UntrustedWarning banner
- Warn on the Others releases list
- Warn on a release by a non-delegate
- Warn on artifacts by non-delegates on a delegate release
- Warn in the download popover for a non-delegate artifact
- Add E2E tests for both release cases

Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Daniel Norman
2026-10-08 18:21:48 +02:00
committed by Rūdolfs Ošiņš
co-authored by Rūdolfs Ošiņš
parent e930bfd397
commit f90db0986a
9 changed files with 1460 additions and 1319 deletions
+20 -11
View File
@@ -17,14 +17,13 @@
import ExternalLink from "@app/components/ExternalLink.svelte";
import Icon from "@app/components/Icon.svelte";
import Popover from "@app/components/Popover.svelte";
import UntrustedWarning from "@app/components/UntrustedWarning.svelte";
interface Props {
artifact: Artifact;
delegateIds: Set<string>;
releaseId: string;
rid: string;
/// Whether the node already seeds this artifact, asked of the node rather
/// than assumed from what this component did.
seeding: boolean;
onDownloaded: () => void;
}
@@ -40,8 +39,6 @@
let activeTab: "app" | "cli" | "browser" = $state("app");
let expanded = $state(false);
// Which transfer is running: a download writes to disk, a fetch only fills
// the node's store.
let running: "download" | "fetch" | undefined = $state();
let progress: ArtifactProgress | undefined = $state();
let downloadError: string | undefined = $state();
@@ -54,8 +51,6 @@
}
});
// Clear the outcome of a finished download once the popover closes, so a
// later visit starts fresh.
$effect(() => {
if (!expanded && !running) {
finished = undefined;
@@ -63,8 +58,6 @@
}
});
// The node reports byte movement per CID, so a shared event channel
// is filtered down to this artifact.
$effect(() => {
// Events only exist under Tauri, not against the test HTTP API.
if (!window.__TAURI_INTERNALS__) {
@@ -146,12 +139,13 @@
const webLocations = $derived(
releases.webLocations(artifact.locations, delegateIds),
);
// Any location at all can be fetched with the CLI, web locations included.
const authorTrusted = $derived(delegateIds.has(artifact.author.did));
const linksByOthers = $derived(
webLocations.some(l => !delegateIds.has(l.user.did)),
);
const downloadable = $derived(seeding || artifact.locations.length > 0);
const downloadLabel = $derived(seeding ? "Save" : "Download");
// The app and CLI tabs fetch through the artifact node, so they are only
// usable while it answers. The browser tab does not need it.
const nodeRunning = $derived($artifactNodeRunning);
const START_COMMAND = "rad-artifact node start";
const command = $derived(
@@ -171,6 +165,9 @@
.start-command {
margin-bottom: 0.75rem;
}
.untrusted {
margin-bottom: 0.75rem;
}
.tabs {
display: flex;
gap: 2px;
@@ -265,6 +262,12 @@
{#snippet popover()}
<div class="popover">
{#if !authorTrusted}
<div class="untrusted">
<UntrustedWarning
text="Not from a delegate. Only download if you trust the author." />
</div>
{/if}
<div class="tabs">
<Button
styleWidth="100%"
@@ -393,6 +396,12 @@
<Icon name="warning" />
These downloads are not checked against the CID.
</div>
{#if authorTrusted && linksByOthers}
<div class="untrusted">
<UntrustedWarning
text="Links without a delegate badge are not from a delegate. Only use them if you trust who added them." />
</div>
{/if}
<div class="locations">
{#each webLocations as location (`${location.user.did}:${location.url}`)}
<div class="location">
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
<script lang="ts">
import Icon from "@app/components/Icon.svelte";
interface Props {
text: string;
}
const { text }: Props = $props();
</script>
<style>
.banner {
display: flex;
align-items: center;
gap: 0.375rem;
color: var(--color-text-secondary);
font: var(--txt-body-s-regular);
}
.icon {
display: flex;
flex-shrink: 0;
color: var(--color-feedback-warning-text);
}
</style>
<div class="banner" role="note">
<span class="icon"><Icon name="warning" /></span>
<span>{text}</span>
</div>
+16 -21
View File
@@ -22,18 +22,12 @@ export function releaseListScope(
export interface ArtifactView {
scope: ReleaseScope;
shown: Artifact[];
// Redacted artifacts within the current author scope.
redactedCount: number;
// What each scope would show, so an artifact hidden as redacted never
// counts towards a scope.
counts: Record<ReleaseScope, number>;
// Filter only when both scopes hold something.
showFilters: boolean;
}
// Split a release's artifacts into two disjoint scopes by author. Show the
// scope asked for unless it is empty, and hide artifacts redacted by their
// author or a delegate unless asked to show them.
// Falls back to the other scope when the one asked for is empty.
export function artifactView(
artifacts: Artifact[],
delegates: Set<string>,
@@ -70,7 +64,6 @@ export function redactedByDelegate(
return artifact.redactions.some(r => delegates.has(r.user.did));
}
// Group locations by the contributing node, preserving order.
export function locationsByNode(
locations: Location[],
): { user: Author; urls: string[] }[] {
@@ -83,9 +76,7 @@ export function locationsByNode(
return [...groups.values()];
}
// Order a node-keyed list so delegates come first. The backend returns these
// sorted by DID (arbitrary to a reader); sort is stable, so the original
// order is preserved within each group.
// The backend sorts by DID, which means nothing to a reader.
export function delegatesFirst<T>(
items: T[],
did: (item: T) => string,
@@ -96,9 +87,6 @@ export function delegatesFirst<T>(
);
}
// Locations a browser can open, as opposed to ones fetched from a seeder
// over the radicle-artifact protocol. Delegate locations come first: they
// are the ones a reader can trust most.
export function webLocations(
locations: Location[],
delegates: Set<string>,
@@ -119,8 +107,6 @@ export function attestedBy(
return attestations.filter(a => delegates.has(a.did)).length;
}
// Only metadata by the author or a delegate is shown, so only they get an
// editor.
export function canEditMetadata(
artifact: Artifact,
ownDid: string,
@@ -140,9 +126,7 @@ export function canAttest(artifact: Artifact, ownDid: string): boolean {
);
}
// The COB stores values as free-form JSON. Text that parses as JSON is sent
// as that value, so numbers and booleans round-trip; anything else is sent
// as a plain string.
// Text that parses as JSON is sent as that value, so numbers round-trip.
export function parseMetadataValue(input: string): unknown {
try {
return JSON.parse(input);
@@ -155,8 +139,6 @@ export function displayMetadataValue(value: unknown): string {
return typeof value === "string" ? value : JSON.stringify(value);
}
// Commits whose SHA starts with, or whose summary contains, the query. A
// pasted commit outside the loaded history still shows as a choice.
export function matchCommits(
commits: Commit[],
query: string,
@@ -179,3 +161,16 @@ export function canonicalTags(refs: RepoRefs): { name: string; tag: Tag }[] {
.map(([name, tag]) => ({ name, tag }))
.sort((a, b) => b.tag.timestamp - a.tag.timestamp);
}
// A release by a non-delegate is untrusted as a whole. On a delegate's
// release, only the artifacts registered by others are.
export function releaseWarning(
creatorDid: string,
delegates: Set<string>,
artifactScope: ReleaseScope,
): "release" | "artifacts" | undefined {
if (!delegates.has(creatorDid)) {
return "release";
}
return artifactScope === "untrusted" ? "artifacts" : undefined;
}
File diff suppressed because it is too large Load Diff
+11
View File
@@ -17,6 +17,7 @@
import ReleaseTeaser from "@app/components/ReleaseTeaser.svelte";
import ScrollArea from "@app/components/ScrollArea.svelte";
import Topbar from "@app/components/Topbar.svelte";
import UntrustedWarning from "@app/components/UntrustedWarning.svelte";
import VirtualList from "@app/components/VirtualList.svelte";
import CreateReleaseModal from "@app/modals/CreateRelease.svelte";
@@ -85,6 +86,10 @@
.filter .global-counter-badge {
margin-left: 0.25rem;
}
.warning {
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--color-border-subtle);
}
.row {
border-bottom: 1px solid var(--color-border-subtle);
}
@@ -158,6 +163,12 @@
</div>
</div>
{:else}
{#if scope === "untrusted"}
<div class="warning">
<UntrustedWarning
text="Not from delegates. Only download from authors you trust." />
</div>
{/if}
<ScrollArea style="height: 100%; min-width: 0;">
<VirtualList
items={list.items}