1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! API key persistence to OPFS.
//!
//! Stored next to `.lh_history.json` in the same per-origin OPFS
//! sandbox. Same security model as `sessionStorage`: anything with JS
//! access to this origin can read the file. The win over
//! `sessionStorage` is that it survives a tab close / browser restart.
//!
//! **Threat model considered:** this is no worse than session/local
//! storage (XSS-equivalent risk). It's NOT encryption at rest — the
//! key sits in plaintext bytes. Per-origin sandboxing is the only
//! protection. If untrusted JS is ever loaded into this origin, the
//! key is exposed.
use crateFilesystem;
const KEY_FILE: &str = ".lh_api_key";
/// Read the persisted Gemini API key, if any. Empty/missing → `None`.
pub async
/// Persist the key. Best-effort; logs and swallows errors.
pub async
/// Delete the persisted key (the "clear" button).
pub async