**Motivations:** - Add new features and fixes for userwallet application - Update documentation for pairing, login state machine, and sync - Add new utilities for bloom filters, nonce store, and contract versioning - Fix mempool websocket offline issues **Root causes:** - N/A (feature additions and improvements) **Correctifs:** - Fix mempool websocket offline handling - Update ESLint configuration **Evolutions:** - Add login state machine service and hook - Add sync loop service - Add bloom filter utilities for anti-replay and state visibility - Add nonce store and contract version utilities - Update pairing confirmation and graph resolver services - Add new documentation for features and fixes - Update userwallet components (LoginScreen, SyncScreen) - Update types for contract, identity, and messages **Pages affectées:** - userwallet/src/components/LoginScreen.tsx - userwallet/src/components/SyncScreen.tsx - userwallet/src/hooks/useChannel.ts - userwallet/src/hooks/useLoginStateMachine.ts (new) - userwallet/src/services/graphResolver.ts - userwallet/src/services/pairingConfirm.ts - userwallet/src/services/syncService.ts - userwallet/src/services/syncLoop.ts (new) - userwallet/src/services/loginStateMachine.ts (new) - userwallet/src/types/contract.ts - userwallet/src/types/identity.ts - userwallet/src/types/message.ts - userwallet/src/utils/canonical.ts - userwallet/src/utils/identity.ts - userwallet/src/utils/indexedDbStorage.ts - userwallet/src/utils/relay.ts - userwallet/src/utils/verification.ts - userwallet/src/utils/bloom.ts (new) - userwallet/src/utils/contractVersion.ts (new) - userwallet/src/utils/nonceStore.ts (new) - userwallet/eslint.config.mjs - userwallet/package.json - userwallet/package-lock.json - userwallet/docs/synthese.md - userwallet/docs/specs-champs-obligatoires-cnil.md (new) - api-relay/README.md - features/userwallet-pairing-words-only-finalise.md - features/userwallet-anti-rejeu-etats-visibles-bloom.md (new) - features/userwallet-bloom-usage-sync.md (new) - features/userwallet-contrat-login-reste-a-faire.md (new) - features/userwallet-ecrans-login-a-valider.md (new) - features/userwallet-eslint-fix.md (new) - features/userwallet-login-state-machine.md (new) - features/userwallet-validation-conformite.md (new) - fixKnowledge/mempool-websocket-offline-fix.md (new) - mempool (submodule) - hash_list.txt - hash_list_cache.txt
48 lines
2.6 KiB
Markdown
48 lines
2.6 KiB
Markdown
# UserWallet – Anti-rejeu, états visibles, Bloom
|
||
|
||
**Author:** Équipe 4NK
|
||
**Date:** 2026-01-26
|
||
|
||
## Objectif
|
||
|
||
Implémenter les éléments « reste à faire » contrat/login (3.3, 3.4, 3.6) : anti-rejeu (nonce, timestamp), états visibles (indéchiffrable, non validé, statut relais), API Bloom.
|
||
|
||
## Impacts
|
||
|
||
- **Login** : vérification timestamp et nonce avant publication ; erreurs `X_NONCE_REUSED`, `X_TIMESTAMP_OUT_OF_WINDOW` ; persistance des nonces utilisés (IndexedDB).
|
||
- **Sync** : compteurs `indechiffrable`, `nonValide`, statut par relais (ok / indisponible) ; affichage dans SyncScreen.
|
||
- **Relais** : `getBloom(relay)` pour consommation optionnelle du Bloom filter.
|
||
|
||
## Modifications
|
||
|
||
**Fichiers ajoutés** : `utils/nonceStore.ts`, `services/syncLoop.ts`.
|
||
|
||
**3.4 Anti-rejeu**
|
||
|
||
- `utils/nonceStore.ts` : `init()`, `hasUsed(nonce)`, `markUsed(nonce, timestamp)`. IndexedDB `userwallet_nonce_cache`, TTL 1 h.
|
||
- `LoginScreen` : avant publish, `verifyTimestamp(proof.challenge.timestamp)` → sinon `X_TIMESTAMP_OUT_OF_WINDOW` ; `nonceStore.init()` puis `hasUsed(nonce)` → sinon `X_NONCE_REUSED` ; après publish réussi, `markUsed(nonce, timestamp)`.
|
||
|
||
**3.3 États visibles**
|
||
|
||
- `SyncService.sync()` : retourne en plus `indechiffrable` (nouveaux messages sans clé), `nonValide` (déchiffrés mais non validés), `relayStatus` (endpoint + ok par relais). Refactor : `processNewMessage`, `processMessageBatch`, `syncOneRelay`, `runSyncLoop` (dans `syncLoop.ts`) pour respecter max-lines / max-params.
|
||
- `SyncScreen` : affiche « Indéchiffrables (clé manquante) », « Non validés (ex. signature manquante) », « Statut relais » (OK / indisponible par relais).
|
||
|
||
**3.6 Bloom**
|
||
|
||
- `utils/relay.ts` : `getBloom(relay)` → `GET /bloom`, retourne le JSON. Pas d’usage dans le sync pour l’instant (optionnel).
|
||
|
||
## Modalités de déploiement
|
||
|
||
Déploiement classique du front userwallet. Aucune migration IndexedDB imposée : `userwallet_nonce_cache` est créé au premier `init()`.
|
||
|
||
## Modalités d’analyse
|
||
|
||
- **Anti-rejeu** : construire un challenge, publier, puis tenter de republier la même preuve → `X_NONCE_REUSED`. Construire un challenge, attendre > 5 min, publier → `X_TIMESTAMP_OUT_OF_WINDOW` si fenêtre par défaut.
|
||
- **États visibles** : lancer une sync avec relais mixte (OK / KO) et messages éventuels non déchiffrables ou non validés → vérifier les compteurs et le statut relais dans SyncScreen.
|
||
- **Bloom** : `getBloom(endpoint)` sur un relais avec `/bloom` → objet JSON.
|
||
|
||
## Références
|
||
|
||
- `features/userwallet-contrat-login-reste-a-faire.md`
|
||
- `userwallet/docs/specs.md` (anti-rejeu, états)
|