@webex/contact-center 3.12.0 → 3.13.0-next.10

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 (297) hide show
  1. package/.repo-context.json +704 -0
  2. package/.sdd/manifest.json +1613 -0
  3. package/AGENTS.md +969 -0
  4. package/dist/cc.js +1102 -47
  5. package/dist/cc.js.map +1 -1
  6. package/dist/config.js +13 -0
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +46 -3
  9. package/dist/constants.js.map +1 -1
  10. package/dist/index.js +86 -17
  11. package/dist/index.js.map +1 -1
  12. package/dist/metrics/MetricsManager.js +16 -0
  13. package/dist/metrics/MetricsManager.js.map +1 -1
  14. package/dist/metrics/behavioral-events.js +211 -0
  15. package/dist/metrics/behavioral-events.js.map +1 -1
  16. package/dist/metrics/constants.js +58 -4
  17. package/dist/metrics/constants.js.map +1 -1
  18. package/dist/services/AddressBook.js +18 -15
  19. package/dist/services/AddressBook.js.map +1 -1
  20. package/dist/services/AnswerCallOnWebexService.js +202 -0
  21. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  22. package/dist/services/ApiAiAssistant.js +369 -14
  23. package/dist/services/ApiAiAssistant.js.map +1 -1
  24. package/dist/services/EntryPoint.js +46 -68
  25. package/dist/services/EntryPoint.js.map +1 -1
  26. package/dist/services/Queue.js +27 -22
  27. package/dist/services/Queue.js.map +1 -1
  28. package/dist/services/UserPreference.js +427 -0
  29. package/dist/services/UserPreference.js.map +1 -0
  30. package/dist/services/WebCallingService.js +287 -37
  31. package/dist/services/WebCallingService.js.map +1 -1
  32. package/dist/services/WebexCrossClientService.js +225 -0
  33. package/dist/services/WebexCrossClientService.js.map +1 -0
  34. package/dist/services/WxAppTelephonyMercurySync.js +111 -0
  35. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  36. package/dist/services/config/Util.js +48 -48
  37. package/dist/services/config/Util.js.map +1 -1
  38. package/dist/services/config/constants.js +57 -79
  39. package/dist/services/config/constants.js.map +1 -1
  40. package/dist/services/config/index.js +100 -226
  41. package/dist/services/config/index.js.map +1 -1
  42. package/dist/services/config/types.js +100 -40
  43. package/dist/services/config/types.js.map +1 -1
  44. package/dist/services/constants.js +19 -1
  45. package/dist/services/constants.js.map +1 -1
  46. package/dist/services/core/Err.js.map +1 -1
  47. package/dist/services/core/Utils.js +131 -32
  48. package/dist/services/core/Utils.js.map +1 -1
  49. package/dist/services/core/WebexRequest.js +6 -2
  50. package/dist/services/core/WebexRequest.js.map +1 -1
  51. package/dist/services/core/aqm-reqs.js +17 -11
  52. package/dist/services/core/aqm-reqs.js.map +1 -1
  53. package/dist/services/core/constants.js +9 -1
  54. package/dist/services/core/constants.js.map +1 -1
  55. package/dist/services/core/types.js.map +1 -1
  56. package/dist/services/core/websocket/WebSocketManager.js +26 -6
  57. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  58. package/dist/services/core/websocket/connection-service.js +3 -1
  59. package/dist/services/core/websocket/connection-service.js.map +1 -1
  60. package/dist/services/core/websocket/types.js.map +1 -1
  61. package/dist/services/index.js +6 -0
  62. package/dist/services/index.js.map +1 -1
  63. package/dist/services/task/Task.js +955 -0
  64. package/dist/services/task/Task.js.map +1 -0
  65. package/dist/services/task/TaskFactory.js +50 -0
  66. package/dist/services/task/TaskFactory.js.map +1 -0
  67. package/dist/services/task/TaskManager.js +1275 -504
  68. package/dist/services/task/TaskManager.js.map +1 -1
  69. package/dist/services/task/TaskUtils.js +221 -27
  70. package/dist/services/task/TaskUtils.js.map +1 -1
  71. package/dist/services/task/WebexCallingUtils.js +70 -0
  72. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  73. package/dist/services/task/constants.js +22 -2
  74. package/dist/services/task/constants.js.map +1 -1
  75. package/dist/services/task/contact.js +29 -0
  76. package/dist/services/task/contact.js.map +1 -1
  77. package/dist/services/task/dialer.js +78 -0
  78. package/dist/services/task/dialer.js.map +1 -1
  79. package/dist/services/task/digital/Digital.js +78 -0
  80. package/dist/services/task/digital/Digital.js.map +1 -0
  81. package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
  82. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  83. package/dist/services/task/state-machine/actions.js +572 -0
  84. package/dist/services/task/state-machine/actions.js.map +1 -0
  85. package/dist/services/task/state-machine/constants.js +161 -0
  86. package/dist/services/task/state-machine/constants.js.map +1 -0
  87. package/dist/services/task/state-machine/guards.js +379 -0
  88. package/dist/services/task/state-machine/guards.js.map +1 -0
  89. package/dist/services/task/state-machine/index.js +53 -0
  90. package/dist/services/task/state-machine/index.js.map +1 -0
  91. package/dist/services/task/state-machine/types.js +54 -0
  92. package/dist/services/task/state-machine/types.js.map +1 -0
  93. package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
  94. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  95. package/dist/services/task/taskDataNormalizer.js +99 -0
  96. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  97. package/dist/services/task/types.js +259 -5
  98. package/dist/services/task/types.js.map +1 -1
  99. package/dist/services/task/voice/Voice.js +1504 -0
  100. package/dist/services/task/voice/Voice.js.map +1 -0
  101. package/dist/services/task/voice/WebRTC.js +152 -0
  102. package/dist/services/task/voice/WebRTC.js.map +1 -0
  103. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  104. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  105. package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
  106. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  107. package/dist/services/wxAppDiagnosticLogging.js +159 -0
  108. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  109. package/dist/services/wxAppTelephonyUtils.js +19 -0
  110. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  111. package/dist/types/cc.d.ts +222 -10
  112. package/dist/types/config.d.ts +13 -0
  113. package/dist/types/constants.d.ts +40 -1
  114. package/dist/types/index.d.ts +58 -22
  115. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  116. package/dist/types/metrics/constants.d.ts +52 -1
  117. package/dist/types/services/AddressBook.d.ts +2 -1
  118. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  119. package/dist/types/services/ApiAiAssistant.d.ts +67 -5
  120. package/dist/types/services/EntryPoint.d.ts +7 -5
  121. package/dist/types/services/Queue.d.ts +5 -3
  122. package/dist/types/services/UserPreference.d.ts +118 -0
  123. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  124. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  125. package/dist/types/services/config/Util.d.ts +4 -8
  126. package/dist/types/services/config/constants.d.ts +49 -76
  127. package/dist/types/services/config/index.d.ts +16 -64
  128. package/dist/types/services/config/types.d.ts +252 -114
  129. package/dist/types/services/constants.d.ts +16 -0
  130. package/dist/types/services/core/Err.d.ts +6 -0
  131. package/dist/types/services/core/Utils.d.ts +43 -13
  132. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  133. package/dist/types/services/core/constants.d.ts +7 -0
  134. package/dist/types/services/core/types.d.ts +2 -0
  135. package/dist/types/services/core/websocket/WebSocketManager.d.ts +2 -0
  136. package/dist/types/services/core/websocket/types.d.ts +1 -1
  137. package/dist/types/services/index.d.ts +2 -0
  138. package/dist/types/services/task/Task.d.ts +186 -0
  139. package/dist/types/services/task/TaskFactory.d.ts +14 -0
  140. package/dist/types/services/task/TaskUtils.d.ts +54 -2
  141. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  142. package/dist/types/services/task/constants.d.ts +20 -0
  143. package/dist/types/services/task/contact.d.ts +4 -0
  144. package/dist/types/services/task/dialer.d.ts +30 -0
  145. package/dist/types/services/task/digital/Digital.d.ts +23 -0
  146. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
  147. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  148. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  149. package/dist/types/services/task/state-machine/guards.d.ts +103 -0
  150. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  151. package/dist/types/services/task/state-machine/types.d.ts +277 -0
  152. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  153. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  154. package/dist/types/services/task/types.d.ts +790 -66
  155. package/dist/types/services/task/voice/Voice.d.ts +241 -0
  156. package/dist/types/services/task/voice/WebRTC.d.ts +54 -0
  157. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  158. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
  159. package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
  160. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  161. package/dist/types/types.d.ts +258 -11
  162. package/dist/types/utils/PageCache.d.ts +20 -3
  163. package/dist/types/webex.d.ts +1 -0
  164. package/dist/types.js +204 -6
  165. package/dist/types.js.map +1 -1
  166. package/dist/utils/PageCache.js +19 -5
  167. package/dist/utils/PageCache.js.map +1 -1
  168. package/dist/webex.js +22 -2
  169. package/dist/webex.js.map +1 -1
  170. package/docs/adr/0001-spec-source-policy.md +97 -0
  171. package/docs/adr/0002-consult-transfer-list-policy.md +345 -0
  172. package/docs/adr/0003-repo-standards-migration.md +104 -0
  173. package/docs/adr/index.md +35 -0
  174. package/docs/architecture.md +460 -0
  175. package/docs/getting-started.md +142 -0
  176. package/docs/index.md +53 -0
  177. package/docs/specs/README.md +98 -0
  178. package/package.json +17 -12
  179. package/schemas/repo-context.schema.json +796 -0
  180. package/src/cc.ts +1439 -105
  181. package/src/config.ts +13 -0
  182. package/src/constants.ts +53 -1
  183. package/src/docs/README.md +727 -0
  184. package/src/index.ts +72 -16
  185. package/src/metrics/MetricsManager.ts +16 -0
  186. package/src/metrics/behavioral-events.ts +218 -0
  187. package/src/metrics/constants.ts +63 -4
  188. package/src/metrics/docs/README.md +710 -0
  189. package/src/services/AddressBook.ts +17 -6
  190. package/src/services/AnswerCallOnWebexService.ts +239 -0
  191. package/src/services/ApiAiAssistant.ts +494 -15
  192. package/src/services/EntryPoint.ts +59 -60
  193. package/src/services/Queue.ts +29 -12
  194. package/src/services/UserPreference.ts +509 -0
  195. package/src/services/WebCallingService.ts +362 -40
  196. package/src/services/WebexCrossClientService.ts +298 -0
  197. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  198. package/src/services/agent/docs/README.md +673 -0
  199. package/src/services/config/Util.ts +54 -84
  200. package/src/services/config/constants.ts +64 -86
  201. package/src/services/config/docs/README.md +530 -0
  202. package/src/services/config/index.ts +116 -277
  203. package/src/services/config/types.ts +238 -125
  204. package/src/services/constants.ts +18 -0
  205. package/src/services/core/Err.ts +3 -0
  206. package/src/services/core/Utils.ts +151 -37
  207. package/src/services/core/WebexRequest.ts +3 -1
  208. package/src/services/core/aqm-reqs.ts +18 -12
  209. package/src/services/core/constants.ts +8 -0
  210. package/src/services/core/docs/README.md +993 -0
  211. package/src/services/core/types.ts +33 -1
  212. package/src/services/core/websocket/WebSocketManager.ts +37 -8
  213. package/src/services/core/websocket/connection-service.ts +5 -1
  214. package/src/services/core/websocket/types.ts +1 -1
  215. package/src/services/docs/README.md +765 -0
  216. package/src/services/index.ts +4 -0
  217. package/src/services/task/Task.ts +1211 -0
  218. package/src/services/task/TaskFactory.ts +82 -0
  219. package/src/services/task/TaskManager.ts +1551 -584
  220. package/src/services/task/TaskUtils.ts +316 -25
  221. package/src/services/task/WebexCallingUtils.ts +136 -0
  222. package/src/services/task/constants.ts +21 -0
  223. package/src/services/task/contact.ts +30 -0
  224. package/src/services/task/dialer.ts +80 -0
  225. package/src/services/task/digital/Digital.ts +102 -0
  226. package/src/services/task/docs/README.md +1569 -0
  227. package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
  228. package/src/services/task/state-machine/actions.ts +741 -0
  229. package/src/services/task/state-machine/constants.ts +172 -0
  230. package/src/services/task/state-machine/docs/README.md +1388 -0
  231. package/src/services/task/state-machine/guards.ts +442 -0
  232. package/src/services/task/state-machine/index.ts +28 -0
  233. package/src/services/task/state-machine/types.ts +258 -0
  234. package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
  235. package/src/services/task/taskDataNormalizer.ts +137 -0
  236. package/src/services/task/types.ts +974 -70
  237. package/src/services/task/voice/Voice.ts +1878 -0
  238. package/src/services/task/voice/WebRTC.ts +194 -0
  239. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  240. package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
  241. package/src/services/wxAppDiagnosticLogging.ts +286 -0
  242. package/src/services/wxAppTelephonyUtils.ts +14 -0
  243. package/src/types.ts +323 -13
  244. package/src/utils/AGENTS.md +291 -0
  245. package/src/utils/PageCache.ts +38 -5
  246. package/src/utils/docs/README.md +413 -0
  247. package/src/webex.js +10 -0
  248. package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
  249. package/test/unit/spec/cc.ts +4046 -181
  250. package/test/unit/spec/index.ts +891 -0
  251. package/test/unit/spec/logger-proxy.ts +70 -0
  252. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  253. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  254. package/test/unit/spec/services/AddressBook.ts +37 -6
  255. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  256. package/test/unit/spec/services/ApiAiAssistant.ts +442 -23
  257. package/test/unit/spec/services/EntryPoint.ts +87 -40
  258. package/test/unit/spec/services/Queue.ts +123 -12
  259. package/test/unit/spec/services/UserPreference.ts +401 -0
  260. package/test/unit/spec/services/WebCallingService.ts +484 -49
  261. package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
  262. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  263. package/test/unit/spec/services/config/Util.ts +501 -0
  264. package/test/unit/spec/services/config/index.ts +318 -548
  265. package/test/unit/spec/services/core/Utils.ts +447 -8
  266. package/test/unit/spec/services/core/WebexRequest.ts +8 -7
  267. package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
  268. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +132 -56
  269. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  270. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  271. package/test/unit/spec/services/task/Task.ts +2723 -0
  272. package/test/unit/spec/services/task/TaskFactory.ts +116 -0
  273. package/test/unit/spec/services/task/TaskManager.ts +4800 -1586
  274. package/test/unit/spec/services/task/TaskUtils.ts +307 -0
  275. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  276. package/test/unit/spec/services/task/contact.ts +33 -0
  277. package/test/unit/spec/services/task/dialer.ts +190 -0
  278. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  279. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
  280. package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
  281. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  282. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
  283. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  284. package/test/unit/spec/services/task/voice/Voice.ts +2355 -0
  285. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  286. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  287. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
  288. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
  289. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  290. package/typedoc.md +1 -1
  291. package/umd/contact-center.min.js +2 -2
  292. package/umd/contact-center.min.js.map +1 -1
  293. package/dist/services/task/index.js +0 -1525
  294. package/dist/services/task/index.js.map +0 -1
  295. package/dist/types/services/task/index.d.ts +0 -650
  296. package/src/services/task/index.ts +0 -1801
  297. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -4,14 +4,22 @@ import {Failure, AugmentedError} from './GlobalTypes';
4
4
  import LoggerProxy from '../../logger-proxy';
5
5
  import WebexRequest from './WebexRequest';
6
6
  import {
7
+ ConsultConferenceData,
8
+ consultConferencePayloadData,
9
+ ConsultTransferDestinationType,
7
10
  TaskData,
8
- ConsultTransferPayLoad,
9
11
  CONSULT_TRANSFER_DESTINATION_TYPE,
12
+ DESTINATION_TYPE,
10
13
  Interaction,
14
+ InteractionParticipant,
11
15
  } from '../task/types';
12
16
  import {PARTICIPANT_TYPES, STATE_CONSULT} from './constants';
13
17
  import {DialPlan} from '../config/types';
14
18
 
19
+ /** Returns whether a value is a non-null object with string keys. */
20
+ export const isRecord = (value: unknown): value is Record<string, unknown> =>
21
+ typeof value === 'object' && value !== null;
22
+
15
23
  /**
16
24
  * Extracts common error details from a Webex request payload.
17
25
  *
@@ -28,60 +36,97 @@ const getCommonErrorDetails = (errObj: WebexRequestPayload) => {
28
36
  };
29
37
 
30
38
  /**
31
- * Checks if the destination type represents an entry point variant (EPDN or ENTRYPOINT).
32
- */
33
- const isEntryPointOrEpdn = (destAgentType?: string): boolean => {
34
- return destAgentType === 'EPDN' || destAgentType === 'ENTRYPOINT';
35
- };
36
-
37
- /**
38
- * Determines if the task involves dialing a number based on the destination type.
39
- * Returns 'DIAL_NUMBER' for dial-related destinations, empty string otherwise.
39
+ * Strips characters defined in the dial plan entry from the input string.
40
+ *
41
+ * @param input - The dial number to sanitize
42
+ * @param strippedChars - String of characters to remove from the input
43
+ * @returns The sanitized input with specified characters removed
40
44
  */
41
- const getAgentActionTypeFromTask = (taskData?: TaskData): 'DIAL_NUMBER' | '' => {
42
- const destAgentType = taskData?.destinationType;
45
+ export const stripDialPlanChars = (input: string, strippedChars: string): string => {
46
+ if (!strippedChars) {
47
+ return input;
48
+ }
43
49
 
44
- // Check if destination requires dialing: direct dial number or entry point variants
45
- const isDialNumber = destAgentType === 'DN';
46
- const isEntryPointVariant = isEntryPointOrEpdn(destAgentType);
50
+ const charsToStrip = new Set(strippedChars.split(''));
47
51
 
48
- // If the destination type is a dial number or an entry point variant, return 'DIAL_NUMBER'
49
- return isDialNumber || isEntryPointVariant ? 'DIAL_NUMBER' : '';
52
+ return input
53
+ .split('')
54
+ .filter((c) => !charsToStrip.has(c))
55
+ .join('');
50
56
  };
51
57
 
52
- // Fallback regex for US/Canada dial numbers when no dial plan entries are configured
53
- export const FALLBACK_DIAL_NUMBER_REGEX = /1[0-9]{3}[2-9][0-9]{6}([,]{1,10}[0-9]+){0,1}/;
54
-
55
58
  /**
56
59
  * Validates a dial number against the provided dial plan regex patterns.
57
60
  * A number is valid if it matches at least one regex pattern in the dial plans.
58
- * Falls back to US/Canada regex validation if no dial plan entries are configured.
61
+ * Skips validation when no dial plan entries are configured, deferring to the server.
59
62
  *
60
63
  * @param input - The dial number to validate
61
64
  * @param dialPlanEntries - Array of dial plan entries containing regex patterns
62
- * @returns true if the input matches at least one dial plan regex pattern, false otherwise
65
+ * @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise
63
66
  */
64
67
  export const isValidDialNumber = (
65
68
  input: string,
66
69
  dialPlanEntries: DialPlan['dialPlanEntity']
67
70
  ): boolean => {
71
+ if (!input) {
72
+ LoggerProxy.warn('Dial number is empty or undefined.', {
73
+ module: 'Utils',
74
+ method: 'isValidDialNumber',
75
+ });
76
+
77
+ return false;
78
+ }
79
+
68
80
  if (!dialPlanEntries || dialPlanEntries.length === 0) {
69
- LoggerProxy.info('No dial plan entries found. Falling back to US number validation.');
81
+ LoggerProxy.log(
82
+ 'No dial plan entries found. Skipping client-side validation, deferring to server.',
83
+ {module: 'Utils', method: 'isValidDialNumber'}
84
+ );
70
85
 
71
- return FALLBACK_DIAL_NUMBER_REGEX.test(input);
86
+ return true;
72
87
  }
73
88
 
74
89
  return dialPlanEntries.some((entry) => {
75
90
  try {
91
+ const sanitizedInput = stripDialPlanChars(input, entry.strippedChars);
76
92
  const regex = new RegExp(entry.regex);
77
93
 
78
- return regex.test(input);
79
- } catch {
94
+ return regex.test(sanitizedInput);
95
+ } catch (e) {
96
+ LoggerProxy.warn(`Failed to validate dial number against entry "${entry.name}": ${e}`, {
97
+ module: 'Utils',
98
+ method: 'isValidDialNumber',
99
+ });
100
+
80
101
  return false;
81
102
  }
82
103
  });
83
104
  };
84
105
 
106
+ /**
107
+ * Checks whether a URL's hostname is, or is a subdomain of, one of the allowed domains.
108
+ *
109
+ * @param url - The candidate URL to validate
110
+ * @param allowedDomains - Domains (or domain suffixes) the URL's hostname must match
111
+ * @returns true when the URL parses and its hostname matches an allowed domain, false otherwise
112
+ */
113
+ export const isAllowedUrlHost = (
114
+ url: string | undefined | null,
115
+ allowedDomains: string[]
116
+ ): boolean => {
117
+ if (!url) {
118
+ return false;
119
+ }
120
+
121
+ try {
122
+ const hostname = new URL(url).hostname.toLowerCase();
123
+
124
+ return allowedDomains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
125
+ } catch (error) {
126
+ return false;
127
+ }
128
+ };
129
+
85
130
  export const getStationLoginErrorData = (failure: Failure, loginOption: LoginOption) => {
86
131
  let duplicateLocationMessage = 'This value is already in use';
87
132
 
@@ -243,6 +288,7 @@ export const createErrDetailsObject = (errObj: WebexRequestPayload) => {
243
288
  return new Err.Details('Service.reqs.generic.failure', details);
244
289
  };
245
290
 
291
+ /*
246
292
  /**
247
293
  * Gets the consulted agent ID from the media object by finding the agent
248
294
  * in the consult media participants (excluding the current agent).
@@ -321,9 +367,16 @@ export const calculateDestAgentId = (interaction: Interaction, agentId: string):
321
367
  return destAgentIdCBT;
322
368
  }
323
369
 
324
- return interaction.participants[consultingAgent]?.type === PARTICIPANT_TYPES.EP_DN
325
- ? interaction.participants[consultingAgent]?.epId
326
- : interaction.participants[consultingAgent]?.id;
370
+ const participant = interaction.participants[consultingAgent];
371
+ if (!participant) {
372
+ return '';
373
+ }
374
+
375
+ if (participant.type === PARTICIPANT_TYPES.EP_DN) {
376
+ return (participant as InteractionParticipant & {epId?: string}).epId ?? '';
377
+ }
378
+
379
+ return participant.id ?? '';
327
380
  };
328
381
 
329
382
  /**
@@ -358,16 +411,77 @@ export const calculateDestType = (interaction: Interaction, agentId: string): st
358
411
  return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
359
412
  };
360
413
 
414
+ /**
415
+ * Gets the destination agent ID from participants.
416
+ * Finds a participant who is not the current agent and is an agent type.
417
+ *
418
+ * @param participants - The participants object from interaction
419
+ * @param agentId - The current agent's ID
420
+ * @returns The destination agent ID, or undefined if none found
421
+ */
422
+ export const buildConsultConferenceParamData = (
423
+ dataPassed: consultConferencePayloadData,
424
+ interactionIdPassed: string
425
+ ): {interactionId: string; data: ConsultConferenceData} => {
426
+ const data: ConsultConferenceData = {
427
+ ...('agentId' in dataPassed && {agentId: dataPassed.agentId}),
428
+ to: dataPassed.destAgentId,
429
+ destinationType: '',
430
+ };
431
+
432
+ if ('destinationType' in dataPassed) {
433
+ const destinationType = String(dataPassed.destinationType || '').trim();
434
+ const normalizedDestinationType = destinationType.toUpperCase().replace(/[-_\s]/g, '');
435
+
436
+ if (normalizedDestinationType === 'DN' || normalizedDestinationType === 'DIALNUMBER') {
437
+ data.destinationType = DESTINATION_TYPE.DIALNUMBER;
438
+ } else if (normalizedDestinationType === 'EPDN' || normalizedDestinationType === 'ENTRYPOINT') {
439
+ data.destinationType = DESTINATION_TYPE.ENTRYPOINT;
440
+ } else if (normalizedDestinationType === 'QUEUE') {
441
+ data.destinationType = DESTINATION_TYPE.QUEUE;
442
+ } else if (normalizedDestinationType === 'AGENT') {
443
+ data.destinationType = DESTINATION_TYPE.AGENT;
444
+ } else {
445
+ data.destinationType = destinationType as ConsultConferenceData['destinationType'];
446
+ }
447
+ } else {
448
+ data.destinationType = DESTINATION_TYPE.AGENT;
449
+ }
450
+
451
+ return {
452
+ interactionId: interactionIdPassed,
453
+ data,
454
+ };
455
+ };
456
+
457
+ /**
458
+ * Derives the consult transfer destination type based on task data.
459
+ * This function determines the appropriate destination type for a consult transfer
460
+ * by examining the destination type stored in the task data.
461
+ *
462
+ * @param taskData - The task data containing destination information
463
+ * @returns The derived consult transfer destination type
464
+ * @public
465
+ */
361
466
  export const deriveConsultTransferDestinationType = (
362
- taskData?: TaskData
363
- ): ConsultTransferPayLoad['destinationType'] => {
364
- const agentActionType = getAgentActionTypeFromTask(taskData);
365
-
366
- if (agentActionType === 'DIAL_NUMBER') {
367
- return isEntryPointOrEpdn(taskData?.destinationType)
368
- ? CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT
369
- : CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
467
+ taskData: TaskData
468
+ ): ConsultTransferDestinationType => {
469
+ const destType = taskData?.destinationType;
470
+ const normalizedDestType = String(destType || '')
471
+ .toUpperCase()
472
+ .replace(/[-_\s]/g, '');
473
+
474
+ // Map destination types to consult transfer destination types
475
+ if (normalizedDestType === 'DN' || normalizedDestType === 'DIALNUMBER') {
476
+ return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
477
+ }
478
+ if (normalizedDestType === 'EPDN' || normalizedDestType === 'ENTRYPOINT') {
479
+ return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;
480
+ }
481
+ if (normalizedDestType === 'QUEUE') {
482
+ return CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE;
370
483
  }
371
484
 
485
+ // Default to agent if no specific type matches
372
486
  return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
373
487
  };
@@ -34,14 +34,16 @@ class WebexRequest {
34
34
  resource: string;
35
35
  method: HTTP_METHODS;
36
36
  body?: RequestBody;
37
+ headers?: Record<string, string | null>;
37
38
  }): Promise<IHttpResponse> {
38
- const {service, resource, method, body} = options;
39
+ const {service, resource, method, body, headers} = options;
39
40
 
40
41
  return this.webex.request({
41
42
  service,
42
43
  resource,
43
44
  method,
44
45
  body,
46
+ ...(headers ? {headers} : {}),
45
47
  });
46
48
  }
47
49
 
@@ -117,16 +117,15 @@ export default class AqmReqs {
117
117
  clear();
118
118
  const notifFail = c.notifFail!;
119
119
  if ('errId' in notifFail) {
120
- LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {
121
- module: AQM_REQS_FILE,
122
- method: METHODS.CREATE_PROMISE,
123
- });
124
- const eerr = new Err.Details(notifFail.errId, msg as any);
125
- LoggerProxy.log(`Routing request failed: ${eerr}`, {
120
+ const error = new Err.Details(notifFail.errId, msg as any);
121
+
122
+ // The raw routing-failure payload/error is never logged verbatim; only a
123
+ // redacted, non-sensitive diagnostic is emitted regardless of redactSensitiveLogs.
124
+ LoggerProxy.log('Routing request failed (sensitive details redacted)', {
126
125
  module: AQM_REQS_FILE,
127
126
  method: METHODS.CREATE_PROMISE,
128
127
  });
129
- reject(eerr);
128
+ reject(error);
130
129
  } else {
131
130
  reject(notifFail.err(msg as any));
132
131
  }
@@ -176,13 +175,20 @@ export default class AqmReqs {
176
175
  if (response?.headers) {
177
176
  response.headers.Authorization = '*';
178
177
  }
179
- LoggerProxy.error(
180
- `Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`,
181
- {
178
+ if (c.redactSensitiveLogs) {
179
+ LoggerProxy.error('Routing request timeout (sensitive details redacted)', {
182
180
  module: AQM_REQS_FILE,
183
181
  method: METHODS.CREATE_PROMISE,
184
- }
185
- );
182
+ });
183
+ } else {
184
+ LoggerProxy.error(
185
+ `Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`,
186
+ {
187
+ module: AQM_REQS_FILE,
188
+ method: METHODS.CREATE_PROMISE,
189
+ }
190
+ );
191
+ }
186
192
  reject(
187
193
  new Err.Details('Service.aqm.reqs.Timeout', {
188
194
  key: keySuccess,
@@ -80,6 +80,14 @@ export const PARTICIPANT_TYPES = {
80
80
  /** Interaction state for consultation */
81
81
  export const STATE_CONSULT = 'consult';
82
82
 
83
+ /**
84
+ * Trusted domains for the RoutingNotifs WebSocket connection. A `webSocketUrl` returned by the
85
+ * subscribe/register API is only opened when its hostname matches one of these domains exactly
86
+ * or is a subdomain of one of them.
87
+ * @ignore
88
+ */
89
+ export const ALLOWED_ROUTING_NOTIFS_DOMAINS = ['cisco.com', 'ciscoccservice.com'];
90
+
83
91
  // Method names for core services
84
92
  export const METHODS = {
85
93
  // WebexRequest methods