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

@@ -11,6 +11,7 @@ import { createGitHost, base64ToUint8Array } from '../git-host';
import * as vault from '../vault';
import * as session from '../session';
import * as devices from '../devices';
import * as sessionTimer from '../session-timer';
// --- Shared ambient state owned by the SW module ---
//
@@ -353,6 +354,16 @@ export async function handle(
const history = state.wasm.get_field_history(JSON.stringify(item));
return { ok: true, data: { history } };
}
case 'get_session_config':
return { ok: true, data: { config: sessionTimer.getConfig() } };
case 'update_session_config': {
sessionTimer.setConfig(msg.config);
sessionTimer.resetTimer();
await chrome.storage.local.set({ sessionTimeoutConfig: msg.config });
return { ok: true };
}
}
}