stream-chat 8.4.1 → 8.6.0
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/browser.es.js +76 -67
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +76 -67
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +76 -67
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +76 -67
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +3 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +1 -0
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +7 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -2
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +8 -3
- package/src/channel_state.ts +1 -1
- package/src/client.ts +7 -12
- package/src/signing.ts +9 -4
- package/src/types.ts +5 -0
package/src/channel_state.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
|
|
16
16
|
type ChannelReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<
|
|
17
17
|
string,
|
|
18
|
-
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics
|
|
18
|
+
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics>; last_read_message_id?: string }
|
|
19
19
|
>;
|
|
20
20
|
|
|
21
21
|
/**
|
package/src/client.ts
CHANGED
|
@@ -1572,17 +1572,6 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
1572
1572
|
channels.push(c);
|
|
1573
1573
|
}
|
|
1574
1574
|
|
|
1575
|
-
if (!offlineMode) {
|
|
1576
|
-
// If the channels are coming from server, then clear out the
|
|
1577
|
-
// previously help offline channels.
|
|
1578
|
-
for (const key in this.activeChannels) {
|
|
1579
|
-
const channel = this.activeChannels[key];
|
|
1580
|
-
if (channel.offlineMode) {
|
|
1581
|
-
delete this.activeChannels[key];
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
1575
|
return channels;
|
|
1587
1576
|
}
|
|
1588
1577
|
|
|
@@ -2648,7 +2637,13 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
2648
2637
|
});
|
|
2649
2638
|
};
|
|
2650
2639
|
|
|
2651
|
-
|
|
2640
|
+
/**
|
|
2641
|
+
* checks signature of a request
|
|
2642
|
+
* @param {string | Buffer} rawBody
|
|
2643
|
+
* @param {string} signature from HTTP header
|
|
2644
|
+
* @returns {boolean}
|
|
2645
|
+
*/
|
|
2646
|
+
verifyWebhook(requestBody: string | Buffer, xSignature: string) {
|
|
2652
2647
|
return !!this.secret && CheckSignature(requestBody, this.secret, xSignature);
|
|
2653
2648
|
}
|
|
2654
2649
|
|
package/src/signing.ts
CHANGED
|
@@ -74,13 +74,18 @@ export function DevToken(userId: string) {
|
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
*
|
|
77
|
-
* @param {string} body the signed message
|
|
77
|
+
* @param {string | Buffer} body the signed message
|
|
78
78
|
* @param {string} secret the shared secret used to generate the signature (Stream API secret)
|
|
79
79
|
* @param {string} signature the signature to validate
|
|
80
80
|
* @return {boolean}
|
|
81
81
|
*/
|
|
82
|
-
export function CheckSignature(body: string, secret: string, signature: string) {
|
|
83
|
-
const key = Buffer.from(secret, '
|
|
82
|
+
export function CheckSignature(body: string | Buffer, secret: string, signature: string) {
|
|
83
|
+
const key = Buffer.from(secret, 'utf8');
|
|
84
84
|
const hash = crypto.createHmac('sha256', key).update(body).digest('hex');
|
|
85
|
-
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(signature));
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
86
91
|
}
|
package/src/types.ts
CHANGED
|
@@ -73,6 +73,9 @@ export type APIResponse = {
|
|
|
73
73
|
|
|
74
74
|
export type AppSettingsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
75
75
|
app?: {
|
|
76
|
+
// TODO
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
call_types: any;
|
|
76
79
|
channel_configs: Record<
|
|
77
80
|
string,
|
|
78
81
|
{
|
|
@@ -596,6 +599,7 @@ export type ReactionResponse<
|
|
|
596
599
|
export type ReadResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
597
600
|
last_read: string;
|
|
598
601
|
user: UserResponse<StreamChatGenerics>;
|
|
602
|
+
last_read_message_id?: string;
|
|
599
603
|
unread_messages?: number;
|
|
600
604
|
};
|
|
601
605
|
|
|
@@ -734,6 +738,7 @@ export type ChannelQueryOptions<StreamChatGenerics extends ExtendableGenerics =
|
|
|
734
738
|
client_id?: string;
|
|
735
739
|
connection_id?: string;
|
|
736
740
|
data?: ChannelResponse<StreamChatGenerics>;
|
|
741
|
+
hide_for_creator?: boolean;
|
|
737
742
|
members?: PaginationOptions;
|
|
738
743
|
messages?: MessagePaginationOptions;
|
|
739
744
|
presence?: boolean;
|