anchorage_layer_simple/features/userwallet-login-state-machine.md
ncantu 5de870fa13 Update login state machine and add new login components
**Motivations:**
- Continue implementation of login state machine
- Add new login components for collect, share and sign screens
- Add utilities for login signing, validation, and publishing
- Update documentation for CNIL compliance and login workflow
- Add features for timeouts, backoff, and validator acceptance

**Root causes:**
- N/A (feature additions and improvements)

**Correctifs:**
- Update login state machine implementation
- Update graph resolver and sync service

**Evolutions:**
- Add LoginCollectShare and LoginSignScreen components
- Add useSignAndPostLogin hook
- Add login utilities: loginSign, loginPublish, loginValidation, collectSignatures
- Add sync utilities: syncUpdateGraph, syncValidate
- Add validatorsAccept utility
- Update App.tsx and LoginScreen.tsx
- Update loginBuilder and loginStateMachine services
- Add documentation for CNIL compliance, remote collection, timeouts, and validator acceptance
- Update identity types

**Pages affectées:**
- userwallet/src/App.tsx
- userwallet/src/components/LoginScreen.tsx
- userwallet/src/components/LoginCollectShare.tsx (new)
- userwallet/src/components/LoginSignScreen.tsx (new)
- userwallet/src/hooks/useSignAndPostLogin.ts (new)
- userwallet/src/services/graphResolver.ts
- userwallet/src/services/loginBuilder.ts
- userwallet/src/services/loginStateMachine.ts
- userwallet/src/services/syncService.ts
- userwallet/src/services/syncUpdateGraph.ts (new)
- userwallet/src/services/syncValidate.ts (new)
- userwallet/src/types/identity.ts
- userwallet/src/utils/relay.ts
- userwallet/src/utils/collectSignatures.ts (new)
- userwallet/src/utils/loginPublish.ts (new)
- userwallet/src/utils/loginSign.ts (new)
- userwallet/src/utils/loginValidation.ts (new)
- userwallet/src/utils/validatorsAccept.ts (new)
- userwallet/docs/synthese.md
- userwallet/docs/specs-champs-obligatoires-cnil.md
- userwallet/features/userwallet-acceptation-version-validateurs.md (new)
- userwallet/features/userwallet-dh-systematique-scan-fetch.md (new)
- features/userwallet-contrat-login-reste-a-faire.md
- features/userwallet-login-state-machine.md
- features/userwallet-validation-conformite.md
- features/userwallet-champs-obligatoires-cnil.md (new)
- features/userwallet-collecte-distante-2-devices.md (new)
- features/userwallet-timeouts-backoff.md (new)
- mempool (submodule)
- hash_list.txt
- hash_list_cache.txt
2026-01-26 15:04:07 +01:00

53 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UserWallet Machine à états login (3.1)
**Author:** Équipe 4NK
**Date:** 2026-01-26
## Objectif
Implémenter la machine à états formelle du login (S_LOGIN_* , E_* , transitions) décrite dans `specs.md`, et lintégrer au flux login existant.
## Impacts
- **Module** : `services/loginStateMachine.ts` (états, événements, `transition`, `getInitialLoginState`, `isTerminal`, `isErrorState`).
- **Hook** : `hooks/useLoginStateMachine` (`state`, `dispatch`, `reset`).
- **LoginScreen** : utilise le hook, dispatch des événements aux points clés (build path, challenge, publish, Retour), affichage de létat (sr-only, aria-live).
- **Flux** : E_SELECT_SERVICE / E_SELECT_MEMBER → E_PATH_OK | E_PATH_INCOMPLETE | E_PATH_INVALID → E_PAIRS_OK → E_CHALLENGE_READY → E_SIGNATURES_COMPLETE → E_PUBLISH_LOGIN_OK | E_PUBLISH_LOGIN_PARTIAL → E_LOCAL_VERDICT_ACCEPT | (reject) → S_LOGIN_SUCCESS | S_LOGIN_FAILURE. E_BACK, E_RETRY, E_SYNC_NOW, E_ADD_PAIR pour reprises.
## Modifications
- `src/services/loginStateMachine.ts` : types `LoginState`, `LoginEvent`, `TransitionResult` ; `transition(state, event)` ; helpers.
- `src/hooks/useLoginStateMachine.ts` : état local, `dispatch`, `reset`.
- `src/components/LoginScreen.tsx` : hook, dispatch dans `handleBuildPath`, `handleBuildChallenge`, `handlePublish` ; `handleBack` + E_BACK ; libellé état (sr-only).
- `src/index.css` : `.sr-only` pour le statut.
## États couverts
S_LOGIN_SELECT_SERVICE, S_LOGIN_SELECT_MEMBER, S_LOGIN_BUILD_PATH, S_LOGIN_CHECK_PAIRS, S_LOGIN_NEED_MORE_PAIRS, S_LOGIN_BUILD_CHALLENGE, S_LOGIN_COLLECT_SIGNATURES, S_LOGIN_PUBLISH_PROOF, S_LOGIN_VERIFY_LOCAL, S_LOGIN_SUCCESS, S_LOGIN_FAILURE, S_ERROR_RECOVERABLE.
## Compléments (après 3.1)
- **G_PAIRING_SATISFIED** : LoginScreen vérifie `isPairingSatisfied()` ; si faux, affiche « Pairing obligatoire » + « Configurer le pairing » → /manage-pairs, « Retour » → /.
- **E_ADD_PAIR / E_SYNC_NOW** : quand chemin incomplet ou S_ERROR_RECOVERABLE, boutons « Synchroniser » (→ /sync) et « Ajouter un pair » (→ /manage-pairs) ; dispatch avant navigation. E_ADD_PAIR depuis S_ERROR_RECOVERABLE → S_LOGIN_SELECT_SERVICE.
- **Timeouts** : `RELAY_FETCH_TIMEOUT_MS` sur tous les fetch relay. Pas de backoff. Voir `features/userwallet-timeouts-backoff.md`.
## Reste à faire (hors scope 3.1)
- Timeouts (réseau, collecte signatures), backoff.
- S_LOGIN_NEED_MORE_PAIRS : écran dédié (actuellement chemin incomplet + recovery).
## Modalités de déploiement
Déploiement classique du front userwallet.
## Modalités danalyse
- Parcourir le flux login (sélection → chemin → challenge → publication) et vérifier les transitions (DevTools, log état si besoin).
- Vérifier que Retour envoie E_BACK et navigue vers `/`.
- Publication partielle → S_ERROR_RECOVERABLE, pas S_LOGIN_SUCCESS.
## Références
- `userwallet/docs/specs.md` (machine à états)
- `features/userwallet-contrat-login-reste-a-faire.md` (§ 3.1)