backend: Prevent instantiation of utility classes by adding private constructors in helpers

This commit is contained in:
Carlos Santos 2025-03-28 10:19:41 +01:00
parent 74254be37b
commit 7dffc6b60a
3 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,10 @@ const enum OpenViduComponentsDataTopic {
} }
export class OpenViduComponentsAdapterHelper { export class OpenViduComponentsAdapterHelper {
private constructor() {
// Prevent instantiation of this utility class
}
static generateRecordingSignal(recordingInfo: MeetRecordingInfo) { static generateRecordingSignal(recordingInfo: MeetRecordingInfo) {
const options: SendDataOptions = { const options: SendDataOptions = {
destinationSids: [], destinationSids: [],

View File

@ -3,6 +3,10 @@ import { MeetRecordingInfo, MeetRecordingOutputMode, MeetRecordingStatus } from
import { EgressStatus } from '@livekit/protocol'; import { EgressStatus } from '@livekit/protocol';
export class RecordingHelper { export class RecordingHelper {
private constructor() {
// Prevent instantiation of this utility class
}
static toRecordingInfo(egressInfo: EgressInfo): MeetRecordingInfo { static toRecordingInfo(egressInfo: EgressInfo): MeetRecordingInfo {
const status = RecordingHelper.extractOpenViduStatus(egressInfo.status); const status = RecordingHelper.extractOpenViduStatus(egressInfo.status);
const size = RecordingHelper.extractSize(egressInfo); const size = RecordingHelper.extractSize(egressInfo);
@ -140,8 +144,9 @@ export class RecordingHelper {
* @param egressInfo - The EgressInfo object containing the endedAt value. * @param egressInfo - The EgressInfo object containing the endedAt value.
* @returns The endedAt value converted to milliseconds. * @returns The endedAt value converted to milliseconds.
*/ */
static extractEndDate(egressInfo: EgressInfo): number { static extractEndDate(egressInfo: EgressInfo): number | undefined {
return this.toMilliseconds(Number(egressInfo.endedAt ?? 0)); const endDateMs = this.toMilliseconds(Number(egressInfo.endedAt ?? 0));
return endDateMs !== 0 ? endDateMs : undefined;
} }
/** /**

View File

@ -4,6 +4,10 @@ import { MEET_NAME_ID } from '../environment.js';
import { uid } from 'uid/single'; import { uid } from 'uid/single';
export class OpenViduRoomHelper { export class OpenViduRoomHelper {
private constructor() {
// Prevent instantiation of this utility class
}
/** /**
* Converts an OpenViduMeetRoom object to an OpenViduMeetRoomOptions object. * Converts an OpenViduMeetRoom object to an OpenViduMeetRoomOptions object.
* *