feat(ext/sw): add session inactivity timer with configurable timeout

Implements a service-worker-side session timer that locks the vault
after a configurable period of inactivity (default 15 min). Supports
two modes: 'inactivity' (timer-based) and 'every_time' (no timer).
Config persists via chrome.storage.local and is exposed through
get_session_config / update_session_config popup messages.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-04-27 02:24:26 -04:00
parent bd13854f59
commit 86621f075f
5 changed files with 192 additions and 1 deletions

View File

@@ -4,6 +4,12 @@ import type {
FieldHistoryView,
} from './types';
// --- Session timeout config ---
export type SessionTimeoutConfig =
| { mode: 'inactivity'; minutes: number }
| { mode: 'every_time' };
// --- Messages a popup (or setup page) may send ---
export type PopupMessage =
@@ -39,7 +45,9 @@ export type PopupMessage =
| { type: 'restore_item'; id: ItemId }
| { type: 'purge_item'; id: ItemId }
| { type: 'purge_all_trash' }
| { type: 'get_field_history'; id: ItemId };
| { type: 'get_field_history'; id: ItemId }
| { type: 'get_session_config' }
| { type: 'update_session_config'; config: SessionTimeoutConfig };
// --- Messages a content script may send ---
@@ -143,6 +151,7 @@ export const POPUP_ONLY_TYPES: ReadonlySet<PopupMessage['type']> = new Set([
'list_devices', 'add_device', 'revoke_device',
'list_trashed', 'restore_item', 'purge_item', 'purge_all_trash',
'get_field_history',
'get_session_config', 'update_session_config',
] as PopupMessage['type'][]);
export const CONTENT_CALLABLE_TYPES: ReadonlySet<ContentMessage['type']> = new Set([