stream-chat 8.5.0 → 8.6.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/dist/index.js CHANGED
@@ -3254,6 +3254,7 @@ var Channel = /*#__PURE__*/function () {
3254
3254
 
3255
3255
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
3256
3256
  this.data = state.channel;
3257
+ this.offlineMode = false;
3257
3258
  this.getClient().dispatchEvent({
3258
3259
  type: 'channels.queried',
3259
3260
  queriedChannels: {
@@ -3263,7 +3264,7 @@ var Channel = /*#__PURE__*/function () {
3263
3264
  });
3264
3265
  return _context32.abrupt("return", state);
3265
3266
 
3266
- case 14:
3267
+ case 15:
3267
3268
  case "end":
3268
3269
  return _context32.stop();
3269
3270
  }
@@ -3967,6 +3968,7 @@ var Channel = /*#__PURE__*/function () {
3967
3968
  var read = _step3.value;
3968
3969
  this.state.read[read.user.id] = {
3969
3970
  last_read: new Date(read.last_read),
3971
+ last_read_message_id: read.last_read_message_id,
3970
3972
  unread_messages: (_read$unread_messages = read.unread_messages) !== null && _read$unread_messages !== void 0 ? _read$unread_messages : 0,
3971
3973
  user: read.user
3972
3974
  };
@@ -5254,16 +5256,21 @@ function DevToken(userId) {
5254
5256
  }
5255
5257
  /**
5256
5258
  *
5257
- * @param {string} body the signed message
5259
+ * @param {string | Buffer} body the signed message
5258
5260
  * @param {string} secret the shared secret used to generate the signature (Stream API secret)
5259
5261
  * @param {string} signature the signature to validate
5260
5262
  * @return {boolean}
5261
5263
  */
5262
5264
 
5263
5265
  function CheckSignature(body, secret, signature) {
5264
- var key = Buffer.from(secret, 'ascii');
5266
+ var key = Buffer.from(secret, 'utf8');
5265
5267
  var hash = crypto__default['default'].createHmac('sha256', key).update(body).digest('hex');
5266
- return hash === signature;
5268
+
5269
+ try {
5270
+ return crypto__default['default'].timingSafeEqual(Buffer.from(hash), Buffer.from(signature));
5271
+ } catch (_unused) {
5272
+ return false;
5273
+ }
5267
5274
  }
5268
5275
 
5269
5276
  /**
@@ -8150,18 +8157,6 @@ var StreamChat = /*#__PURE__*/function () {
8150
8157
  _iterator3.f();
8151
8158
  }
8152
8159
 
8153
- if (!offlineMode) {
8154
- // If the channels are coming from server, then clear out the
8155
- // previously help offline channels.
8156
- for (var _key5 in this.activeChannels) {
8157
- var _channel7 = this.activeChannels[_key5];
8158
-
8159
- if (_channel7.offlineMode) {
8160
- delete this.activeChannels[_key5];
8161
- }
8162
- }
8163
- }
8164
-
8165
8160
  return channels;
8166
8161
  }
8167
8162
  /**
@@ -10052,7 +10047,7 @@ var StreamChat = /*#__PURE__*/function () {
10052
10047
  }, {
10053
10048
  key: "getUserAgent",
10054
10049
  value: function getUserAgent() {
10055
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.5.0");
10050
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.6.0");
10056
10051
  }
10057
10052
  }, {
10058
10053
  key: "setUserAgent",
@@ -10129,9 +10124,9 @@ var StreamChat = /*#__PURE__*/function () {
10129
10124
  this.cleaningIntervalRef = setInterval(function () {
10130
10125
  // call clean on the channel, used for calling the stop.typing event etc.
10131
10126
  for (var _i3 = 0, _Object$values2 = Object.values(that.activeChannels); _i3 < _Object$values2.length; _i3++) {
10132
- var _channel8 = _Object$values2[_i3];
10127
+ var _channel7 = _Object$values2[_i3];
10133
10128
 
10134
- _channel8.clean();
10129
+ _channel7.clean();
10135
10130
  }
10136
10131
  }, 500);
10137
10132
  }
@@ -10143,7 +10138,14 @@ var StreamChat = /*#__PURE__*/function () {
10143
10138
 
10144
10139
  }, {
10145
10140
  key: "verifyWebhook",
10146
- value: function verifyWebhook(requestBody, xSignature) {
10141
+ value:
10142
+ /**
10143
+ * checks signature of a request
10144
+ * @param {string | Buffer} rawBody
10145
+ * @param {string} signature from HTTP header
10146
+ * @returns {boolean}
10147
+ */
10148
+ function verifyWebhook(requestBody, xSignature) {
10147
10149
  return !!this.secret && CheckSignature(requestBody, this.secret, xSignature);
10148
10150
  }
10149
10151
  /** getPermission - gets the definition for a permission