stream-chat 9.56.0 → 9.56.1

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.
@@ -239,6 +239,7 @@ __export(index_exports, {
239
239
  timeLeftMs: () => timeLeftMs,
240
240
  verifyAndParseWebhook: () => verifyAndParseWebhook,
241
241
  verifySignature: () => verifySignature,
242
+ webhookConfig: () => webhookConfig,
242
243
  withCancellation: () => withCancellation,
243
244
  withoutConcurrency: () => withoutConcurrency
244
245
  });
@@ -9275,9 +9276,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
9275
9276
  if (!_MessageDeliveryReporter.hasPermissionToReportDeliveryFor(collection)) return;
9276
9277
  const candidate = this.getNextDeliveryReportCandidate(collection);
9277
9278
  if (!candidate?.key) return;
9278
- const buffer = this.markDeliveredRequestInFlight ? this.nextDeliveryReportCandidates : this.deliveryReportCandidates;
9279
- if (candidate.id === null) buffer.delete(candidate.key);
9280
- else buffer.set(candidate.key, candidate.id);
9279
+ const buffer2 = this.markDeliveredRequestInFlight ? this.nextDeliveryReportCandidates : this.deliveryReportCandidates;
9280
+ if (candidate.id === null) buffer2.delete(candidate.key);
9281
+ else buffer2.set(candidate.key, candidate.id);
9281
9282
  }
9282
9283
  /**
9283
9284
  * Removes candidate from the delivery report buffer
@@ -12181,6 +12182,7 @@ var StableWSConnection = class {
12181
12182
  var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
12182
12183
  var import_crypto = __toESM(require("crypto"));
12183
12184
  var import_zlib = __toESM(require("zlib"));
12185
+ var import_buffer = __toESM(require("buffer"));
12184
12186
  function JWTUserToken(apiSecret, userId, extraData = {}, jwtOptions = {}) {
12185
12187
  if (typeof userId !== "string") {
12186
12188
  throw new TypeError("userId should be a string");
@@ -12256,13 +12258,29 @@ var InvalidWebhookError = class extends Error {
12256
12258
  this.name = "InvalidWebhookError";
12257
12259
  }
12258
12260
  };
12261
+ var webhookConfig = {
12262
+ maxPayloadBytes: 10 * 1024 * 1024
12263
+ };
12259
12264
  function gunzipPayload(rawBody) {
12260
12265
  const GZIP_MAGIC = Buffer.from([31, 139]);
12261
12266
  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody);
12262
12267
  if (body.length >= 2 && body.subarray(0, 2).equals(GZIP_MAGIC)) {
12268
+ const max = webhookConfig.maxPayloadBytes;
12269
+ if (!Number.isInteger(max) || max < 1) {
12270
+ const got = typeof max === "string" ? JSON.stringify(max) : String(max);
12271
+ throw new RangeError(
12272
+ `webhookConfig.maxPayloadBytes must be a positive integer, got ${got}`
12273
+ );
12274
+ }
12275
+ const limit = Math.min(max, import_buffer.default.constants.MAX_LENGTH);
12263
12276
  try {
12264
- return import_zlib.default.gunzipSync(body);
12265
- } catch {
12277
+ return import_zlib.default.gunzipSync(body, { maxOutputLength: limit });
12278
+ } catch (err) {
12279
+ if (err.code === "ERR_BUFFER_TOO_LARGE") {
12280
+ throw new InvalidWebhookError(
12281
+ `${InvalidWebhookErrorMessages.gzipFailed}: payload exceeds ${limit} bytes`
12282
+ );
12283
+ }
12266
12284
  throw new InvalidWebhookError(InvalidWebhookErrorMessages.gzipFailed);
12267
12285
  }
12268
12286
  }
@@ -15535,7 +15553,7 @@ var StreamChat = class _StreamChat {
15535
15553
  return this.userAgent;
15536
15554
  }
15537
15555
  if (!this.cachedUserAgent) {
15538
- const version = "9.56.0";
15556
+ const version = "9.56.1";
15539
15557
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
15540
15558
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
15541
15559
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -20397,6 +20415,7 @@ var LiveLocationManager = _LiveLocationManager;
20397
20415
  timeLeftMs,
20398
20416
  verifyAndParseWebhook,
20399
20417
  verifySignature,
20418
+ webhookConfig,
20400
20419
  withCancellation,
20401
20420
  withoutConcurrency
20402
20421
  });