@stream-io/node-sdk 0.9.2 → 0.9.4
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/CHANGELOG.md +14 -0
- package/dist/index.cjs.js +24 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.mjs +24 -6
- package/dist/index.es.mjs.map +1 -1
- package/dist/src/gen/models/index.d.ts +4 -0
- package/dist/src/utils/webhook.d.ts +15 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/src/gen/feeds/FeedsApi.ts +1 -0
- package/src/gen/models/index.ts +4 -0
- package/src/utils/webhook.ts +24 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.4](https://github.com/GetStream/stream-node/compare/v0.9.3...v0.9.4) (2026-11-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add skip_feed_creation to GetOrCreateFeedRequest ([#396](https://github.com/GetStream/stream-node/issues/396)) ([54d7fe1](https://github.com/GetStream/stream-node/commit/54d7fe162b8cdf85244ed438af48d7ef92498558))
|
|
9
|
+
|
|
10
|
+
## [0.9.3](https://github.com/GetStream/stream-node/compare/v0.9.2...v0.9.3) (2026-11-13)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* limit decompressed webhook payloads to 10 MiB, configurable with webhookConfig.maxPayloadBytes ([#394](https://github.com/GetStream/stream-node/issues/394)) ([3de82bd](https://github.com/GetStream/stream-node/commit/3de82bda9eff5a2531c3d90086bb221e01a2f3e7))
|
|
16
|
+
|
|
3
17
|
## [0.9.2](https://github.com/GetStream/stream-node/compare/v0.9.1...v0.9.2) (2026-11-13)
|
|
4
18
|
|
|
5
19
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -75,6 +75,15 @@ var InvalidWebhookError = class extends Error {
|
|
|
75
75
|
};
|
|
76
76
|
var GZIP_MAGIC = Buffer.from([31, 139]);
|
|
77
77
|
/**
|
|
78
|
+
* Webhook helper settings.
|
|
79
|
+
*
|
|
80
|
+
* `maxPayloadBytes` caps the decompressed size of a gzip webhook body
|
|
81
|
+
* (default 10 MiB). {@link gunzipPayload} runs before the signature
|
|
82
|
+
* check, so without a cap an unsigned gzip bomb could exhaust memory.
|
|
83
|
+
* Raise it if your events are larger.
|
|
84
|
+
*/
|
|
85
|
+
var webhookConfig = { maxPayloadBytes: 10485760 };
|
|
86
|
+
/**
|
|
78
87
|
* Returns `body` as a `Buffer`, gzip-decompressed when its first two
|
|
79
88
|
* bytes match the gzip magic (`1f 8b`, per RFC 1952). When the body is
|
|
80
89
|
* plain JSON (no compression, or middleware already decompressed), the
|
|
@@ -83,13 +92,21 @@ var GZIP_MAGIC = Buffer.from([31, 139]);
|
|
|
83
92
|
* Magic-byte detection (rather than relying on a header) keeps the same
|
|
84
93
|
* handler correct when middleware - Express, Next.js, AWS Lambda -
|
|
85
94
|
* auto-decompresses the request before your code sees it.
|
|
95
|
+
*
|
|
96
|
+
* @throws {InvalidWebhookError} When the body has the gzip magic but is
|
|
97
|
+
* not valid gzip, or inflates to more than
|
|
98
|
+
* `webhookConfig.maxPayloadBytes`.
|
|
86
99
|
*/
|
|
87
100
|
function gunzipPayload(rawBody) {
|
|
88
101
|
const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody);
|
|
89
|
-
if (body.length >= 2 && body.subarray(0, 2).equals(GZIP_MAGIC))
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
if (body.length >= 2 && body.subarray(0, 2).equals(GZIP_MAGIC)) {
|
|
103
|
+
const limit = webhookConfig.maxPayloadBytes;
|
|
104
|
+
try {
|
|
105
|
+
return zlib.default.gunzipSync(body, { maxOutputLength: limit });
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err.code === "ERR_BUFFER_TOO_LARGE") throw new InvalidWebhookError(`${InvalidWebhookErrorMessages.gzipFailed}: payload exceeds ${limit} bytes`);
|
|
108
|
+
throw new InvalidWebhookError(InvalidWebhookErrorMessages.gzipFailed);
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
return body;
|
|
95
112
|
}
|
|
@@ -4832,7 +4849,7 @@ var ApiClient = class {
|
|
|
4832
4849
|
const headers = {
|
|
4833
4850
|
Authorization: this.apiConfig.token,
|
|
4834
4851
|
"stream-auth-type": "jwt",
|
|
4835
|
-
"X-Stream-Client": "stream-node-0.9.
|
|
4852
|
+
"X-Stream-Client": "stream-node-0.9.4",
|
|
4836
4853
|
"Accept-Encoding": "gzip",
|
|
4837
4854
|
"x-client-request-id": clientRequestId
|
|
4838
4855
|
};
|
|
@@ -5705,6 +5722,7 @@ var FeedsApi = class {
|
|
|
5705
5722
|
next: request?.next,
|
|
5706
5723
|
overwrite_interest_weights: request?.overwrite_interest_weights,
|
|
5707
5724
|
prev: request?.prev,
|
|
5725
|
+
skip_feed_creation: request?.skip_feed_creation,
|
|
5708
5726
|
user_id: request?.user_id,
|
|
5709
5727
|
view: request?.view,
|
|
5710
5728
|
watch: request?.watch,
|
|
@@ -6953,5 +6971,6 @@ exports.nsToDate = nsToDate;
|
|
|
6953
6971
|
exports.nsToMs = nsToMs;
|
|
6954
6972
|
exports.nsToRfc3339 = nsToRfc3339;
|
|
6955
6973
|
exports.verifyAndParseWebhook = verifyAndParseWebhook;
|
|
6974
|
+
exports.webhookConfig = webhookConfig;
|
|
6956
6975
|
|
|
6957
6976
|
//# sourceMappingURL=index.cjs.js.map
|