Nostr_Keynctr/CHECKPOINT-encryption.md

122 lines
5.7 KiB
Markdown

# Checkpoint — Profile metadata publishing + profile pictures (2026-08-22)
**App renamed to Keynectr (2026-08-23).** A stopping point you can return to if this session is closed. Everything below was
verified green at the moment this file was written.
## Where things are
- Project: `/home/avi/Projects/Nostr_Keynctr` (renamed from `0_Nostr` after commit `1116dfd`)
- Git repo: `master` @ `a6329d5` ("Publish profile metadata (name + picture) so external
clients show it"). Before it: `db81f8d` (profile deletion with undo), `9a8f334`
(audit checkpoint refresh), and the 2026-08-21 audit-fix commits (`f7db29e`, `d90b6e5`,
`130d7e2`).
- Working tree is **clean** apart from this checkpoint update, which is committed right after.
## What was completed
**Problem:** profiles created in the app never published a Nostr kind 0 metadata event,
so other clients showed generated petnames ("evil iguana", "homeless leech") or a
truncated npub instead of the user's chosen name.
1. **Automatic metadata on creation**`create_profile` now publishes a kind 0 event
with the label as `name`/`display_name` to all enabled relays (best-effort; relay
failures never block creation).
2. **"Publish name" action for existing profiles** — new button on every Profiles-screen
card plus CLI `publish-name <npub>`. Returns a per-relay report shown in the UI.
3. **Profile pictures end-to-end**
- Vault: optional `picture: Option<String>` per profile (serde default → old vaults
load unchanged).
- Backend: `set_profile_picture` validates http(s) URLs only, stores the URL, and
publishes kind 0 including `picture`; clearing supported (`None`).
- GUI: "Picture" button opens a modal — paste a URL, upload a file via the existing
nostr.build pipeline, or remove; avatar shows the picture everywhere in-app.
- CLI: `set-picture <npub> <url>`.
4. **Nested-runtime safety** — metadata publishing runs on a dedicated OS thread with its
own tokio runtime, so both sync (CLI) and async (IPC server) callers are safe.
5. **Finished prior session's delete/undo work** — exposed `undo_history` in
`AppStateView`, fixed invalid Button variants / missing icon / null-safety errors so
the frontend typechecks again.
6. **Test hygiene fix**`Settings::default()` points at real relays and tests were
silently publishing events to them (one got rate-limited by damus.io). All test suites
now use offline settings; test time dropped from ~126 s to ~3 s.
## Commits added in this session
- `7c6a085` Rename the app to Keynectr
- `ae5ddda` Allow new profile methods through the Electron IPC allowlist
- `a6329d5` Publish profile metadata (name + picture) so external clients show it
**Gotcha for future work:** any new backend request type must also be added to
`RENDERER_METHODS` in `frontend/electron/main.ts`, or the main process rejects it with
"rejected renderer method" before it reaches the Rust backend.
## Verification commands run (all green)
Rust (repo root):
```
cargo test # 96 passed; 0 failed
cargo clippy --all-targets # 0 errors/warnings from session code
cargo fmt --check # clean
cargo build --release # success
```
Frontend (`frontend/`):
```
npm test # 14 files, 78 tests passed
npm run typecheck # clean
npm run lint # 0 errors
npm run format:check # clean
npm run build # vite build success
npm run electron:build # tsc electron main success
```
## How to use / reproduce
GUI:
```bash
cd ~/Projects/Nostr_Keynctr/frontend && npm start
```
- New profiles publish their name automatically on creation.
- Existing profiles: **Profiles → Publish name** button, or **Picture** button to set a
photo (URL paste or file upload) which publishes immediately.
CLI:
```bash
B=~/Projects/Nostr_Keynctr/target/release/keynectr
$B list # show profiles
$B relays enable wss://nos.lol # enable at least one relay first
$B publish-name <npub> # republish stored name
$B set-picture <npub> https://…/img.png # set + publish picture
```
Verified live during the session: kind 0 events confirmed present on nos.lol,
relay.primal.net, relay.damus.io and the user's own wss://nostr.l484.com via direct
websocket queries; Iris shows the stored names after publish.
## Notes & next steps
- Nostr has no relay-to-relay sync: names/pictures are only visible on relays they were
published to. Keep major relays enabled so clients that don't read your own relay can
see the profile.
- Clients cache profiles; hard-refresh (Ctrl+Shift+R) after republishing.
- **Next feature (agreed 2026-08-22): NIP-05 identifiers.** Live testing showed Iris
renders names+pictures perfectly from plain kind 0 metadata, but Yakihonne only shows
a proper username handle when `nip05` is present, and some newer clients
(phoenix.social) are picky about relay coverage. Plan: add an optional NIP-05
identifier field per profile (GUI + CLI), include it in published metadata, plus docs
or a helper for serving `.well-known/nostr.json` on the user's domain (the HTTP side
cannot be done by the app alone).
- Other candidates: rename profiles (edit label + republish), banner/about fields in the
edit UI.
- **Rename details:** binary is now `keynectr`; data lives in `~/.local/share/keynectr`
(auto-migrated from `nost-feed-manager` on first run — verified live). The KDF verifier
string in crypto.rs was deliberately NOT renamed so old encrypted backups stay readable.
If a GitHub remote is ever added, rename the repo to `Nostr_Keynctr` there too.
- Relay config at time of writing (all enabled): nos.lol, relay.primal.net, l484.com
(user's own), damus.io, snort.social, soloco.nl; relay.nostr.band added but was
unreachable (handshake timeout) — retry enabling later.