mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-03 16:41:27 +01:00
The data directory is the whole diary, and until now keeping a copy of it was someone's manual job. The server can now register itself in Proton Drive as a device — its own sync root, next to the desktop clients — and keep that folder equal to DIARY_DATA_DIR, encrypted client-side by the same Rust SDK the Linux client uses. One interactive `narl-diary proton-login`, then nothing prompts again. The stored session carries the tokens, the mailbox password (the key chain is rebuilt from it on every start) and the account key salts, which have to be captured at login: `core/v4/keys/salts` needs the `locked` scope, and only a password-login token has it. Refresh tokens are single-use, so every rotation is written back before it can be needed. It lives as a 0600 file next to the database, on the same volume as the data it protects; `--features keyring` puts it in the OS keyring instead, for hosts that have a Secret Service. The mirror is one-way and change-driven: writes mark the diary dirty and it is mirrored once the writing stops, with an interval as the backstop — an hour of writing is one backup, not sixty. `diary.db` goes up as a VACUUM INTO snapshot, so it is a real point in time rather than a file copied out from under a writer, and as a new revision each time, so Proton keeps the older ones. Uploads are immutable, so they are written once and skipped by size afterwards. Deletions do not propagate unless asked: a backup that forgets on command is one accident away from being no backup at all. Identification follows Proton's third-party rules — an honest `external-drive-narl_diary@<version>-alpha`, the disclosure printed before any credential is asked for, and remembered folder uids instead of walking the tree every run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D5Gk8FPkRXu1e6Nj2BCRE1
42 lines
1.4 KiB
Bash
42 lines
1.4 KiB
Bash
# The one and only account. Both are checked in constant time on login.
|
|
DIARY_USER=narl
|
|
DIARY_PASSWORD=change-me
|
|
|
|
# Signs session cookies. Rotate it to log every device out. 32+ random chars.
|
|
# Generate one with: openssl rand -base64 32
|
|
DIARY_SECRET=replace-with-32-random-characters
|
|
|
|
# Where the SQLite database and uploaded media live.
|
|
DIARY_DATA_DIR=./data
|
|
|
|
# Address to listen on. Put a TLS terminating reverse proxy in front of this.
|
|
DIARY_BIND=127.0.0.1:4242
|
|
|
|
# How long a login lasts, in days.
|
|
DIARY_SESSION_DAYS=30
|
|
|
|
# Largest single upload, in megabytes.
|
|
DIARY_MAX_UPLOAD_MB=64
|
|
|
|
# Set to 1 once the app is served over HTTPS, so the cookie gets `Secure`.
|
|
DIARY_SECURE_COOKIE=0
|
|
|
|
# --- Proton Drive backup -----------------------------------------------------
|
|
# Off until `narl-diary proton-login` stores a session under DIARY_DATA_DIR.
|
|
# These only shape how often the mirror runs.
|
|
|
|
# The device the server registers in Proton Drive; its sync root is the folder
|
|
# the diary is mirrored into.
|
|
DIARY_PROTON_DEVICE=narl-diary
|
|
|
|
# Backstop between runs, in minutes. 0 leaves it change-driven only.
|
|
DIARY_BACKUP_INTERVAL_MIN=60
|
|
|
|
# How long the diary must be quiet after a change before it is mirrored, so a
|
|
# writing session uploads once rather than after every save.
|
|
DIARY_BACKUP_DEBOUNCE_SEC=300
|
|
|
|
# Set to 1 to let a deletion here trash the mirrored file there. Off by
|
|
# default: a backup that forgets on command is one accident from being none.
|
|
DIARY_BACKUP_PRUNE=0
|