@wazo/sdk 0.38.22 → 0.39.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (883) hide show
  1. package/README.md +62 -293
  2. package/dist/wazo-sdk.js +9 -25
  3. package/esm/__tests__/api-client.test.js +183 -5059
  4. package/esm/__tests__/web-rtc-client.test.js +177 -7930
  5. package/esm/api/agentd.js +23 -832
  6. package/esm/api/amid.js +9 -411
  7. package/esm/api/application.js +60 -829
  8. package/esm/api/auth.js +164 -1213
  9. package/esm/api/call-logd.js +24 -733
  10. package/esm/api/calld.js +114 -1469
  11. package/esm/api/chatd.js +48 -1311
  12. package/esm/api/confd.js +67 -1580
  13. package/esm/api/ctid-ng.js +92 -1343
  14. package/esm/api/dird.js +100 -1590
  15. package/esm/api/webhookd.js +7 -513
  16. package/esm/api-client.js +143 -4880
  17. package/esm/checker/Checker.js +45 -8727
  18. package/esm/checker/checks/aor.js +24 -4924
  19. package/esm/checker/checks/api.js +70 -4968
  20. package/esm/checker/checks/ice-ipv4.js +63 -117
  21. package/esm/checker/checks/index.js +8 -8677
  22. package/esm/checker/checks/symmetric-nat.js +54 -102
  23. package/esm/checker/checks/wazo-websocket.js +34 -999
  24. package/esm/checker/checks/webrtc-transport.js +28 -7845
  25. package/esm/checker/checks/webrtc.js +31 -7852
  26. package/esm/domain/AdHocAPIConference.js +86 -5115
  27. package/esm/domain/Agent.js +27 -61
  28. package/esm/domain/BadResponse.js +20 -43
  29. package/esm/domain/Call.js +120 -210
  30. package/esm/domain/CallLog.js +123 -305
  31. package/esm/domain/CallSession.js +251 -423
  32. package/esm/domain/ChatMessage.js +52 -105
  33. package/esm/domain/ChatRoom.js +28 -60
  34. package/esm/domain/Contact.js +435 -741
  35. package/esm/domain/Country.js +17 -19
  36. package/esm/domain/Device/DebugDevice.js +31 -47
  37. package/esm/domain/Device/Device.js +1 -1
  38. package/esm/domain/DirectorySource.js +1 -1
  39. package/esm/domain/ExternalApp.js +23 -56
  40. package/esm/domain/Features.js +57 -5009
  41. package/esm/domain/ForwardOption.js +35 -70
  42. package/esm/domain/IndirectTransfer.js +38 -97
  43. package/esm/domain/Line.js +37 -88
  44. package/esm/domain/Meeting.js +58 -113
  45. package/esm/domain/MeetingAuthorization.js +38 -68
  46. package/esm/domain/MeetingStatus.js +13 -28
  47. package/esm/domain/NotificationOptions.js +43 -77
  48. package/esm/domain/Phone/CTIPhone.js +245 -5743
  49. package/esm/domain/Phone/Phone.js +1 -2
  50. package/esm/domain/Phone/WebRTCPhone.js +1457 -2671
  51. package/esm/domain/Profile.js +120 -405
  52. package/esm/domain/Recording.js +27 -51
  53. package/esm/domain/Relocation.js +16 -40
  54. package/esm/domain/Room.js +90 -133
  55. package/esm/domain/SFUNotAvailableError.js +5 -8
  56. package/esm/domain/ServerError.js +8 -61
  57. package/esm/domain/Session.js +125 -251
  58. package/esm/domain/SipLine.js +78 -155
  59. package/esm/domain/Subscription.js +39 -83
  60. package/esm/domain/SwitchboardCall.js +51 -143
  61. package/esm/domain/Voicemail.js +57 -122
  62. package/esm/domain/__tests__/Agent.test.js +31 -101
  63. package/esm/domain/__tests__/Call.test.js +24 -232
  64. package/esm/domain/__tests__/CallLog.test.js +60 -386
  65. package/esm/domain/__tests__/CallSession.test.js +74 -502
  66. package/esm/domain/__tests__/Contact.test.js +220 -902
  67. package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
  68. package/esm/domain/__tests__/Line.test.js +48 -156
  69. package/esm/domain/__tests__/Meeting.test.js +73 -226
  70. package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
  71. package/esm/domain/__tests__/Profile.test.js +135 -496
  72. package/esm/domain/__tests__/Room.test.js +227 -719
  73. package/esm/domain/__tests__/Session.test.js +357 -1025
  74. package/esm/domain/__tests__/SipLine.test.js +24 -179
  75. package/esm/domain/__tests__/Voicemail.test.js +82 -200
  76. package/esm/domain/types.js +1 -1
  77. package/esm/index.js +63 -14985
  78. package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
  79. package/esm/pubkey.js +10 -0
  80. package/esm/service/CallApi.js +42 -5014
  81. package/esm/service/IssueReporter.js +278 -360
  82. package/esm/service/__tests__/IssueReporter.test.js +92 -494
  83. package/esm/service/getApiClient.js +53 -4972
  84. package/esm/simple/Auth.js +212 -14747
  85. package/esm/simple/Configuration.js +8 -14796
  86. package/esm/simple/Directory.js +6 -4964
  87. package/esm/simple/Phone.js +309 -14727
  88. package/esm/simple/Websocket.js +68 -1112
  89. package/esm/simple/index.js +125 -14792
  90. package/esm/simple/room/LocalParticipant.js +1 -14797
  91. package/esm/simple/room/Participant.js +274 -14760
  92. package/esm/simple/room/RemoteParticipant.js +6 -14796
  93. package/esm/simple/room/Room.js +648 -14736
  94. package/esm/simple/room/SipRoom.js +111 -14790
  95. package/esm/simple/room/Stream.js +40 -14792
  96. package/esm/simple/room/__tests__/Participant.test.js +68 -14872
  97. package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14805
  98. package/esm/simple/utils.js +9 -14799
  99. package/esm/types/WebSocketMessage.js +1 -1
  100. package/esm/types/__tests__/api-client.test.d.ts +2 -0
  101. package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
  102. package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
  103. package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  104. package/esm/types/api/agentd.d.ts +17 -0
  105. package/esm/types/api/agentd.d.ts.map +1 -0
  106. package/esm/types/api/amid.d.ts +8 -0
  107. package/esm/types/api/amid.d.ts.map +1 -0
  108. package/esm/types/api/application.d.ts +34 -0
  109. package/esm/types/api/application.d.ts.map +1 -0
  110. package/esm/types/api/auth.d.ts +64 -0
  111. package/esm/types/api/auth.d.ts.map +1 -0
  112. package/esm/types/api/call-logd.d.ts +12 -0
  113. package/esm/types/api/call-logd.d.ts.map +1 -0
  114. package/esm/types/api/calld.d.ts +51 -0
  115. package/esm/types/api/calld.d.ts.map +1 -0
  116. package/esm/types/api/chatd.d.ts +42 -0
  117. package/esm/types/api/chatd.d.ts.map +1 -0
  118. package/esm/types/api/confd.d.ts +39 -0
  119. package/esm/types/api/confd.d.ts.map +1 -0
  120. package/esm/types/api/ctid-ng.d.ts +36 -0
  121. package/esm/types/api/ctid-ng.d.ts.map +1 -0
  122. package/esm/types/api/dird.d.ts +38 -0
  123. package/esm/types/api/dird.d.ts.map +1 -0
  124. package/esm/types/api/webhookd.d.ts +24 -0
  125. package/esm/types/api/webhookd.d.ts.map +1 -0
  126. package/esm/types/api-client.d.ts +63 -0
  127. package/esm/types/api-client.d.ts.map +1 -0
  128. package/esm/types/checker/Checker.d.ts +13 -0
  129. package/esm/types/checker/Checker.d.ts.map +1 -0
  130. package/esm/types/checker/checks/aor.d.ts +6 -0
  131. package/esm/types/checker/checks/aor.d.ts.map +1 -0
  132. package/esm/types/checker/checks/api.d.ts +6 -0
  133. package/esm/types/checker/checks/api.d.ts.map +1 -0
  134. package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
  135. package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  136. package/esm/types/checker/checks/index.d.ts +9 -0
  137. package/esm/types/checker/checks/index.d.ts.map +1 -0
  138. package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
  139. package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  140. package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
  141. package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  142. package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
  143. package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  144. package/esm/types/checker/checks/webrtc.d.ts +6 -0
  145. package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
  146. package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
  147. package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
  148. package/esm/types/domain/Agent.d.ts +31 -0
  149. package/esm/types/domain/Agent.d.ts.map +1 -0
  150. package/esm/types/domain/BadResponse.d.ts +11 -0
  151. package/esm/types/domain/BadResponse.d.ts.map +1 -0
  152. package/esm/types/domain/Call.d.ts +79 -0
  153. package/esm/types/domain/Call.d.ts.map +1 -0
  154. package/esm/types/domain/CallLog.d.ts +91 -0
  155. package/esm/types/domain/CallLog.d.ts.map +1 -0
  156. package/esm/types/domain/CallSession.d.ts +120 -0
  157. package/esm/types/domain/CallSession.d.ts.map +1 -0
  158. package/esm/types/domain/ChatMessage.d.ts +41 -0
  159. package/esm/types/domain/ChatMessage.d.ts.map +1 -0
  160. package/esm/types/domain/ChatRoom.d.ts +22 -0
  161. package/esm/types/domain/ChatRoom.d.ts.map +1 -0
  162. package/esm/types/domain/Contact.d.ts +316 -0
  163. package/esm/types/domain/Contact.d.ts.map +1 -0
  164. package/esm/types/domain/Country.d.ts +20 -0
  165. package/esm/types/domain/Country.d.ts.map +1 -0
  166. package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
  167. package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
  168. package/esm/types/domain/Device/Device.d.ts +13 -0
  169. package/esm/types/domain/Device/Device.d.ts.map +1 -0
  170. package/esm/types/domain/DirectorySource.d.ts +13 -0
  171. package/esm/types/domain/DirectorySource.d.ts.map +1 -0
  172. package/esm/types/domain/ExternalApp.d.ts +22 -0
  173. package/esm/types/domain/ExternalApp.d.ts.map +1 -0
  174. package/esm/types/domain/Features.d.ts +24 -0
  175. package/esm/types/domain/Features.d.ts.map +1 -0
  176. package/esm/types/domain/ForwardOption.d.ts +27 -0
  177. package/esm/types/domain/ForwardOption.d.ts.map +1 -0
  178. package/esm/types/domain/IndirectTransfer.d.ts +31 -0
  179. package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
  180. package/esm/types/domain/Line.d.ts +46 -0
  181. package/esm/types/domain/Line.d.ts.map +1 -0
  182. package/esm/types/domain/Meeting.d.ts +45 -0
  183. package/esm/types/domain/Meeting.d.ts.map +1 -0
  184. package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
  185. package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
  186. package/esm/types/domain/MeetingStatus.d.ts +10 -0
  187. package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
  188. package/esm/types/domain/NotificationOptions.d.ts +22 -0
  189. package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
  190. package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
  191. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  192. package/esm/types/domain/Phone/Phone.d.ts +71 -0
  193. package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
  194. package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  195. package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  196. package/esm/types/domain/Profile.d.ts +151 -0
  197. package/esm/types/domain/Profile.d.ts.map +1 -0
  198. package/esm/types/domain/Recording.d.ts +26 -0
  199. package/esm/types/domain/Recording.d.ts.map +1 -0
  200. package/esm/types/domain/Relocation.d.ts +23 -0
  201. package/esm/types/domain/Relocation.d.ts.map +1 -0
  202. package/esm/types/domain/Room.d.ts +35 -0
  203. package/esm/types/domain/Room.d.ts.map +1 -0
  204. package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
  205. package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  206. package/esm/types/domain/ServerError.d.ts +6 -0
  207. package/esm/types/domain/ServerError.d.ts.map +1 -0
  208. package/esm/types/domain/Session.d.ts +90 -0
  209. package/esm/types/domain/Session.d.ts.map +1 -0
  210. package/esm/types/domain/SipLine.d.ts +54 -0
  211. package/esm/types/domain/SipLine.d.ts.map +1 -0
  212. package/esm/types/domain/Subscription.d.ts +43 -0
  213. package/esm/types/domain/Subscription.d.ts.map +1 -0
  214. package/esm/types/domain/SwitchboardCall.d.ts +62 -0
  215. package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
  216. package/esm/types/domain/Voicemail.d.ts +50 -0
  217. package/esm/types/domain/Voicemail.d.ts.map +1 -0
  218. package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
  219. package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  220. package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
  221. package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
  222. package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
  223. package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  224. package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
  225. package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  226. package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
  227. package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  228. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  229. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  230. package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
  231. package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
  232. package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
  233. package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  234. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  235. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  236. package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
  237. package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  238. package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
  239. package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
  240. package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
  241. package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
  242. package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
  243. package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  244. package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  245. package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  246. package/esm/types/domain/types.d.ts +217 -0
  247. package/esm/types/domain/types.d.ts.map +1 -0
  248. package/esm/types/index.d.ts +304 -0
  249. package/esm/types/index.d.ts.map +1 -0
  250. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  251. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  252. package/esm/types/pubkey.d.ts +3 -0
  253. package/esm/types/pubkey.d.ts.map +1 -0
  254. package/esm/types/service/CallApi.d.ts +28 -0
  255. package/esm/types/service/CallApi.d.ts.map +1 -0
  256. package/esm/types/service/IssueReporter.d.ts +40 -0
  257. package/esm/types/service/IssueReporter.d.ts.map +1 -0
  258. package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  259. package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  260. package/esm/types/service/getApiClient.d.ts +16 -0
  261. package/esm/types/service/getApiClient.d.ts.map +1 -0
  262. package/esm/types/simple/Auth.d.ts +51 -0
  263. package/esm/types/simple/Auth.d.ts.map +1 -0
  264. package/esm/types/simple/Configuration.d.ts +3 -0
  265. package/esm/types/simple/Configuration.d.ts.map +1 -0
  266. package/esm/types/simple/Directory.d.ts +3 -0
  267. package/esm/types/simple/Directory.d.ts.map +1 -0
  268. package/esm/types/simple/Phone.d.ts +115 -0
  269. package/esm/types/simple/Phone.d.ts.map +1 -0
  270. package/esm/types/simple/Websocket.d.ts +19 -0
  271. package/esm/types/simple/Websocket.d.ts.map +1 -0
  272. package/esm/types/simple/index.d.ts +147 -0
  273. package/esm/types/simple/index.d.ts.map +1 -0
  274. package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
  275. package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
  276. package/esm/types/simple/room/Participant.d.ts +76 -0
  277. package/esm/types/simple/room/Participant.d.ts.map +1 -0
  278. package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
  279. package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  280. package/esm/types/simple/room/Room.d.ts +116 -0
  281. package/esm/types/simple/room/Room.d.ts.map +1 -0
  282. package/esm/types/simple/room/SipRoom.d.ts +14 -0
  283. package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
  284. package/esm/types/simple/room/Stream.d.ts +13 -0
  285. package/esm/types/simple/room/Stream.d.ts.map +1 -0
  286. package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  287. package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  288. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  289. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  290. package/esm/types/simple/utils.d.ts +3 -0
  291. package/esm/types/simple/utils.d.ts.map +1 -0
  292. package/esm/types/types/WebSocketMessage.d.ts +285 -0
  293. package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
  294. package/esm/types/utils/Emitter.d.ts +18 -0
  295. package/esm/types/utils/Emitter.d.ts.map +1 -0
  296. package/esm/types/utils/Heartbeat.d.ts +21 -0
  297. package/esm/types/utils/Heartbeat.d.ts.map +1 -0
  298. package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
  299. package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  300. package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  301. package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  302. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  303. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  304. package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
  305. package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  306. package/esm/types/utils/__tests__/array.test.d.ts +2 -0
  307. package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
  308. package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
  309. package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  310. package/esm/types/utils/__tests__/object.test.d.ts +2 -0
  311. package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
  312. package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
  313. package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  314. package/esm/types/utils/__tests__/string.test.d.ts +2 -0
  315. package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
  316. package/esm/types/utils/api-requester.d.ts +45 -0
  317. package/esm/types/utils/api-requester.d.ts.map +1 -0
  318. package/esm/types/utils/array.d.ts +2 -0
  319. package/esm/types/utils/array.d.ts.map +1 -0
  320. package/esm/types/utils/compare-version.d.ts +3 -0
  321. package/esm/types/utils/compare-version.d.ts.map +1 -0
  322. package/esm/types/utils/isMobile.d.ts +3 -0
  323. package/esm/types/utils/isMobile.d.ts.map +1 -0
  324. package/esm/types/utils/new-from.d.ts +3 -0
  325. package/esm/types/utils/new-from.d.ts.map +1 -0
  326. package/esm/types/utils/object.d.ts +2 -0
  327. package/esm/types/utils/object.d.ts.map +1 -0
  328. package/esm/types/utils/once.d.ts +2 -0
  329. package/esm/types/utils/once.d.ts.map +1 -0
  330. package/esm/types/utils/sdp.d.ts +13 -0
  331. package/esm/types/utils/sdp.d.ts.map +1 -0
  332. package/esm/types/utils/string.d.ts +2 -0
  333. package/esm/types/utils/string.d.ts.map +1 -0
  334. package/esm/types/utils/update-from.d.ts +3 -0
  335. package/esm/types/utils/update-from.d.ts.map +1 -0
  336. package/esm/types/utils/webrtc.d.ts +15 -0
  337. package/esm/types/utils/webrtc.d.ts.map +1 -0
  338. package/esm/types/web-rtc-client.d.ts +220 -0
  339. package/esm/types/web-rtc-client.d.ts.map +1 -0
  340. package/esm/types/websocket-client.d.ts +134 -0
  341. package/esm/types/websocket-client.d.ts.map +1 -0
  342. package/esm/utils/Emitter.js +17 -27
  343. package/esm/utils/Heartbeat.js +60 -83
  344. package/esm/utils/PhoneNumberUtil.js +48 -63
  345. package/esm/utils/__tests__/Heartbeat.test.js +59 -168
  346. package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
  347. package/esm/utils/__tests__/api-requester.test.js +127 -780
  348. package/esm/utils/__tests__/array.test.js +16 -19
  349. package/esm/utils/__tests__/compare-version.test.js +8 -26
  350. package/esm/utils/__tests__/object.test.js +73 -54
  351. package/esm/utils/__tests__/sdp.test.js +87 -216
  352. package/esm/utils/__tests__/string.test.js +21 -27
  353. package/esm/utils/api-requester.js +197 -675
  354. package/esm/utils/array.js +7 -11
  355. package/esm/utils/compare-version.js +12 -15
  356. package/esm/utils/isMobile.js +0 -2
  357. package/esm/utils/new-from.js +7 -12
  358. package/esm/utils/object.js +9 -23
  359. package/esm/utils/once.js +12 -13
  360. package/esm/utils/sdp.js +87 -131
  361. package/esm/utils/string.js +5 -9
  362. package/esm/utils/update-from.js +9 -16
  363. package/esm/utils/webrtc.js +35 -36
  364. package/esm/web-rtc-client.js +2038 -7677
  365. package/esm/websocket-client.js +352 -944
  366. package/lib/__tests__/api-client.test.js +199 -5067
  367. package/lib/__tests__/web-rtc-client.test.js +191 -7941
  368. package/lib/api/agentd.js +27 -837
  369. package/lib/api/amid.js +18 -415
  370. package/lib/api/application.js +64 -834
  371. package/lib/api/auth.js +166 -1222
  372. package/lib/api/call-logd.js +28 -738
  373. package/lib/api/calld.js +126 -1473
  374. package/lib/api/chatd.js +65 -1316
  375. package/lib/api/confd.js +79 -1584
  376. package/lib/api/ctid-ng.js +96 -1348
  377. package/lib/api/dird.js +105 -1596
  378. package/lib/api/webhookd.js +11 -518
  379. package/lib/api-client.js +139 -4884
  380. package/lib/checker/Checker.js +61 -8739
  381. package/lib/checker/checks/aor.js +37 -4929
  382. package/lib/checker/checks/api.js +81 -4971
  383. package/lib/checker/checks/ice-ipv4.js +66 -118
  384. package/lib/checker/checks/index.js +13 -8687
  385. package/lib/checker/checks/symmetric-nat.js +56 -104
  386. package/lib/checker/checks/wazo-websocket.js +58 -1006
  387. package/lib/checker/checks/webrtc-transport.js +41 -7853
  388. package/lib/checker/checks/webrtc.js +42 -7858
  389. package/lib/domain/AdHocAPIConference.js +80 -5116
  390. package/lib/domain/Agent.js +23 -64
  391. package/lib/domain/BadResponse.js +17 -44
  392. package/lib/domain/Call.js +108 -215
  393. package/lib/domain/CallLog.js +117 -311
  394. package/lib/domain/CallSession.js +221 -424
  395. package/lib/domain/ChatMessage.js +49 -110
  396. package/lib/domain/ChatRoom.js +28 -60
  397. package/lib/domain/Contact.js +409 -742
  398. package/lib/domain/Country.js +19 -21
  399. package/lib/domain/Device/DebugDevice.js +34 -49
  400. package/lib/domain/Device/Device.js +2 -2
  401. package/lib/domain/DirectorySource.js +2 -2
  402. package/lib/domain/ExternalApp.js +24 -56
  403. package/lib/domain/Features.js +68 -5018
  404. package/lib/domain/ForwardOption.js +36 -71
  405. package/lib/domain/IndirectTransfer.js +39 -98
  406. package/lib/domain/Line.js +35 -88
  407. package/lib/domain/Meeting.js +51 -118
  408. package/lib/domain/MeetingAuthorization.js +35 -75
  409. package/lib/domain/MeetingStatus.js +13 -29
  410. package/lib/domain/NotificationOptions.js +45 -77
  411. package/lib/domain/Phone/CTIPhone.js +283 -5755
  412. package/lib/domain/Phone/Phone.js +2 -5
  413. package/lib/domain/Phone/WebRTCPhone.js +1457 -2716
  414. package/lib/domain/Profile.js +127 -406
  415. package/lib/domain/Recording.js +28 -57
  416. package/lib/domain/Relocation.js +15 -43
  417. package/lib/domain/Room.js +73 -134
  418. package/lib/domain/SFUNotAvailableError.js +7 -9
  419. package/lib/domain/ServerError.js +14 -63
  420. package/lib/domain/Session.js +118 -251
  421. package/lib/domain/SipLine.js +70 -155
  422. package/lib/domain/Subscription.js +32 -86
  423. package/lib/domain/SwitchboardCall.js +45 -145
  424. package/lib/domain/Voicemail.js +56 -127
  425. package/lib/domain/__tests__/Agent.test.js +36 -103
  426. package/lib/domain/__tests__/Call.test.js +28 -237
  427. package/lib/domain/__tests__/CallLog.test.js +65 -392
  428. package/lib/domain/__tests__/CallSession.test.js +78 -503
  429. package/lib/domain/__tests__/Contact.test.js +224 -903
  430. package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
  431. package/lib/domain/__tests__/Line.test.js +52 -157
  432. package/lib/domain/__tests__/Meeting.test.js +78 -232
  433. package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
  434. package/lib/domain/__tests__/Profile.test.js +161 -496
  435. package/lib/domain/__tests__/Room.test.js +239 -719
  436. package/lib/domain/__tests__/Session.test.js +350 -1024
  437. package/lib/domain/__tests__/SipLine.test.js +28 -180
  438. package/lib/domain/__tests__/Voicemail.test.js +86 -205
  439. package/lib/domain/types.js +2 -2
  440. package/lib/index.js +105 -15010
  441. package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
  442. package/lib/pubkey.js +12 -0
  443. package/lib/service/CallApi.js +88 -5015
  444. package/lib/service/IssueReporter.js +264 -366
  445. package/lib/service/__tests__/IssueReporter.test.js +97 -500
  446. package/lib/service/getApiClient.js +70 -4990
  447. package/lib/simple/Auth.js +272 -14777
  448. package/lib/simple/Configuration.js +23 -14805
  449. package/lib/simple/Directory.js +18 -4966
  450. package/lib/simple/Phone.js +345 -14746
  451. package/lib/simple/Websocket.js +98 -1117
  452. package/lib/simple/index.js +151 -14800
  453. package/lib/simple/room/LocalParticipant.js +7 -14808
  454. package/lib/simple/room/Participant.js +269 -14778
  455. package/lib/simple/room/RemoteParticipant.js +11 -14806
  456. package/lib/simple/room/Room.js +655 -14761
  457. package/lib/simple/room/SipRoom.js +136 -14805
  458. package/lib/simple/room/Stream.js +43 -14802
  459. package/lib/simple/room/__tests__/Participant.test.js +79 -14879
  460. package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14814
  461. package/lib/simple/utils.js +22 -14808
  462. package/lib/types/WebSocketMessage.js +2 -4
  463. package/lib/types/__tests__/api-client.test.d.ts +2 -0
  464. package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
  465. package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
  466. package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  467. package/lib/types/api/agentd.d.ts +17 -0
  468. package/lib/types/api/agentd.d.ts.map +1 -0
  469. package/lib/types/api/amid.d.ts +8 -0
  470. package/lib/types/api/amid.d.ts.map +1 -0
  471. package/lib/types/api/application.d.ts +34 -0
  472. package/lib/types/api/application.d.ts.map +1 -0
  473. package/lib/types/api/auth.d.ts +64 -0
  474. package/lib/types/api/auth.d.ts.map +1 -0
  475. package/lib/types/api/call-logd.d.ts +12 -0
  476. package/lib/types/api/call-logd.d.ts.map +1 -0
  477. package/lib/types/api/calld.d.ts +51 -0
  478. package/lib/types/api/calld.d.ts.map +1 -0
  479. package/lib/types/api/chatd.d.ts +42 -0
  480. package/lib/types/api/chatd.d.ts.map +1 -0
  481. package/lib/types/api/confd.d.ts +39 -0
  482. package/lib/types/api/confd.d.ts.map +1 -0
  483. package/lib/types/api/ctid-ng.d.ts +36 -0
  484. package/lib/types/api/ctid-ng.d.ts.map +1 -0
  485. package/lib/types/api/dird.d.ts +38 -0
  486. package/lib/types/api/dird.d.ts.map +1 -0
  487. package/lib/types/api/webhookd.d.ts +24 -0
  488. package/lib/types/api/webhookd.d.ts.map +1 -0
  489. package/lib/types/api-client.d.ts +63 -0
  490. package/lib/types/api-client.d.ts.map +1 -0
  491. package/lib/types/checker/Checker.d.ts +13 -0
  492. package/lib/types/checker/Checker.d.ts.map +1 -0
  493. package/lib/types/checker/checks/aor.d.ts +6 -0
  494. package/lib/types/checker/checks/aor.d.ts.map +1 -0
  495. package/lib/types/checker/checks/api.d.ts +6 -0
  496. package/lib/types/checker/checks/api.d.ts.map +1 -0
  497. package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
  498. package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  499. package/lib/types/checker/checks/index.d.ts +9 -0
  500. package/lib/types/checker/checks/index.d.ts.map +1 -0
  501. package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
  502. package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  503. package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
  504. package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  505. package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
  506. package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  507. package/lib/types/checker/checks/webrtc.d.ts +6 -0
  508. package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
  509. package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
  510. package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
  511. package/lib/types/domain/Agent.d.ts +31 -0
  512. package/lib/types/domain/Agent.d.ts.map +1 -0
  513. package/lib/types/domain/BadResponse.d.ts +11 -0
  514. package/lib/types/domain/BadResponse.d.ts.map +1 -0
  515. package/lib/types/domain/Call.d.ts +79 -0
  516. package/lib/types/domain/Call.d.ts.map +1 -0
  517. package/lib/types/domain/CallLog.d.ts +91 -0
  518. package/lib/types/domain/CallLog.d.ts.map +1 -0
  519. package/lib/types/domain/CallSession.d.ts +120 -0
  520. package/lib/types/domain/CallSession.d.ts.map +1 -0
  521. package/lib/types/domain/ChatMessage.d.ts +41 -0
  522. package/lib/types/domain/ChatMessage.d.ts.map +1 -0
  523. package/lib/types/domain/ChatRoom.d.ts +22 -0
  524. package/lib/types/domain/ChatRoom.d.ts.map +1 -0
  525. package/lib/types/domain/Contact.d.ts +316 -0
  526. package/lib/types/domain/Contact.d.ts.map +1 -0
  527. package/lib/types/domain/Country.d.ts +20 -0
  528. package/lib/types/domain/Country.d.ts.map +1 -0
  529. package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
  530. package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
  531. package/lib/types/domain/Device/Device.d.ts +13 -0
  532. package/lib/types/domain/Device/Device.d.ts.map +1 -0
  533. package/lib/types/domain/DirectorySource.d.ts +13 -0
  534. package/lib/types/domain/DirectorySource.d.ts.map +1 -0
  535. package/lib/types/domain/ExternalApp.d.ts +22 -0
  536. package/lib/types/domain/ExternalApp.d.ts.map +1 -0
  537. package/lib/types/domain/Features.d.ts +24 -0
  538. package/lib/types/domain/Features.d.ts.map +1 -0
  539. package/lib/types/domain/ForwardOption.d.ts +27 -0
  540. package/lib/types/domain/ForwardOption.d.ts.map +1 -0
  541. package/lib/types/domain/IndirectTransfer.d.ts +31 -0
  542. package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
  543. package/lib/types/domain/Line.d.ts +46 -0
  544. package/lib/types/domain/Line.d.ts.map +1 -0
  545. package/lib/types/domain/Meeting.d.ts +45 -0
  546. package/lib/types/domain/Meeting.d.ts.map +1 -0
  547. package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
  548. package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
  549. package/lib/types/domain/MeetingStatus.d.ts +10 -0
  550. package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
  551. package/lib/types/domain/NotificationOptions.d.ts +22 -0
  552. package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
  553. package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
  554. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  555. package/lib/types/domain/Phone/Phone.d.ts +71 -0
  556. package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
  557. package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  558. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  559. package/lib/types/domain/Profile.d.ts +151 -0
  560. package/lib/types/domain/Profile.d.ts.map +1 -0
  561. package/lib/types/domain/Recording.d.ts +26 -0
  562. package/lib/types/domain/Recording.d.ts.map +1 -0
  563. package/lib/types/domain/Relocation.d.ts +23 -0
  564. package/lib/types/domain/Relocation.d.ts.map +1 -0
  565. package/lib/types/domain/Room.d.ts +35 -0
  566. package/lib/types/domain/Room.d.ts.map +1 -0
  567. package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
  568. package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  569. package/lib/types/domain/ServerError.d.ts +6 -0
  570. package/lib/types/domain/ServerError.d.ts.map +1 -0
  571. package/lib/types/domain/Session.d.ts +90 -0
  572. package/lib/types/domain/Session.d.ts.map +1 -0
  573. package/lib/types/domain/SipLine.d.ts +54 -0
  574. package/lib/types/domain/SipLine.d.ts.map +1 -0
  575. package/lib/types/domain/Subscription.d.ts +43 -0
  576. package/lib/types/domain/Subscription.d.ts.map +1 -0
  577. package/lib/types/domain/SwitchboardCall.d.ts +62 -0
  578. package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
  579. package/lib/types/domain/Voicemail.d.ts +50 -0
  580. package/lib/types/domain/Voicemail.d.ts.map +1 -0
  581. package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
  582. package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  583. package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
  584. package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
  585. package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
  586. package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  587. package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
  588. package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  589. package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
  590. package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  591. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  592. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  593. package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
  594. package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
  595. package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
  596. package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  597. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  598. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  599. package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
  600. package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  601. package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
  602. package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
  603. package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
  604. package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
  605. package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
  606. package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  607. package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  608. package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  609. package/lib/types/domain/types.d.ts +217 -0
  610. package/lib/types/domain/types.d.ts.map +1 -0
  611. package/lib/types/index.d.ts +304 -0
  612. package/lib/types/index.d.ts.map +1 -0
  613. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  614. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  615. package/lib/types/pubkey.d.ts +3 -0
  616. package/lib/types/pubkey.d.ts.map +1 -0
  617. package/lib/types/service/CallApi.d.ts +28 -0
  618. package/lib/types/service/CallApi.d.ts.map +1 -0
  619. package/lib/types/service/IssueReporter.d.ts +40 -0
  620. package/lib/types/service/IssueReporter.d.ts.map +1 -0
  621. package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  622. package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  623. package/lib/types/service/getApiClient.d.ts +16 -0
  624. package/lib/types/service/getApiClient.d.ts.map +1 -0
  625. package/lib/types/simple/Auth.d.ts +51 -0
  626. package/lib/types/simple/Auth.d.ts.map +1 -0
  627. package/lib/types/simple/Configuration.d.ts +3 -0
  628. package/lib/types/simple/Configuration.d.ts.map +1 -0
  629. package/lib/types/simple/Directory.d.ts +3 -0
  630. package/lib/types/simple/Directory.d.ts.map +1 -0
  631. package/lib/types/simple/Phone.d.ts +115 -0
  632. package/lib/types/simple/Phone.d.ts.map +1 -0
  633. package/lib/types/simple/Websocket.d.ts +19 -0
  634. package/lib/types/simple/Websocket.d.ts.map +1 -0
  635. package/lib/types/simple/index.d.ts +147 -0
  636. package/lib/types/simple/index.d.ts.map +1 -0
  637. package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
  638. package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
  639. package/lib/types/simple/room/Participant.d.ts +76 -0
  640. package/lib/types/simple/room/Participant.d.ts.map +1 -0
  641. package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
  642. package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  643. package/lib/types/simple/room/Room.d.ts +116 -0
  644. package/lib/types/simple/room/Room.d.ts.map +1 -0
  645. package/lib/types/simple/room/SipRoom.d.ts +14 -0
  646. package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
  647. package/lib/types/simple/room/Stream.d.ts +13 -0
  648. package/lib/types/simple/room/Stream.d.ts.map +1 -0
  649. package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  650. package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  651. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  652. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  653. package/lib/types/simple/utils.d.ts +3 -0
  654. package/lib/types/simple/utils.d.ts.map +1 -0
  655. package/lib/types/types/WebSocketMessage.d.ts +285 -0
  656. package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
  657. package/lib/types/utils/Emitter.d.ts +18 -0
  658. package/lib/types/utils/Emitter.d.ts.map +1 -0
  659. package/lib/types/utils/Heartbeat.d.ts +21 -0
  660. package/lib/types/utils/Heartbeat.d.ts.map +1 -0
  661. package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
  662. package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  663. package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  664. package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  665. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  666. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  667. package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
  668. package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  669. package/lib/types/utils/__tests__/array.test.d.ts +2 -0
  670. package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
  671. package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
  672. package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  673. package/lib/types/utils/__tests__/object.test.d.ts +2 -0
  674. package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
  675. package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
  676. package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  677. package/lib/types/utils/__tests__/string.test.d.ts +2 -0
  678. package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
  679. package/lib/types/utils/api-requester.d.ts +45 -0
  680. package/lib/types/utils/api-requester.d.ts.map +1 -0
  681. package/lib/types/utils/array.d.ts +2 -0
  682. package/lib/types/utils/array.d.ts.map +1 -0
  683. package/lib/types/utils/compare-version.d.ts +3 -0
  684. package/lib/types/utils/compare-version.d.ts.map +1 -0
  685. package/lib/types/utils/isMobile.d.ts +3 -0
  686. package/lib/types/utils/isMobile.d.ts.map +1 -0
  687. package/lib/types/utils/new-from.d.ts +3 -0
  688. package/lib/types/utils/new-from.d.ts.map +1 -0
  689. package/lib/types/utils/object.d.ts +2 -0
  690. package/lib/types/utils/object.d.ts.map +1 -0
  691. package/lib/types/utils/once.d.ts +2 -0
  692. package/lib/types/utils/once.d.ts.map +1 -0
  693. package/lib/types/utils/sdp.d.ts +13 -0
  694. package/lib/types/utils/sdp.d.ts.map +1 -0
  695. package/lib/types/utils/string.d.ts +2 -0
  696. package/lib/types/utils/string.d.ts.map +1 -0
  697. package/lib/types/utils/update-from.d.ts +3 -0
  698. package/lib/types/utils/update-from.d.ts.map +1 -0
  699. package/lib/types/utils/webrtc.d.ts +15 -0
  700. package/lib/types/utils/webrtc.d.ts.map +1 -0
  701. package/lib/types/web-rtc-client.d.ts +220 -0
  702. package/lib/types/web-rtc-client.d.ts.map +1 -0
  703. package/lib/types/websocket-client.d.ts +134 -0
  704. package/lib/types/websocket-client.d.ts.map +1 -0
  705. package/lib/utils/Emitter.js +22 -33
  706. package/lib/utils/Heartbeat.js +54 -86
  707. package/lib/utils/PhoneNumberUtil.js +60 -77
  708. package/lib/utils/__tests__/Heartbeat.test.js +73 -170
  709. package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
  710. package/lib/utils/__tests__/api-requester.test.js +139 -784
  711. package/lib/utils/__tests__/array.test.js +18 -21
  712. package/lib/utils/__tests__/compare-version.test.js +12 -27
  713. package/lib/utils/__tests__/object.test.js +75 -56
  714. package/lib/utils/__tests__/sdp.test.js +99 -220
  715. package/lib/utils/__tests__/string.test.js +23 -29
  716. package/lib/utils/api-requester.js +191 -685
  717. package/lib/utils/array.js +10 -14
  718. package/lib/utils/compare-version.js +15 -18
  719. package/lib/utils/isMobile.js +3 -5
  720. package/lib/utils/new-from.js +9 -14
  721. package/lib/utils/object.js +12 -26
  722. package/lib/utils/once.js +15 -15
  723. package/lib/utils/sdp.js +97 -150
  724. package/lib/utils/string.js +8 -12
  725. package/lib/utils/update-from.js +11 -18
  726. package/lib/utils/webrtc.js +38 -39
  727. package/lib/web-rtc-client.js +2070 -7694
  728. package/lib/websocket-client.js +357 -1021
  729. package/package.json +41 -34
  730. package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
  731. package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
  732. package/src/api/agentd.ts +37 -0
  733. package/src/api/amid.ts +16 -0
  734. package/src/api/application.ts +96 -0
  735. package/src/api/auth.ts +259 -0
  736. package/src/api/call-logd.ts +38 -0
  737. package/src/api/calld.ts +183 -0
  738. package/src/api/chatd.ts +101 -0
  739. package/src/api/confd.ts +110 -0
  740. package/src/api/ctid-ng.ts +152 -0
  741. package/src/api/dird.ts +146 -0
  742. package/src/api/webhookd.ts +30 -0
  743. package/src/{api-client.js → api-client.ts} +103 -67
  744. package/src/checker/{Checker.js → Checker.ts} +27 -20
  745. package/src/checker/checks/{aor.js → aor.ts} +10 -6
  746. package/src/checker/checks/{api.js → api.ts} +18 -17
  747. package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
  748. package/src/checker/checks/{index.js → index.ts} +1 -9
  749. package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
  750. package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
  751. package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
  752. package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
  753. package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
  754. package/src/domain/{Agent.js → Agent.ts} +11 -7
  755. package/src/domain/BadResponse.ts +29 -0
  756. package/src/domain/{Call.js → Call.ts} +62 -46
  757. package/src/domain/{CallLog.js → CallLog.ts} +61 -63
  758. package/src/domain/{CallSession.js → CallSession.ts} +55 -52
  759. package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
  760. package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
  761. package/src/domain/{Contact.js → Contact.ts} +380 -262
  762. package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
  763. package/src/domain/Device/{Device.js → Device.ts} +0 -11
  764. package/src/domain/DirectorySource.ts +13 -0
  765. package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
  766. package/src/domain/{Features.js → Features.ts} +43 -17
  767. package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
  768. package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
  769. package/src/domain/{Line.js → Line.ts} +39 -26
  770. package/src/domain/{Meeting.js → Meeting.ts} +36 -29
  771. package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
  772. package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
  773. package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
  774. package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
  775. package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
  776. package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +456 -422
  777. package/src/domain/{Profile.js → Profile.ts} +117 -100
  778. package/src/domain/{Recording.js → Recording.ts} +25 -16
  779. package/src/domain/{Relocation.js → Relocation.ts} +15 -14
  780. package/src/domain/{Room.js → Room.ts} +58 -27
  781. package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
  782. package/src/domain/ServerError.ts +12 -0
  783. package/src/domain/{Session.js → Session.ts} +89 -67
  784. package/src/domain/{SipLine.js → SipLine.ts} +52 -45
  785. package/src/domain/{Subscription.js → Subscription.ts} +22 -13
  786. package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
  787. package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
  788. package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
  789. package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
  790. package/src/domain/__tests__/CallLog.test.ts +65 -0
  791. package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
  792. package/src/domain/__tests__/Contact.test.ts +238 -0
  793. package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
  794. package/src/domain/__tests__/Line.test.ts +53 -0
  795. package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
  796. package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
  797. package/src/domain/__tests__/Profile.test.ts +139 -0
  798. package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
  799. package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
  800. package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
  801. package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
  802. package/src/domain/types.ts +227 -0
  803. package/src/{index.js → index.ts} +4 -28
  804. package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
  805. package/{config.js → src/pubkey.ts} +3 -3
  806. package/src/service/{CallApi.js → CallApi.ts} +14 -18
  807. package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
  808. package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
  809. package/src/service/getApiClient.ts +94 -0
  810. package/src/simple/{Auth.js → Auth.ts} +130 -101
  811. package/src/simple/{Configuration.js → Configuration.ts} +2 -3
  812. package/src/simple/{Directory.js → Directory.ts} +2 -3
  813. package/src/simple/Phone.ts +623 -0
  814. package/src/simple/Websocket.ts +119 -0
  815. package/src/simple/{index.js → index.ts} +51 -21
  816. package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
  817. package/src/simple/room/{Participant.js → Participant.ts} +108 -46
  818. package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
  819. package/src/simple/room/{Room.js → Room.ts} +266 -183
  820. package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
  821. package/src/simple/room/{Stream.js → Stream.ts} +8 -6
  822. package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
  823. package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
  824. package/src/simple/utils.ts +12 -0
  825. package/src/types/WebSocketMessage.ts +335 -0
  826. package/src/types/global.d.ts +26 -0
  827. package/src/utils/Emitter.ts +34 -0
  828. package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
  829. package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
  830. package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
  831. package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
  832. package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
  833. package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
  834. package/src/utils/__tests__/object.test.ts +77 -0
  835. package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
  836. package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
  837. package/src/utils/{api-requester.js → api-requester.ts} +104 -83
  838. package/src/utils/{array.js → array.ts} +2 -2
  839. package/src/utils/{compare-version.js → compare-version.ts} +3 -2
  840. package/src/utils/{isMobile.js → isMobile.ts} +1 -1
  841. package/src/utils/{new-from.js → new-from.ts} +3 -6
  842. package/src/utils/{object.js → object.ts} +3 -6
  843. package/src/utils/{once.js → once.ts} +5 -5
  844. package/src/utils/sdp.ts +119 -0
  845. package/src/utils/{string.js → string.ts} +2 -3
  846. package/src/utils/update-from.ts +11 -0
  847. package/src/utils/{webrtc.js → webrtc.ts} +21 -3
  848. package/src/{web-rtc-client.js → web-rtc-client.ts} +879 -476
  849. package/src/{websocket-client.js → websocket-client.ts} +146 -144
  850. package/esm/simple/Softphone.js +0 -394
  851. package/lib/simple/Softphone.js +0 -396
  852. package/src/api/agentd.js +0 -74
  853. package/src/api/amid.js +0 -13
  854. package/src/api/application.js +0 -137
  855. package/src/api/auth.js +0 -279
  856. package/src/api/call-logd.js +0 -20
  857. package/src/api/calld.js +0 -214
  858. package/src/api/chatd.js +0 -80
  859. package/src/api/confd.js +0 -127
  860. package/src/api/ctid-ng.js +0 -153
  861. package/src/api/dird.js +0 -159
  862. package/src/api/webhookd.js +0 -31
  863. package/src/domain/BadResponse.js +0 -42
  864. package/src/domain/DirectorySource.js +0 -16
  865. package/src/domain/ServerError.js +0 -18
  866. package/src/domain/__tests__/CallLog.test.js +0 -75
  867. package/src/domain/__tests__/Contact.test.js +0 -170
  868. package/src/domain/__tests__/Line.test.js +0 -73
  869. package/src/domain/__tests__/Profile.test.js +0 -104
  870. package/src/domain/types.js +0 -248
  871. package/src/lib/WazoSessionDescriptionHandler.js +0 -467
  872. package/src/service/getApiClient.js +0 -122
  873. package/src/simple/Phone.js +0 -425
  874. package/src/simple/Softphone.js +0 -392
  875. package/src/simple/Websocket.js +0 -86
  876. package/src/simple/utils.js +0 -17
  877. package/src/types/WebSocketMessage.js +0 -232
  878. package/src/utils/Emitter.js +0 -26
  879. package/src/utils/__tests__/object.test.js +0 -35
  880. package/src/utils/sdp.js +0 -140
  881. package/src/utils/update-from.js +0 -15
  882. /package/src/domain/{Country.js → Country.ts} +0 -0
  883. /package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
@@ -1,1044 +1,380 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var ReconnectingWebSocket = require('reconnecting-websocket');
6
- var EventEmitter = require('events');
7
- var moment = require('moment');
8
- require('js-base64');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var ReconnectingWebSocket__default = /*#__PURE__*/_interopDefaultLegacy(ReconnectingWebSocket);
13
- var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
14
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
15
-
16
- //
17
-
18
- class Emitter {
19
-
20
-
21
- constructor() {
22
- this.eventEmitter = new EventEmitter__default['default']();
23
- }
24
-
25
- on(event , callback ) {
26
- this.eventEmitter.on(event, callback);
27
- }
28
-
29
- once(event , callback ) {
30
- this.eventEmitter.once(event, callback);
31
- }
32
-
33
- off(event , callback ) {
34
- this.eventEmitter.removeListener(event, callback);
35
- }
36
-
37
- unbind() {
38
- this.eventEmitter.removeAllListeners();
39
- }
40
- }
41
-
42
- /* */
43
- /* global navigator */
44
- const isMobile = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
45
-
46
- /* */
47
-
48
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
49
-
50
- // Use a function here to be able to mock it in tests
51
- const realFetch = () => {
52
- if (typeof document !== 'undefined' && window.fetch) {
53
- // Browser
54
- return window.fetch;
55
- }
56
-
57
- if (isMobile()) {
58
- // React native
59
- return fetch;
60
- }
61
-
62
- // nodejs
63
- // this package is disable for react-native in package.json because it requires nodejs modules
64
- // Used to trick the optimizer to avoid requiring `node-fetch/lib/index` directly
65
- // It causes to require it on browsers when delivered by a nodejs engine (cf: vitejs).
66
- try {
67
- // $FlowFixMe
68
- return require(Math.random() >= 0 ? 'node-fetch/lib/index' : '');
69
- } catch (e) {
70
- return fetch;
71
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
72
10
  };
73
-
74
- /* global window */
75
-
76
- const TRACE = 'trace';
77
- const DEBUG = 'debug';
78
- const INFO = 'info';
79
- const LOG = 'log';
80
- const WARN = 'warn';
81
- const ERROR = 'error';
82
- const CONSOLE_METHODS = [INFO, LOG, WARN, ERROR];
83
- const LOG_LEVELS = [TRACE, DEBUG, INFO, LOG, WARN, ERROR];
84
- const CATEGORY_PREFIX = 'logger-category=';
85
-
86
- const MAX_REMOTE_RETRY = 100;
87
-
88
- const addLevelsTo = (instance , withMethods = false) => {
89
- instance.TRACE = TRACE;
90
- instance.DEBUG = DEBUG;
91
- instance.INFO = INFO;
92
- instance.LOG = LOG;
93
- instance.WARN = WARN;
94
- instance.ERROR = ERROR;
95
-
96
- if (withMethods) {
97
- instance.trace = (...args) => instance.apply(null, [TRACE, ...args]);
98
- instance.debug = (...args) => instance.apply(null, [DEBUG, ...args]);
99
- instance.info = (...args) => instance.apply(null, [INFO, ...args]);
100
- instance.log = (...args) => instance.apply(null, [LOG, ...args]);
101
- instance.warn = (...args) => instance.apply(null, [WARN, ...args]);
102
- instance.error = (...args) => instance.apply(null, [ERROR, ...args]);
103
- }
104
-
105
- return instance;
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
106
13
  };
107
-
108
- const safeStringify = (object ) => {
109
- const result = '{"message": "Not parsable JSON"}';
110
- try {
111
- return JSON.stringify(object);
112
- } catch (e) {
113
- // Nothing to do
114
- }
115
-
116
- return result;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.APPLICATION_DESTINATION_NODE_CREATED = exports.APPLICATION_PROGRESS_STOPPED = exports.APPLICATION_PROGRESS_STARTED = exports.APPLICATION_CALL_ANSWERED = exports.APPLICATION_CALL_UPDATED = exports.APPLICATION_CALL_DELETED = exports.APPLICATION_CALL_INITIATED = exports.APPLICATION_CALL_ENTERED = exports.APPLICATION_CALL_DTMF_RECEIVED = exports.FAX_OUTBOUND_USER_FAILED = exports.FAX_OUTBOUND_USER_SUCCEEDED = exports.FAX_OUTBOUND_USER_CREATED = exports.SWITCHBOARD_HELD_CALL_ANSWERED = exports.SWITCHBOARD_HELD_CALLS_UPDATED = exports.SWITCHBOARD_QUEUED_CALL_ANSWERED = exports.SWITCHBOARD_QUEUED_CALLS_UPDATED = exports.MEETING_USER_PARTICIPANT_LEFT = exports.MEETING_USER_PARTICIPANT_JOINED = exports.CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = exports.CONFERENCE_USER_PARTICIPANT_TALK_STARTED = exports.CONFERENCE_USER_PARTICIPANT_LEFT = exports.CONFERENCE_USER_PARTICIPANT_JOINED = exports.CHATD_USER_ROOM_CREATED = exports.CHATD_USER_ROOM_MESSAGE_CREATED = exports.CHATD_PRESENCE_UPDATED = exports.AUTH_USER_EXTERNAL_AUTH_DELETED = exports.AUTH_USER_EXTERNAL_AUTH_ADDED = exports.CALL_RESUMED = exports.CALL_HELD = exports.CALL_UPDATED = exports.CALL_ENDED = exports.CALL_DTMF_CREATED = exports.CALL_ANSWERED = exports.CALL_CREATED = exports.CALL_LOG_USER_CREATED = exports.USER_VOICEMAIL_MESSAGE_DELETED = exports.USER_VOICEMAIL_MESSAGE_UPDATED = exports.USER_VOICEMAIL_MESSAGE_CREATED = exports.USERS_SERVICES_DND_UPDATED = exports.USERS_FORWARDS_UNCONDITIONAL_UPDATED = exports.USERS_FORWARDS_NOANSWER_UPDATED = exports.USERS_FORWARDS_BUSY_UPDATED = exports.ENDPOINT_STATUS_UPDATE = exports.CHAT_MESSAGE_RECEIVED = exports.CHAT_MESSAGE_SENT = exports.USER_STATUS_UPDATE = exports.FAVORITE_DELETED = exports.FAVORITE_ADDED = exports.AUTH_SESSION_EXPIRE_SOON = exports.SOCKET_EVENTS = void 0;
16
+ exports.HEARTBEAT_ENGINE_VERSION = exports.MEETING_USER_GUEST_AUTHORIZATION_CREATED = exports.MEETING_USER_PROGRESS = exports.CONFERENCE_ADHOC_DELETED = exports.CONFERENCE_ADHOC_PARTICIPANT_LEFT = exports.AGENT_UNPAUSED = exports.AGENT_PAUSED = exports.AGENT_STATUS_UPDATE = exports.LINE_STATUS_UPDATED = exports.TRUNK_STATUS_UPDATED = exports.APPLICATION_USER_OUTGOING_CALL_CREATED = exports.APPLICATION_SNOOP_UPDATED = exports.APPLICATION_SNOOP_DELETED = exports.APPLICATION_SNOOP_CREATED = exports.APPLICATION_PLAYBACK_DELETED = exports.APPLICATION_PLAYBACK_CREATED = exports.APPLICATION_NODE_UPDATED = exports.APPLICATION_NODE_DELETED = exports.APPLICATION_NODE_CREATED = void 0;
17
+ /* eslint-disable no-underscore-dangle */
18
+ const reconnecting_websocket_1 = __importDefault(require("reconnecting-websocket"));
19
+ const Emitter_1 = __importDefault(require("./utils/Emitter"));
20
+ const IssueReporter_1 = __importDefault(require("./service/IssueReporter"));
21
+ const Heartbeat_1 = __importDefault(require("./utils/Heartbeat"));
22
+ exports.SOCKET_EVENTS = {
23
+ ON_OPEN: 'onopen',
24
+ ON_MESSAGE: 'onmessage',
25
+ ON_ERROR: 'onerror',
26
+ ON_CLOSE: 'onclose',
27
+ INITIALIZED: 'initialized',
28
+ ON_AUTH_FAILED: 'on_auth_failed',
117
29
  };
118
-
119
- class IssueReporter {
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
- constructor() {
137
- addLevelsTo(this);
138
-
139
- this.oldConsoleMethods = null;
140
- this.enabled = false;
141
- this.remoteClientConfiguration = null;
142
- this.buffer = [];
143
- this.bufferTimeout = null;
144
- this._boundProcessBuffer = this._processBuffer.bind(this);
145
- this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
146
- this._callback = null;
147
- }
148
-
149
- init() {
150
- this._catchConsole();
151
- }
152
-
153
- setCallback(cb ) {
154
- this._callback = cb;
155
- }
156
-
157
- configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
158
- this.remoteClientConfiguration = configuration;
159
- }
160
-
161
- enable() {
162
- if (!this.oldConsoleMethods) {
163
- this.init();
164
- }
165
-
166
- this.enabled = true;
167
- }
168
-
169
- disable() {
170
- this.enabled = false;
171
- }
172
-
173
- loggerFor(category ) {
174
- const logger = (level , ...args ) => {
175
- this.log.apply(this, [level, this._makeCategory(category), ...args]);
176
- };
177
-
178
- return addLevelsTo(logger, true);
179
- }
180
-
181
- removeSlashes(str ) {
182
- return str.replace(/"/g, "'").replace(/\\/g, '');
183
- }
184
-
185
- log(level , ...args ) {
186
- if (!this.enabled) {
187
- return;
188
- }
189
-
190
- // Handle category label
191
- let category = null;
192
- let skipSendToRemote = false;
193
- let extra = {};
194
- if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
195
- category = args[0].split('=')[1];
196
- // eslint-disable-next-line no-param-reassign
197
- args.splice(0, 1);
198
- }
199
-
200
- // Handle extra data as object for the last argument
201
- const lastArg = args[args.length - 1];
202
- if (lastArg && ((typeof lastArg === 'object' && Object.keys(lastArg).length) || lastArg instanceof Error)) {
203
- if (lastArg instanceof Error) {
204
- extra = {
205
- errorMessage: lastArg.message,
206
- errorStack: lastArg.stack,
207
- errorType: lastArg.constructor.name,
208
- skipSendToRemote: lastArg.skipSendToRemote,
30
+ exports.AUTH_SESSION_EXPIRE_SOON = 'auth_session_expire_soon';
31
+ exports.FAVORITE_ADDED = 'favorite_added';
32
+ exports.FAVORITE_DELETED = 'favorite_deleted';
33
+ exports.USER_STATUS_UPDATE = 'user_status_update';
34
+ exports.CHAT_MESSAGE_SENT = 'chat_message_sent';
35
+ exports.CHAT_MESSAGE_RECEIVED = 'chat_message_received';
36
+ exports.ENDPOINT_STATUS_UPDATE = 'endpoint_status_update';
37
+ exports.USERS_FORWARDS_BUSY_UPDATED = 'users_forwards_busy_updated';
38
+ exports.USERS_FORWARDS_NOANSWER_UPDATED = 'users_forwards_noanswer_updated';
39
+ exports.USERS_FORWARDS_UNCONDITIONAL_UPDATED = 'users_forwards_unconditional_updated';
40
+ exports.USERS_SERVICES_DND_UPDATED = 'users_services_dnd_updated';
41
+ exports.USER_VOICEMAIL_MESSAGE_CREATED = 'user_voicemail_message_created';
42
+ exports.USER_VOICEMAIL_MESSAGE_UPDATED = 'user_voicemail_message_updated';
43
+ exports.USER_VOICEMAIL_MESSAGE_DELETED = 'user_voicemail_message_deleted';
44
+ exports.CALL_LOG_USER_CREATED = 'call_log_user_created';
45
+ exports.CALL_CREATED = 'call_created';
46
+ exports.CALL_ANSWERED = 'call_answered';
47
+ exports.CALL_DTMF_CREATED = 'call_dtmf_created';
48
+ exports.CALL_ENDED = 'call_ended';
49
+ exports.CALL_UPDATED = 'call_updated';
50
+ exports.CALL_HELD = 'call_held';
51
+ exports.CALL_RESUMED = 'call_resumed';
52
+ exports.AUTH_USER_EXTERNAL_AUTH_ADDED = 'auth_user_external_auth_added';
53
+ exports.AUTH_USER_EXTERNAL_AUTH_DELETED = 'auth_user_external_auth_deleted';
54
+ exports.CHATD_PRESENCE_UPDATED = 'chatd_presence_updated';
55
+ exports.CHATD_USER_ROOM_MESSAGE_CREATED = 'chatd_user_room_message_created';
56
+ exports.CHATD_USER_ROOM_CREATED = 'chatd_user_room_created';
57
+ exports.CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
58
+ exports.CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
59
+ exports.CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
60
+ exports.CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
61
+ exports.MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
62
+ exports.MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
63
+ exports.SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
64
+ exports.SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
65
+ exports.SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
66
+ exports.SWITCHBOARD_HELD_CALL_ANSWERED = 'switchboard_held_call_answered';
67
+ exports.FAX_OUTBOUND_USER_CREATED = 'fax_outbound_user_created';
68
+ exports.FAX_OUTBOUND_USER_SUCCEEDED = 'fax_outbound_user_succeeded';
69
+ exports.FAX_OUTBOUND_USER_FAILED = 'fax_outbound_user_failed';
70
+ exports.APPLICATION_CALL_DTMF_RECEIVED = 'application_call_dtmf_received';
71
+ exports.APPLICATION_CALL_ENTERED = 'application_call_entered';
72
+ exports.APPLICATION_CALL_INITIATED = 'application_call_initiated';
73
+ exports.APPLICATION_CALL_DELETED = 'application_call_deleted';
74
+ exports.APPLICATION_CALL_UPDATED = 'application_call_updated';
75
+ exports.APPLICATION_CALL_ANSWERED = 'application_call_answered';
76
+ exports.APPLICATION_PROGRESS_STARTED = 'application_progress_started';
77
+ exports.APPLICATION_PROGRESS_STOPPED = 'application_progress_stopped';
78
+ exports.APPLICATION_DESTINATION_NODE_CREATED = 'application_destination_node_created';
79
+ exports.APPLICATION_NODE_CREATED = 'application_node_created';
80
+ exports.APPLICATION_NODE_DELETED = 'application_node_deleted';
81
+ exports.APPLICATION_NODE_UPDATED = 'application_node_updated';
82
+ exports.APPLICATION_PLAYBACK_CREATED = 'application_playback_created';
83
+ exports.APPLICATION_PLAYBACK_DELETED = 'application_playback_deleted';
84
+ exports.APPLICATION_SNOOP_CREATED = 'application_snoop_created';
85
+ exports.APPLICATION_SNOOP_DELETED = 'application_snoop_deleted';
86
+ exports.APPLICATION_SNOOP_UPDATED = 'application_snoop_updated';
87
+ exports.APPLICATION_USER_OUTGOING_CALL_CREATED = 'application_user_outgoing_call_created';
88
+ exports.TRUNK_STATUS_UPDATED = 'trunk_status_updated';
89
+ exports.LINE_STATUS_UPDATED = 'line_status_updated';
90
+ exports.AGENT_STATUS_UPDATE = 'agent_status_update';
91
+ exports.AGENT_PAUSED = 'agent_paused';
92
+ exports.AGENT_UNPAUSED = 'agent_unpaused';
93
+ exports.CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
94
+ exports.CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
95
+ exports.MEETING_USER_PROGRESS = 'meeting_user_progress';
96
+ exports.MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
97
+ const BLACKLIST_EVENTS = [exports.CHAT_MESSAGE_SENT, exports.CHAT_MESSAGE_RECEIVED, exports.CHATD_USER_ROOM_MESSAGE_CREATED, exports.CHATD_USER_ROOM_CREATED];
98
+ exports.HEARTBEAT_ENGINE_VERSION = '20.09';
99
+ const logger = IssueReporter_1.default.loggerFor('wazo-ws');
100
+ const messageLogger = IssueReporter_1.default.loggerFor('wazo-ws-message');
101
+ class WebSocketClient extends Emitter_1.default {
102
+ /**
103
+ *
104
+ * @param host
105
+ * @param token
106
+ * @param events
107
+ * @param version
108
+ * @param heartbeat
109
+ * @param options @see https://github.com/pladaria/reconnecting-websocket#available-options
110
+ */
111
+ constructor({ host, token, version, events, heartbeat, }, options = {
112
+ host,
113
+ token,
114
+ version: 1,
115
+ events: [],
116
+ heartbeat: {},
117
+ }) {
118
+ super();
119
+ this.initialized = false;
120
+ this.socket = null;
121
+ this.host = host;
122
+ this.token = token;
123
+ this.events = events;
124
+ this.options = options;
125
+ this.version = version;
126
+ this._boundOnHeartbeat = this._onHeartbeat.bind(this);
127
+ const { delay, timeout, max, } = heartbeat || {};
128
+ this.heartbeat = new Heartbeat_1.default(delay, timeout, max);
129
+ this.heartbeat.setSendHeartbeat(this.pingServer.bind(this));
130
+ this.heartbeat.setOnHeartbeatTimeout(this._onHeartbeatTimeout.bind(this));
131
+ this.eventLists = WebSocketClient.eventLists;
132
+ }
133
+ connect() {
134
+ logger.info('connect method started', {
135
+ host: this.host,
136
+ token: this.token,
137
+ });
138
+ this.socket = new reconnecting_websocket_1.default(this._getUrl.bind(this), [], this.options);
139
+ if (this.options.binaryType) {
140
+ this.socket.binaryType = this.options.binaryType;
141
+ }
142
+ this.socket.onopen = () => {
143
+ logger.info('on Wazo WS open', {
144
+ method: 'connect',
145
+ host: this.host,
146
+ });
147
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_OPEN);
148
+ };
149
+ this.socket.onerror = event => {
150
+ logger.error('on Wazo WS error', event.target);
151
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_ERROR, event);
152
+ };
153
+ this.socket.onmessage = (event) => {
154
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_MESSAGE, event.data);
155
+ const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
156
+ let { name, } = message;
157
+ if (message.data && message.data.name) {
158
+ // eslint-disable-next-line
159
+ name = message.data.name;
160
+ }
161
+ if (BLACKLIST_EVENTS.indexOf(name) === -1) {
162
+ messageLogger.trace(IssueReporter_1.default.removeSlashes(event.data), {
163
+ method: 'onmessage',
164
+ });
165
+ }
166
+ else {
167
+ messageLogger.trace(`{"name": "${name}", "info": "content not shown"}`, {
168
+ method: 'onmessage',
169
+ });
170
+ }
171
+ if (!this.initialized) {
172
+ this._handleInitMessage(message, this.socket);
173
+ }
174
+ else {
175
+ this._handleMessage(message);
176
+ }
177
+ };
178
+ this.socket.onclose = event => {
179
+ // Can't be converted to JSON (circular structure)
180
+ logger.info('on Wazo WS close', {
181
+ reason: event.reason,
182
+ code: event.code,
183
+ readyState: event.target.readyState,
184
+ host: this.host,
185
+ token: this.token,
186
+ });
187
+ this.initialized = false;
188
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_CLOSE, event);
189
+ switch (event.code) {
190
+ case 4002:
191
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_AUTH_FAILED);
192
+ break;
193
+ case 4003:
194
+ break;
195
+ default:
196
+ }
197
+ };
198
+ this.socket.onerror = event => {
199
+ logger.info('Wazo WS error', {
200
+ message: event.message,
201
+ // @ts-ignore
202
+ code: event.code,
203
+ readyState: event.target.readyState,
204
+ });
209
205
  };
210
- } else {
211
- extra = lastArg;
212
- }
213
- // eslint-disable-next-line no-param-reassign
214
- args.splice(1, 1);
215
- }
216
-
217
- if (extra.skipSendToRemote) {
218
- skipSendToRemote = true;
219
- delete extra.skipSendToRemote;
220
206
  }
221
-
222
- const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
223
- const message = args.join(', ');
224
- let consoleMessage = message;
225
-
226
- if (Object.keys(extra).length) {
227
- const parsedExtra = safeStringify(extra);
228
- consoleMessage = `${consoleMessage} (${parsedExtra})`;
207
+ close(force = false) {
208
+ logger.info('Wazo WS close', {
209
+ socket: !!this.socket,
210
+ host: this.host,
211
+ token: this.token,
212
+ });
213
+ if (!this.socket) {
214
+ return;
215
+ }
216
+ this.socket.close();
217
+ this.initialized = false;
218
+ if (force) {
219
+ this.host = null;
220
+ this.token = null;
221
+ this.socket = null;
222
+ }
229
223
  }
230
-
231
- if (category) {
232
- consoleMessage = `[${category}] ${consoleMessage}`;
224
+ updateToken(token) {
225
+ this.token = token;
226
+ logger.info('Wazo WS updating token', {
227
+ url: this._getUrl(),
228
+ token,
229
+ socket: !!this.socket,
230
+ });
231
+ if (this.socket) {
232
+ // If still connected, send the token to the WS
233
+ if (this.isConnected() && Number(this.version) >= 2) {
234
+ this.socket.send(JSON.stringify({
235
+ op: 'token',
236
+ data: {
237
+ token,
238
+ },
239
+ }));
240
+ }
241
+ else if (!this.isConnected()) {
242
+ this.reconnect('token refreshed');
243
+ }
244
+ }
233
245
  }
234
-
235
- // Log the message in the console anyway (but don't console.error on mobile)
236
- const consoleLevel = isMobile() && level === 'error' ? WARN : level;
237
-
238
- // eslint-disable-next-line
239
- const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
240
- oldMethod.apply(oldMethod, [date, consoleMessage]);
241
-
242
- if (this._callback) {
243
- this._callback(level, consoleMessage);
246
+ hasHeartbeat() {
247
+ return this.heartbeat.hasHeartbeat;
244
248
  }
245
-
246
- if (!skipSendToRemote) {
247
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
249
+ startHeartbeat() {
250
+ logger.info('Wazo WS start heartbeat', {
251
+ host: this.host,
252
+ token: this.token,
253
+ });
254
+ if (!this.socket) {
255
+ this.heartbeat.stop();
256
+ return;
257
+ }
258
+ this.off('pong', this._boundOnHeartbeat);
259
+ this.on('pong', this._boundOnHeartbeat);
260
+ this.heartbeat.start();
261
+ }
262
+ stopHeartbeat() {
263
+ logger.info('Wazo WS stop heartbeat', {
264
+ host: this.host,
265
+ token: this.token,
266
+ });
267
+ this.heartbeat.stop();
248
268
  }
249
- }
250
-
251
- logRequest(url , options , response , start ) {
252
- if (!this.enabled) {
253
- return;
269
+ setOnHeartbeatTimeout(cb) {
270
+ this.onHeartBeatTimeout = cb;
254
271
  }
255
- const { status } = response;
256
- const duration = new Date() - start;
257
-
258
- let level = TRACE;
259
- if (status >= 400 && status < 500) {
260
- level = WARN;
261
- } else if (status >= 500) {
262
- level = ERROR;
272
+ setOnHeartbeatCallback(cb) {
273
+ this.heartbeatCb = cb;
263
274
  }
264
-
265
- this.log(level, this._makeCategory('http'), url, {
266
- status,
267
- body: this.removeSlashes(JSON.stringify(options.body)),
268
- method: options.method,
269
- headers: options.headers,
270
- duration,
271
- });
272
- }
273
-
274
- // Logs aren't stored anymore
275
- getLogs() {
276
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
277
- return [];
278
- }
279
-
280
- getParsedLogs() {
281
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
282
- return [];
283
- }
284
-
285
- getReport() {
286
- return this.getParsedLogs().join('\r\n');
287
- }
288
-
289
- _catchConsole() {
290
- this.oldConsoleMethods = {};
291
- CONSOLE_METHODS.forEach((methodName ) => {
292
- // eslint-disable-next-line
293
- this.oldConsoleMethods[methodName] = console[methodName];
294
- window.console[methodName] = (...args) => {
295
- // Store message
275
+ pingServer() {
276
+ if (!this.socket || !this.isConnected()) {
277
+ return;
278
+ }
296
279
  try {
297
- this.log(methodName, args.join(' '));
298
- // Use old console method to log it normally
299
- this.oldConsoleMethods[methodName].apply(null, args);
300
- } catch (e) {
301
- // Avoid circular structure issues
280
+ this.socket.send(JSON.stringify({
281
+ op: 'ping',
282
+ data: {
283
+ payload: 'pong',
284
+ },
285
+ }));
302
286
  }
303
- };
304
- });
305
- }
306
-
307
- _sendToRemoteLogger(level , payload = {}) {
308
- if (!this.remoteClientConfiguration) {
309
- return;
310
- }
311
-
312
- const { level: minLevel, bufferSize } = this.remoteClientConfiguration;
313
- if (!minLevel || this._isLevelAbove(minLevel, level)) {
314
- return;
315
- }
316
-
317
- payload.level = level;
318
-
319
- if (bufferSize > 0) {
320
- return this._addToBuffer(payload);
321
- }
322
-
323
- this._sendDebugToGrafana(payload);
324
- }
325
-
326
- _parseLoggerBody(payload ) {
327
- const { level } = payload;
328
- const { maxMessageSize, extra } = this.remoteClientConfiguration || {};
329
-
330
- delete payload.level;
331
-
332
- if (maxMessageSize && typeof payload.message === 'string' && payload.message.length > maxMessageSize) {
333
- payload.message = `${payload.message.substr(0, maxMessageSize)}...`;
334
- }
335
-
336
- return safeStringify({
337
- level,
338
- ...payload,
339
- ...extra,
340
- });
341
- }
342
-
343
- _addToBuffer(payload ) {
344
- // Reset buffer timer
345
- if (this.bufferTimeout) {
346
- clearTimeout(this.bufferTimeout);
347
- this.bufferTimeout = null;
348
- }
349
-
350
- this.buffer.push(payload);
351
-
352
- // $FlowFixMe
353
- const { bufferSize, bufferTimeout } = this.remoteClientConfiguration;
354
-
355
- if (this.buffer.length > bufferSize) {
356
- return this._processBuffer();
357
- }
358
-
359
- if (bufferTimeout > 0) {
360
- this.bufferTimeout = setTimeout(this._boundProcessBuffer, bufferTimeout);
361
- }
362
- }
363
-
364
- _processBuffer() {
365
- this._sendDebugToGrafana(this.buffer);
366
-
367
- this.buffer = [];
368
- if (this.bufferTimeout) {
369
- clearTimeout(this.bufferTimeout);
370
- this.bufferTimeout = null;
371
- }
372
- }
373
-
374
- _sendDebugToGrafana(payload , retry = 0) {
375
- if (!this.remoteClientConfiguration || retry >= MAX_REMOTE_RETRY) {
376
- return;
377
- }
378
-
379
- const { tag, host, port } = this.remoteClientConfiguration;
380
- const isArray = Array.isArray(payload);
381
- const isSecure = +port === 443;
382
- const url = `http${isSecure ? 's' : ''}://${host}${isSecure ? '' : `:${port}`}/${tag}`;
383
- const body = isArray ? `[${payload.map(this._boundParseLoggerBody).join(',')}]` : this._parseLoggerBody(payload);
384
-
385
- realFetch()(url, {
386
- method: 'POST',
387
- headers: {
388
- Accept: 'application/json',
389
- 'Content-Type': 'application/json',
390
- },
391
- // $FlowFixMe
392
- body,
393
- }).catch((e ) => {
394
- // $FlowFixMe
395
- e.skipSendToRemote = true;
396
- this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
397
-
398
- setTimeout(() => {
399
- if (isArray) {
400
- payload = payload.map(message => this._writeRetryCount(message, retry + 1));
401
- } else if (payload && typeof payload === 'object') {
402
- payload = this._writeRetryCount(payload, retry + 1);
287
+ catch (_) { // Nothing to do
403
288
  }
404
-
405
- this._sendDebugToGrafana(payload, retry + 1);
406
- }, 5000 + retry * 1000);
407
- });
408
- }
409
-
410
- _writeRetryCount(message , count ) {
411
- if (message && typeof message === 'object') {
412
- // $FlowFixMe
413
- message._retry = count;
414
- }
415
-
416
- return message;
417
- }
418
-
419
- _isLevelAbove(level1 , level2 ) {
420
- const index1 = LOG_LEVELS.indexOf(level1);
421
- const index2 = LOG_LEVELS.indexOf(level2);
422
- if (index1 === -1 || index2 === -1) {
423
- return false;
424
- }
425
-
426
- return index1 > index2;
427
- }
428
-
429
- _makeCategory(category ) {
430
- return `${CATEGORY_PREFIX}${category}`;
431
- }
432
- }
433
-
434
- var IssueReporter$1 = new IssueReporter();
435
-
436
- //
437
-
438
- const DEFAULT_HEARTBEAT_DELAY = 2000;
439
- const DEFAULT_HEARTBEAT_TIMEOUT = 5000;
440
- const DEFAULT_MAX_HEARTBEATS = 3;
441
-
442
- class Heartbeat {
443
-
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
- constructor(heartbeatDelay = DEFAULT_HEARTBEAT_DELAY, heartbeatTimeout = DEFAULT_HEARTBEAT_TIMEOUT,
455
- maxHeartbeats = DEFAULT_MAX_HEARTBEATS) {
456
- this.heartbeatDelay = heartbeatDelay;
457
- this.heartbeatTimeout = heartbeatTimeout;
458
- this.maxHeartbeats = maxHeartbeats;
459
-
460
- this.hasHeartbeat = false;
461
- this._heartbeatTries = 0;
462
- }
463
-
464
- setSendHeartbeat(cb ) {
465
- this._sendHeartbeatCallback = cb;
466
- }
467
-
468
- setOnHeartbeatTimeout(cb ) {
469
- this._onTimeoutCallback = cb;
470
- }
471
-
472
- stop() {
473
- this.hasHeartbeat = false;
474
-
475
- if (this._heartbeatNotReceivedTimeout) {
476
- clearTimeout(this._heartbeatNotReceivedTimeout);
477
- }
478
- if (this._heartbeatDelayTimeout) {
479
- clearTimeout(this._heartbeatDelayTimeout);
480
- }
481
- }
482
-
483
- start() {
484
- this.stop();
485
- this.hasHeartbeat = true;
486
- this._heartbeatTries = 0;
487
- this._sendHeartbeat();
488
- }
489
-
490
- onHeartbeat() {
491
- this._clearTimeouts();
492
-
493
- if (!this.hasHeartbeat) {
494
- return;
495
- }
496
-
497
- this._sendHeartbeat();
498
- }
499
-
500
- _sendHeartbeat() {
501
- if (this._heartbeatTries >= this.maxHeartbeats) {
502
- return;
503
- }
504
-
505
- this._clearTimeouts();
506
-
507
- this._heartbeatDelayTimeout = setTimeout(() => {
508
- this._heartbeatTries++;
509
-
510
- if (this._sendHeartbeatCallback) {
511
- this._sendHeartbeatCallback();
512
- }
513
- }, this.heartbeatDelay);
514
-
515
- if (this._onTimeoutCallback) {
516
- this._heartbeatNotReceivedTimeout = setTimeout(this._onTimeoutCallback, this.heartbeatTimeout);
517
- }
518
- }
519
-
520
- _clearTimeouts() {
521
- if (this._heartbeatNotReceivedTimeout) {
522
- clearTimeout(this._heartbeatNotReceivedTimeout);
523
- }
524
-
525
- if (this._heartbeatDelayTimeout) {
526
- clearTimeout(this._heartbeatDelayTimeout);
527
- }
528
- }
529
- }
530
-
531
- //
532
-
533
- const SOCKET_EVENTS = {
534
- ON_OPEN: 'onopen',
535
- ON_MESSAGE: 'onmessage',
536
- ON_ERROR: 'onerror',
537
- ON_CLOSE: 'onclose',
538
- INITIALIZED: 'initialized',
539
- ON_AUTH_FAILED: 'on_auth_failed',
540
- };
541
-
542
-
543
-
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
-
553
-
554
- const AUTH_SESSION_EXPIRE_SOON = 'auth_session_expire_soon';
555
- const FAVORITE_ADDED = 'favorite_added';
556
- const FAVORITE_DELETED = 'favorite_deleted';
557
- const USER_STATUS_UPDATE = 'user_status_update';
558
- const CHAT_MESSAGE_SENT = 'chat_message_sent';
559
- const CHAT_MESSAGE_RECEIVED = 'chat_message_received';
560
- const ENDPOINT_STATUS_UPDATE = 'endpoint_status_update';
561
- const USERS_FORWARDS_BUSY_UPDATED = 'users_forwards_busy_updated';
562
- const USERS_FORWARDS_NOANSWER_UPDATED = 'users_forwards_noanswer_updated';
563
- const USERS_FORWARDS_UNCONDITIONAL_UPDATED = 'users_forwards_unconditional_updated';
564
- const USERS_SERVICES_DND_UPDATED = 'users_services_dnd_updated';
565
- const USER_VOICEMAIL_MESSAGE_CREATED = 'user_voicemail_message_created';
566
- const USER_VOICEMAIL_MESSAGE_UPDATED = 'user_voicemail_message_updated';
567
- const USER_VOICEMAIL_MESSAGE_DELETED = 'user_voicemail_message_deleted';
568
- const CALL_LOG_USER_CREATED = 'call_log_user_created';
569
- const CALL_CREATED = 'call_created';
570
- const CALL_ANSWERED = 'call_answered';
571
- const CALL_DTMF_CREATED = 'call_dtmf_created';
572
- const CALL_ENDED = 'call_ended';
573
- const CALL_UPDATED = 'call_updated';
574
- const CALL_HELD = 'call_held';
575
- const CALL_RESUMED = 'call_resumed';
576
- const AUTH_USER_EXTERNAL_AUTH_ADDED = 'auth_user_external_auth_added';
577
- const AUTH_USER_EXTERNAL_AUTH_DELETED = 'auth_user_external_auth_deleted';
578
- const CHATD_PRESENCE_UPDATED = 'chatd_presence_updated';
579
- const CHATD_USER_ROOM_MESSAGE_CREATED = 'chatd_user_room_message_created';
580
- const CHATD_USER_ROOM_CREATED = 'chatd_user_room_created';
581
- const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
582
- const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
583
- const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
584
- const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
585
- const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
586
- const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
587
- const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
588
- const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
589
- const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
590
- const SWITCHBOARD_HELD_CALL_ANSWERED = 'switchboard_held_call_answered';
591
- const FAX_OUTBOUND_USER_CREATED = 'fax_outbound_user_created';
592
- const FAX_OUTBOUND_USER_SUCCEEDED = 'fax_outbound_user_succeeded';
593
- const FAX_OUTBOUND_USER_FAILED = 'fax_outbound_user_failed';
594
- const APPLICATION_CALL_DTMF_RECEIVED = 'application_call_dtmf_received';
595
- const APPLICATION_CALL_ENTERED = 'application_call_entered';
596
- const APPLICATION_CALL_INITIATED = 'application_call_initiated';
597
- const APPLICATION_CALL_DELETED = 'application_call_deleted';
598
- const APPLICATION_CALL_UPDATED = 'application_call_updated';
599
- const APPLICATION_CALL_ANSWERED = 'application_call_answered';
600
- const APPLICATION_PROGRESS_STARTED = 'application_progress_started';
601
- const APPLICATION_PROGRESS_STOPPED = 'application_progress_stopped';
602
- const APPLICATION_DESTINATION_NODE_CREATED = 'application_destination_node_created';
603
- const APPLICATION_NODE_CREATED = 'application_node_created';
604
- const APPLICATION_NODE_DELETED = 'application_node_deleted';
605
- const APPLICATION_NODE_UPDATED = 'application_node_updated';
606
- const APPLICATION_PLAYBACK_CREATED = 'application_playback_created';
607
- const APPLICATION_PLAYBACK_DELETED = 'application_playback_deleted';
608
- const APPLICATION_SNOOP_CREATED = 'application_snoop_created';
609
- const APPLICATION_SNOOP_DELETED = 'application_snoop_deleted';
610
- const APPLICATION_SNOOP_UPDATED = 'application_snoop_updated';
611
- const APPLICATION_USER_OUTGOING_CALL_CREATED = 'application_user_outgoing_call_created';
612
- const TRUNK_STATUS_UPDATED = 'trunk_status_updated';
613
- const LINE_STATUS_UPDATED = 'line_status_updated';
614
- const AGENT_STATUS_UPDATE = 'agent_status_update';
615
- const AGENT_PAUSED = 'agent_paused';
616
- const AGENT_UNPAUSED = 'agent_unpaused';
617
- const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
618
- const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
619
- const MEETING_USER_PROGRESS = 'meeting_user_progress';
620
- const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
621
-
622
- const BLACKLIST_EVENTS = [
623
- CHAT_MESSAGE_SENT,
624
- CHAT_MESSAGE_RECEIVED,
625
- CHATD_USER_ROOM_MESSAGE_CREATED,
626
- CHATD_USER_ROOM_CREATED,
627
- ];
628
-
629
- const HEARTBEAT_ENGINE_VERSION = '20.09';
630
- const logger = IssueReporter$1.loggerFor('wazo-ws');
631
- const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
632
-
633
- class WebSocketClient extends Emitter {
634
-
635
-
636
-
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
-
647
-
648
-
649
- /**
650
- *
651
- * @param host
652
- * @param token
653
- * @param events
654
- * @param version
655
- * @param heartbeat
656
- * @param options @see https://github.com/pladaria/reconnecting-websocket#available-options
657
- */
658
- constructor({ host, token, version = 1, events = [], heartbeat = {} } , options = {}) {
659
- super();
660
- this.initialized = false;
661
-
662
- this.socket = null;
663
- this.host = host;
664
- this.token = token;
665
- this.events = events;
666
- this.options = options;
667
- this.version = version;
668
-
669
- this._boundOnHeartbeat = this._onHeartbeat.bind(this);
670
- const { delay, timeout, max } = heartbeat;
671
- this.heartbeat = new Heartbeat(delay, timeout, max);
672
- this.heartbeat.setSendHeartbeat(this.pingServer.bind(this));
673
- this.heartbeat.setOnHeartbeatTimeout(this._onHeartbeatTimeout.bind(this));
674
-
675
- this.eventLists = WebSocketClient.eventLists;
676
- }
677
-
678
- connect() {
679
- logger.info('connect method started', { host: this.host, token: this.token });
680
- this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
681
- if (this.options.binaryType) {
682
- this.socket.binaryType = this.options.binaryType;
683
- }
684
-
685
- this.socket.onopen = () => {
686
- logger.info('on Wazo WS open', { method: 'connect', host: this.host });
687
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
688
- };
689
-
690
- this.socket.onerror = event => {
691
- logger.error('on Wazo WS error', event.target);
692
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
693
- };
694
-
695
- this.socket.onmessage = (event ) => {
696
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
697
-
698
- const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
699
- let { name } = message;
700
- if (message.data && message.data.name) {
701
- // eslint-disable-next-line
702
- name = message.data.name;
703
- }
704
-
705
- if (BLACKLIST_EVENTS.indexOf(name) === -1) {
706
- // $FlowFixMe
707
- messageLogger.trace(IssueReporter$1.removeSlashes(event.data), { method: 'onmessage' });
708
- } else {
709
- messageLogger.trace(`{"name": "${name}", "info": "content not shown"}`, { method: 'onmessage' });
710
- }
711
-
712
- if (!this.initialized) {
713
- this._handleInitMessage(message, this.socket);
714
- } else {
715
- this._handleMessage(message);
716
- }
717
- };
718
-
719
- this.socket.onclose = event => {
720
- // Can't be converted to JSON (circular structure)
721
- logger.info('on Wazo WS close', {
722
- reason: event.reason,
723
- code: event.code,
724
- readyState: event.target.readyState,
725
- host: this.host,
726
- token: this.token,
727
- });
728
- this.initialized = false;
729
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
730
-
731
- switch (event.code) {
732
- case 4002:
733
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
734
- break;
735
- }
736
- };
737
-
738
- this.socket.onerror = event => {
739
- logger.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
740
- };
741
- }
742
-
743
- close(force = false) {
744
- logger.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
745
-
746
- if (!this.socket) {
747
- return;
748
- }
749
-
750
- this.socket.close();
751
- this.initialized = false;
752
-
753
- if (force) {
754
- this.host = null;
755
- this.token = null;
756
- this.socket = null;
757
289
  }
758
- }
759
-
760
- updateToken(token ) {
761
- this.token = token;
762
- logger.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
763
-
764
- if (this.socket) {
765
- // If still connected, send the token to the WS
766
- if (this.isConnected() && this.version >= 2) {
767
- // $FlowFixMe
768
- this.socket.send(JSON.stringify({ op: 'token', data: { token } }));
769
- } else if (!this.isConnected()) {
770
- this.reconnect('token refreshed');
771
- }
290
+ isConnected() {
291
+ return this.socket && this.socket.readyState === this.socket.OPEN;
772
292
  }
773
- }
774
-
775
- hasHeartbeat() {
776
- return this.heartbeat.hasHeartbeat;
777
- }
778
-
779
- startHeartbeat() {
780
- logger.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
781
-
782
- if (!this.socket) {
783
- this.heartbeat.stop();
784
- return;
785
- }
786
-
787
- this.off('pong', this._boundOnHeartbeat);
788
- this.on('pong', this._boundOnHeartbeat);
789
-
790
- this.heartbeat.start();
791
- }
792
-
793
- stopHeartbeat() {
794
- logger.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
795
-
796
- this.heartbeat.stop();
797
- }
798
-
799
- setOnHeartbeatTimeout(cb ) {
800
- this.onHeartBeatTimeout = cb;
801
- }
802
-
803
- setOnHeartbeatCallback(cb ) {
804
- this.heartbeatCb = cb;
805
- }
806
-
807
- pingServer() {
808
- if (!this.socket || !this.isConnected()) {
809
- return;
810
- }
811
-
812
- try {
813
- this.socket.send(JSON.stringify({ op: 'ping', data: { payload: 'pong' } }));
814
- } catch (_) {
815
- // Nothing to do
816
- }
817
- }
818
-
819
- isConnected() {
820
- return this.socket && this.socket.readyState === this.socket.OPEN;
821
- }
822
-
823
- reconnect(reason ) {
824
- logger.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
825
- if (!this.socket) {
826
- return;
827
- }
828
- this.socket.reconnect(reason);
829
- }
830
-
831
- _handleInitMessage(message , sock ) {
832
- switch (message.op) {
833
- case 'init':
834
- this.events.forEach(event => {
835
- const op = {
836
- op: 'subscribe',
837
- data: { event_name: event },
838
- };
839
-
840
- sock.send(JSON.stringify(op));
293
+ reconnect(reason) {
294
+ logger.info('Wazo WS reconnect', {
295
+ reason,
296
+ socket: !!this.socket,
297
+ host: this.host,
298
+ token: this.token,
841
299
  });
842
-
843
- sock.send(JSON.stringify({ op: 'start' }));
844
- break;
845
- case 'subscribe':
846
- break;
847
- case 'start':
848
- this.initialized = true;
849
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
850
- break;
851
- default:
852
- this.eventEmitter.emit('message', message);
853
- }
854
- }
855
-
856
- _handleMessage(message ) {
857
- if (message.op === 'pong') {
858
- this.eventEmitter.emit('pong', message.data);
859
- if (this.heartbeatCb) {
860
- this.heartbeatCb();
861
- }
862
- return;
863
- }
864
-
865
- if (this.version === 1) {
866
- this.eventEmitter.emit(message.name, message);
867
- return;
300
+ if (!this.socket) {
301
+ return;
302
+ }
303
+ // @HEADS UP: first arg is `code`, second is `reason`; inputing arbitrary value for `code`
304
+ this.socket.reconnect(0, reason);
305
+ }
306
+ _handleInitMessage(message, sock) {
307
+ var _a;
308
+ switch (message.op) {
309
+ case 'init':
310
+ (_a = this.events) === null || _a === void 0 ? void 0 : _a.forEach(event => {
311
+ const op = {
312
+ op: 'subscribe',
313
+ data: {
314
+ event_name: event,
315
+ },
316
+ };
317
+ sock.send(JSON.stringify(op));
318
+ });
319
+ sock.send(JSON.stringify({
320
+ op: 'start',
321
+ }));
322
+ break;
323
+ case 'subscribe':
324
+ break;
325
+ case 'start':
326
+ this.initialized = true;
327
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.INITIALIZED);
328
+ break;
329
+ default:
330
+ this.eventEmitter.emit('message', message);
331
+ }
868
332
  }
869
-
870
- if (this.version >= 2 && message.op === 'event') {
871
- this.eventEmitter.emit(message.data.name, message.data);
333
+ _handleMessage(message) {
334
+ if (message.op === 'pong') {
335
+ this.eventEmitter.emit('pong', message.data);
336
+ if (this.heartbeatCb) {
337
+ this.heartbeatCb();
338
+ }
339
+ return;
340
+ }
341
+ if (this.version === 1) {
342
+ this.eventEmitter.emit(message.name, message);
343
+ return;
344
+ }
345
+ if (Number(this.version) >= 2 && message.op === 'event') {
346
+ this.eventEmitter.emit(message.data.name, message.data);
347
+ }
872
348
  }
873
- }
874
-
875
- _getUrl() {
876
- if (!this.host || !this.token) {
877
- this.close();
349
+ _getUrl() {
350
+ if (!this.host || !this.token) {
351
+ this.close();
352
+ }
353
+ const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
354
+ logger.info('Wazo WS url computed to reconnect', {
355
+ url,
356
+ });
357
+ return url;
878
358
  }
879
- const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
880
- logger.info('Wazo WS url computed to reconnect', { url });
881
-
882
- return url;
883
- }
884
-
885
- _onHeartbeat(message ) {
886
- if (message.payload === 'pong') {
887
- this.heartbeat.onHeartbeat();
888
- logger.log('on heartbeat received from Wazo WS');
359
+ _onHeartbeat(message) {
360
+ if (message.payload === 'pong') {
361
+ this.heartbeat.onHeartbeat();
362
+ logger.log('on heartbeat received from Wazo WS');
363
+ }
889
364
  }
890
- }
891
-
892
- async _onHeartbeatTimeout() {
893
- logger.log('heartbeat timed out', { host: this.host, token: this.token });
894
-
895
- this.close();
896
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
897
-
898
- if (this.onHeartBeatTimeout) {
899
- this.onHeartBeatTimeout();
365
+ _onHeartbeatTimeout() {
366
+ return __awaiter(this, void 0, void 0, function* () {
367
+ logger.log('heartbeat timed out', {
368
+ host: this.host,
369
+ token: this.token,
370
+ });
371
+ this.close();
372
+ this.eventEmitter.emit(exports.SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
373
+ if (this.onHeartBeatTimeout) {
374
+ this.onHeartBeatTimeout();
375
+ }
376
+ });
900
377
  }
901
- }
902
- }
903
-
904
- // Can't use static
905
- WebSocketClient.eventLists = [
906
- AUTH_SESSION_EXPIRE_SOON,
907
- FAVORITE_ADDED,
908
- FAVORITE_DELETED,
909
- USER_STATUS_UPDATE,
910
- CHAT_MESSAGE_SENT,
911
- CHAT_MESSAGE_RECEIVED,
912
- ENDPOINT_STATUS_UPDATE,
913
- USERS_FORWARDS_BUSY_UPDATED,
914
- USERS_FORWARDS_NOANSWER_UPDATED,
915
- USERS_FORWARDS_UNCONDITIONAL_UPDATED,
916
- USERS_SERVICES_DND_UPDATED,
917
- USER_VOICEMAIL_MESSAGE_CREATED,
918
- USER_VOICEMAIL_MESSAGE_UPDATED,
919
- USER_VOICEMAIL_MESSAGE_DELETED,
920
- CALL_LOG_USER_CREATED,
921
- CALL_ANSWERED,
922
- CALL_CREATED,
923
- CALL_DTMF_CREATED,
924
- CALL_ENDED,
925
- CALL_UPDATED,
926
- CALL_HELD,
927
- CALL_RESUMED,
928
- AUTH_USER_EXTERNAL_AUTH_ADDED,
929
- AUTH_USER_EXTERNAL_AUTH_DELETED,
930
- CHATD_PRESENCE_UPDATED,
931
- CHATD_USER_ROOM_MESSAGE_CREATED,
932
- CHATD_USER_ROOM_CREATED,
933
- CONFERENCE_USER_PARTICIPANT_JOINED,
934
- CONFERENCE_USER_PARTICIPANT_LEFT,
935
- MEETING_USER_PARTICIPANT_JOINED,
936
- MEETING_USER_PARTICIPANT_LEFT,
937
- CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
938
- CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
939
- SWITCHBOARD_QUEUED_CALLS_UPDATED,
940
- SWITCHBOARD_QUEUED_CALL_ANSWERED,
941
- SWITCHBOARD_HELD_CALLS_UPDATED,
942
- SWITCHBOARD_HELD_CALL_ANSWERED,
943
- FAX_OUTBOUND_USER_CREATED,
944
- FAX_OUTBOUND_USER_SUCCEEDED,
945
- FAX_OUTBOUND_USER_FAILED,
946
- APPLICATION_CALL_DTMF_RECEIVED,
947
- APPLICATION_CALL_ENTERED,
948
- APPLICATION_CALL_INITIATED,
949
- APPLICATION_CALL_DELETED,
950
- APPLICATION_CALL_UPDATED,
951
- APPLICATION_CALL_ANSWERED,
952
- APPLICATION_PROGRESS_STARTED,
953
- APPLICATION_PROGRESS_STOPPED,
954
- APPLICATION_DESTINATION_NODE_CREATED,
955
- APPLICATION_NODE_CREATED,
956
- APPLICATION_NODE_DELETED,
957
- APPLICATION_NODE_UPDATED,
958
- APPLICATION_PLAYBACK_CREATED,
959
- APPLICATION_PLAYBACK_DELETED,
960
- APPLICATION_SNOOP_CREATED,
961
- APPLICATION_SNOOP_DELETED,
962
- APPLICATION_SNOOP_UPDATED,
963
- APPLICATION_USER_OUTGOING_CALL_CREATED,
964
- TRUNK_STATUS_UPDATED,
965
- LINE_STATUS_UPDATED,
966
- AGENT_STATUS_UPDATE,
967
- AGENT_PAUSED,
968
- AGENT_UNPAUSED,
969
- CONFERENCE_ADHOC_PARTICIPANT_LEFT,
970
- CONFERENCE_ADHOC_DELETED,
971
- MEETING_USER_PROGRESS,
972
- MEETING_USER_GUEST_AUTHORIZATION_CREATED,
973
- ];
974
-
975
- exports.AGENT_PAUSED = AGENT_PAUSED;
976
- exports.AGENT_STATUS_UPDATE = AGENT_STATUS_UPDATE;
977
- exports.AGENT_UNPAUSED = AGENT_UNPAUSED;
978
- exports.APPLICATION_CALL_ANSWERED = APPLICATION_CALL_ANSWERED;
979
- exports.APPLICATION_CALL_DELETED = APPLICATION_CALL_DELETED;
980
- exports.APPLICATION_CALL_DTMF_RECEIVED = APPLICATION_CALL_DTMF_RECEIVED;
981
- exports.APPLICATION_CALL_ENTERED = APPLICATION_CALL_ENTERED;
982
- exports.APPLICATION_CALL_INITIATED = APPLICATION_CALL_INITIATED;
983
- exports.APPLICATION_CALL_UPDATED = APPLICATION_CALL_UPDATED;
984
- exports.APPLICATION_DESTINATION_NODE_CREATED = APPLICATION_DESTINATION_NODE_CREATED;
985
- exports.APPLICATION_NODE_CREATED = APPLICATION_NODE_CREATED;
986
- exports.APPLICATION_NODE_DELETED = APPLICATION_NODE_DELETED;
987
- exports.APPLICATION_NODE_UPDATED = APPLICATION_NODE_UPDATED;
988
- exports.APPLICATION_PLAYBACK_CREATED = APPLICATION_PLAYBACK_CREATED;
989
- exports.APPLICATION_PLAYBACK_DELETED = APPLICATION_PLAYBACK_DELETED;
990
- exports.APPLICATION_PROGRESS_STARTED = APPLICATION_PROGRESS_STARTED;
991
- exports.APPLICATION_PROGRESS_STOPPED = APPLICATION_PROGRESS_STOPPED;
992
- exports.APPLICATION_SNOOP_CREATED = APPLICATION_SNOOP_CREATED;
993
- exports.APPLICATION_SNOOP_DELETED = APPLICATION_SNOOP_DELETED;
994
- exports.APPLICATION_SNOOP_UPDATED = APPLICATION_SNOOP_UPDATED;
995
- exports.APPLICATION_USER_OUTGOING_CALL_CREATED = APPLICATION_USER_OUTGOING_CALL_CREATED;
996
- exports.AUTH_SESSION_EXPIRE_SOON = AUTH_SESSION_EXPIRE_SOON;
997
- exports.AUTH_USER_EXTERNAL_AUTH_ADDED = AUTH_USER_EXTERNAL_AUTH_ADDED;
998
- exports.AUTH_USER_EXTERNAL_AUTH_DELETED = AUTH_USER_EXTERNAL_AUTH_DELETED;
999
- exports.CALL_ANSWERED = CALL_ANSWERED;
1000
- exports.CALL_CREATED = CALL_CREATED;
1001
- exports.CALL_DTMF_CREATED = CALL_DTMF_CREATED;
1002
- exports.CALL_ENDED = CALL_ENDED;
1003
- exports.CALL_HELD = CALL_HELD;
1004
- exports.CALL_LOG_USER_CREATED = CALL_LOG_USER_CREATED;
1005
- exports.CALL_RESUMED = CALL_RESUMED;
1006
- exports.CALL_UPDATED = CALL_UPDATED;
1007
- exports.CHATD_PRESENCE_UPDATED = CHATD_PRESENCE_UPDATED;
1008
- exports.CHATD_USER_ROOM_CREATED = CHATD_USER_ROOM_CREATED;
1009
- exports.CHATD_USER_ROOM_MESSAGE_CREATED = CHATD_USER_ROOM_MESSAGE_CREATED;
1010
- exports.CHAT_MESSAGE_RECEIVED = CHAT_MESSAGE_RECEIVED;
1011
- exports.CHAT_MESSAGE_SENT = CHAT_MESSAGE_SENT;
1012
- exports.CONFERENCE_ADHOC_DELETED = CONFERENCE_ADHOC_DELETED;
1013
- exports.CONFERENCE_ADHOC_PARTICIPANT_LEFT = CONFERENCE_ADHOC_PARTICIPANT_LEFT;
1014
- exports.CONFERENCE_USER_PARTICIPANT_JOINED = CONFERENCE_USER_PARTICIPANT_JOINED;
1015
- exports.CONFERENCE_USER_PARTICIPANT_LEFT = CONFERENCE_USER_PARTICIPANT_LEFT;
1016
- exports.CONFERENCE_USER_PARTICIPANT_TALK_STARTED = CONFERENCE_USER_PARTICIPANT_TALK_STARTED;
1017
- exports.CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = CONFERENCE_USER_PARTICIPANT_TALK_STOPPED;
1018
- exports.ENDPOINT_STATUS_UPDATE = ENDPOINT_STATUS_UPDATE;
1019
- exports.FAVORITE_ADDED = FAVORITE_ADDED;
1020
- exports.FAVORITE_DELETED = FAVORITE_DELETED;
1021
- exports.FAX_OUTBOUND_USER_CREATED = FAX_OUTBOUND_USER_CREATED;
1022
- exports.FAX_OUTBOUND_USER_FAILED = FAX_OUTBOUND_USER_FAILED;
1023
- exports.FAX_OUTBOUND_USER_SUCCEEDED = FAX_OUTBOUND_USER_SUCCEEDED;
1024
- exports.HEARTBEAT_ENGINE_VERSION = HEARTBEAT_ENGINE_VERSION;
1025
- exports.LINE_STATUS_UPDATED = LINE_STATUS_UPDATED;
1026
- exports.MEETING_USER_GUEST_AUTHORIZATION_CREATED = MEETING_USER_GUEST_AUTHORIZATION_CREATED;
1027
- exports.MEETING_USER_PARTICIPANT_JOINED = MEETING_USER_PARTICIPANT_JOINED;
1028
- exports.MEETING_USER_PARTICIPANT_LEFT = MEETING_USER_PARTICIPANT_LEFT;
1029
- exports.MEETING_USER_PROGRESS = MEETING_USER_PROGRESS;
1030
- exports.SOCKET_EVENTS = SOCKET_EVENTS;
1031
- exports.SWITCHBOARD_HELD_CALLS_UPDATED = SWITCHBOARD_HELD_CALLS_UPDATED;
1032
- exports.SWITCHBOARD_HELD_CALL_ANSWERED = SWITCHBOARD_HELD_CALL_ANSWERED;
1033
- exports.SWITCHBOARD_QUEUED_CALLS_UPDATED = SWITCHBOARD_QUEUED_CALLS_UPDATED;
1034
- exports.SWITCHBOARD_QUEUED_CALL_ANSWERED = SWITCHBOARD_QUEUED_CALL_ANSWERED;
1035
- exports.TRUNK_STATUS_UPDATED = TRUNK_STATUS_UPDATED;
1036
- exports.USERS_FORWARDS_BUSY_UPDATED = USERS_FORWARDS_BUSY_UPDATED;
1037
- exports.USERS_FORWARDS_NOANSWER_UPDATED = USERS_FORWARDS_NOANSWER_UPDATED;
1038
- exports.USERS_FORWARDS_UNCONDITIONAL_UPDATED = USERS_FORWARDS_UNCONDITIONAL_UPDATED;
1039
- exports.USERS_SERVICES_DND_UPDATED = USERS_SERVICES_DND_UPDATED;
1040
- exports.USER_STATUS_UPDATE = USER_STATUS_UPDATE;
1041
- exports.USER_VOICEMAIL_MESSAGE_CREATED = USER_VOICEMAIL_MESSAGE_CREATED;
1042
- exports.USER_VOICEMAIL_MESSAGE_DELETED = USER_VOICEMAIL_MESSAGE_DELETED;
1043
- exports.USER_VOICEMAIL_MESSAGE_UPDATED = USER_VOICEMAIL_MESSAGE_UPDATED;
378
+ } // Can't use static
379
+ WebSocketClient.eventLists = [exports.AUTH_SESSION_EXPIRE_SOON, exports.FAVORITE_ADDED, exports.FAVORITE_DELETED, exports.USER_STATUS_UPDATE, exports.CHAT_MESSAGE_SENT, exports.CHAT_MESSAGE_RECEIVED, exports.ENDPOINT_STATUS_UPDATE, exports.USERS_FORWARDS_BUSY_UPDATED, exports.USERS_FORWARDS_NOANSWER_UPDATED, exports.USERS_FORWARDS_UNCONDITIONAL_UPDATED, exports.USERS_SERVICES_DND_UPDATED, exports.USER_VOICEMAIL_MESSAGE_CREATED, exports.USER_VOICEMAIL_MESSAGE_UPDATED, exports.USER_VOICEMAIL_MESSAGE_DELETED, exports.CALL_LOG_USER_CREATED, exports.CALL_ANSWERED, exports.CALL_CREATED, exports.CALL_DTMF_CREATED, exports.CALL_ENDED, exports.CALL_UPDATED, exports.CALL_HELD, exports.CALL_RESUMED, exports.AUTH_USER_EXTERNAL_AUTH_ADDED, exports.AUTH_USER_EXTERNAL_AUTH_DELETED, exports.CHATD_PRESENCE_UPDATED, exports.CHATD_USER_ROOM_MESSAGE_CREATED, exports.CHATD_USER_ROOM_CREATED, exports.CONFERENCE_USER_PARTICIPANT_JOINED, exports.CONFERENCE_USER_PARTICIPANT_LEFT, exports.MEETING_USER_PARTICIPANT_JOINED, exports.MEETING_USER_PARTICIPANT_LEFT, exports.CONFERENCE_USER_PARTICIPANT_TALK_STARTED, exports.CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, exports.SWITCHBOARD_QUEUED_CALLS_UPDATED, exports.SWITCHBOARD_QUEUED_CALL_ANSWERED, exports.SWITCHBOARD_HELD_CALLS_UPDATED, exports.SWITCHBOARD_HELD_CALL_ANSWERED, exports.FAX_OUTBOUND_USER_CREATED, exports.FAX_OUTBOUND_USER_SUCCEEDED, exports.FAX_OUTBOUND_USER_FAILED, exports.APPLICATION_CALL_DTMF_RECEIVED, exports.APPLICATION_CALL_ENTERED, exports.APPLICATION_CALL_INITIATED, exports.APPLICATION_CALL_DELETED, exports.APPLICATION_CALL_UPDATED, exports.APPLICATION_CALL_ANSWERED, exports.APPLICATION_PROGRESS_STARTED, exports.APPLICATION_PROGRESS_STOPPED, exports.APPLICATION_DESTINATION_NODE_CREATED, exports.APPLICATION_NODE_CREATED, exports.APPLICATION_NODE_DELETED, exports.APPLICATION_NODE_UPDATED, exports.APPLICATION_PLAYBACK_CREATED, exports.APPLICATION_PLAYBACK_DELETED, exports.APPLICATION_SNOOP_CREATED, exports.APPLICATION_SNOOP_DELETED, exports.APPLICATION_SNOOP_UPDATED, exports.APPLICATION_USER_OUTGOING_CALL_CREATED, exports.TRUNK_STATUS_UPDATED, exports.LINE_STATUS_UPDATED, exports.AGENT_STATUS_UPDATE, exports.AGENT_PAUSED, exports.AGENT_UNPAUSED, exports.CONFERENCE_ADHOC_PARTICIPANT_LEFT, exports.CONFERENCE_ADHOC_DELETED, exports.MEETING_USER_PROGRESS, exports.MEETING_USER_GUEST_AUTHORIZATION_CREATED];
1044
380
  exports.default = WebSocketClient;