feat: add protected bookmark credentials and startup options

This commit is contained in:
omar committed 2026-11-02 09:49:29 +03:00
1 parent 7108026544
commit a1f5e43f5f
28 files changed
+1835 -102

No files matched your search

+32 -1
View File
@@ -148,7 +148,7 @@ Result = profile object; emits `profile` event.
Nickname rules: after trimming, 3–30 Unicode scalar values, no control characters.
### 4.4 `connect` — `{address, server_password?, channel?, channel_password?, identity_id?}`
### 4.4 `connect` — `{address, server_password?, channel?, channel_password?, identity_id?, nickname?}`
- `address`: `host`, `host:port`, `[v6]:port` (default port 9987). Not a path.
- `server_password`: optional string.
@@ -156,6 +156,9 @@ Nickname rules: after trimming, 3–30 Unicode scalar values, no control charact
path `"Parent/Child"`.
- `identity_id`: selected vault UID; omitted selects the default. Server-demanded proof-of-work is handled by the bounded identity CLI, not automatically during connect.
- Uses the persisted identity and nickname (`profile_missing` / `nickname_required` otherwise).
An optional `nickname` overrides the name for this connection only, without changing the saved identity,
name, nickname or UID. At connect time the core trims and validates 3–30 Unicode scalar values with no
control characters; an invalid override returns `invalid_nickname`, never a fallback to the saved name.
If the nickname is taken on the server, the server appends digits (e.g. `Name1`); the
snapshot shows the server-side name, the profile keeps the saved one.
- After connecting the core subscribes to all channels (`channelsubscribeall`), so the
@@ -165,6 +168,34 @@ Emits `state: connecting`, then on success `snapshot`, `audio_state`, `state: co
then the response `{"ok":true,"result":{"own_client_id":7}}`. On failure the response is
`connect_failed` and `state: disconnected` with `reason`.
#### Desktop bookmark orchestration (Electron IPC, not native commands)
Main resolves saved bookmarks before dispatching `connect`; the renderer never passes a saved password
as a native argument. These IPC handlers require the trusted application top frame:
- `bookmarks:password-state(id)` returns availability and saved/not-saved flags, never plaintext.
- `bookmarks:password-set(id, expectedAddress, kind, value)` saves or clears (`value: ""`) the server or
channel password. `kind` is `server` or `channel`; nonempty values use OS `safeStorage` encryption.
- `bookmarks:password-reveal(id, expectedAddress, kind)` returns plaintext only for an explicit Reveal
action. Changing the window, target or credential during native storage interaction invalidates it.
- `bookmarks:connect(connectionId, bookmarkId, startup)` reads current metadata and decrypts in main.
A failed decrypt/binding check stops the operation; it never substitutes an empty password. Automatic
startup with `auto_connect_muted` sends `set_audio {input_muted:true}` before `connect`, rechecking the
captured connection/session and bookmark after the acknowledgement. Output mute is never changed.
- `bookmarks:startup()` returns enabled bookmark metadata in tree order once per main-process lifetime.
Renderer reloads cannot issue a second startup batch. Offscreen runs return an empty list and refuse
bookmark connects with `test_safety` before dispatching a core command.
Passwords live only as `server_password_encrypted` / `channel_password_encrypted` in the atomic prefs
record. Each envelope binds its purpose and exact trimmed address. Generic prefs writes preserve the
current ciphertext for unchanged targets, clear it on address changes, and permit new-ID copies only
from a same-address bookmark. Clearing remains possible without an available key store. Linux
`basic_text`, unknown backends and legacy hardcoded-key `v10` ciphertext are rejected. Platform semantics:
[Electron safeStorage](https://www.electronjs.org/docs/latest/api/safe-storage); the legacy Linux format is
documented in [Chromium OSCrypt](https://chromium.googlesource.com/chromium/src/+/2d15a8eb787a31d5bbab0ff4a6a539a0df7c99dc/components/os_crypt/os_crypt_linux.cc).
Windows DPAPI does not protect against other software running as the same OS user. Actual keyring/Keychain
operation and portability are not established by Windows or simulated-backend tests.
### 4.5 `disconnect` — `{message?: string}`
Sends a clean `clientdisconnect` and waits (≤ 3 s) for the server. Result