feat(ext/shared): add Device + FieldHistory types + 8 new message types

Device: name, public_key (hex), added_at.
FieldHistoryView: field_id, field_name, current_value, entries[].
Messages: list_devices, add_device, revoke_device, list_trashed,
restore_item, purge_item, purge_all_trash, get_field_history.

Also adds stub cases in popup-only.ts switch to keep tsc happy until
Tasks 3-5 wire up the real handlers.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-04-26 15:49:01 -04:00
parent caebe9f97e
commit 5a001a805c
3 changed files with 63 additions and 2 deletions

View File

@@ -290,6 +290,17 @@ export async function handle(
return { ok: false, error: 'download_failed' };
}
}
// Handlers for these cases are added in Tasks 35.
case 'list_devices':
case 'add_device':
case 'revoke_device':
case 'list_trashed':
case 'restore_item':
case 'purge_item':
case 'purge_all_trash':
case 'get_field_history':
return { ok: false, error: 'not_implemented' };
}
}

View File

@@ -1,6 +1,7 @@
import type {
Item, ItemId, Manifest, ManifestEntry, VaultConfig, SetupState,
DeviceSettings, GeneratorRequest, VaultSettings, AttachmentRef,
DeviceSettings, GeneratorRequest, VaultSettings, AttachmentRef, Device,
FieldHistoryView,
} from './types';
// --- Messages a popup (or setup page) may send ---
@@ -30,7 +31,15 @@ export type PopupMessage =
| { type: 'get_blacklist' }
| { type: 'remove_blacklist'; hostname: string }
| { type: 'upload_attachment'; itemId: string; filename: string; mimeType: string; bytes: ArrayBuffer }
| { type: 'download_attachment'; itemId: string; attachmentId: string };
| { type: 'download_attachment'; itemId: string; attachmentId: string }
| { type: 'list_devices' }
| { type: 'add_device'; name: string; public_key: string }
| { type: 'revoke_device'; name: string }
| { type: 'list_trashed' }
| { type: 'restore_item'; id: ItemId }
| { type: 'purge_item'; id: ItemId }
| { type: 'purge_all_trash' }
| { type: 'get_field_history'; id: ItemId };
// --- Messages a content script may send ---
@@ -105,6 +114,22 @@ export interface DownloadAttachmentResponse extends Extract<Response, { ok: true
data: { bytes: ArrayBuffer; filename: string; mimeType: string };
}
export interface ListDevicesResponse extends Extract<Response, { ok: true }> {
data: { devices: Device[] };
}
export interface ListTrashedResponse extends Extract<Response, { ok: true }> {
data: { items: Array<[ItemId, ManifestEntry]> };
}
export interface PurgeAllTrashResponse extends Extract<Response, { ok: true }> {
data: { itemCount: number; orphanCount: number };
}
export interface FieldHistoryResponse extends Extract<Response, { ok: true }> {
data: { history: FieldHistoryView[] };
}
// --- Capability sets (consumed by the router) ---
export const POPUP_ONLY_TYPES: ReadonlySet<PopupMessage['type']> = new Set([
@@ -115,6 +140,9 @@ export const POPUP_ONLY_TYPES: ReadonlySet<PopupMessage['type']> = new Set([
'ack_autofill_origin', 'get_settings', 'update_settings',
'get_vault_settings', 'update_vault_settings', 'get_blacklist',
'remove_blacklist', 'upload_attachment', 'download_attachment',
'list_devices', 'add_device', 'revoke_device',
'list_trashed', 'restore_item', 'purge_item', 'purge_all_trash',
'get_field_history',
] as PopupMessage['type'][]);
export const CONTENT_CALLABLE_TYPES: ReadonlySet<ContentMessage['type']> = new Set([

View File

@@ -144,6 +144,28 @@ export interface AttachmentSummary {
size: number;
}
// --- Devices ---
export interface Device {
name: string;
public_key: string; // hex-encoded ed25519 pubkey
added_at: number; // unix timestamp
}
// --- Field history view ---
export interface FieldHistoryViewEntry {
value: string;
changed_at: number;
}
export interface FieldHistoryView {
field_id: string;
field_name: string;
current_value: string;
entries: FieldHistoryViewEntry[];
}
// --- Item envelope ---
export interface Item {