@webex/calling 3.12.0 → 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 (291) hide show
  1. package/dist/CallRecording/CallRecording.js +160 -0
  2. package/dist/CallRecording/CallRecording.js.map +1 -0
  3. package/dist/CallRecording/CallRecording.test.js +257 -0
  4. package/dist/CallRecording/CallRecording.test.js.map +1 -0
  5. package/dist/CallRecording/WxcCallRecordingConnector.js +748 -0
  6. package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
  7. package/dist/CallRecording/WxcCallRecordingConnector.test.js +824 -0
  8. package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
  9. package/dist/CallRecording/callRecordingFixtures.js +266 -0
  10. package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
  11. package/dist/CallRecording/constants.js +35 -0
  12. package/dist/CallRecording/constants.js.map +1 -0
  13. package/dist/CallRecording/types.js +142 -0
  14. package/dist/CallRecording/types.js.map +1 -0
  15. package/dist/CallRecording/userhub.js +117 -0
  16. package/dist/CallRecording/userhub.js.map +1 -0
  17. package/dist/CallRecording/utils.js +42 -0
  18. package/dist/CallRecording/utils.js.map +1 -0
  19. package/dist/CallRecording/utils.test.js +97 -0
  20. package/dist/CallRecording/utils.test.js.map +1 -0
  21. package/dist/CallingClient/CallingClient.js +469 -233
  22. package/dist/CallingClient/CallingClient.js.map +1 -1
  23. package/dist/CallingClient/CallingClient.test.js +736 -179
  24. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  25. package/dist/CallingClient/calling/CallerId/index.js +3 -1
  26. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  27. package/dist/CallingClient/calling/CallerId/index.test.js +12 -2
  28. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  29. package/dist/CallingClient/calling/call.js +645 -458
  30. package/dist/CallingClient/calling/call.js.map +1 -1
  31. package/dist/CallingClient/calling/call.test.js +928 -498
  32. package/dist/CallingClient/calling/call.test.js.map +1 -1
  33. package/dist/CallingClient/calling/callManager.js +106 -35
  34. package/dist/CallingClient/calling/callManager.js.map +1 -1
  35. package/dist/CallingClient/calling/callManager.test.js +140 -0
  36. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  37. package/dist/CallingClient/calling/types.js +5 -0
  38. package/dist/CallingClient/calling/types.js.map +1 -1
  39. package/dist/CallingClient/constants.js +33 -3
  40. package/dist/CallingClient/constants.js.map +1 -1
  41. package/dist/CallingClient/line/index.js +27 -3
  42. package/dist/CallingClient/line/index.js.map +1 -1
  43. package/dist/CallingClient/line/line.test.js +102 -17
  44. package/dist/CallingClient/line/line.test.js.map +1 -1
  45. package/dist/CallingClient/registration/register.js +971 -506
  46. package/dist/CallingClient/registration/register.js.map +1 -1
  47. package/dist/CallingClient/registration/register.test.js +946 -61
  48. package/dist/CallingClient/registration/register.test.js.map +1 -1
  49. package/dist/CallingClient/registration/types.js +26 -0
  50. package/dist/CallingClient/registration/types.js.map +1 -1
  51. package/dist/CallingClient/registration/webWorker.js +41 -104
  52. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  53. package/dist/CallingClient/registration/webWorker.test.js +39 -153
  54. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  55. package/dist/CallingClient/registration/webWorkerStr.js +1 -1
  56. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
  57. package/dist/CallingClient/types.js +7 -0
  58. package/dist/CallingClient/types.js.map +1 -1
  59. package/dist/CallingClient/utils/constants.js +58 -0
  60. package/dist/CallingClient/utils/constants.js.map +1 -0
  61. package/dist/CallingClient/utils/index.js +63 -0
  62. package/dist/CallingClient/utils/index.js.map +1 -0
  63. package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
  64. package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
  65. package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
  66. package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
  67. package/dist/CallingClient/utils/request.js +435 -0
  68. package/dist/CallingClient/utils/request.js.map +1 -0
  69. package/dist/CallingClient/utils/request.test.js +999 -0
  70. package/dist/CallingClient/utils/request.test.js.map +1 -0
  71. package/dist/CallingClient/utils/types.js +7 -0
  72. package/dist/CallingClient/utils/types.js.map +1 -0
  73. package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
  74. package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
  75. package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
  76. package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
  77. package/dist/Contacts/ContactsClient.js +13 -11
  78. package/dist/Contacts/ContactsClient.js.map +1 -1
  79. package/dist/Contacts/ContactsClient.test.js +3 -8
  80. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  81. package/dist/Errors/types.js +2 -0
  82. package/dist/Errors/types.js.map +1 -1
  83. package/dist/Events/types.js +38 -11
  84. package/dist/Events/types.js.map +1 -1
  85. package/dist/Metrics/index.js +63 -2
  86. package/dist/Metrics/index.js.map +1 -1
  87. package/dist/Metrics/index.test.js +357 -1
  88. package/dist/Metrics/index.test.js.map +1 -1
  89. package/dist/Metrics/types.js +19 -1
  90. package/dist/Metrics/types.js.map +1 -1
  91. package/dist/SDKConnector/types.js.map +1 -1
  92. package/dist/api.js +56 -0
  93. package/dist/api.js.map +1 -1
  94. package/dist/common/Utils.js +252 -127
  95. package/dist/common/Utils.js.map +1 -1
  96. package/dist/common/Utils.test.js +493 -229
  97. package/dist/common/Utils.test.js.map +1 -1
  98. package/dist/common/callUtils.js +187 -0
  99. package/dist/common/callUtils.js.map +1 -0
  100. package/dist/common/callUtils.test.js +313 -0
  101. package/dist/common/callUtils.test.js.map +1 -0
  102. package/dist/common/constants.js +27 -1
  103. package/dist/common/constants.js.map +1 -1
  104. package/dist/common/index.js +11 -0
  105. package/dist/common/index.js.map +1 -1
  106. package/dist/common/testUtil.js +11 -5
  107. package/dist/common/testUtil.js.map +1 -1
  108. package/dist/common/types.js +3 -0
  109. package/dist/common/types.js.map +1 -1
  110. package/dist/index.js +171 -40
  111. package/dist/index.js.map +1 -1
  112. package/dist/mobius-socket/config.js +24 -0
  113. package/dist/mobius-socket/config.js.map +1 -0
  114. package/dist/mobius-socket/errors.js +143 -0
  115. package/dist/mobius-socket/errors.js.map +1 -0
  116. package/dist/mobius-socket/errors.test.js +20 -0
  117. package/dist/mobius-socket/errors.test.js.map +1 -0
  118. package/dist/mobius-socket/index.js +57 -0
  119. package/dist/mobius-socket/index.js.map +1 -0
  120. package/dist/mobius-socket/mobius-socket-events.test.js +493 -0
  121. package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
  122. package/dist/mobius-socket/mobius-socket.js +849 -0
  123. package/dist/mobius-socket/mobius-socket.js.map +1 -0
  124. package/dist/mobius-socket/mobius-socket.test.js +1898 -0
  125. package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
  126. package/dist/mobius-socket/socket/constants.js +55 -0
  127. package/dist/mobius-socket/socket/constants.js.map +1 -0
  128. package/dist/mobius-socket/socket/index.js +15 -0
  129. package/dist/mobius-socket/socket/index.js.map +1 -0
  130. package/dist/mobius-socket/socket/socket-base.js +614 -0
  131. package/dist/mobius-socket/socket/socket-base.js.map +1 -0
  132. package/dist/mobius-socket/socket/socket.js +19 -0
  133. package/dist/mobius-socket/socket/socket.js.map +1 -0
  134. package/dist/mobius-socket/socket/socket.shim.js +26 -0
  135. package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
  136. package/dist/mobius-socket/socket/types.js +7 -0
  137. package/dist/mobius-socket/socket/types.js.map +1 -0
  138. package/dist/mobius-socket/socket.test.js +747 -0
  139. package/dist/mobius-socket/socket.test.js.map +1 -0
  140. package/dist/mobius-socket/test/mocha-helpers.js +23 -0
  141. package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
  142. package/dist/mobius-socket/test/promise-tick.js +28 -0
  143. package/dist/mobius-socket/test/promise-tick.js.map +1 -0
  144. package/dist/mobius-socket/types.js +7 -0
  145. package/dist/mobius-socket/types.js.map +1 -0
  146. package/dist/module/CallRecording/CallRecording.js +56 -0
  147. package/dist/module/CallRecording/WxcCallRecordingConnector.js +349 -0
  148. package/dist/module/CallRecording/callRecordingFixtures.js +231 -0
  149. package/dist/module/CallRecording/constants.js +27 -0
  150. package/dist/module/CallRecording/types.js +19 -0
  151. package/dist/module/CallRecording/userhub.js +100 -0
  152. package/dist/module/CallRecording/utils.js +14 -0
  153. package/dist/module/CallingClient/CallingClient.js +137 -20
  154. package/dist/module/CallingClient/calling/CallerId/index.js +2 -2
  155. package/dist/module/CallingClient/calling/call.js +207 -68
  156. package/dist/module/CallingClient/calling/callManager.js +51 -11
  157. package/dist/module/CallingClient/calling/types.js +2 -0
  158. package/dist/module/CallingClient/constants.js +28 -0
  159. package/dist/module/CallingClient/line/index.js +11 -3
  160. package/dist/module/CallingClient/registration/register.js +297 -68
  161. package/dist/module/CallingClient/registration/types.js +5 -1
  162. package/dist/module/CallingClient/registration/webWorker.js +42 -61
  163. package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
  164. package/dist/module/CallingClient/utils/constants.js +36 -0
  165. package/dist/module/CallingClient/utils/index.js +5 -0
  166. package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
  167. package/dist/module/CallingClient/utils/request.js +211 -0
  168. package/dist/module/CallingClient/utils/types.js +1 -0
  169. package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
  170. package/dist/module/Contacts/ContactsClient.js +1 -1
  171. package/dist/module/Errors/types.js +2 -0
  172. package/dist/module/Events/types.js +23 -10
  173. package/dist/module/Metrics/index.js +48 -1
  174. package/dist/module/Metrics/types.js +18 -0
  175. package/dist/module/api.js +3 -2
  176. package/dist/module/common/Utils.js +103 -58
  177. package/dist/module/common/callUtils.js +90 -0
  178. package/dist/module/common/constants.js +11 -0
  179. package/dist/module/common/index.js +1 -0
  180. package/dist/module/common/testUtil.js +7 -1
  181. package/dist/module/common/types.js +3 -0
  182. package/dist/module/index.js +7 -3
  183. package/dist/module/mobius-socket/config.js +15 -0
  184. package/dist/module/mobius-socket/errors.js +58 -0
  185. package/dist/module/mobius-socket/index.js +24 -0
  186. package/dist/module/mobius-socket/mobius-socket.js +593 -0
  187. package/dist/module/mobius-socket/socket/constants.js +26 -0
  188. package/dist/module/mobius-socket/socket/index.js +4 -0
  189. package/dist/module/mobius-socket/socket/socket-base.js +376 -0
  190. package/dist/module/mobius-socket/socket/socket.js +9 -0
  191. package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
  192. package/dist/module/mobius-socket/socket/types.js +1 -0
  193. package/dist/module/mobius-socket/types.js +1 -0
  194. package/dist/types/CallRecording/CallRecording.d.ts +18 -0
  195. package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
  196. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +27 -0
  197. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
  198. package/dist/types/CallRecording/callRecordingFixtures.d.ts +152 -0
  199. package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
  200. package/dist/types/CallRecording/constants.d.ts +28 -0
  201. package/dist/types/CallRecording/constants.d.ts.map +1 -0
  202. package/dist/types/CallRecording/types.d.ts +184 -0
  203. package/dist/types/CallRecording/types.d.ts.map +1 -0
  204. package/dist/types/CallRecording/userhub.d.ts +44 -0
  205. package/dist/types/CallRecording/userhub.d.ts.map +1 -0
  206. package/dist/types/CallRecording/utils.d.ts +3 -0
  207. package/dist/types/CallRecording/utils.d.ts.map +1 -0
  208. package/dist/types/CallingClient/CallingClient.d.ts +8 -0
  209. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  210. package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
  211. package/dist/types/CallingClient/calling/call.d.ts +17 -3
  212. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  213. package/dist/types/CallingClient/calling/callManager.d.ts +8 -4
  214. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  215. package/dist/types/CallingClient/calling/types.d.ts +38 -9
  216. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  217. package/dist/types/CallingClient/constants.d.ts +28 -0
  218. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  219. package/dist/types/CallingClient/line/index.d.ts +3 -2
  220. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  221. package/dist/types/CallingClient/registration/register.d.ts +9 -1
  222. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  223. package/dist/types/CallingClient/registration/types.d.ts +26 -2
  224. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  225. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
  226. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
  227. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
  228. package/dist/types/CallingClient/types.d.ts +6 -2
  229. package/dist/types/CallingClient/types.d.ts.map +1 -1
  230. package/dist/types/CallingClient/utils/constants.d.ts +35 -0
  231. package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
  232. package/dist/types/CallingClient/utils/index.d.ts +6 -0
  233. package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
  234. package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
  235. package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
  236. package/dist/types/CallingClient/utils/request.d.ts +28 -0
  237. package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
  238. package/dist/types/CallingClient/utils/types.d.ts +34 -0
  239. package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
  240. package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
  241. package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
  242. package/dist/types/Errors/types.d.ts +2 -0
  243. package/dist/types/Errors/types.d.ts.map +1 -1
  244. package/dist/types/Events/types.d.ts +80 -16
  245. package/dist/types/Events/types.d.ts.map +1 -1
  246. package/dist/types/Metrics/index.d.ts.map +1 -1
  247. package/dist/types/Metrics/types.d.ts +19 -2
  248. package/dist/types/Metrics/types.d.ts.map +1 -1
  249. package/dist/types/SDKConnector/types.d.ts +40 -12
  250. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  251. package/dist/types/api.d.ts +6 -4
  252. package/dist/types/api.d.ts.map +1 -1
  253. package/dist/types/common/Utils.d.ts +11 -5
  254. package/dist/types/common/Utils.d.ts.map +1 -1
  255. package/dist/types/common/callUtils.d.ts +6 -0
  256. package/dist/types/common/callUtils.d.ts.map +1 -0
  257. package/dist/types/common/constants.d.ts +6 -0
  258. package/dist/types/common/constants.d.ts.map +1 -1
  259. package/dist/types/common/index.d.ts +1 -0
  260. package/dist/types/common/index.d.ts.map +1 -1
  261. package/dist/types/common/testUtil.d.ts +6 -1
  262. package/dist/types/common/testUtil.d.ts.map +1 -1
  263. package/dist/types/common/types.d.ts +5 -1
  264. package/dist/types/common/types.d.ts.map +1 -1
  265. package/dist/types/index.d.ts +9 -4
  266. package/dist/types/index.d.ts.map +1 -1
  267. package/dist/types/mobius-socket/config.d.ts +17 -0
  268. package/dist/types/mobius-socket/config.d.ts.map +1 -0
  269. package/dist/types/mobius-socket/errors.d.ts +32 -0
  270. package/dist/types/mobius-socket/errors.d.ts.map +1 -0
  271. package/dist/types/mobius-socket/index.d.ts +14 -0
  272. package/dist/types/mobius-socket/index.d.ts.map +1 -0
  273. package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
  274. package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
  275. package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
  276. package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
  277. package/dist/types/mobius-socket/socket/index.d.ts +5 -0
  278. package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
  279. package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
  280. package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
  281. package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
  282. package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
  283. package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
  284. package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
  285. package/dist/types/mobius-socket/socket/types.d.ts +61 -0
  286. package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
  287. package/dist/types/mobius-socket/types.d.ts +21 -0
  288. package/dist/types/mobius-socket/types.d.ts.map +1 -0
  289. package/package.json +21 -5
  290. package/src/mobius-socket/socket/socket.shim.ts +22 -0
  291. package/src/mobius-socket/socket/socket.ts +14 -0
@@ -23,6 +23,7 @@ var _types2 = require("../Errors/types");
23
23
  var _Utils = require("./Utils");
24
24
  var _voicemailFixture = require("../Voicemail/voicemailFixture");
25
25
  var _constants2 = require("./constants");
26
+ var _testFixtures = require("../CallSettings/testFixtures");
26
27
  var _types3 = require("../Events/types");
27
28
  var _SDKConnector = _interopRequireDefault(require("../SDKConnector"));
28
29
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -38,6 +39,7 @@ var mockSubmitRegistrationMetric = jest.fn();
38
39
  var mockEmitterCb = jest.fn();
39
40
  var mockRestoreCb = jest.fn();
40
41
  var mock429RetryCb = jest.fn();
42
+ var mockSessionSupersededCb = jest.fn();
41
43
  var webex = (0, _testUtil.getTestUtilsWebex)();
42
44
  _SDKConnector.default.setWebex(webex);
43
45
  webex.internal.metrics.submitClientMetrics = mockSubmitRegistrationMetric;
@@ -64,6 +66,28 @@ describe('Mobius service discovery tests', function () {
64
66
  expect(filteredUris.primary[0]).toBe(defaultMobiusUrl + callingContext);
65
67
  expect(filteredUris.backup.length).toBe(0);
66
68
  });
69
+ it('filterMobiusUris drops untrusted wss hosts', function () {
70
+ var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
71
+ var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
72
+ discoveryResponse.primary.wss = ['wss://mobius-dfw.webex.com/socket', 'wss://evil.example.com/socket'];
73
+ discoveryResponse.backup.wss = ['wss://mobius-sjc.webex.com/socket', 'wss://attacker.example.org/socket'];
74
+ var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
75
+ expect(filteredUris.primaryWss).toHaveLength(1);
76
+ expect(filteredUris.primaryWss[0]).toBe('wss://mobius-dfw.webex.com/socket');
77
+ expect(filteredUris.backupWss).toHaveLength(1);
78
+ expect(filteredUris.backupWss[0]).toBe('wss://mobius-sjc.webex.com/socket');
79
+ });
80
+ it('filterMobiusUris drops malformed/unparseable wss hosts', function () {
81
+ var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
82
+ var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
83
+ discoveryResponse.primary.wss = ['wss://mobius-dfw.webex.com/socket', 'wss://', 'not a url'];
84
+ discoveryResponse.backup.wss = ['not a url', 'wss://mobius-sjc.webex.com/socket'];
85
+ var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
86
+ expect(filteredUris.primaryWss).toHaveLength(1);
87
+ expect(filteredUris.primaryWss[0]).toBe('wss://mobius-dfw.webex.com/socket');
88
+ expect(filteredUris.backupWss).toHaveLength(1);
89
+ expect(filteredUris.backupWss[0]).toBe('wss://mobius-sjc.webex.com/socket');
90
+ });
67
91
  });
68
92
  describe('Call Tests - keepalive (handleCallEstablished) cases', function () {
69
93
  var logObj = {
@@ -452,6 +476,18 @@ describe('Registration Tests', function () {
452
476
  restoreCbExpected: false,
453
477
  retry429CbExpected: false,
454
478
  logMsg: '400 Bad Request'
479
+ }, {
480
+ name: 'verify 409 error response',
481
+ statusCode: _types2.ERROR_CODE.CONFLICT,
482
+ deviceErrorCode: 0,
483
+ message: _constants.SESSION_SUPERSEDED_MESSAGE,
484
+ errorType: _types2.ERROR_TYPE.SESSION_SUPERSEDED,
485
+ emitterCbExpected: false,
486
+ finalError: true,
487
+ restoreCbExpected: false,
488
+ retry429CbExpected: false,
489
+ sessionSupersededCbExpected: true,
490
+ logMsg: '409 Conflict: session superseded by another device for this user'
455
491
  }, {
456
492
  name: 'verify unknown error response',
457
493
  statusCode: 206,
@@ -477,55 +513,114 @@ describe('Registration Tests', function () {
477
513
  };
478
514
 
479
515
  /* eslint-disable @typescript-eslint/no-explicit-any */
480
- it.each(errorCodes)('%s', function (codeObj) {
481
- var webexPayload = {
482
- statusCode: codeObj.statusCode,
483
- headers: _objectSpread({
484
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
485
- }, codeObj.retryAfter && {
486
- 'retry-after': codeObj.retryAfter.toString()
487
- }),
488
- body: {
489
- device: {
490
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
491
- },
492
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
493
- errorCode: codeObj.deviceErrorCode,
494
- devices: [{
495
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
496
- uri: 'https://mobius.webex.com/api/v1/calling/web/',
497
- status: 'active',
498
- lastSeen: '2022-04-07T18:00:40Z',
499
- addresses: ['sip:sipAddress@webex.com']
500
- }]
501
- }
502
- };
503
- if (codeObj.customBodyPresent) {
504
- webexPayload.body = codeObj.body;
505
- }
506
- var mockErrorEvent = {
507
- type: codeObj.errorType,
508
- message: codeObj.message,
509
- context: logObj
516
+ it.each(errorCodes)('%s', /*#__PURE__*/function () {
517
+ var _ref8 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(codeObj) {
518
+ var webexPayload, mockErrorEvent, callClientError, result;
519
+ return _regenerator.default.wrap(function (_context8) {
520
+ while (1) switch (_context8.prev = _context8.next) {
521
+ case 0:
522
+ webexPayload = {
523
+ statusCode: codeObj.statusCode,
524
+ headers: _objectSpread({
525
+ trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
526
+ }, codeObj.retryAfter && {
527
+ 'retry-after': codeObj.retryAfter.toString()
528
+ }),
529
+ body: {
530
+ device: {
531
+ deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
532
+ },
533
+ userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
534
+ errorCode: codeObj.deviceErrorCode,
535
+ devices: [{
536
+ deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
537
+ uri: 'https://mobius.webex.com/api/v1/calling/web/',
538
+ status: 'active',
539
+ lastSeen: '2022-04-07T18:00:40Z',
540
+ addresses: ['sip:sipAddress@webex.com']
541
+ }]
542
+ }
543
+ };
544
+ if (codeObj.customBodyPresent) {
545
+ webexPayload.body = codeObj.body;
546
+ }
547
+ mockErrorEvent = {
548
+ type: codeObj.errorType,
549
+ message: codeObj.message,
550
+ context: logObj
551
+ };
552
+ callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
553
+ _context8.next = 1;
554
+ return (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, {
555
+ retry429Cb: mock429RetryCb,
556
+ restoreRegCb: mockRestoreCb,
557
+ sessionSupersededCb: mockSessionSupersededCb
558
+ });
559
+ case 1:
560
+ result = _context8.sent;
561
+ expect(result.finalError).toBe(codeObj.finalError);
562
+ if (codeObj.emitterCbExpected) {
563
+ expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
564
+ } else {
565
+ expect(mockEmitterCb).not.toHaveBeenCalled();
566
+ }
567
+ if (codeObj.restoreCbExpected) {
568
+ expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
569
+ } else {
570
+ expect(mockRestoreCb).not.toHaveBeenCalled();
571
+ }
572
+ if (codeObj.retry429CbExpected) {
573
+ expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
574
+ } else {
575
+ expect(mock429RetryCb).not.toHaveBeenCalled();
576
+ }
577
+ if (codeObj.sessionSupersededCbExpected) {
578
+ expect(mockSessionSupersededCb).toBeCalledOnceWith(callClientError);
579
+ } else {
580
+ expect(mockSessionSupersededCb).not.toHaveBeenCalled();
581
+ }
582
+ expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
583
+ expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
584
+ case 2:
585
+ case "end":
586
+ return _context8.stop();
587
+ }
588
+ }, _callee8);
589
+ }));
590
+ return function (_x) {
591
+ return _ref8.apply(this, arguments);
510
592
  };
511
- var callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
512
- (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mock429RetryCb, mockRestoreCb);
513
- if (codeObj.emitterCbExpected) {
514
- expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
515
- }
516
- if (codeObj.restoreCbExpected) {
517
- expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
518
- } else {
519
- expect(mockRestoreCb).not.toHaveBeenCalled();
520
- }
521
- if (codeObj.retry429CbExpected) {
522
- expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
523
- } else {
524
- expect(mock429RetryCb).not.toHaveBeenCalled();
525
- }
526
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
527
- expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
528
- });
593
+ }());
594
+ it('verify 409 response for a caller that does not handle a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
595
+ var webexPayload, result;
596
+ return _regenerator.default.wrap(function (_context9) {
597
+ while (1) switch (_context9.prev = _context9.next) {
598
+ case 0:
599
+ webexPayload = {
600
+ statusCode: _types2.ERROR_CODE.CONFLICT,
601
+ headers: {
602
+ trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
603
+ }
604
+ };
605
+ _context9.next = 1;
606
+ return (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, {
607
+ retry429Cb: mock429RetryCb,
608
+ restoreRegCb: mockRestoreCb
609
+ });
610
+ case 1:
611
+ result = _context9.sent;
612
+ expect(result).toStrictEqual({
613
+ finalError: false,
614
+ shouldDisconnect: false
615
+ });
616
+ expect(mockEmitterCb).not.toHaveBeenCalled();
617
+ expect(logSpy).toHaveBeenCalledWith('409 Conflict: ignored, caller does not handle a superseded session', logObj);
618
+ case 2:
619
+ case "end":
620
+ return _context9.stop();
621
+ }
622
+ }, _callee9);
623
+ })));
529
624
  });
530
625
  describe('CallingClient Error Tests', function () {
531
626
  var logSpy = jest.spyOn(_Logger.default, 'warn');
@@ -536,10 +631,10 @@ describe('CallingClient Error Tests', function () {
536
631
  beforeEach(function () {
537
632
  jest.clearAllMocks();
538
633
  });
539
- it('verify 401 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
634
+ it('verify 401 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
540
635
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
541
- return _regenerator.default.wrap(function (_context8) {
542
- while (1) switch (_context8.prev = _context8.next) {
636
+ return _regenerator.default.wrap(function (_context0) {
637
+ while (1) switch (_context0.prev = _context0.next) {
543
638
  case 0:
544
639
  statusCode = _types2.ERROR_CODE.UNAUTHORIZED;
545
640
  message = 'User is unauthorized due to an expired token.';
@@ -564,24 +659,24 @@ describe('CallingClient Error Tests', function () {
564
659
  context: logObj
565
660
  };
566
661
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
567
- _context8.next = 1;
662
+ _context0.next = 1;
568
663
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
569
664
  case 1:
570
- result = _context8.sent;
665
+ result = _context0.sent;
571
666
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
572
667
  expect(result).toBe(finalError);
573
668
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
574
669
  expect(logSpy).toHaveBeenCalledWith('401 Unauthorized', logObj);
575
670
  case 2:
576
671
  case "end":
577
- return _context8.stop();
672
+ return _context0.stop();
578
673
  }
579
- }, _callee8);
674
+ }, _callee0);
580
675
  })));
581
- it('verify 500 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
676
+ it('verify 500 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
582
677
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
583
- return _regenerator.default.wrap(function (_context9) {
584
- while (1) switch (_context9.prev = _context9.next) {
678
+ return _regenerator.default.wrap(function (_context1) {
679
+ while (1) switch (_context1.prev = _context1.next) {
585
680
  case 0:
586
681
  statusCode = _types2.ERROR_CODE.INTERNAL_SERVER_ERROR;
587
682
  message = 'An unknown error occurred while placing the request. Wait a moment and try again.';
@@ -606,24 +701,24 @@ describe('CallingClient Error Tests', function () {
606
701
  context: logObj
607
702
  };
608
703
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
609
- _context9.next = 1;
704
+ _context1.next = 1;
610
705
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
611
706
  case 1:
612
- result = _context9.sent;
707
+ result = _context1.sent;
613
708
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
614
709
  expect(result).toBe(finalError);
615
710
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
616
711
  expect(logSpy).toHaveBeenCalledWith('500 Internal Server Error', logObj);
617
712
  case 2:
618
713
  case "end":
619
- return _context9.stop();
714
+ return _context1.stop();
620
715
  }
621
- }, _callee9);
716
+ }, _callee1);
622
717
  })));
623
- it('verify unknown error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
718
+ it('verify unknown error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
624
719
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
625
- return _regenerator.default.wrap(function (_context0) {
626
- while (1) switch (_context0.prev = _context0.next) {
720
+ return _regenerator.default.wrap(function (_context10) {
721
+ while (1) switch (_context10.prev = _context10.next) {
627
722
  case 0:
628
723
  statusCode = 206;
629
724
  message = 'Unknown error';
@@ -648,19 +743,19 @@ describe('CallingClient Error Tests', function () {
648
743
  context: logObj
649
744
  };
650
745
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
651
- _context0.next = 1;
746
+ _context10.next = 1;
652
747
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
653
748
  case 1:
654
- result = _context0.sent;
749
+ result = _context10.sent;
655
750
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
656
751
  expect(result).toBe(finalError);
657
752
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
658
753
  expect(logSpy).toHaveBeenCalledWith('Unknown Error', logObj);
659
754
  case 2:
660
755
  case "end":
661
- return _context0.stop();
756
+ return _context10.stop();
662
757
  }
663
- }, _callee0);
758
+ }, _callee10);
664
759
  })));
665
760
  });
666
761
  describe('Call Tests', function () {
@@ -1208,11 +1303,11 @@ describe('resolveContact tests', function () {
1208
1303
  }));
1209
1304
  });
1210
1305
  });
1211
- it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
1306
+ it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
1212
1307
  var _callingPartyInfo$use2;
1213
1308
  var callingPartyInfo, warnSpy, webexSpy, displayInfo, query;
1214
- return _regenerator.default.wrap(function (_context1) {
1215
- while (1) switch (_context1.prev = _context1.next) {
1309
+ return _regenerator.default.wrap(function (_context11) {
1310
+ while (1) switch (_context11.prev = _context11.next) {
1216
1311
  case 0:
1217
1312
  callingPartyInfo = {};
1218
1313
  warnSpy = jest.spyOn(_Logger.default, 'warn');
@@ -1222,10 +1317,10 @@ describe('resolveContact tests', function () {
1222
1317
  callingPartyInfo.userExternalId = {
1223
1318
  $: 'userExternalId'
1224
1319
  };
1225
- _context1.next = 1;
1320
+ _context11.next = 1;
1226
1321
  return (0, _Utils.resolveContact)(callingPartyInfo);
1227
1322
  case 1:
1228
- displayInfo = _context1.sent;
1323
+ displayInfo = _context11.sent;
1229
1324
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1230
1325
  expect(warnSpy).toHaveBeenCalledWith('Error response: - 500', {
1231
1326
  file: _constants.UTILS_FILE,
@@ -1237,15 +1332,15 @@ describe('resolveContact tests', function () {
1237
1332
  }));
1238
1333
  case 2:
1239
1334
  case "end":
1240
- return _context1.stop();
1335
+ return _context11.stop();
1241
1336
  }
1242
- }, _callee1);
1337
+ }, _callee11);
1243
1338
  })));
1244
- it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
1339
+ it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1245
1340
  var _callingPartyInfo$use3;
1246
1341
  var callingPartyInfo, scimResponse, webexSpy, displayInfo, query;
1247
- return _regenerator.default.wrap(function (_context10) {
1248
- while (1) switch (_context10.prev = _context10.next) {
1342
+ return _regenerator.default.wrap(function (_context12) {
1343
+ while (1) switch (_context12.prev = _context12.next) {
1249
1344
  case 0:
1250
1345
  callingPartyInfo = {};
1251
1346
  scimResponse = (0, _testUtil.getSampleScimResponse)();
@@ -1257,10 +1352,10 @@ describe('resolveContact tests', function () {
1257
1352
  callingPartyInfo.userExternalId = {
1258
1353
  $: 'userExternalId'
1259
1354
  };
1260
- _context10.next = 1;
1355
+ _context12.next = 1;
1261
1356
  return (0, _Utils.resolveContact)(callingPartyInfo);
1262
1357
  case 1:
1263
- displayInfo = _context10.sent;
1358
+ displayInfo = _context12.sent;
1264
1359
  query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use3 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use3 === void 0 ? void 0 : _callingPartyInfo$use3.$, "\""));
1265
1360
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1266
1361
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
@@ -1269,15 +1364,15 @@ describe('resolveContact tests', function () {
1269
1364
  scimResponse.totalResults = '1';
1270
1365
  case 2:
1271
1366
  case "end":
1272
- return _context10.stop();
1367
+ return _context12.stop();
1273
1368
  }
1274
- }, _callee10);
1369
+ }, _callee12);
1275
1370
  })));
1276
- it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
1371
+ it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1277
1372
  var _callingPartyInfo$use4, _displayInfo, _displayInfo2;
1278
1373
  var callingPartyInfo, scimResponse, webexSpy, displayInfo, query, phoneNumbers;
1279
- return _regenerator.default.wrap(function (_context11) {
1280
- while (1) switch (_context11.prev = _context11.next) {
1374
+ return _regenerator.default.wrap(function (_context13) {
1375
+ while (1) switch (_context13.prev = _context13.next) {
1281
1376
  case 0:
1282
1377
  callingPartyInfo = {};
1283
1378
  scimResponse = (0, _testUtil.getSampleScimResponse)();
@@ -1289,10 +1384,10 @@ describe('resolveContact tests', function () {
1289
1384
  callingPartyInfo.userExternalId = {
1290
1385
  $: 'userExternalId'
1291
1386
  };
1292
- _context11.next = 1;
1387
+ _context13.next = 1;
1293
1388
  return (0, _Utils.resolveContact)(callingPartyInfo);
1294
1389
  case 1:
1295
- displayInfo = _context11.sent;
1390
+ displayInfo = _context13.sent;
1296
1391
  query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use4 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use4 === void 0 ? void 0 : _callingPartyInfo$use4.$, "\""));
1297
1392
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1298
1393
  uri: query
@@ -1308,10 +1403,10 @@ describe('resolveContact tests', function () {
1308
1403
  statusCode: 200,
1309
1404
  body: scimResponse
1310
1405
  });
1311
- _context11.next = 2;
1406
+ _context13.next = 2;
1312
1407
  return (0, _Utils.resolveContact)(callingPartyInfo);
1313
1408
  case 2:
1314
- displayInfo = _context11.sent;
1409
+ displayInfo = _context13.sent;
1315
1410
  expect((_displayInfo2 = displayInfo) === null || _displayInfo2 === void 0 ? void 0 : _displayInfo2.num).toBeUndefined();
1316
1411
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1317
1412
  uri: query
@@ -1319,9 +1414,9 @@ describe('resolveContact tests', function () {
1319
1414
  scimResponse.Resources[0].phoneNumbers = phoneNumbers;
1320
1415
  case 3:
1321
1416
  case "end":
1322
- return _context11.stop();
1417
+ return _context13.stop();
1323
1418
  }
1324
- }, _callee11);
1419
+ }, _callee13);
1325
1420
  })));
1326
1421
  it('Resolve by userExternalId - no photo', function () {
1327
1422
  var callingPartyInfo = {};
@@ -1346,6 +1441,63 @@ describe('resolveContact tests', function () {
1346
1441
  }));
1347
1442
  });
1348
1443
  });
1444
+ it('resolveContact escapes SCIM filter injection in userExternalId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1445
+ var callingPartyInfo, injectionPayload, webexSpy, escapedValue, expectedQuery;
1446
+ return _regenerator.default.wrap(function (_context14) {
1447
+ while (1) switch (_context14.prev = _context14.next) {
1448
+ case 0:
1449
+ callingPartyInfo = {};
1450
+ injectionPayload = 'x" or userName pr "';
1451
+ webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1452
+ statusCode: 200,
1453
+ body: (0, _testUtil.getSampleScimResponse)()
1454
+ });
1455
+ callingPartyInfo.userExternalId = {
1456
+ $: injectionPayload
1457
+ };
1458
+ _context14.next = 1;
1459
+ return (0, _Utils.resolveContact)(callingPartyInfo);
1460
+ case 1:
1461
+ // After escaping: backslash → \\ then double-quote → \"
1462
+ escapedValue = injectionPayload.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
1463
+ expectedQuery = scimUrl + encodeURIComponent("id eq \"".concat(escapedValue, "\""));
1464
+ expect(webexSpy).toHaveBeenCalledWith(expect.objectContaining({
1465
+ uri: expectedQuery
1466
+ }));
1467
+ case 2:
1468
+ case "end":
1469
+ return _context14.stop();
1470
+ }
1471
+ }, _callee14);
1472
+ })));
1473
+ it('legitimate externalId still resolves', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1474
+ var callingPartyInfo, legitimateId, webexSpy, expectedQuery;
1475
+ return _regenerator.default.wrap(function (_context15) {
1476
+ while (1) switch (_context15.prev = _context15.next) {
1477
+ case 0:
1478
+ callingPartyInfo = {};
1479
+ legitimateId = '69fde5ad-fb8b-4a1b-9998-b0999e95719b';
1480
+ webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1481
+ statusCode: 200,
1482
+ body: (0, _testUtil.getSampleScimResponse)()
1483
+ });
1484
+ callingPartyInfo.userExternalId = {
1485
+ $: legitimateId
1486
+ };
1487
+ _context15.next = 1;
1488
+ return (0, _Utils.resolveContact)(callingPartyInfo);
1489
+ case 1:
1490
+ // A UUID contains no SCIM metacharacters; the query string is unchanged
1491
+ expectedQuery = scimUrl + encodeURIComponent("id eq \"".concat(legitimateId, "\""));
1492
+ expect(webexSpy).toHaveBeenCalledWith(expect.objectContaining({
1493
+ uri: expectedQuery
1494
+ }));
1495
+ case 2:
1496
+ case "end":
1497
+ return _context15.stop();
1498
+ }
1499
+ }, _callee15);
1500
+ })));
1349
1501
  it('Resolve with minimal response from SCIM', function () {
1350
1502
  var callingPartyInfo = {};
1351
1503
  var scimResponse = (0, _testUtil.getSampleMinimumScimResponse)();
@@ -1386,10 +1538,10 @@ describe('resolveContact tests', function () {
1386
1538
  }));
1387
1539
  });
1388
1540
  });
1389
- it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1541
+ it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1390
1542
  var callingPartyInfo, peopleListResponse, items, webexSpy, displayInfo;
1391
- return _regenerator.default.wrap(function (_context12) {
1392
- while (1) switch (_context12.prev = _context12.next) {
1543
+ return _regenerator.default.wrap(function (_context16) {
1544
+ while (1) switch (_context16.prev = _context16.next) {
1393
1545
  case 0:
1394
1546
  callingPartyInfo = {};
1395
1547
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1399,10 +1551,10 @@ describe('resolveContact tests', function () {
1399
1551
  callingPartyInfo.name = {
1400
1552
  $: 'Name'
1401
1553
  };
1402
- _context12.next = 1;
1554
+ _context16.next = 1;
1403
1555
  return (0, _Utils.resolveContact)(callingPartyInfo);
1404
1556
  case 1:
1405
- displayInfo = _context12.sent;
1557
+ displayInfo = _context16.sent;
1406
1558
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1407
1559
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1408
1560
  displayName: 'Name'
@@ -1410,15 +1562,15 @@ describe('resolveContact tests', function () {
1410
1562
  peopleListResponse.items = items;
1411
1563
  case 2:
1412
1564
  case "end":
1413
- return _context12.stop();
1565
+ return _context16.stop();
1414
1566
  }
1415
- }, _callee12);
1567
+ }, _callee16);
1416
1568
  })));
1417
- it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1569
+ it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1418
1570
  var _displayInfo3, _displayInfo4, _displayInfo5, _displayInfo6, _displayInfo7, _displayInfo8;
1419
1571
  var callingPartyInfo, peopleListResponse, id, webexSpy, displayInfo;
1420
- return _regenerator.default.wrap(function (_context13) {
1421
- while (1) switch (_context13.prev = _context13.next) {
1572
+ return _regenerator.default.wrap(function (_context17) {
1573
+ while (1) switch (_context17.prev = _context17.next) {
1422
1574
  case 0:
1423
1575
  callingPartyInfo = {};
1424
1576
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1429,10 +1581,10 @@ describe('resolveContact tests', function () {
1429
1581
  callingPartyInfo.name = {
1430
1582
  $: 'Name'
1431
1583
  };
1432
- _context13.next = 1;
1584
+ _context17.next = 1;
1433
1585
  return (0, _Utils.resolveContact)(callingPartyInfo);
1434
1586
  case 1:
1435
- displayInfo = _context13.sent;
1587
+ displayInfo = _context17.sent;
1436
1588
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1437
1589
  displayName: 'Name'
1438
1590
  }));
@@ -1445,10 +1597,10 @@ describe('resolveContact tests', function () {
1445
1597
  /* Also test empty id */
1446
1598
  peopleListResponse.items[0].id = '';
1447
1599
  webex.people.list.mockResolvedValueOnce(peopleListResponse);
1448
- _context13.next = 2;
1600
+ _context17.next = 2;
1449
1601
  return (0, _Utils.resolveContact)(callingPartyInfo);
1450
1602
  case 2:
1451
- displayInfo = _context13.sent;
1603
+ displayInfo = _context17.sent;
1452
1604
  expect((_displayInfo7 = displayInfo) === null || _displayInfo7 === void 0 ? void 0 : _displayInfo7.id).toStrictEqual('');
1453
1605
  expect((_displayInfo8 = displayInfo) === null || _displayInfo8 === void 0 ? void 0 : _displayInfo8.name).toStrictEqual(peopleListResponse.items[0].displayName);
1454
1606
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
@@ -1457,14 +1609,14 @@ describe('resolveContact tests', function () {
1457
1609
  peopleListResponse.items[0].id = id;
1458
1610
  case 3:
1459
1611
  case "end":
1460
- return _context13.stop();
1612
+ return _context17.stop();
1461
1613
  }
1462
- }, _callee13);
1614
+ }, _callee17);
1463
1615
  })));
1464
- it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1616
+ it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1465
1617
  var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1466
- return _regenerator.default.wrap(function (_context14) {
1467
- while (1) switch (_context14.prev = _context14.next) {
1618
+ return _regenerator.default.wrap(function (_context18) {
1619
+ while (1) switch (_context18.prev = _context18.next) {
1468
1620
  case 0:
1469
1621
  callingPartyInfo = {};
1470
1622
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1475,10 +1627,10 @@ describe('resolveContact tests', function () {
1475
1627
  callingPartyInfo.name = {
1476
1628
  $: 'Name'
1477
1629
  };
1478
- _context14.next = 1;
1630
+ _context18.next = 1;
1479
1631
  return (0, _Utils.resolveContact)(callingPartyInfo);
1480
1632
  case 1:
1481
- displayInfo = _context14.sent;
1633
+ displayInfo = _context18.sent;
1482
1634
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1483
1635
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
1484
1636
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
@@ -1488,14 +1640,14 @@ describe('resolveContact tests', function () {
1488
1640
  peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1489
1641
  case 2:
1490
1642
  case "end":
1491
- return _context14.stop();
1643
+ return _context18.stop();
1492
1644
  }
1493
- }, _callee14);
1645
+ }, _callee18);
1494
1646
  })));
1495
- it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1647
+ it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1496
1648
  var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1497
- return _regenerator.default.wrap(function (_context15) {
1498
- while (1) switch (_context15.prev = _context15.next) {
1649
+ return _regenerator.default.wrap(function (_context19) {
1650
+ while (1) switch (_context19.prev = _context19.next) {
1499
1651
  case 0:
1500
1652
  callingPartyInfo = {};
1501
1653
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1505,10 +1657,10 @@ describe('resolveContact tests', function () {
1505
1657
  callingPartyInfo.name = {
1506
1658
  $: 'Name'
1507
1659
  };
1508
- _context15.next = 1;
1660
+ _context19.next = 1;
1509
1661
  return (0, _Utils.resolveContact)(callingPartyInfo);
1510
1662
  case 1:
1511
- displayInfo = _context15.sent;
1663
+ displayInfo = _context19.sent;
1512
1664
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1513
1665
  displayName: 'Name'
1514
1666
  }));
@@ -1518,9 +1670,9 @@ describe('resolveContact tests', function () {
1518
1670
  peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1519
1671
  case 2:
1520
1672
  case "end":
1521
- return _context15.stop();
1673
+ return _context19.stop();
1522
1674
  }
1523
- }, _callee15);
1675
+ }, _callee19);
1524
1676
  })));
1525
1677
  });
1526
1678
  describe('Store and Fetch voicemail tests', function () {
@@ -1638,40 +1790,40 @@ describe('Infer id from UUID Tests', function () {
1638
1790
  });
1639
1791
  });
1640
1792
  describe('Get endpoint by CALLING_BACKEND tests', function () {
1641
- it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1793
+ it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1642
1794
  var _t;
1643
- return _regenerator.default.wrap(function (_context16) {
1644
- while (1) switch (_context16.prev = _context16.next) {
1795
+ return _regenerator.default.wrap(function (_context20) {
1796
+ while (1) switch (_context20.prev = _context20.next) {
1645
1797
  case 0:
1646
1798
  _t = expect;
1647
- _context16.next = 1;
1799
+ _context20.next = 1;
1648
1800
  return (0, _Utils.getXsiActionEndpoint)(webex, {
1649
1801
  file: 'testFile',
1650
1802
  method: 'testMethod'
1651
1803
  }, _types.CALLING_BACKEND.UCM);
1652
1804
  case 1:
1653
- _t(_context16.sent).toBeInstanceOf(Error);
1805
+ _t(_context20.sent).toBeInstanceOf(Error);
1654
1806
  case 2:
1655
1807
  case "end":
1656
- return _context16.stop();
1808
+ return _context20.stop();
1657
1809
  }
1658
- }, _callee16);
1810
+ }, _callee20);
1659
1811
  })));
1660
- it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1812
+ it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1661
1813
  var _t2;
1662
- return _regenerator.default.wrap(function (_context17) {
1663
- while (1) switch (_context17.prev = _context17.next) {
1814
+ return _regenerator.default.wrap(function (_context21) {
1815
+ while (1) switch (_context21.prev = _context21.next) {
1664
1816
  case 0:
1665
1817
  _t2 = expect;
1666
- _context17.next = 1;
1818
+ _context21.next = 1;
1667
1819
  return (0, _Utils.getVgActionEndpoint)(webex, _types.CALLING_BACKEND.WXC);
1668
1820
  case 1:
1669
- _t2(_context17.sent).toBeInstanceOf(Error);
1821
+ _t2(_context21.sent).toBeInstanceOf(Error);
1670
1822
  case 2:
1671
1823
  case "end":
1672
- return _context17.stop();
1824
+ return _context21.stop();
1673
1825
  }
1674
- }, _callee17);
1826
+ }, _callee21);
1675
1827
  })));
1676
1828
  });
1677
1829
  describe('Get XSI Action Endpoint tests', function () {
@@ -1689,10 +1841,91 @@ describe('Get XSI Action Endpoint tests', function () {
1689
1841
  file: 'testFile',
1690
1842
  method: 'testMethod'
1691
1843
  };
1692
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1844
+ var expectedXsiEndpoint = 'https://api-proxy-si.broadcloudpbx.net/com.broadsoft.xsi-actions';
1845
+ beforeEach(function () {
1846
+ mockWebex.request.mockClear();
1847
+ });
1848
+ it('should return xsiEndpoint for WXC backend using _serviceUrls.hydra', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1849
+ var hydraEndpoint, wxcWebex, result;
1850
+ return _regenerator.default.wrap(function (_context22) {
1851
+ while (1) switch (_context22.prev = _context22.next) {
1852
+ case 0:
1853
+ hydraEndpoint = 'https://hydra-a.wbx2.com/v1/';
1854
+ wxcWebex = {
1855
+ request: jest.fn().mockResolvedValue({
1856
+ statusCode: 200,
1857
+ body: _testFixtures.xsiEndpointUrlResponse
1858
+ }),
1859
+ internal: {
1860
+ services: {
1861
+ _serviceUrls: {
1862
+ hydra: hydraEndpoint
1863
+ },
1864
+ _activeServices: {
1865
+ hydra: 'urn:TEAM:us-east-2_a:hydra'
1866
+ },
1867
+ get: jest.fn()
1868
+ }
1869
+ }
1870
+ };
1871
+ _context22.next = 1;
1872
+ return (0, _Utils.getXsiActionEndpoint)(wxcWebex, loggerContext, _types.CALLING_BACKEND.WXC);
1873
+ case 1:
1874
+ result = _context22.sent;
1875
+ expect(wxcWebex.request).toBeCalledOnceWith({
1876
+ method: _types.HTTP_METHODS.GET,
1877
+ uri: "".concat(hydraEndpoint, "/").concat(_constants2.XSI_ACTION_ENDPOINT_ORG_URL_PARAM)
1878
+ });
1879
+ expect(result).toBe(expectedXsiEndpoint);
1880
+ expect(wxcWebex.internal.services.get).not.toHaveBeenCalled();
1881
+ case 2:
1882
+ case "end":
1883
+ return _context22.stop();
1884
+ }
1885
+ }, _callee22);
1886
+ })));
1887
+ it('should return xsiEndpoint for WXC backend using services.get when _serviceUrls is undefined', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1888
+ var hydraEndpoint, activeHydraCluster, wxcWebex, result;
1889
+ return _regenerator.default.wrap(function (_context23) {
1890
+ while (1) switch (_context23.prev = _context23.next) {
1891
+ case 0:
1892
+ hydraEndpoint = 'https://hydra-a.wbx2.com/v1/';
1893
+ activeHydraCluster = 'urn:TEAM:us-east-2_a:hydra';
1894
+ wxcWebex = {
1895
+ request: jest.fn().mockResolvedValue({
1896
+ statusCode: 200,
1897
+ body: _testFixtures.xsiEndpointUrlResponse
1898
+ }),
1899
+ internal: {
1900
+ services: {
1901
+ _serviceUrls: undefined,
1902
+ _activeServices: {
1903
+ hydra: activeHydraCluster
1904
+ },
1905
+ get: jest.fn().mockReturnValue(hydraEndpoint)
1906
+ }
1907
+ }
1908
+ };
1909
+ _context23.next = 1;
1910
+ return (0, _Utils.getXsiActionEndpoint)(wxcWebex, loggerContext, _types.CALLING_BACKEND.WXC);
1911
+ case 1:
1912
+ result = _context23.sent;
1913
+ expect(wxcWebex.internal.services.get).toBeCalledOnceWith(activeHydraCluster);
1914
+ expect(wxcWebex.request).toBeCalledOnceWith({
1915
+ method: _types.HTTP_METHODS.GET,
1916
+ uri: "".concat(hydraEndpoint, "/").concat(_constants2.XSI_ACTION_ENDPOINT_ORG_URL_PARAM)
1917
+ });
1918
+ expect(result).toBe(expectedXsiEndpoint);
1919
+ case 2:
1920
+ case "end":
1921
+ return _context23.stop();
1922
+ }
1923
+ }, _callee23);
1924
+ })));
1925
+ it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1693
1926
  var mockResponse, xsiEndpoint;
1694
- return _regenerator.default.wrap(function (_context18) {
1695
- while (1) switch (_context18.prev = _context18.next) {
1927
+ return _regenerator.default.wrap(function (_context24) {
1928
+ while (1) switch (_context24.prev = _context24.next) {
1696
1929
  case 0:
1697
1930
  mockResponse = {
1698
1931
  body: {
@@ -1704,22 +1937,22 @@ describe('Get XSI Action Endpoint tests', function () {
1704
1937
  }
1705
1938
  };
1706
1939
  mockWebex.request.mockResolvedValue(mockResponse);
1707
- _context18.next = 1;
1940
+ _context24.next = 1;
1708
1941
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1709
1942
  case 1:
1710
- xsiEndpoint = _context18.sent;
1943
+ xsiEndpoint = _context24.sent;
1711
1944
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1712
1945
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1713
1946
  case 2:
1714
1947
  case "end":
1715
- return _context18.stop();
1948
+ return _context24.stop();
1716
1949
  }
1717
- }, _callee18);
1950
+ }, _callee24);
1718
1951
  })));
1719
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0/', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1952
+ it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0/', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1720
1953
  var mockResponse, xsiEndpoint;
1721
- return _regenerator.default.wrap(function (_context19) {
1722
- while (1) switch (_context19.prev = _context19.next) {
1954
+ return _regenerator.default.wrap(function (_context25) {
1955
+ while (1) switch (_context25.prev = _context25.next) {
1723
1956
  case 0:
1724
1957
  mockResponse = {
1725
1958
  body: {
@@ -1731,22 +1964,22 @@ describe('Get XSI Action Endpoint tests', function () {
1731
1964
  }
1732
1965
  };
1733
1966
  mockWebex.request.mockResolvedValue(mockResponse);
1734
- _context19.next = 1;
1967
+ _context25.next = 1;
1735
1968
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1736
1969
  case 1:
1737
- xsiEndpoint = _context19.sent;
1970
+ xsiEndpoint = _context25.sent;
1738
1971
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1739
1972
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1740
1973
  case 2:
1741
1974
  case "end":
1742
- return _context19.stop();
1975
+ return _context25.stop();
1743
1976
  }
1744
- }, _callee19);
1977
+ }, _callee25);
1745
1978
  })));
1746
- it('should return xsiEndpoint for BWRKS backend when URL does not end with any version', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1979
+ it('should return xsiEndpoint for BWRKS backend when URL does not end with any version', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1747
1980
  var mockResponse, xsiEndpoint;
1748
- return _regenerator.default.wrap(function (_context20) {
1749
- while (1) switch (_context20.prev = _context20.next) {
1981
+ return _regenerator.default.wrap(function (_context26) {
1982
+ while (1) switch (_context26.prev = _context26.next) {
1750
1983
  case 0:
1751
1984
  mockResponse = {
1752
1985
  body: {
@@ -1758,67 +1991,19 @@ describe('Get XSI Action Endpoint tests', function () {
1758
1991
  }
1759
1992
  };
1760
1993
  mockWebex.request.mockResolvedValue(mockResponse);
1761
- _context20.next = 1;
1994
+ _context26.next = 1;
1762
1995
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1763
1996
  case 1:
1764
- xsiEndpoint = _context20.sent;
1997
+ xsiEndpoint = _context26.sent;
1765
1998
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1766
1999
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1767
2000
  case 2:
1768
2001
  case "end":
1769
- return _context20.stop();
2002
+ return _context26.stop();
1770
2003
  }
1771
- }, _callee20);
2004
+ }, _callee26);
1772
2005
  })));
1773
2006
  });
1774
- describe('modifySdpForIPv4', function () {
1775
- it('should return original SDP if input is empty', function () {
1776
- expect((0, _Utils.modifySdpForIPv4)('')).toBe('');
1777
- });
1778
- it('should return original SDP if there is no IPv6 c= line', function () {
1779
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\n\ns=Test Session";
1780
- expect((0, _Utils.modifySdpForIPv4)(sdp)).toEqual(sdp);
1781
- });
1782
- it('should replace IPv6 c= line with default IPv4 if no IPv4 candidate exists', function () {
1783
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1784
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1785
- var result = (0, _Utils.modifySdpForIPv4)(sdp);
1786
- expect(result).toEqual(expectedSdp);
1787
- });
1788
- it('should replace IPv6 c= line with an existing IPv4 candidate address', function () {
1789
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1790
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.2\na=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1791
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1792
- });
1793
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate UDP first', function () {
1794
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\n a=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host";
1795
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10\na=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host\n";
1796
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1797
- });
1798
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate TCP first', function () {
1799
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1800
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\na=candidate:2 1 TCP 2122260223 192.1.1.1 3479 typ host generation 0 network-id 1 network-cost 10\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1801
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1802
- });
1803
- it('should replace all IPv6 c= line if multiple exist', function () {
1804
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP6 2001:db8::2\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1805
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1806
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1807
- });
1808
- it('should not modify SDP if IPv6 c= line is absent and IPv4 candidate already exists', function () {
1809
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\ns=Test Session\nc=IN IP4 192.168.1.1\na=candidate:1 1 UDP 2122260223 192.168.1.1 3478 typ host";
1810
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(sdp.trim());
1811
- });
1812
- it('should handle malformed SDP gracefully and return unmodified input', function () {
1813
- var malformedSdp = "random text without proper format";
1814
- expect((0, _Utils.modifySdpForIPv4)(malformedSdp).trim()).toEqual(malformedSdp.trim());
1815
- });
1816
- it('should handle an SDP with both IP6 and IP4 c= lines correctly', function () {
1817
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP4 192.168.1.3\n a=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1818
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.3\nc=IN IP4 192.168.1.3\na=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1819
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1820
- });
1821
- });
1822
2007
  describe('uploadLogs', function () {
1823
2008
  var submitLogsMock;
1824
2009
  beforeEach(function () {
@@ -1838,19 +2023,19 @@ describe('uploadLogs', function () {
1838
2023
  afterEach(function () {
1839
2024
  jest.clearAllMocks();
1840
2025
  });
1841
- it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
2026
+ it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1842
2027
  var mockMetaData, logSpy, result;
1843
- return _regenerator.default.wrap(function (_context21) {
1844
- while (1) switch (_context21.prev = _context21.next) {
2028
+ return _regenerator.default.wrap(function (_context27) {
2029
+ while (1) switch (_context27.prev = _context27.next) {
1845
2030
  case 0:
1846
2031
  mockMetaData = {
1847
2032
  correlationId: 'test-correlation'
1848
2033
  };
1849
2034
  logSpy = jest.spyOn(_Logger.default, 'info');
1850
- _context21.next = 1;
2035
+ _context27.next = 1;
1851
2036
  return (0, _Utils.uploadLogs)(mockMetaData, true);
1852
2037
  case 1:
1853
- result = _context21.sent;
2038
+ result = _context27.sent;
1854
2039
  expect(result).toEqual({
1855
2040
  trackingid: '1234',
1856
2041
  feedbackId: 'mocked-uuid-12345'
@@ -1883,14 +2068,14 @@ describe('uploadLogs', function () {
1883
2068
  });
1884
2069
  case 2:
1885
2070
  case "end":
1886
- return _context21.stop();
2071
+ return _context27.stop();
1887
2072
  }
1888
- }, _callee21);
2073
+ }, _callee27);
1889
2074
  })));
1890
- it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
2075
+ it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1891
2076
  var mockMetaData, mockError, logSpy, _t3;
1892
- return _regenerator.default.wrap(function (_context22) {
1893
- while (1) switch (_context22.prev = _context22.next) {
2077
+ return _regenerator.default.wrap(function (_context28) {
2078
+ while (1) switch (_context28.prev = _context28.next) {
1894
2079
  case 0:
1895
2080
  mockMetaData = {
1896
2081
  correlationId: 'test-correlation'
@@ -1898,17 +2083,17 @@ describe('uploadLogs', function () {
1898
2083
  mockError = new Error('Upload failed'); // Mock the submitLogs to fail
1899
2084
  submitLogsMock.mockRejectedValueOnce(mockError);
1900
2085
  logSpy = jest.spyOn(_Logger.default, 'error');
1901
- _context22.prev = 1;
1902
- _context22.next = 2;
2086
+ _context28.prev = 1;
2087
+ _context28.next = 2;
1903
2088
  return (0, _Utils.uploadLogs)(mockMetaData, true);
1904
2089
  case 2:
1905
2090
  // If we get here, the test should fail since we expected an exception
1906
2091
  expect(true).toBe(false); // This will fail the test if no exception is thrown
1907
- _context22.next = 4;
2092
+ _context28.next = 4;
1908
2093
  break;
1909
2094
  case 3:
1910
- _context22.prev = 3;
1911
- _t3 = _context22["catch"](1);
2095
+ _context28.prev = 3;
2096
+ _t3 = _context28["catch"](1);
1912
2097
  expect(_t3).toBe(mockError);
1913
2098
  expect(logSpy).toHaveBeenCalledWith("Failed to upload Logs ".concat((0, _stringify.default)(_t3)), {
1914
2099
  file: _constants.UTILS_FILE,
@@ -1935,14 +2120,14 @@ describe('uploadLogs', function () {
1935
2120
  });
1936
2121
  case 4:
1937
2122
  case "end":
1938
- return _context22.stop();
2123
+ return _context28.stop();
1939
2124
  }
1940
- }, _callee22, null, [[1, 3]]);
2125
+ }, _callee28, null, [[1, 3]]);
1941
2126
  })));
1942
- it('should log error and not throw an error if the upload fails with throw exception false', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
2127
+ it('should log error and not throw an error if the upload fails with throw exception false', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
1943
2128
  var mockMetaData, mockError, logSpy, result;
1944
- return _regenerator.default.wrap(function (_context23) {
1945
- while (1) switch (_context23.prev = _context23.next) {
2129
+ return _regenerator.default.wrap(function (_context29) {
2130
+ while (1) switch (_context29.prev = _context29.next) {
1946
2131
  case 0:
1947
2132
  mockMetaData = {
1948
2133
  correlationId: 'test-correlation',
@@ -1951,10 +2136,10 @@ describe('uploadLogs', function () {
1951
2136
  mockError = new Error('Upload failed'); // Mock the submitLogs to fail
1952
2137
  submitLogsMock.mockRejectedValueOnce(mockError);
1953
2138
  logSpy = jest.spyOn(_Logger.default, 'error');
1954
- _context23.next = 1;
2139
+ _context29.next = 1;
1955
2140
  return (0, _Utils.uploadLogs)(mockMetaData, false);
1956
2141
  case 1:
1957
- result = _context23.sent;
2142
+ result = _context29.sent;
1958
2143
  expect(result).toBeUndefined();
1959
2144
  expect(logSpy).toHaveBeenCalledWith("Failed to upload Logs ".concat((0, _stringify.default)(mockError)), {
1960
2145
  file: _constants.UTILS_FILE,
@@ -1981,9 +2166,88 @@ describe('uploadLogs', function () {
1981
2166
  });
1982
2167
  case 2:
1983
2168
  case "end":
1984
- return _context23.stop();
2169
+ return _context29.stop();
1985
2170
  }
1986
- }, _callee23);
2171
+ }, _callee29);
1987
2172
  })));
1988
2173
  });
2174
+ describe('resolveCallingBackend', function () {
2175
+ var createDevice = function createDevice(callingBehavior, entitlementKeys) {
2176
+ return {
2177
+ url: 'https://wdm.example.com/devices/123',
2178
+ userId: 'user-id',
2179
+ orgId: 'org-id',
2180
+ version: '1.0',
2181
+ callingBehavior: callingBehavior,
2182
+ features: {
2183
+ developer: {
2184
+ models: [],
2185
+ get: jest.fn()
2186
+ },
2187
+ entitlement: {
2188
+ models: entitlementKeys.map(function (key) {
2189
+ return {
2190
+ _values: {
2191
+ key: key
2192
+ }
2193
+ };
2194
+ })
2195
+ }
2196
+ }
2197
+ };
2198
+ };
2199
+ it.each([['bc-sp-basic', _types.CALLING_BACKEND.WXC], ['bc-sp-standard', _types.CALLING_BACKEND.WXC]])('returns WXC when callingBehavior is NATIVE_WEBEX_TEAMS_CALLING and entitlement is %s', function (entitlement, expected) {
2200
+ var device = createDevice('NATIVE_WEBEX_TEAMS_CALLING', [entitlement]);
2201
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(expected);
2202
+ });
2203
+ it('returns BWRKS when callingBehavior is NATIVE_WEBEX_TEAMS_CALLING and entitlement is broadworks-connector', function () {
2204
+ var device = createDevice('NATIVE_WEBEX_TEAMS_CALLING', ['broadworks-connector']);
2205
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.BWRKS);
2206
+ });
2207
+ it('returns UCM when callingBehavior is NATIVE_SIP_CALL_TO_UCM', function () {
2208
+ var device = createDevice('NATIVE_SIP_CALL_TO_UCM', []);
2209
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.UCM);
2210
+ });
2211
+ it('returns INVALID when callingBehavior is unknown', function () {
2212
+ var device = createDevice('UNKNOWN_BEHAVIOR', []);
2213
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.INVALID);
2214
+ });
2215
+ it('returns INVALID when callingBehavior is NATIVE_WEBEX_TEAMS_CALLING but no matching entitlement', function () {
2216
+ var device = createDevice('NATIVE_WEBEX_TEAMS_CALLING', ['some-other-entitlement']);
2217
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.INVALID);
2218
+ });
2219
+ it('matches the first qualifying entitlement when multiple are present', function () {
2220
+ var device = createDevice('NATIVE_WEBEX_TEAMS_CALLING', ['broadworks-connector', 'bc-sp-basic']);
2221
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.BWRKS);
2222
+ });
2223
+ });
2224
+ describe('getCallingBackEnd', function () {
2225
+ it('passes webex.internal.device to resolveCallingBackend and returns its result', function () {
2226
+ var device = {
2227
+ url: 'https://wdm.example.com/devices/123',
2228
+ userId: 'user-id',
2229
+ orgId: 'org-id',
2230
+ version: '1.0',
2231
+ callingBehavior: 'NATIVE_SIP_CALL_TO_UCM',
2232
+ features: {
2233
+ developer: {
2234
+ models: [],
2235
+ get: jest.fn()
2236
+ },
2237
+ entitlement: {
2238
+ models: []
2239
+ }
2240
+ }
2241
+ };
2242
+ var mockWebex = {
2243
+ internal: {
2244
+ device: device
2245
+ }
2246
+ };
2247
+ var result = (0, _Utils.getCallingBackEnd)(mockWebex);
2248
+ expect(result).toBe((0, _Utils.resolveCallingBackend)(device));
2249
+ expect((0, _Utils.resolveCallingBackend)(device)).toBe(_types.CALLING_BACKEND.UCM);
2250
+ expect(result).toBe(_types.CALLING_BACKEND.UCM);
2251
+ });
2252
+ });
1989
2253
  //# sourceMappingURL=Utils.test.js.map