@stream-io/video-client 0.0.4 → 0.0.6

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.0.6](https://github.com/GetStream/stream-video-js/compare/client0.0.5...client0.0.6) (2023-06-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * Add token creation to client ([#607](https://github.com/GetStream/stream-video-js/issues/607)) ([5f95420](https://github.com/GetStream/stream-video-js/commit/5f9542029a64ddaf6ee7912ea7b364fc74c93bf0))
11
+
12
+ ### [0.0.5](https://github.com/GetStream/stream-video-js/compare/client0.0.4...client0.0.5) (2023-06-06)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * adjustments to the new egress response structure ([#595](https://github.com/GetStream/stream-video-js/issues/595)) ([3b3edea](https://github.com/GetStream/stream-video-js/commit/3b3edea7d032a50cb0757c6b46114e8009ae56fc))
18
+
5
19
  ### [0.0.4](https://github.com/GetStream/stream-video-js/compare/client0.0.3...client0.0.4) (2023-06-06)
6
20
 
7
21
 
@@ -7543,14 +7543,17 @@ const watchCallBroadcastingStarted = (state) => {
7543
7543
  return function onCallBroadcastingStarted(event) {
7544
7544
  if (event.type !== 'call.broadcasting_started')
7545
7545
  return;
7546
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { broadcasting: true, hls_playlist_url: event.hls_playlist_url })));
7546
+ state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: true, hls: Object.assign(Object.assign({}, metadata.egress.hls), { playlist_url: event.hls_playlist_url }) }) })));
7547
7547
  };
7548
7548
  };
7549
+ /**
7550
+ * Watches for `call.broadcasting_stopped` events.
7551
+ */
7549
7552
  const watchCallBroadcastingStopped = (state) => {
7550
7553
  return function onCallBroadcastingStopped(event) {
7551
7554
  if (event.type !== 'call.broadcasting_stopped')
7552
7555
  return;
7553
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { broadcasting: false })));
7556
+ state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: false }) })));
7554
7557
  };
7555
7558
  };
7556
7559
 
@@ -10990,7 +10993,7 @@ class StreamClient {
10990
10993
  }
10991
10994
  getUserAgent() {
10992
10995
  return (this.userAgent ||
10993
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.3"}`);
10996
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.5"}`);
10994
10997
  }
10995
10998
  setUserAgent(userAgent) {
10996
10999
  this.userAgent = userAgent;
@@ -11024,6 +11027,32 @@ class StreamClient {
11024
11027
  createAbortControllerForNextRequest() {
11025
11028
  return (this.nextRequestAbortController = new AbortController());
11026
11029
  }
11030
+ /**
11031
+ * createToken - Creates a token to authenticate this user. This function is used server side.
11032
+ * The resulting token should be passed to the client side when the users registers or logs in.
11033
+ *
11034
+ * @param {string} userID The User ID
11035
+ * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
11036
+ * @param call_cids for anonymous tokens you have to provide the call cids the use can join
11037
+ *
11038
+ * @return {string} Returns a token
11039
+ */
11040
+ createToken(userID, exp, iat, call_cids) {
11041
+ if (this.secret == null) {
11042
+ throw Error(`tokens can only be created server-side using the API Secret`);
11043
+ }
11044
+ const extra = {};
11045
+ if (exp) {
11046
+ extra.exp = exp;
11047
+ }
11048
+ if (iat) {
11049
+ extra.iat = iat;
11050
+ }
11051
+ if (call_cids) {
11052
+ extra.call_cids = call_cids;
11053
+ }
11054
+ return JWTUserToken(this.secret, userID, extra, {});
11055
+ }
11027
11056
  }
11028
11057
 
11029
11058
  /**
@@ -11261,9 +11290,7 @@ class StreamVideoClient {
11261
11290
  this.removeDevice = (id, userID) => __awaiter(this, void 0, void 0, function* () {
11262
11291
  return yield this.streamClient.delete('/devices', Object.assign({ id }, (userID ? { user_id: userID } : {})));
11263
11292
  });
11264
- this.streamClient = new StreamClient(apiKey, Object.assign({
11265
- // FIXME: OL: fix SSR.
11266
- browser: true, persistUserOnConnectionFailure: true }, opts));
11293
+ this.streamClient = new StreamClient(apiKey, Object.assign({ persistUserOnConnectionFailure: true }, opts));
11267
11294
  this.writeableStateStore = new StreamVideoWriteableStateStore();
11268
11295
  this.readOnlyStateStore = new StreamVideoReadOnlyStateStore(this.writeableStateStore);
11269
11296
  }
@@ -11280,6 +11307,19 @@ class StreamVideoClient {
11280
11307
  return yield this.addDevice(id, push_provider, push_provider_name, userID, true);
11281
11308
  });
11282
11309
  }
11310
+ /**
11311
+ * createToken - Creates a token to authenticate this user. This function is used server side.
11312
+ * The resulting token should be passed to the client side when the users registers or logs in.
11313
+ *
11314
+ * @param {string} userID The User ID
11315
+ * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
11316
+ * @param call_cids for anonymous tokens you have to provide the call cids the use can join
11317
+ *
11318
+ * @return {string} Returns a token
11319
+ */
11320
+ createToken(userID, exp, iat, call_cids) {
11321
+ return this.streamClient.createToken(userID, exp, iat, call_cids);
11322
+ }
11283
11323
  }
11284
11324
 
11285
11325
  const getDevices = (constraints) => {