}
public getRandomTagId(): string {
- const index = Math.floor(Math.random() * this.authorizedTags.length);
+ const index = Math.floor(Utils.secureRandom() * this.authorizedTags.length);
return this.authorizedTags[index];
}
const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? {} as ChargingStationInfo;
if (!Utils.isEmptyArray(stationTemplateFromFile.power)) {
stationTemplateFromFile.power = stationTemplateFromFile.power as number[];
- const powerArrayRandomIndex = Math.floor(Math.random() * stationTemplateFromFile.power.length);
+ const powerArrayRandomIndex = Math.floor(Utils.secureRandom() * stationTemplateFromFile.power.length);
stationInfo.maxPower = stationTemplateFromFile.powerUnit === PowerUnits.KILO_WATT
? stationTemplateFromFile.power[powerArrayRandomIndex] * 1000
: stationTemplateFromFile.power[powerArrayRandomIndex];
if (webSocketPingInterval > 0 && !this.webSocketPingSetInterval) {
this.webSocketPingSetInterval = setInterval(() => {
if (this.isWebSocketConnectionOpened()) {
- this.wsConnection.ping((): void => { });
+ this.wsConnection.ping((): void => { /* This is intentional */ });
}
}, webSocketPingInterval * 1000);
logger.info(this.logPrefix() + ' WebSocket ping started every ' + Utils.secondsToHHMMSS(webSocketPingInterval));
indexUrl = this.index % supervisionUrls.length;
} else {
// Get a random url
- indexUrl = Math.floor(Math.random() * supervisionUrls.length);
+ indexUrl = Math.floor(Utils.secureRandom() * supervisionUrls.length);
}
return new URL(supervisionUrls[indexUrl]);
}