**Motivations:** - Implement BIP39 mnemonic import for identity creation - Add password-based key protection for enhanced security - Improve pairing workflow with QR code and URL display - Migrate hash cache from LocalStorage to IndexedDB for better scalability - Update signet-dashboard and mempool components **Root causes:** - N/A (feature implementations) **Correctifs:** - N/A (no bug fixes in this commit) **Evolutions:** - BIP39 mnemonic import: Support for 12/24 word English mnemonics with BIP32 derivation path m/44'/0'/0'/0/0 - Key protection: Password-based encryption of private keys at rest with unlock/lock functionality - Pairing workflow: QR code and URL display for device pairing, form-based word exchange between devices - IndexedDB migration: Hash cache moved from LocalStorage to IndexedDB to avoid size limitations - Global action bar: URL parameter support for navigation - Pairing connection: Enhanced pairing status management **Pages affectées:** - userwallet/src/utils/identity.ts - userwallet/src/utils/keyProtection.ts - userwallet/src/utils/sessionUnlockedKey.ts - userwallet/src/utils/indexedDbStorage.ts - userwallet/src/utils/cache.ts - userwallet/src/utils/pairing.ts - userwallet/src/components/UnlockScreen.tsx - userwallet/src/components/PairingDisplayScreen.tsx - userwallet/src/components/PairingSetupBlock.tsx - userwallet/src/components/GlobalActionBar.tsx - userwallet/src/components/HomeScreen.tsx - userwallet/src/components/ImportIdentityScreen.tsx - userwallet/src/components/DataExportImportScreen.tsx - userwallet/src/hooks/useIdentity.ts - userwallet/src/hooks/usePairingConnected.ts - userwallet/src/services/syncService.ts - userwallet/src/services/pairingConfirm.ts - userwallet/src/App.tsx - userwallet/package.json - userwallet/docs/specs.md - userwallet/docs/storage.md - userwallet/docs/synthese.md - signet-dashboard/public/*.html - signet-dashboard/public/app.js - signet-dashboard/public/styles.css - mempool (submodule updates) - hash_list.txt, hash_list_cache.txt, utxo_list.txt, utxo_list_cache.txt, fees_list.txt - features/*.md (documentation files)
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { useState, FormEvent } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useIdentity } from '../hooks/useIdentity';
|
|
import { useErrorHandler } from '../hooks/useErrorHandler';
|
|
import { ErrorDisplay } from './ErrorDisplay';
|
|
|
|
export function CreateIdentityScreen(): JSX.Element {
|
|
const navigate = useNavigate();
|
|
const { createNewIdentity } = useIdentity();
|
|
const { error, handleError, clearError } = useErrorHandler();
|
|
const [name, setName] = useState('');
|
|
const [isCreating, setIsCreating] = useState(false);
|
|
|
|
const handleSubmit = async (e: FormEvent<HTMLFormElement>): Promise<void> => {
|
|
e.preventDefault();
|
|
setIsCreating(true);
|
|
clearError();
|
|
try {
|
|
createNewIdentity(name || undefined);
|
|
navigate('/');
|
|
} catch (err) {
|
|
handleError(err, 'Erreur lors de la création de l\'identité');
|
|
} finally {
|
|
setIsCreating(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<main>
|
|
<h1>Créer une identité locale</h1>
|
|
{error !== null && <ErrorDisplay error={error} onDismiss={clearError} />}
|
|
<form onSubmit={handleSubmit} aria-label="Formulaire de création d'identité">
|
|
<div>
|
|
<label htmlFor="name">
|
|
Nom local de l'identité (optionnel)
|
|
<input
|
|
id="name"
|
|
type="text"
|
|
value={name}
|
|
onChange={(e) => {
|
|
setName(e.target.value);
|
|
}}
|
|
placeholder="Mon identité"
|
|
/>
|
|
</label>
|
|
</div>
|
|
<div>
|
|
<button type="submit" disabled={isCreating}>
|
|
{isCreating ? 'Création...' : "Générer l'identité"}
|
|
</button>
|
|
<button type="button" onClick={() => navigate('/')}>
|
|
Annuler
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
);
|
|
}
|