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).
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
import '../security/secret_store.dart';
|
|
|
|
/// Your own display name and short "about", persisted locally (keystore-backed,
|
|
/// no plaintext at rest). The network copy is a published NIP-01 kind:0 event;
|
|
/// this local copy prefills the editor and works offline.
|
|
class ProfileStore {
|
|
/// [accountScope] namespaces the keys per social identity (empty = the
|
|
/// original identity's legacy keys). See [socialAccountScope].
|
|
ProfileStore(this._store, {String accountScope = ''})
|
|
: _base = accountScope.isEmpty
|
|
? 'tane.social.profile.'
|
|
: 'tane.social.$accountScope.profile.';
|
|
|
|
final SecretStore _store;
|
|
final String _base;
|
|
|
|
String get _nameKey => '${_base}name';
|
|
String get _aboutKey => '${_base}about';
|
|
String get _g1Key => '${_base}g1';
|
|
|
|
Future<String> name() async => (await _store.read(_nameKey)) ?? '';
|
|
Future<String> about() async => (await _store.read(_aboutKey)) ?? '';
|
|
|
|
/// Your Ğ1 (Duniter) address, if you chose to share one.
|
|
Future<String> g1() async => (await _store.read(_g1Key)) ?? '';
|
|
|
|
Future<void> save({
|
|
required String name,
|
|
required String about,
|
|
String g1 = '',
|
|
}) async {
|
|
await _store.write(_nameKey, name.trim());
|
|
await _store.write(_aboutKey, about.trim());
|
|
await _store.write(_g1Key, g1.trim());
|
|
}
|
|
}
|