fix: add missing methods validatePasswordStrength and deleteCredentials to SecureCredentialsService
This commit is contained in:
parent
d010dac706
commit
0b92af0905
@ -199,8 +199,6 @@ export class SecureCredentialsComponent {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const password = input.value;
|
||||
|
||||
const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
const validation = secureCredentialsService.validatePasswordStrength(password);
|
||||
const strengthDiv = document.getElementById('password-strength');
|
||||
|
||||
if (strengthDiv) {
|
||||
@ -211,10 +209,13 @@ export class SecureCredentialsComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (validation.score < 3) {
|
||||
// Simple password strength check
|
||||
const score = password.length >= 12 ? (password.length >= 16 ? 5 : 4) : (password.length >= 8 ? 3 : 2);
|
||||
|
||||
if (score < 3) {
|
||||
strengthDiv.className += ' weak';
|
||||
strengthDiv.textContent = 'Mot de passe faible';
|
||||
} else if (validation.score < 5) {
|
||||
} else if (score < 5) {
|
||||
strengthDiv.className += ' medium';
|
||||
strengthDiv.textContent = 'Mot de passe moyen';
|
||||
} else {
|
||||
@ -245,9 +246,9 @@ export class SecureCredentialsComponent {
|
||||
}
|
||||
|
||||
try {
|
||||
const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
await secureCredentialsService.deleteCredentials();
|
||||
this.showMessage('Credentials supprimés avec succès', 'success');
|
||||
// TODO: Implement credentials deletion
|
||||
console.log('Credentials deletion requested but not implemented');
|
||||
this.showMessage('Suppression des credentials non implémentée', 'warning');
|
||||
await this.updateUI();
|
||||
|
||||
// Émettre l'événement
|
||||
|
||||
@ -798,7 +798,8 @@ async function waitForCredentialsAvailability(): Promise<void> {
|
||||
isWaitingForCredentials = true;
|
||||
|
||||
try {
|
||||
const { secureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const { SecureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
|
||||
let attempts = 0;
|
||||
const maxAttempts = 20;
|
||||
@ -891,7 +892,8 @@ async function handleMainPairing(): Promise<void> {
|
||||
}
|
||||
|
||||
// Import and trigger authentication with selected mode
|
||||
const { secureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const { SecureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
|
||||
// Check if we have existing credentials (regardless of wallet existence)
|
||||
console.log('🔍 Checking for existing credentials...');
|
||||
@ -1114,7 +1116,8 @@ async function handleDeleteAccount(): Promise<void> {
|
||||
|
||||
// Get services
|
||||
const service = await Services.getInstance();
|
||||
const { secureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const { SecureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
|
||||
// Delete all credentials
|
||||
await secureCredentialsService.deleteCredentials();
|
||||
|
||||
@ -777,4 +777,52 @@ QR Code URL: ${qrUrl}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime les credentials (alias pour deleteCredentials)
|
||||
*/
|
||||
async deleteCredentials(): Promise<void> {
|
||||
return this.clearCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
* Valide la force d'un mot de passe
|
||||
*/
|
||||
validatePasswordStrength(password: string): {
|
||||
isValid: boolean;
|
||||
score: number;
|
||||
feedback: string[];
|
||||
} {
|
||||
const feedback: string[] = [];
|
||||
let score = 0;
|
||||
|
||||
// Vérifications de complexité
|
||||
if (password.length < 8) {
|
||||
feedback.push('Le mot de passe doit contenir au moins 8 caractères');
|
||||
return { isValid: false, score: 0, feedback };
|
||||
}
|
||||
|
||||
if (password.length >= 8) score += 1;
|
||||
if (password.length >= 12) score += 1;
|
||||
if (password.length >= 16) score += 1;
|
||||
|
||||
if (/[a-z]/.test(password)) score += 1;
|
||||
if (/[A-Z]/.test(password)) score += 1;
|
||||
if (/[0-9]/.test(password)) score += 1;
|
||||
if (/[^a-zA-Z0-9]/.test(password)) score += 1;
|
||||
|
||||
// Feedback détaillé
|
||||
if (score < 3) {
|
||||
feedback.push('Mot de passe faible : ajoutez des majuscules, chiffres et caractères spéciaux');
|
||||
} else if (score < 5) {
|
||||
feedback.push('Mot de passe moyen : renforcez avec plus de complexité');
|
||||
}
|
||||
|
||||
const isValid = score >= 3;
|
||||
|
||||
return { isValid, score, feedback };
|
||||
}
|
||||
}
|
||||
|
||||
// Export instance pour compatibilité
|
||||
export const secureCredentialsService = SecureCredentialsService.getInstance();
|
||||
@ -9,7 +9,7 @@ import { eventBus } from './event-bus';
|
||||
import { secureLogger } from './secure-logger';
|
||||
import { memoryManager } from './memory-manager';
|
||||
import { secureKeyManager } from './secure-key-manager';
|
||||
import { SecureCredentialsService } from './secure-credentials.service';
|
||||
import { SecureCredentialsService, secureCredentialsService } from './secure-credentials.service';
|
||||
import Database from './database.service';
|
||||
|
||||
export interface ServiceContainer {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user