@relaybox/rest
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -33,3 +33,3 @@ import { ExtendedJwtPayload } from './types/jwt.types'; | ||
*/ | ||
publish(roomId: string | string[], event: string, data: any): Promise<PublishResponseData>; | ||
publish(roomId: string | string[], event: string, data: any, clientId?: string): Promise<PublishResponseData>; | ||
/** | ||
@@ -36,0 +36,0 @@ * Prepares the request parameters including the request body, HMAC signature, and public key. |
@@ -62,6 +62,6 @@ "use strict"; | ||
*/ | ||
publish(roomId, event, data) { | ||
publish(roomId, event, data, clientId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
(0, validation_1.validateParams)({ roomId, event, data }, ['roomId', 'event', 'data']); | ||
const [requestBody, requestSignature, publicKey] = this.prepareRequestParams(roomId, event, data); | ||
const { body: requestBody, signature: requestSignature, publicKey } = this.prepareRequestParams(roomId, event, data, clientId); | ||
const requestParams = { | ||
@@ -87,3 +87,3 @@ method: 'POST', | ||
*/ | ||
prepareRequestParams(roomId, event, data) { | ||
prepareRequestParams(roomId, event, data, clientId) { | ||
const timestamp = Date.now(); | ||
@@ -94,7 +94,8 @@ const body = JSON.stringify({ | ||
data, | ||
timestamp | ||
timestamp, | ||
clientId | ||
}); | ||
const { publicKey: publicKey, secretKey } = this.apiKeyParts; | ||
const signature = (0, signature_1.generateHmacSignature)(body, secretKey); | ||
return [body, signature, publicKey]; | ||
return { body, signature, publicKey }; | ||
} | ||
@@ -101,0 +102,0 @@ /** |
{ | ||
"name": "@relaybox/rest", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "RelayBox REST Services SDK. Enables seemless integration between server-side applications and RelayBox's authentication and realtime services. It provides robust functionality for generating authentication tokens, publishing events, and interacting efficiently with RelayBox's suite of services.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
33481
601