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:
vjrj 2026-07-10 20:20:04 +02:00
parent d36fd05741
commit 993f7b37ab
25 changed files with 597 additions and 33 deletions

View file

@ -415,7 +415,15 @@
"copy": "Copiar",
"copied": "Copiao",
"save": "Guardar",
"saved": "Perfil guardáu"
"saved": "Perfil guardáu",
"identities": "Les tos identidaes",
"identitiesHelp": "Ten identidaes separaes — cada una coles sos mensaxes y contactos. Toes salen de la to única copia de seguridá, asina que camudar nun amiesta nada que recordar.",
"identityLabel": "Identidá {n}",
"current": "N'usu",
"newIdentity": "Identidá nueva",
"switchTitle": "¿Camudar d'identidá?",
"switchBody": "Los mensaxes y contactos guárdense per separao pa cada identidá. Pues volver cuando quieras.",
"switchAction": "Camudar"
},
"chatList": {
"title": "Mensaxes",

View file

@ -418,7 +418,15 @@
"copy": "Copy",
"copied": "Copied",
"save": "Save",
"saved": "Profile saved"
"saved": "Profile saved",
"identities": "Your identities",
"identitiesHelp": "Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.",
"identityLabel": "Identity {n}",
"current": "In use",
"newIdentity": "New identity",
"switchTitle": "Switch identity?",
"switchBody": "Messages and contacts are kept separate for each identity. You can switch back anytime.",
"switchAction": "Switch"
},
"chatList": {
"title": "Messages",

View file

@ -417,7 +417,15 @@
"copy": "Copiar",
"copied": "Copiado",
"save": "Guardar",
"saved": "Perfil guardado"
"saved": "Perfil guardado",
"identities": "Tus identidades",
"identitiesHelp": "Ten identidades separadas — cada una con sus mensajes y contactos. Todas salen de tu única copia de seguridad, así que cambiar no añade nada que recordar.",
"identityLabel": "Identidad {n}",
"current": "En uso",
"newIdentity": "Nueva identidad",
"switchTitle": "¿Cambiar de identidad?",
"switchBody": "Los mensajes y contactos se guardan por separado para cada identidad. Puedes volver cuando quieras.",
"switchAction": "Cambiar"
},
"chatList": {
"title": "Mensajes",

View file

@ -414,7 +414,15 @@
"copy": "Copiar",
"copied": "Copiado",
"save": "Guardar",
"saved": "Perfil guardado"
"saved": "Perfil guardado",
"identities": "As tuas identidades",
"identitiesHelp": "Mantém identidades separadas — cada uma com as suas mensagens e contactos. Todas vêm da tua única cópia de segurança, por isso mudar não acrescenta nada para lembrar.",
"identityLabel": "Identidade {n}",
"current": "Em uso",
"newIdentity": "Nova identidade",
"switchTitle": "Mudar de identidade?",
"switchBody": "As mensagens e contactos são guardados separadamente para cada identidade. Podes voltar quando quiseres.",
"switchAction": "Mudar"
},
"chatList": {
"title": "Mensagens",

View file

@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 4
/// Strings: 1548 (387 per locale)
/// Strings: 1580 (395 per locale)
///
/// Built on 2026-07-10 at 17:18 UTC
/// Built on 2026-07-10 at 18:22 UTC
// coverage:ignore-file
// ignore_for_file: type=lint, unused_import

View file

@ -713,6 +713,14 @@ class _Translations$profile$ast extends Translations$profile$en {
@override String get copied => 'Copiao';
@override String get save => 'Guardar';
@override String get saved => 'Perfil guardáu';
@override String get identities => 'Les tos identidaes';
@override String get identitiesHelp => 'Ten identidaes separaes — cada una coles sos mensaxes y contactos. Toes salen de la to única copia de seguridá, asina que camudar nun amiesta nada que recordar.';
@override String identityLabel({required Object n}) => 'Identidá ${n}';
@override String get current => 'N\'usu';
@override String get newIdentity => 'Identidá nueva';
@override String get switchTitle => '¿Camudar d\'identidá?';
@override String get switchBody => 'Los mensaxes y contactos guárdense per separao pa cada identidá. Pues volver cuando quieras.';
@override String get switchAction => 'Camudar';
}
// Path: chatList
@ -1469,6 +1477,14 @@ extension on TranslationsAst {
'profile.copied' => 'Copiao',
'profile.save' => 'Guardar',
'profile.saved' => 'Perfil guardáu',
'profile.identities' => 'Les tos identidaes',
'profile.identitiesHelp' => 'Ten identidaes separaes — cada una coles sos mensaxes y contactos. Toes salen de la to única copia de seguridá, asina que camudar nun amiesta nada que recordar.',
'profile.identityLabel' => ({required Object n}) => 'Identidá ${n}',
'profile.current' => 'N\'usu',
'profile.newIdentity' => 'Identidá nueva',
'profile.switchTitle' => '¿Camudar d\'identidá?',
'profile.switchBody' => 'Los mensaxes y contactos guárdense per separao pa cada identidá. Pues volver cuando quieras.',
'profile.switchAction' => 'Camudar',
'chatList.title' => 'Mensaxes',
'chatList.empty' => 'Entá nun hai charres. Escríbi-y a alguien dende\'l mercáu.',
'chat.title' => 'Charra',

View file

@ -1330,6 +1330,30 @@ class Translations$profile$en {
/// en: 'Profile saved'
String get saved => 'Profile saved';
/// en: 'Your identities'
String get identities => 'Your identities';
/// en: 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.'
String get identitiesHelp => 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.';
/// en: 'Identity {n}'
String identityLabel({required Object n}) => 'Identity ${n}';
/// en: 'In use'
String get current => 'In use';
/// en: 'New identity'
String get newIdentity => 'New identity';
/// en: 'Switch identity?'
String get switchTitle => 'Switch identity?';
/// en: 'Messages and contacts are kept separate for each identity. You can switch back anytime.'
String get switchBody => 'Messages and contacts are kept separate for each identity. You can switch back anytime.';
/// en: 'Switch'
String get switchAction => 'Switch';
}
// Path: chatList
@ -2233,6 +2257,14 @@ extension on Translations {
'profile.copied' => 'Copied',
'profile.save' => 'Save',
'profile.saved' => 'Profile saved',
'profile.identities' => 'Your identities',
'profile.identitiesHelp' => 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.',
'profile.identityLabel' => ({required Object n}) => 'Identity ${n}',
'profile.current' => 'In use',
'profile.newIdentity' => 'New identity',
'profile.switchTitle' => 'Switch identity?',
'profile.switchBody' => 'Messages and contacts are kept separate for each identity. You can switch back anytime.',
'profile.switchAction' => 'Switch',
'chatList.title' => 'Messages',
'chatList.empty' => 'No conversations yet. Message someone from the market.',
'chat.title' => 'Chat',

View file

@ -715,6 +715,14 @@ class _Translations$profile$es extends Translations$profile$en {
@override String get copied => 'Copiado';
@override String get save => 'Guardar';
@override String get saved => 'Perfil guardado';
@override String get identities => 'Tus identidades';
@override String get identitiesHelp => 'Ten identidades separadas — cada una con sus mensajes y contactos. Todas salen de tu única copia de seguridad, así que cambiar no añade nada que recordar.';
@override String identityLabel({required Object n}) => 'Identidad ${n}';
@override String get current => 'En uso';
@override String get newIdentity => 'Nueva identidad';
@override String get switchTitle => '¿Cambiar de identidad?';
@override String get switchBody => 'Los mensajes y contactos se guardan por separado para cada identidad. Puedes volver cuando quieras.';
@override String get switchAction => 'Cambiar';
}
// Path: chatList
@ -1473,6 +1481,14 @@ extension on TranslationsEs {
'profile.copied' => 'Copiado',
'profile.save' => 'Guardar',
'profile.saved' => 'Perfil guardado',
'profile.identities' => 'Tus identidades',
'profile.identitiesHelp' => 'Ten identidades separadas — cada una con sus mensajes y contactos. Todas salen de tu única copia de seguridad, así que cambiar no añade nada que recordar.',
'profile.identityLabel' => ({required Object n}) => 'Identidad ${n}',
'profile.current' => 'En uso',
'profile.newIdentity' => 'Nueva identidad',
'profile.switchTitle' => '¿Cambiar de identidad?',
'profile.switchBody' => 'Los mensajes y contactos se guardan por separado para cada identidad. Puedes volver cuando quieras.',
'profile.switchAction' => 'Cambiar',
'chatList.title' => 'Mensajes',
'chatList.empty' => 'Aún no hay conversaciones. Escribe a alguien desde el mercado.',
'chat.title' => 'Chat',

View file

@ -712,6 +712,14 @@ class _Translations$profile$pt extends Translations$profile$en {
@override String get copied => 'Copiado';
@override String get save => 'Guardar';
@override String get saved => 'Perfil guardado';
@override String get identities => 'As tuas identidades';
@override String get identitiesHelp => 'Mantém identidades separadas — cada uma com as suas mensagens e contactos. Todas vêm da tua única cópia de segurança, por isso mudar não acrescenta nada para lembrar.';
@override String identityLabel({required Object n}) => 'Identidade ${n}';
@override String get current => 'Em uso';
@override String get newIdentity => 'Nova identidade';
@override String get switchTitle => 'Mudar de identidade?';
@override String get switchBody => 'As mensagens e contactos são guardados separadamente para cada identidade. Podes voltar quando quiseres.';
@override String get switchAction => 'Mudar';
}
// Path: chatList
@ -1467,6 +1475,14 @@ extension on TranslationsPt {
'profile.copied' => 'Copiado',
'profile.save' => 'Guardar',
'profile.saved' => 'Perfil guardado',
'profile.identities' => 'As tuas identidades',
'profile.identitiesHelp' => 'Mantém identidades separadas — cada uma com as suas mensagens e contactos. Todas vêm da tua única cópia de segurança, por isso mudar não acrescenta nada para lembrar.',
'profile.identityLabel' => ({required Object n}) => 'Identidade ${n}',
'profile.current' => 'Em uso',
'profile.newIdentity' => 'Nova identidade',
'profile.switchTitle' => 'Mudar de identidade?',
'profile.switchBody' => 'As mensagens e contactos são guardados separadamente para cada identidade. Podes voltar quando quiseres.',
'profile.switchAction' => 'Mudar',
'chatList.title' => 'Mensagens',
'chatList.empty' => 'Ainda não há conversas. Escreve a alguém a partir do mercado.',
'chat.title' => 'Conversa',