Compare commits
4 Commits
0c883dfcac
...
cc8a2ea708
| Author | SHA1 | Date | |
|---|---|---|---|
| cc8a2ea708 | |||
| 6d7da4d276 | |||
| 0a84381d4f | |||
| 066580f8d6 |
@ -104,55 +104,39 @@ export class SecureCredentialsService {
|
|||||||
const encryptedSpendKey = await this.encryptKey(credentialData.spendKey, masterKey);
|
const encryptedSpendKey = await this.encryptKey(credentialData.spendKey, masterKey);
|
||||||
const encryptedScanKey = await this.encryptKey(credentialData.scanKey, masterKey);
|
const encryptedScanKey = await this.encryptKey(credentialData.scanKey, masterKey);
|
||||||
|
|
||||||
// Vérifier si WebAuthn est disponible et si on est en HTTPS
|
// Forcer l'utilisation de WebAuthn (pas de fallback)
|
||||||
const isSecureContext = window.isSecureContext;
|
console.log('🔍 DEBUG: Forcing WebAuthn credential creation');
|
||||||
const hasWebAuthn = navigator.credentials && navigator.credentials.create;
|
secureLogger.info('Forcing WebAuthn credential creation', {
|
||||||
|
component: 'SecureCredentialsService',
|
||||||
|
operation: 'webauthn_force'
|
||||||
|
});
|
||||||
|
|
||||||
let credential = null;
|
const credential = await navigator.credentials.create({
|
||||||
|
publicKey: {
|
||||||
if (isSecureContext && hasWebAuthn) {
|
challenge: new Uint8Array(32),
|
||||||
// Stocker dans les credentials du navigateur (HTTPS requis)
|
rp: { name: '4NK Secure Storage' },
|
||||||
try {
|
user: {
|
||||||
credential = await navigator.credentials.create({
|
id: new TextEncoder().encode('4nk-user'),
|
||||||
publicKey: {
|
name: '4NK User',
|
||||||
challenge: new Uint8Array(32),
|
displayName: '4NK User'
|
||||||
rp: { name: '4NK Secure Storage' },
|
},
|
||||||
user: {
|
pubKeyCredParams: [
|
||||||
id: new TextEncoder().encode('4nk-user'),
|
{ type: 'public-key', alg: -7 }, // ES256
|
||||||
name: '4NK User',
|
{ type: 'public-key', alg: -257 } // RS256
|
||||||
displayName: '4NK User'
|
],
|
||||||
},
|
authenticatorSelection: {
|
||||||
pubKeyCredParams: [
|
authenticatorAttachment: 'platform',
|
||||||
{ type: 'public-key', alg: -7 }, // ES256
|
userVerification: 'required'
|
||||||
{ type: 'public-key', alg: -257 } // RS256
|
},
|
||||||
],
|
timeout: 60000,
|
||||||
authenticatorSelection: {
|
attestation: 'direct'
|
||||||
authenticatorAttachment: 'platform',
|
|
||||||
userVerification: 'required'
|
|
||||||
},
|
|
||||||
timeout: 60000,
|
|
||||||
attestation: 'direct'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
secureLogger.info('WebAuthn credential created successfully', {
|
|
||||||
component: 'SecureCredentialsService',
|
|
||||||
operation: 'webauthn_create'
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
secureLogger.warn('WebAuthn credential creation failed, using fallback', error as Error, {
|
|
||||||
component: 'SecureCredentialsService',
|
|
||||||
operation: 'webauthn_create'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
secureLogger.info('WebAuthn not available (HTTP context), using fallback storage', {
|
|
||||||
component: 'SecureCredentialsService',
|
secureLogger.info('WebAuthn credential created successfully', {
|
||||||
operation: 'webauthn_fallback',
|
component: 'SecureCredentialsService',
|
||||||
isSecureContext,
|
operation: 'webauthn_create'
|
||||||
hasWebAuthn
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (credential) {
|
if (credential) {
|
||||||
// Stocker les données chiffrées dans IndexedDB
|
// Stocker les données chiffrées dans IndexedDB
|
||||||
|
|||||||
@ -2533,6 +2533,26 @@ async function onCreateButtonClick() {
|
|||||||
console.log(`🔍 Creator flow detected`);
|
console.log(`🔍 Creator flow detected`);
|
||||||
updateCreatorStatus('Creating pairing process...');
|
updateCreatorStatus('Creating pairing process...');
|
||||||
|
|
||||||
|
// Initialize WebAuthn credentials immediately on user click
|
||||||
|
try {
|
||||||
|
console.log('🔍 DEBUG: Testing WebAuthn availability...');
|
||||||
|
console.log('🔍 DEBUG: isSecureContext:', window.isSecureContext);
|
||||||
|
console.log('🔍 DEBUG: hasCredentials:', !!navigator.credentials);
|
||||||
|
console.log('🔍 DEBUG: hasCreate:', !!navigator.credentials?.create);
|
||||||
|
console.log('🔍 DEBUG: protocol:', window.location.protocol);
|
||||||
|
|
||||||
|
const { secureCredentialsService } = await import('../services/secure-credentials.service');
|
||||||
|
updateCreatorStatus('🔐 Requesting browser authentication...');
|
||||||
|
|
||||||
|
// This should trigger the browser popup immediately
|
||||||
|
const credentials = await secureCredentialsService.generateSecureCredentials('4nk-pairing-password');
|
||||||
|
console.log('✅ WebAuthn credentials obtained');
|
||||||
|
updateCreatorStatus('✅ Browser authentication successful');
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('⚠️ WebAuthn failed, continuing with fallback:', error);
|
||||||
|
updateCreatorStatus('⚠️ Using fallback authentication');
|
||||||
|
}
|
||||||
|
|
||||||
await prepareAndSendPairingTx();
|
await prepareAndSendPairingTx();
|
||||||
updateCreatorStatus('Pairing process created! Generating 4 words...');
|
updateCreatorStatus('Pairing process created! Generating 4 words...');
|
||||||
|
|
||||||
@ -2700,30 +2720,7 @@ export async function prepareAndSendPairingTx(): Promise<void> {
|
|||||||
// Update UI with creator address
|
// Update UI with creator address
|
||||||
updateCreatorStatus(`Creator address: ${creatorAddress}`);
|
updateCreatorStatus(`Creator address: ${creatorAddress}`);
|
||||||
|
|
||||||
// Initialize secure credentials with PBKDF2 and browser credentials
|
// Secure credentials already initialized in the click handler
|
||||||
try {
|
|
||||||
const { secureCredentialsService } = await import('../services/secure-credentials.service');
|
|
||||||
|
|
||||||
// Check if we're in a secure context (HTTPS)
|
|
||||||
if (window.isSecureContext) {
|
|
||||||
updateCreatorStatus('🔐 Initializing secure credentials with browser...');
|
|
||||||
} else {
|
|
||||||
updateCreatorStatus('🔐 Initializing secure credentials (HTTP mode - WebAuthn not available)...');
|
|
||||||
}
|
|
||||||
|
|
||||||
// This will trigger the browser popup for WebAuthn (only in HTTPS)
|
|
||||||
const credentials = await secureCredentialsService.generateSecureCredentials('4nk-pairing-password');
|
|
||||||
console.log('✅ Secure credentials initialized with PBKDF2 and WebAuthn');
|
|
||||||
|
|
||||||
if (window.isSecureContext) {
|
|
||||||
updateCreatorStatus('✅ Secure credentials ready (WebAuthn enabled)');
|
|
||||||
} else {
|
|
||||||
updateCreatorStatus('✅ Secure credentials ready (fallback mode - use HTTPS for WebAuthn)');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('⚠️ Secure credentials initialization failed:', error);
|
|
||||||
updateCreatorStatus('⚠️ Using fallback credentials');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create pairing process with creator's address
|
// Create pairing process with creator's address
|
||||||
const createPairingProcessReturn = await service.createPairingProcess(
|
const createPairingProcessReturn = await service.createPairingProcess(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user