stream-chat
Advanced tools
Comparing version 8.5.0 to 8.6.0
@@ -7,2 +7,3 @@ import { Channel } from './channel'; | ||
user: UserResponse<StreamChatGenerics>; | ||
last_read_message_id?: string; | ||
}>; | ||
@@ -9,0 +10,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Secret, SignOptions } from 'jsonwebtoken'; | ||
@@ -25,3 +26,3 @@ import { UR } from './types'; | ||
* | ||
* @param {string} body the signed message | ||
* @param {string | Buffer} body the signed message | ||
* @param {string} secret the shared secret used to generate the signature (Stream API secret) | ||
@@ -31,3 +32,3 @@ * @param {string} signature the signature to validate | ||
*/ | ||
export declare function CheckSignature(body: string, secret: string, signature: string): boolean; | ||
export declare function CheckSignature(body: string | Buffer, secret: string, signature: string): boolean; | ||
//# sourceMappingURL=signing.d.ts.map |
{ | ||
"name": "stream-chat", | ||
"version": "8.5.0", | ||
"version": "8.6.0", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -18,3 +18,3 @@ import { Channel } from './channel'; | ||
string, | ||
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics> } | ||
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics>; last_read_message_id?: string } | ||
>; | ||
@@ -21,0 +21,0 @@ |
@@ -1039,2 +1039,3 @@ import { ChannelState } from './channel_state'; | ||
this.data = state.channel; | ||
this.offlineMode = false; | ||
@@ -1499,2 +1500,3 @@ this.getClient().dispatchEvent({ | ||
last_read: new Date(read.last_read), | ||
last_read_message_id: read.last_read_message_id, | ||
unread_messages: read.unread_messages ?? 0, | ||
@@ -1501,0 +1503,0 @@ user: read.user, |
@@ -77,3 +77,3 @@ import jwt, { Secret, SignOptions } from 'jsonwebtoken'; | ||
* | ||
* @param {string} body the signed message | ||
* @param {string | Buffer} body the signed message | ||
* @param {string} secret the shared secret used to generate the signature (Stream API secret) | ||
@@ -83,6 +83,11 @@ * @param {string} signature the signature to validate | ||
*/ | ||
export function CheckSignature(body: string, secret: string, signature: string) { | ||
const key = Buffer.from(secret, 'ascii'); | ||
export function CheckSignature(body: string | Buffer, secret: string, signature: string) { | ||
const key = Buffer.from(secret, 'utf8'); | ||
const hash = crypto.createHmac('sha256', key).update(body).digest('hex'); | ||
return hash === signature; | ||
try { | ||
return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(signature)); | ||
} catch { | ||
return false; | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4963654
52536