@stream-io/video-client 0.1.2 → 0.1.3
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 +7 -0
- package/dist/index.browser.es.js +26 -17
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +26 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +26 -17
- package/dist/index.es.js.map +1 -1
- package/dist/src/__tests__/StreamVideoClient.test.d.ts +1 -1
- package/dist/src/coordinator/connection/client.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/StreamVideoClient.test.ts +85 -4
- package/src/__tests__/StreamVideoServerClient.test.ts +22 -0
- package/src/coordinator/connection/client.ts +22 -11
- package/src/coordinator/connection/connection.ts +2 -2
- package/src/coordinator/connection/connection_fallback.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.1.3](https://github.com/GetStream/stream-video-js/compare/client0.1.2...client0.1.3) (2023-07-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* server side user connect + add tests ([#825](https://github.com/GetStream/stream-video-js/issues/825)) ([95ea24d](https://github.com/GetStream/stream-video-js/commit/95ea24d03306d1b25c3c5af042a202a7b551d865))
|
|
11
|
+
|
|
5
12
|
### [0.1.2](https://github.com/GetStream/stream-video-js/compare/client0.1.1...client0.1.2) (2023-07-19)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -10725,6 +10725,7 @@ class StableWSConnection {
|
|
|
10725
10725
|
* @return {ConnectAPIResponse<ConnectedEvent>} Promise that completes once the first health check message is received
|
|
10726
10726
|
*/
|
|
10727
10727
|
_connect() {
|
|
10728
|
+
var _a, _b, _c, _d;
|
|
10728
10729
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10729
10730
|
if (this.isConnecting ||
|
|
10730
10731
|
(this.isDisconnected && this.client.options.enableWSFallback))
|
|
@@ -10761,7 +10762,7 @@ class StableWSConnection {
|
|
|
10761
10762
|
this.isConnecting = false;
|
|
10762
10763
|
if (response) {
|
|
10763
10764
|
this.connectionID = response.connection_id;
|
|
10764
|
-
this.client.resolveConnectionId(this.connectionID);
|
|
10765
|
+
(_b = (_a = this.client).resolveConnectionId) === null || _b === void 0 ? void 0 : _b.call(_a, this.connectionID);
|
|
10765
10766
|
if (this.client.insightMetrics.wsConsecutiveFailures > 0 &&
|
|
10766
10767
|
this.client.options.enableInsights) {
|
|
10767
10768
|
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
@@ -10780,7 +10781,7 @@ class StableWSConnection {
|
|
|
10780
10781
|
const insights = buildWsFatalInsight(this, convertErrorToJson(err));
|
|
10781
10782
|
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
10782
10783
|
}
|
|
10783
|
-
this.client.rejectConnectionId();
|
|
10784
|
+
(_d = (_c = this.client).rejectConnectionId) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
10784
10785
|
throw err;
|
|
10785
10786
|
}
|
|
10786
10787
|
});
|
|
@@ -11186,6 +11187,7 @@ class WSConnectionFallback {
|
|
|
11186
11187
|
undefined, {
|
|
11187
11188
|
config: Object.assign(Object.assign({}, config), { cancelToken: (_a = this.cancelToken) === null || _a === void 0 ? void 0 : _a.token }),
|
|
11188
11189
|
params,
|
|
11190
|
+
publicEndpoint: true,
|
|
11189
11191
|
});
|
|
11190
11192
|
this.consecutiveFailures = 0; // always reset in case of no error
|
|
11191
11193
|
return res;
|
|
@@ -11242,6 +11244,7 @@ class WSConnectionFallback {
|
|
|
11242
11244
|
* @param reconnect should be false for first call and true for subsequent calls to keep the connection alive and call recoverState
|
|
11243
11245
|
*/
|
|
11244
11246
|
this.connect = (reconnect = false) => __awaiter(this, void 0, void 0, function* () {
|
|
11247
|
+
var _c, _d, _e, _f;
|
|
11245
11248
|
if (this.state === ConnectionState.Connecting) {
|
|
11246
11249
|
this._log('connect() - connecting already in progress', { reconnect }, 'warn');
|
|
11247
11250
|
return;
|
|
@@ -11258,7 +11261,7 @@ class WSConnectionFallback {
|
|
|
11258
11261
|
}, reconnect);
|
|
11259
11262
|
this._setState(ConnectionState.Connected);
|
|
11260
11263
|
this.connectionID = event.connection_id;
|
|
11261
|
-
this.client.resolveConnectionId();
|
|
11264
|
+
(_d = (_c = this.client).resolveConnectionId) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
11262
11265
|
// @ts-expect-error
|
|
11263
11266
|
this.client.dispatchEvent(event);
|
|
11264
11267
|
this._poll();
|
|
@@ -11266,7 +11269,7 @@ class WSConnectionFallback {
|
|
|
11266
11269
|
}
|
|
11267
11270
|
catch (err) {
|
|
11268
11271
|
this._setState(ConnectionState.Closed);
|
|
11269
|
-
this.client.rejectConnectionId();
|
|
11272
|
+
(_f = (_e = this.client).rejectConnectionId) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
11270
11273
|
throw err;
|
|
11271
11274
|
}
|
|
11272
11275
|
});
|
|
@@ -11277,10 +11280,10 @@ class WSConnectionFallback {
|
|
|
11277
11280
|
return !!this.connectionID && this.state === ConnectionState.Connected;
|
|
11278
11281
|
};
|
|
11279
11282
|
this.disconnect = (timeout = 2000) => __awaiter(this, void 0, void 0, function* () {
|
|
11280
|
-
var
|
|
11283
|
+
var _g;
|
|
11281
11284
|
removeConnectionEventListeners(this._onlineStatusChanged);
|
|
11282
11285
|
this._setState(ConnectionState.Disconnected);
|
|
11283
|
-
(
|
|
11286
|
+
(_g = this.cancelToken) === null || _g === void 0 ? void 0 : _g.cancel('disconnect() is called');
|
|
11284
11287
|
this.cancelToken = undefined;
|
|
11285
11288
|
const connection_id = this.connectionID;
|
|
11286
11289
|
this.connectionID = undefined;
|
|
@@ -11317,7 +11320,7 @@ class WSConnectionFallback {
|
|
|
11317
11320
|
}
|
|
11318
11321
|
}
|
|
11319
11322
|
|
|
11320
|
-
const version = '0.1.
|
|
11323
|
+
const version = '0.1.3';
|
|
11321
11324
|
|
|
11322
11325
|
const logger = getLogger(['location']);
|
|
11323
11326
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|
|
@@ -11494,6 +11497,10 @@ class StreamClient {
|
|
|
11494
11497
|
this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists');
|
|
11495
11498
|
return Promise.resolve();
|
|
11496
11499
|
}
|
|
11500
|
+
this.connectionIdPromise = new Promise((resolve, reject) => {
|
|
11501
|
+
this.resolveConnectionId = resolve;
|
|
11502
|
+
this.rejectConnectionId = reject;
|
|
11503
|
+
});
|
|
11497
11504
|
this.clientID = `${this.userID}--${randomId()}`;
|
|
11498
11505
|
this.wsPromise = this.connect();
|
|
11499
11506
|
return this.wsPromise;
|
|
@@ -11522,11 +11529,19 @@ class StreamClient {
|
|
|
11522
11529
|
this.anonymous = false;
|
|
11523
11530
|
yield this.closeConnection(timeout);
|
|
11524
11531
|
this.tokenManager.reset();
|
|
11532
|
+
this.connectionIdPromise = undefined;
|
|
11533
|
+
this.rejectConnectionId = undefined;
|
|
11534
|
+
this.resolveConnectionId = undefined;
|
|
11525
11535
|
});
|
|
11526
11536
|
/**
|
|
11527
11537
|
* connectAnonymousUser - Set an anonymous user and open a WebSocket connection
|
|
11528
11538
|
*/
|
|
11529
11539
|
this.connectAnonymousUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
|
|
11540
|
+
var _g;
|
|
11541
|
+
this.connectionIdPromise = new Promise((resolve, reject) => {
|
|
11542
|
+
this.resolveConnectionId = resolve;
|
|
11543
|
+
this.rejectConnectionId = reject;
|
|
11544
|
+
});
|
|
11530
11545
|
this.anonymous = true;
|
|
11531
11546
|
yield this._setToken(user, tokenOrProvider, this.anonymous);
|
|
11532
11547
|
if (this.resolveConnectPromise) {
|
|
@@ -11538,7 +11553,7 @@ class StreamClient {
|
|
|
11538
11553
|
// some endpoints require a connection_id to be resolved.
|
|
11539
11554
|
// as anonymous users aren't allowed to open WS connections, we just
|
|
11540
11555
|
// resolve the connection_id here.
|
|
11541
|
-
this.resolveConnectionId();
|
|
11556
|
+
(_g = this.resolveConnectionId) === null || _g === void 0 ? void 0 : _g.call(this);
|
|
11542
11557
|
});
|
|
11543
11558
|
/**
|
|
11544
11559
|
* on - Listen to events on all channels and users your watching
|
|
@@ -11601,8 +11616,8 @@ class StreamClient {
|
|
|
11601
11616
|
});
|
|
11602
11617
|
};
|
|
11603
11618
|
this.doAxiosRequest = (type, url, data, options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
11604
|
-
var
|
|
11605
|
-
if (!options.publicEndpoint
|
|
11619
|
+
var _h;
|
|
11620
|
+
if (!options.publicEndpoint) {
|
|
11606
11621
|
if (this.waitForConnectPromise) {
|
|
11607
11622
|
yield this.waitForConnectPromise;
|
|
11608
11623
|
}
|
|
@@ -11643,7 +11658,7 @@ class StreamClient {
|
|
|
11643
11658
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11644
11659
|
}
|
|
11645
11660
|
catch (e /**TODO: generalize error types */) {
|
|
11646
|
-
e.client_request_id = (
|
|
11661
|
+
e.client_request_id = (_h = requestConfig.headers) === null || _h === void 0 ? void 0 : _h['x-client-request-id'];
|
|
11647
11662
|
this._logApiError(type, url, e);
|
|
11648
11663
|
this.consecutiveFailures += 1;
|
|
11649
11664
|
if (e.response) {
|
|
@@ -11908,12 +11923,6 @@ class StreamClient {
|
|
|
11908
11923
|
keepAliveMsecs: 3000,
|
|
11909
11924
|
});
|
|
11910
11925
|
}
|
|
11911
|
-
this.connectionIdPromise = this.secret
|
|
11912
|
-
? undefined
|
|
11913
|
-
: new Promise((resolve, reject) => {
|
|
11914
|
-
this.resolveConnectionId = resolve;
|
|
11915
|
-
this.rejectConnectionId = reject;
|
|
11916
|
-
});
|
|
11917
11926
|
this.setBaseURL(this.options.baseURL || 'https://video.stream-io-api.com/video');
|
|
11918
11927
|
if (typeof process !== 'undefined' && process.env.STREAM_LOCAL_TEST_RUN) {
|
|
11919
11928
|
this.setBaseURL('http://localhost:3030/video');
|