stream-chat 8.5.0 → 8.7.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 +582 -550
- 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 +582 -550
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +582 -550
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +582 -550
- package/dist/index.js.map +1 -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 +9 -2
- 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 +14 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +2 -0
- package/src/channel_state.ts +1 -1
- package/src/client.ts +12 -12
- package/src/signing.ts +9 -4
- package/src/types.ts +15 -0
package/src/client.ts
CHANGED
|
@@ -93,6 +93,7 @@ import {
|
|
|
93
93
|
GetImportResponse,
|
|
94
94
|
GetMessageAPIResponse,
|
|
95
95
|
GetRateLimitsResponse,
|
|
96
|
+
GetUnreadCountAPIResponse,
|
|
96
97
|
ListChannelResponse,
|
|
97
98
|
ListCommandsResponse,
|
|
98
99
|
ListImportsPaginationOptions,
|
|
@@ -1572,17 +1573,6 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
1572
1573
|
channels.push(c);
|
|
1573
1574
|
}
|
|
1574
1575
|
|
|
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
1576
|
return channels;
|
|
1587
1577
|
}
|
|
1588
1578
|
|
|
@@ -1673,6 +1663,10 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
1673
1663
|
);
|
|
1674
1664
|
}
|
|
1675
1665
|
|
|
1666
|
+
async getUnreadCount(userID?: string) {
|
|
1667
|
+
return await this.get<GetUnreadCountAPIResponse>(this.baseURL + '/unread', userID ? { user_id: userID } : {});
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1676
1670
|
/**
|
|
1677
1671
|
* removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
|
|
1678
1672
|
*
|
|
@@ -2648,7 +2642,13 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
2648
2642
|
});
|
|
2649
2643
|
};
|
|
2650
2644
|
|
|
2651
|
-
|
|
2645
|
+
/**
|
|
2646
|
+
* checks signature of a request
|
|
2647
|
+
* @param {string | Buffer} rawBody
|
|
2648
|
+
* @param {string} signature from HTTP header
|
|
2649
|
+
* @returns {boolean}
|
|
2650
|
+
*/
|
|
2651
|
+
verifyWebhook(requestBody: string | Buffer, xSignature: string) {
|
|
2652
2652
|
return !!this.secret && CheckSignature(requestBody, this.secret, xSignature);
|
|
2653
2653
|
}
|
|
2654
2654
|
|
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
|
@@ -476,6 +476,20 @@ export type GetRepliesAPIResponse<StreamChatGenerics extends ExtendableGenerics
|
|
|
476
476
|
messages: MessageResponse<StreamChatGenerics>[];
|
|
477
477
|
};
|
|
478
478
|
|
|
479
|
+
export type GetUnreadCountAPIResponse = APIResponse & {
|
|
480
|
+
channel_type: {
|
|
481
|
+
channel_count: number;
|
|
482
|
+
channel_type: string;
|
|
483
|
+
unread_count: number;
|
|
484
|
+
}[];
|
|
485
|
+
channels: {
|
|
486
|
+
channel_id: string;
|
|
487
|
+
last_read: string;
|
|
488
|
+
unread_count: number;
|
|
489
|
+
}[];
|
|
490
|
+
total_unread_count: number;
|
|
491
|
+
};
|
|
492
|
+
|
|
479
493
|
export type ListChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
480
494
|
channel_types: Record<
|
|
481
495
|
string,
|
|
@@ -599,6 +613,7 @@ export type ReactionResponse<
|
|
|
599
613
|
export type ReadResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
600
614
|
last_read: string;
|
|
601
615
|
user: UserResponse<StreamChatGenerics>;
|
|
616
|
+
last_read_message_id?: string;
|
|
602
617
|
unread_messages?: number;
|
|
603
618
|
};
|
|
604
619
|
|