Skip to content

Commit 12de75f

Browse files
committed
Technical comments removed
1 parent e4273f5 commit 12de75f

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

src/network/EnhancedSecureWebRTCManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class EnhancedSecureWebRTCManager {
455455
size: size,
456456
isFakeTraffic: true,
457457
source: 'fake_traffic_generator',
458-
fakeId: crypto.getRandomValues(new Uint32Array(1))[0].toString(36) // Уникальный ID
458+
fakeId: crypto.getRandomValues(new Uint32Array(1))[0].toString(36)
459459
};
460460
}
461461

@@ -1253,7 +1253,6 @@ async processOrderedPackets() {
12531253
return 'FAKE_MESSAGE_FILTERED';
12541254
}
12551255
} catch (e) {
1256-
// Не JSON - это нормально для обычных сообщений
12571256
if (window.DEBUG_MODE) {
12581257
console.log('📝 Decrypted content is not JSON, treating as plain text message');
12591258
}

src/session/PayPerSessionManager.js

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class PayPerSessionManager {
145145
// IMPROVED user fingerprint generation
146146
generateAdvancedUserFingerprint() {
147147
try {
148-
// Базовые компоненты (как было)
149148
const basicComponents = [
150149
navigator.userAgent || '',
151150
navigator.language || '',
@@ -161,10 +160,9 @@ class PayPerSessionManager {
161160
navigator.onLine ? '1' : '0'
162161
];
163162

164-
// НОВЫЕ КОМПОНЕНТЫ ДЛЯ HARDWARE BINDING
165163
const hardwareComponents = [];
166164

167-
// WebGL отпечаток (очень сложно подделать)
165+
// WebGL fingerprint
168166
try {
169167
const canvas = document.createElement('canvas');
170168
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
@@ -181,7 +179,7 @@ class PayPerSessionManager {
181179
hardwareComponents.push('webgl_error');
182180
}
183181

184-
// Canvas отпечаток (уникален для каждого устройства)
182+
// Canvas print
185183
try {
186184
const canvas = document.createElement('canvas');
187185
canvas.width = 200;
@@ -197,7 +195,7 @@ class PayPerSessionManager {
197195
hardwareComponents.push('canvas_error');
198196
}
199197

200-
// Аудио отпечаток (очень стабилен)
198+
// Audio fingerprint
201199
try {
202200
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
203201
const oscillator = audioContext.createOscillator();
@@ -220,14 +218,12 @@ class PayPerSessionManager {
220218
hardwareComponents.push('audio_error');
221219
}
222220

223-
// Производительность CPU (стабильна для устройства)
221+
// CPU Performance
224222
const cpuBenchmark = this.performCPUBenchmark();
225223
hardwareComponents.push(cpuBenchmark);
226224

227-
// Объединяем все компоненты
228225
const allComponents = [...basicComponents, ...hardwareComponents];
229-
230-
// Создаем несколько уровней хеширования
226+
231227
let primaryHash = 0;
232228
let secondaryHash = 0;
233229
let tertiaryHash = 0;
@@ -236,28 +232,24 @@ class PayPerSessionManager {
236232
const secondaryStr = allComponents.slice(8, 16).join('|');
237233
const tertiaryStr = allComponents.slice(16).join('|');
238234

239-
// Первичный хеш
240235
for (let i = 0; i < primaryStr.length; i++) {
241236
const char = primaryStr.charCodeAt(i);
242237
primaryHash = ((primaryHash << 7) - primaryHash) + char;
243238
primaryHash = primaryHash & primaryHash;
244239
}
245-
246-
// Вторичный хеш
240+
247241
for (let i = 0; i < secondaryStr.length; i++) {
248242
const char = secondaryStr.charCodeAt(i);
249243
secondaryHash = ((secondaryHash << 11) - secondaryHash) + char;
250244
secondaryHash = secondaryHash & secondaryHash;
251245
}
252246

253-
// Третичный хеш
254247
for (let i = 0; i < tertiaryStr.length; i++) {
255248
const char = tertiaryStr.charCodeAt(i);
256249
tertiaryHash = ((tertiaryHash << 13) - tertiaryHash) + char;
257250
tertiaryHash = tertiaryHash & tertiaryHash;
258251
}
259252

260-
// Комбинированный отпечаток
261253
const combined = `${Math.abs(primaryHash).toString(36)}_${Math.abs(secondaryHash).toString(36)}_${Math.abs(tertiaryHash).toString(36)}`;
262254

263255
console.log('🔒 Enhanced fingerprint generated:', {
@@ -272,7 +264,6 @@ class PayPerSessionManager {
272264

273265
} catch (error) {
274266
console.warn('Failed to generate enhanced fingerprint:', error);
275-
// Fallback к более простому отпечатку
276267
return 'fallback_' + Date.now().toString(36) + '_' + Math.random().toString(36).substr(2, 9);
277268
}
278269
}
@@ -440,8 +431,7 @@ class PayPerSessionManager {
440431

441432
getHardwareFingerprint() {
442433
const components = [];
443-
444-
// CPU информация
434+
445435
components.push(navigator.hardwareConcurrency || 0);
446436
components.push(navigator.deviceMemory || 0);
447437

@@ -477,10 +467,8 @@ class PayPerSessionManager {
477467
}
478468

479469
registerEnhancedDemoSessionUsage(userFingerprint, preimage) {
480-
// Вызываем оригинальный метод
481470
const session = this.registerDemoSessionUsage(userFingerprint, preimage);
482471

483-
// Дополнительно сохраняем в persistent storage
484472
this.savePersistentData();
485473

486474
console.log('📊 Enhanced demo session registered:', {
@@ -524,11 +512,11 @@ class PayPerSessionManager {
524512
getAntiResetMessage(antiResetCheck) {
525513
switch (antiResetCheck.reason) {
526514
case 'hardware_mismatch':
527-
return 'Обнаружена попытка сброса ограничений. Доступ к демо-режиму временно ограничен.';
515+
return 'An attempt to reset restrictions was detected. Access to demo mode is temporarily restricted.';
528516
case 'global_limit_exceeded':
529-
return `Глобальный лимит демо-сессий превышен (${antiResetCheck.globalCount}/10). Для продолжения требуется оплаченная сессия.`;
517+
return `Global demo session limit exceeded (${antiResetCheck.globalCount}/10). A paid session is required to continue.`;
530518
default:
531-
return 'Доступ к демо-режиму ограничен по соображениям безопасности.';
519+
return 'Access to demo mode is restricted for security reasons.';
532520
}
533521
}
534522

@@ -638,7 +626,7 @@ class PayPerSessionManager {
638626
return {
639627
allowed: false,
640628
reason: 'multiple_tabs',
641-
message: 'Демо-режим доступен только в одной вкладке одновременно.'
629+
message: 'Demo mode is only available in one tab at a time..'
642630
};
643631
}
644632

@@ -681,7 +669,6 @@ class PayPerSessionManager {
681669
const activeTabsStr = this.getFromStorage(activeTabsKey);
682670
const activeTabs = activeTabsStr ? JSON.parse(activeTabsStr) : [];
683671

684-
// Обновляем timestamp для текущей вкладки
685672
const updatedTabs = activeTabs.map(tab => {
686673
if (tab.tabId === this.currentTabId) {
687674
return {
@@ -858,7 +845,6 @@ class PayPerSessionManager {
858845
throw new Error('Preimage must be valid hexadecimal');
859846
}
860847

861-
// СПЕЦИАЛЬНАЯ обработка demo preimage с УСИЛЕННЫМИ проверками
862848
if (this.isDemoPreimage(preimage)) {
863849
console.log('🎮 Demo preimage detected - performing ENHANCED validation...');
864850

@@ -885,23 +871,22 @@ class PayPerSessionManager {
885871
if (age > 15 * 60 * 1000) {
886872
throw new Error(`Demo preimage expired (age: ${Math.round(age / (60 * 1000))} minutes)`);
887873
}
888-
889-
// Demo preimage не должен быть из будущего
874+
890875
if (age < -2 * 60 * 1000) {
891876
throw new Error('Demo preimage timestamp from future - possible clock manipulation');
892877
}
893878

894-
// CHECK 4: ИСПРАВЛЕННЫЙ вызов лимитов - используем ПРАВИЛЬНЫЙ метод
895-
const userFingerprint = this.generateAdvancedUserFingerprint(); // ИСПРАВЛЕНО!
896-
const limitsCheck = this.checkEnhancedDemoSessionLimits(userFingerprint); // ИСПРАВЛЕНО!
879+
// CHECK 4: FIXED calling limits - use the CORRECT method
880+
const userFingerprint = this.generateAdvancedUserFingerprint();
881+
const limitsCheck = this.checkEnhancedDemoSessionLimits(userFingerprint);
897882

898883
if (!limitsCheck.allowed) {
899884
throw new Error(`Demo session limits exceeded: ${limitsCheck.message}`);
900885
}
901886

902887
// FIX: For demo sessions, do NOT add preimage to usedPreimages here,
903888
// as this will only be done after successful activation
904-
this.registerEnhancedDemoSessionUsage(userFingerprint, preimage); // ИСПРАВЛЕНО!
889+
this.registerEnhancedDemoSessionUsage(userFingerprint, preimage);
905890

906891
console.log('✅ Demo preimage ENHANCED validation passed');
907892
return true;
@@ -1321,7 +1306,6 @@ class PayPerSessionManager {
13211306
};
13221307
}
13231308

1324-
// ИСПРАВЛЕННЫЙ вызов - используем правильные методы
13251309
const userFingerprint = this.generateAdvancedUserFingerprint();
13261310
const demoCheck = this.checkEnhancedDemoSessionLimits(userFingerprint);
13271311

@@ -1503,7 +1487,7 @@ class PayPerSessionManager {
15031487

15041488
handleDemoSessionExpiry(preimage) {
15051489
if (this.currentSession && this.currentSession.preimage === preimage) {
1506-
const userFingerprint = this.generateAdvancedUserFingerprint(); // ИСПРАВЛЕНО!
1490+
const userFingerprint = this.generateAdvancedUserFingerprint();
15071491
const sessionDuration = Date.now() - this.currentSession.startTime;
15081492

15091493
this.registerDemoSessionCompletion(userFingerprint, sessionDuration, preimage);
@@ -1533,7 +1517,7 @@ class PayPerSessionManager {
15331517
const expiredSession = this.currentSession;
15341518

15351519
if (expiredSession && expiredSession.isDemo) {
1536-
const userFingerprint = this.generateAdvancedUserFingerprint(); // ИСПРАВЛЕНО!
1520+
const userFingerprint = this.generateAdvancedUserFingerprint();
15371521
const sessionDuration = Date.now() - expiredSession.startTime;
15381522
this.registerDemoSessionCompletion(userFingerprint, sessionDuration, expiredSession.preimage);
15391523
}
@@ -1582,8 +1566,8 @@ class PayPerSessionManager {
15821566

15831567
// UPDATED demo session creation
15841568
createDemoSession() {
1585-
const userFingerprint = this.generateAdvancedUserFingerprint(); // ИСПРАВЛЕНО!
1586-
const demoCheck = this.checkEnhancedDemoSessionLimits(userFingerprint); // ИСПРАВЛЕНО!
1569+
const userFingerprint = this.generateAdvancedUserFingerprint();
1570+
const demoCheck = this.checkEnhancedDemoSessionLimits(userFingerprint);
15871571

15881572
if (!demoCheck.allowed) {
15891573
return {
@@ -1943,7 +1927,7 @@ class PayPerSessionManager {
19431927

19441928
// IMPORTANT: We register the end of the current demo session during cleanup
19451929
if (this.currentSession && this.currentSession.isDemo) {
1946-
const userFingerprint = this.generateAdvancedUserFingerprint(); // ИСПРАВЛЕНО!
1930+
const userFingerprint = this.generateAdvancedUserFingerprint();
19471931
const sessionDuration = Date.now() - this.currentSession.startTime;
19481932
this.registerDemoSessionCompletion(userFingerprint, sessionDuration, this.currentSession.preimage);
19491933
}

0 commit comments

Comments
 (0)