@stream-io/video-client 0.0.5 → 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/dist/index.es.js CHANGED
@@ -10997,7 +10997,7 @@ class StreamClient {
10997
10997
  }
10998
10998
  getUserAgent() {
10999
10999
  return (this.userAgent ||
11000
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.4"}`);
11000
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.5"}`);
11001
11001
  }
11002
11002
  setUserAgent(userAgent) {
11003
11003
  this.userAgent = userAgent;
@@ -11031,6 +11031,32 @@ class StreamClient {
11031
11031
  createAbortControllerForNextRequest() {
11032
11032
  return (this.nextRequestAbortController = new AbortController());
11033
11033
  }
11034
+ /**
11035
+ * createToken - Creates a token to authenticate this user. This function is used server side.
11036
+ * The resulting token should be passed to the client side when the users registers or logs in.
11037
+ *
11038
+ * @param {string} userID The User ID
11039
+ * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
11040
+ * @param call_cids for anonymous tokens you have to provide the call cids the use can join
11041
+ *
11042
+ * @return {string} Returns a token
11043
+ */
11044
+ createToken(userID, exp, iat, call_cids) {
11045
+ if (this.secret == null) {
11046
+ throw Error(`tokens can only be created server-side using the API Secret`);
11047
+ }
11048
+ const extra = {};
11049
+ if (exp) {
11050
+ extra.exp = exp;
11051
+ }
11052
+ if (iat) {
11053
+ extra.iat = iat;
11054
+ }
11055
+ if (call_cids) {
11056
+ extra.call_cids = call_cids;
11057
+ }
11058
+ return JWTUserToken(this.secret, userID, extra, {});
11059
+ }
11034
11060
  }
11035
11061
 
11036
11062
  /**
@@ -11268,9 +11294,7 @@ class StreamVideoClient {
11268
11294
  this.removeDevice = (id, userID) => __awaiter(this, void 0, void 0, function* () {
11269
11295
  return yield this.streamClient.delete('/devices', Object.assign({ id }, (userID ? { user_id: userID } : {})));
11270
11296
  });
11271
- this.streamClient = new StreamClient(apiKey, Object.assign({
11272
- // FIXME: OL: fix SSR.
11273
- browser: true, persistUserOnConnectionFailure: true }, opts));
11297
+ this.streamClient = new StreamClient(apiKey, Object.assign({ persistUserOnConnectionFailure: true }, opts));
11274
11298
  this.writeableStateStore = new StreamVideoWriteableStateStore();
11275
11299
  this.readOnlyStateStore = new StreamVideoReadOnlyStateStore(this.writeableStateStore);
11276
11300
  }
@@ -11287,6 +11311,19 @@ class StreamVideoClient {
11287
11311
  return yield this.addDevice(id, push_provider, push_provider_name, userID, true);
11288
11312
  });
11289
11313
  }
11314
+ /**
11315
+ * createToken - Creates a token to authenticate this user. This function is used server side.
11316
+ * The resulting token should be passed to the client side when the users registers or logs in.
11317
+ *
11318
+ * @param {string} userID The User ID
11319
+ * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
11320
+ * @param call_cids for anonymous tokens you have to provide the call cids the use can join
11321
+ *
11322
+ * @return {string} Returns a token
11323
+ */
11324
+ createToken(userID, exp, iat, call_cids) {
11325
+ return this.streamClient.createToken(userID, exp, iat, call_cids);
11326
+ }
11290
11327
  }
11291
11328
 
11292
11329
  const getDevices = (constraints) => {