Skip to content

Commit

Permalink
fix: revert proxy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed May 17, 2024
1 parent ca28beb commit ee583cf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 84 deletions.
24 changes: 7 additions & 17 deletions packages/hms-video-store/src/analytics/HTTPAnalyticsTransport.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import AnalyticsEvent from './AnalyticsEvent';
import { IAnalyticsTransportProvider } from './IAnalyticsTransportProvider';
import { HMSProxyConfig } from '../interfaces';
import {
CLIENT_ANAYLTICS_PROD_ENDPOINT,
CLIENT_ANAYLTICS_QA_ENDPOINT,
CLIENT_ANAYLTICS_STORAGE_LIMIT,
} from '../utils/constants';
import { getEndpointFromProxy } from '../utils/get-endpoint-from-proxy';
import { LocalStorage } from '../utils/local-storage';
import HMSLogger from '../utils/logger';
import { ENV } from '../utils/support';
Expand Down Expand Up @@ -41,15 +39,13 @@ class ClientAnalyticsTransport implements IAnalyticsTransportProvider {
isConnected = true;
private env: null | ENV = null;
private websocketURL = '';
private proxy?: HMSProxyConfig;

setEnv(env: ENV) {
this.env = env;
this.flushFailedEvents();
}

setWebsocketEndpoint(ws: string, proxy?: HMSProxyConfig) {
this.proxy = proxy;
setWebsocketEndpoint(ws: string) {
this.websocketURL = ws;
}

Expand All @@ -71,19 +67,13 @@ class ClientAnalyticsTransport implements IAnalyticsTransportProvider {
};
const url = this.env === ENV.PROD ? CLIENT_ANAYLTICS_PROD_ENDPOINT : CLIENT_ANAYLTICS_QA_ENDPOINT;

const proxyUrl = getEndpointFromProxy(this.proxy);
const headers = {
'Content-Type': 'application/json',
Authorization: `Bearer ${event.metadata.token}`,
user_agent_v2: event.metadata.userAgent,
'Target-URL': url,
};
if (proxyUrl) {
headers['Target-URL'] = url;
}
fetch(proxyUrl || url, {
fetch(url, {
method: 'POST',
headers,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${event.metadata.token}`,
user_agent_v2: event.metadata.userAgent,
},
body: JSON.stringify(requestBody),
})
.then(response => {
Expand Down
1 change: 0 additions & 1 deletion packages/hms-video-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export type {
HMSQuizLeaderboardResponse,
HMSQuizLeaderboardSummary,
HMSTranscriptionInfo,
HMSProxyConfig,
HMSICEServer,
} from './internal';

Expand Down
14 changes: 0 additions & 14 deletions packages/hms-video-store/src/interfaces/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ export type HMSICEServer = {
password?: string;
};

enum HMSProxyType {
HTTPS = 0,
}

export type HMSProxyConfig = {
type: HMSProxyType;
host: string;
port: number;
};

export interface HMSConfig {
/**
* the name of the peer, can be later accessed via peer.name and can also be changed mid call.
Expand Down Expand Up @@ -74,10 +64,6 @@ export interface HMSConfig {
* will be kept awake.
*/
autoManageWakeLock?: boolean;
/**
* use custom proxy for signalling connection (advanced)
*/
proxy?: HMSProxyConfig;
/**
* use custom STUN/TURN servers for media connection (advanced)
*/
Expand Down
14 changes: 3 additions & 11 deletions packages/hms-video-store/src/signal/init/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { InitConfig } from './models';
import { ErrorFactory } from '../../error/ErrorFactory';
import { HMSAction } from '../../error/HMSAction';
import { HMSICEServer, HMSProxyConfig } from '../../interfaces';
import { getEndpointFromProxy } from '../../utils/get-endpoint-from-proxy';
import { HMSICEServer } from '../../interfaces';
import { transformIceServerConfig } from '../../utils/ice-server-config';
import HMSLogger from '../../utils/logger';

Expand Down Expand Up @@ -30,26 +29,19 @@ export default class InitService {
initEndpoint = 'https://prod-init.100ms.live',
region = '',
iceServers = [],
proxy,
}: {
token: string;
peerId: string;
userAgent: string;
initEndpoint?: string;
region?: string;
iceServers?: HMSICEServer[];
proxy?: HMSProxyConfig;
}): Promise<InitConfig> {
HMSLogger.d(TAG, `fetchInitConfig: initEndpoint=${initEndpoint} token=${token} peerId=${peerId} region=${region} `);
const url = getUrl(initEndpoint, peerId, userAgent, region);
try {
const proxyUrl = getEndpointFromProxy(proxy);
const headers: Record<string, string> = { Authorization: `Bearer ${token}` };
if (proxyUrl) {
headers['Target-URL'] = url;
}
const response = await fetch(proxyUrl || url, {
headers,
const response = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});
try {
const config = await response.clone().json();
Expand Down
19 changes: 5 additions & 14 deletions packages/hms-video-store/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ErrorFactory } from '../error/ErrorFactory';
import { HMSAction } from '../error/HMSAction';
import { HMSException } from '../error/HMSException';
import { EventBus } from '../events/EventBus';
import { HMSICEServer, HMSProxyConfig, HMSRole } from '../interfaces';
import { HMSICEServer, HMSRole } from '../interfaces';
import { HMSLocalStream } from '../media/streams/HMSLocalStream';
import { HMSLocalTrack, HMSLocalVideoTrack, HMSTrack } from '../media/tracks';
import { TrackState } from '../notification-manager';
Expand Down Expand Up @@ -449,7 +449,6 @@ export default class HMSTransport {
customData: { name: string; metaData: string },
autoSubscribeVideo = false,
iceServers?: HMSICEServer[],
proxy?: HMSProxyConfig,
): Promise<InitConfig | void> {
this.setTransportStateForConnect();
this.joinParameters = new JoinParameters(
Expand All @@ -460,10 +459,9 @@ export default class HMSTransport {
endpoint,
autoSubscribeVideo,
iceServers,
proxy,
);
try {
const response = await this.internalConnect(token, endpoint, peerId, iceServers, proxy);
const response = await this.internalConnect(token, endpoint, peerId, iceServers);
return response;
} catch (error) {
const shouldRetry =
Expand All @@ -479,7 +477,7 @@ export default class HMSTransport {

if (shouldRetry) {
const task = async () => {
await this.internalConnect(token, endpoint, peerId, iceServers, proxy);
await this.internalConnect(token, endpoint, peerId, iceServers);
return Boolean(this.initConfig && this.initConfig.endpoint);
};

Expand Down Expand Up @@ -903,13 +901,7 @@ export default class HMSTransport {
}
}

private async internalConnect(
token: string,
initEndpoint: string,
peerId: string,
iceServers?: HMSICEServer[],
proxy?: HMSProxyConfig,
) {
private async internalConnect(token: string, initEndpoint: string, peerId: string, iceServers?: HMSICEServer[]) {
HMSLogger.d(TAG, 'connect: started ⏰');
const connectRequestedAt = new Date();
try {
Expand All @@ -920,7 +912,6 @@ export default class HMSTransport {
userAgent: this.store.getUserAgent(),
initEndpoint,
iceServers,
proxy,
});
const room = this.store.getRoom();
if (room) {
Expand All @@ -930,7 +921,7 @@ export default class HMSTransport {
room.isNoiseCancellationEnabled = this.isFlagEnabled(InitFlags.FLAG_NOISE_CANCELLATION);
}
this.analyticsTimer.end(TimedEvent.INIT);
HTTPAnalyticsTransport.setWebsocketEndpoint(this.initConfig.endpoint, proxy);
HTTPAnalyticsTransport.setWebsocketEndpoint(this.initConfig.endpoint);
// if leave was called while init was going on, don't open websocket
this.validateNotDisconnected('post init');
await this.openSignal(token, peerId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HMSICEServer, HMSProxyConfig } from '../../interfaces';
import { HMSICEServer } from '../../interfaces';

export class JoinParameters {
constructor(
Expand All @@ -9,6 +9,5 @@ export class JoinParameters {
public endpoint: string = 'https://prod-init.100ms.live/init',
public autoSubscribeVideo: boolean = false,
public iceServers?: HMSICEServer[],
public proxy?: HMSProxyConfig,
) {}
}
16 changes: 0 additions & 16 deletions packages/hms-video-store/src/utils/get-endpoint-from-proxy.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/react-sdk/src/hooks/usePreviewJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
HMSConfigInitialSettings,
HMSICEServer,
HMSPreviewConfig,
HMSProxyConfig,
HMSRoomState,
selectIsConnectedToRoom,
selectRoomState,
Expand Down Expand Up @@ -54,11 +53,6 @@ export interface usePreviewInput {
*/
autoManageWakeLock?: boolean;

/**
* use custom proxy for signalling connection (advanced)
*/
proxy?: HMSProxyConfig;

/**
* use custom STUN/TURN servers for media connection (advanced)
*/
Expand Down Expand Up @@ -102,7 +96,6 @@ export const usePreviewJoin = ({
asRole,
autoManageVideo,
autoManageWakeLock,
proxy,
iceServers,
}: usePreviewInput): usePreviewResult => {
const actions = useHMSActions();
Expand All @@ -122,7 +115,6 @@ export const usePreviewJoin = ({
captureNetworkQualityInPreview,
autoManageVideo,
autoManageWakeLock,
proxy,
iceServers,
};
}, [
Expand All @@ -135,7 +127,6 @@ export const usePreviewJoin = ({
asRole,
autoManageVideo,
autoManageWakeLock,
proxy,
iceServers,
]);

Expand Down

0 comments on commit ee583cf

Please sign in to comment.