Skip to content

Commit f7765cf

Browse files
author
Aidan Zimmermann
committed
STREAM-777: resolve merge conflict
2 parents 5681697 + 3d567e6 commit f7765cf

11 files changed

Lines changed: 200 additions & 8 deletions

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
# [Unreleased](https://github.com/MyPureCloud/genesys-cloud-webrtc-sdk/compare/v11.3.2...HEAD)
6+
# [Unreleased](https://github.com/MyPureCloud/genesys-cloud-webrtc-sdk/compare/v11.3.3...HEAD)
7+
8+
# [v11.3.3](https://github.com/MyPureCloud/genesys-cloud-webrtc-sdk/compare/v11.3.2...v11.3.3)
9+
#### Changed
10+
* [#937] - Exposes raw webmessage data from conversation topic
711

812
# [v11.3.2](https://github.com/MyPureCloud/genesys-cloud-webrtc-sdk/compare/v11.3.1...v11.3.2)
913
### Changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "genesys-cloud-webrtc-sdk",
3-
"version": "11.3.2",
3+
"version": "11.3.3",
44
"description": "client for the interfacing with Genesys Cloud WebRTC",
55
"repository": "https://github.com/mypurecloud/genesys-cloud-webrtc-sdk",
66
"license": "MIT",

src/client-private.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export async function proxyStreamingClientEvents (this: GenesysCloudWebrtcSdk):
113113
export const handleConversationUpdate = function (this: GenesysCloudWebrtcSdk, updateEvent: SubscriptionEvent) {
114114
const update = new ConversationUpdate(updateEvent.eventBody);
115115
this.sessionManager.handleConversationUpdate(update);
116+
this.sessionManager.handleConversationUpdateRaw(updateEvent);
116117
};
117118

118119
export const handleDisconnectedEvent = function (this: GenesysCloudWebrtcSdk, eventData: { reconnecting: boolean }) {

src/sessions/base-session-handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
IUpdateOutgoingMedia,
1818
IConversationHeldRequest,
1919
IActiveConversationDescription,
20+
SubscriptionEvent,
2021
} from '../types/interfaces';
2122

2223
type ExtendedHTMLAudioElement = HTMLAudioElement & {
@@ -46,6 +47,10 @@ export default abstract class BaseSessionHandler {
4647

4748
abstract handleConversationUpdate (update: ConversationUpdate, sessions: IExtendedMediaSession[]): void;
4849

50+
handleConversationUpdateRaw (update: SubscriptionEvent): void {
51+
this.sdk.emit('conversationUpdateRaw', update);
52+
}
53+
4954
protected log (level: LogLevels, message: any, details?: any, logOptions?: ILogMessageOptions): void {
5055
this.sdk.logger[level].call(this.sdk.logger, message, details, logOptions);
5156
}

src/sessions/session-manager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
IConversationHeldRequest,
2222
IPendingSessionActionParams,
2323
VideoMediaSession,
24-
IActiveConversationDescription, IStartScreenConferenceSessionParams
24+
IActiveConversationDescription, IStartScreenConferenceSessionParams,
25+
SubscriptionEvent
2526
} from '../types/interfaces';
2627
import { ConversationUpdate } from '../conversations/conversation-update';
2728
import { SessionTypesAsStrings } from 'genesys-cloud-streaming-client';
@@ -76,6 +77,15 @@ export class SessionManager {
7677
);
7778
}
7879

80+
handleConversationUpdateRaw (update: SubscriptionEvent): void {
81+
/* let each enabled handler process updates */
82+
this.sessionHandlers
83+
.filter(handler => !handler.disabled)
84+
.forEach(handler =>
85+
handler.handleConversationUpdateRaw(update)
86+
);
87+
}
88+
7989
getPendingSession (params: { conversationId?: string, sessionId?: string, sessionType?: SessionTypes | SessionTypesAsStrings }): IPendingSession | undefined {
8090
const session = this.pendingSessions
8191
.find(s => {

src/types/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ export interface SdkEvents {
10201020
handledPendingSession: ISessionIdAndConversationId;
10211021
cancelPendingSession: ISessionIdAndConversationId;
10221022
conversationUpdate: ISdkConversationUpdateEvent;
1023+
conversationUpdateRaw: SubscriptionEvent;
10231024
station: (event: { action: 'Associated' | 'Disassociated', station: IStation | null }) => void;
10241025
concurrentSoftphoneSessionsEnabled: boolean; // lineAppearence > 1
10251026
resolutionUpdated: IResolutionChange

test/unit/client-private.test.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ describe('setupStreamingClient', () => {
8989

9090
describe('handleConversationUpdate', () => {
9191
it('should call sessionManager.handleConversationUpdate with the transformed event', () => {
92-
mockSdk.sessionManager = { handleConversationUpdate: jest.fn() } as any;
93-
92+
mockSdk.sessionManager = { handleConversationUpdateRaw: jest.fn(), handleConversationUpdate: jest.fn() } as any;
93+
9494
const userId = '444kjskdk';
9595
const participant1 = {
9696
id: '7b809e10-fb79-4420-9d5f-69d232ddf490',
@@ -146,6 +146,65 @@ describe('handleConversationUpdate', () => {
146146
});
147147
});
148148

149+
describe('handleConversationUpdateRaw', () => {
150+
it('should call sessionManager.handleConversationUpdateRaw with the event', () => {
151+
mockSdk.sessionManager = { handleConversationUpdateRaw: jest.fn(), handleConversationUpdate: jest.fn() } as any;
152+
153+
const userId = '444kjskdk';
154+
const participant1 = {
155+
id: '7b809e10-fb79-4420-9d5f-69d232ddf490',
156+
userId: 'dad93e0d-31fa-4fd2-8fc4-d9d3f214ddcf',
157+
purpose: 'user',
158+
videos: [
159+
{
160+
state: CommunicationStates.connected,
161+
id: '5e2bf9b8-c9d5-4975-b89b-756b6bd0b3d5',
162+
context: '5d1130ff978496186c5ce304@conference.test-valve-1ym37mj1kao.orgspan.com',
163+
audioMuted: false,
164+
videoMuted: true,
165+
sharingScreen: false,
166+
peerCount: 0
167+
}
168+
]
169+
};
170+
171+
const local = {
172+
id: '7sdffs-4420-9d5f-69d232ddf490',
173+
userId,
174+
purpose: 'user',
175+
videos: [
176+
{
177+
state: CommunicationStates.connected,
178+
id: '5e2bf9b855125-b89b-756b6bd0b3d5',
179+
context: '5d1130ff978496186c5ce304@conference.test-valve-1ym37mj1kao.orgspan.com',
180+
audioMuted: false,
181+
videoMuted: true,
182+
sharingScreen: false,
183+
peerCount: 0
184+
}
185+
]
186+
};
187+
188+
const event: SubscriptionEvent = {
189+
eventBody: {
190+
id: 'ff5a3ba2-373b-42c7-912a-5309a2656095',
191+
participants: [participant1, local]
192+
},
193+
metadata: {
194+
correlationId: '11l2k31j'
195+
},
196+
topicName: `v2.users.${userId}.coversations`
197+
};
198+
199+
handleConversationUpdate.call(mockSdk, event);
200+
201+
const spy = mockSdk.sessionManager.handleConversationUpdateRaw;
202+
expect(spy).toHaveBeenCalled();
203+
const arg = (spy as jest.Mock).mock.calls[0][0];
204+
expect(arg).toEqual(event);
205+
});
206+
});
207+
149208
describe('handleDisconnectedEvent', () => {
150209
it('should emit disconnected event with message and eventData', () => {
151210
const eventData = { reconnecting: true };

test/unit/client.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import {
2929
IStation,
3030
IPersonDetails,
3131
ISessionIdAndConversationId,
32+
<<<<<<< HEAD
3233
VideoSessionHandler, ScreenRecordingMetadata, IStartScreenConferenceSessionParams
34+
=======
35+
VideoSessionHandler
36+
>>>>>>> 3d567e61595d3f56241eb475ca863cd3f2204ec0
3337
} from '../../src';
3438
import * as utils from '../../src/utils';
3539
import { RetryPromise } from 'genesys-cloud-streaming-client/dist/es/utils';
@@ -329,6 +333,80 @@ describe('Client', () => {
329333
expect(sessionManagerMock.startSession).not.toHaveBeenCalled();
330334
}
331335
});
336+
337+
it('should allow video conference with JWT authentication', async () => {
338+
const testJwt = 'test.jwt.token';
339+
sdk = constructSdk({ jwt: testJwt });
340+
341+
sdk._personDetails = {
342+
id: 'test-user-id',
343+
name: 'Test User',
344+
chat: {
345+
jabberId: 'test-user@test.com'
346+
}
347+
};
348+
349+
sessionManagerMock.startSession.mockResolvedValue({});
350+
await sdk.startVideoConference('test-room@conference.com');
351+
352+
expect(sessionManagerMock.startSession).toBeCalledWith({
353+
jid: 'test-room@conference.com',
354+
sessionType: SessionTypes.collaborateVideo
355+
});
356+
});
357+
358+
it('should include JWT in video session request', async () => {
359+
const testJwt = 'test.jwt.token';
360+
const mockDecodedJwt = {
361+
data: {
362+
jid: 'test-user@test.com',
363+
conversationId: 'test-conversation-id',
364+
sourceCommunicationId: 'test-source-comm-id'
365+
}
366+
};
367+
368+
jwtDecodeSpy.mockReturnValue(mockDecodedJwt);
369+
370+
sdk = constructSdk({ jwt: testJwt });
371+
const handler = new VideoSessionHandler(sdk, sessionManagerMock);
372+
373+
sdk._personDetails = {
374+
id: 'test-user-id',
375+
name: 'Test User',
376+
chat: {
377+
jabberId: 'test-user@test.com'
378+
}
379+
};
380+
381+
const mockInitiateRtcSession = jest.fn().mockResolvedValue(undefined);
382+
sdk._streamingConnection = {
383+
webrtcSessions: {
384+
initiateRtcSession: mockInitiateRtcSession
385+
},
386+
disconnect: jest.fn().mockResolvedValue(undefined)
387+
} as any;
388+
389+
const requestApiSpy = jest.spyOn(utils, 'requestApi');
390+
391+
const result = await handler.startSession({
392+
jid: 'test-room@conference.com',
393+
sessionType: SessionTypes.collaborateVideo
394+
});
395+
396+
expect(mockInitiateRtcSession).toHaveBeenCalledWith({
397+
jid: mockDecodedJwt.data.jid,
398+
conversationId: mockDecodedJwt.data.conversationId,
399+
sourceCommunicationId: mockDecodedJwt.data.sourceCommunicationId,
400+
mediaPurpose: SessionTypes.collaborateVideo,
401+
sessionType: SessionTypes.collaborateVideo
402+
});
403+
404+
expect(result).toEqual({
405+
conversationId: mockDecodedJwt.data.conversationId
406+
});
407+
408+
expect(requestApiSpy).not.toHaveBeenCalled();
409+
});
332410
});
333411

334412
describe('startLiveMonitoringSession()', () => {

test/unit/sessions/base-session-handler.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ describe('handleConversationUpdate', () => {
466466
it('nothing to test', () => {
467467
handler.handleConversationUpdate({} as any, {} as any);
468468
});
469+
it('nothing to test', () => {
470+
handler.handleConversationUpdateRaw({} as any);
471+
});
469472
});
470473

471474
describe('handlePropose', () => {

0 commit comments

Comments
 (0)