fix: Prevent handshake processing loop and auto-trigger WebAuthn
**Motivations :** - Fix infinite loop of 'process.states is not an array' warnings - Auto-trigger WebAuthn authentication on page load - Prevent duplicate handshake processing **Modifications :** - Added processedHandshakes Set to track processed handshakes - Added handshake deduplication logic in handleHandshakeMsg - Auto-trigger handleMainPairing() in home page initialization - Prevent spam of process.states warnings **Pages affectées :** - src/services/service.ts - Added handshake deduplication - src/pages/home/home.ts - Auto-trigger WebAuthn on init
This commit is contained in:
parent
4ec026e892
commit
65132ea2f0
@ -149,6 +149,10 @@ export async function initHomePage(): Promise<void> {
|
||||
console.log('🔧 Displaying emojis...');
|
||||
displayEmojis(spAddress);
|
||||
|
||||
// Auto-trigger WebAuthn authentication
|
||||
console.log('🔐 Auto-triggering WebAuthn authentication...');
|
||||
await handleMainPairing();
|
||||
|
||||
// Hide loading spinner after initialization
|
||||
console.log('🔧 Hiding loading spinner...');
|
||||
hideHomeLoadingSpinner();
|
||||
|
||||
@ -149,6 +149,7 @@ export default class Services {
|
||||
private currentBlockHeight: number = -1;
|
||||
private relayReadyResolver: (() => void) | null = null;
|
||||
private relayReadyPromise: Promise<void> | null = null;
|
||||
private processedHandshakes: Set<string> = new Set();
|
||||
// Private constructor to prevent direct instantiation from outside
|
||||
private constructor() {}
|
||||
|
||||
@ -2172,6 +2173,17 @@ export default class Services {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a flag to prevent processing the same handshake multiple times
|
||||
const handshakeKey = `${url}_${Date.now()}`;
|
||||
if (this.processedHandshakes && this.processedHandshakes.has(handshakeKey)) {
|
||||
console.debug('Handshake already processed for', url);
|
||||
return;
|
||||
}
|
||||
if (!this.processedHandshakes) {
|
||||
this.processedHandshakes = new Set();
|
||||
}
|
||||
this.processedHandshakes.add(handshakeKey);
|
||||
|
||||
if (this.processesCache && Object.keys(this.processesCache).length === 0) {
|
||||
// We restored db but cache is empty, meaning we're starting from scratch
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user