@stream-io/node-sdk 0.7.55 → 0.7.57

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.
@@ -103,4 +103,36 @@ export declare class StreamClient extends CommonApi {
103
103
  role?: string;
104
104
  }, call_cids: string[], exp?: number, iat?: number) => string;
105
105
  verifyWebhook: (requestBody: string | Buffer, xSignature: string) => boolean;
106
+ /**
107
+ * Verify and parse an HTTP webhook event.
108
+ *
109
+ * Decompresses `rawBody` when gzipped (detected from the body bytes),
110
+ * verifies the `X-Signature` header against the app's API secret, and
111
+ * returns the parsed typed event. Works whether or not Stream is
112
+ * currently compressing payloads for this app, and stays correct behind
113
+ * middleware that auto-decompresses the request.
114
+ *
115
+ * @param rawBody Raw HTTP request body bytes Stream signed
116
+ * @param signature Value of the `X-Signature` header
117
+ * @throws {InvalidWebhookError} When the signature does not match or
118
+ * the gzip / JSON envelope is malformed.
119
+ */
120
+ verifyAndParseWebhook: (rawBody: string | Buffer, signature: string) => import("./gen/models").WHEvent;
121
+ /**
122
+ * Parse an SQS firehose event: decodes the message `Body` (base64 +
123
+ * optional gzip) and returns the parsed typed event. No HMAC
124
+ * verification (Stream does not sign SQS bodies).
125
+ *
126
+ * @param messageBody SQS message `Body` string
127
+ * @throws {InvalidWebhookError} When the base64 / gzip envelope is malformed.
128
+ */
129
+ parseSqs: (messageBody: string) => import("./gen/models").WHEvent;
130
+ /**
131
+ * Parse an SNS-delivered event (unwraps envelope JSON when needed, then
132
+ * same decode path as SQS). No HMAC verification.
133
+ *
134
+ * @param notificationBody Raw SNS POST body or pre-extracted `Message` string
135
+ * @throws {InvalidWebhookError} When the envelope cannot be decoded.
136
+ */
137
+ parseSns: (notificationBody: string) => import("./gen/models").WHEvent;
106
138
  }
@@ -7,6 +7,7 @@ export declare class FeedApi {
7
7
  constructor(feedsApi: FeedsApi, group: string, id: string);
8
8
  delete(request?: {
9
9
  hard_delete?: boolean;
10
+ purge_user_activities?: boolean;
10
11
  }): Promise<StreamResponse<DeleteFeedResponse>>;
11
12
  getOrCreate(request?: GetOrCreateFeedRequest): Promise<StreamResponse<GetOrCreateFeedResponse>>;
12
13
  update(request?: UpdateFeedRequest): Promise<StreamResponse<UpdateFeedResponse>>;
@@ -1,5 +1,5 @@
1
1
  import { ApiClient, StreamResponse } from '../../gen-imports';
2
- import { AcceptFeedMemberInviteRequest, AcceptFeedMemberInviteResponse, AcceptFollowRequest, AcceptFollowResponse, ActivityFeedbackRequest, ActivityFeedbackResponse, AddActivityRequest, AddActivityResponse, AddBookmarkRequest, AddBookmarkResponse, AddCommentBookmarkRequest, AddCommentBookmarkResponse, AddCommentReactionRequest, AddCommentReactionResponse, AddCommentRequest, AddCommentResponse, AddCommentsBatchRequest, AddCommentsBatchResponse, AddReactionRequest, AddReactionResponse, CastPollVoteRequest, CreateCollectionsRequest, CreateCollectionsResponse, CreateFeedGroupRequest, CreateFeedGroupResponse, CreateFeedViewRequest, CreateFeedViewResponse, CreateFeedsBatchRequest, CreateFeedsBatchResponse, CreateMembershipLevelRequest, CreateMembershipLevelResponse, DeleteActivitiesRequest, DeleteActivitiesResponse, DeleteActivityReactionResponse, DeleteActivityResponse, DeleteBookmarkFolderResponse, DeleteBookmarkResponse, DeleteCollectionsResponse, DeleteCommentBookmarkResponse, DeleteCommentReactionResponse, DeleteCommentResponse, DeleteFeedGroupResponse, DeleteFeedResponse, DeleteFeedUserDataRequest, DeleteFeedUserDataResponse, DeleteFeedViewResponse, DeleteFeedsBatchRequest, DeleteFeedsBatchResponse, ExportFeedUserDataResponse, FollowBatchRequest, FollowBatchResponse, FollowRequest, GetActivityResponse, GetCommentRepliesResponse, GetCommentResponse, GetCommentsResponse, GetFeedGroupResponse, GetFeedViewResponse, GetFeedVisibilityResponse, GetFeedsRateLimitsResponse, GetFollowSuggestionsResponse, GetOrCreateFeedGroupRequest, GetOrCreateFeedGroupResponse, GetOrCreateFeedRequest, GetOrCreateFeedResponse, GetOrCreateFeedViewRequest, GetOrCreateFeedViewResponse, ListFeedGroupsResponse, ListFeedViewsResponse, ListFeedVisibilitiesResponse, MarkActivityRequest, OwnBatchRequest, OwnBatchResponse, PinActivityRequest, PinActivityResponse, PollVoteResponse, QueryActivitiesRequest, QueryActivitiesResponse, QueryActivityReactionsRequest, QueryActivityReactionsResponse, QueryBookmarkFoldersRequest, QueryBookmarkFoldersResponse, QueryBookmarksRequest, QueryBookmarksResponse, QueryCollectionsRequest, QueryCollectionsResponse, QueryCommentReactionsRequest, QueryCommentReactionsResponse, QueryCommentsRequest, QueryCommentsResponse, QueryFeedMembersRequest, QueryFeedMembersResponse, QueryFeedsRequest, QueryFeedsResponse, QueryFeedsUsageStatsRequest, QueryFeedsUsageStatsResponse, QueryFollowsRequest, QueryFollowsResponse, QueryMembershipLevelsRequest, QueryMembershipLevelsResponse, QueryPinnedActivitiesRequest, QueryPinnedActivitiesResponse, ReadCollectionsResponse, RejectFeedMemberInviteRequest, RejectFeedMemberInviteResponse, RejectFollowRequest, RejectFollowResponse, Response, RestoreActivityRequest, RestoreActivityResponse, RestoreCommentRequest, RestoreCommentResponse, RestoreFeedGroupResponse, SingleFollowResponse, TrackActivityMetricsRequest, TrackActivityMetricsResponse, UnfollowBatchRequest, UnfollowBatchResponse, UnfollowResponse, UnpinActivityResponse, UpdateActivitiesPartialBatchRequest, UpdateActivitiesPartialBatchResponse, UpdateActivityPartialRequest, UpdateActivityPartialResponse, UpdateActivityRequest, UpdateActivityResponse, UpdateBookmarkFolderRequest, UpdateBookmarkFolderResponse, UpdateBookmarkRequest, UpdateBookmarkResponse, UpdateCollectionsRequest, UpdateCollectionsResponse, UpdateCommentBookmarkRequest, UpdateCommentBookmarkResponse, UpdateCommentPartialRequest, UpdateCommentPartialResponse, UpdateCommentRequest, UpdateCommentResponse, UpdateFeedGroupRequest, UpdateFeedGroupResponse, UpdateFeedMembersRequest, UpdateFeedMembersResponse, UpdateFeedRequest, UpdateFeedResponse, UpdateFeedViewRequest, UpdateFeedViewResponse, UpdateFeedVisibilityRequest, UpdateFeedVisibilityResponse, UpdateFollowRequest, UpdateFollowResponse, UpdateMembershipLevelRequest, UpdateMembershipLevelResponse, UpsertActivitiesRequest, UpsertActivitiesResponse, UpsertCollectionsRequest, UpsertCollectionsResponse } from '../models';
2
+ import { AcceptFeedMemberInviteRequest, AcceptFeedMemberInviteResponse, AcceptFollowRequest, AcceptFollowResponse, ActivityFeedbackRequest, ActivityFeedbackResponse, AddActivityRequest, AddActivityResponse, AddBookmarkRequest, AddBookmarkResponse, AddCommentBookmarkRequest, AddCommentBookmarkResponse, AddCommentReactionRequest, AddCommentReactionResponse, AddCommentRequest, AddCommentResponse, AddCommentsBatchRequest, AddCommentsBatchResponse, AddReactionRequest, AddReactionResponse, CastPollVoteRequest, CreateCollectionsRequest, CreateCollectionsResponse, CreateFeedGroupRequest, CreateFeedGroupResponse, CreateFeedViewRequest, CreateFeedViewResponse, CreateFeedsBatchRequest, CreateFeedsBatchResponse, CreateMembershipLevelRequest, CreateMembershipLevelResponse, DeleteActivitiesRequest, DeleteActivitiesResponse, DeleteActivityReactionResponse, DeleteActivityResponse, DeleteBookmarkFolderResponse, DeleteBookmarkResponse, DeleteCollectionsResponse, DeleteCommentBookmarkResponse, DeleteCommentReactionResponse, DeleteCommentResponse, DeleteFeedGroupResponse, DeleteFeedResponse, DeleteFeedUserDataRequest, DeleteFeedUserDataResponse, DeleteFeedViewResponse, DeleteFeedsBatchRequest, DeleteFeedsBatchResponse, ExportFeedUserDataResponse, FollowBatchRequest, FollowBatchResponse, FollowRequest, GetActivityResponse, GetCommentRepliesResponse, GetCommentResponse, GetCommentsResponse, GetFeedGroupResponse, GetFeedViewResponse, GetFeedVisibilityResponse, GetFeedsRateLimitsResponse, GetFollowSuggestionsResponse, GetOrCreateFeedGroupRequest, GetOrCreateFeedGroupResponse, GetOrCreateFeedRequest, GetOrCreateFeedResponse, GetOrCreateFeedViewRequest, GetOrCreateFeedViewResponse, ListFeedGroupsResponse, ListFeedViewsResponse, ListFeedVisibilitiesResponse, MarkActivityRequest, OwnBatchRequest, OwnBatchResponse, PinActivityRequest, PinActivityResponse, PollVoteResponse, QueryActivitiesRequest, QueryActivitiesResponse, QueryActivityReactionsRequest, QueryActivityReactionsResponse, QueryBookmarkFoldersRequest, QueryBookmarkFoldersResponse, QueryBookmarksRequest, QueryBookmarksResponse, QueryCollectionsRequest, QueryCollectionsResponse, QueryCommentReactionsRequest, QueryCommentReactionsResponse, QueryCommentsRequest, QueryCommentsResponse, QueryFeedMembersRequest, QueryFeedMembersResponse, QueryFeedsRequest, QueryFeedsResponse, QueryFeedsUsageStatsRequest, QueryFeedsUsageStatsResponse, QueryFollowsRequest, QueryFollowsResponse, QueryMembershipLevelsRequest, QueryMembershipLevelsResponse, QueryPinnedActivitiesRequest, QueryPinnedActivitiesResponse, QueryRevisionHistoryRequest, QueryRevisionHistoryResponse, ReadCollectionsResponse, RejectFeedMemberInviteRequest, RejectFeedMemberInviteResponse, RejectFollowRequest, RejectFollowResponse, Response, RestoreActivityRequest, RestoreActivityResponse, RestoreCommentRequest, RestoreCommentResponse, RestoreFeedGroupResponse, SingleFollowResponse, TrackActivityMetricsRequest, TrackActivityMetricsResponse, UnfollowBatchRequest, UnfollowBatchResponse, UnfollowResponse, UnpinActivityResponse, UpdateActivitiesPartialBatchRequest, UpdateActivitiesPartialBatchResponse, UpdateActivityPartialRequest, UpdateActivityPartialResponse, UpdateActivityRequest, UpdateActivityResponse, UpdateBookmarkFolderRequest, UpdateBookmarkFolderResponse, UpdateBookmarkRequest, UpdateBookmarkResponse, UpdateCollectionsRequest, UpdateCollectionsResponse, UpdateCommentBookmarkRequest, UpdateCommentBookmarkResponse, UpdateCommentPartialRequest, UpdateCommentPartialResponse, UpdateCommentRequest, UpdateCommentResponse, UpdateFeedGroupRequest, UpdateFeedGroupResponse, UpdateFeedMembersRequest, UpdateFeedMembersResponse, UpdateFeedRequest, UpdateFeedResponse, UpdateFeedViewRequest, UpdateFeedViewResponse, UpdateFeedVisibilityRequest, UpdateFeedVisibilityResponse, UpdateFollowRequest, UpdateFollowResponse, UpdateMembershipLevelRequest, UpdateMembershipLevelResponse, UpsertActivitiesRequest, UpsertActivitiesResponse, UpsertCollectionsRequest, UpsertCollectionsResponse } from '../models';
3
3
  export declare class FeedsApi {
4
4
  readonly apiClient: ApiClient;
5
5
  constructor(apiClient: ApiClient);
@@ -160,6 +160,7 @@ export declare class FeedsApi {
160
160
  feed_group_id: string;
161
161
  feed_id: string;
162
162
  hard_delete?: boolean;
163
+ purge_user_activities?: boolean;
163
164
  }): Promise<StreamResponse<DeleteFeedResponse>>;
164
165
  getOrCreateFeed(request: GetOrCreateFeedRequest & {
165
166
  feed_group_id: string;
@@ -281,6 +282,7 @@ export declare class FeedsApi {
281
282
  updateMembershipLevel(request: UpdateMembershipLevelRequest & {
282
283
  id: string;
283
284
  }): Promise<StreamResponse<UpdateMembershipLevelResponse>>;
285
+ queryRevisionHistory(request: QueryRevisionHistoryRequest): Promise<StreamResponse<QueryRevisionHistoryResponse>>;
284
286
  queryFeedsUsageStats(request?: QueryFeedsUsageStatsRequest): Promise<StreamResponse<QueryFeedsUsageStatsResponse>>;
285
287
  unfollowBatch(request: UnfollowBatchRequest): Promise<StreamResponse<UnfollowBatchResponse>>;
286
288
  getOrCreateUnfollows(request: UnfollowBatchRequest): Promise<StreamResponse<UnfollowBatchResponse>>;
@@ -734,7 +734,7 @@ export interface ActivitySelectorConfig {
734
734
  */
735
735
  cutoff_window?: string;
736
736
  /**
737
- * Minimum popularity threshold
737
+ * Minimum popularity threshold. For the 'popular' selector, omit to use the default (5); values below 1 are rejected
738
738
  */
739
739
  min_popularity?: number;
740
740
  /**
@@ -761,7 +761,7 @@ export interface ActivitySelectorConfigResponse {
761
761
  */
762
762
  cutoff_window?: string;
763
763
  /**
764
- * Minimum popularity threshold
764
+ * Minimum popularity threshold. For the 'popular' selector, values below 1 are normalized to the default (5) at read time.
765
765
  */
766
766
  min_popularity?: number;
767
767
  /**
@@ -1192,6 +1192,7 @@ export interface AppResponseFields {
1192
1192
  disable_auth_checks: boolean;
1193
1193
  disable_permissions_checks: boolean;
1194
1194
  enforce_unique_usernames: string;
1195
+ feed_audit_logs_enabled: boolean;
1195
1196
  guest_user_creation_disabled: boolean;
1196
1197
  id: number;
1197
1198
  image_moderation_enabled: boolean;
@@ -4882,7 +4883,6 @@ export interface CreateFeedViewRequest {
4882
4883
  * Configuration for selecting activities
4883
4884
  */
4884
4885
  activity_selectors?: ActivitySelectorConfig[];
4885
- activity_filter?: ActivityFilterConfig;
4886
4886
  aggregation?: AggregationConfig;
4887
4887
  ranking?: RankingConfig;
4888
4888
  }
@@ -5493,6 +5493,10 @@ export interface DeleteFeedsBatchRequest {
5493
5493
  * Whether to permanently delete the feeds instead of soft delete
5494
5494
  */
5495
5495
  hard_delete?: boolean;
5496
+ /**
5497
+ * When hard-deleting, also fully delete activities authored by each feed's owner from every other feed those activities were fanned out to. Default false preserves existing fan-out. Requires 'hard_delete' to be true; the request is rejected otherwise. Feeds with no recorded owner (created_by_id is empty) are silently skipped for the purge step — owner-matching against an empty string is a safety guard, not a wildcard.
5498
+ */
5499
+ purge_user_activities?: boolean;
5496
5500
  }
5497
5501
  export interface DeleteFeedsBatchResponse {
5498
5502
  duration: string;
@@ -5927,6 +5931,10 @@ export interface EnrichmentOptions {
5927
5931
  * Default: false. When true, includes fetching and enriching own_followings (follows where activity author's feeds follow current user's feeds).
5928
5932
  */
5929
5933
  enrich_own_followings?: boolean;
5934
+ /**
5935
+ * Controls the top-level flat 'activities' array for aggregated feeds. For new apps, defaults to false (excluded); set to true to include. For older apps, defaults to true (included) for backward compatibility; set to false to exclude.
5936
+ */
5937
+ include_flat_activities?: boolean;
5930
5938
  /**
5931
5939
  * Default: false. When true, includes score_vars in activity responses containing variable values used at ranking time.
5932
5940
  */
@@ -6723,7 +6731,6 @@ export interface FeedViewResponse {
6723
6731
  * Configured activity selectors
6724
6732
  */
6725
6733
  activity_selectors?: ActivitySelectorConfigResponse[];
6726
- activity_filter?: ActivityFilterConfig;
6727
6734
  aggregation?: AggregationConfig;
6728
6735
  ranking?: RankingConfig;
6729
6736
  }
@@ -7742,7 +7749,6 @@ export interface GetOrCreateFeedViewRequest {
7742
7749
  * Configuration for selecting activities
7743
7750
  */
7744
7751
  activity_selectors?: ActivitySelectorConfig[];
7745
- activity_filter?: ActivityFilterConfig;
7746
7752
  aggregation?: AggregationConfig;
7747
7753
  ranking?: RankingConfig;
7748
7754
  }
@@ -12018,6 +12024,31 @@ export interface QueryReviewQueueResponse {
12018
12024
  prev?: string;
12019
12025
  filter_config?: FilterConfigResponse;
12020
12026
  }
12027
+ export interface QueryRevisionHistoryRequest {
12028
+ /**
12029
+ * Filter to apply to the query
12030
+ */
12031
+ filter: Record<string, any>;
12032
+ limit?: number;
12033
+ next?: string;
12034
+ prev?: string;
12035
+ /**
12036
+ * Array of sort parameters
12037
+ */
12038
+ sort?: SortParamRequest[];
12039
+ }
12040
+ export interface QueryRevisionHistoryResponse {
12041
+ /**
12042
+ * Duration of the request in milliseconds
12043
+ */
12044
+ duration: string;
12045
+ /**
12046
+ * Revision history entries
12047
+ */
12048
+ revisions: RevisionHistoryResponse[];
12049
+ next?: string;
12050
+ prev?: string;
12051
+ }
12021
12052
  export interface QuerySegmentTargetsRequest {
12022
12053
  /**
12023
12054
  * Limit
@@ -13044,6 +13075,16 @@ export interface ReviewQueueItemUpdatedEvent {
13044
13075
  action?: ActionLogResponse;
13045
13076
  review_queue_item?: ReviewQueueItemResponse;
13046
13077
  }
13078
+ export interface RevisionHistoryResponse {
13079
+ action_type: string;
13080
+ actor_type: string;
13081
+ created_at: Date;
13082
+ object_id: string;
13083
+ object_type: string;
13084
+ user_id: string;
13085
+ changed_fields?: string[];
13086
+ previous_obj_serialized?: Record<string, any>;
13087
+ }
13047
13088
  export interface RingCallRequest {
13048
13089
  /**
13049
13090
  * Indicate if call should be video
@@ -15529,7 +15570,6 @@ export interface UpdateFeedViewRequest {
15529
15570
  * Updated configuration for selecting activities
15530
15571
  */
15531
15572
  activity_selectors?: ActivitySelectorConfig[];
15532
- activity_filter?: ActivityFilterConfig;
15533
15573
  aggregation?: AggregationConfig;
15534
15574
  ranking?: RankingConfig;
15535
15575
  }
@@ -0,0 +1,98 @@
1
+ import type { WHEvent } from '../gen/models';
2
+ /**
3
+ * Canonical failure-mode messages for {@link InvalidWebhookError}.
4
+ *
5
+ * Callers that prefer exact-match filtering (security logging, retry
6
+ * policy) over substring matches can compare `err.message` to these
7
+ * constants instead of pattern-matching free-form text.
8
+ */
9
+ export declare const InvalidWebhookErrorMessages: {
10
+ readonly signatureMismatch: "signature mismatch";
11
+ readonly invalidBase64: "invalid base64 encoding";
12
+ readonly gzipFailed: "gzip decompression failed";
13
+ readonly invalidJson: "invalid JSON payload";
14
+ };
15
+ /**
16
+ * Thrown by {@link verifyAndParseWebhook} when the supplied `x-signature`
17
+ * does not match the HMAC of the uncompressed payload, and by all webhook
18
+ * helpers (including {@link parseSqs} / {@link parseSns}) when a
19
+ * gzip / base64 / JSON envelope is malformed.
20
+ *
21
+ * The message identifies which failure mode fired. See
22
+ * {@link InvalidWebhookErrorMessages} for the canonical strings.
23
+ */
24
+ export declare class InvalidWebhookError extends Error {
25
+ name: string;
26
+ constructor(message?: string);
27
+ }
28
+ /**
29
+ * Returns `body` as a `Buffer`, gzip-decompressed when its first two
30
+ * bytes match the gzip magic (`1f 8b`, per RFC 1952). When the body is
31
+ * plain JSON (no compression, or middleware already decompressed), the
32
+ * bytes are returned unchanged.
33
+ *
34
+ * Magic-byte detection (rather than relying on a header) keeps the same
35
+ * handler correct when middleware - Express, Next.js, AWS Lambda -
36
+ * auto-decompresses the request before your code sees it.
37
+ */
38
+ export declare function gunzipPayload(rawBody: string | Buffer): Buffer;
39
+ /**
40
+ * Reverses the SQS firehose envelope: the message `Body` is
41
+ * base64-decoded, then the result is gzip-decompressed when it begins
42
+ * with the gzip magic. Returns the raw JSON `Buffer` Stream signed.
43
+ *
44
+ * SQS bodies are always base64-encoded so they remain valid UTF-8 over
45
+ * the queue. The same call works whether or not Stream is currently
46
+ * compressing payloads for this app.
47
+ */
48
+ export declare function decodeSqsPayload(body: string): Buffer;
49
+ /**
50
+ * Reverses an SNS HTTP notification envelope. When `notificationBody`
51
+ * is a JSON envelope (`{"Type":"Notification","Message":"..."}`), the
52
+ * inner `Message` field is extracted and run through the SQS pipeline
53
+ * (base64-decode, then gzip-if-magic). When the input is not a JSON
54
+ * envelope it is treated as the already-extracted `Message` string,
55
+ * so call sites that pre-unwrap continue to work.
56
+ */
57
+ export declare function decodeSnsPayload(notificationBody: string): Buffer;
58
+ /**
59
+ * Constant-time HMAC-SHA256 verification of `signature` against the
60
+ * digest of `body` using `secret` as the key. The signature is always
61
+ * computed over the **uncompressed** JSON bytes, so callers that
62
+ * decoded a gzipped or base64-wrapped payload must pass the inflated
63
+ * bytes here.
64
+ *
65
+ * The legacy `client.verifyWebhook` helper wraps this function, so
66
+ * callers that have already migrated to `verifyAndParseWebhook`,
67
+ * `parseSqs`, or `parseSns` rarely need to invoke this directly.
68
+ */
69
+ export declare function verifySignature(body: string | Buffer, signature: string, secret: string): boolean;
70
+ /**
71
+ * Parse a JSON-encoded webhook event into a typed {@link WHEvent}. New
72
+ * event types Stream introduces still parse successfully — the runtime
73
+ * shape is the JSON Stream sent and the `type` field stays preserved.
74
+ */
75
+ export declare function parseEvent(payload: Buffer | string): WHEvent;
76
+ /**
77
+ * Decompress (when gzipped), verify the HMAC `signature`, and return
78
+ * the parsed {@link WHEvent}.
79
+ *
80
+ * @param rawBody Raw HTTP request body bytes Stream signed
81
+ * @param signature Value of the `X-Signature` header
82
+ * @param secret Your app's API secret
83
+ * @throws {InvalidWebhookError} When the signature does not match or
84
+ * the gzip / base64 / JSON envelope is malformed.
85
+ */
86
+ export declare function verifyAndParseWebhook(rawBody: string | Buffer, signature: string, secret: string): WHEvent;
87
+ /**
88
+ * Decode the SQS message `Body` (base64, then gzip-if-magic) and return
89
+ * the parsed {@link WHEvent}. Stream does not attach an application-level
90
+ * HMAC to SQS deliveries — use {@link verifyAndParseWebhook} for HTTP
91
+ * webhooks.
92
+ */
93
+ export declare function parseSqs(messageBody: string): WHEvent;
94
+ /**
95
+ * Decode an SNS notification (unwrap the JSON envelope when needed; same
96
+ * inner format as SQS). No application-level HMAC verification.
97
+ */
98
+ export declare function parseSns(notificationBody: string): WHEvent;
package/index.ts CHANGED
@@ -6,3 +6,7 @@ export * from './src/StreamVideoClient';
6
6
  export * from './src/gen/models';
7
7
  export * from './src/StreamFeedsClient';
8
8
  export * from './src/StreamFeed';
9
+ export {
10
+ InvalidWebhookError,
11
+ InvalidWebhookErrorMessages,
12
+ } from './src/utils/webhook';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/node-sdk",
3
- "version": "0.7.55",
3
+ "version": "0.7.57",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -1,4 +1,10 @@
1
1
  import { JWTServerToken, JWTUserToken } from './utils/create-token';
2
+ import {
3
+ InvalidWebhookError,
4
+ parseSns as parseSnsHelper,
5
+ parseSqs as parseSqsHelper,
6
+ verifyAndParseWebhook as verifyAndParseWebhookHelper,
7
+ } from './utils/webhook';
2
8
  import { CommonApi } from './gen/common/CommonApi';
3
9
  import { StreamVideoClient } from './StreamVideoClient';
4
10
  import crypto from 'crypto';
@@ -253,4 +259,46 @@ export class StreamClient extends CommonApi {
253
259
  return false;
254
260
  }
255
261
  };
262
+
263
+ /**
264
+ * Verify and parse an HTTP webhook event.
265
+ *
266
+ * Decompresses `rawBody` when gzipped (detected from the body bytes),
267
+ * verifies the `X-Signature` header against the app's API secret, and
268
+ * returns the parsed typed event. Works whether or not Stream is
269
+ * currently compressing payloads for this app, and stays correct behind
270
+ * middleware that auto-decompresses the request.
271
+ *
272
+ * @param rawBody Raw HTTP request body bytes Stream signed
273
+ * @param signature Value of the `X-Signature` header
274
+ * @throws {InvalidWebhookError} When the signature does not match or
275
+ * the gzip / JSON envelope is malformed.
276
+ */
277
+ verifyAndParseWebhook = (rawBody: string | Buffer, signature: string) => {
278
+ if (!this.secret) {
279
+ throw new InvalidWebhookError(
280
+ 'cannot verify webhook signature without an API secret on the client',
281
+ );
282
+ }
283
+ return verifyAndParseWebhookHelper(rawBody, signature, this.secret);
284
+ };
285
+
286
+ /**
287
+ * Parse an SQS firehose event: decodes the message `Body` (base64 +
288
+ * optional gzip) and returns the parsed typed event. No HMAC
289
+ * verification (Stream does not sign SQS bodies).
290
+ *
291
+ * @param messageBody SQS message `Body` string
292
+ * @throws {InvalidWebhookError} When the base64 / gzip envelope is malformed.
293
+ */
294
+ parseSqs = (messageBody: string) => parseSqsHelper(messageBody);
295
+
296
+ /**
297
+ * Parse an SNS-delivered event (unwraps envelope JSON when needed, then
298
+ * same decode path as SQS). No HMAC verification.
299
+ *
300
+ * @param notificationBody Raw SNS POST body or pre-extracted `Message` string
301
+ * @throws {InvalidWebhookError} When the envelope cannot be decoded.
302
+ */
303
+ parseSns = (notificationBody: string) => parseSnsHelper(notificationBody);
256
304
  }
@@ -31,6 +31,7 @@ export class FeedApi {
31
31
 
32
32
  delete(request?: {
33
33
  hard_delete?: boolean;
34
+ purge_user_activities?: boolean;
34
35
  }): Promise<StreamResponse<DeleteFeedResponse>> {
35
36
  return this.feedsApi.deleteFeed({
36
37
  feed_id: this.id,
@@ -102,6 +102,8 @@ import {
102
102
  QueryMembershipLevelsResponse,
103
103
  QueryPinnedActivitiesRequest,
104
104
  QueryPinnedActivitiesResponse,
105
+ QueryRevisionHistoryRequest,
106
+ QueryRevisionHistoryResponse,
105
107
  ReadCollectionsResponse,
106
108
  RejectFeedMemberInviteRequest,
107
109
  RejectFeedMemberInviteResponse,
@@ -1543,9 +1545,11 @@ export class FeedsApi {
1543
1545
  feed_group_id: string;
1544
1546
  feed_id: string;
1545
1547
  hard_delete?: boolean;
1548
+ purge_user_activities?: boolean;
1546
1549
  }): Promise<StreamResponse<DeleteFeedResponse>> {
1547
1550
  const queryParams = {
1548
1551
  hard_delete: request?.hard_delete,
1552
+ purge_user_activities: request?.purge_user_activities,
1549
1553
  };
1550
1554
  const pathParams = {
1551
1555
  feed_group_id: request?.feed_group_id,
@@ -2081,7 +2085,6 @@ export class FeedsApi {
2081
2085
  const body = {
2082
2086
  id: request?.id,
2083
2087
  activity_selectors: request?.activity_selectors,
2084
- activity_filter: request?.activity_filter,
2085
2088
  aggregation: request?.aggregation,
2086
2089
  ranking: request?.ranking,
2087
2090
  };
@@ -2142,7 +2145,6 @@ export class FeedsApi {
2142
2145
  };
2143
2146
  const body = {
2144
2147
  activity_selectors: request?.activity_selectors,
2145
- activity_filter: request?.activity_filter,
2146
2148
  aggregation: request?.aggregation,
2147
2149
  ranking: request?.ranking,
2148
2150
  };
@@ -2171,7 +2173,6 @@ export class FeedsApi {
2171
2173
  };
2172
2174
  const body = {
2173
2175
  activity_selectors: request?.activity_selectors,
2174
- activity_filter: request?.activity_filter,
2175
2176
  aggregation: request?.aggregation,
2176
2177
  ranking: request?.ranking,
2177
2178
  };
@@ -2276,6 +2277,7 @@ export class FeedsApi {
2276
2277
  const body = {
2277
2278
  feeds: request?.feeds,
2278
2279
  hard_delete: request?.hard_delete,
2280
+ purge_user_activities: request?.purge_user_activities,
2279
2281
  };
2280
2282
 
2281
2283
  const response = await this.apiClient.sendRequest<
@@ -2701,6 +2703,33 @@ export class FeedsApi {
2701
2703
  return { ...response.body, metadata: response.metadata };
2702
2704
  }
2703
2705
 
2706
+ async queryRevisionHistory(
2707
+ request: QueryRevisionHistoryRequest,
2708
+ ): Promise<StreamResponse<QueryRevisionHistoryResponse>> {
2709
+ const body = {
2710
+ filter: request?.filter,
2711
+ limit: request?.limit,
2712
+ next: request?.next,
2713
+ prev: request?.prev,
2714
+ sort: request?.sort,
2715
+ };
2716
+
2717
+ const response = await this.apiClient.sendRequest<
2718
+ StreamResponse<QueryRevisionHistoryResponse>
2719
+ >(
2720
+ 'POST',
2721
+ '/api/v2/feeds/revisions/query',
2722
+ undefined,
2723
+ undefined,
2724
+ body,
2725
+ 'application/json',
2726
+ );
2727
+
2728
+ decoders.QueryRevisionHistoryResponse?.(response.body);
2729
+
2730
+ return { ...response.body, metadata: response.metadata };
2731
+ }
2732
+
2704
2733
  async queryFeedsUsageStats(
2705
2734
  request?: QueryFeedsUsageStatsRequest,
2706
2735
  ): Promise<StreamResponse<QueryFeedsUsageStatsResponse>> {
@@ -4053,6 +4053,13 @@ decoders.QueryReviewQueueResponse = (input?: Record<string, any>) => {
4053
4053
  return decode(typeMappings, input);
4054
4054
  };
4055
4055
 
4056
+ decoders.QueryRevisionHistoryResponse = (input?: Record<string, any>) => {
4057
+ const typeMappings: TypeMapping = {
4058
+ revisions: { type: 'RevisionHistoryResponse', isSingle: false },
4059
+ };
4060
+ return decode(typeMappings, input);
4061
+ };
4062
+
4056
4063
  decoders.QuerySegmentTargetsResponse = (input?: Record<string, any>) => {
4057
4064
  const typeMappings: TypeMapping = {
4058
4065
  targets: { type: 'SegmentTargetResponse', isSingle: false },
@@ -4402,6 +4409,13 @@ decoders.ReviewQueueItemUpdatedEvent = (input?: Record<string, any>) => {
4402
4409
  return decode(typeMappings, input);
4403
4410
  };
4404
4411
 
4412
+ decoders.RevisionHistoryResponse = (input?: Record<string, any>) => {
4413
+ const typeMappings: TypeMapping = {
4414
+ created_at: { type: 'DatetimeType', isSingle: true },
4415
+ };
4416
+ return decode(typeMappings, input);
4417
+ };
4418
+
4405
4419
  decoders.Role = (input?: Record<string, any>) => {
4406
4420
  const typeMappings: TypeMapping = {
4407
4421
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -1041,7 +1041,7 @@ export interface ActivitySelectorConfig {
1041
1041
  cutoff_window?: string;
1042
1042
 
1043
1043
  /**
1044
- * Minimum popularity threshold
1044
+ * Minimum popularity threshold. For the 'popular' selector, omit to use the default (5); values below 1 are rejected
1045
1045
  */
1046
1046
  min_popularity?: number;
1047
1047
 
@@ -1083,7 +1083,7 @@ export interface ActivitySelectorConfigResponse {
1083
1083
  cutoff_window?: string;
1084
1084
 
1085
1085
  /**
1086
- * Minimum popularity threshold
1086
+ * Minimum popularity threshold. For the 'popular' selector, values below 1 are normalized to the default (5) at read time.
1087
1087
  */
1088
1088
  min_popularity?: number;
1089
1089
 
@@ -1656,6 +1656,8 @@ export interface AppResponseFields {
1656
1656
 
1657
1657
  enforce_unique_usernames: string;
1658
1658
 
1659
+ feed_audit_logs_enabled: boolean;
1660
+
1659
1661
  guest_user_creation_disabled: boolean;
1660
1662
 
1661
1663
  id: number;
@@ -7090,8 +7092,6 @@ export interface CreateFeedViewRequest {
7090
7092
  */
7091
7093
  activity_selectors?: ActivitySelectorConfig[];
7092
7094
 
7093
- activity_filter?: ActivityFilterConfig;
7094
-
7095
7095
  aggregation?: AggregationConfig;
7096
7096
 
7097
7097
  ranking?: RankingConfig;
@@ -7898,6 +7898,11 @@ export interface DeleteFeedsBatchRequest {
7898
7898
  * Whether to permanently delete the feeds instead of soft delete
7899
7899
  */
7900
7900
  hard_delete?: boolean;
7901
+
7902
+ /**
7903
+ * When hard-deleting, also fully delete activities authored by each feed's owner from every other feed those activities were fanned out to. Default false preserves existing fan-out. Requires 'hard_delete' to be true; the request is rejected otherwise. Feeds with no recorded owner (created_by_id is empty) are silently skipped for the purge step — owner-matching against an empty string is a safety guard, not a wildcard.
7904
+ */
7905
+ purge_user_activities?: boolean;
7901
7906
  }
7902
7907
 
7903
7908
  export interface DeleteFeedsBatchResponse {
@@ -8485,6 +8490,11 @@ export interface EnrichmentOptions {
8485
8490
  */
8486
8491
  enrich_own_followings?: boolean;
8487
8492
 
8493
+ /**
8494
+ * Controls the top-level flat 'activities' array for aggregated feeds. For new apps, defaults to false (excluded); set to true to include. For older apps, defaults to true (included) for backward compatibility; set to false to exclude.
8495
+ */
8496
+ include_flat_activities?: boolean;
8497
+
8488
8498
  /**
8489
8499
  * Default: false. When true, includes score_vars in activity responses containing variable values used at ranking time.
8490
8500
  */
@@ -9601,8 +9611,6 @@ export interface FeedViewResponse {
9601
9611
  */
9602
9612
  activity_selectors?: ActivitySelectorConfigResponse[];
9603
9613
 
9604
- activity_filter?: ActivityFilterConfig;
9605
-
9606
9614
  aggregation?: AggregationConfig;
9607
9615
 
9608
9616
  ranking?: RankingConfig;
@@ -11141,8 +11149,6 @@ export interface GetOrCreateFeedViewRequest {
11141
11149
  */
11142
11150
  activity_selectors?: ActivitySelectorConfig[];
11143
11151
 
11144
- activity_filter?: ActivityFilterConfig;
11145
-
11146
11152
  aggregation?: AggregationConfig;
11147
11153
 
11148
11154
  ranking?: RankingConfig;
@@ -17242,6 +17248,40 @@ export interface QueryReviewQueueResponse {
17242
17248
  filter_config?: FilterConfigResponse;
17243
17249
  }
17244
17250
 
17251
+ export interface QueryRevisionHistoryRequest {
17252
+ /**
17253
+ * Filter to apply to the query
17254
+ */
17255
+ filter: Record<string, any>;
17256
+
17257
+ limit?: number;
17258
+
17259
+ next?: string;
17260
+
17261
+ prev?: string;
17262
+
17263
+ /**
17264
+ * Array of sort parameters
17265
+ */
17266
+ sort?: SortParamRequest[];
17267
+ }
17268
+
17269
+ export interface QueryRevisionHistoryResponse {
17270
+ /**
17271
+ * Duration of the request in milliseconds
17272
+ */
17273
+ duration: string;
17274
+
17275
+ /**
17276
+ * Revision history entries
17277
+ */
17278
+ revisions: RevisionHistoryResponse[];
17279
+
17280
+ next?: string;
17281
+
17282
+ prev?: string;
17283
+ }
17284
+
17245
17285
  export interface QuerySegmentTargetsRequest {
17246
17286
  /**
17247
17287
  * Limit
@@ -18679,6 +18719,24 @@ export interface ReviewQueueItemUpdatedEvent {
18679
18719
  review_queue_item?: ReviewQueueItemResponse;
18680
18720
  }
18681
18721
 
18722
+ export interface RevisionHistoryResponse {
18723
+ action_type: string;
18724
+
18725
+ actor_type: string;
18726
+
18727
+ created_at: Date;
18728
+
18729
+ object_id: string;
18730
+
18731
+ object_type: string;
18732
+
18733
+ user_id: string;
18734
+
18735
+ changed_fields?: string[];
18736
+
18737
+ previous_obj_serialized?: Record<string, any>;
18738
+ }
18739
+
18682
18740
  export interface RingCallRequest {
18683
18741
  /**
18684
18742
  * Indicate if call should be video
@@ -22462,8 +22520,6 @@ export interface UpdateFeedViewRequest {
22462
22520
  */
22463
22521
  activity_selectors?: ActivitySelectorConfig[];
22464
22522
 
22465
- activity_filter?: ActivityFilterConfig;
22466
-
22467
22523
  aggregation?: AggregationConfig;
22468
22524
 
22469
22525
  ranking?: RankingConfig;