stream-chat 9.50.3 → 10.0.0-rc.2
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 +19798 -14472
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +19817 -14482
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +19795 -14469
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +221 -0
- package/dist/types/EventHandlerPipeline.d.ts +104 -0
- package/dist/types/api-client.d.ts +26 -0
- package/dist/types/campaign.d.ts +0 -44
- package/dist/types/channel.d.ts +454 -479
- package/dist/types/channel_batch_updater.d.ts +0 -93
- package/dist/types/channel_state.d.ts +53 -201
- package/dist/types/client.d.ts +451 -1920
- package/dist/types/client_state.d.ts +4 -4
- package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
- package/dist/types/configuration/index.d.ts +1 -0
- package/dist/types/configuration/types.d.ts +53 -0
- package/dist/types/connection.d.ts +49 -41
- package/dist/types/connection_fallback.d.ts +6 -4
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/entityStore/EntityStore.d.ts +111 -0
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
- package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
- package/dist/types/entityStore/index.d.ts +2 -0
- package/dist/types/errors.d.ts +10 -2
- package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
- package/dist/types/gen/chat/ChatApi.d.ts +334 -0
- package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
- package/dist/types/gen/models/index.d.ts +8836 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
- package/dist/types/gen-imports.d.ts +3 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/insights.d.ts +9 -8
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
- package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
- package/dist/types/messageComposer/configuration/types.d.ts +11 -11
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
- package/dist/types/messageComposer/messageComposer.d.ts +10 -10
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
- package/dist/types/messageComposer/pollComposer.d.ts +5 -4
- package/dist/types/messageComposer/textComposer.d.ts +8 -3
- package/dist/types/messageComposer/types.d.ts +6 -28
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
- package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
- package/dist/types/messageOperations/index.d.ts +3 -0
- package/dist/types/messageOperations/types.d.ts +49 -0
- package/dist/types/moderation.d.ts +21 -203
- package/dist/types/notifications/types.d.ts +8 -7
- package/dist/types/offline-support/offline_support_api.d.ts +111 -87
- package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
- package/dist/types/offline-support/types.d.ts +19 -23
- package/dist/types/offline-support/util.d.ts +4 -2
- package/dist/types/pagination/FilterBuilder.d.ts +1 -1
- package/dist/types/pagination/ItemIndex.d.ts +25 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
- package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/filterCompiler.d.ts +7 -0
- package/dist/types/pagination/index.d.ts +1 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
- package/dist/types/pagination/paginators/index.d.ts +7 -0
- package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
- package/dist/types/pagination/sortCompiler.d.ts +49 -0
- package/dist/types/pagination/types.normalization.d.ts +11 -0
- package/dist/types/pagination/utility.normalization.d.ts +18 -0
- package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
- package/dist/types/pagination/utility.search.d.ts +13 -0
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/poll.d.ts +29 -32
- package/dist/types/poll_manager.d.ts +2 -2
- package/dist/types/reminders/Reminder.d.ts +2 -5
- package/dist/types/reminders/ReminderManager.d.ts +2 -9
- package/dist/types/search/MessageSearchSource.d.ts +4 -4
- package/dist/types/search/UserSearchSource.d.ts +1 -1
- package/dist/types/search/types.d.ts +3 -3
- package/dist/types/segment.d.ts +0 -34
- package/dist/types/signing.d.ts +105 -65
- package/dist/types/store.d.ts +1 -0
- package/dist/types/thread.d.ts +70 -34
- package/dist/types/thread_manager.d.ts +3 -3
- package/dist/types/token_manager.d.ts +15 -10
- package/dist/types/types.d.ts +197 -3404
- package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
- package/dist/types/utils/WithSubscriptions.d.ts +2 -1
- package/dist/types/utils/concurrency.d.ts +4 -4
- package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
- package/dist/types/utils/retryable.d.ts +34 -0
- package/dist/types/utils/throttling/throttle.d.ts +36 -0
- package/dist/types/utils.d.ts +100 -194
- package/package.json +7 -3
- package/src/ChannelManager.ts +724 -0
- package/src/CooldownTimer.ts +2 -2
- package/src/EventHandlerPipeline.ts +228 -0
- package/src/LiveLocationManager.ts +12 -11
- package/src/api-client.ts +275 -0
- package/src/campaign.ts +1 -77
- package/src/channel.ts +1344 -1282
- package/src/channel_batch_updater.ts +1 -211
- package/src/channel_state.ts +144 -1013
- package/src/client.ts +936 -3995
- package/src/client_state.ts +4 -4
- package/src/configuration/InstanceConfigurationService.ts +73 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/types.ts +81 -0
- package/src/connection.ts +145 -94
- package/src/connection_fallback.ts +29 -27
- package/src/constants.ts +1 -5
- package/src/custom_types.ts +4 -1
- package/src/entityStore/EntityStore.ts +208 -0
- package/src/entityStore/StoreBackedItemIndex.ts +115 -0
- package/src/entityStore/applyReactionLocally.ts +113 -0
- package/src/entityStore/index.ts +2 -0
- package/src/errors.ts +14 -2
- package/src/gen/chat/ChannelApi.ts +275 -0
- package/src/gen/chat/ChatApi.ts +2554 -0
- package/src/gen/model-decoders/decoders.ts +2680 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
- package/src/gen/models/index.ts +12673 -0
- package/src/gen/moderation/ModerationApi.ts +607 -0
- package/src/gen-imports.ts +3 -0
- package/src/index.ts +11 -12
- package/src/insights.ts +6 -5
- package/src/logger.ts +28 -0
- package/src/messageComposer/LocationComposer.ts +9 -5
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
- package/src/messageComposer/attachmentIdentity.ts +16 -9
- package/src/messageComposer/attachmentManager.ts +13 -8
- package/src/messageComposer/configuration/types.ts +11 -11
- package/src/messageComposer/linkPreviewsManager.ts +9 -10
- package/src/messageComposer/messageComposer.ts +57 -53
- package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
- package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
- package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
- package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
- package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
- package/src/messageComposer/middleware/textComposer/types.ts +9 -4
- package/src/messageComposer/pollComposer.ts +6 -8
- package/src/messageComposer/textComposer.ts +27 -2
- package/src/messageComposer/types.ts +6 -28
- package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
- package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
- package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
- package/src/messageOperations/MessageOperations.ts +212 -0
- package/src/messageOperations/index.ts +10 -0
- package/src/messageOperations/types.ts +64 -0
- package/src/moderation.ts +38 -431
- package/src/notifications/types.ts +8 -7
- package/src/offline-support/offline_support_api.ts +200 -133
- package/src/offline-support/offline_sync_manager.ts +23 -44
- package/src/offline-support/types.ts +23 -26
- package/src/offline-support/util.ts +5 -4
- package/src/pagination/FilterBuilder.ts +4 -1
- package/src/pagination/ItemIndex.ts +25 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
- package/src/pagination/cursorDerivation/index.ts +1 -0
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
- package/src/pagination/filterCompiler.ts +196 -0
- package/src/pagination/index.ts +1 -3
- package/src/pagination/paginators/BasePaginator.ts +2859 -0
- package/src/pagination/paginators/ChannelPaginator.ts +729 -0
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
- package/src/pagination/paginators/MessagePaginator.ts +508 -0
- package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
- package/src/pagination/paginators/ReminderPaginator.ts +107 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
- package/src/pagination/paginators/index.ts +7 -0
- package/src/pagination/paginators/stateThrottling.ts +31 -0
- package/src/pagination/sortCompiler.ts +193 -0
- package/src/pagination/types.normalization.ts +14 -0
- package/src/pagination/utility.normalization.ts +106 -0
- package/src/pagination/utility.queryChannel.ts +84 -0
- package/src/pagination/utility.search.ts +80 -0
- package/src/permissions.ts +7 -8
- package/src/poll.ts +101 -110
- package/src/poll_manager.ts +14 -8
- package/src/reminders/Reminder.ts +2 -5
- package/src/reminders/ReminderManager.ts +19 -21
- package/src/search/BaseSearchSource.ts +0 -3
- package/src/search/ChannelMemberSearchSource.ts +7 -1
- package/src/search/ChannelSearchSource.ts +10 -3
- package/src/search/MessageSearchSource.ts +29 -30
- package/src/search/UserSearchSource.ts +12 -8
- package/src/search/types.ts +3 -4
- package/src/segment.ts +1 -95
- package/src/signing.ts +107 -67
- package/src/store.ts +2 -1
- package/src/thread.ts +562 -238
- package/src/thread_manager.ts +37 -16
- package/src/token_manager.ts +21 -10
- package/src/types.ts +364 -4533
- package/src/uploadManager.ts +8 -0
- package/src/utils/FixedSizeQueueCache.ts +12 -6
- package/src/utils/WithSubscriptions.ts +2 -1
- package/src/utils/concurrency.ts +4 -4
- package/src/utils/mergeWith/mergeWith.ts +3 -3
- package/src/utils/mergeWith/mergeWithCore.ts +140 -164
- package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
- package/src/utils/retryable.ts +117 -0
- package/src/utils/throttling/throttle.ts +130 -0
- package/src/utils.ts +208 -754
- package/dist/types/channel_manager.d.ts +0 -122
- package/dist/types/events.d.ts +0 -72
- package/dist/types/pagination/BasePaginator.d.ts +0 -69
- package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
- package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
- package/src/channel_manager.ts +0 -830
- package/src/events.ts +0 -75
- package/src/pagination/BasePaginator.ts +0 -184
- package/src/pagination/ReminderPaginator.ts +0 -56
- package/src/pagination/UserGroupPaginator.ts +0 -93
|
@@ -9,12 +9,12 @@ export type SearchSourceState<T = any> = {
|
|
|
9
9
|
offset?: number;
|
|
10
10
|
};
|
|
11
11
|
export type SearchSourceOptions = {
|
|
12
|
-
/** The number of milliseconds to debounce the search query
|
|
12
|
+
/** The number of milliseconds to debounce the search query (defaults to `300`). */
|
|
13
13
|
debounceMs?: number;
|
|
14
14
|
pageSize?: number;
|
|
15
|
-
/** When true
|
|
15
|
+
/** When `true`, the source can execute queries with an empty search string (defaults to `false`). */
|
|
16
16
|
allowEmptySearchString?: boolean;
|
|
17
|
-
/** When true
|
|
17
|
+
/** When `true`, previously loaded items are cleared at the start of a new search query (defaults to `true`). */
|
|
18
18
|
resetOnNewSearchQuery?: boolean;
|
|
19
19
|
};
|
|
20
20
|
export type SearchSourceType = 'channels' | 'users' | 'messages' | (string & {});
|
package/dist/types/segment.d.ts
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { StreamChat } from './client';
|
|
2
|
-
import type { QuerySegmentTargetsFilter, SegmentData, SegmentResponse, SortParam } from './types';
|
|
3
|
-
type SegmentType = 'user' | 'channel';
|
|
4
|
-
type SegmentUpdatableFields = {
|
|
5
|
-
description?: string;
|
|
6
|
-
filter?: {};
|
|
7
|
-
name?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class Segment {
|
|
10
|
-
type: SegmentType;
|
|
11
|
-
id: string | null;
|
|
12
|
-
client: StreamChat;
|
|
13
|
-
data?: SegmentData | SegmentResponse;
|
|
14
|
-
constructor(client: StreamChat, type: SegmentType, id: string | null, data?: SegmentData);
|
|
15
|
-
create(): Promise<{
|
|
16
|
-
segment: SegmentResponse;
|
|
17
|
-
}>;
|
|
18
|
-
verifySegmentId(): void;
|
|
19
|
-
get(): Promise<{
|
|
20
|
-
segment: SegmentResponse;
|
|
21
|
-
} & import("./types").APIResponse>;
|
|
22
|
-
update(data: Partial<SegmentUpdatableFields>): Promise<{
|
|
23
|
-
segment: SegmentResponse;
|
|
24
|
-
}>;
|
|
25
|
-
addTargets(targets: string[]): Promise<import("./types").APIResponse>;
|
|
26
|
-
removeTargets(targets: string[]): Promise<import("./types").APIResponse>;
|
|
27
|
-
delete(): Promise<import("./types").APIResponse>;
|
|
28
|
-
targetExists(targetId: string): Promise<import("./types").APIResponse>;
|
|
29
|
-
queryTargets(filter?: QuerySegmentTargetsFilter | null, sort?: SortParam[] | null | [], options?: {}): Promise<{
|
|
30
|
-
targets: import("./types").SegmentTargetsResponse[];
|
|
31
|
-
next?: string;
|
|
32
|
-
} & import("./types").APIResponse>;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
package/dist/types/signing.d.ts
CHANGED
|
@@ -1,42 +1,64 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UR } from './types';
|
|
3
|
+
import type { WSEvent } from './gen/models';
|
|
3
4
|
/**
|
|
4
|
-
* Creates the JWT token that can be used for a
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @
|
|
11
|
-
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
12
|
-
* @return {string} JWT Token
|
|
5
|
+
* Creates the JWT token that can be used for a user session.
|
|
6
|
+
*
|
|
7
|
+
* @param apiSecret - API secret key.
|
|
8
|
+
* @param userId - The `user_id` key in the JWT payload.
|
|
9
|
+
* @param extraData - Extra data that should be part of the JWT token (optional, defaults to `{}`).
|
|
10
|
+
* @param jwtOptions - Options that can be passed to `jwt.sign` (optional, defaults to `{}`).
|
|
11
|
+
* @returns The signed JWT token.
|
|
13
12
|
*/
|
|
14
13
|
export declare function JWTUserToken(apiSecret: jwt.Secret, userId: string, extraData?: UR, jwtOptions?: jwt.SignOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates the JWT token that can be used for a server-side session.
|
|
16
|
+
*
|
|
17
|
+
* @param apiSecret - API secret key.
|
|
18
|
+
* @param jwtOptions - Options that can be passed to `jwt.sign` (optional, defaults to `{}`).
|
|
19
|
+
* @returns The signed JWT token.
|
|
20
|
+
*/
|
|
15
21
|
export declare function JWTServerToken(apiSecret: jwt.Secret, jwtOptions?: jwt.SignOptions): string;
|
|
22
|
+
/**
|
|
23
|
+
* Decodes a JWT token and returns the embedded `user_id`.
|
|
24
|
+
*
|
|
25
|
+
* @param token - The JWT token to decode.
|
|
26
|
+
* @returns The `user_id` extracted from the token's payload, or an empty string when the token is malformed.
|
|
27
|
+
*/
|
|
16
28
|
export declare function UserFromToken(token: string): string;
|
|
17
29
|
/**
|
|
30
|
+
* Generates a development token for the given user.
|
|
31
|
+
*
|
|
32
|
+
* Development tokens are unsigned and must only be used in environments where token validation is disabled.
|
|
18
33
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
34
|
+
* @param userId - The ID of the user.
|
|
35
|
+
* @returns The development token.
|
|
21
36
|
*/
|
|
22
37
|
export declare function DevToken(userId: string): string;
|
|
23
38
|
/**
|
|
24
|
-
* Constant-time HMAC-SHA256 verification of `signature` against the
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
39
|
+
* Constant-time HMAC-SHA256 verification of `signature` against the digest of `body` using `secret`
|
|
40
|
+
* as the key. The signature is always computed over the **uncompressed** JSON bytes, so callers that
|
|
41
|
+
* decoded a gzipped or base64-wrapped payload must pass the inflated bytes here.
|
|
42
|
+
*
|
|
43
|
+
* The legacy `client.verifyWebhook` helper wraps this function, so callers that have already
|
|
44
|
+
* migrated to {@link verifyAndParseWebhook}, {@link parseSqs}, or {@link parseSns} rarely need to
|
|
45
|
+
* invoke this directly.
|
|
46
|
+
*
|
|
47
|
+
* @param body - The uncompressed payload bytes that Stream signed.
|
|
48
|
+
* @param signature - The HMAC-SHA256 signature delivered alongside the payload.
|
|
49
|
+
* @param secret - Your app's API secret used as the HMAC key.
|
|
50
|
+
* @returns `true` when the signature matches the digest of `body`, otherwise `false`.
|
|
34
51
|
*/
|
|
35
52
|
export declare function verifySignature(body: string | Buffer, signature: string, secret: string): boolean;
|
|
36
53
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
54
|
+
* Verifies an HMAC-SHA256 signature with the legacy parameter order.
|
|
55
|
+
*
|
|
56
|
+
* @param body - The uncompressed payload bytes that Stream signed.
|
|
57
|
+
* @param secret - Your app's API secret used as the HMAC key.
|
|
58
|
+
* @param signature - The HMAC-SHA256 signature delivered alongside the payload.
|
|
59
|
+
* @returns `true` when the signature matches the digest of `body`, otherwise `false`.
|
|
60
|
+
* @deprecated Use {@link verifySignature} instead — same logic, parameters reordered to match the
|
|
61
|
+
* cross-SDK contract (`verifySignature(body, signature, secret)`).
|
|
40
62
|
*/
|
|
41
63
|
export declare function CheckSignature(body: string | Buffer, secret: string, signature: string): boolean;
|
|
42
64
|
/**
|
|
@@ -65,60 +87,78 @@ export declare class InvalidWebhookError extends Error {
|
|
|
65
87
|
constructor(message?: string);
|
|
66
88
|
}
|
|
67
89
|
/**
|
|
68
|
-
* Returns `body` as a `Buffer`, gzip-decompressed when its first two
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
90
|
+
* Returns `body` as a `Buffer`, gzip-decompressed when its first two bytes match the gzip magic
|
|
91
|
+
* (`1f 8b`, per RFC 1952). When the body is plain JSON (no compression, or middleware already
|
|
92
|
+
* decompressed), the bytes are returned unchanged.
|
|
93
|
+
*
|
|
94
|
+
* Magic-byte detection (rather than relying on a header) keeps the same handler correct when
|
|
95
|
+
* middleware — Express, Next.js, AWS Lambda — auto-decompresses the request before your code sees it.
|
|
96
|
+
*
|
|
97
|
+
* @param rawBody - The raw HTTP request body, either as a string or a `Buffer`.
|
|
98
|
+
* @returns The uncompressed payload bytes.
|
|
99
|
+
* @throws {@link InvalidWebhookError} when the gzip envelope is malformed.
|
|
76
100
|
*/
|
|
77
101
|
export declare function gunzipPayload(rawBody: string | Buffer): Buffer;
|
|
78
102
|
/**
|
|
79
|
-
* Reverses the SQS firehose envelope: the message `Body` is
|
|
80
|
-
*
|
|
81
|
-
* with the gzip magic. Returns the raw JSON `Buffer` Stream signed.
|
|
103
|
+
* Reverses the SQS firehose envelope: the message `Body` is base64-decoded, then the result is
|
|
104
|
+
* gzip-decompressed when it begins with the gzip magic. Returns the raw JSON `Buffer` Stream signed.
|
|
82
105
|
*
|
|
83
|
-
* SQS bodies are always base64-encoded so they remain valid UTF-8 over
|
|
84
|
-
*
|
|
85
|
-
*
|
|
106
|
+
* SQS bodies are always base64-encoded so they remain valid UTF-8 over the queue. The same call
|
|
107
|
+
* works whether or not Stream is currently compressing payloads for this app.
|
|
108
|
+
*
|
|
109
|
+
* @param body - The base64-encoded SQS message body.
|
|
110
|
+
* @returns The decoded (and decompressed, when gzipped) payload bytes.
|
|
111
|
+
* @throws {@link InvalidWebhookError} when the body is not canonical base64 or the gzip envelope is malformed.
|
|
86
112
|
*/
|
|
87
113
|
export declare function decodeSqsPayload(body: string): Buffer;
|
|
88
114
|
/**
|
|
89
|
-
* Reverses an SNS HTTP notification envelope. When `notificationBody`
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
115
|
+
* Reverses an SNS HTTP notification envelope. When `notificationBody` is a JSON envelope
|
|
116
|
+
* (`{"Type":"Notification","MessageRequest":"..."}`), the inner `MessageRequest` field is extracted and run
|
|
117
|
+
* through the SQS pipeline (base64-decode, then gzip-if-magic). When the input is not a JSON
|
|
118
|
+
* envelope it is treated as the already-extracted `MessageRequest` string, so call sites that pre-unwrap
|
|
119
|
+
* continue to work.
|
|
120
|
+
*
|
|
121
|
+
* @param notificationBody - The raw SNS notification body, or a pre-extracted `MessageRequest` string.
|
|
122
|
+
* @returns The decoded (and decompressed, when gzipped) payload bytes.
|
|
123
|
+
* @throws {@link InvalidWebhookError} when the body is not canonical base64 or the gzip envelope is malformed.
|
|
95
124
|
*/
|
|
96
125
|
export declare function decodeSnsPayload(notificationBody: string): Buffer;
|
|
97
126
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
127
|
+
* Parses a JSON-encoded webhook event into a typed {@link WSEvent}. New event types Stream
|
|
128
|
+
* introduces still parse successfully — the runtime shape is the JSON Stream sent and the `type`
|
|
129
|
+
* field stays preserved.
|
|
130
|
+
*
|
|
131
|
+
* @param payload - The raw event payload bytes or string.
|
|
132
|
+
* @returns The parsed WebSocket event.
|
|
133
|
+
* @throws {@link InvalidWebhookError} when the payload is not valid JSON.
|
|
101
134
|
*/
|
|
102
|
-
export declare function parseEvent(payload: Buffer | string):
|
|
135
|
+
export declare function parseEvent(payload: Buffer | string): WSEvent;
|
|
103
136
|
/**
|
|
104
|
-
* Decompress (when gzipped), verify the HMAC `signature`, and return
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @
|
|
110
|
-
* @throws {InvalidWebhookError}
|
|
111
|
-
* the gzip envelope is malformed.
|
|
137
|
+
* Decompress (when gzipped), verify the HMAC `signature`, and return the parsed {@link WSEvent}.
|
|
138
|
+
*
|
|
139
|
+
* @param rawBody - Raw HTTP request body bytes Stream signed.
|
|
140
|
+
* @param signature - Value of the `X-Signature` header.
|
|
141
|
+
* @param secret - Your app's API secret.
|
|
142
|
+
* @returns The parsed WebSocket event.
|
|
143
|
+
* @throws {@link InvalidWebhookError} when the signature does not match or the gzip envelope is malformed.
|
|
112
144
|
*/
|
|
113
|
-
export declare function verifyAndParseWebhook(rawBody: string | Buffer, signature: string, secret: string):
|
|
145
|
+
export declare function verifyAndParseWebhook(rawBody: string | Buffer, signature: string, secret: string): WSEvent;
|
|
114
146
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
147
|
+
* Decodes the SQS message `Body` (base64, then gzip-if-magic) and returns the parsed {@link WSEvent}.
|
|
148
|
+
* Stream does not attach an application-level HMAC to SQS deliveries — use
|
|
149
|
+
* {@link verifyAndParseWebhook} for HTTP webhooks.
|
|
150
|
+
*
|
|
151
|
+
* @param messageBody - The base64-encoded SQS message body.
|
|
152
|
+
* @returns The parsed WebSocket event.
|
|
153
|
+
* @throws {@link InvalidWebhookError} when the body is malformed.
|
|
118
154
|
*/
|
|
119
|
-
export declare function parseSqs(messageBody: string):
|
|
155
|
+
export declare function parseSqs(messageBody: string): WSEvent;
|
|
120
156
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
157
|
+
* Decodes an SNS notification (unwraps the JSON envelope when needed; same inner format as SQS).
|
|
158
|
+
* No application-level HMAC verification.
|
|
159
|
+
*
|
|
160
|
+
* @param notificationBody - The raw SNS notification body, or a pre-extracted `MessageRequest` string.
|
|
161
|
+
* @returns The parsed WebSocket event.
|
|
162
|
+
* @throws {@link InvalidWebhookError} when the body is malformed.
|
|
123
163
|
*/
|
|
124
|
-
export declare function parseSns(notificationBody: string):
|
|
164
|
+
export declare function parseSns(notificationBody: string): WSEvent;
|
package/dist/types/store.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class StateStore<T extends Record<string, unknown>> {
|
|
|
12
12
|
constructor(value: T);
|
|
13
13
|
/**
|
|
14
14
|
* Allows merging two stores only if their keys differ otherwise there's no way to ensure the data type stability.
|
|
15
|
+
*
|
|
15
16
|
* @experimental
|
|
16
17
|
* This method is experimental and may change in future versions.
|
|
17
18
|
*/
|
package/dist/types/thread.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { StateStore } from './store';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Channel } from './channel';
|
|
2
|
+
import type { DraftResponse, EventAPIResponse, LocalMessage, MarkReadRequest, MessageResponse, ReactionRequest, SendReactionRequest, ThreadStateResponse, UserResponse } from './types';
|
|
3
|
+
import type { Channel, DeleteMessageWithStateUpdateParams, SendMessageWithStateUpdateParams, UpdateMessageWithStateUpdateParams } from './channel';
|
|
4
4
|
import type { StreamChat } from './client';
|
|
5
5
|
import type { CustomThreadData } from './custom_types';
|
|
6
6
|
import { MessageComposer } from './messageComposer';
|
|
7
|
+
import { MessageOperations } from './messageOperations';
|
|
7
8
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
8
|
-
|
|
9
|
-
sort?: {
|
|
10
|
-
created_at: AscDesc;
|
|
11
|
-
}[];
|
|
12
|
-
} & MessagePaginationOptions & {
|
|
13
|
-
user?: UserResponse;
|
|
14
|
-
user_id?: string;
|
|
15
|
-
};
|
|
9
|
+
import { MessagePaginator } from './pagination';
|
|
16
10
|
export type ThreadState = {
|
|
17
11
|
/**
|
|
18
12
|
* Determines if the thread is currently opened and on-screen. When the thread is active,
|
|
@@ -25,25 +19,17 @@ export type ThreadState = {
|
|
|
25
19
|
deletedAt: Date | null;
|
|
26
20
|
isLoading: boolean;
|
|
27
21
|
isStateStale: boolean;
|
|
28
|
-
pagination: ThreadRepliesPagination;
|
|
29
22
|
/**
|
|
30
23
|
* Thread is identified by and has a one-to-one relation with its parent message.
|
|
31
24
|
* We use parent message id as a thread id.
|
|
32
25
|
*/
|
|
33
26
|
parentMessage: LocalMessage;
|
|
34
|
-
participants:
|
|
27
|
+
participants: ThreadStateResponse['thread_participants'];
|
|
35
28
|
read: ThreadReadState;
|
|
36
|
-
replies: Array<LocalMessage>;
|
|
37
29
|
replyCount: number;
|
|
38
30
|
title: string;
|
|
39
31
|
updatedAt: Date | null;
|
|
40
32
|
};
|
|
41
|
-
export type ThreadRepliesPagination = {
|
|
42
|
-
isLoadingNext: boolean;
|
|
43
|
-
isLoadingPrev: boolean;
|
|
44
|
-
nextCursor: string | null;
|
|
45
|
-
prevCursor: string | null;
|
|
46
|
-
};
|
|
47
33
|
export type ThreadUserReadState = {
|
|
48
34
|
lastReadAt: Date;
|
|
49
35
|
unreadMessageCount: number;
|
|
@@ -52,16 +38,30 @@ export type ThreadUserReadState = {
|
|
|
52
38
|
firstUnreadMessageId?: string;
|
|
53
39
|
};
|
|
54
40
|
export type ThreadReadState = Record<string, ThreadUserReadState | undefined>;
|
|
55
|
-
export
|
|
41
|
+
export type CustomThreadMarkReadRequestFn = (params: {
|
|
42
|
+
thread: Thread;
|
|
43
|
+
options?: MarkReadRequest;
|
|
44
|
+
}) => Promise<EventAPIResponse | null> | void;
|
|
45
|
+
export type ThreadInstanceConfig = {
|
|
46
|
+
requestHandlers?: {
|
|
47
|
+
markReadRequest?: CustomThreadMarkReadRequestFn;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
56
50
|
export declare class Thread extends WithSubscriptions {
|
|
51
|
+
readonly configState: StateStore<ThreadInstanceConfig>;
|
|
57
52
|
readonly state: StateStore<ThreadState>;
|
|
58
53
|
readonly id: string;
|
|
59
54
|
readonly messageComposer: MessageComposer;
|
|
55
|
+
readonly messagePaginator: MessagePaginator;
|
|
56
|
+
readonly messageOperations: MessageOperations;
|
|
60
57
|
private client;
|
|
61
58
|
private failedRepliesMap;
|
|
62
|
-
constructor({ client, threadData, }: {
|
|
59
|
+
constructor({ client, threadData, channel, parentMessage, draft, }: {
|
|
63
60
|
client: StreamChat;
|
|
64
|
-
threadData
|
|
61
|
+
threadData?: ThreadStateResponse;
|
|
62
|
+
channel?: Channel;
|
|
63
|
+
parentMessage?: MessageResponse | LocalMessage;
|
|
64
|
+
draft?: DraftResponse;
|
|
65
65
|
});
|
|
66
66
|
get channel(): Channel;
|
|
67
67
|
get hasStaleState(): boolean;
|
|
@@ -80,11 +80,13 @@ export declare class Thread extends WithSubscriptions {
|
|
|
80
80
|
private subscribeRepliesRead;
|
|
81
81
|
private subscribeMessageDeleted;
|
|
82
82
|
private subscribeMessageUpdated;
|
|
83
|
+
private subscribeUserMessagesDeleted;
|
|
84
|
+
private subscribeParentMessageFromStore;
|
|
83
85
|
unregisterSubscriptions: () => symbol;
|
|
84
86
|
deleteReplyLocally: ({ message }: {
|
|
85
87
|
message: MessageResponse;
|
|
86
88
|
}) => void;
|
|
87
|
-
upsertReplyLocally: ({ message,
|
|
89
|
+
upsertReplyLocally: ({ message, }: {
|
|
88
90
|
message: MessageResponse | LocalMessage;
|
|
89
91
|
timestampChanged?: boolean;
|
|
90
92
|
}) => void;
|
|
@@ -92,17 +94,51 @@ export declare class Thread extends WithSubscriptions {
|
|
|
92
94
|
message: MessageResponse;
|
|
93
95
|
}) => void;
|
|
94
96
|
updateParentMessageOrReplyLocally: (message: MessageResponse) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Sends a message with optimistic local state update.
|
|
99
|
+
*/
|
|
100
|
+
sendMessageWithLocalUpdate({ localMessage, message, options, sendMessageRequestFn, }: SendMessageWithStateUpdateParams): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Retry sending a failed message.
|
|
103
|
+
*/
|
|
104
|
+
retrySendMessageWithLocalUpdate(params: Omit<SendMessageWithStateUpdateParams, 'message'>): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Updates a message with optimistic local state update.
|
|
107
|
+
*
|
|
108
|
+
* The update flows through `messagePaginator`, which is the sole reply source.
|
|
109
|
+
*/
|
|
110
|
+
updateMessageWithLocalUpdate(params: UpdateMessageWithStateUpdateParams): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Deletes a message with local state update.
|
|
113
|
+
*/
|
|
114
|
+
deleteMessageWithLocalUpdate(params: DeleteMessageWithStateUpdateParams): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Adds a reaction to a reply with an optimistic local state update, mirroring
|
|
117
|
+
* {@link Channel.addReactionWithLocalUpdate}. The optimistic message is applied to THIS thread's
|
|
118
|
+
* paginator (so pure replies get optimism the channel paginator can't give); the request routes
|
|
119
|
+
* through the parent channel since reactions are channel-level.
|
|
120
|
+
*/
|
|
121
|
+
addReactionWithLocalUpdate({ messageId, reaction, options, }: {
|
|
122
|
+
messageId: string;
|
|
123
|
+
reaction: ReactionRequest;
|
|
124
|
+
options?: Pick<SendReactionRequest, 'enforce_unique' | 'skip_push'>;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Removes the current user's reaction from a reply with an optimistic local state update,
|
|
128
|
+
* mirroring {@link Thread.addReactionWithLocalUpdate}.
|
|
129
|
+
*/
|
|
130
|
+
deleteReactionWithLocalUpdate({ messageId, type, }: {
|
|
131
|
+
messageId: string;
|
|
132
|
+
type: string;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
markRead: ({ force }?: {
|
|
135
|
+
force?: boolean;
|
|
136
|
+
}) => Promise<EventAPIResponse | import("./types").StreamResponse<import(".").MarkReadResponse> | null>;
|
|
137
|
+
private throttledMarkRead;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use `thread.markRead` instead.
|
|
140
|
+
*/
|
|
95
141
|
markAsRead: ({ force }?: {
|
|
96
142
|
force?: boolean;
|
|
97
|
-
}) => Promise<import("./types").
|
|
98
|
-
private throttledMarkAsRead;
|
|
99
|
-
queryReplies: ({ limit, sort, ...otherOptions }?: QueryRepliesOptions) => Promise<import("./types").GetRepliesAPIResponse>;
|
|
100
|
-
loadNextPage: ({ limit }?: {
|
|
101
|
-
limit?: number;
|
|
102
|
-
}) => Promise<void>;
|
|
103
|
-
loadPrevPage: ({ limit }?: {
|
|
104
|
-
limit?: number;
|
|
105
|
-
}) => Promise<void>;
|
|
106
|
-
private loadPage;
|
|
143
|
+
}) => Promise<EventAPIResponse | import("./types").StreamResponse<import(".").MarkReadResponse> | null>;
|
|
107
144
|
}
|
|
108
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StateStore } from './store';
|
|
2
2
|
import type { StreamChat } from './client';
|
|
3
3
|
import type { Thread } from './thread';
|
|
4
|
-
import type {
|
|
4
|
+
import type { QueryThreadsRequest } from './types';
|
|
5
5
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
6
6
|
export declare const THREAD_MANAGER_INITIAL_STATE: {
|
|
7
7
|
active: boolean;
|
|
@@ -65,9 +65,9 @@ export declare class ThreadManager extends WithSubscriptions {
|
|
|
65
65
|
reload: ({ force }?: {
|
|
66
66
|
force?: boolean | undefined;
|
|
67
67
|
}) => Promise<void>;
|
|
68
|
-
queryThreads: (options?:
|
|
68
|
+
queryThreads: (options?: QueryThreadsRequest) => Promise<{
|
|
69
69
|
threads: Thread[];
|
|
70
70
|
next: string | undefined;
|
|
71
71
|
}>;
|
|
72
|
-
loadNextPage: (options?: Omit<
|
|
72
|
+
loadNextPage: (options?: Omit<QueryThreadsRequest, "next">) => Promise<void>;
|
|
73
73
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type jwt from 'jsonwebtoken';
|
|
2
|
-
import type { TokenOrProvider
|
|
2
|
+
import type { TokenOrProvider } from './types';
|
|
3
|
+
export type TokenManagerMinimalUser = {
|
|
4
|
+
id: string;
|
|
5
|
+
anon?: boolean;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* TokenManager
|
|
5
9
|
*
|
|
@@ -11,27 +15,28 @@ export declare class TokenManager {
|
|
|
11
15
|
secret?: jwt.Secret;
|
|
12
16
|
token?: string;
|
|
13
17
|
tokenProvider?: TokenOrProvider;
|
|
14
|
-
user?:
|
|
18
|
+
user?: TokenManagerMinimalUser;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
20
|
+
* Initializes the token manager, optionally with a server-side API secret used to mint tokens
|
|
21
|
+
* locally.
|
|
17
22
|
*
|
|
18
|
-
* @param
|
|
23
|
+
* @param secret - Optional API secret. When provided, the manager will sign server tokens locally.
|
|
19
24
|
*/
|
|
20
25
|
constructor(secret?: jwt.Secret);
|
|
21
26
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
27
|
+
* Sets the static string token or token provider. A token provider should return a token string
|
|
28
|
+
* or a promise that resolves to a token string.
|
|
24
29
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
30
|
+
* @param tokenOrProvider - A token string or an async provider that returns one.
|
|
31
|
+
* @param user - The user the token belongs to.
|
|
27
32
|
*/
|
|
28
|
-
setTokenOrProvider: (tokenOrProvider: TokenOrProvider, user:
|
|
33
|
+
setTokenOrProvider: (tokenOrProvider: TokenOrProvider, user: TokenManagerMinimalUser) => Promise<void>;
|
|
29
34
|
/**
|
|
30
35
|
* Resets the token manager.
|
|
31
36
|
* Useful for client disconnection or switching user.
|
|
32
37
|
*/
|
|
33
38
|
reset: () => void;
|
|
34
|
-
validateToken: (tokenOrProvider: TokenOrProvider, user:
|
|
39
|
+
validateToken: (tokenOrProvider: TokenOrProvider, user: TokenManagerMinimalUser) => void;
|
|
35
40
|
tokenReady: () => Promise<string> | null;
|
|
36
41
|
loadToken: () => Promise<string>;
|
|
37
42
|
getToken: () => string | undefined;
|