Skip to content

Commit e4273f5

Browse files
committed
Major Security Improvements:
- Enhanced user fingerprinting with WebGL, Canvas, and Audio fingerprinting - Hardware binding to prevent F5/Ctrl+F5 abuse - Persistent storage across browser sessions (localStorage + sessionStorage) - Global demo session counter with 10 session limit per device - Multi-tab protection (max 2 tabs simultaneously) - Anti-reset protection with hardware mismatch detection Demo Session Protection: - Advanced fingerprint generation with CPU benchmarking - Enhanced validation with cryptographic verification - Automatic cleanup and session completion tracking - Cooldown periods between sessions (1min + 15min completion) - Weekly partial reset of global counters Fixes: - Fixed SessionTimer console spam after connection disconnect - Added missing registerEnhancedDemoSessionUsage method - Corrected method calls from generateUserFingerprint to generateAdvancedUserFingerprint - Implemented proper event handling for connection state changes WebRTC Improvements: - Added peer-disconnect, new-connection, and connection-cleaned events - Enhanced connection cleanup with proper UI notifications - Fixed SessionTimer state management during disconnections - Prevented infinite re-rendering and console logging Performance Optimizations: - Auto-save persistent data every 30 seconds - Periodic cleanup of old session data (every 6 hours) - Memory management for used preimages (10k limit) - Tab heartbeat system for multi-tab detection Testing: - Demo sessions now properly enforce limits - P2P anonymity maintained (no server validation) - Compatible with incognito mode restrictions - Resistant to common abuse techniques
1 parent 3263583 commit e4273f5

File tree

5 files changed

+695
-134
lines changed

5 files changed

+695
-134
lines changed

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,6 @@ <h3 key="title" className="text-2xl font-semibold text-primary mb-3">
32443244
}
32453245

32463246
try {
3247-
console.log('📤 Attempting to send message:', messageInput.substring(0, 100));
32483247

32493248
// Add the message to local messages immediately (sent message)
32503249
const sentMessage = {

src/components/ui/Header.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const EnhancedMinimalHeader = ({
163163
React.createElement('p', {
164164
key: 'subtitle',
165165
className: 'text-xs sm:text-sm text-muted hidden sm:block'
166-
}, 'End-to-end freedom. v4.0.02.88')
166+
}, 'End-to-end freedom. v4.0.03.00')
167167
])
168168
]),
169169

src/components/ui/SessionTimer.jsx

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
22
const [currentTime, setCurrentTime] = React.useState(timeLeft || 0);
33
const [showExpiredMessage, setShowExpiredMessage] = React.useState(false);
44
const [initialized, setInitialized] = React.useState(false);
5-
const [connectionBroken, setConnectionBroken] = React.useState(false);
5+
const [connectionBroken, setConnectionBroken] = React.useState(false);
6+
67

8+
const [loggedHidden, setLoggedHidden] = React.useState(false);
79

810
React.useEffect(() => {
911
if (connectionBroken) {
10-
console.log('⏱️ SessionTimer initialization skipped - connection broken');
12+
if (!loggedHidden) {
13+
console.log('⏱️ SessionTimer initialization skipped - connection broken');
14+
setLoggedHidden(true);
15+
}
1116
return;
1217
}
1318

@@ -23,17 +28,22 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
2328

2429
setCurrentTime(initialTime);
2530
setInitialized(true);
26-
}, [sessionManager, connectionBroken]);
31+
setLoggedHidden(false);
32+
}, [sessionManager, connectionBroken]);
2733

2834
React.useEffect(() => {
2935
if (connectionBroken) {
30-
console.log('⏱️ SessionTimer props update skipped - connection broken');
36+
if (!loggedHidden) {
37+
console.log('⏱️ SessionTimer props update skipped - connection broken');
38+
setLoggedHidden(true);
39+
}
3140
return;
3241
}
3342

3443
if (timeLeft && timeLeft > 0) {
3544
setCurrentTime(timeLeft);
3645
}
46+
setLoggedHidden(false);
3747
}, [timeLeft, connectionBroken]);
3848

3949
React.useEffect(() => {
@@ -42,15 +52,17 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
4252
}
4353

4454
if (connectionBroken) {
45-
console.log('⏱️ Timer interval skipped - connection broken');
55+
if (!loggedHidden) {
56+
console.log('⏱️ Timer interval skipped - connection broken');
57+
setLoggedHidden(true);
58+
}
4659
return;
4760
}
4861

4962
if (!currentTime || currentTime <= 0 || !sessionManager) {
5063
return;
5164
}
5265

53-
5466
const interval = setInterval(() => {
5567
if (connectionBroken) {
5668
console.log('⏱️ Timer interval stopped - connection broken');
@@ -81,22 +93,18 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
8193
}, 1000);
8294

8395
return () => {
84-
8596
clearInterval(interval);
8697
};
87-
}, [initialized, currentTime, sessionManager, connectionBroken]);
88-
98+
}, [initialized, currentTime, sessionManager, connectionBroken]);
8999

90100
React.useEffect(() => {
91101
const handleSessionTimerUpdate = (event) => {
92-
93102
if (event.detail.timeLeft && event.detail.timeLeft > 0) {
94103
setCurrentTime(event.detail.timeLeft);
95104
}
96105
};
97106

98107
const handleForceHeaderUpdate = (event) => {
99-
100108
if (sessionManager && sessionManager.hasActiveSession()) {
101109
const newTime = sessionManager.getTimeLeft();
102110
setCurrentTime(newTime);
@@ -105,28 +113,41 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
105113

106114
const handlePeerDisconnect = (event) => {
107115
console.log('🔌 Peer disconnect detected in SessionTimer - stopping timer permanently');
108-
setConnectionBroken(true);
116+
setConnectionBroken(true);
109117
setCurrentTime(0);
110118
setShowExpiredMessage(false);
119+
setLoggedHidden(false);
111120
};
112121

113122
const handleNewConnection = (event) => {
114123
console.log('🔌 New connection detected in SessionTimer - resetting connection state');
115-
setConnectionBroken(false);
124+
setConnectionBroken(false);
125+
setLoggedHidden(false);
126+
};
127+
128+
const handleConnectionCleaned = (event) => {
129+
console.log('🧹 Connection cleaned - resetting SessionTimer state');
130+
setConnectionBroken(false);
131+
setCurrentTime(0);
132+
setShowExpiredMessage(false);
133+
setInitialized(false);
134+
setLoggedHidden(false);
116135
};
117136

118137
document.addEventListener('session-timer-update', handleSessionTimerUpdate);
119138
document.addEventListener('force-header-update', handleForceHeaderUpdate);
120139
document.addEventListener('peer-disconnect', handlePeerDisconnect);
121140
document.addEventListener('new-connection', handleNewConnection);
141+
document.addEventListener('connection-cleaned', handleConnectionCleaned);
122142

123143
return () => {
124144
document.removeEventListener('session-timer-update', handleSessionTimerUpdate);
125145
document.removeEventListener('force-header-update', handleForceHeaderUpdate);
126146
document.removeEventListener('peer-disconnect', handlePeerDisconnect);
127147
document.removeEventListener('new-connection', handleNewConnection);
148+
document.removeEventListener('connection-cleaned', handleConnectionCleaned);
128149
};
129-
}, [sessionManager]);
150+
}, [sessionManager]);
130151

131152
if (showExpiredMessage) {
132153
return React.createElement('div', {
@@ -145,20 +166,33 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
145166
}
146167

147168
if (!sessionManager) {
148-
console.log('⏱️ SessionTimer hidden - no sessionManager');
169+
if (!loggedHidden) {
170+
console.log('⏱️ SessionTimer hidden - no sessionManager');
171+
setLoggedHidden(true);
172+
}
149173
return null;
150174
}
151175

152176
if (connectionBroken) {
153-
console.log('⏱️ SessionTimer hidden - connection broken');
177+
if (!loggedHidden) {
178+
console.log('⏱️ SessionTimer hidden - connection broken');
179+
setLoggedHidden(true);
180+
}
154181
return null;
155182
}
156183

157184
if (!currentTime || currentTime <= 0) {
158-
console.log('⏱️ SessionTimer hidden - no time left');
185+
if (!loggedHidden) {
186+
console.log('⏱️ SessionTimer hidden - no time left');
187+
setLoggedHidden(true);
188+
}
159189
return null;
160190
}
161191

192+
if (loggedHidden) {
193+
setLoggedHidden(false);
194+
}
195+
162196
const totalMinutes = Math.floor(currentTime / (60 * 1000));
163197
const totalSeconds = Math.floor(currentTime / 1000);
164198

@@ -179,8 +213,8 @@ const SessionTimer = ({ timeLeft, sessionType, sessionManager }) => {
179213
};
180214

181215
const getTimerStyle = () => {
182-
const totalDuration = sessionType === 'demo' ? 6 * 60 * 1000 : 60 * 60 * 1000;
183-
const timeProgress = (totalDuration - currentTime) / totalDuration;
216+
const totalDuration = sessionType === 'demo' ? 6 * 60 * 1000 : 60 * 60 * 1000;
217+
const timeProgress = (totalDuration - currentTime) / totalDuration;
184218

185219
let backgroundColor, textColor, iconColor, iconClass, shouldPulse;
186220

@@ -247,4 +281,4 @@ window.updateSessionTimer = (newTimeLeft, newSessionType) => {
247281
}));
248282
};
249283

250-
console.log('✅ SessionTimer loaded with fixes and improvements');
284+
console.log('✅ SessionTimer loaded with anti-spam logging fixes');

src/network/EnhancedSecureWebRTCManager.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,13 @@ async autoEnableSecurityFeatures() {
25052505
securityLevel: offerPackage.securityLevel.level
25062506
});
25072507

2508+
document.dispatchEvent(new CustomEvent('new-connection', {
2509+
detail: {
2510+
type: 'offer',
2511+
timestamp: Date.now()
2512+
}
2513+
}));
2514+
25082515
return offerPackage;
25092516
} catch (error) {
25102517
window.EnhancedSecureCryptoUtils.secureLog.log('error', 'Enhanced secure offer creation failed', {
@@ -2712,6 +2719,13 @@ async autoEnableSecurityFeatures() {
27122719
securityLevel: answerPackage.securityLevel.level
27132720
});
27142721

2722+
document.dispatchEvent(new CustomEvent('new-connection', {
2723+
detail: {
2724+
type: 'answer',
2725+
timestamp: Date.now()
2726+
}
2727+
}));
2728+
27152729
return answerPackage;
27162730
} catch (error) {
27172731
window.EnhancedSecureCryptoUtils.secureLog.log('error', 'Enhanced secure answer creation failed', {
@@ -3252,6 +3266,13 @@ async autoEnableSecurityFeatures() {
32523266
setTimeout(() => {
32533267
this.sendDisconnectNotification();
32543268
}, 100);
3269+
3270+
document.dispatchEvent(new CustomEvent('peer-disconnect', {
3271+
detail: {
3272+
reason: 'user_disconnect',
3273+
timestamp: Date.now()
3274+
}
3275+
}));
32553276

32563277
setTimeout(() => {
32573278
this.cleanupConnection();
@@ -3263,6 +3284,13 @@ async autoEnableSecurityFeatures() {
32633284
this.isVerified = false;
32643285
this.onMessage('🔌 Connection lost. Attempting to reconnect...', 'system');
32653286

3287+
document.dispatchEvent(new CustomEvent('peer-disconnect', {
3288+
detail: {
3289+
reason: 'connection_lost',
3290+
timestamp: Date.now()
3291+
}
3292+
}));
3293+
32663294
setTimeout(() => {
32673295
if (!this.intentionalDisconnect) {
32683296
this.attemptReconnection();
@@ -3322,6 +3350,13 @@ async autoEnableSecurityFeatures() {
33223350
this.onKeyExchange('');
33233351
this.onVerificationRequired('');
33243352

3353+
document.dispatchEvent(new CustomEvent('peer-disconnect', {
3354+
detail: {
3355+
reason: reason,
3356+
timestamp: Date.now()
3357+
}
3358+
}));
3359+
33253360
setTimeout(() => {
33263361
this.cleanupConnection();
33273362
}, 2000);
@@ -3390,6 +3425,13 @@ async autoEnableSecurityFeatures() {
33903425
// IMPORTANT: Clearing security logs
33913426
window.EnhancedSecureCryptoUtils.secureLog.clearLogs();
33923427

3428+
document.dispatchEvent(new CustomEvent('connection-cleaned', {
3429+
detail: {
3430+
timestamp: Date.now(),
3431+
reason: this.intentionalDisconnect ? 'user_cleanup' : 'automatic_cleanup'
3432+
}
3433+
}));
3434+
33933435
// Notifying the UI about complete cleanup
33943436
this.onStatusChange('disconnected');
33953437
this.onKeyExchange('');

0 commit comments

Comments
 (0)