feat(identity): switch social identity, all from the one backup
Adds pseudonymous, switchable social identities derived from the SAME root seed via an account index (NostrKeyDerivation.deriveFromSeed(seed, account)). HKDF is one-way so accounts are unlinkable to the Ğ1 key; account 0 is the original identity, byte-for-byte unchanged (no rotation for current users), and every account regenerates from the single seed — so switching adds nothing to back up. - SocialAccountStore: keystore-backed active account + max created. - Per-identity stores (chats, profile, name cache) namespaced by account scope (account 0 = legacy keys, no migration) so identities never mix. - switchSocialAccount() re-derives the identity, re-scopes the stores and restarts the inbox listener; RestartWidget rebuilds the tree to pick up the new social singletons. DB/inventory untouched. - Profile 'Your identities' switcher: list, create, switch (with a note that messages/contacts are kept separate per identity). i18n en/es/pt/ast. Tests: account-indexed derivation (legacy 0 unchanged, accounts distinct yet deterministic, negatives rejected); SocialAccountStore; per-identity store scope isolation. Resolves the flagged 'change identity' decision (open-decisions §B). Known: switching resets navigation to home (full tree rebuild).
This commit is contained in:
parent
d36fd05741
commit
993f7b37ab
25 changed files with 597 additions and 33 deletions
|
|
@ -23,9 +23,13 @@ class ChatSummary {
|
|||
}
|
||||
|
||||
class MessageStore {
|
||||
MessageStore(this._store);
|
||||
/// [accountScope] namespaces the keys per social identity (empty = the
|
||||
/// original identity's legacy keys). See [socialAccountScope].
|
||||
MessageStore(this._store, {String accountScope = ''})
|
||||
: _base = accountScope.isEmpty ? 'tane.social.' : 'tane.social.$accountScope.';
|
||||
|
||||
final SecretStore _store;
|
||||
final String _base;
|
||||
|
||||
/// Serializes [append]'s read-modify-write. Several sources now write the same
|
||||
/// conversation concurrently (the app-wide inbox listener and an open chat's
|
||||
|
|
@ -33,17 +37,15 @@ class MessageStore {
|
|||
/// read the same history and the second write would clobber the first.
|
||||
Future<void> _writeTail = Future.value();
|
||||
|
||||
static const _prefix = 'tane.social.chat.';
|
||||
|
||||
/// Index of peers we have a conversation with (the keystore is key/value with
|
||||
/// no key enumeration, so we track the list ourselves).
|
||||
static const _indexKey = 'tane.social.chats';
|
||||
String get _indexKey => '${_base}chats';
|
||||
|
||||
/// Keep only the most recent [_cap] messages per conversation, to bound the
|
||||
/// keystore entry size.
|
||||
static const _cap = 200;
|
||||
|
||||
String _key(String peerPubkey) => '$_prefix$peerPubkey';
|
||||
String _key(String peerPubkey) => '${_base}chat.$peerPubkey';
|
||||
|
||||
/// Messages exchanged with [peerPubkey], oldest first.
|
||||
Future<List<PrivateMessage>> history(String peerPubkey) async {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue