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.
- package/dist/cjs/index.browser.js +30 -6
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +25 -6
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +30 -6
- package/dist/esm/index.mjs.map +3 -3
- package/dist/types/signing.d.ts +20 -2
- package/package.json +2 -1
- package/src/signing.ts +37 -4
|
@@ -58,6 +58,12 @@ var require_zlib = __commonJS({
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
// (disabled):buffer
|
|
62
|
+
var require_buffer = __commonJS({
|
|
63
|
+
"(disabled):buffer"() {
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
61
67
|
// src/index.ts
|
|
62
68
|
var index_exports = {};
|
|
63
69
|
__export(index_exports, {
|
|
@@ -270,6 +276,7 @@ __export(index_exports, {
|
|
|
270
276
|
timeLeftMs: () => timeLeftMs,
|
|
271
277
|
verifyAndParseWebhook: () => verifyAndParseWebhook,
|
|
272
278
|
verifySignature: () => verifySignature,
|
|
279
|
+
webhookConfig: () => webhookConfig,
|
|
273
280
|
withCancellation: () => withCancellation,
|
|
274
281
|
withoutConcurrency: () => withoutConcurrency
|
|
275
282
|
});
|
|
@@ -9306,9 +9313,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
9306
9313
|
if (!_MessageDeliveryReporter.hasPermissionToReportDeliveryFor(collection)) return;
|
|
9307
9314
|
const candidate = this.getNextDeliveryReportCandidate(collection);
|
|
9308
9315
|
if (!candidate?.key) return;
|
|
9309
|
-
const
|
|
9310
|
-
if (candidate.id === null)
|
|
9311
|
-
else
|
|
9316
|
+
const buffer2 = this.markDeliveredRequestInFlight ? this.nextDeliveryReportCandidates : this.deliveryReportCandidates;
|
|
9317
|
+
if (candidate.id === null) buffer2.delete(candidate.key);
|
|
9318
|
+
else buffer2.set(candidate.key, candidate.id);
|
|
9312
9319
|
}
|
|
9313
9320
|
/**
|
|
9314
9321
|
* Removes candidate from the delivery report buffer
|
|
@@ -12212,6 +12219,7 @@ var StableWSConnection = class {
|
|
|
12212
12219
|
var import_jsonwebtoken = __toESM(require_jsonwebtoken());
|
|
12213
12220
|
var import_crypto = __toESM(require_crypto());
|
|
12214
12221
|
var import_zlib = __toESM(require_zlib());
|
|
12222
|
+
var import_buffer = __toESM(require_buffer());
|
|
12215
12223
|
function JWTUserToken(apiSecret, userId, extraData = {}, jwtOptions = {}) {
|
|
12216
12224
|
if (typeof userId !== "string") {
|
|
12217
12225
|
throw new TypeError("userId should be a string");
|
|
@@ -12287,13 +12295,29 @@ var InvalidWebhookError = class extends Error {
|
|
|
12287
12295
|
this.name = "InvalidWebhookError";
|
|
12288
12296
|
}
|
|
12289
12297
|
};
|
|
12298
|
+
var webhookConfig = {
|
|
12299
|
+
maxPayloadBytes: 10 * 1024 * 1024
|
|
12300
|
+
};
|
|
12290
12301
|
function gunzipPayload(rawBody) {
|
|
12291
12302
|
const GZIP_MAGIC = Buffer.from([31, 139]);
|
|
12292
12303
|
const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody);
|
|
12293
12304
|
if (body.length >= 2 && body.subarray(0, 2).equals(GZIP_MAGIC)) {
|
|
12305
|
+
const max = webhookConfig.maxPayloadBytes;
|
|
12306
|
+
if (!Number.isInteger(max) || max < 1) {
|
|
12307
|
+
const got = typeof max === "string" ? JSON.stringify(max) : String(max);
|
|
12308
|
+
throw new RangeError(
|
|
12309
|
+
`webhookConfig.maxPayloadBytes must be a positive integer, got ${got}`
|
|
12310
|
+
);
|
|
12311
|
+
}
|
|
12312
|
+
const limit = Math.min(max, import_buffer.default.constants.MAX_LENGTH);
|
|
12294
12313
|
try {
|
|
12295
|
-
return import_zlib.default.gunzipSync(body);
|
|
12296
|
-
} catch {
|
|
12314
|
+
return import_zlib.default.gunzipSync(body, { maxOutputLength: limit });
|
|
12315
|
+
} catch (err) {
|
|
12316
|
+
if (err.code === "ERR_BUFFER_TOO_LARGE") {
|
|
12317
|
+
throw new InvalidWebhookError(
|
|
12318
|
+
`${InvalidWebhookErrorMessages.gzipFailed}: payload exceeds ${limit} bytes`
|
|
12319
|
+
);
|
|
12320
|
+
}
|
|
12297
12321
|
throw new InvalidWebhookError(InvalidWebhookErrorMessages.gzipFailed);
|
|
12298
12322
|
}
|
|
12299
12323
|
}
|
|
@@ -15566,7 +15590,7 @@ var StreamChat = class _StreamChat {
|
|
|
15566
15590
|
return this.userAgent;
|
|
15567
15591
|
}
|
|
15568
15592
|
if (!this.cachedUserAgent) {
|
|
15569
|
-
const version = "9.56.
|
|
15593
|
+
const version = "9.56.1";
|
|
15570
15594
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
15571
15595
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
15572
15596
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|