fix: correct TypeScript and ESLint errors
**Motivations :** - Corriger les erreurs TypeScript qui bloquaient la compilation - Corriger les erreurs ESLint pour améliorer la qualité du code - Utiliser les bons formats pour secureLogger.error **Modifications :** - Corriger les appels secureLogger.error pour passer error comme 2e paramètre - Ajouter les imports manquants (Database dans security-mode.service.ts) - Préfixer les variables non utilisées avec _ pour respecter ESLint - Corriger les comparaisons BigInt (utiliser BigInt(0) au lieu de 0n) - Ajouter @ts-expect-error pour PasswordCredential API expérimentale - Corriger le paramètre services non utilisé dans router.ts **Pages affectées :** - src/services/service.ts (comparaisons BigInt, imports) - src/services/security-mode.service.ts (import Database) - src/services/secure-credentials.service.ts (secureLogger.error, PasswordCredential) - src/services/credentials/encryption.service.ts (secureLogger.error, salt type) - src/router.ts (paramètre _services) - src/components/device-management/device-management.ts (variable _data) - src/components/secure-credentials/secure-credentials.ts (variable _error) - src/components/security-mode-selector/security-mode-selector.ts (paramètre _mode) - src/components/login-modal/login-modal.js (window globals)
This commit is contained in:
parent
8e6756539d
commit
aa95537254
@ -649,8 +649,8 @@ export class DeviceManagementComponent extends HTMLElement {
|
|||||||
if (file) {
|
if (file) {
|
||||||
try {
|
try {
|
||||||
const text = await file.text();
|
const text = await file.text();
|
||||||
const data = JSON.parse(text);
|
const _data = JSON.parse(text);
|
||||||
// Use data variable
|
// Data parsed but not used yet (for future use)
|
||||||
|
|
||||||
// Import the account data
|
// Import the account data
|
||||||
if (window.importJSON) {
|
if (window.importJSON) {
|
||||||
|
|||||||
@ -9,5 +9,7 @@ export async function closeLoginModal() {
|
|||||||
router.closeLoginModal();
|
router.closeLoginModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable no-undef */
|
||||||
window.confirmLogin = confirmLogin;
|
window.confirmLogin = confirmLogin;
|
||||||
window.closeLoginModal = closeLoginModal;
|
window.closeLoginModal = closeLoginModal;
|
||||||
|
/* eslint-enable no-undef */
|
||||||
|
|||||||
@ -232,7 +232,7 @@ export class SecureCredentialsComponent {
|
|||||||
try {
|
try {
|
||||||
await this.updateUI();
|
await this.updateUI();
|
||||||
this.showMessage('Credentials actualisés', 'success');
|
this.showMessage('Credentials actualisés', 'success');
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
this.showMessage('Erreur lors de l\'actualisation', 'error');
|
this.showMessage('Erreur lors de l\'actualisation', 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,12 +17,12 @@ export interface SecurityModeConfig {
|
|||||||
export class SecurityModeSelector {
|
export class SecurityModeSelector {
|
||||||
private container: HTMLElement;
|
private container: HTMLElement;
|
||||||
private selectedMode: SecurityMode | null = null;
|
private selectedMode: SecurityMode | null = null;
|
||||||
private onModeSelected: (mode: SecurityMode) => void;
|
private onModeSelected: (_mode: SecurityMode) => void;
|
||||||
private onCancel: () => void;
|
private onCancel: () => void;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
onModeSelected: (mode: SecurityMode) => void,
|
onModeSelected: (_mode: SecurityMode) => void,
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
) {
|
) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|||||||
@ -105,7 +105,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Vérifier que le wallet contient bien les données attendues
|
// Vérifier que le wallet contient bien les données attendues
|
||||||
if (wallet.sp_wallet && wallet.sp_wallet.birthday !== undefined) {
|
if (wallet.sp_wallet?.birthday !== undefined) {
|
||||||
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
||||||
|
|||||||
@ -141,7 +141,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vérifier que le wallet contient bien les données attendues
|
// Vérifier que le wallet contient bien les données attendues
|
||||||
if (wallet.sp_wallet && wallet.sp_wallet.birthday !== undefined) {
|
if (wallet.sp_wallet?.birthday !== undefined) {
|
||||||
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export async function initHomePage(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vérifier que le wallet contient bien les données attendues
|
// Vérifier que le wallet contient bien les données attendues
|
||||||
if (wallet.sp_wallet && wallet.sp_wallet.birthday !== undefined) {
|
if (wallet.sp_wallet?.birthday !== undefined) {
|
||||||
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
console.log('✅ Wallet found in database with birthday:', wallet.sp_wallet.birthday);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
throw new Error('Wallet found but missing required data (sp_wallet or birthday)');
|
||||||
|
|||||||
@ -49,14 +49,14 @@ export async function checkStorageStateAndNavigate(): Promise<void> {
|
|||||||
|
|
||||||
// Vérifier si la date anniversaire est configurée (wallet avec birthday > 0)
|
// Vérifier si la date anniversaire est configurée (wallet avec birthday > 0)
|
||||||
const device = await services.getDeviceFromDatabase();
|
const device = await services.getDeviceFromDatabase();
|
||||||
if (device && device.sp_wallet && device.sp_wallet.birthday > 0) {
|
if (device?.sp_wallet && device.sp_wallet.birthday > 0) {
|
||||||
console.log('🎂 Birthday is configured, navigating to pairing');
|
console.log('🎂 Birthday is configured, navigating to pairing');
|
||||||
await navigate('home'); // Pour l'instant, rediriger vers home pour le pairing
|
await navigate('home'); // Pour l'instant, rediriger vers home pour le pairing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vérifier si le wallet existe (même avec birthday = 0)
|
// Vérifier si le wallet existe (même avec birthday = 0)
|
||||||
if (device && device.sp_wallet) {
|
if (device?.sp_wallet) {
|
||||||
console.log('💰 Wallet exists but birthday not set, navigating to birthday-setup');
|
console.log('💰 Wallet exists but birthday not set, navigating to birthday-setup');
|
||||||
await navigate('birthday-setup');
|
await navigate('birthday-setup');
|
||||||
return;
|
return;
|
||||||
@ -1255,7 +1255,7 @@ async function handleSecurityKeyManagement(): Promise<boolean> {
|
|||||||
/**
|
/**
|
||||||
* ÉTAPE 5: Handshake
|
* ÉTAPE 5: Handshake
|
||||||
*/
|
*/
|
||||||
async function performHandshake(services: any): Promise<void> {
|
async function performHandshake(_services: any): Promise<void> {
|
||||||
console.log('🤝 Performing handshake...');
|
console.log('🤝 Performing handshake...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -90,10 +90,9 @@ export class EncryptionService {
|
|||||||
|
|
||||||
return btoa(String.fromCharCode(...combined));
|
return btoa(String.fromCharCode(...combined));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to encrypt with password', {
|
secureLogger.error('Failed to encrypt with password', error as Error, {
|
||||||
component: 'EncryptionService',
|
component: 'EncryptionService',
|
||||||
operation: 'encryptWithPassword',
|
operation: 'encryptWithPassword'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -206,10 +205,9 @@ export class EncryptionService {
|
|||||||
|
|
||||||
return new TextDecoder().decode(decrypted);
|
return new TextDecoder().decode(decrypted);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to decrypt with password base64', {
|
secureLogger.error('Failed to decrypt with password base64', error as Error, {
|
||||||
component: 'EncryptionService',
|
component: 'EncryptionService',
|
||||||
operation: 'decryptWithPasswordBase64',
|
operation: 'decryptWithPasswordBase64'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -236,7 +234,7 @@ export class EncryptionService {
|
|||||||
const key = await crypto.subtle.deriveKey(
|
const key = await crypto.subtle.deriveKey(
|
||||||
{
|
{
|
||||||
name: 'PBKDF2',
|
name: 'PBKDF2',
|
||||||
salt: salt,
|
salt: new Uint8Array(salt),
|
||||||
iterations: iterations,
|
iterations: iterations,
|
||||||
hash: 'SHA-256'
|
hash: 'SHA-256'
|
||||||
},
|
},
|
||||||
|
|||||||
@ -103,8 +103,7 @@ export class StorageService {
|
|||||||
async hasCredentials(): Promise<boolean> {
|
async hasCredentials(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const credentials = await this.getCredentials();
|
const credentials = await this.getCredentials();
|
||||||
return credentials !== null &&
|
return credentials?.spendKey !== undefined &&
|
||||||
credentials.spendKey !== undefined &&
|
|
||||||
credentials.scanKey !== undefined;
|
credentials.scanKey !== undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to check credentials existence', error as Error, {
|
secureLogger.error('Failed to check credentials existence', error as Error, {
|
||||||
|
|||||||
@ -59,7 +59,7 @@ export class WebAuthnService {
|
|||||||
*/
|
*/
|
||||||
async detectAvailableAuthenticators(): Promise<boolean> {
|
async detectAvailableAuthenticators(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
if (!navigator.credentials || !navigator.credentials.create) {
|
if (!navigator.credentials?.create) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ export class WebAuthnService {
|
|||||||
|
|
||||||
// Vérifier la disponibilité sans faire d'appel réel à WebAuthn
|
// Vérifier la disponibilité sans faire d'appel réel à WebAuthn
|
||||||
// Juste vérifier que les APIs sont disponibles
|
// Juste vérifier que les APIs sont disponibles
|
||||||
if (!navigator.credentials || !navigator.credentials.create) {
|
if (!navigator.credentials?.create) {
|
||||||
console.log('❌ WebAuthn credentials API not available');
|
console.log('❌ WebAuthn credentials API not available');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@ export class Database {
|
|||||||
|
|
||||||
Object.values(this.storeDefinitions).forEach(({ name, options, indices }) => {
|
Object.values(this.storeDefinitions).forEach(({ name, options, indices }) => {
|
||||||
if (!db.objectStoreNames.contains(name)) {
|
if (!db.objectStoreNames.contains(name)) {
|
||||||
let store = db.createObjectStore(name, options as IDBObjectStoreParameters);
|
const store = db.createObjectStore(name, options as IDBObjectStoreParameters);
|
||||||
|
|
||||||
indices.forEach(({ name, keyPath, options }) => {
|
indices.forEach(({ name, keyPath, options }) => {
|
||||||
store.createIndex(name, keyPath, options);
|
store.createIndex(name, keyPath, options);
|
||||||
@ -116,7 +116,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async registerServiceWorker(path: string) {
|
public async registerServiceWorker(path: string) {
|
||||||
if (!('serviceWorker' in navigator)) return; // Ensure service workers are supported
|
if (!('serviceWorker' in navigator)) {return;} // Ensure service workers are supported
|
||||||
console.log('registering worker at', path);
|
console.log('registering worker at', path);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -268,7 +268,7 @@ export class Database {
|
|||||||
|
|
||||||
private async handleDownloadList(downloadList: string[]): Promise<void> {
|
private async handleDownloadList(downloadList: string[]): Promise<void> {
|
||||||
// Download the missing data
|
// Download the missing data
|
||||||
let requestedStateId: string[] = [];
|
const requestedStateId: string[] = [];
|
||||||
const service = await Services.getInstance();
|
const service = await Services.getInstance();
|
||||||
for (const hash of downloadList) {
|
for (const hash of downloadList) {
|
||||||
const diff = await service.getDiffByValue(hash);
|
const diff = await service.getDiffByValue(hash);
|
||||||
@ -321,7 +321,7 @@ export class Database {
|
|||||||
} else if (data.type === 'TO_DOWNLOAD') {
|
} else if (data.type === 'TO_DOWNLOAD') {
|
||||||
console.log(`Received missing data ${data}`);
|
console.log(`Received missing data ${data}`);
|
||||||
// Download the missing data
|
// Download the missing data
|
||||||
let requestedStateId: string[] = [];
|
const requestedStateId: string[] = [];
|
||||||
for (const hash of data.data) {
|
for (const hash of data.data) {
|
||||||
try {
|
try {
|
||||||
const valueBytes = await service.fetchValueFromStorage(hash);
|
const valueBytes = await service.fetchValueFromStorage(hash);
|
||||||
|
|||||||
@ -128,10 +128,9 @@ export class SecureCredentialsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to check PBKDF2 key existence', {
|
secureLogger.error('Failed to check PBKDF2 key existence', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'hasPBKDF2Key',
|
operation: 'hasPBKDF2Key'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -155,10 +154,9 @@ export class SecureCredentialsService {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to retrieve PBKDF2 key from pbkdf2keys store', {
|
secureLogger.error('Failed to retrieve PBKDF2 key from pbkdf2keys store', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'getPBKDF2KeyFromStore',
|
operation: 'getPBKDF2KeyFromStore'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -186,10 +184,9 @@ export class SecureCredentialsService {
|
|||||||
securityMode
|
securityMode
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to store PBKDF2 key in pbkdf2keys store', {
|
secureLogger.error('Failed to store PBKDF2 key in pbkdf2keys store', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'storePBKDF2KeyInStore',
|
operation: 'storePBKDF2KeyInStore'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -238,10 +235,9 @@ export class SecureCredentialsService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to retrieve PBKDF2 key', {
|
secureLogger.error('Failed to retrieve PBKDF2 key', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'retrievePBKDF2Key',
|
operation: 'retrievePBKDF2Key'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -325,10 +321,9 @@ export class SecureCredentialsService {
|
|||||||
return pbkdf2Key;
|
return pbkdf2Key;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to generate PBKDF2 key', {
|
secureLogger.error('Failed to generate PBKDF2 key', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'generatePBKDF2Key',
|
operation: 'generatePBKDF2Key'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -492,7 +487,7 @@ export class SecureCredentialsService {
|
|||||||
* Génère des credentials en clair
|
* Génère des credentials en clair
|
||||||
*/
|
*/
|
||||||
private async generatePlainCredentials(
|
private async generatePlainCredentials(
|
||||||
password: string,
|
_password: string,
|
||||||
_options: CredentialOptions = {}
|
_options: CredentialOptions = {}
|
||||||
): Promise<CredentialData> {
|
): Promise<CredentialData> {
|
||||||
try {
|
try {
|
||||||
@ -575,7 +570,7 @@ export class SecureCredentialsService {
|
|||||||
*/
|
*/
|
||||||
private async decryptWithWebAuthn(
|
private async decryptWithWebAuthn(
|
||||||
credentials: CredentialData,
|
credentials: CredentialData,
|
||||||
password: string
|
_password: string
|
||||||
): Promise<CredentialData> {
|
): Promise<CredentialData> {
|
||||||
try {
|
try {
|
||||||
const currentMode = await this.securityModeService.getCurrentMode();
|
const currentMode = await this.securityModeService.getCurrentMode();
|
||||||
@ -647,7 +642,7 @@ export class SecureCredentialsService {
|
|||||||
/**
|
/**
|
||||||
* Stocke des credentials
|
* Stocke des credentials
|
||||||
*/
|
*/
|
||||||
async storeCredentials(credentials: CredentialData, password: string): Promise<void> {
|
async storeCredentials(credentials: CredentialData, _password: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// Import dynamique du service de stockage
|
// Import dynamique du service de stockage
|
||||||
const { StorageService } = await import('./credentials/storage.service');
|
const { StorageService } = await import('./credentials/storage.service');
|
||||||
@ -713,7 +708,7 @@ export class SecureCredentialsService {
|
|||||||
/**
|
/**
|
||||||
* Valide un code OTP
|
* Valide un code OTP
|
||||||
*/
|
*/
|
||||||
async validateOTPCode(secret: string, code: string): Promise<boolean> {
|
async validateOTPCode(_secret: string, code: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
// Implémentation simplifiée de validation OTP
|
// Implémentation simplifiée de validation OTP
|
||||||
// Dans une implémentation complète, on utiliserait une bibliothèque comme speakeasy
|
// Dans une implémentation complète, on utiliserait une bibliothèque comme speakeasy
|
||||||
@ -950,12 +945,14 @@ QR Code URL: ${qrUrl}`);
|
|||||||
try {
|
try {
|
||||||
// Essayer de récupérer un mot de passe existant
|
// Essayer de récupérer un mot de passe existant
|
||||||
const existingCredential = await navigator.credentials.get({
|
const existingCredential = await navigator.credentials.get({
|
||||||
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
password: true,
|
password: true,
|
||||||
mediation: 'optional'
|
mediation: 'optional'
|
||||||
});
|
} as CredentialRequestOptions);
|
||||||
|
|
||||||
if (existingCredential && existingCredential.type === 'password') {
|
if (existingCredential?.type === 'password') {
|
||||||
const passwordCredential = existingCredential as PasswordCredential;
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
|
const passwordCredential = existingCredential as any;
|
||||||
console.log('🔐 Retrieved existing password from browser');
|
console.log('🔐 Retrieved existing password from browser');
|
||||||
return passwordCredential.password;
|
return passwordCredential.password;
|
||||||
}
|
}
|
||||||
@ -1035,7 +1032,9 @@ QR Code URL: ${qrUrl}`);
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Sauvegarder le mot de passe dans le gestionnaire de mots de passe du navigateur
|
// Sauvegarder le mot de passe dans le gestionnaire de mots de passe du navigateur
|
||||||
if (navigator.credentials && navigator.credentials.create) {
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
|
if (typeof PasswordCredential !== 'undefined' && navigator.credentials && navigator.credentials.create) {
|
||||||
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
const credential = new PasswordCredential({
|
const credential = new PasswordCredential({
|
||||||
id: '4nk-pbkdf2-password',
|
id: '4nk-pbkdf2-password',
|
||||||
password: password,
|
password: password,
|
||||||
@ -1097,10 +1096,9 @@ QR Code URL: ${qrUrl}`);
|
|||||||
const encryptionService = EncryptionService.getInstance();
|
const encryptionService = EncryptionService.getInstance();
|
||||||
return await encryptionService.decrypt(encryptedKey, password);
|
return await encryptionService.decrypt(encryptedKey, password);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
secureLogger.error('Failed to decrypt PBKDF2 key with password', {
|
secureLogger.error('Failed to decrypt PBKDF2 key with password', error as Error, {
|
||||||
component: 'SecureCredentialsService',
|
component: 'SecureCredentialsService',
|
||||||
operation: 'decryptPBKDF2KeyWithPassword',
|
operation: 'decryptPBKDF2KeyWithPassword'
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1118,12 +1116,14 @@ QR Code URL: ${qrUrl}`);
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const credential = await navigator.credentials.get({
|
const credential = await navigator.credentials.get({
|
||||||
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
password: true,
|
password: true,
|
||||||
mediation: 'optional'
|
mediation: 'optional'
|
||||||
});
|
} as CredentialRequestOptions);
|
||||||
|
|
||||||
if (credential && credential.type === 'password') {
|
if (credential?.type === 'password') {
|
||||||
const passwordCredential = credential as PasswordCredential;
|
// @ts-expect-error - PasswordCredential API may not be in TypeScript definitions
|
||||||
|
const passwordCredential = credential as any;
|
||||||
console.log('🔐 Retrieved password from browser password manager');
|
console.log('🔐 Retrieved password from browser password manager');
|
||||||
return passwordCredential.password;
|
return passwordCredential.password;
|
||||||
}
|
}
|
||||||
@ -1151,14 +1151,14 @@ QR Code URL: ${qrUrl}`);
|
|||||||
return { isValid: false, score: 0, feedback };
|
return { isValid: false, score: 0, feedback };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password.length >= 8) score += 1;
|
if (password.length >= 8) {score += 1;}
|
||||||
if (password.length >= 12) score += 1;
|
if (password.length >= 12) {score += 1;}
|
||||||
if (password.length >= 16) score += 1;
|
if (password.length >= 16) {score += 1;}
|
||||||
|
|
||||||
if (/[a-z]/.test(password)) score += 1;
|
if (/[a-z]/.test(password)) {score += 1;}
|
||||||
if (/[A-Z]/.test(password)) score += 1;
|
if (/[A-Z]/.test(password)) {score += 1;}
|
||||||
if (/[0-9]/.test(password)) score += 1;
|
if (/[0-9]/.test(password)) {score += 1;}
|
||||||
if (/[^a-zA-Z0-9]/.test(password)) score += 1;
|
if (/[^a-zA-Z0-9]/.test(password)) {score += 1;}
|
||||||
|
|
||||||
// Feedback détaillé
|
// Feedback détaillé
|
||||||
if (score < 3) {
|
if (score < 3) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { secureLogger } from './secure-logger';
|
import { secureLogger } from './secure-logger';
|
||||||
|
import Database from './database.service';
|
||||||
|
|
||||||
export type SecurityMode = 'proton-pass' | 'os' | 'otp' | '2fa' | 'password' | 'none';
|
export type SecurityMode = 'proton-pass' | 'os' | 'otp' | '2fa' | 'password' | 'none';
|
||||||
|
|
||||||
|
|||||||
@ -1328,7 +1328,7 @@ export default class Services {
|
|||||||
console.log(`💰 Amount after block scan: ${updatedAmount}`);
|
console.log(`💰 Amount after block scan: ${updatedAmount}`);
|
||||||
|
|
||||||
// Update user with scan results
|
// Update user with scan results
|
||||||
if (updatedAmount > BigInt(0)) {
|
if (updatedAmount > 0n) {
|
||||||
this.updateUserStatus(`💰 Wallet updated! Found ${updatedAmount} tokens`);
|
this.updateUserStatus(`💰 Wallet updated! Found ${updatedAmount} tokens`);
|
||||||
} else {
|
} else {
|
||||||
this.updateUserStatus('⏳ Transaction processed, waiting for confirmation...');
|
this.updateUserStatus('⏳ Transaction processed, waiting for confirmation...');
|
||||||
@ -1887,7 +1887,7 @@ export default class Services {
|
|||||||
getRequest.onerror = () => reject(getRequest.error);
|
getRequest.onerror = () => reject(getRequest.error);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (walletData && walletData.encrypted_wallet) {
|
if (walletData?.encrypted_wallet) {
|
||||||
encryptedWallet = walletData.encrypted_wallet;
|
encryptedWallet = walletData.encrypted_wallet;
|
||||||
console.log('✅ encrypted_wallet preserved');
|
console.log('✅ encrypted_wallet preserved');
|
||||||
} else {
|
} else {
|
||||||
@ -1941,7 +1941,7 @@ export default class Services {
|
|||||||
await new Promise<void>((resolveVerify, rejectVerify) => {
|
await new Promise<void>((resolveVerify, rejectVerify) => {
|
||||||
verifyRequest.onsuccess = () => {
|
verifyRequest.onsuccess = () => {
|
||||||
const savedData = verifyRequest.result;
|
const savedData = verifyRequest.result;
|
||||||
if (savedData && savedData.encrypted_device === encryptedDevice) {
|
if (savedData?.encrypted_device === encryptedDevice) {
|
||||||
console.log('✅ Verified: Device correctly saved in database');
|
console.log('✅ Verified: Device correctly saved in database');
|
||||||
resolveVerify();
|
resolveVerify();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user