Document multiple identities in AGENTS.md
This commit is contained in:
1 file changed
+50
-9
@@ -33,13 +33,13 @@ src/signer/approval.rs asking the user (timeout ⇒ deny)
|
||||
src/signer/policy.rs the auto-approval rate limit
|
||||
src/store/apps.rs the registry of approved applications + their permissions
|
||||
src/store/audit.rs the activity log (metadata only, mode 0600)
|
||||
src/store/keys.rs key storage (Secret Service, one item per key)
|
||||
src/store/keys.rs identity + device keys; listing without reading secrets
|
||||
src/ui/approval.rs approval dialogs
|
||||
src/ui/apps_view.rs the apps page (permission table + revoke)
|
||||
src/ui/activity_view.rs the activity page
|
||||
src/ui/kind.rs human names for the common event kinds
|
||||
src/ui/plain.rs plain-text rows/banners/dialogs (markup off)
|
||||
src/ui/keys_view.rs the keys page
|
||||
src/ui/keys_view.rs the keys page (identity list + management)
|
||||
src/ui/signer_view.rs the signer page (pairing string, QR, state)
|
||||
src/ui/qr.rs QR → GdkTexture
|
||||
data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, style.css)
|
||||
@@ -131,6 +131,42 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
**Regent extension**, not NIP-46; the requested `perms` from a `connect`
|
||||
(`params[2]`) are shown in the pairing dialog but never auto-granted.
|
||||
|
||||
## Multiple identities (M7a)
|
||||
|
||||
- **The invariant:** the responder resolves a request **only** from the app's
|
||||
stored identity (`App.identity`). The UI's *current identity*
|
||||
(GSettings `current-identity`) is never read at request time — it only scopes
|
||||
pages (M7b) and sets the **default for new pairings**. Switching it therefore
|
||||
never re-identifies an existing app.
|
||||
- Each approved app is bound to one identity at pairing. NIP-46 clients mint a
|
||||
client keypair per connection, so the same app can be paired under two
|
||||
identities in parallel (two client pubkeys → two registry entries). A client
|
||||
that reuses one keypair for two identities cannot be distinguished — requests
|
||||
carry no identity field — so re-pairing **rebinds**, and that resets the
|
||||
policy.
|
||||
- **Rebinding clears the stored policy.** `AppRegistry::approve` only preserves
|
||||
a policy when the identity is unchanged; a permission granted while signing as
|
||||
A must not carry over to B. The approval dialog warns about this.
|
||||
- The registry is keyed by **client pubkey only** (unique per connection). Audit
|
||||
entries carry `identity: Option<String>`; pre-M7 entries have none and are
|
||||
shown under every scope (M7b).
|
||||
- The keyring/API split: `KeyStore::list_user_keys()` (no secrets),
|
||||
`user_key(pubkey)` (on demand), `SignerConfig.keys: IdentityKeys`
|
||||
(`Fixed`/`Many` for tests, `Store(Arc<KeyStore>)` in production). The
|
||||
responder loads the key **after** the approval, just before signing.
|
||||
- One-time migrations run in this order: migrate the keyring item → resolve the
|
||||
current identity (setting valid, else first key) → bind legacy apps
|
||||
(`bind_legacy`) → only then serve. `AppState::refresh_identities` does the
|
||||
latter two at startup and after any key change.
|
||||
- Keys page: list, **Add/Import**, per-key **Rename / Copy / Export / Remove**,
|
||||
and **Use for new pairings**. Removing a key clears it as current, revokes the
|
||||
apps bound to it (the dialog names them), and deletes the item.
|
||||
- Approval dialogs show **"Signing as: {name} ({npub})"**; in-app pairing uses
|
||||
the current identity and warns when it would rebind an existing app.
|
||||
- Headless: `--headless`/`--pair` take **`--key <npub|hex>`** (default: the
|
||||
current identity). Serving resolves per app, so headless needs no single
|
||||
"active" key.
|
||||
|
||||
## Headless mode and CLI pairing (M6)
|
||||
|
||||
- `regent --headless` runs the signer with **no window** (and no display): it is
|
||||
@@ -183,13 +219,18 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
|
||||
## Keys
|
||||
|
||||
- The **identity key** is the user's `nsec`. It lives in the system keyring and
|
||||
is used only to sign events and to do nip04/nip44 on the user's behalf.
|
||||
- The **device key** is generated on first use and used for NIP-46 transport
|
||||
(encrypting/decrypting requests, signing responses). It is what relays and
|
||||
requesting apps see, and it can be rotated without touching the identity key.
|
||||
- Both are individual keyring items with attributes
|
||||
`application=org.kosmos.raucao.Regent` and `kind=user|device`.
|
||||
- **Any number of identity keys** (`nsec`s) live in the system keyring; they sign
|
||||
events and do nip04/nip44. Identity items are addressed by
|
||||
`application=org.kosmos.raucao.Regent`, `kind=user`, `pubkey=<hex>`; the item
|
||||
**label is the user-facing name**. Listing uses attributes/labels only — a
|
||||
secret is read **on demand**, when a request actually needs it, never all at
|
||||
startup (the exposure window stays small, and a locked keyring fails closed).
|
||||
- **One device key** (`kind=device`), generated on first use, used for NIP-46
|
||||
transport (encrypting/decrypting requests, signing responses). It is what
|
||||
relays and requesting apps see and can be rotated without touching any
|
||||
identity.
|
||||
- A legacy single `kind=user` item (no `pubkey` attribute) is migrated in place
|
||||
on connect; its secret is read exactly once for that.
|
||||
- **Never write the `nsec` to a file**, log it, or put it in argv/env. The
|
||||
plaintext strings we handle are wrapped in `zeroize::Zeroizing`. Verified: on
|
||||
drop, `nostr::SecretKey` calls secp256k1's `non_secure_erase()`, which is a
|
||||
|
||||
Reference in new issue
Block a user