commit dcd277990ae12610c82162619422ffdcdb4c1f42
parent 0de570c68567f16e175ca85ec416ed70216e0c67
Author: triesap <tyson@radroots.org>
Date: Fri, 9 Oct 2026 19:58:34 +0000
web: wire conversation options and safe private context access (HCP-105)
- Resolve identity and citation selectors against the original current private room
- Verify public listing coordinates and included versions only on user action
- Keep incomplete head and withdrawal coverage visibly last-known and unresolved
- Retain genuine expiry regression and exact independent source acceptance
Diffstat:
13 files changed, 1405 insertions(+), 29 deletions(-)
diff --git a/web/src/lib/components/ConversationOptions.svelte b/web/src/lib/components/ConversationOptions.svelte
@@ -0,0 +1,65 @@
+<script lang="ts">
+ import { onMount } from 'svelte';
+ import {
+ subscribeInboxView,
+ type InboxView
+ } from '../messaging/inbox-view.ts';
+ import {
+ conversationOptionsSnapshot,
+ requestConversationOption
+ } from '../messaging/cited-product.ts';
+ let {
+ controller,
+ conversationId,
+ onblock,
+ onreport
+ }: {
+ controller: InboxView;
+ conversationId: string;
+ onblock?: (peer: string) => void;
+ onreport?: (peer: string) => void;
+ } = $props();
+ let revision = $state(0);
+ const actual = $derived.by(() => {
+ void revision;
+ return conversationOptionsSnapshot(controller, conversationId);
+ });
+ onMount(() =>
+ subscribeInboxView(controller, () => {
+ revision++;
+ })
+ );
+</script>
+
+{#if actual}
+ <details>
+ <summary>Identity and conversation options</summary>
+ <p>Authenticated conversation peer: {actual.peer}</p>
+ {#if onblock}<button
+ type="button"
+ onclick={() => {
+ if (onblock)
+ requestConversationOption(
+ controller,
+ conversationId,
+ 'block',
+ onblock,
+ 'reviewed_conversation_option'
+ );
+ }}>Block person</button
+ >{/if}
+ {#if onreport}<button
+ type="button"
+ onclick={() => {
+ if (onreport)
+ requestConversationOption(
+ controller,
+ conversationId,
+ 'report',
+ onreport,
+ 'reviewed_conversation_option'
+ );
+ }}>Report conversation</button
+ >{/if}
+ </details>
+{/if}
diff --git a/web/src/lib/components/ConversationThread.svelte b/web/src/lib/components/ConversationThread.svelte
@@ -3,6 +3,7 @@
import InboxStatus from './InboxStatus.svelte';
import Button from './primitives/Button.svelte';
import MessageItem from './MessageItem.svelte';
+ import ConversationOptions from './ConversationOptions.svelte';
import MessageComposer from './MessageComposer.svelte';
import {
createReplyController,
@@ -52,8 +53,8 @@
readProblem = $state(false),
retryRevision = $state(0),
displayedPending = $state(false);
- let runtime: PublicRuntime | undefined,
- off = () => {},
+ let runtime = $state.raw<PublicRuntime | undefined>();
+ let off = () => {},
initialized = false,
previous = Array.from<string>([]),
attempted = Array.from<string>([]),
@@ -191,10 +192,12 @@
<div class="page page--reading stack">
<h2>Conversation</h2>
{#if owned && model.status === 'ready'}
+ <ConversationOptions controller={owned} {conversationId} />
{#each model.messages as message (message.data.rumorId)}<MessageItem
controller={owned}
{conversationId}
{message}
+ {runtime}
onreply={replyTo}
/>{/each}
{#if reply}{#key reply}<MessageComposer
diff --git a/web/src/lib/components/MessageItem.svelte b/web/src/lib/components/MessageItem.svelte
@@ -1,6 +1,24 @@
+<script module lang="ts">
+ declare function setInterval(
+ callback: () => void,
+ milliseconds: number
+ ): number;
+ declare function clearInterval(timer: number): void;
+</script>
+
<script lang="ts">
+ import { onMount, untrack } from 'svelte';
+ import type { PublicRuntime } from '../runtime/public-runtime.ts';
+ import {
+ captureCitedProduct,
+ citedProductSnapshot,
+ closeCitedProduct,
+ type CitedProduct
+ } from '../messaging/cited-product.ts';
import {
inboxMessageSnapshot,
+ inboxThreadRevision,
+ subscribeInboxView,
type InboxView
} from '../messaging/inbox-view.ts';
import type { ThreadMessage } from '../messaging/conversation-thread.ts';
@@ -9,20 +27,68 @@
controller,
conversationId,
message,
- onreply
+ onreply,
+ runtime
}: {
controller: InboxView;
conversationId: string;
message: ThreadMessage;
onreply?: (parent: string) => void;
+ runtime?: PublicRuntime;
} = $props();
// Copied rows select only a hash. Render fresh current original room bytes.
- const current = $derived(
- inboxMessageSnapshot(controller, conversationId, message.data.rumorId)
- );
+ let observation = $state(0);
+ const current = $derived.by(() => {
+ void observation;
+ return inboxMessageSnapshot(
+ controller,
+ conversationId,
+ message.data.rumorId
+ );
+ });
+ $effect(() => {
+ const view = controller;
+ let previous = -2,
+ changes = 0;
+ return untrack(() =>
+ subscribeInboxView(view, () => {
+ const next = inboxThreadRevision(view);
+ if (next === previous) return;
+ previous = next;
+ changes += 1;
+ observation = changes;
+ })
+ );
+ });
const time = $derived(
current ? new Date(current.data.createdAt * 1000) : undefined
);
+ let citation = $state.raw<CitedProduct | undefined>(),
+ context = $state<ReturnType<typeof citedProductSnapshot>>();
+ function verify(value: string) {
+ if (citation) closeCitedProduct(citation);
+ citation =
+ current && runtime
+ ? captureCitedProduct(
+ controller,
+ conversationId,
+ current.data.rumorId,
+ value,
+ runtime,
+ 'reviewed_product_citation'
+ )
+ : undefined;
+ context = citation ? citedProductSnapshot(citation) : undefined;
+ }
+ onMount(() => {
+ const timer = setInterval(() => {
+ if (citation) context = citedProductSnapshot(citation);
+ }, 250);
+ return () => {
+ clearInterval(timer);
+ if (citation) closeCitedProduct(citation);
+ };
+ });
</script>
{#if current}
@@ -49,7 +115,31 @@
>Product citation: {citation.identifier || 'listing'} (unverified)</a
>
</p>
+ {#if runtime}<button type="button" onclick={() => verify(citation.naddr)}
+ >Verify product citation</button
+ >{/if}
{/each}
+ {#if context}
+ {#if context.outcome === 'checking'}<p>Checking listing citation…</p>
+ {:else if context.outcome === 'withdrawn'}<p>Listing is withdrawn</p>
+ {:else if context.food}<p>{context.food.title}</p>
+ <p>
+ {context.outcome === 'sold'
+ ? 'Listing is sold'
+ : 'Signed listing observed'}
+ </p>
+ {:else}<p>Listing citation remains unresolved</p>{/if}
+ {#if context.lastKnownFood}<p>{context.lastKnownFood.title}</p>
+ <p>
+ Last-known signed listing; current head and withdrawal checks are
+ incomplete.
+ </p>{/if}
+ {#if context.includedVersion === 'matched'}<p>
+ Included version verified
+ </p>{:else if context.includedVersion === 'different'}<p>
+ Included version differs from the observed listing
+ </p>{/if}
+ {/if}
{#if current.citations.length || /quoted price/i.test(current.data.content)}<p
class="text-small"
>
@@ -62,7 +152,12 @@
type="button"
class="button button--secondary"
onclick={() => {
- if (current) onreply?.(current.data.rumorId);
+ const actual = inboxMessageSnapshot(
+ controller,
+ conversationId,
+ message.data.rumorId
+ );
+ if (actual) onreply?.(actual.data.rumorId);
}}>Reply to this message</button
>{/if}
</article>
diff --git a/web/src/lib/messaging/cited-product.ts b/web/src/lib/messaging/cited-product.ts
@@ -0,0 +1,285 @@
+import { includedProductVersion } from '../nostr/enquiry-references.ts';
+import { PUBLIC_QUERY_BUDGETS } from '../config/budgets.ts';
+import { decodeProductReference } from '../nostr/references.ts';
+import {
+ inboxMessageSnapshot,
+ inboxReplyOwnership,
+ inboxThreadSnapshot,
+ type InboxReplyOwnership,
+ type InboxView
+} from './inbox-view.ts';
+import {
+ createPublicView,
+ beginPublicViewRun,
+ disposePublicView,
+ publicViewRunCurrent,
+ publicViewOwnsRun,
+ publicViewProjectionAvailable,
+ subscribePublicView,
+ type PublicView,
+ type PublicRuntime
+} from '../runtime/public-runtime.ts';
+import {
+ publicRequestScopeSnapshot,
+ type PublicRequest
+} from '../nostr/request-scope.ts';
+import {
+ createPublicHeadCandidate,
+ publicHeadSnapshot,
+ selectPublicHead,
+ type PublicHead
+} from '../catalog/heads.ts';
+import {
+ createPublicViewHeadResolver,
+ headResolutionSnapshot,
+ resolveHeads,
+ closeHeadResolver
+} from '../catalog/resolve-head.ts';
+import { subscribePrivateSessionClose } from '../runtime/private-session.ts';
+import { subscribeIdentityInvalidation } from '../runtime/identity-session.ts';
+import type { FoodProjection } from '../contracts/food-availability-v1/read.ts';
+
+declare const citedBrand: unique symbol;
+export type CitedProduct = Readonly<{ [citedBrand]: true }>;
+type Snapshot = Readonly<{
+ outcome: 'checking' | 'unresolved' | 'active' | 'sold' | 'withdrawn';
+ food?: FoodProjection;
+ lastKnownFood?: FoodProjection;
+ includedVersion: 'none' | 'unverified' | 'matched' | 'different';
+}>;
+const owners = new WeakMap<
+ CitedProduct,
+ { snapshot(): Snapshot | undefined; close(): void }
+>();
+
+export function conversationOptionsSnapshot(
+ view: InboxView,
+ id: string
+): Readonly<{ peer: string }> | undefined {
+ const thread = inboxThreadSnapshot(view, id);
+ for (const row of thread.messages) {
+ const original = inboxReplyOwnership(view, id, row.data.rumorId);
+ if (original?.current()) return { peer: original.peer };
+ }
+ return undefined;
+}
+export function requestConversationOption(
+ view: InboxView,
+ id: string,
+ action: 'block' | 'report',
+ invoke: (peer: string) => void,
+ review: unknown
+): boolean {
+ if (
+ review !== 'reviewed_conversation_option' ||
+ (action !== 'block' && action !== 'report')
+ )
+ return false;
+ const actual = conversationOptionsSnapshot(view, id);
+ if (!actual) return false;
+ invoke(actual.peer);
+ return true;
+}
+
+// Neither a copied row nor a body pointer is authority. Resolve the selector
+// against the current original private room before allocating an anonymous view.
+export function captureCitedProduct(
+ inbox: InboxView,
+ id: string,
+ rumor: string,
+ value: unknown,
+ runtime: PublicRuntime,
+ review: unknown
+): CitedProduct | undefined {
+ if (typeof window === 'undefined' || review !== 'reviewed_product_citation')
+ return undefined;
+ const original = inboxReplyOwnership(inbox, id, rumor),
+ message = inboxMessageSnapshot(inbox, id, rumor),
+ decoded = decodeProductReference(value);
+ if (
+ !original?.current() ||
+ !message ||
+ !decoded ||
+ !message.citations.some((row) => row.naddr === decoded.naddr) ||
+ ![original.owner, original.peer].includes(decoded.pubkey)
+ )
+ return undefined;
+ const reference = decoded;
+ const privateIds = inboxThreadSnapshot(inbox, id).messages.flatMap((row) => [
+ row.data.rumorId,
+ ...(row.data.replyTo ? [row.data.replyTo] : [])
+ ]);
+ if (privateIds.includes(reference.identifier)) return undefined;
+ let versions = Array.from<string>([]);
+ for (const match of message.data.content.matchAll(
+ /\b(nevent1[023456789acdefghjklmnpqrstuvwxyz]+)\b/gi
+ )) {
+ const version = includedProductVersion(match[1], reference.pubkey);
+ if (version && !privateIds.includes(version) && !versions.includes(version))
+ versions = versions.concat(version);
+ }
+ const exactId = versions.length === 1 ? versions[0] : undefined;
+ let view: PublicView;
+ try {
+ view = createPublicView(runtime);
+ } catch {
+ return undefined;
+ }
+ const run = beginPublicViewRun(view),
+ resolver = createPublicViewHeadResolver(view, run, {
+ nowSeconds: () => Math.floor(Date.now() / 1000)
+ });
+ let closed = false,
+ failed = false,
+ head: PublicHead | undefined,
+ exact: string | undefined;
+ let privateScope: InboxReplyOwnership | undefined = original;
+ const requests = new Map<PublicRequest, true>();
+ let offPrivate = () => {},
+ offIdentity = () => {};
+ function close() {
+ if (closed) return;
+ closed = true;
+ privateScope = undefined;
+ offPrivate();
+ offIdentity();
+ try {
+ closeHeadResolver(resolver);
+ } finally {
+ disposePublicView(view);
+ }
+ }
+ const owned = () =>
+ !closed &&
+ !!privateScope?.current() &&
+ !!inboxMessageSnapshot(inbox, id, rumor) &&
+ publicViewProjectionAvailable(view) &&
+ publicViewOwnsRun(view, run);
+ const current = () => owned() && publicViewRunCurrent(view, run);
+ const token = Object.freeze({}) as CitedProduct;
+ owners.set(token, {
+ close,
+ snapshot() {
+ if (!owned()) {
+ close();
+ return undefined;
+ }
+ const row = headResolutionSnapshot(resolver)[0],
+ scopes = Array.from(requests.keys(), publicRequestScopeSnapshot);
+ const pending =
+ current() &&
+ [
+ ...scopes,
+ ...(row?.headSources ? [row.headSources] : []),
+ ...(row?.deletionSources ? [row.deletionSources] : [])
+ ].some((scope) => scope.state === 'active');
+ const suppressed = row?.deletion.outcome === 'suppressed';
+ // A retained signed head is not a completed coordinate/withdrawal read.
+ // Original source coverage must remain honest after ordinary run expiry.
+ const complete =
+ row?.coverage === 'bounded-eose' &&
+ !row.lastKnown &&
+ scopes.length > 0 &&
+ scopes.every(
+ (scope) =>
+ scope.state === 'eose' && scope.result.coverage === 'bounded-eose'
+ );
+ const food =
+ !suppressed && !pending && !failed && complete
+ ? row?.state.food
+ : undefined;
+ return {
+ outcome: suppressed
+ ? 'withdrawn'
+ : pending
+ ? 'checking'
+ : food
+ ? food.status
+ : 'unresolved',
+ food,
+ lastKnownFood:
+ !suppressed && !pending && !food ? row?.state.food : undefined,
+ includedVersion: !exactId
+ ? 'none'
+ : !exact || !food
+ ? 'unverified'
+ : exact === row?.state.head.id
+ ? 'matched'
+ : 'different'
+ };
+ }
+ });
+ offPrivate = subscribePrivateSessionClose(original.session, close);
+ offIdentity = subscribeIdentityInvalidation(original.identity, close);
+ function admit(
+ proof: Parameters<typeof createPublicHeadCandidate>[0],
+ exactOnly: boolean
+ ) {
+ if (!current()) return;
+ const candidate = createPublicHeadCandidate(proof);
+ if (!candidate) return;
+ const data = publicHeadSnapshot(candidate);
+ if (
+ data.kind !== 30402 ||
+ data.pubkey !== reference.pubkey ||
+ data.identifier !== reference.identifier
+ )
+ return;
+ if (exactOnly) {
+ if (data.id === exactId) exact = data.id;
+ return;
+ }
+ head = selectPublicHead(head, candidate).head;
+ try {
+ resolveHeads(resolver, [head]);
+ } catch {
+ failed = true;
+ }
+ }
+ try {
+ const request = subscribePublicView(
+ view,
+ run,
+ 'head',
+ [
+ {
+ kinds: [30402],
+ authors: [reference.pubkey],
+ '#d': [reference.identifier],
+ limit: PUBLIC_QUERY_BUDGETS.requestedPerRelay
+ }
+ ],
+ (proof) => admit(proof, false)
+ );
+ requests.set(request, true);
+ if (exactId && current())
+ requests.set(
+ subscribePublicView(
+ view,
+ run,
+ 'head',
+ [
+ {
+ kinds: [30402],
+ authors: [reference.pubkey],
+ ids: [exactId],
+ limit: PUBLIC_QUERY_BUDGETS.requestedPerRelay
+ }
+ ],
+ (proof) => admit(proof, true)
+ ),
+ true
+ );
+ } catch {
+ failed = true;
+ }
+ return token;
+}
+export function citedProductSnapshot(
+ token: CitedProduct
+): Snapshot | undefined {
+ return owners.get(token)?.snapshot();
+}
+export function closeCitedProduct(token: CitedProduct): void {
+ owners.get(token)?.close();
+}
diff --git a/web/src/lib/messaging/inbox-view.ts b/web/src/lib/messaging/inbox-view.ts
@@ -1101,6 +1101,9 @@ export function createInboxView(input: Inputs): InboxView | undefined {
read,
stop,
close() {
+ // Retain this first terminal fanout before cleanup can reenter Close or
+ // unsubscribe another observer. Authority is revoked before callbacks.
+ const terminalListeners = closed ? [] : Array.from(listeners.values());
if (!closed) {
closed = true;
epoch++;
@@ -1120,6 +1123,12 @@ export function createInboxView(input: Inputs): InboxView | undefined {
);
}
listeners.clear();
+ for (const listener of terminalListeners)
+ try {
+ listener(snapshot());
+ } catch {
+ /* Isolate terminal presentation without stranding other observers. */
+ }
return pendingCleanup.length === 0;
}
});
diff --git a/web/src/lib/nostr/enquiry-references.ts b/web/src/lib/nostr/enquiry-references.ts
@@ -12,6 +12,25 @@ export type EnquiryReferences = Readonly<{
naddr: string;
nevent: string;
}>;
+// A body pointer is only a bounded public-version selector, never proof. Strip
+// relay hints and require its asserted kind and author before any public query.
+export function includedProductVersion(
+ value: string,
+ author: string
+): string | undefined {
+ if (!boundedUtf8(value, 2048)) return undefined;
+ try {
+ const pointer = decodePointer(value);
+ return pointer.type === 'nevent' &&
+ pointer.data.kind === 30402 &&
+ pointer.data.author === author &&
+ /^[a-f0-9]{64}$/.test(pointer.data.id)
+ ? pointer.data.id
+ : undefined;
+ } catch {
+ return undefined;
+ }
+}
// Public signed listing proofs only. No body links, private parent IDs or relay
// hints enter this projection; references never perform a lookup or fetch.
export function enquiryReferences(
diff --git a/web/tests/e2e/conversation-options.spec.ts b/web/tests/e2e/conversation-options.spec.ts
@@ -0,0 +1,523 @@
+import { test, expect, type Page } from '@playwright/test';
+import { build } from 'vite';
+import { svelte } from '@sveltejs/vite-plugin-svelte';
+import { fileURLToPath } from 'node:url';
+import { once } from 'node:events';
+import { WebSocketServer } from 'ws';
+import { finalizeEvent, getPublicKey } from 'applesauce-core/helpers';
+import { createStaticHarness } from '../integration/harness/static.ts';
+import type * as Fixture from './harness/conversation-options.ts';
+declare global {
+ interface Window {
+ hcp105: typeof Fixture;
+ hcp105Fixture: Awaited<ReturnType<typeof Fixture.renderFixture>>;
+ }
+}
+let server: Awaited<ReturnType<typeof createStaticHarness>>,
+ sockets: WebSocketServer,
+ endpoint: string,
+ bundle: string;
+type Mode =
+ | 'normal'
+ | 'missing'
+ | 'wrong_author'
+ | 'wrong_coordinate'
+ | 'invalid_signature'
+ | 'sold'
+ | 'deleted'
+ | 'partial'
+ | 'hold';
+let mode: Mode = 'normal',
+ requests: unknown[][] = [],
+ events: unknown[][] = [],
+ release = () => {};
+const secret = new Uint8Array(32).fill(84),
+ otherSecret = new Uint8Array(32).fill(90),
+ peer = getPublicKey(secret);
+function listing(createdAt = 1700000060) {
+ const event = finalizeEvent(
+ {
+ kind: 30402,
+ created_at: createdAt,
+ content: 'Independently signed carrots',
+ tags: [
+ ['d', mode === 'wrong_coordinate' ? 'apples' : 'carrots'],
+ ['title', 'Verified carrots'],
+ ['summary', 'Actual signed listing'],
+ ['published_at', '1700000000'],
+ ['location', 'Victoria'],
+ ['price', '3.5', 'CAD'],
+ ['radroots:price_unit', 'lb'],
+ ['status', mode === 'sold' ? 'sold' : 'active']
+ ]
+ },
+ mode === 'wrong_author' ? otherSecret : secret
+ );
+ return mode === 'invalid_signature'
+ ? { ...event, sig: '0'.repeat(128) }
+ : event;
+}
+test.beforeAll(async () => {
+ server = await createStaticHarness();
+ sockets = new WebSocketServer({
+ host: '127.0.0.1',
+ port: 0,
+ maxPayload: 65536
+ });
+ await once(sockets, 'listening');
+ const address = sockets.address();
+ if (!address || typeof address === 'string') throw Error('no loopback');
+ endpoint = 'ws://127.0.0.1:' + address.port;
+ sockets.on('connection', (socket) =>
+ socket.on('message', (bytes) => {
+ const raw = Buffer.isBuffer(bytes)
+ ? bytes
+ : Array.isArray(bytes)
+ ? Buffer.concat(bytes)
+ : Buffer.from(bytes);
+ const frame = JSON.parse(raw.toString()) as unknown[];
+ if (frame[0] === 'EVENT') {
+ events.push(frame);
+ return;
+ }
+ if (frame[0] !== 'REQ') return;
+ requests.push(frame);
+ const filters = frame.slice(2) as { kinds?: number[]; ids?: string[] }[];
+ const send = () => {
+ if (mode !== 'missing') {
+ if (filters.some((f) => f.kinds?.includes(30402))) {
+ const exact = filters.find((f) => f.ids)?.ids;
+ const event = exact?.includes(listing(1700000050).id)
+ ? listing(1700000050)
+ : listing();
+ socket.send(JSON.stringify(['EVENT', frame[1], event]));
+ }
+ if (mode === 'deleted' && filters.some((f) => f.kinds?.includes(5)))
+ socket.send(
+ JSON.stringify([
+ 'EVENT',
+ frame[1],
+ finalizeEvent(
+ {
+ kind: 5,
+ created_at: 1700000070,
+ tags: [['a', '30402:' + peer + ':carrots']],
+ content: ''
+ },
+ secret
+ )
+ ])
+ );
+ }
+ if (!(
+ mode === 'partial' &&
+ filters.some((filter) => filter.kinds?.includes(5))
+ ))
+ socket.send(JSON.stringify(['EOSE', frame[1]]));
+ };
+ if (mode === 'hold') release = send;
+ else send();
+ })
+ );
+ const result = await build({
+ configFile: false,
+ logLevel: 'silent',
+ plugins: [svelte({ configFile: false })],
+ resolve: {
+ conditions: ['browser'],
+ alias: {
+ '$app/navigation': fileURLToPath(
+ new URL('./harness/conversation-options.ts', import.meta.url)
+ )
+ }
+ },
+ build: {
+ write: false,
+ minify: false,
+ lib: {
+ entry: fileURLToPath(
+ new URL('./harness/conversation-options.ts', import.meta.url)
+ ),
+ name: 'hcp105',
+ formats: ['iife']
+ }
+ }
+ });
+ const output = Array.isArray(result) ? result[0] : result;
+ if (!('output' in output)) throw Error('no bundle');
+ const chunks = output.output.filter((row) => row.type === 'chunk');
+ expect(chunks).toHaveLength(1);
+ bundle = chunks[0].code;
+});
+test.afterAll(async () => {
+ for (const socket of sockets.clients) socket.terminate();
+ await new Promise<void>((resolve) => sockets.close(() => resolve()));
+ await server.close();
+});
+test.beforeEach(async ({ page }) => {
+ mode = 'normal';
+ requests = [];
+ events = [];
+ release = () => {};
+ await page.addInitScript(
+ ({ endpoint }) => {
+ const Native = window.WebSocket;
+ window.WebSocket = class extends Native {
+ constructor(url: string | URL, protocols?: string | string[]) {
+ if (
+ ![
+ 'wss://discovery.example.org',
+ 'wss://archive.example.org',
+ 'wss://peer.example.org'
+ ].includes(new URL(String(url)).origin)
+ )
+ throw Error('unapproved destination');
+ super(endpoint, protocols);
+ }
+ };
+ },
+ { endpoint }
+ );
+ await page.goto(server.url + '/search');
+ await page.addScriptTag({ content: bundle });
+});
+test.afterEach(async ({ page }) => {
+ if (!page.isClosed())
+ await page.evaluate(() => window.hcp105Fixture?.close());
+});
+async function ready(
+ page: Page,
+ scenario: Fixture.OptionsScenario = 'contexts'
+) {
+ await page.evaluate(async (scenario) => {
+ window.hcp105Fixture = await window.hcp105.renderFixture(scenario);
+ }, scenario);
+ await expect(page.locator('[data-options-fixture]')).toBeVisible();
+ await expect
+ .poll(() =>
+ page.evaluate(async () =>
+ (await window.hcp105Fixture.native()).received.every(
+ (row) =>
+ (JSON.parse((row as { wire: string }).wire) as { read: unknown })
+ .read !== null
+ )
+ )
+ )
+ .toBe(true);
+}
+const panel = (page: Page) => page.locator('[data-options-fixture]');
+const verify = (page: Page) =>
+ panel(page)
+ .getByRole('button', { name: 'Verify product citation', exact: true })
+ .click();
+
+test('mount and conversation disclosure show the original authenticated peer without discovery native writes or profile routes', async ({
+ page
+}) => {
+ await ready(page);
+ const before = await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }));
+ await panel(page)
+ .getByText('Identity and conversation options', { exact: true })
+ .click();
+ await expect(panel(page)).toContainText(peer);
+ expect(await page.evaluate(() => window.hcp105Fixture.options()?.peer)).toBe(
+ peer
+ );
+ expect(requests).toEqual([]);
+ expect(events).toEqual([]);
+ expect(
+ await panel(page).locator('a[href*="/profiles"],a[href*="/shops"]').count()
+ ).toBe(0);
+ expect(
+ await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }))
+ ).toEqual(before);
+});
+test('local block and report hooks receive the authenticated inner peer without implementing private disclosure or public reports', async ({
+ page
+}) => {
+ await ready(page);
+ await panel(page)
+ .getByText('Identity and conversation options', { exact: true })
+ .click();
+ await panel(page)
+ .getByRole('button', { name: 'Block person', exact: true })
+ .click();
+ await panel(page)
+ .getByRole('button', { name: 'Report conversation', exact: true })
+ .click();
+ expect(await page.evaluate(() => window.hcp105Fixture.hooks())).toEqual([
+ { action: 'block', peer },
+ { action: 'report', peer }
+ ]);
+ expect(requests).toEqual([]);
+ expect(events).toEqual([]);
+});
+test('explicit citation verification uses actual independently signed pair publisher and fixed bounded public queries', async ({
+ page
+}) => {
+ await ready(page);
+ const before = await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }));
+ await verify(page);
+ await expect(panel(page)).toContainText('Verified carrots');
+ await expect(panel(page)).toContainText('Signed listing observed');
+ expect(requests.length).toBeGreaterThan(0);
+ for (const frame of requests)
+ for (const filter of frame.slice(2) as {
+ kinds: number[];
+ authors: string[];
+ limit: number;
+ }[]) {
+ expect(filter.kinds.every((kind) => [30402, 5].includes(kind))).toBe(
+ true
+ );
+ expect(filter.authors).toEqual([peer]);
+ expect(filter.limit).toBe(200);
+ }
+ expect(events).toEqual([]);
+ expect(
+ await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }))
+ ).toEqual(before);
+ await expect(panel(page)).toContainText('not a current or locked quote');
+});
+for (const rejection of [
+ 'missing',
+ 'wrong_author',
+ 'wrong_coordinate',
+ 'invalid_signature'
+] as const)
+ test('untrusted listing stays unresolved: ' + rejection, async ({ page }) => {
+ mode = rejection;
+ await ready(page);
+ await verify(page);
+ await expect(panel(page)).toContainText(
+ 'Listing citation remains unresolved'
+ );
+ await expect(panel(page)).not.toContainText('Signed listing observed');
+ expect(events).toEqual([]);
+ });
+test('sold listing is independently observed without reserving inventory or accepting an order', async ({
+ page
+}) => {
+ mode = 'sold';
+ await ready(page);
+ const native = await page.evaluate(() => window.hcp105Fixture.native());
+ await verify(page);
+ await expect(panel(page)).toContainText('Listing is sold');
+ expect(await page.evaluate(() => window.hcp105Fixture.native())).toEqual(
+ native
+ );
+ expect(events).toEqual([]);
+});
+test('actual signed public deletion keeps the citation withdrawn rather than trusted', async ({
+ page
+}) => {
+ mode = 'deleted';
+ await ready(page);
+ await verify(page);
+ await expect(panel(page)).toContainText('Listing is withdrawn');
+ await expect(panel(page)).not.toContainText('Signed listing observed');
+ expect(events).toEqual([]);
+});
+test('unknown private parent and arbitrary body link never spawn a public hash query or external navigation', async ({
+ page
+}) => {
+ await ready(page, 'parent_reference');
+ await expect(panel(page)).toContainText('Earlier message unavailable');
+ await expect(panel(page)).toContainText('https://untrusted.example.org');
+ expect(
+ await page.evaluate(() => window.hcp105Fixture.capture('f'.repeat(64)))
+ ).toBe(false);
+ expect(requests).toEqual([]);
+ expect(await panel(page).locator('a[href^="https://"]').count()).toBe(0);
+ expect(events).toEqual([]);
+ await verify(page);
+ await expect(panel(page)).toContainText('Verified carrots');
+ expect(JSON.stringify(requests)).not.toContain('f'.repeat(64));
+});
+test('included exact public version is independently verified from the genuine original message', async ({
+ page
+}) => {
+ await ready(page, 'exact');
+ await verify(page);
+ await expect(panel(page)).toContainText('Included version verified');
+ const id = await page.evaluate(() => window.hcp105Fixture.citedVersion);
+ expect(
+ requests.some((frame) =>
+ (frame.slice(2) as { ids?: string[] }[]).some((filter) =>
+ filter.ids?.includes(id)
+ )
+ )
+ ).toBe(true);
+ expect(events).toEqual([]);
+});
+test('a genuinely signed older included version stays distinct from the observed current listing and cannot lock a quote', async ({
+ page
+}) => {
+ await ready(page, 'stale');
+ await verify(page);
+ await expect(panel(page)).toContainText(
+ 'Included version differs from the observed listing'
+ );
+ await expect(panel(page)).not.toContainText('Included version verified');
+ await expect(panel(page)).toContainText('not a current or locked quote');
+ expect(events).toEqual([]);
+});
+test('copied view runtime and citation tokens cannot borrow independent verification or option authority', async ({
+ page
+}) => {
+ await ready(page);
+ expect(
+ await page.evaluate(() =>
+ window.hcp105Fixture.capture(undefined, 'unreviewed')
+ )
+ ).toBe(false);
+ expect(requests).toEqual([]);
+ expect(await page.evaluate(() => window.hcp105Fixture.copied())).toEqual({
+ view: false,
+ runtime: false,
+ snapshot: undefined,
+ options: undefined,
+ hook: false
+ });
+ expect(requests).toEqual([]);
+ expect(events).toEqual([]);
+});
+test('logout during actual held public response cannot revive private citation context or invoke local hooks', async ({
+ page
+}) => {
+ mode = 'hold';
+ await ready(page);
+ await verify(page);
+ await expect.poll(() => requests.length).toBe(1);
+ await page.evaluate(() => window.hcp105Fixture.logout());
+ mode = 'normal';
+ release();
+ await expect(panel(page)).not.toContainText('Verified carrots');
+ await expect(panel(page)).not.toContainText(peer);
+ expect(events).toEqual([]);
+ expect(await page.evaluate(() => window.hcp105Fixture.hooks())).toEqual([]);
+});
+test('unmount closes the original held query without private writes or late context rendering', async ({
+ page
+}) => {
+ mode = 'hold';
+ await ready(page);
+ const native = await page.evaluate(() => window.hcp105Fixture.native());
+ await verify(page);
+ await expect.poll(() => requests.length).toBe(1);
+ await page.evaluate(() => window.hcp105Fixture.closePanel());
+ mode = 'normal';
+ release();
+ await expect(panel(page)).toHaveCount(0);
+ expect(events).toEqual([]);
+ expect(await page.evaluate(() => window.hcp105Fixture.native())).toEqual(
+ native
+ );
+});
+
+test('expired signed listing with incomplete deletion coverage remains visibly unresolved', async ({
+ page
+}) => {
+ mode = 'partial';
+ await ready(page, 'exact');
+ const before = await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }));
+ await verify(page);
+ await expect
+ .poll(() =>
+ requests.some((frame) =>
+ (frame.slice(2) as { kinds: number[] }[]).some((filter) =>
+ filter.kinds.includes(5)
+ )
+ )
+ )
+ .toBe(true);
+ await page.evaluate(() => window.hcp105Fixture.advance());
+ await expect(panel(page)).toContainText(
+ 'Listing citation remains unresolved'
+ );
+ await expect(panel(page)).not.toContainText('Included version verified');
+ await expect(panel(page)).not.toContainText('Signed listing observed');
+ expect(
+ await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }))
+ ).toEqual(before);
+ expect(events).toEqual([]);
+});
+
+for (const action of ['logout', 'selection', 'close'] as const)
+ test(
+ 'standalone original message revocation clears private rendering and stale Reply: ' +
+ action,
+ async ({ page }) => {
+ await ready(page, 'exact');
+ await expect(panel(page).locator('article[data-message-id]')).toHaveCount(
+ 1
+ );
+ await expect(panel(page)).toContainText(
+ 'Quoted price: 4 GBP https://untrusted.example.org'
+ );
+ await expect(
+ panel(page).getByRole('button', {
+ name: 'Reply to this message',
+ exact: true
+ })
+ ).toBeVisible();
+ const before = await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }));
+ await page.evaluate(
+ (action) => window.hcp105Fixture.revokeAndClick(action),
+ action
+ );
+ expect(
+ await page.evaluate(() => window.hcp105Fixture.currentMessage())
+ ).toBe(false);
+ if (action === 'close')
+ expect(
+ await page.evaluate(() => window.hcp105Fixture.terminal())
+ ).toEqual(['reentered', 'survived']);
+ expect(await page.evaluate(() => window.hcp105Fixture.hooks())).toEqual(
+ []
+ );
+ await expect(panel(page).locator('article[data-message-id]')).toHaveCount(
+ 0
+ );
+ await expect(panel(page)).not.toContainText(
+ 'Quoted price: 4 GBP https://untrusted.example.org'
+ );
+ await expect(
+ panel(page).getByRole('button', {
+ name: 'Reply to this message',
+ exact: true
+ })
+ ).toHaveCount(0);
+ await expect(panel(page).locator('a[href*="/products/"]')).toHaveCount(0);
+ await expect(panel(page)).not.toContainText(peer);
+ expect(
+ await page.evaluate(async () => ({
+ native: await window.hcp105Fixture.native(),
+ delta: window.hcp105Fixture.delta()
+ }))
+ ).toEqual(before);
+ expect(requests).toEqual([]);
+ expect(events).toEqual([]);
+ }
+ );
diff --git a/web/tests/e2e/harness/conversation-options-panel.svelte b/web/tests/e2e/harness/conversation-options-panel.svelte
@@ -0,0 +1,36 @@
+<script lang="ts">
+ import ConversationOptions from '../../../src/lib/components/ConversationOptions.svelte';
+ import MessageItem from '../../../src/lib/components/MessageItem.svelte';
+ import type { InboxView } from '../../../src/lib/messaging/inbox-view.ts';
+ import type { PublicRuntime } from '../../../src/lib/runtime/public-runtime.ts';
+ import type { ThreadMessage } from '../../../src/lib/messaging/conversation-thread.ts';
+ let {
+ controller,
+ conversationId,
+ runtime,
+ message,
+ hook
+ }: {
+ controller: InboxView;
+ conversationId: string;
+ runtime: PublicRuntime;
+ message: ThreadMessage;
+ hook: (action: string, peer: string) => void;
+ } = $props();
+</script>
+
+<section data-options-fixture>
+ <ConversationOptions
+ {controller}
+ {conversationId}
+ onblock={(peer: string) => hook('block', peer)}
+ onreport={(peer: string) => hook('report', peer)}
+ />
+ <MessageItem
+ {controller}
+ {conversationId}
+ {message}
+ {runtime}
+ onreply={(parent: string) => hook('reply', parent)}
+ />
+</section>
diff --git a/web/tests/e2e/harness/conversation-options.ts b/web/tests/e2e/harness/conversation-options.ts
@@ -0,0 +1,253 @@
+import { mount, unmount, tick } from 'svelte';
+import {
+ renderFixture as renderThread,
+ type Scenario
+} from './conversation-thread.ts';
+import Panel from './conversation-options-panel.svelte';
+import {
+ captureCitedProduct,
+ citedProductSnapshot,
+ closeCitedProduct,
+ conversationOptionsSnapshot,
+ requestConversationOption,
+ type CitedProduct
+} from '../../../src/lib/messaging/cited-product.ts';
+import {
+ inboxReplyOwnership,
+ inboxMessageSnapshot,
+ subscribeInboxView,
+ closeInboxView
+} from '../../../src/lib/messaging/inbox-view.ts';
+import { inboxSetupViewOwnership } from '../../../src/lib/messaging/inbox-setup-view.ts';
+import {
+ createPublicRuntimeContext,
+ mountPublicRuntime,
+ closePublicRuntime
+} from '../../../src/lib/runtime/public-runtime.ts';
+import { finalizeEvent, getPublicKey } from 'applesauce-core/helpers';
+import { neventEncode } from 'applesauce-core/helpers/pointers';
+import { encodeProductReference } from '../../../src/lib/nostr/references.ts';
+export { beforeNavigate, goto } from './conversation-thread.ts';
+
+export type OptionsScenario = Scenario | 'exact' | 'stale' | 'parent_reference';
+export async function renderFixture(scenario: OptionsScenario = 'contexts') {
+ const publicSecret = new Uint8Array(32).fill(84);
+ const version = finalizeEvent(
+ {
+ kind: 30402,
+ created_at: scenario === 'stale' ? 1700000050 : 1700000060,
+ content: 'Independently signed carrots',
+ tags: [
+ ['d', 'carrots'],
+ ['title', 'Verified carrots'],
+ ['summary', 'Actual signed listing'],
+ ['published_at', '1700000000'],
+ ['location', 'Victoria'],
+ ['price', '3.5', 'CAD'],
+ ['radroots:price_unit', 'lb'],
+ ['status', 'active']
+ ]
+ },
+ publicSecret
+ );
+ const selectedCitation = encodeProductReference({
+ kind: 30402,
+ pubkey: getPublicKey(publicSecret),
+ identifier: 'carrots'
+ });
+ const seeded = ['exact', 'stale', 'parent_reference'].includes(scenario);
+ const included = neventEncode({
+ id: scenario === 'parent_reference' ? 'f'.repeat(64) : version.id,
+ author: version.pubkey,
+ kind: 30402
+ });
+ const body = seeded
+ ? 'About carrots\nProduct: nostr:' +
+ selectedCitation +
+ '\nVersion: nostr:' +
+ included +
+ '\nQuoted price: 4 GBP https://untrusted.example.org'
+ : undefined;
+ const kind: Scenario =
+ scenario === 'parent_reference'
+ ? 'hostile'
+ : scenario === 'exact' || scenario === 'stale'
+ ? 'inbound'
+ : scenario;
+ const thread = await renderThread(kind, undefined, false, undefined, body);
+ await thread.checkSetup();
+ if (!(await thread.unlock())) throw Error('no genuine thread');
+ const message =
+ thread
+ .thread()
+ .messages.find((row) =>
+ row.citations.some((ref) => ref.naddr === thread.carrots)
+ ) ?? thread.thread().messages[0];
+ if (!message) throw Error('no original message');
+ const scope = inboxReplyOwnership(
+ thread.controller,
+ thread.conversationId,
+ message.data.rumorId
+ );
+ const setup = scope && inboxSetupViewOwnership(scope.setup);
+ const context = createPublicRuntimeContext();
+ let clockOffset = 0;
+ const candidate =
+ setup &&
+ mountPublicRuntime(context, setup.policy, {
+ now: () => performance.now() + clockOffset,
+ schedule(callback, delay) {
+ const timer = setTimeout(callback, delay);
+ return () => clearTimeout(timer);
+ }
+ });
+ if (!candidate) throw Error('no original runtime');
+ const runtime = candidate;
+ const hooks: { action: string; peer: string }[] = [];
+ const target = document.createElement('div');
+ document.body.append(target);
+ const mounted = mount(Panel, {
+ target,
+ props: {
+ controller: thread.controller,
+ conversationId: thread.conversationId,
+ runtime,
+ message,
+ hook: (action: string, peer: string) => {
+ hooks.push({ action, peer });
+ }
+ }
+ });
+ const tokens: CitedProduct[] = [];
+ const terminal: string[] = [];
+ const terminalOff: (() => void)[] = [];
+ let unmounted = false;
+ function capture(
+ value: unknown = thread.carrots,
+ review: unknown = 'reviewed_product_citation'
+ ) {
+ const token = captureCitedProduct(
+ thread.controller,
+ thread.conversationId,
+ message.data.rumorId,
+ value,
+ runtime,
+ review
+ );
+ if (token) tokens.push(token);
+ return token;
+ }
+ async function closePanel() {
+ if (unmounted) return;
+ unmounted = true;
+ await unmount(mounted);
+ target.remove();
+ }
+ return {
+ currentMessage: () =>
+ !!inboxMessageSnapshot(
+ thread.controller,
+ thread.conversationId,
+ message.data.rumorId
+ ),
+ terminal: () => terminal.slice(),
+ revokeAndClick: async (action: 'logout' | 'selection' | 'close') => {
+ const button = Array.from(
+ target.querySelectorAll<HTMLButtonElement>('button')
+ ).find((row) => row.textContent === 'Reply to this message');
+ if (!button) throw Error('no original rendered Reply control');
+ if (action === 'logout') thread.logout();
+ else if (action === 'selection')
+ await thread.resolve('dddddddd-dddd-4ddd-8ddd-dddddddddddd');
+ else {
+ const revoked = () =>
+ !inboxMessageSnapshot(
+ thread.controller,
+ thread.conversationId,
+ message.data.rumorId
+ );
+ terminalOff.push(
+ subscribeInboxView(thread.controller, () => {
+ if (!revoked()) return;
+ terminal.push('reentered');
+ closeInboxView(thread.controller);
+ })
+ );
+ terminalOff.push(
+ subscribeInboxView(thread.controller, () => {
+ if (revoked()) throw Error('controlled terminal observer failure');
+ })
+ );
+ terminalOff.push(
+ subscribeInboxView(thread.controller, () => {
+ if (revoked()) terminal.push('survived');
+ })
+ );
+ closeInboxView(thread.controller);
+ }
+ await tick();
+ button.click();
+ },
+ advance: () => {
+ clockOffset += 15_001;
+ },
+ owner: thread.owner,
+ peer: thread.peer,
+ parent: message.data.replyTo,
+ rumorId: message.data.rumorId,
+ citation: thread.carrots,
+ citedVersion: version.id,
+ delta: thread.delta,
+ native: thread.native,
+ hooks: () => hooks.slice(),
+ options: () =>
+ conversationOptionsSnapshot(thread.controller, thread.conversationId),
+ capture: (value?: unknown, review?: unknown) => !!capture(value, review),
+ snapshot: () => {
+ const token = tokens.at(-1);
+ return token && citedProductSnapshot(token);
+ },
+ copied() {
+ const token = tokens.at(-1);
+ return {
+ view: !!captureCitedProduct(
+ { ...thread.controller },
+ thread.conversationId,
+ message.data.rumorId,
+ thread.carrots,
+ runtime,
+ 'reviewed_product_citation'
+ ),
+ runtime: !!captureCitedProduct(
+ thread.controller,
+ thread.conversationId,
+ message.data.rumorId,
+ thread.carrots,
+ { ...runtime },
+ 'reviewed_product_citation'
+ ),
+ snapshot: token && citedProductSnapshot({ ...token }),
+ options: conversationOptionsSnapshot(
+ { ...thread.controller },
+ thread.conversationId
+ ),
+ hook: requestConversationOption(
+ { ...thread.controller },
+ thread.conversationId,
+ 'block',
+ (peer) => hooks.push({ action: 'copied', peer }),
+ 'reviewed_conversation_option'
+ )
+ };
+ },
+ logout: thread.logout,
+ closePanel,
+ async close() {
+ for (const off of terminalOff) off();
+ await closePanel();
+ for (const token of tokens) closeCitedProduct(token);
+ closePublicRuntime(context);
+ await thread.close();
+ }
+ };
+}
diff --git a/web/tests/e2e/harness/conversation-thread.ts b/web/tests/e2e/harness/conversation-thread.ts
@@ -84,7 +84,8 @@ export async function renderFixture(
freshOwnLookup?: (
owner: string,
policy: RelayPolicy
- ) => Promise<InboxResolver>
+ ) => Promise<InboxResolver>,
+ initialContent?: string
) {
// Receipt scenario performs actual original SDK retry and receives loopback
// OKs before mounting the readonly thread. The UI itself never publishes.
@@ -183,9 +184,10 @@ export async function renderFixture(
};
} else
first = cipher(
- kind === 'hostile'
- ? '<img src=x> Quoted price 4 GBP https://untrusted.example.org nostr:naddr1invalid'
- : 'Actual encrypted thread fixture',
+ initialContent ??
+ (kind === 'hostile'
+ ? '<img src=x> Quoted price 4 GBP https://untrusted.example.org nostr:naddr1invalid'
+ : 'Actual encrypted thread fixture'),
1700000000,
0,
kind === 'hostile' ? 'f'.repeat(64) : undefined
diff --git a/web/tests/provenance/output.test.mjs b/web/tests/provenance/output.test.mjs
@@ -305,7 +305,7 @@ import { auditOutput } from '../../tools/check-output.mjs';
const f = await fixture(t);
const files = await f.audit();
// Exact eleven-route module/page/static admission; CSS stays once-imported.
- assert.equal(files.length, 51);
+ assert.equal(files.length, 52);
// The actual SDK payload crosses the reader scratch boundary; a reused
// scratch buffer must still preserve every compiler/static byte exactly.
const sizes = await Promise.all(
@@ -350,6 +350,9 @@ import { auditOutput } from '../../tools/check-output.mjs';
'src/lib/messaging/inbox-list.ts',
'src/lib/components/ConversationThread.svelte',
'src/lib/components/MessageItem.svelte',
+ 'src/lib/components/ConversationOptions.svelte',
+ 'src/lib/messaging/cited-product.ts',
+ 'src/lib/nostr/enquiry-references.ts',
'src/lib/components/MessageComposer.svelte',
'src/lib/messaging/reply-controller.ts',
'src/lib/messaging/rumor-plan.ts',
@@ -423,7 +426,9 @@ import { auditOutput } from '../../tools/check-output.mjs';
'thread-dynamic',
'thread-entry-role',
'reply-missing-navigation',
- 'reply-missing-handles'
+ 'reply-missing-handles',
+ 'context-resolver-dynamic',
+ 'context-resolver-entry'
])
await check(
'actual inbox list compiler rejects ' + mutation,
@@ -437,13 +442,18 @@ import { auditOutput } from '../../tools/check-output.mjs';
const entry = Object.entries(manifest).find(
([, row]) =>
row.name ===
- (mutation.startsWith('thread-') ||
- mutation.startsWith('reply-')
- ? 'nodes/5'
- : 'InboxStatus')
+ (mutation.startsWith('context-')
+ ? 'resolve-head'
+ : mutation.startsWith('thread-') ||
+ mutation.startsWith('reply-')
+ ? 'nodes/5'
+ : 'InboxStatus')
);
assert.ok(entry);
const [, row] = entry;
+ if (mutation === 'context-resolver-dynamic')
+ row.dynamicImports = [];
+ if (mutation === 'context-resolver-entry') row.isEntry = true;
if (mutation === 'directory-missing-context')
row.imports = row.imports.filter(
(/** @type {string} */ value) =>
@@ -533,7 +543,7 @@ import { auditOutput } from '../../tools/check-output.mjs';
assert.ok(Buffer.byteLength(expanded) > 64 * 1024);
await writeFile(file, expanded);
await refresh(f);
- assert.equal((await f.audit()).length, 51);
+ assert.equal((await f.audit()).length, 52);
}
);
@@ -1084,7 +1094,7 @@ import { auditOutput } from '../../tools/check-output.mjs';
}
await writeFile(file, JSON.stringify(manifest));
if (mutation === 'permuted-edges')
- assert.equal((await f.audit()).length, 51);
+ assert.equal((await f.audit()).length, 52);
else await assert.rejects(f.audit, /compiler|references/);
}
);
diff --git a/web/tests/unit/cited-product.test.ts b/web/tests/unit/cited-product.test.ts
@@ -0,0 +1,64 @@
+import { describe, expect, it } from 'vitest';
+import {
+ captureCitedProduct,
+ citedProductSnapshot,
+ closeCitedProduct,
+ conversationOptionsSnapshot,
+ requestConversationOption,
+ type CitedProduct
+} from '../../src/lib/messaging/cited-product.ts';
+import type { InboxView } from '../../src/lib/messaging/inbox-view.ts';
+import type { PublicRuntime } from '../../src/lib/runtime/public-runtime.ts';
+
+const id = '12345678-1234-4234-8234-123456789abc';
+describe('private citation and conversation options reject detached authority', () => {
+ it('SSR cannot allocate a citation query from arbitrary scalar hints', () => {
+ expect(
+ captureCitedProduct(
+ {} as InboxView,
+ id,
+ 'a'.repeat(64),
+ 'naddr1invalid',
+ {} as PublicRuntime,
+ 'reviewed_product_citation'
+ )
+ ).toBeUndefined();
+ });
+ it('copied citation tokens do not expose verified context', () => {
+ expect(citedProductSnapshot({} as CitedProduct)).toBeUndefined();
+ });
+ it('closing a fake citation never creates query authority', () => {
+ const fake = {} as CitedProduct;
+ closeCitedProduct(fake);
+ expect(citedProductSnapshot(fake)).toBeUndefined();
+ });
+ it('fake views do not expose an authenticated conversation identity', () => {
+ expect(conversationOptionsSnapshot({} as InboxView, id)).toBeUndefined();
+ });
+ it('fake local options cannot invoke a block or private report hook', () => {
+ const peers: string[] = [];
+ for (const action of ['block', 'report'] as const)
+ expect(
+ requestConversationOption(
+ {} as InboxView,
+ id,
+ action,
+ (peer) => peers.push(peer),
+ 'reviewed_conversation_option'
+ )
+ ).toBe(false);
+ expect(peers).toEqual([]);
+ });
+ it('unreviewed citation capture cannot become an effect', () => {
+ expect(
+ captureCitedProduct(
+ {} as InboxView,
+ id,
+ 'a'.repeat(64),
+ 'naddr1invalid',
+ {} as PublicRuntime,
+ undefined
+ )
+ ).toBeUndefined();
+ });
+});
diff --git a/web/tools/check-output.mjs b/web/tools/check-output.mjs
@@ -511,7 +511,7 @@ async function inboxPresentationAdmission(web) {
'src/lib/components/InboxStatus.svelte':
'29f17df1ccece671ea2ba57578dc028fa541ce924e1cdc4b3e7753da500da53f',
'src/lib/messaging/inbox-view.ts':
- 'ba082b95304ef931dde530b846a986cbf492f82d16a4fb04ffc9448f5b21ee81',
+ 'f725d1e122550232efa52b26139d3047d3bbfd6d3d11b1ef0a110b5e4b4410dc',
'src/lib/messaging/inbox-sync.ts':
'84f9b3bb165a81878bb281c51d245aff7eb06a0fa55b857a49b13d0cb1cff8ae',
'src/lib/messaging/inbox-setup-view.ts':
@@ -523,9 +523,9 @@ async function inboxPresentationAdmission(web) {
'src/lib/messaging/inbox-list.ts':
'9cc82877bfa8dbb2a7fa41bceb842793349416271f19569f49fdd5cfc1de07e5',
'src/lib/components/ConversationThread.svelte':
- 'beb2fa152de393ffd6edf2fa42f4eb14376983e05e7624292f3f8c60eea57dc0',
+ 'ae59e6c06c0c5a86a58f49abed0ac9702631a694605b2c6686dfa65db0359080',
'src/lib/components/MessageItem.svelte':
- '50c7f7b2f41c46c45ac59013daeed915d116375b45b9f846e06051695aa3c6a8',
+ '5c9af10ece18deeddd85e11453239c2a0b8e741cb84529e15c4ad87864704517',
'src/lib/messaging/conversation-thread.ts':
'7367f0e6d96a9f249514f66c2459274e856eb83462523e37264d4cd97d2e36d1',
'src/lib/persistence/private-storage.ts':
@@ -537,7 +537,13 @@ async function inboxPresentationAdmission(web) {
'src/lib/messaging/reply-controller.ts':
'c13f1395b5317febcd23396babbcc116065ff96e8cbeb29c8eadfdfc14e45c2d',
'src/lib/messaging/rumor-plan.ts':
- '11a672d05a1eaf680b8039bd4c0986754b64f7103034c698843dc24d0560e0f5'
+ '11a672d05a1eaf680b8039bd4c0986754b64f7103034c698843dc24d0560e0f5',
+ 'src/lib/components/ConversationOptions.svelte':
+ 'a33d9ffb13e28ce985799fa69342c8fa63816da70e1f9383d4e8e82f5a393c6d',
+ 'src/lib/messaging/cited-product.ts':
+ 'b4a43fad9b020cf647350350e5d0195df9a80d772ab6910e0e9fb8c11b4b0e48',
+ 'src/lib/nostr/enquiry-references.ts':
+ 'a17175337ee53279f898a7c6fa1af7e77ad26c0d2c0da46f26a9766fa701d365'
};
for (const [name, pin] of Object.entries(producers)) {
const bytes = await readOwned(web, name);
@@ -705,7 +711,8 @@ export async function auditOutput(webDirectory) {
if (hasProductPresentation) names.add('publishers');
if (hasInboxSetup) names.add('private-handles');
if (hasInboxPresentation)
- for (const name of ['InboxStatus', 'InboxSetup', 'read']) names.add(name);
+ for (const name of ['InboxStatus', 'InboxSetup', 'read', 'resolve-head'])
+ names.add(name);
const admitted = new Map([['build-info.json', expectedMetadata]]);
const seen = new Set();
for (const [key, record] of Object.entries(manifest)) {
@@ -1056,6 +1063,7 @@ export async function auditOutput(webDirectory) {
'public-key',
'private-handles',
'public-runtime',
+ 'references',
'client',
'Button',
'client.svelte',
@@ -1064,9 +1072,11 @@ export async function auditOutput(webDirectory) {
'view-context',
'legacy',
'InboxSetup',
- 'InboxStatus'
+ 'InboxStatus',
+ 'resolve-head'
]
- ]
+ ],
+ ['resolve-head', ['public-runtime', 'Button', 'read']]
];
for (const [name, imports] of dependencies) {
const [key, row] = entry(name);
@@ -1123,7 +1133,7 @@ export async function auditOutput(webDirectory) {
'public-key',
identityCompilerModule,
'Button',
- ...(hasInboxPresentation ? ['read'] : [])
+ ...(hasInboxPresentation ? ['resolve-head'] : [])
]
: hasPublicRuntime === 'public_identity'
? ['public-key', identityCompilerModule, 'Disclosure', 'Button']
@@ -1143,7 +1153,8 @@ export async function auditOutput(webDirectory) {
'client.svelte',
'state',
'Disclosure',
- 'publishers'
+ 'publishers',
+ ...(hasInboxPresentation ? ['resolve-head'] : [])
]
: hasPublicRuntime === 'public_identity'
? [
@@ -1186,7 +1197,8 @@ export async function auditOutput(webDirectory) {
'state',
'Disclosure',
'routes',
- 'publishers'
+ 'publishers',
+ ...(hasInboxPresentation ? ['resolve-head'] : [])
]
: hasPublicRuntime === 'public_identity'
? [