From 5a001a805c2c4b7befaee25ba6377bbb49d782da Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sun, 26 Apr 2026 15:49:01 -0400 Subject: [PATCH] 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 --- .../src/service-worker/router/popup-only.ts | 11 +++++++ extension/src/shared/messages.ts | 32 +++++++++++++++++-- extension/src/shared/types.ts | 22 +++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/extension/src/service-worker/router/popup-only.ts b/extension/src/service-worker/router/popup-only.ts index dc7b640..ad3920b 100644 --- a/extension/src/service-worker/router/popup-only.ts +++ b/extension/src/service-worker/router/popup-only.ts @@ -290,6 +290,17 @@ export async function handle( return { ok: false, error: 'download_failed' }; } } + + // Handlers for these cases are added in Tasks 3–5. + 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' }; } } diff --git a/extension/src/shared/messages.ts b/extension/src/shared/messages.ts index 069b56d..128affd 100644 --- a/extension/src/shared/messages.ts +++ b/extension/src/shared/messages.ts @@ -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 { + data: { devices: Device[] }; +} + +export interface ListTrashedResponse extends Extract { + data: { items: Array<[ItemId, ManifestEntry]> }; +} + +export interface PurgeAllTrashResponse extends Extract { + data: { itemCount: number; orphanCount: number }; +} + +export interface FieldHistoryResponse extends Extract { + data: { history: FieldHistoryView[] }; +} + // --- Capability sets (consumed by the router) --- export const POPUP_ONLY_TYPES: ReadonlySet = new Set([ @@ -115,6 +140,9 @@ export const POPUP_ONLY_TYPES: ReadonlySet = 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 = new Set([ diff --git a/extension/src/shared/types.ts b/extension/src/shared/types.ts index dcc1d8c..c54e954 100644 --- a/extension/src/shared/types.ts +++ b/extension/src/shared/types.ts @@ -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 {