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.
@@ -52,6 +52,12 @@ var require_zlib = __commonJS({
52
52
  }
53
53
  });
54
54
 
55
+ // (disabled):buffer
56
+ var require_buffer = __commonJS({
57
+ "(disabled):buffer"() {
58
+ }
59
+ });
60
+
55
61
  // src/base64.ts
56
62
  import { fromByteArray } from "base64-js";
57
63
  function isString(arrayOrString) {
@@ -9083,9 +9089,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
9083
9089
  if (!_MessageDeliveryReporter.hasPermissionToReportDeliveryFor(collection)) return;
9084
9090
  const candidate = this.getNextDeliveryReportCandidate(collection);
9085
9091
  if (!candidate?.key) return;
9086
- const buffer = this.markDeliveredRequestInFlight ? this.nextDeliveryReportCandidates : this.deliveryReportCandidates;
9087
- if (candidate.id === null) buffer.delete(candidate.key);
9088
- else buffer.set(candidate.key, candidate.id);
9092
+ const buffer2 = this.markDeliveredRequestInFlight ? this.nextDeliveryReportCandidates : this.deliveryReportCandidates;
9093
+ if (candidate.id === null) buffer2.delete(candidate.key);
9094
+ else buffer2.set(candidate.key, candidate.id);
9089
9095
  }
9090
9096
  /**
9091
9097
  * Removes candidate from the delivery report buffer
@@ -11989,6 +11995,7 @@ var StableWSConnection = class {
11989
11995
  var import_jsonwebtoken = __toESM(require_jsonwebtoken());
11990
11996
  var import_crypto = __toESM(require_crypto());
11991
11997
  var import_zlib = __toESM(require_zlib());
11998
+ var import_buffer = __toESM(require_buffer());
11992
11999
  function JWTUserToken(apiSecret, userId, extraData = {}, jwtOptions = {}) {
11993
12000
  if (typeof userId !== "string") {
11994
12001
  throw new TypeError("userId should be a string");
@@ -12064,13 +12071,29 @@ var InvalidWebhookError = class extends Error {
12064
12071
  this.name = "InvalidWebhookError";
12065
12072
  }
12066
12073
  };
12074
+ var webhookConfig = {
12075
+ maxPayloadBytes: 10 * 1024 * 1024
12076
+ };
12067
12077
  function gunzipPayload(rawBody) {
12068
12078
  const GZIP_MAGIC = Buffer.from([31, 139]);
12069
12079
  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody);
12070
12080
  if (body.length >= 2 && body.subarray(0, 2).equals(GZIP_MAGIC)) {
12081
+ const max = webhookConfig.maxPayloadBytes;
12082
+ if (!Number.isInteger(max) || max < 1) {
12083
+ const got = typeof max === "string" ? JSON.stringify(max) : String(max);
12084
+ throw new RangeError(
12085
+ `webhookConfig.maxPayloadBytes must be a positive integer, got ${got}`
12086
+ );
12087
+ }
12088
+ const limit = Math.min(max, import_buffer.default.constants.MAX_LENGTH);
12071
12089
  try {
12072
- return import_zlib.default.gunzipSync(body);
12073
- } catch {
12090
+ return import_zlib.default.gunzipSync(body, { maxOutputLength: limit });
12091
+ } catch (err) {
12092
+ if (err.code === "ERR_BUFFER_TOO_LARGE") {
12093
+ throw new InvalidWebhookError(
12094
+ `${InvalidWebhookErrorMessages.gzipFailed}: payload exceeds ${limit} bytes`
12095
+ );
12096
+ }
12074
12097
  throw new InvalidWebhookError(InvalidWebhookErrorMessages.gzipFailed);
12075
12098
  }
12076
12099
  }
@@ -15343,7 +15366,7 @@ var StreamChat = class _StreamChat {
15343
15366
  return this.userAgent;
15344
15367
  }
15345
15368
  if (!this.cachedUserAgent) {
15346
- const version = "9.56.0";
15369
+ const version = "9.56.1";
15347
15370
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
15348
15371
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
15349
15372
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -20204,6 +20227,7 @@ export {
20204
20227
  timeLeftMs,
20205
20228
  verifyAndParseWebhook,
20206
20229
  verifySignature,
20230
+ webhookConfig,
20207
20231
  withCancellation,
20208
20232
  withoutConcurrency
20209
20233
  };