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
30
apps/app_seeds/lib/ui/restart_widget.dart
Normal file
30
apps/app_seeds/lib/ui/restart_widget.dart
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Rebuilds its whole subtree from scratch on demand — used to apply a social
|
||||
/// identity switch, which re-registers the social singletons in the locator and
|
||||
/// needs the widget tree (router, screens, sessions) rebuilt to pick them up.
|
||||
///
|
||||
/// [builder] is re-invoked on each restart, so it should read its dependencies
|
||||
/// fresh (e.g. from the service locator) rather than close over stale ones.
|
||||
class RestartWidget extends StatefulWidget {
|
||||
const RestartWidget({required this.builder, super.key});
|
||||
|
||||
final Widget Function() builder;
|
||||
|
||||
/// Tears down and rebuilds everything under the nearest [RestartWidget].
|
||||
static void restart(BuildContext context) =>
|
||||
context.findAncestorStateOfType<_RestartWidgetState>()?.restart();
|
||||
|
||||
@override
|
||||
State<RestartWidget> createState() => _RestartWidgetState();
|
||||
}
|
||||
|
||||
class _RestartWidgetState extends State<RestartWidget> {
|
||||
Key _key = UniqueKey();
|
||||
|
||||
void restart() => setState(() => _key = UniqueKey());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
KeyedSubtree(key: _key, child: widget.builder());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue