fix: eliminate division on crypto random in getSafeRandomFloat
This commit is contained in:
9
dist/app-boot.js
vendored
9
dist/app-boot.js
vendored
@@ -8216,17 +8216,16 @@ var EnhancedSecureWebRTCManager = class _EnhancedSecureWebRTCManager {
|
|||||||
} while (randomValue >= range);
|
} while (randomValue >= range);
|
||||||
return min + randomValue;
|
return min + randomValue;
|
||||||
}
|
}
|
||||||
getSafeRandomFloat(minFloat, maxFloat, scale = 1e3) {
|
getSafeRandomFloat(minFloat, maxFloat, steps = 1e3) {
|
||||||
if (typeof minFloat !== "number" || typeof maxFloat !== "number") {
|
if (typeof minFloat !== "number" || typeof maxFloat !== "number") {
|
||||||
throw new Error("getSafeRandomFloat requires numeric min and max");
|
throw new Error("getSafeRandomFloat requires numeric min and max");
|
||||||
}
|
}
|
||||||
if (minFloat >= maxFloat) {
|
if (minFloat >= maxFloat) {
|
||||||
throw new Error("minFloat must be less than maxFloat");
|
throw new Error("minFloat must be less than maxFloat");
|
||||||
}
|
}
|
||||||
const minInt = Math.round(minFloat * scale);
|
const randomIndex = this.getSafeRandomInt(0, steps);
|
||||||
const maxInt = Math.round(maxFloat * scale);
|
const step = (maxFloat - minFloat) / steps;
|
||||||
const intVal = this.getSafeRandomInt(minInt, maxInt);
|
return minFloat + randomIndex * step;
|
||||||
return intVal / scale;
|
|
||||||
}
|
}
|
||||||
generateFingerprintMask() {
|
generateFingerprintMask() {
|
||||||
const mask = {
|
const mask = {
|
||||||
|
|||||||
4
dist/app-boot.js.map
vendored
4
dist/app-boot.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -4511,18 +4511,18 @@ this._secureLog('info', '🔒 Enhanced Mutex system fully initialized and valida
|
|||||||
return min + randomValue;
|
return min + randomValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSafeRandomFloat(minFloat, maxFloat, scale = 1000) {
|
getSafeRandomFloat(minFloat, maxFloat, steps = 1000) {
|
||||||
if (typeof minFloat !== 'number' || typeof maxFloat !== 'number') {
|
if (typeof minFloat !== 'number' || typeof maxFloat !== 'number') {
|
||||||
throw new Error('getSafeRandomFloat requires numeric min and max');
|
throw new Error('getSafeRandomFloat requires numeric min and max');
|
||||||
}
|
}
|
||||||
if (minFloat >= maxFloat) {
|
if (minFloat >= maxFloat) {
|
||||||
throw new Error('minFloat must be less than maxFloat');
|
throw new Error('minFloat must be less than maxFloat');
|
||||||
}
|
}
|
||||||
|
const randomIndex = this.getSafeRandomInt(0, steps);
|
||||||
|
|
||||||
const minInt = Math.round(minFloat * scale);
|
const step = (maxFloat - minFloat) / steps;
|
||||||
const maxInt = Math.round(maxFloat * scale);
|
|
||||||
const intVal = this.getSafeRandomInt(minInt, maxInt);
|
return minFloat + (randomIndex * step);
|
||||||
return intVal / scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generateFingerprintMask() {
|
generateFingerprintMask() {
|
||||||
|
|||||||
Reference in New Issue
Block a user