@webex/contact-center 3.12.0-webex-services-ready.4 → 3.13.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.
Files changed (250) hide show
  1. package/.sdd/manifest.json +24 -13
  2. package/ai-docs/ARCHITECTURE.md +1 -1
  3. package/ai-docs/CONTRACTS.md +19 -3
  4. package/ai-docs/SECURITY.md +1 -1
  5. package/ai-docs/SERVICE_STATE.md +4 -0
  6. package/ai-docs/contact-center-spec.md +50 -6
  7. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  8. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  9. package/dist/cc.js +757 -22
  10. package/dist/cc.js.map +1 -1
  11. package/dist/config.js +7 -0
  12. package/dist/config.js.map +1 -1
  13. package/dist/constants.js +23 -2
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.js +34 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/metrics/MetricsManager.js +16 -0
  18. package/dist/metrics/MetricsManager.js.map +1 -1
  19. package/dist/metrics/behavioral-events.js +110 -0
  20. package/dist/metrics/behavioral-events.js.map +1 -1
  21. package/dist/metrics/constants.js +33 -0
  22. package/dist/metrics/constants.js.map +1 -1
  23. package/dist/services/AddressBook.js +18 -15
  24. package/dist/services/AddressBook.js.map +1 -1
  25. package/dist/services/AnswerCallOnWebexService.js +202 -0
  26. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  27. package/dist/services/ApiAiAssistant.js +221 -11
  28. package/dist/services/ApiAiAssistant.js.map +1 -1
  29. package/dist/services/EntryPoint.js +46 -68
  30. package/dist/services/EntryPoint.js.map +1 -1
  31. package/dist/services/Queue.js +27 -22
  32. package/dist/services/Queue.js.map +1 -1
  33. package/dist/services/WebCallingService.js +10 -2
  34. package/dist/services/WebCallingService.js.map +1 -1
  35. package/dist/services/WebexCrossClientService.js +225 -0
  36. package/dist/services/WebexCrossClientService.js.map +1 -0
  37. package/dist/services/WxAppTelephonyMercurySync.js +111 -0
  38. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  39. package/dist/services/config/Util.js +46 -46
  40. package/dist/services/config/Util.js.map +1 -1
  41. package/dist/services/config/constants.js +34 -77
  42. package/dist/services/config/constants.js.map +1 -1
  43. package/dist/services/config/index.js +100 -226
  44. package/dist/services/config/index.js.map +1 -1
  45. package/dist/services/config/types.js +51 -18
  46. package/dist/services/config/types.js.map +1 -1
  47. package/dist/services/constants.js +11 -1
  48. package/dist/services/constants.js.map +1 -1
  49. package/dist/services/core/Err.js.map +1 -1
  50. package/dist/services/core/Utils.js +25 -1
  51. package/dist/services/core/Utils.js.map +1 -1
  52. package/dist/services/core/WebexRequest.js +6 -2
  53. package/dist/services/core/WebexRequest.js.map +1 -1
  54. package/dist/services/core/aqm-reqs.js +17 -11
  55. package/dist/services/core/aqm-reqs.js.map +1 -1
  56. package/dist/services/core/constants.js +9 -1
  57. package/dist/services/core/constants.js.map +1 -1
  58. package/dist/services/core/types.js.map +1 -1
  59. package/dist/services/core/websocket/WebSocketManager.js +17 -1
  60. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  61. package/dist/services/task/Task.js +275 -8
  62. package/dist/services/task/Task.js.map +1 -1
  63. package/dist/services/task/TaskFactory.js +11 -6
  64. package/dist/services/task/TaskFactory.js.map +1 -1
  65. package/dist/services/task/TaskManager.js +590 -42
  66. package/dist/services/task/TaskManager.js.map +1 -1
  67. package/dist/services/task/TaskUtils.js +11 -1
  68. package/dist/services/task/TaskUtils.js.map +1 -1
  69. package/dist/services/task/WebexCallingUtils.js +70 -0
  70. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  71. package/dist/services/task/constants.js +14 -2
  72. package/dist/services/task/constants.js.map +1 -1
  73. package/dist/services/task/contact.js +29 -0
  74. package/dist/services/task/contact.js.map +1 -1
  75. package/dist/services/task/digital/Digital.js +4 -3
  76. package/dist/services/task/digital/Digital.js.map +1 -1
  77. package/dist/services/task/state-machine/TaskStateMachine.js +162 -53
  78. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
  79. package/dist/services/task/state-machine/actions.js +6 -1
  80. package/dist/services/task/state-machine/actions.js.map +1 -1
  81. package/dist/services/task/state-machine/guards.js +7 -10
  82. package/dist/services/task/state-machine/guards.js.map +1 -1
  83. package/dist/services/task/state-machine/types.js.map +1 -1
  84. package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
  85. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
  86. package/dist/services/task/types.js +47 -1
  87. package/dist/services/task/types.js.map +1 -1
  88. package/dist/services/task/voice/Voice.js +477 -17
  89. package/dist/services/task/voice/Voice.js.map +1 -1
  90. package/dist/services/task/voice/WebRTC.js +6 -3
  91. package/dist/services/task/voice/WebRTC.js.map +1 -1
  92. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  93. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  94. package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
  95. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  96. package/dist/services/wxAppDiagnosticLogging.js +159 -0
  97. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  98. package/dist/services/wxAppTelephonyUtils.js +19 -0
  99. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  100. package/dist/types/cc.d.ts +102 -8
  101. package/dist/types/config.d.ts +7 -0
  102. package/dist/types/constants.d.ts +21 -0
  103. package/dist/types/index.d.ts +34 -15
  104. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  105. package/dist/types/metrics/constants.d.ts +31 -0
  106. package/dist/types/services/AddressBook.d.ts +2 -1
  107. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  108. package/dist/types/services/ApiAiAssistant.d.ts +48 -4
  109. package/dist/types/services/EntryPoint.d.ts +7 -5
  110. package/dist/types/services/Queue.d.ts +5 -3
  111. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  112. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  113. package/dist/types/services/config/Util.d.ts +4 -8
  114. package/dist/types/services/config/constants.d.ts +28 -76
  115. package/dist/types/services/config/index.d.ts +16 -64
  116. package/dist/types/services/config/types.d.ts +146 -173
  117. package/dist/types/services/constants.d.ts +9 -0
  118. package/dist/types/services/core/Err.d.ts +2 -0
  119. package/dist/types/services/core/Utils.d.ts +10 -0
  120. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  121. package/dist/types/services/core/constants.d.ts +7 -0
  122. package/dist/types/services/core/types.d.ts +2 -0
  123. package/dist/types/services/task/Task.d.ts +34 -5
  124. package/dist/types/services/task/TaskFactory.d.ts +4 -2
  125. package/dist/types/services/task/TaskUtils.d.ts +6 -0
  126. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  127. package/dist/types/services/task/constants.d.ts +12 -0
  128. package/dist/types/services/task/contact.d.ts +4 -0
  129. package/dist/types/services/task/digital/Digital.d.ts +4 -3
  130. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +304 -56
  131. package/dist/types/services/task/state-machine/guards.d.ts +6 -5
  132. package/dist/types/services/task/state-machine/types.d.ts +9 -1
  133. package/dist/types/services/task/types.d.ts +192 -5
  134. package/dist/types/services/task/voice/Voice.d.ts +68 -11
  135. package/dist/types/services/task/voice/WebRTC.d.ts +5 -4
  136. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  137. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
  138. package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
  139. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  140. package/dist/types/types.d.ts +80 -13
  141. package/dist/types/utils/PageCache.d.ts +20 -3
  142. package/dist/types.js +54 -8
  143. package/dist/types.js.map +1 -1
  144. package/dist/utils/PageCache.js +19 -5
  145. package/dist/utils/PageCache.js.map +1 -1
  146. package/dist/webex.js +9 -1
  147. package/dist/webex.js.map +1 -1
  148. package/package.json +10 -9
  149. package/src/cc.ts +969 -38
  150. package/src/config.ts +7 -0
  151. package/src/constants.ts +24 -0
  152. package/src/index.ts +39 -10
  153. package/src/metrics/MetricsManager.ts +16 -0
  154. package/src/metrics/ai-docs/metrics-spec.md +138 -21
  155. package/src/metrics/behavioral-events.ts +112 -0
  156. package/src/metrics/constants.ts +36 -0
  157. package/src/services/AddressBook.ts +17 -6
  158. package/src/services/AnswerCallOnWebexService.ts +239 -0
  159. package/src/services/ApiAiAssistant.ts +297 -13
  160. package/src/services/EntryPoint.ts +59 -60
  161. package/src/services/Queue.ts +29 -12
  162. package/src/services/WebCallingService.ts +16 -2
  163. package/src/services/WebexCrossClientService.ts +298 -0
  164. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  165. package/src/services/agent/ai-docs/AGENTS.md +1 -1
  166. package/src/services/agent/ai-docs/agent-spec.md +1 -0
  167. package/src/services/ai-docs/AGENTS.md +10 -10
  168. package/src/services/ai-docs/services-spec.md +25 -5
  169. package/src/services/config/Util.ts +52 -82
  170. package/src/services/config/ai-docs/AGENTS.md +35 -40
  171. package/src/services/config/ai-docs/ARCHITECTURE.md +90 -103
  172. package/src/services/config/ai-docs/config-spec.md +132 -132
  173. package/src/services/config/constants.ts +39 -85
  174. package/src/services/config/index.ts +116 -277
  175. package/src/services/config/types.ts +140 -195
  176. package/src/services/constants.ts +10 -0
  177. package/src/services/core/Err.ts +1 -0
  178. package/src/services/core/Utils.ts +28 -0
  179. package/src/services/core/WebexRequest.ts +3 -1
  180. package/src/services/core/ai-docs/core-spec.md +25 -11
  181. package/src/services/core/aqm-reqs.ts +18 -12
  182. package/src/services/core/constants.ts +8 -0
  183. package/src/services/core/types.ts +33 -1
  184. package/src/services/core/websocket/WebSocketManager.ts +26 -2
  185. package/src/services/task/Task.ts +386 -12
  186. package/src/services/task/TaskFactory.ts +33 -6
  187. package/src/services/task/TaskManager.ts +857 -41
  188. package/src/services/task/TaskUtils.ts +13 -0
  189. package/src/services/task/WebexCallingUtils.ts +136 -0
  190. package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
  191. package/src/services/task/ai-docs/task-spec.md +190 -8
  192. package/src/services/task/constants.ts +13 -0
  193. package/src/services/task/contact.ts +30 -0
  194. package/src/services/task/digital/Digital.ts +11 -4
  195. package/src/services/task/state-machine/TaskStateMachine.ts +235 -81
  196. package/src/services/task/state-machine/actions.ts +5 -2
  197. package/src/services/task/state-machine/ai-docs/AGENTS.md +6 -4
  198. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +35 -16
  199. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +103 -33
  200. package/src/services/task/state-machine/guards.ts +7 -10
  201. package/src/services/task/state-machine/types.ts +16 -1
  202. package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
  203. package/src/services/task/types.ts +269 -4
  204. package/src/services/task/voice/Voice.ts +625 -17
  205. package/src/services/task/voice/WebRTC.ts +11 -4
  206. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  207. package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
  208. package/src/services/wxAppDiagnosticLogging.ts +286 -0
  209. package/src/services/wxAppTelephonyUtils.ts +14 -0
  210. package/src/types.ts +108 -13
  211. package/src/utils/AGENTS.md +21 -10
  212. package/src/utils/PageCache.ts +38 -5
  213. package/src/utils/ai-docs/utils-spec.md +21 -11
  214. package/src/webex.js +8 -0
  215. package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
  216. package/test/unit/spec/cc.ts +3408 -152
  217. package/test/unit/spec/index.ts +885 -0
  218. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  219. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  220. package/test/unit/spec/services/AddressBook.ts +37 -6
  221. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  222. package/test/unit/spec/services/ApiAiAssistant.ts +269 -8
  223. package/test/unit/spec/services/EntryPoint.ts +87 -40
  224. package/test/unit/spec/services/Queue.ts +123 -12
  225. package/test/unit/spec/services/WebCallingService.ts +38 -0
  226. package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
  227. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  228. package/test/unit/spec/services/config/Util.ts +501 -0
  229. package/test/unit/spec/services/config/index.ts +313 -543
  230. package/test/unit/spec/services/core/Utils.ts +22 -0
  231. package/test/unit/spec/services/core/WebexRequest.ts +8 -7
  232. package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
  233. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +64 -14
  234. package/test/unit/spec/services/task/Task.ts +2257 -11
  235. package/test/unit/spec/services/task/TaskFactory.ts +56 -2
  236. package/test/unit/spec/services/task/TaskManager.ts +5559 -1493
  237. package/test/unit/spec/services/task/TaskUtils.ts +72 -0
  238. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  239. package/test/unit/spec/services/task/contact.ts +33 -0
  240. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1501 -92
  241. package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
  242. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
  243. package/test/unit/spec/services/task/voice/Voice.ts +1710 -4
  244. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  245. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
  246. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
  247. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  248. package/typedoc.md +1 -1
  249. package/umd/contact-center.min.js +2 -2
  250. package/umd/contact-center.min.js.map +1 -1
@@ -1036,4 +1036,26 @@ describe('Utils', () => {
1036
1036
  });
1037
1037
  });
1038
1038
 
1039
+ describe('isAllowedUrlHost', () => {
1040
+ it('returns true when the hostname exactly matches an allowed domain', () => {
1041
+ expect(Utils.isAllowedUrlHost('wss://cisco.com', ['cisco.com'])).toBe(true);
1042
+ });
1043
+
1044
+ it('returns true when the hostname is a subdomain of an allowed domain', () => {
1045
+ expect(Utils.isAllowedUrlHost('wss://notifs.wxcc-us1.cisco.com', ['cisco.com'])).toBe(true);
1046
+ });
1047
+
1048
+ it('returns false when the hostname is not in the allowed domains list', () => {
1049
+ expect(Utils.isAllowedUrlHost('wss://evil.attacker.com', ['cisco.com'])).toBe(false);
1050
+ });
1051
+
1052
+ it('returns false for an unparsable url', () => {
1053
+ expect(Utils.isAllowedUrlHost('not-a-url', ['cisco.com'])).toBe(false);
1054
+ });
1055
+
1056
+ it('returns false for a null/undefined url', () => {
1057
+ expect(Utils.isAllowedUrlHost(null as any, ['cisco.com'])).toBe(false);
1058
+ expect(Utils.isAllowedUrlHost(undefined as any, ['cisco.com'])).toBe(false);
1059
+ });
1060
+ });
1039
1061
  });
@@ -51,6 +51,7 @@ describe('WebexRequest', () => {
51
51
  resource: 'resource',
52
52
  method: HTTP_METHODS.POST,
53
53
  body: { key: 'value' },
54
+ headers: {'x-test-header': 'test-value'},
54
55
  });
55
56
 
56
57
  expect(result).toEqual(mockResponse);
@@ -59,6 +60,7 @@ describe('WebexRequest', () => {
59
60
  resource: 'resource',
60
61
  method: HTTP_METHODS.POST,
61
62
  body: { key: 'value' },
63
+ headers: {'x-test-header': 'test-value'},
62
64
  });
63
65
  });
64
66
 
@@ -89,9 +91,8 @@ describe('WebexRequest', () => {
89
91
  trackEvent: jest.fn(),
90
92
  timeEvent: jest.fn(),
91
93
  };
92
-
94
+
93
95
  jest.spyOn(MetricsManager, 'getInstance').mockReturnValue(mockMetricsManager);
94
-
95
96
  });
96
97
 
97
98
  it('should upload logs and return the response', async () => {
@@ -112,8 +113,8 @@ describe('WebexRequest', () => {
112
113
  {module: WEBEX_REQUEST_FILE, method: 'uploadLogs'}
113
114
  );
114
115
  expect(mockMetricsManager.trackEvent).toBeCalledWith(
115
- "Upload Logs Success",
116
- {feedbackId: "mocked-uuid-12345", trackingId: '1234'},
116
+ "Upload Logs Success",
117
+ {feedbackId: "mocked-uuid-12345", trackingId: '1234'},
117
118
  ["behavioral"]
118
119
  );
119
120
  expect(mockWebex.internal.support.submitLogs).toHaveBeenCalledWith({... mockMetaData, feedbackId: "mocked-uuid-12345"}, undefined, {type: 'diff'});
@@ -135,10 +136,10 @@ describe('WebexRequest', () => {
135
136
  {module: WEBEX_REQUEST_FILE, method: 'uploadLogs'}
136
137
  );
137
138
  expect(mockMetricsManager.trackEvent).toBeCalledWith(
138
- "Upload Logs Failed",
139
- {stack: "My stack", feedbackId: "mocked-uuid-12345", correlationId: 'correlation-id'},
139
+ "Upload Logs Failed",
140
+ {stack: "My stack", feedbackId: "mocked-uuid-12345", correlationId: 'correlation-id'},
140
141
  ["behavioral"]
141
142
  );
142
143
  });
143
144
  });
144
- });
145
+ });
@@ -334,6 +334,28 @@ describe('AqmReqs', () => {
334
334
  });
335
335
 
336
336
  describe('Event tests', () => {
337
+ const participantDropConfig = (participantId: string, timeout?: number | 'disabled') => ({
338
+ host: 'fake-host',
339
+ url: `/v1/tasks/interaction/conference/participants/${participantId}/drop`,
340
+ data: {},
341
+ timeout,
342
+ redactSensitiveLogs: true,
343
+ err: (error: any) => error,
344
+ notifSuccess: {
345
+ bind: {
346
+ type: 'RoutingMessage',
347
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
348
+ },
349
+ },
350
+ notifFail: {
351
+ bind: {
352
+ type: 'RoutingMessage',
353
+ data: {type: 'ParticipantDropConferenceFailed'},
354
+ },
355
+ errId: 'Service.aqm.task.dropConferenceParticipant' as const,
356
+ },
357
+ });
358
+
337
359
  it('should handle onMessage events', async () => {
338
360
  webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
339
361
 
@@ -564,5 +586,124 @@ describe('AqmReqs', () => {
564
586
  const result = await promise;
565
587
  expect(result).toEqual(eventData);
566
588
  });
589
+
590
+ it('redacts sensitive routing failure payloads from logs', async () => {
591
+ const participantId = '+1/failure-secret';
592
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
593
+ const promise = aqm['createPromise'](participantDropConfig(participantId, 'disabled'));
594
+
595
+ webSocketManagerInstance.emit(
596
+ 'message',
597
+ JSON.stringify({
598
+ type: 'RoutingMessage',
599
+ data: {type: 'ParticipantDropConferenceFailed', participantId},
600
+ })
601
+ );
602
+
603
+ await expect(promise).rejects.toBeDefined();
604
+ expect(LoggerProxy.log).toHaveBeenCalledTimes(1);
605
+ expect(LoggerProxy.log).toHaveBeenCalledWith(
606
+ 'Routing request failed (sensitive details redacted)',
607
+ expect.objectContaining({module: AQM_REQS_FILE})
608
+ );
609
+ expect(JSON.stringify((LoggerProxy.log as jest.Mock).mock.calls)).not.toContain(participantId);
610
+ expect(aqm['pendingRequests']).toEqual({});
611
+ });
612
+
613
+ it('never logs the raw routing-failure payload even when redactSensitiveLogs is not set', async () => {
614
+ const participantId = '+1/plain-failure-secret';
615
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
616
+ const conf = {
617
+ ...participantDropConfig(participantId, 'disabled'),
618
+ redactSensitiveLogs: false,
619
+ };
620
+ const promise = aqm['createPromise'](conf);
621
+
622
+ webSocketManagerInstance.emit(
623
+ 'message',
624
+ JSON.stringify({
625
+ type: 'RoutingMessage',
626
+ data: {type: 'ParticipantDropConferenceFailed', participantId},
627
+ })
628
+ );
629
+
630
+ await expect(promise).rejects.toBeDefined();
631
+ expect(LoggerProxy.log).toHaveBeenCalledWith(
632
+ 'Routing request failed (sensitive details redacted)',
633
+ expect.objectContaining({module: AQM_REQS_FILE})
634
+ );
635
+
636
+ const loggedCalls = JSON.stringify((LoggerProxy.log as jest.Mock).mock.calls);
637
+ expect(loggedCalls).not.toContain(participantId);
638
+ expect(loggedCalls).not.toContain('ParticipantDropConferenceFailed');
639
+ expect(aqm['pendingRequests']).toEqual({});
640
+ });
641
+
642
+ it('resolves a correlated participant-left event and clears its binds', async () => {
643
+ jest.useFakeTimers();
644
+ (global.window as any).setTimeout = global.setTimeout;
645
+
646
+ try {
647
+ const participantId = '+1/success-secret';
648
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
649
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
650
+ const eventData = {
651
+ type: 'RoutingMessage',
652
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
653
+ };
654
+
655
+ webSocketManagerInstance.emit('message', JSON.stringify(eventData));
656
+
657
+ await expect(promise).resolves.toEqual(eventData);
658
+ expect(aqm['pendingRequests']).toEqual({});
659
+ } finally {
660
+ jest.useRealTimers();
661
+ (global.window as any).setTimeout = global.setTimeout;
662
+ }
663
+ });
664
+
665
+ it('clears participant Drop binds after an HTTP failure without logging sensitive data', async () => {
666
+ jest.useFakeTimers();
667
+ (global.window as any).setTimeout = global.setTimeout;
668
+
669
+ try {
670
+ const participantId = '+1/http-secret';
671
+ const httpFailure = {headers: {Authorization: 'Bearer secret'}};
672
+ webexRequestInstance.request.mockRejectedValueOnce(httpFailure);
673
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
674
+
675
+ await expect(promise).rejects.toBe(httpFailure);
676
+ expect(aqm['pendingRequests']).toEqual({});
677
+ expect(JSON.stringify([
678
+ (LoggerProxy.log as jest.Mock).mock.calls,
679
+ (LoggerProxy.error as jest.Mock).mock.calls,
680
+ ])).not.toContain(participantId);
681
+ expect(httpFailure.headers.Authorization).toBe('*');
682
+ } finally {
683
+ jest.useRealTimers();
684
+ (global.window as any).setTimeout = global.setTimeout;
685
+ }
686
+ });
687
+
688
+ it('uses the default timeout without logging a sensitive request URL', async () => {
689
+ jest.useFakeTimers();
690
+ (global.window as any).setTimeout = global.setTimeout;
691
+
692
+ try {
693
+ const participantId = '+1/timeout-secret';
694
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
695
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
696
+ const rejection = expect(promise).rejects.toBeDefined();
697
+
698
+ jest.advanceTimersByTime(20000);
699
+
700
+ await rejection;
701
+ expect(JSON.stringify((LoggerProxy.error as jest.Mock).mock.calls)).not.toContain(participantId);
702
+ expect(aqm['pendingRequests']).toEqual({});
703
+ } finally {
704
+ jest.useRealTimers();
705
+ (global.window as any).setTimeout = global.setTimeout;
706
+ }
707
+ });
567
708
  });
568
- });
709
+ });
@@ -94,7 +94,9 @@ describe('WebSocketManager', () => {
94
94
  };
95
95
 
96
96
  global.Worker = jest.fn(() => mockWorker) as any;
97
- global.WebSocket = MockWebSocket as any;
97
+ global.WebSocket = jest.fn(function (this: any, ...args: any[]) {
98
+ return new MockWebSocket(...(args as []));
99
+ }) as any;
98
100
 
99
101
  global.Blob = function (content: any[], options: any) {
100
102
  return {content, options};
@@ -119,10 +121,58 @@ describe('WebSocketManager', () => {
119
121
  expect(webSocketManager).toBeDefined();
120
122
  });
121
123
 
124
+ describe('webSocketUrl validation', () => {
125
+ it('rejects a non-wss webSocketUrl and does not construct a socket', async () => {
126
+ const subscribeResponse = {
127
+ body: {
128
+ webSocketUrl: 'http://fake-url.cisco.com',
129
+ },
130
+ };
131
+
132
+ (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
133
+
134
+ await expect(
135
+ webSocketManager.initWebSocket({body: fakeSubscribeRequest, resource: SUBSCRIBE_API})
136
+ ).rejects.toBeDefined();
137
+
138
+ expect(global.WebSocket).not.toHaveBeenCalled();
139
+ });
140
+
141
+ it('rejects a wss webSocketUrl with a non-allow-listed host and does not construct a socket', async () => {
142
+ const subscribeResponse = {
143
+ body: {
144
+ webSocketUrl: 'wss://evil.attacker.com',
145
+ },
146
+ };
147
+
148
+ (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
149
+
150
+ await expect(
151
+ webSocketManager.initWebSocket({body: fakeSubscribeRequest, resource: SUBSCRIBE_API})
152
+ ).rejects.toBeDefined();
153
+
154
+ expect(global.WebSocket).not.toHaveBeenCalled();
155
+ });
156
+
157
+ it('connects for a valid wss allow-listed webSocketUrl', async () => {
158
+ const subscribeResponse = {
159
+ body: {
160
+ webSocketUrl: 'wss://notifs.wxcc-us1.cisco.com',
161
+ },
162
+ };
163
+
164
+ (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
165
+
166
+ await webSocketManager.initWebSocket({body: fakeSubscribeRequest, resource: SUBSCRIBE_API});
167
+
168
+ expect(global.WebSocket).toHaveBeenCalledWith('wss://notifs.wxcc-us1.cisco.com');
169
+ });
170
+ });
171
+
122
172
  it('should register and connect to WebSocket with X-ORGANIZATION-ID header for INT environment', async () => {
123
173
  const subscribeResponse = {
124
174
  body: {
125
- webSocketUrl: 'wss://fake-url',
175
+ webSocketUrl: 'wss://fake-url.cisco.com',
126
176
  },
127
177
  };
128
178
 
@@ -144,7 +194,7 @@ describe('WebSocketManager', () => {
144
194
  it('should connect rtd websocket', async () => {
145
195
  const subscribeResponse = {
146
196
  body: {
147
- webSocketUrl: 'wss://fake-url',
197
+ webSocketUrl: 'wss://fake-url.cisco.com',
148
198
  },
149
199
  };
150
200
 
@@ -167,7 +217,7 @@ describe('WebSocketManager', () => {
167
217
  it('should register and connect to WebSocket without X-ORGANIZATION-ID header for production environment', async () => {
168
218
  const subscribeResponse = {
169
219
  body: {
170
- webSocketUrl: 'wss://fake-url',
220
+ webSocketUrl: 'wss://fake-url.cisco.com',
171
221
  },
172
222
  };
173
223
  // Mock production environment (services.isIntegrationEnvironment returns false)
@@ -196,7 +246,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
196
246
  it('should not send X-ORGANIZATION-ID header when services.isIntegrationEnvironment is not available', async () => {
197
247
  const subscribeResponse = {
198
248
  body: {
199
- webSocketUrl: 'wss://fake-url',
249
+ webSocketUrl: 'wss://fake-url.cisco.com',
200
250
  },
201
251
  };
202
252
 
@@ -245,7 +295,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
245
295
  it('should close WebSocket connection', async () => {
246
296
  const subscribeResponse = {
247
297
  body: {
248
- webSocketUrl: 'wss://fake-url',
298
+ webSocketUrl: 'wss://fake-url.cisco.com',
249
299
  },
250
300
  };
251
301
 
@@ -262,7 +312,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
262
312
  it('should handle WebSocket keepalive messages', async () => {
263
313
  const subscribeResponse = {
264
314
  body: {
265
- webSocketUrl: 'wss://fake-url',
315
+ webSocketUrl: 'wss://fake-url.cisco.com',
266
316
  },
267
317
  };
268
318
 
@@ -286,7 +336,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
286
336
  it('should handle WebSocket close due to network issue', async () => {
287
337
  const subscribeResponse = {
288
338
  body: {
289
- webSocketUrl: 'wss://fake-url',
339
+ webSocketUrl: 'wss://fake-url.cisco.com',
290
340
  },
291
341
  };
292
342
 
@@ -333,7 +383,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
333
383
  it('should handle WebSocket error event', async () => {
334
384
  const subscribeResponse = {
335
385
  body: {
336
- webSocketUrl: 'wss://fake-url',
386
+ webSocketUrl: 'wss://fake-url.cisco.com',
337
387
  },
338
388
  };
339
389
 
@@ -353,7 +403,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
353
403
  it('should handle WebSocket message event with AGENT_MULTI_LOGIN', async () => {
354
404
  const subscribeResponse = {
355
405
  body: {
356
- webSocketUrl: 'wss://fake-url',
406
+ webSocketUrl: 'wss://fake-url.cisco.com',
357
407
  },
358
408
  };
359
409
 
@@ -376,7 +426,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
376
426
  it('should handle WebSocket message event with Welcome', async () => {
377
427
  const subscribeResponse = {
378
428
  body: {
379
- webSocketUrl: 'wss://fake-url',
429
+ webSocketUrl: 'wss://fake-url.cisco.com',
380
430
  },
381
431
  };
382
432
 
@@ -395,7 +445,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
395
445
  it('should handle WebSocket close with forceCloseWebSocketOnTimeout', async () => {
396
446
  const subscribeResponse = {
397
447
  body: {
398
- webSocketUrl: 'wss://fake-url',
448
+ webSocketUrl: 'wss://fake-url.cisco.com',
399
449
  },
400
450
  };
401
451
 
@@ -430,7 +480,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
430
480
  it('should handle WebSocket close without reconnect', async () => {
431
481
  const subscribeResponse = {
432
482
  body: {
433
- webSocketUrl: 'wss://fake-url',
483
+ webSocketUrl: 'wss://fake-url.cisco.com',
434
484
  },
435
485
  };
436
486
 
@@ -460,7 +510,7 @@ it('should register and connect to WebSocket without X-ORGANIZATION-ID header fo
460
510
  it('should handle WebSocket close with clean close', async () => {
461
511
  const subscribeResponse = {
462
512
  body: {
463
- webSocketUrl: 'wss://fake-url',
513
+ webSocketUrl: 'wss://fake-url.cisco.com',
464
514
  },
465
515
  };
466
516