@webex/calling 3.0.0-next.4 → 3.0.0-next.41

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 (316) hide show
  1. package/CHANGELOG.md +1403 -1403
  2. package/README.md +74 -74
  3. package/dist/CallHistory/CallHistory.js +201 -0
  4. package/dist/CallHistory/CallHistory.js.map +1 -0
  5. package/dist/CallHistory/CallHistory.test.js +142 -0
  6. package/dist/CallHistory/CallHistory.test.js.map +1 -0
  7. package/dist/CallHistory/callHistoryFixtures.js +366 -0
  8. package/dist/CallHistory/callHistoryFixtures.js.map +1 -0
  9. package/dist/CallHistory/constants.js +17 -0
  10. package/dist/CallHistory/constants.js.map +1 -0
  11. package/dist/CallHistory/types.js +7 -0
  12. package/dist/CallHistory/types.js.map +1 -0
  13. package/dist/CallSettings/CallSettings.js +279 -0
  14. package/dist/CallSettings/CallSettings.js.map +1 -0
  15. package/dist/CallSettings/CallSettings.test.js +122 -0
  16. package/dist/CallSettings/CallSettings.test.js.map +1 -0
  17. package/dist/CallSettings/UcmBackendConnector.js +216 -0
  18. package/dist/CallSettings/UcmBackendConnector.js.map +1 -0
  19. package/dist/CallSettings/UcmBackendConnector.test.js +259 -0
  20. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -0
  21. package/dist/CallSettings/WxCallBackendConnector.js +547 -0
  22. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -0
  23. package/dist/CallSettings/WxCallBackendConnector.test.js +802 -0
  24. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -0
  25. package/dist/CallSettings/constants.js +19 -0
  26. package/dist/CallSettings/constants.js.map +1 -0
  27. package/dist/CallSettings/testFixtures.js +68 -0
  28. package/dist/CallSettings/testFixtures.js.map +1 -0
  29. package/dist/CallSettings/types.js +7 -0
  30. package/dist/CallSettings/types.js.map +1 -0
  31. package/dist/CallingClient/CallingClient.js +631 -0
  32. package/dist/CallingClient/CallingClient.js.map +1 -0
  33. package/dist/CallingClient/CallingClient.test.js +992 -0
  34. package/dist/CallingClient/CallingClient.test.js.map +1 -0
  35. package/dist/CallingClient/callRecordFixtures.js +101 -0
  36. package/dist/CallingClient/callRecordFixtures.js.map +1 -0
  37. package/dist/CallingClient/calling/CallerId/index.js +267 -0
  38. package/dist/CallingClient/calling/CallerId/index.js.map +1 -0
  39. package/dist/CallingClient/calling/CallerId/index.test.js +274 -0
  40. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -0
  41. package/dist/CallingClient/calling/CallerId/types.js +7 -0
  42. package/dist/CallingClient/calling/CallerId/types.js.map +1 -0
  43. package/dist/CallingClient/calling/call.js +3055 -0
  44. package/dist/CallingClient/calling/call.js.map +1 -0
  45. package/dist/CallingClient/calling/call.test.js +2858 -0
  46. package/dist/CallingClient/calling/call.test.js.map +1 -0
  47. package/dist/CallingClient/calling/callManager.js +432 -0
  48. package/dist/CallingClient/calling/callManager.js.map +1 -0
  49. package/dist/CallingClient/calling/callManager.test.js +683 -0
  50. package/dist/CallingClient/calling/callManager.test.js.map +1 -0
  51. package/dist/CallingClient/calling/index.js +30 -0
  52. package/dist/CallingClient/calling/index.js.map +1 -0
  53. package/dist/CallingClient/calling/types.js +69 -0
  54. package/dist/CallingClient/calling/types.js.map +1 -0
  55. package/dist/CallingClient/callingClientFixtures.js +143 -0
  56. package/dist/CallingClient/callingClientFixtures.js.map +1 -0
  57. package/dist/CallingClient/constants.js +134 -0
  58. package/dist/CallingClient/constants.js.map +1 -0
  59. package/dist/CallingClient/line/index.js +314 -0
  60. package/dist/CallingClient/line/index.js.map +1 -0
  61. package/dist/CallingClient/line/line.test.js +270 -0
  62. package/dist/CallingClient/line/line.test.js.map +1 -0
  63. package/dist/CallingClient/line/types.js +21 -0
  64. package/dist/CallingClient/line/types.js.map +1 -0
  65. package/dist/CallingClient/registration/index.js +19 -0
  66. package/dist/CallingClient/registration/index.js.map +1 -0
  67. package/dist/CallingClient/registration/register.js +1286 -0
  68. package/dist/CallingClient/registration/register.js.map +1 -0
  69. package/dist/CallingClient/registration/register.test.js +839 -0
  70. package/dist/CallingClient/registration/register.test.js.map +1 -0
  71. package/dist/CallingClient/registration/registerFixtures.js +36 -0
  72. package/dist/CallingClient/registration/registerFixtures.js.map +1 -0
  73. package/dist/CallingClient/registration/types.js +7 -0
  74. package/dist/CallingClient/registration/types.js.map +1 -0
  75. package/dist/CallingClient/types.js +7 -0
  76. package/dist/CallingClient/types.js.map +1 -0
  77. package/dist/Contacts/ContactsClient.js +1156 -0
  78. package/dist/Contacts/ContactsClient.js.map +1 -0
  79. package/dist/Contacts/ContactsClient.test.js +725 -0
  80. package/dist/Contacts/ContactsClient.test.js.map +1 -0
  81. package/dist/Contacts/constants.js +28 -0
  82. package/dist/Contacts/constants.js.map +1 -0
  83. package/dist/Contacts/contactFixtures.js +314 -0
  84. package/dist/Contacts/contactFixtures.js.map +1 -0
  85. package/dist/Contacts/types.js +43 -0
  86. package/dist/Contacts/types.js.map +1 -0
  87. package/dist/Errors/catalog/CallError.js +92 -0
  88. package/dist/Errors/catalog/CallError.js.map +1 -0
  89. package/dist/Errors/catalog/CallingDeviceError.js +86 -0
  90. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -0
  91. package/dist/Errors/catalog/ExtendedError.js +44 -0
  92. package/dist/Errors/catalog/ExtendedError.js.map +1 -0
  93. package/dist/Errors/catalog/LineError.js +88 -0
  94. package/dist/Errors/catalog/LineError.js.map +1 -0
  95. package/dist/Errors/index.js +28 -0
  96. package/dist/Errors/index.js.map +1 -0
  97. package/dist/Errors/types.js +57 -0
  98. package/dist/Errors/types.js.map +1 -0
  99. package/dist/Events/impl/index.js +81 -0
  100. package/dist/Events/impl/index.js.map +1 -0
  101. package/dist/Events/types.js +103 -0
  102. package/dist/Events/types.js.map +1 -0
  103. package/dist/Logger/index.js +220 -0
  104. package/dist/Logger/index.js.map +1 -0
  105. package/dist/Logger/index.test.js +62 -0
  106. package/dist/Logger/index.test.js.map +1 -0
  107. package/dist/Logger/types.js +34 -0
  108. package/dist/Logger/types.js.map +1 -0
  109. package/dist/Metrics/index.js +327 -0
  110. package/dist/Metrics/index.js.map +1 -0
  111. package/dist/Metrics/index.test.js +291 -0
  112. package/dist/Metrics/index.test.js.map +1 -0
  113. package/dist/Metrics/types.js +45 -0
  114. package/dist/Metrics/types.js.map +1 -0
  115. package/dist/SDKConnector/index.js +104 -0
  116. package/dist/SDKConnector/index.js.map +1 -0
  117. package/dist/SDKConnector/index.test.js +9 -0
  118. package/dist/SDKConnector/index.test.js.map +1 -0
  119. package/dist/SDKConnector/types.js +7 -0
  120. package/dist/SDKConnector/types.js.map +1 -0
  121. package/dist/SDKConnector/utils.js +39 -0
  122. package/dist/SDKConnector/utils.js.map +1 -0
  123. package/dist/SDKConnector/utils.test.js +9 -0
  124. package/dist/SDKConnector/utils.test.js.map +1 -0
  125. package/dist/Voicemail/BroadworksBackendConnector.js +641 -0
  126. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -0
  127. package/dist/Voicemail/BroadworksBackendConnector.test.js +733 -0
  128. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -0
  129. package/dist/Voicemail/UcmBackendConnector.js +574 -0
  130. package/dist/Voicemail/UcmBackendConnector.js.map +1 -0
  131. package/dist/Voicemail/UcmBackendConnector.test.js +629 -0
  132. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -0
  133. package/dist/Voicemail/Voicemail.js +380 -0
  134. package/dist/Voicemail/Voicemail.js.map +1 -0
  135. package/dist/Voicemail/Voicemail.test.js +226 -0
  136. package/dist/Voicemail/Voicemail.test.js.map +1 -0
  137. package/dist/Voicemail/WxCallBackendConnector.js +547 -0
  138. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -0
  139. package/dist/Voicemail/WxCallBackendConnector.test.js +942 -0
  140. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -0
  141. package/dist/Voicemail/constants.js +37 -0
  142. package/dist/Voicemail/constants.js.map +1 -0
  143. package/dist/Voicemail/types.js +7 -0
  144. package/dist/Voicemail/types.js.map +1 -0
  145. package/dist/Voicemail/voicemailFixture.js +524 -0
  146. package/dist/Voicemail/voicemailFixture.js.map +1 -0
  147. package/dist/api.js +157 -0
  148. package/dist/api.js.map +1 -0
  149. package/dist/common/Utils.js +1257 -0
  150. package/dist/common/Utils.js.map +1 -0
  151. package/dist/common/Utils.test.js +1227 -0
  152. package/dist/common/Utils.test.js.map +1 -0
  153. package/dist/common/constants.js +49 -0
  154. package/dist/common/constants.js.map +1 -0
  155. package/dist/common/index.js +19 -0
  156. package/dist/common/index.js.map +1 -0
  157. package/dist/common/testUtil.js +959 -0
  158. package/dist/common/testUtil.js.map +1 -0
  159. package/dist/common/types.js +66 -0
  160. package/dist/common/types.js.map +1 -0
  161. package/dist/index.js +309 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/module/CallHistory/CallHistory.js +83 -81
  164. package/dist/module/CallHistory/callHistoryFixtures.js +366 -307
  165. package/dist/module/CallHistory/constants.js +9 -9
  166. package/dist/module/CallHistory/types.js +1 -1
  167. package/dist/module/CallSettings/CallSettings.js +65 -65
  168. package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
  169. package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
  170. package/dist/module/CallSettings/constants.js +11 -11
  171. package/dist/module/CallSettings/testFixtures.js +62 -62
  172. package/dist/module/CallSettings/types.js +1 -1
  173. package/dist/module/CallingClient/CallingClient.js +265 -248
  174. package/dist/module/CallingClient/callRecordFixtures.js +93 -93
  175. package/dist/module/CallingClient/calling/CallerId/index.js +149 -169
  176. package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
  177. package/dist/module/CallingClient/calling/call.js +1701 -1658
  178. package/dist/module/CallingClient/calling/callManager.js +278 -284
  179. package/dist/module/CallingClient/calling/index.js +2 -2
  180. package/dist/module/CallingClient/calling/types.js +53 -53
  181. package/dist/module/CallingClient/callingClientFixtures.js +156 -38
  182. package/dist/module/CallingClient/constants.js +126 -122
  183. package/dist/module/CallingClient/line/index.js +155 -158
  184. package/dist/module/CallingClient/line/types.js +10 -15
  185. package/dist/module/CallingClient/registration/index.js +1 -1
  186. package/dist/module/CallingClient/registration/register.js +515 -507
  187. package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
  188. package/dist/module/CallingClient/registration/types.js +1 -1
  189. package/dist/module/CallingClient/types.js +1 -1
  190. package/dist/module/Contacts/ContactsClient.js +487 -484
  191. package/dist/module/Contacts/constants.js +20 -20
  192. package/dist/module/Contacts/contactFixtures.js +284 -284
  193. package/dist/module/Contacts/types.js +10 -10
  194. package/dist/module/Errors/catalog/CallError.js +26 -26
  195. package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
  196. package/dist/module/Errors/catalog/ExtendedError.js +10 -10
  197. package/dist/module/Errors/catalog/LineError.js +24 -24
  198. package/dist/module/Errors/index.js +3 -2
  199. package/dist/module/Errors/types.js +48 -48
  200. package/dist/module/Events/impl/index.js +19 -19
  201. package/dist/module/Events/types.js +85 -83
  202. package/dist/module/Logger/index.js +114 -114
  203. package/dist/module/Logger/types.js +25 -25
  204. package/dist/module/Metrics/index.js +232 -232
  205. package/dist/module/Metrics/types.js +37 -37
  206. package/dist/module/SDKConnector/index.js +39 -39
  207. package/dist/module/SDKConnector/types.js +1 -1
  208. package/dist/module/SDKConnector/utils.js +12 -12
  209. package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
  210. package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
  211. package/dist/module/Voicemail/Voicemail.js +110 -110
  212. package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
  213. package/dist/module/Voicemail/constants.js +29 -29
  214. package/dist/module/Voicemail/types.js +1 -1
  215. package/dist/module/Voicemail/voicemailFixture.js +510 -510
  216. package/dist/module/api.js +7 -6
  217. package/dist/module/common/Utils.js +797 -802
  218. package/dist/module/common/constants.js +41 -41
  219. package/dist/module/common/index.js +1 -1
  220. package/dist/module/common/testUtil.js +939 -938
  221. package/dist/module/common/types.js +58 -57
  222. package/dist/module/index.js +17 -8
  223. package/dist/types/CallHistory/CallHistory.d.ts +18 -17
  224. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  225. package/dist/types/CallHistory/callHistoryFixtures.d.ts +95 -94
  226. package/dist/types/CallHistory/callHistoryFixtures.d.ts.map +1 -1
  227. package/dist/types/CallHistory/constants.d.ts +9 -9
  228. package/dist/types/CallHistory/types.d.ts +18 -18
  229. package/dist/types/CallSettings/CallSettings.d.ts +19 -19
  230. package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
  231. package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
  232. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  233. package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
  234. package/dist/types/CallSettings/constants.d.ts +11 -11
  235. package/dist/types/CallSettings/testFixtures.d.ts +15 -15
  236. package/dist/types/CallSettings/types.d.ts +108 -107
  237. package/dist/types/CallSettings/types.d.ts.map +1 -1
  238. package/dist/types/CallingClient/CallingClient.d.ts +37 -35
  239. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  240. package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
  241. package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
  242. package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
  243. package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
  244. package/dist/types/CallingClient/calling/CallerId/types.d.ts.map +1 -1
  245. package/dist/types/CallingClient/calling/call.d.ts +98 -96
  246. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  247. package/dist/types/CallingClient/calling/callManager.d.ts +24 -25
  248. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  249. package/dist/types/CallingClient/calling/index.d.ts +2 -2
  250. package/dist/types/CallingClient/calling/types.d.ts +206 -206
  251. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  252. package/dist/types/CallingClient/callingClientFixtures.d.ts +86 -18
  253. package/dist/types/CallingClient/callingClientFixtures.d.ts.map +1 -1
  254. package/dist/types/CallingClient/constants.d.ts +126 -122
  255. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  256. package/dist/types/CallingClient/line/index.d.ts +43 -43
  257. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  258. package/dist/types/CallingClient/line/types.d.ts +43 -55
  259. package/dist/types/CallingClient/line/types.d.ts.map +1 -1
  260. package/dist/types/CallingClient/registration/index.d.ts +1 -1
  261. package/dist/types/CallingClient/registration/register.d.ts +64 -64
  262. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  263. package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
  264. package/dist/types/CallingClient/registration/types.d.ts +20 -20
  265. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  266. package/dist/types/CallingClient/types.d.ts +31 -29
  267. package/dist/types/CallingClient/types.d.ts.map +1 -1
  268. package/dist/types/Contacts/ContactsClient.d.ts +27 -26
  269. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  270. package/dist/types/Contacts/constants.d.ts +19 -19
  271. package/dist/types/Contacts/contactFixtures.d.ts +280 -280
  272. package/dist/types/Contacts/types.d.ts +74 -72
  273. package/dist/types/Contacts/types.d.ts.map +1 -1
  274. package/dist/types/Errors/catalog/CallError.d.ts +11 -11
  275. package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
  276. package/dist/types/Errors/catalog/CallingDeviceError.d.ts.map +1 -1
  277. package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
  278. package/dist/types/Errors/catalog/LineError.d.ts +10 -10
  279. package/dist/types/Errors/catalog/LineError.d.ts.map +1 -1
  280. package/dist/types/Errors/index.d.ts +3 -2
  281. package/dist/types/Errors/index.d.ts.map +1 -1
  282. package/dist/types/Errors/types.d.ts +59 -60
  283. package/dist/types/Errors/types.d.ts.map +1 -1
  284. package/dist/types/Events/impl/index.d.ts +8 -8
  285. package/dist/types/Events/types.d.ts +311 -288
  286. package/dist/types/Events/types.d.ts.map +1 -1
  287. package/dist/types/Logger/index.d.ts +12 -12
  288. package/dist/types/Logger/types.d.ts +25 -25
  289. package/dist/types/Metrics/index.d.ts +5 -5
  290. package/dist/types/Metrics/types.d.ts +42 -42
  291. package/dist/types/SDKConnector/index.d.ts +12 -12
  292. package/dist/types/SDKConnector/types.d.ts +129 -128
  293. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  294. package/dist/types/SDKConnector/utils.d.ts +5 -5
  295. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
  296. package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
  297. package/dist/types/Voicemail/Voicemail.d.ts +27 -27
  298. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  299. package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
  300. package/dist/types/Voicemail/constants.d.ts +29 -29
  301. package/dist/types/Voicemail/types.d.ts +133 -133
  302. package/dist/types/Voicemail/types.d.ts.map +1 -1
  303. package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
  304. package/dist/types/api.d.ts +16 -16
  305. package/dist/types/api.d.ts.map +1 -1
  306. package/dist/types/common/Utils.d.ts +34 -34
  307. package/dist/types/common/Utils.d.ts.map +1 -1
  308. package/dist/types/common/constants.d.ts +41 -41
  309. package/dist/types/common/index.d.ts +1 -1
  310. package/dist/types/common/testUtil.d.ts +3612 -3611
  311. package/dist/types/common/testUtil.d.ts.map +1 -1
  312. package/dist/types/common/types.d.ts +192 -191
  313. package/dist/types/common/types.d.ts.map +1 -1
  314. package/dist/types/index.d.ts +21 -8
  315. package/dist/types/index.d.ts.map +1 -1
  316. package/package.json +5 -3
@@ -0,0 +1,1286 @@
1
+ "use strict";
2
+
3
+ var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
4
+ var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
5
+ var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
6
+ var _Array$isArray = require("@babel/runtime-corejs2/core-js/array/is-array");
7
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
9
+ _Object$defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ exports.createRegistration = exports.Registration = void 0;
13
+ var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
14
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
15
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
17
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
19
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
20
+ var _uuid = require("uuid");
21
+ var _types = require("../../Errors/types");
22
+ var _common = require("../../common");
23
+ var _types2 = require("../../Metrics/types");
24
+ var _Metrics = require("../../Metrics");
25
+ var _calling = require("../calling");
26
+ var _Logger = _interopRequireDefault(require("../../Logger"));
27
+ var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
28
+ var _types3 = require("../../common/types");
29
+ var _constants = require("../constants");
30
+ var _types4 = require("../line/types");
31
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
32
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
33
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
34
+ /**
35
+ *
36
+ */
37
+ var Registration = exports.Registration = /*#__PURE__*/function () {
38
+ /**
39
+ */
40
+ function Registration(webex, serviceData, mutex, lineEmitter, logLevel) {
41
+ (0, _classCallCheck2.default)(this, Registration);
42
+ (0, _defineProperty2.default)(this, "sdkConnector", void 0);
43
+ (0, _defineProperty2.default)(this, "webex", void 0);
44
+ (0, _defineProperty2.default)(this, "userId", '');
45
+ (0, _defineProperty2.default)(this, "serviceData", void 0);
46
+ (0, _defineProperty2.default)(this, "failback429RetryAttempts", void 0);
47
+ (0, _defineProperty2.default)(this, "registrationStatus", void 0);
48
+ (0, _defineProperty2.default)(this, "failbackTimer", void 0);
49
+ (0, _defineProperty2.default)(this, "activeMobiusUrl", void 0);
50
+ (0, _defineProperty2.default)(this, "keepaliveTimer", void 0);
51
+ (0, _defineProperty2.default)(this, "rehomingIntervalMin", void 0);
52
+ (0, _defineProperty2.default)(this, "rehomingIntervalMax", void 0);
53
+ (0, _defineProperty2.default)(this, "mutex", void 0);
54
+ (0, _defineProperty2.default)(this, "metricManager", void 0);
55
+ (0, _defineProperty2.default)(this, "lineEmitter", void 0);
56
+ (0, _defineProperty2.default)(this, "callManager", void 0);
57
+ (0, _defineProperty2.default)(this, "deviceInfo", {});
58
+ (0, _defineProperty2.default)(this, "primaryMobiusUris", void 0);
59
+ (0, _defineProperty2.default)(this, "backupMobiusUris", void 0);
60
+ (0, _defineProperty2.default)(this, "registerRetry", false);
61
+ (0, _defineProperty2.default)(this, "reconnectPending", false);
62
+ this.sdkConnector = _SDKConnector.default;
63
+ this.serviceData = serviceData;
64
+ if (!this.sdkConnector.getWebex()) {
65
+ _SDKConnector.default.setWebex(webex);
66
+ }
67
+ this.webex = this.sdkConnector.getWebex();
68
+ this.userId = this.webex.internal.device.userId;
69
+ this.registrationStatus = _types3.RegistrationStatus.IDLE;
70
+ this.failback429RetryAttempts = 0;
71
+ _Logger.default.setLogger(logLevel, _constants.REGISTRATION_FILE);
72
+ this.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
73
+ this.rehomingIntervalMax = _constants.DEFAULT_REHOMING_INTERVAL_MAX;
74
+ this.mutex = mutex;
75
+ this.callManager = (0, _calling.getCallManager)(this.webex, serviceData.indicator);
76
+ this.metricManager = (0, _Metrics.getMetricManager)(this.webex, serviceData.indicator);
77
+ this.lineEmitter = lineEmitter;
78
+ this.primaryMobiusUris = [];
79
+ this.backupMobiusUris = [];
80
+ }
81
+ (0, _createClass2.default)(Registration, [{
82
+ key: "getActiveMobiusUrl",
83
+ value: function getActiveMobiusUrl() {
84
+ return this.activeMobiusUrl;
85
+ }
86
+ }, {
87
+ key: "setActiveMobiusUrl",
88
+ value: function setActiveMobiusUrl(url) {
89
+ _Logger.default.info("ActiveMobiusUrl: ".concat(url), {
90
+ method: 'setActiveMobiusUrl',
91
+ file: _constants.REGISTRATION_FILE
92
+ });
93
+ this.activeMobiusUrl = url;
94
+ this.callManager.updateActiveMobius(url);
95
+ }
96
+ }, {
97
+ key: "setMobiusServers",
98
+ value: function setMobiusServers(primaryMobiusUris, backupMobiusUris) {
99
+ this.primaryMobiusUris = primaryMobiusUris;
100
+ this.backupMobiusUris = backupMobiusUris;
101
+ }
102
+
103
+ /**
104
+ * Implementation of sending keepalive.
105
+ *
106
+ */
107
+ }, {
108
+ key: "postKeepAlive",
109
+ value: (function () {
110
+ var _postKeepAlive = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
111
+ return _regenerator.default.wrap(function _callee$(_context) {
112
+ while (1) switch (_context.prev = _context.next) {
113
+ case 0:
114
+ return _context.abrupt("return", this.webex.request({
115
+ uri: "".concat(url, "/status"),
116
+ method: _types3.HTTP_METHODS.POST,
117
+ headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT),
118
+ service: _types3.ALLOWED_SERVICES.MOBIUS
119
+ }));
120
+ case 1:
121
+ case "end":
122
+ return _context.stop();
123
+ }
124
+ }, _callee, this);
125
+ }));
126
+ function postKeepAlive(_x) {
127
+ return _postKeepAlive.apply(this, arguments);
128
+ }
129
+ return postKeepAlive;
130
+ }()
131
+ /**
132
+ * Implementation of delete device.
133
+ *
134
+ */
135
+ )
136
+ }, {
137
+ key: "deleteRegistration",
138
+ value: (function () {
139
+ var _deleteRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url, deviceId, deviceUrl) {
140
+ var _response;
141
+ var response;
142
+ return _regenerator.default.wrap(function _callee2$(_context2) {
143
+ while (1) switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ _context2.prev = 0;
146
+ _context2.t0 = fetch;
147
+ _context2.t1 = "".concat(url).concat(_constants.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId);
148
+ _context2.t2 = _types3.HTTP_METHODS.DELETE;
149
+ _context2.t3 = _defineProperty2.default;
150
+ _context2.t4 = _defineProperty2.default;
151
+ _context2.t5 = _defineProperty2.default;
152
+ _context2.t6 = (0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, deviceUrl);
153
+ _context2.next = 10;
154
+ return this.webex.credentials.getUserToken();
155
+ case 10:
156
+ _context2.t7 = _context2.sent;
157
+ _context2.t8 = (0, _context2.t5)(_context2.t6, "Authorization", _context2.t7);
158
+ _context2.t9 = "".concat(_constants.WEBEX_WEB_CLIENT, "_").concat((0, _uuid.v4)());
159
+ _context2.t10 = (0, _context2.t4)(_context2.t8, "trackingId", _context2.t9);
160
+ _context2.t11 = _constants.SPARK_USER_AGENT;
161
+ _context2.t12 = _constants.CALLING_USER_AGENT;
162
+ _context2.t13 = (0, _context2.t3)(_context2.t10, _context2.t11, _context2.t12);
163
+ _context2.t14 = {
164
+ method: _context2.t2,
165
+ headers: _context2.t13
166
+ };
167
+ _context2.next = 20;
168
+ return (0, _context2.t0)(_context2.t1, _context2.t14);
169
+ case 20:
170
+ response = _context2.sent;
171
+ _context2.next = 26;
172
+ break;
173
+ case 23:
174
+ _context2.prev = 23;
175
+ _context2.t15 = _context2["catch"](0);
176
+ _Logger.default.warn("Delete failed with Mobius", {});
177
+ case 26:
178
+ this.setStatus(_types3.RegistrationStatus.INACTIVE);
179
+ this.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
180
+ return _context2.abrupt("return", (_response = response) === null || _response === void 0 ? void 0 : _response.json());
181
+ case 29:
182
+ case "end":
183
+ return _context2.stop();
184
+ }
185
+ }, _callee2, this, [[0, 23]]);
186
+ }));
187
+ function deleteRegistration(_x2, _x3, _x4) {
188
+ return _deleteRegistration.apply(this, arguments);
189
+ }
190
+ return deleteRegistration;
191
+ }()
192
+ /**
193
+ * Implementation of POST request for device registration.
194
+ *
195
+ */
196
+ )
197
+ }, {
198
+ key: "postRegistration",
199
+ value: (function () {
200
+ var _postRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
201
+ var deviceInfo;
202
+ return _regenerator.default.wrap(function _callee3$(_context3) {
203
+ while (1) switch (_context3.prev = _context3.next) {
204
+ case 0:
205
+ deviceInfo = {
206
+ userId: this.userId,
207
+ clientDeviceUri: this.webex.internal.device.url,
208
+ serviceData: this.serviceData
209
+ };
210
+ return _context3.abrupt("return", this.webex.request({
211
+ uri: "".concat(url, "device"),
212
+ method: _types3.HTTP_METHODS.POST,
213
+ headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT),
214
+ body: deviceInfo,
215
+ service: _types3.ALLOWED_SERVICES.MOBIUS
216
+ }));
217
+ case 2:
218
+ case "end":
219
+ return _context3.stop();
220
+ }
221
+ }, _callee3, this);
222
+ }));
223
+ function postRegistration(_x5) {
224
+ return _postRegistration.apply(this, arguments);
225
+ }
226
+ return postRegistration;
227
+ }()
228
+ /**
229
+ * Re-attempts registration with the mobius url it was last registered
230
+ * to, that mobius url is expected to be updated already in this.activeMobiusUrl.
231
+ */
232
+ )
233
+ }, {
234
+ key: "restorePreviousRegistration",
235
+ value: (function () {
236
+ var _restorePreviousRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(caller) {
237
+ var abort;
238
+ return _regenerator.default.wrap(function _callee4$(_context4) {
239
+ while (1) switch (_context4.prev = _context4.next) {
240
+ case 0:
241
+ abort = false;
242
+ if (!this.activeMobiusUrl) {
243
+ _context4.next = 5;
244
+ break;
245
+ }
246
+ _context4.next = 4;
247
+ return this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
248
+ case 4:
249
+ abort = _context4.sent;
250
+ case 5:
251
+ return _context4.abrupt("return", abort);
252
+ case 6:
253
+ case "end":
254
+ return _context4.stop();
255
+ }
256
+ }, _callee4, this);
257
+ }));
258
+ function restorePreviousRegistration(_x6) {
259
+ return _restorePreviousRegistration.apply(this, arguments);
260
+ }
261
+ return restorePreviousRegistration;
262
+ }()
263
+ /**
264
+ * When a failback request is rejected with 429, it means the
265
+ * request did not even land on primary mobius to know if it
266
+ * can handle this device registration now, in such cases this
267
+ * method is called to retry sooner than the rehoming timer value.
268
+ */
269
+ )
270
+ }, {
271
+ key: "scheduleFailback429Retry",
272
+ value: (function () {
273
+ var _scheduleFailback429Retry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
274
+ var interval, abort;
275
+ return _regenerator.default.wrap(function _callee5$(_context5) {
276
+ while (1) switch (_context5.prev = _context5.next) {
277
+ case 0:
278
+ if (!(this.failback429RetryAttempts >= _constants.REG_FAILBACK_429_MAX_RETRIES)) {
279
+ _context5.next = 2;
280
+ break;
281
+ }
282
+ return _context5.abrupt("return");
283
+ case 2:
284
+ this.clearFailbackTimer();
285
+ this.failback429RetryAttempts += 1;
286
+ _Logger.default.log("Received 429 while rehoming, 429 retry count : ".concat(this.failback429RetryAttempts), {
287
+ file: _constants.REGISTRATION_FILE,
288
+ method: _constants.FAILBACK_429_RETRY_UTIL
289
+ });
290
+ interval = this.getRegRetryInterval(this.failback429RetryAttempts);
291
+ this.startFailbackTimer(interval);
292
+ _context5.next = 9;
293
+ return this.restorePreviousRegistration(_constants.FAILBACK_429_RETRY_UTIL);
294
+ case 9:
295
+ abort = _context5.sent;
296
+ if (!(!abort && !this.isDeviceRegistered())) {
297
+ _context5.next = 13;
298
+ break;
299
+ }
300
+ _context5.next = 13;
301
+ return this.restartRegistration(_constants.FAILBACK_429_RETRY_UTIL);
302
+ case 13:
303
+ case "end":
304
+ return _context5.stop();
305
+ }
306
+ }, _callee5, this);
307
+ }));
308
+ function scheduleFailback429Retry() {
309
+ return _scheduleFailback429Retry.apply(this, arguments);
310
+ }
311
+ return scheduleFailback429Retry;
312
+ }()
313
+ /**
314
+ * Calculates and returns a random interval value using input argument
315
+ * attempt as the variable factor.
316
+ *
317
+ * attempted already.
318
+ */
319
+ )
320
+ }, {
321
+ key: "getRegRetryInterval",
322
+ value: function getRegRetryInterval() {
323
+ var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
324
+ return _constants.BASE_REG_RETRY_TIMER_VAL_IN_SEC + Math.pow(_constants.BASE_REG_TIMER_MFACTOR, attempt) + Math.floor((Math.random() * (_constants.REG_RANDOM_T_FACTOR_UPPER_LIMIT - _constants.SEC_TO_MSEC_MFACTOR + 1) + _constants.SEC_TO_MSEC_MFACTOR) / _constants.SEC_TO_MSEC_MFACTOR);
325
+ }
326
+
327
+ /**
328
+ * Schedules registration retry with primary mobius servers at a random
329
+ * interval calculated based on the number of times registration retry is already done
330
+ * Once the time taken since the beginning of retry attempt exceeds the
331
+ * retry threshold, it switches over to backup mobius servers.
332
+ *
333
+ */
334
+ }, {
335
+ key: "startFailoverTimer",
336
+ value: (function () {
337
+ var _startFailoverTimer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
338
+ var _this = this;
339
+ var attempt,
340
+ timeElapsed,
341
+ loggerContext,
342
+ interval,
343
+ excessVal,
344
+ abort,
345
+ scheduledTime,
346
+ _args10 = arguments;
347
+ return _regenerator.default.wrap(function _callee10$(_context10) {
348
+ while (1) switch (_context10.prev = _context10.next) {
349
+ case 0:
350
+ attempt = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : 1;
351
+ timeElapsed = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 0;
352
+ loggerContext = {
353
+ file: _constants.REGISTRATION_FILE,
354
+ method: this.startFailoverTimer.name
355
+ };
356
+ interval = this.getRegRetryInterval(attempt);
357
+ if (timeElapsed + interval > _constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC) {
358
+ excessVal = timeElapsed + interval - _constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC;
359
+ interval -= excessVal;
360
+ }
361
+ if (!(interval > _constants.BASE_REG_RETRY_TIMER_VAL_IN_SEC)) {
362
+ _context10.next = 11;
363
+ break;
364
+ }
365
+ scheduledTime = Math.floor((0, _now.default)() / 1000);
366
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
367
+ return _regenerator.default.wrap(function _callee7$(_context7) {
368
+ while (1) switch (_context7.prev = _context7.next) {
369
+ case 0:
370
+ _context7.next = 2;
371
+ return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
372
+ var currentTime;
373
+ return _regenerator.default.wrap(function _callee6$(_context6) {
374
+ while (1) switch (_context6.prev = _context6.next) {
375
+ case 0:
376
+ _context6.next = 2;
377
+ return _this.attemptRegistrationWithServers(_this.startFailoverTimer.name);
378
+ case 2:
379
+ abort = _context6.sent;
380
+ currentTime = Math.floor((0, _now.default)() / 1000);
381
+ if (!(!abort && !_this.isDeviceRegistered())) {
382
+ _context6.next = 7;
383
+ break;
384
+ }
385
+ _context6.next = 7;
386
+ return _this.startFailoverTimer(attempt + 1, timeElapsed + (currentTime - scheduledTime));
387
+ case 7:
388
+ case "end":
389
+ return _context6.stop();
390
+ }
391
+ }, _callee6);
392
+ })));
393
+ case 2:
394
+ case "end":
395
+ return _context7.stop();
396
+ }
397
+ }, _callee7);
398
+ })), interval * _constants.SEC_TO_MSEC_MFACTOR);
399
+ _Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
400
+ _context10.next = 20;
401
+ break;
402
+ case 11:
403
+ if (!this.backupMobiusUris.length) {
404
+ _context10.next = 19;
405
+ break;
406
+ }
407
+ _Logger.default.log('Failing over to backup servers.', loggerContext);
408
+ _context10.next = 15;
409
+ return this.attemptRegistrationWithServers(this.startFailoverTimer.name, this.backupMobiusUris);
410
+ case 15:
411
+ abort = _context10.sent;
412
+ if (!abort && !this.isDeviceRegistered()) {
413
+ interval = this.getRegRetryInterval();
414
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
415
+ return _regenerator.default.wrap(function _callee9$(_context9) {
416
+ while (1) switch (_context9.prev = _context9.next) {
417
+ case 0:
418
+ _context9.next = 2;
419
+ return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
420
+ return _regenerator.default.wrap(function _callee8$(_context8) {
421
+ while (1) switch (_context8.prev = _context8.next) {
422
+ case 0:
423
+ _context8.next = 2;
424
+ return _this.attemptRegistrationWithServers(_this.startFailoverTimer.name, _this.backupMobiusUris);
425
+ case 2:
426
+ abort = _context8.sent;
427
+ if (!abort && !_this.isDeviceRegistered()) {
428
+ (0, _common.emitFinalFailure)(function (clientError) {
429
+ _this.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
430
+ }, loggerContext);
431
+ }
432
+ case 4:
433
+ case "end":
434
+ return _context8.stop();
435
+ }
436
+ }, _callee8);
437
+ })));
438
+ case 2:
439
+ case "end":
440
+ return _context9.stop();
441
+ }
442
+ }, _callee9);
443
+ })), interval * _constants.SEC_TO_MSEC_MFACTOR);
444
+ _Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
445
+ }
446
+ _context10.next = 20;
447
+ break;
448
+ case 19:
449
+ (0, _common.emitFinalFailure)(function (clientError) {
450
+ _this.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
451
+ }, loggerContext);
452
+ case 20:
453
+ case "end":
454
+ return _context10.stop();
455
+ }
456
+ }, _callee10, this);
457
+ }));
458
+ function startFailoverTimer() {
459
+ return _startFailoverTimer.apply(this, arguments);
460
+ }
461
+ return startFailoverTimer;
462
+ }()
463
+ /**
464
+ * Clears the failback timer if running.
465
+ */
466
+ )
467
+ }, {
468
+ key: "clearFailbackTimer",
469
+ value: function clearFailbackTimer() {
470
+ if (this.failbackTimer) {
471
+ clearTimeout(this.failbackTimer);
472
+ this.failbackTimer = undefined;
473
+ }
474
+ }
475
+
476
+ /**
477
+ * Returns true if device is registered with a backup mobius.
478
+ */
479
+ }, {
480
+ key: "isFailbackRequired",
481
+ value: function isFailbackRequired() {
482
+ return this.isDeviceRegistered() && this.primaryMobiusUris.indexOf(this.activeMobiusUrl) === -1;
483
+ }
484
+
485
+ /**
486
+ * Calculates and returns a random value between rehomingIntervalMin and
487
+ * rehomingIntervalMax.
488
+ */
489
+ }, {
490
+ key: "getFailbackInterval",
491
+ value: function getFailbackInterval() {
492
+ return Math.floor(Math.random() * (this.rehomingIntervalMax - this.rehomingIntervalMin + 1) + this.rehomingIntervalMin);
493
+ }
494
+
495
+ /**
496
+ * Starts failback timer to move to primary mobius if device
497
+ * is registered with a backup mobius.
498
+ */
499
+ }, {
500
+ key: "initiateFailback",
501
+ value: function initiateFailback() {
502
+ if (this.isFailbackRequired()) {
503
+ if (!this.failbackTimer) {
504
+ this.failback429RetryAttempts = 0;
505
+ var intervalInMinutes = this.getFailbackInterval();
506
+ this.startFailbackTimer(intervalInMinutes * _constants.MINUTES_TO_SEC_MFACTOR);
507
+ }
508
+ } else {
509
+ this.failback429RetryAttempts = 0;
510
+ this.clearFailbackTimer();
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Starts failback timer with the interval value received.
516
+ *
517
+ */
518
+ }, {
519
+ key: "startFailbackTimer",
520
+ value: function startFailbackTimer(intervalInSeconds) {
521
+ var _this2 = this;
522
+ this.failbackTimer = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
523
+ return _regenerator.default.wrap(function _callee11$(_context11) {
524
+ while (1) switch (_context11.prev = _context11.next) {
525
+ case 0:
526
+ return _context11.abrupt("return", _this2.executeFailback());
527
+ case 1:
528
+ case "end":
529
+ return _context11.stop();
530
+ }
531
+ }, _callee11);
532
+ })), intervalInSeconds * _constants.SEC_TO_MSEC_MFACTOR);
533
+ _Logger.default.log("Failback scheduled after ".concat(intervalInSeconds, " seconds."), {
534
+ file: _constants.REGISTRATION_FILE,
535
+ method: this.startFailbackTimer.name
536
+ });
537
+ }
538
+
539
+ /**
540
+ * Core logic for the failback processing, scheduled and executed
541
+ * at failback timer expiry.
542
+ */
543
+ }, {
544
+ key: "executeFailback",
545
+ value: (function () {
546
+ var _executeFailback = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
547
+ var _this3 = this;
548
+ return _regenerator.default.wrap(function _callee13$(_context13) {
549
+ while (1) switch (_context13.prev = _context13.next) {
550
+ case 0:
551
+ _context13.next = 2;
552
+ return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
553
+ var abort, abortNew;
554
+ return _regenerator.default.wrap(function _callee12$(_context12) {
555
+ while (1) switch (_context12.prev = _context12.next) {
556
+ case 0:
557
+ if (!_this3.isFailbackRequired()) {
558
+ _context12.next = 27;
559
+ break;
560
+ }
561
+ if (!((0, _keys.default)(_this3.callManager.getActiveCalls()).length === 0)) {
562
+ _context12.next = 24;
563
+ break;
564
+ }
565
+ _Logger.default.info("Attempting failback to primary.", {
566
+ file: _constants.REGISTRATION_FILE,
567
+ method: _this3.executeFailback.name
568
+ });
569
+ _context12.next = 5;
570
+ return _this3.deregister();
571
+ case 5:
572
+ _context12.next = 7;
573
+ return _this3.attemptRegistrationWithServers(_constants.FAILBACK_UTIL);
574
+ case 7:
575
+ abort = _context12.sent;
576
+ if (!(!abort && !_this3.isDeviceRegistered())) {
577
+ _context12.next = 22;
578
+ break;
579
+ }
580
+ _context12.next = 11;
581
+ return _this3.restorePreviousRegistration(_constants.FAILBACK_UTIL);
582
+ case 11:
583
+ abortNew = _context12.sent;
584
+ if (!abortNew) {
585
+ _context12.next = 15;
586
+ break;
587
+ }
588
+ _this3.clearFailbackTimer();
589
+ return _context12.abrupt("return");
590
+ case 15:
591
+ if (_this3.isDeviceRegistered()) {
592
+ _context12.next = 20;
593
+ break;
594
+ }
595
+ _context12.next = 18;
596
+ return _this3.restartRegistration(_this3.executeFailback.name);
597
+ case 18:
598
+ _context12.next = 22;
599
+ break;
600
+ case 20:
601
+ _this3.failbackTimer = undefined;
602
+ _this3.initiateFailback();
603
+ case 22:
604
+ _context12.next = 27;
605
+ break;
606
+ case 24:
607
+ _Logger.default.info('Active calls present, deferring failback to next cycle.', {
608
+ file: _constants.REGISTRATION_FILE,
609
+ method: _this3.executeFailback.name
610
+ });
611
+ _this3.failbackTimer = undefined;
612
+ _this3.initiateFailback();
613
+ case 27:
614
+ case "end":
615
+ return _context12.stop();
616
+ }
617
+ }, _callee12);
618
+ })));
619
+ case 2:
620
+ case "end":
621
+ return _context13.stop();
622
+ }
623
+ }, _callee13, this);
624
+ }));
625
+ function executeFailback() {
626
+ return _executeFailback.apply(this, arguments);
627
+ }
628
+ return executeFailback;
629
+ }()
630
+ /**
631
+ * Updates rehomingIntervalMin and rehomingIntervalMax values
632
+ * if received in registration response from a primary mobius
633
+ * server.
634
+ *
635
+ */
636
+ )
637
+ }, {
638
+ key: "setIntervalValues",
639
+ value: function setIntervalValues(deviceInfo) {
640
+ if (this.primaryMobiusUris.indexOf(this.activeMobiusUrl) !== -1) {
641
+ this.rehomingIntervalMin = deviceInfo !== null && deviceInfo !== void 0 && deviceInfo.rehomingIntervalMin ? deviceInfo.rehomingIntervalMin : _constants.DEFAULT_REHOMING_INTERVAL_MIN;
642
+ this.rehomingIntervalMax = deviceInfo !== null && deviceInfo !== void 0 && deviceInfo.rehomingIntervalMax ? deviceInfo.rehomingIntervalMax : _constants.DEFAULT_REHOMING_INTERVAL_MAX;
643
+ }
644
+ }
645
+
646
+ /**
647
+ * Retrieves information about the device as {@link IDeviceInfo}.
648
+ *
649
+ */
650
+ }, {
651
+ key: "getDeviceInfo",
652
+ value: function getDeviceInfo() {
653
+ return this.deviceInfo;
654
+ }
655
+
656
+ /**
657
+ * Checks if the device is currently registered.
658
+ *
659
+ * by checking if isRegistered state is set to
660
+ * ACTIVE, else false.
661
+ */
662
+ }, {
663
+ key: "isDeviceRegistered",
664
+ value: function isDeviceRegistered() {
665
+ return this.registrationStatus === _types3.RegistrationStatus.ACTIVE;
666
+ }
667
+ }, {
668
+ key: "getStatus",
669
+ value: function getStatus() {
670
+ return this.registrationStatus;
671
+ }
672
+ }, {
673
+ key: "setStatus",
674
+ value: function setStatus(value) {
675
+ this.registrationStatus = value;
676
+ }
677
+
678
+ /**
679
+ * Start fresh registration cycle with the mobius
680
+ * server list already present.
681
+ *
682
+ */
683
+ }, {
684
+ key: "restartRegistration",
685
+ value: (function () {
686
+ var _restartRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(caller) {
687
+ var abort;
688
+ return _regenerator.default.wrap(function _callee14$(_context14) {
689
+ while (1) switch (_context14.prev = _context14.next) {
690
+ case 0:
691
+ /*
692
+ * Cancel any failback timer running
693
+ * and start fresh registration attempt with retry as true.
694
+ */
695
+ this.clearFailbackTimer();
696
+ this.failback429RetryAttempts = 0;
697
+ _context14.next = 4;
698
+ return this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
699
+ case 4:
700
+ abort = _context14.sent;
701
+ if (!(!abort && !this.isDeviceRegistered())) {
702
+ _context14.next = 8;
703
+ break;
704
+ }
705
+ _context14.next = 8;
706
+ return this.startFailoverTimer();
707
+ case 8:
708
+ case "end":
709
+ return _context14.stop();
710
+ }
711
+ }, _callee14, this);
712
+ }));
713
+ function restartRegistration(_x7) {
714
+ return _restartRegistration.apply(this, arguments);
715
+ }
716
+ return restartRegistration;
717
+ }()
718
+ /**
719
+ * Restores the connection and attempts refreshing existing registration with server.
720
+ * Allows retry if not restored in the first attempt.
721
+ *
722
+ */
723
+ )
724
+ }, {
725
+ key: "handleConnectionRestoration",
726
+ value: (function () {
727
+ var _handleConnectionRestoration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(retry) {
728
+ var _this4 = this;
729
+ return _regenerator.default.wrap(function _callee16$(_context16) {
730
+ while (1) switch (_context16.prev = _context16.next) {
731
+ case 0:
732
+ _context16.next = 2;
733
+ return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
734
+ var abort;
735
+ return _regenerator.default.wrap(function _callee15$(_context15) {
736
+ while (1) switch (_context15.prev = _context15.next) {
737
+ case 0:
738
+ if (!retry) {
739
+ _context15.next = 14;
740
+ break;
741
+ }
742
+ _Logger.default.info('Mercury connection is up again, re-registering with Webex Calling if needed', {
743
+ file: _constants.REGISTRATION_FILE,
744
+ method: _this4.handleConnectionRestoration.name
745
+ });
746
+ _this4.clearKeepaliveTimer();
747
+ if (!_this4.isDeviceRegistered()) {
748
+ _context15.next = 6;
749
+ break;
750
+ }
751
+ _context15.next = 6;
752
+ return _this4.deregister();
753
+ case 6:
754
+ if (!_this4.activeMobiusUrl) {
755
+ _context15.next = 13;
756
+ break;
757
+ }
758
+ _context15.next = 9;
759
+ return _this4.restorePreviousRegistration(_this4.handleConnectionRestoration.name);
760
+ case 9:
761
+ abort = _context15.sent;
762
+ if (!(!abort && !_this4.isDeviceRegistered())) {
763
+ _context15.next = 13;
764
+ break;
765
+ }
766
+ _context15.next = 13;
767
+ return _this4.restartRegistration(_this4.handleConnectionRestoration.name);
768
+ case 13:
769
+ retry = false;
770
+ case 14:
771
+ case "end":
772
+ return _context15.stop();
773
+ }
774
+ }, _callee15);
775
+ })));
776
+ case 2:
777
+ return _context16.abrupt("return", retry);
778
+ case 3:
779
+ case "end":
780
+ return _context16.stop();
781
+ }
782
+ }, _callee16, this);
783
+ }));
784
+ function handleConnectionRestoration(_x8) {
785
+ return _handleConnectionRestoration.apply(this, arguments);
786
+ }
787
+ return handleConnectionRestoration;
788
+ }()
789
+ /**
790
+ * Callback function for restoring registration in case of failure during initial registration
791
+ * due to device registration already exists.
792
+ *
793
+ */
794
+ )
795
+ }, {
796
+ key: "restoreRegistrationCallBack",
797
+ value: function restoreRegistrationCallBack() {
798
+ var _this5 = this;
799
+ return /*#__PURE__*/function () {
800
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(restoreData, caller) {
801
+ var logContext, restore, finalError;
802
+ return _regenerator.default.wrap(function _callee17$(_context17) {
803
+ while (1) switch (_context17.prev = _context17.next) {
804
+ case 0:
805
+ logContext = {
806
+ file: _constants.REGISTRATION_FILE,
807
+ method: caller
808
+ };
809
+ if (_this5.isRegRetry()) {
810
+ _context17.next = 17;
811
+ break;
812
+ }
813
+ _Logger.default.info('Registration restoration in progress.', logContext);
814
+ restore = _this5.getExistingDevice(restoreData);
815
+ if (!restore) {
816
+ _context17.next = 14;
817
+ break;
818
+ }
819
+ _this5.setRegRetry(true);
820
+ _context17.next = 8;
821
+ return _this5.deregister();
822
+ case 8:
823
+ _context17.next = 10;
824
+ return _this5.restorePreviousRegistration(caller);
825
+ case 10:
826
+ finalError = _context17.sent;
827
+ _this5.setRegRetry(false);
828
+ if (_this5.isDeviceRegistered()) {
829
+ _Logger.default.info('Registration restored successfully.', logContext);
830
+ }
831
+ return _context17.abrupt("return", finalError);
832
+ case 14:
833
+ _this5.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
834
+ _context17.next = 18;
835
+ break;
836
+ case 17:
837
+ _this5.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
838
+ case 18:
839
+ return _context17.abrupt("return", false);
840
+ case 19:
841
+ case "end":
842
+ return _context17.stop();
843
+ }
844
+ }, _callee17);
845
+ }));
846
+ return function (_x9, _x10) {
847
+ return _ref8.apply(this, arguments);
848
+ };
849
+ }();
850
+ }
851
+
852
+ /**
853
+ * Triggers the registration with the given list of Mobius servers
854
+ * Registration is attempted with primary and backup until it succeeds or the list is exhausted
855
+ */
856
+ }, {
857
+ key: "triggerRegistration",
858
+ value: (function () {
859
+ var _triggerRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
860
+ var abort;
861
+ return _regenerator.default.wrap(function _callee18$(_context18) {
862
+ while (1) switch (_context18.prev = _context18.next) {
863
+ case 0:
864
+ if (!(this.primaryMobiusUris.length > 0)) {
865
+ _context18.next = 7;
866
+ break;
867
+ }
868
+ _context18.next = 3;
869
+ return this.attemptRegistrationWithServers(this.triggerRegistration.name, this.primaryMobiusUris);
870
+ case 3:
871
+ abort = _context18.sent;
872
+ if (!(!this.isDeviceRegistered() && !abort)) {
873
+ _context18.next = 7;
874
+ break;
875
+ }
876
+ _context18.next = 7;
877
+ return this.startFailoverTimer();
878
+ case 7:
879
+ case "end":
880
+ return _context18.stop();
881
+ }
882
+ }, _callee18, this);
883
+ }));
884
+ function triggerRegistration() {
885
+ return _triggerRegistration.apply(this, arguments);
886
+ }
887
+ return triggerRegistration;
888
+ }()
889
+ /**
890
+ * Attempts registration with the server list received in
891
+ * argument one by one until registration either succeeds with
892
+ * one or all of them are tried.
893
+ *
894
+ * attempt has hit a final error and a retry should not be scheduled
895
+ * else false.
896
+ */
897
+ )
898
+ }, {
899
+ key: "attemptRegistrationWithServers",
900
+ value: (function () {
901
+ var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(caller) {
902
+ var _this6 = this;
903
+ var servers,
904
+ abort,
905
+ _iterator,
906
+ _step,
907
+ url,
908
+ _this$deviceInfo$devi,
909
+ resp,
910
+ body,
911
+ error,
912
+ _args19 = arguments;
913
+ return _regenerator.default.wrap(function _callee19$(_context19) {
914
+ while (1) switch (_context19.prev = _context19.next) {
915
+ case 0:
916
+ servers = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : this.primaryMobiusUris;
917
+ abort = false;
918
+ if (!this.isDeviceRegistered()) {
919
+ _context19.next = 5;
920
+ break;
921
+ }
922
+ _Logger.default.log("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), {
923
+ file: _constants.REGISTRATION_FILE,
924
+ method: this.attemptRegistrationWithServers.name
925
+ });
926
+ return _context19.abrupt("return", abort);
927
+ case 5:
928
+ _iterator = _createForOfIteratorHelper(servers);
929
+ _context19.prev = 6;
930
+ _iterator.s();
931
+ case 8:
932
+ if ((_step = _iterator.n()).done) {
933
+ _context19.next = 53;
934
+ break;
935
+ }
936
+ url = _step.value;
937
+ _context19.prev = 10;
938
+ abort = false;
939
+ this.registrationStatus = _types3.RegistrationStatus.INACTIVE;
940
+ this.lineEmitter(_types4.LINE_EVENTS.CONNECTING);
941
+ _Logger.default.log("[".concat(caller, "] : Mobius url to contact: ").concat(url), {
942
+ file: _constants.REGISTRATION_FILE,
943
+ method: this.attemptRegistrationWithServers.name
944
+ });
945
+ // eslint-disable-next-line no-await-in-loop
946
+ _context19.next = 17;
947
+ return this.postRegistration(url);
948
+ case 17:
949
+ resp = _context19.sent;
950
+ this.deviceInfo = resp.body;
951
+ this.registrationStatus = _types3.RegistrationStatus.ACTIVE;
952
+ this.lineEmitter(_types4.LINE_EVENTS.REGISTERED, resp.body);
953
+ this.setActiveMobiusUrl(url);
954
+ this.setIntervalValues(this.deviceInfo);
955
+ this.metricManager.setDeviceInfo(this.deviceInfo);
956
+ this.metricManager.submitRegistrationMetric(_types2.METRIC_EVENT.REGISTRATION, _types2.REG_ACTION.REGISTER, _types2.METRIC_TYPE.BEHAVIORAL, undefined);
957
+ this.startKeepaliveTimer((_this$deviceInfo$devi = this.deviceInfo.device) === null || _this$deviceInfo$devi === void 0 ? void 0 : _this$deviceInfo$devi.uri, this.deviceInfo.keepaliveInterval);
958
+ this.initiateFailback();
959
+ return _context19.abrupt("break", 53);
960
+ case 30:
961
+ _context19.prev = 30;
962
+ _context19.t0 = _context19["catch"](10);
963
+ body = _context19.t0; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
964
+ _context19.next = 35;
965
+ return (0, _common.handleRegistrationErrors)(body, function (clientError, finalError) {
966
+ if (finalError) {
967
+ _this6.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
968
+ } else {
969
+ _this6.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
970
+ }
971
+ _this6.metricManager.submitRegistrationMetric(_types2.METRIC_EVENT.REGISTRATION_ERROR, _types2.REG_ACTION.REGISTER, _types2.METRIC_TYPE.BEHAVIORAL, clientError);
972
+ }, {
973
+ method: this.attemptRegistrationWithServers.name,
974
+ file: _constants.REGISTRATION_FILE
975
+ }, this.restoreRegistrationCallBack());
976
+ case 35:
977
+ abort = _context19.sent;
978
+ if (!(this.registrationStatus === _types3.RegistrationStatus.ACTIVE)) {
979
+ _context19.next = 39;
980
+ break;
981
+ }
982
+ _Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(this.activeMobiusUrl), {
983
+ file: _constants.REGISTRATION_FILE,
984
+ method: this.attemptRegistrationWithServers.name
985
+ });
986
+ return _context19.abrupt("break", 53);
987
+ case 39:
988
+ if (!abort) {
989
+ _context19.next = 44;
990
+ break;
991
+ }
992
+ this.setStatus(_types3.RegistrationStatus.INACTIVE);
993
+ return _context19.abrupt("break", 53);
994
+ case 44:
995
+ if (!(caller === this.executeFailback.name)) {
996
+ _context19.next = 51;
997
+ break;
998
+ }
999
+ error = body.statusCode;
1000
+ if (!(error === _types.ERROR_CODE.TOO_MANY_REQUESTS)) {
1001
+ _context19.next = 51;
1002
+ break;
1003
+ }
1004
+ _context19.next = 49;
1005
+ return this.scheduleFailback429Retry();
1006
+ case 49:
1007
+ abort = true;
1008
+ return _context19.abrupt("break", 53);
1009
+ case 51:
1010
+ _context19.next = 8;
1011
+ break;
1012
+ case 53:
1013
+ _context19.next = 58;
1014
+ break;
1015
+ case 55:
1016
+ _context19.prev = 55;
1017
+ _context19.t1 = _context19["catch"](6);
1018
+ _iterator.e(_context19.t1);
1019
+ case 58:
1020
+ _context19.prev = 58;
1021
+ _iterator.f();
1022
+ return _context19.finish(58);
1023
+ case 61:
1024
+ return _context19.abrupt("return", abort);
1025
+ case 62:
1026
+ case "end":
1027
+ return _context19.stop();
1028
+ }
1029
+ }, _callee19, this, [[6, 55, 58, 61], [10, 30]]);
1030
+ }));
1031
+ function attemptRegistrationWithServers(_x11) {
1032
+ return _attemptRegistrationWithServers.apply(this, arguments);
1033
+ }
1034
+ return attemptRegistrationWithServers;
1035
+ }()
1036
+ /**
1037
+ * This method sets up a timer to periodically send keep-alive requests to maintain a connection.
1038
+ * It handles retries, error handling, and re-registration attempts based on the response, ensuring continuous connectivity with the server.
1039
+ */
1040
+ )
1041
+ }, {
1042
+ key: "startKeepaliveTimer",
1043
+ value: function startKeepaliveTimer(url, interval) {
1044
+ var _this7 = this;
1045
+ var keepAliveRetryCount = 0;
1046
+ this.clearKeepaliveTimer();
1047
+ this.keepaliveTimer = setInterval( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
1048
+ var logContext;
1049
+ return _regenerator.default.wrap(function _callee21$(_context21) {
1050
+ while (1) switch (_context21.prev = _context21.next) {
1051
+ case 0:
1052
+ logContext = {
1053
+ file: _constants.REGISTRATION_FILE,
1054
+ method: _this7.startKeepaliveTimer.name
1055
+ };
1056
+ _context21.next = 3;
1057
+ return _this7.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
1058
+ var res, error, abort;
1059
+ return _regenerator.default.wrap(function _callee20$(_context20) {
1060
+ while (1) switch (_context20.prev = _context20.next) {
1061
+ case 0:
1062
+ if (!(_this7.isDeviceRegistered() && keepAliveRetryCount < 5)) {
1063
+ _context20.next = 29;
1064
+ break;
1065
+ }
1066
+ _context20.prev = 1;
1067
+ _context20.next = 4;
1068
+ return _this7.postKeepAlive(url);
1069
+ case 4:
1070
+ res = _context20.sent;
1071
+ _Logger.default.info("Sent Keepalive, status: ".concat(res.statusCode), logContext);
1072
+ if (keepAliveRetryCount > 0) {
1073
+ _this7.lineEmitter(_types4.LINE_EVENTS.RECONNECTED);
1074
+ }
1075
+ keepAliveRetryCount = 0;
1076
+ _context20.next = 29;
1077
+ break;
1078
+ case 10:
1079
+ _context20.prev = 10;
1080
+ _context20.t0 = _context20["catch"](1);
1081
+ keepAliveRetryCount += 1;
1082
+ error = _context20.t0;
1083
+ _Logger.default.warn("Keep-alive missed ".concat(keepAliveRetryCount, " times. Status -> ").concat(error.statusCode, " "), logContext);
1084
+ _context20.next = 17;
1085
+ return (0, _common.handleRegistrationErrors)(error, function (clientError, finalError) {
1086
+ if (finalError) {
1087
+ _this7.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
1088
+ }
1089
+ _this7.metricManager.submitRegistrationMetric(_types2.METRIC_EVENT.REGISTRATION, _types2.REG_ACTION.KEEPALIVE_FAILURE, _types2.METRIC_TYPE.BEHAVIORAL, clientError);
1090
+ }, {
1091
+ method: _this7.startKeepaliveTimer.name,
1092
+ file: _constants.REGISTRATION_FILE
1093
+ });
1094
+ case 17:
1095
+ abort = _context20.sent;
1096
+ if (!(abort || keepAliveRetryCount >= 5)) {
1097
+ _context20.next = 28;
1098
+ break;
1099
+ }
1100
+ _this7.setStatus(_types3.RegistrationStatus.INACTIVE);
1101
+ _this7.clearKeepaliveTimer();
1102
+ _this7.clearFailbackTimer();
1103
+ _this7.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
1104
+ if (abort) {
1105
+ _context20.next = 26;
1106
+ break;
1107
+ }
1108
+ _context20.next = 26;
1109
+ return _this7.reconnectOnFailure(_this7.startKeepaliveTimer.name);
1110
+ case 26:
1111
+ _context20.next = 29;
1112
+ break;
1113
+ case 28:
1114
+ _this7.lineEmitter(_types4.LINE_EVENTS.RECONNECTING);
1115
+ case 29:
1116
+ case "end":
1117
+ return _context20.stop();
1118
+ }
1119
+ }, _callee20, null, [[1, 10]]);
1120
+ })));
1121
+ case 3:
1122
+ case "end":
1123
+ return _context21.stop();
1124
+ }
1125
+ }, _callee21);
1126
+ })), interval * 1000);
1127
+ }
1128
+
1129
+ /**
1130
+ * Clears the keepalive timer if running.
1131
+ */
1132
+ }, {
1133
+ key: "clearKeepaliveTimer",
1134
+ value: function clearKeepaliveTimer() {
1135
+ if (this.keepaliveTimer) {
1136
+ clearInterval(this.keepaliveTimer);
1137
+ this.keepaliveTimer = undefined;
1138
+ }
1139
+ }
1140
+ }, {
1141
+ key: "isReconnectPending",
1142
+ value: function isReconnectPending() {
1143
+ return this.reconnectPending;
1144
+ }
1145
+ }, {
1146
+ key: "deregister",
1147
+ value: function () {
1148
+ var _deregister = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
1149
+ var _this$deviceInfo$devi2, _this$deviceInfo$devi3;
1150
+ return _regenerator.default.wrap(function _callee22$(_context22) {
1151
+ while (1) switch (_context22.prev = _context22.next) {
1152
+ case 0:
1153
+ _context22.prev = 0;
1154
+ _context22.next = 3;
1155
+ return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.deviceId, (_this$deviceInfo$devi3 = this.deviceInfo.device) === null || _this$deviceInfo$devi3 === void 0 ? void 0 : _this$deviceInfo$devi3.clientDeviceUri);
1156
+ case 3:
1157
+ _context22.next = 8;
1158
+ break;
1159
+ case 5:
1160
+ _context22.prev = 5;
1161
+ _context22.t0 = _context22["catch"](0);
1162
+ _Logger.default.warn("Delete failed with Mobius", {});
1163
+ case 8:
1164
+ this.clearKeepaliveTimer();
1165
+ this.setStatus(_types3.RegistrationStatus.INACTIVE);
1166
+ case 10:
1167
+ case "end":
1168
+ return _context22.stop();
1169
+ }
1170
+ }, _callee22, this, [[0, 5]]);
1171
+ }));
1172
+ function deregister() {
1173
+ return _deregister.apply(this, arguments);
1174
+ }
1175
+ return deregister;
1176
+ }()
1177
+ /**
1178
+ * Indicates whether the calling client is in a mode
1179
+ * to retry registration.
1180
+ */
1181
+ }, {
1182
+ key: "isRegRetry",
1183
+ value: function isRegRetry() {
1184
+ return this.registerRetry;
1185
+ }
1186
+
1187
+ /**
1188
+ * Sets the received value in instance variable
1189
+ * registerRetry for registration retry cases.
1190
+ *
1191
+ */
1192
+ }, {
1193
+ key: "setRegRetry",
1194
+ value: function setRegRetry(value) {
1195
+ this.registerRetry = value;
1196
+ }
1197
+
1198
+ /**
1199
+ * Restores the deviceInfo object in callingClient when receiving a 403 with error code 101.
1200
+ *
1201
+ */
1202
+ }, {
1203
+ key: "getExistingDevice",
1204
+ value: function getExistingDevice(restoreData) {
1205
+ if (restoreData.devices && restoreData.devices.length > 0) {
1206
+ this.deviceInfo = {
1207
+ userId: restoreData.userId,
1208
+ device: restoreData.devices[0],
1209
+ keepaliveInterval: _constants.DEFAULT_KEEPALIVE_INTERVAL,
1210
+ rehomingIntervalMax: _constants.DEFAULT_REHOMING_INTERVAL_MAX,
1211
+ rehomingIntervalMin: _constants.DEFAULT_REHOMING_INTERVAL_MIN
1212
+ };
1213
+ var stringToReplace = "".concat(_constants.DEVICES_ENDPOINT_RESOURCE, "/").concat(restoreData.devices[0].deviceId);
1214
+ var uri = restoreData.devices[0].uri.replace(stringToReplace, '');
1215
+ this.setActiveMobiusUrl(uri);
1216
+ this.registrationStatus = _types3.RegistrationStatus.ACTIVE;
1217
+ return true;
1218
+ }
1219
+ return false;
1220
+ }
1221
+
1222
+ /**
1223
+ * Invoked to re-register in cases when the registration
1224
+ * is lost due to some failure.
1225
+ * If there are active calls, it will only mark reconnectPending
1226
+ * as true and then retry will happen when this method gets
1227
+ * invoked again on receiving all calls cleared event from
1228
+ * callManager.
1229
+ *
1230
+ */
1231
+ }, {
1232
+ key: "reconnectOnFailure",
1233
+ value: (function () {
1234
+ var _reconnectOnFailure = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(caller) {
1235
+ var abort;
1236
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1237
+ while (1) switch (_context23.prev = _context23.next) {
1238
+ case 0:
1239
+ this.reconnectPending = false;
1240
+ if (this.isDeviceRegistered()) {
1241
+ _context23.next = 13;
1242
+ break;
1243
+ }
1244
+ if (!((0, _keys.default)(this.callManager.getActiveCalls()).length === 0)) {
1245
+ _context23.next = 11;
1246
+ break;
1247
+ }
1248
+ _context23.next = 5;
1249
+ return this.restorePreviousRegistration(caller);
1250
+ case 5:
1251
+ abort = _context23.sent;
1252
+ if (!(!abort && !this.isDeviceRegistered())) {
1253
+ _context23.next = 9;
1254
+ break;
1255
+ }
1256
+ _context23.next = 9;
1257
+ return this.restartRegistration(caller);
1258
+ case 9:
1259
+ _context23.next = 13;
1260
+ break;
1261
+ case 11:
1262
+ this.reconnectPending = true;
1263
+ _Logger.default.info('Active call(s) present, deferred reconnect till call cleanup.', {
1264
+ file: _constants.REGISTRATION_FILE,
1265
+ method: this.reconnectOnFailure.name
1266
+ });
1267
+ case 13:
1268
+ case "end":
1269
+ return _context23.stop();
1270
+ }
1271
+ }, _callee23, this);
1272
+ }));
1273
+ function reconnectOnFailure(_x12) {
1274
+ return _reconnectOnFailure.apply(this, arguments);
1275
+ }
1276
+ return reconnectOnFailure;
1277
+ }())
1278
+ }]);
1279
+ return Registration;
1280
+ }();
1281
+ /*
1282
+ */
1283
+ var createRegistration = exports.createRegistration = function createRegistration(webex, serviceData, mutex, lineEmitter, logLevel) {
1284
+ return new Registration(webex, serviceData, mutex, lineEmitter, logLevel);
1285
+ };
1286
+ //# sourceMappingURL=register.js.map