@stream-io/video-client 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/index.browser.es.js +66 -46
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +65 -47
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +66 -46
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/client.d.ts +1 -6
- package/dist/src/coordinator/connection/types.d.ts +12 -0
- package/dist/src/helpers/DynascaleManager.d.ts +0 -2
- package/dist/src/helpers/client-details.d.ts +1 -6
- package/dist/src/helpers/clientUtils.d.ts +1 -1
- package/dist/src/stats/SfuStatsReporter.d.ts +2 -3
- package/dist/src/stats/utils.d.ts +2 -6
- package/package.json +2 -2
- package/src/Call.ts +8 -6
- package/src/coordinator/connection/client.ts +23 -23
- package/src/coordinator/connection/connection.ts +1 -1
- package/src/coordinator/connection/types.ts +14 -0
- package/src/helpers/DynascaleManager.ts +0 -2
- package/src/helpers/__tests__/clientUtils.test.ts +29 -3
- package/src/helpers/client-details.ts +23 -19
- package/src/helpers/clientUtils.ts +22 -12
- package/src/rtc/BasePeerConnection.ts +1 -0
- package/src/stats/SfuStatsReporter.ts +3 -6
- package/src/stats/utils.ts +2 -3
package/dist/index.cjs.js
CHANGED
|
@@ -5285,6 +5285,8 @@ class BasePeerConnection {
|
|
|
5285
5285
|
this.onIceConnectionStateChange = () => {
|
|
5286
5286
|
const state = this.pc.iceConnectionState;
|
|
5287
5287
|
this.logger('debug', `ICE connection state changed`, state);
|
|
5288
|
+
if (this.state.callingState === exports.CallingState.OFFLINE)
|
|
5289
|
+
return;
|
|
5288
5290
|
if (this.state.callingState === exports.CallingState.RECONNECTING)
|
|
5289
5291
|
return;
|
|
5290
5292
|
// do nothing when ICE is restarting
|
|
@@ -7463,7 +7465,7 @@ const aggregate = (stats) => {
|
|
|
7463
7465
|
return report;
|
|
7464
7466
|
};
|
|
7465
7467
|
|
|
7466
|
-
const version = "1.
|
|
7468
|
+
const version = "1.18.0";
|
|
7467
7469
|
const [major, minor, patch] = version.split('.');
|
|
7468
7470
|
let sdkInfo = {
|
|
7469
7471
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -7484,15 +7486,9 @@ const getSdkInfo = () => {
|
|
|
7484
7486
|
const setOSInfo = (info) => {
|
|
7485
7487
|
osInfo = info;
|
|
7486
7488
|
};
|
|
7487
|
-
const getOSInfo = () => {
|
|
7488
|
-
return osInfo;
|
|
7489
|
-
};
|
|
7490
7489
|
const setDeviceInfo = (info) => {
|
|
7491
7490
|
deviceInfo = info;
|
|
7492
7491
|
};
|
|
7493
|
-
const getDeviceInfo = () => {
|
|
7494
|
-
return deviceInfo;
|
|
7495
|
-
};
|
|
7496
7492
|
const getWebRTCInfo = () => {
|
|
7497
7493
|
return webRtcInfo;
|
|
7498
7494
|
};
|
|
@@ -7560,26 +7556,40 @@ const setPowerState = (powerMode) => {
|
|
|
7560
7556
|
const getDeviceState = () => {
|
|
7561
7557
|
return deviceState;
|
|
7562
7558
|
};
|
|
7563
|
-
const getClientDetails = () => {
|
|
7559
|
+
const getClientDetails = async () => {
|
|
7564
7560
|
if (isReactNative()) {
|
|
7565
7561
|
// Since RN doesn't support web, sharing browser info is not required
|
|
7566
7562
|
return {
|
|
7567
|
-
sdk:
|
|
7568
|
-
os:
|
|
7569
|
-
device:
|
|
7563
|
+
sdk: sdkInfo,
|
|
7564
|
+
os: osInfo,
|
|
7565
|
+
device: deviceInfo,
|
|
7570
7566
|
};
|
|
7571
7567
|
}
|
|
7568
|
+
// @ts-expect-error - userAgentData is not yet in the TS types
|
|
7569
|
+
const userAgentDataApi = navigator.userAgentData;
|
|
7570
|
+
let userAgentData;
|
|
7571
|
+
if (userAgentDataApi && userAgentDataApi.getHighEntropyValues) {
|
|
7572
|
+
try {
|
|
7573
|
+
userAgentData = await userAgentDataApi.getHighEntropyValues([
|
|
7574
|
+
'platform',
|
|
7575
|
+
'platformVersion',
|
|
7576
|
+
]);
|
|
7577
|
+
}
|
|
7578
|
+
catch (e) {
|
|
7579
|
+
// Ignore the error
|
|
7580
|
+
}
|
|
7581
|
+
}
|
|
7572
7582
|
const userAgent = new uaParserJs.UAParser(navigator.userAgent);
|
|
7573
7583
|
const { browser, os, device, cpu } = userAgent.getResult();
|
|
7574
7584
|
return {
|
|
7575
|
-
sdk:
|
|
7585
|
+
sdk: sdkInfo,
|
|
7576
7586
|
browser: {
|
|
7577
7587
|
name: browser.name || navigator.userAgent,
|
|
7578
7588
|
version: browser.version || '',
|
|
7579
7589
|
},
|
|
7580
7590
|
os: {
|
|
7581
|
-
name: os.name || '',
|
|
7582
|
-
version: os.version || '',
|
|
7591
|
+
name: userAgentData?.platform || os.name || '',
|
|
7592
|
+
version: userAgentData?.platformVersion || os.version || '',
|
|
7583
7593
|
architecture: cpu.architecture || '',
|
|
7584
7594
|
},
|
|
7585
7595
|
device: {
|
|
@@ -7808,8 +7818,6 @@ const globalOverrideKey = Symbol('globalOverrideKey');
|
|
|
7808
7818
|
class DynascaleManager {
|
|
7809
7819
|
/**
|
|
7810
7820
|
* Creates a new DynascaleManager instance.
|
|
7811
|
-
*
|
|
7812
|
-
* @param call the call to manage.
|
|
7813
7821
|
*/
|
|
7814
7822
|
constructor(callState, speaker) {
|
|
7815
7823
|
/**
|
|
@@ -10447,6 +10455,7 @@ class Call {
|
|
|
10447
10455
|
this.leaveCallHooks.forEach((hook) => hook());
|
|
10448
10456
|
this.initialized = false;
|
|
10449
10457
|
this.hasJoinedOnce = false;
|
|
10458
|
+
this.ringingSubject.next(false);
|
|
10450
10459
|
this.clientStore.unregisterCall(this);
|
|
10451
10460
|
this.camera.dispose();
|
|
10452
10461
|
this.microphone.dispose();
|
|
@@ -10505,7 +10514,7 @@ class Call {
|
|
|
10505
10514
|
this.state.updateFromCallResponse(response.call);
|
|
10506
10515
|
this.state.setMembers(response.members);
|
|
10507
10516
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
10508
|
-
if (params?.ring
|
|
10517
|
+
if (params?.ring) {
|
|
10509
10518
|
// the call response can indicate where the call is still ringing or not
|
|
10510
10519
|
this.ringingSubject.next(true);
|
|
10511
10520
|
}
|
|
@@ -10527,7 +10536,7 @@ class Call {
|
|
|
10527
10536
|
this.state.updateFromCallResponse(response.call);
|
|
10528
10537
|
this.state.setMembers(response.members);
|
|
10529
10538
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
10530
|
-
if (data?.ring
|
|
10539
|
+
if (data?.ring) {
|
|
10531
10540
|
// the call response can indicate where the call is still ringing or not
|
|
10532
10541
|
this.ringingSubject.next(true);
|
|
10533
10542
|
}
|
|
@@ -10639,7 +10648,7 @@ class Call {
|
|
|
10639
10648
|
: previousSfuClient;
|
|
10640
10649
|
this.sfuClient = sfuClient;
|
|
10641
10650
|
this.dynascaleManager.setSfuClient(sfuClient);
|
|
10642
|
-
const clientDetails = getClientDetails();
|
|
10651
|
+
const clientDetails = await getClientDetails();
|
|
10643
10652
|
// we don't need to send JoinRequest if we are re-using an existing healthy SFU client
|
|
10644
10653
|
if (previousSfuClient !== sfuClient) {
|
|
10645
10654
|
// prepare a generic SDP and send it to the SFU.
|
|
@@ -10898,7 +10907,7 @@ class Call {
|
|
|
10898
10907
|
this.state.updateFromCallResponse(joinResponse.call);
|
|
10899
10908
|
this.state.setMembers(joinResponse.members);
|
|
10900
10909
|
this.state.setOwnCapabilities(joinResponse.own_capabilities);
|
|
10901
|
-
if (data?.ring
|
|
10910
|
+
if (data?.ring) {
|
|
10902
10911
|
this.ringingSubject.next(true);
|
|
10903
10912
|
}
|
|
10904
10913
|
if (this.ringing && !this.isCreatedByMe) {
|
|
@@ -11767,7 +11776,7 @@ class Call {
|
|
|
11767
11776
|
* @param custom Custom data
|
|
11768
11777
|
*/
|
|
11769
11778
|
this.submitFeedback = async (rating, { reason, custom, } = {}) => {
|
|
11770
|
-
const { sdkName, sdkVersion, ...platform } = getSdkSignature(getClientDetails());
|
|
11779
|
+
const { sdkName, sdkVersion, ...platform } = getSdkSignature(await getClientDetails());
|
|
11771
11780
|
return this.streamClient.post(`${this.streamClientBasePath}/feedback`, {
|
|
11772
11781
|
rating,
|
|
11773
11782
|
reason,
|
|
@@ -12451,7 +12460,7 @@ class StableWSConnection {
|
|
|
12451
12460
|
}
|
|
12452
12461
|
}
|
|
12453
12462
|
catch (err) {
|
|
12454
|
-
|
|
12463
|
+
this.client._setupConnectionIdPromise();
|
|
12455
12464
|
this.isConnecting = false;
|
|
12456
12465
|
// @ts-ignore
|
|
12457
12466
|
this._log(`_connect() - Error - `, err);
|
|
@@ -12764,8 +12773,7 @@ class StreamClient {
|
|
|
12764
12773
|
if (this.userID) {
|
|
12765
12774
|
throw new Error('Use client.disconnect() before trying to connect as a different user. connectUser was called twice.');
|
|
12766
12775
|
}
|
|
12767
|
-
if ((this.
|
|
12768
|
-
!this.options.allowServerSideConnect) {
|
|
12776
|
+
if ((this.secret || this.node) && !this.options.allowServerSideConnect) {
|
|
12769
12777
|
this.logger('warn', 'Please do not use connectUser server side. Use our @stream-io/node-sdk instead: https://getstream.io/video/docs/api/');
|
|
12770
12778
|
}
|
|
12771
12779
|
// we generate the client id client side
|
|
@@ -12833,7 +12841,7 @@ class StreamClient {
|
|
|
12833
12841
|
this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists');
|
|
12834
12842
|
return;
|
|
12835
12843
|
}
|
|
12836
|
-
|
|
12844
|
+
this._setupConnectionIdPromise();
|
|
12837
12845
|
this.clientID = `${this.userID}--${randomId()}`;
|
|
12838
12846
|
const newWsPromise = this.connect();
|
|
12839
12847
|
this.wsPromiseSafe = makeSafePromise(newWsPromise);
|
|
@@ -12870,7 +12878,7 @@ class StreamClient {
|
|
|
12870
12878
|
*/
|
|
12871
12879
|
this.connectAnonymousUser = async (user, tokenOrProvider) => {
|
|
12872
12880
|
addConnectionEventListeners(this.updateNetworkConnectionStatus);
|
|
12873
|
-
|
|
12881
|
+
this._setupConnectionIdPromise();
|
|
12874
12882
|
this.anonymous = true;
|
|
12875
12883
|
await this._setToken(user, tokenOrProvider, this.anonymous);
|
|
12876
12884
|
this._setUser(user);
|
|
@@ -12920,12 +12928,16 @@ class StreamClient {
|
|
|
12920
12928
|
}));
|
|
12921
12929
|
};
|
|
12922
12930
|
this._logApiRequest = (type, url, data, config) => {
|
|
12931
|
+
if (getLogLevel() !== 'trace')
|
|
12932
|
+
return;
|
|
12923
12933
|
this.logger('trace', `client: ${type} - Request - ${url}`, {
|
|
12924
12934
|
payload: data,
|
|
12925
12935
|
config,
|
|
12926
12936
|
});
|
|
12927
12937
|
};
|
|
12928
12938
|
this._logApiResponse = (type, url, response) => {
|
|
12939
|
+
if (getLogLevel() !== 'trace')
|
|
12940
|
+
return;
|
|
12929
12941
|
this.logger('trace', `client:${type} - Response - url: ${url} > status ${response.status}`, {
|
|
12930
12942
|
response,
|
|
12931
12943
|
});
|
|
@@ -13074,17 +13086,17 @@ class StreamClient {
|
|
|
13074
13086
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
13075
13087
|
};
|
|
13076
13088
|
this.getUserAgent = () => {
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13089
|
+
if (!this.cachedUserAgent) {
|
|
13090
|
+
const { clientAppIdentifier = {} } = this.options;
|
|
13091
|
+
const { sdkName = 'js', sdkVersion = "1.18.0", ...extras } = clientAppIdentifier;
|
|
13092
|
+
this.cachedUserAgent = [
|
|
13093
|
+
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
13094
|
+
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
13095
|
+
`client_bundle=${"node-cjs"}`,
|
|
13096
|
+
].join('|');
|
|
13097
|
+
}
|
|
13098
|
+
return this.cachedUserAgent;
|
|
13083
13099
|
};
|
|
13084
|
-
/**
|
|
13085
|
-
* _isUsingServerAuth - Returns true if we're using server side auth
|
|
13086
|
-
*/
|
|
13087
|
-
this._isUsingServerAuth = () => !!this.secret;
|
|
13088
13100
|
this._enrichAxiosOptions = (options = {
|
|
13089
13101
|
params: {},
|
|
13090
13102
|
headers: {},
|
|
@@ -13197,24 +13209,32 @@ class StreamClient {
|
|
|
13197
13209
|
const getInstanceKey = (apiKey, user) => {
|
|
13198
13210
|
return `${apiKey}/${user.id}`;
|
|
13199
13211
|
};
|
|
13212
|
+
/**
|
|
13213
|
+
* Utility function to get the client app identifier.
|
|
13214
|
+
*/
|
|
13215
|
+
const getClientAppIdentifier = (options) => {
|
|
13216
|
+
const appId = options?.clientAppIdentifier || {};
|
|
13217
|
+
const sdkInfo = getSdkInfo();
|
|
13218
|
+
if (sdkInfo) {
|
|
13219
|
+
// ensure the sdk name and version are set correctly,
|
|
13220
|
+
// overriding any user-provided values
|
|
13221
|
+
appId.sdkName = SdkType[sdkInfo.type].toLowerCase();
|
|
13222
|
+
appId.sdkVersion = `${sdkInfo.major}.${sdkInfo.minor}.${sdkInfo.patch}`;
|
|
13223
|
+
}
|
|
13224
|
+
return appId;
|
|
13225
|
+
};
|
|
13200
13226
|
/**
|
|
13201
13227
|
* Creates a coordinator client.
|
|
13202
13228
|
*/
|
|
13203
13229
|
const createCoordinatorClient = (apiKey, options) => {
|
|
13230
|
+
const clientAppIdentifier = getClientAppIdentifier(options);
|
|
13204
13231
|
const coordinatorLogger = getLogger(['coordinator']);
|
|
13205
|
-
|
|
13232
|
+
return new StreamClient(apiKey, {
|
|
13206
13233
|
persistUserOnConnectionFailure: true,
|
|
13207
13234
|
...options,
|
|
13235
|
+
clientAppIdentifier,
|
|
13208
13236
|
logger: coordinatorLogger,
|
|
13209
13237
|
});
|
|
13210
|
-
const sdkInfo = getSdkInfo();
|
|
13211
|
-
if (sdkInfo) {
|
|
13212
|
-
const sdkName = SdkType[sdkInfo.type].toLowerCase();
|
|
13213
|
-
const sdkVersion = `${sdkInfo.major}.${sdkInfo.minor}.${sdkInfo.patch}`;
|
|
13214
|
-
const userAgent = streamClient.getUserAgent();
|
|
13215
|
-
streamClient.setUserAgent(`${userAgent}-video-${sdkName}-sdk-${sdkVersion}`);
|
|
13216
|
-
}
|
|
13217
|
-
return streamClient;
|
|
13218
13238
|
};
|
|
13219
13239
|
/**
|
|
13220
13240
|
* Creates a token provider and allows integrators to provide
|
|
@@ -13644,11 +13664,9 @@ exports.getAudioDevices = getAudioDevices;
|
|
|
13644
13664
|
exports.getAudioOutputDevices = getAudioOutputDevices;
|
|
13645
13665
|
exports.getAudioStream = getAudioStream;
|
|
13646
13666
|
exports.getClientDetails = getClientDetails;
|
|
13647
|
-
exports.getDeviceInfo = getDeviceInfo;
|
|
13648
13667
|
exports.getDeviceState = getDeviceState;
|
|
13649
13668
|
exports.getLogLevel = getLogLevel;
|
|
13650
13669
|
exports.getLogger = getLogger;
|
|
13651
|
-
exports.getOSInfo = getOSInfo;
|
|
13652
13670
|
exports.getScreenShareStream = getScreenShareStream;
|
|
13653
13671
|
exports.getSdkInfo = getSdkInfo;
|
|
13654
13672
|
exports.getVideoBrowserPermission = getVideoBrowserPermission;
|