@wazo/sdk 0.38.22 → 0.39.0-beta.1

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 (884) hide show
  1. package/README.md +0 -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 +35 -1312
  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 -4881
  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 +430 -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 +1446 -2670
  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 +211 -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 +211 -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 +1973 -7676
  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 +49 -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 +138 -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 +404 -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 +1446 -2715
  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 +271 -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 +211 -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 +1999 -7696
  728. package/lib/websocket-client.js +357 -1021
  729. package/package.json +40 -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 +83 -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} +99 -65
  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} +373 -261
  762. package/src/domain/{Country.js → Country.ts} +0 -0
  763. package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
  764. package/src/domain/Device/{Device.js → Device.ts} +0 -11
  765. package/src/domain/DirectorySource.ts +13 -0
  766. package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
  767. package/src/domain/{Features.js → Features.ts} +43 -17
  768. package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
  769. package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
  770. package/src/domain/{Line.js → Line.ts} +39 -26
  771. package/src/domain/{Meeting.js → Meeting.ts} +36 -29
  772. package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
  773. package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
  774. package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
  775. package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
  776. package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
  777. package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +434 -413
  778. package/src/domain/{Profile.js → Profile.ts} +117 -100
  779. package/src/domain/{Recording.js → Recording.ts} +25 -16
  780. package/src/domain/{Relocation.js → Relocation.ts} +15 -14
  781. package/src/domain/{Room.js → Room.ts} +58 -27
  782. package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
  783. package/src/domain/ServerError.ts +12 -0
  784. package/src/domain/{Session.js → Session.ts} +89 -67
  785. package/src/domain/{SipLine.js → SipLine.ts} +52 -45
  786. package/src/domain/{Subscription.js → Subscription.ts} +22 -13
  787. package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
  788. package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
  789. package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
  790. package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
  791. package/src/domain/__tests__/CallLog.test.ts +65 -0
  792. package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
  793. package/src/domain/__tests__/Contact.test.ts +238 -0
  794. package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
  795. package/src/domain/__tests__/Line.test.ts +53 -0
  796. package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
  797. package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
  798. package/src/domain/__tests__/Profile.test.ts +139 -0
  799. package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
  800. package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
  801. package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
  802. package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
  803. package/src/domain/types.ts +227 -0
  804. package/src/global.d.ts +5 -0
  805. package/src/{index.js → index.ts} +4 -28
  806. package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
  807. package/{config.js → src/pubkey.ts} +3 -3
  808. package/src/service/{CallApi.js → CallApi.ts} +14 -18
  809. package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
  810. package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
  811. package/src/service/getApiClient.ts +94 -0
  812. package/src/simple/{Auth.js → Auth.ts} +127 -100
  813. package/src/simple/{Configuration.js → Configuration.ts} +2 -3
  814. package/src/simple/{Directory.js → Directory.ts} +2 -3
  815. package/src/simple/Phone.ts +623 -0
  816. package/src/simple/Websocket.ts +119 -0
  817. package/src/simple/{index.js → index.ts} +51 -21
  818. package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
  819. package/src/simple/room/{Participant.js → Participant.ts} +108 -46
  820. package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
  821. package/src/simple/room/{Room.js → Room.ts} +266 -183
  822. package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
  823. package/src/simple/room/{Stream.js → Stream.ts} +8 -6
  824. package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
  825. package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
  826. package/src/simple/utils.ts +12 -0
  827. package/src/types/WebSocketMessage.ts +335 -0
  828. package/src/types/global.d.ts +26 -0
  829. package/src/utils/Emitter.ts +34 -0
  830. package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
  831. package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
  832. package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
  833. package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
  834. package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
  835. package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
  836. package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
  837. package/src/utils/__tests__/object.test.ts +77 -0
  838. package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
  839. package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
  840. package/src/utils/{api-requester.js → api-requester.ts} +104 -83
  841. package/src/utils/{array.js → array.ts} +2 -2
  842. package/src/utils/{compare-version.js → compare-version.ts} +3 -2
  843. package/src/utils/{isMobile.js → isMobile.ts} +1 -1
  844. package/src/utils/{new-from.js → new-from.ts} +3 -6
  845. package/src/utils/{object.js → object.ts} +3 -6
  846. package/src/utils/{once.js → once.ts} +5 -5
  847. package/src/utils/sdp.ts +119 -0
  848. package/src/utils/{string.js → string.ts} +2 -3
  849. package/src/utils/update-from.ts +11 -0
  850. package/src/utils/{webrtc.js → webrtc.ts} +21 -3
  851. package/src/{web-rtc-client.js → web-rtc-client.ts} +786 -457
  852. package/src/{websocket-client.js → websocket-client.ts} +146 -144
  853. package/esm/simple/Softphone.js +0 -394
  854. package/lib/simple/Softphone.js +0 -396
  855. package/src/api/agentd.js +0 -74
  856. package/src/api/amid.js +0 -13
  857. package/src/api/application.js +0 -137
  858. package/src/api/auth.js +0 -279
  859. package/src/api/call-logd.js +0 -20
  860. package/src/api/calld.js +0 -214
  861. package/src/api/chatd.js +0 -80
  862. package/src/api/confd.js +0 -127
  863. package/src/api/ctid-ng.js +0 -153
  864. package/src/api/dird.js +0 -159
  865. package/src/api/webhookd.js +0 -31
  866. package/src/domain/BadResponse.js +0 -42
  867. package/src/domain/DirectorySource.js +0 -16
  868. package/src/domain/ServerError.js +0 -18
  869. package/src/domain/__tests__/CallLog.test.js +0 -75
  870. package/src/domain/__tests__/Contact.test.js +0 -170
  871. package/src/domain/__tests__/Line.test.js +0 -73
  872. package/src/domain/__tests__/Profile.test.js +0 -104
  873. package/src/domain/types.js +0 -248
  874. package/src/lib/WazoSessionDescriptionHandler.js +0 -467
  875. package/src/service/getApiClient.js +0 -122
  876. package/src/simple/Phone.js +0 -425
  877. package/src/simple/Softphone.js +0 -392
  878. package/src/simple/Websocket.js +0 -86
  879. package/src/simple/utils.js +0 -17
  880. package/src/types/WebSocketMessage.js +0 -232
  881. package/src/utils/Emitter.js +0 -26
  882. package/src/utils/__tests__/object.test.js +0 -35
  883. package/src/utils/sdp.js +0 -140
  884. package/src/utils/update-from.js +0 -15
package/lib/api/confd.js CHANGED
@@ -1,1590 +1,85 @@
1
- 'use strict';
2
-
3
- var jsBase64 = require('js-base64');
4
- var moment = require('moment');
5
-
6
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
-
8
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
9
-
10
- /* */
11
-
12
- class BadResponse extends Error {
13
- static fromResponse(error , status ) {
14
- return new BadResponse(
15
- error.message || JSON.stringify(error),
16
- status,
17
- error.timestamp,
18
- error.error_id,
19
- error.details,
20
- error,
21
- );
22
- }
23
-
24
- static fromText(response , status ) {
25
- return new BadResponse(response, status);
26
- }
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
- constructor(
36
- message ,
37
- status ,
38
- timestamp = null,
39
- errorId = null,
40
- details = null,
41
- error = null,
42
- ) {
43
- super(message);
44
-
45
- this.timestamp = timestamp;
46
- this.status = status;
47
- this.errorId = errorId;
48
- this.details = details;
49
- this.error = error;
50
- }
51
- }
52
-
53
- /* */
54
-
55
- class ServerError extends BadResponse {
56
- static fromResponse(error , status ) {
57
- return new ServerError(
58
- error.message || JSON.stringify(error),
59
- status,
60
- error.timestamp,
61
- error.error_id,
62
- error.details,
63
- );
64
- }
65
-
66
- static fromText(response , status ) {
67
- return new ServerError(response, status);
68
- }
69
- }
70
-
71
- /* */
72
- /* global navigator */
73
- const isMobile = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
74
-
75
- /* global window */
76
-
77
- const TRACE = 'trace';
78
- const DEBUG = 'debug';
79
- const INFO = 'info';
80
- const LOG = 'log';
81
- const WARN = 'warn';
82
- const ERROR = 'error';
83
- const CONSOLE_METHODS = [INFO, LOG, WARN, ERROR];
84
- const LOG_LEVELS = [TRACE, DEBUG, INFO, LOG, WARN, ERROR];
85
- const CATEGORY_PREFIX = 'logger-category=';
86
-
87
- const MAX_REMOTE_RETRY = 100;
88
-
89
- const addLevelsTo = (instance , withMethods = false) => {
90
- instance.TRACE = TRACE;
91
- instance.DEBUG = DEBUG;
92
- instance.INFO = INFO;
93
- instance.LOG = LOG;
94
- instance.WARN = WARN;
95
- instance.ERROR = ERROR;
96
-
97
- if (withMethods) {
98
- instance.trace = (...args) => instance.apply(null, [TRACE, ...args]);
99
- instance.debug = (...args) => instance.apply(null, [DEBUG, ...args]);
100
- instance.info = (...args) => instance.apply(null, [INFO, ...args]);
101
- instance.log = (...args) => instance.apply(null, [LOG, ...args]);
102
- instance.warn = (...args) => instance.apply(null, [WARN, ...args]);
103
- instance.error = (...args) => instance.apply(null, [ERROR, ...args]);
104
- }
105
-
106
- return instance;
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
+ });
107
10
  };
108
-
109
- const safeStringify = (object ) => {
110
- const result = '{"message": "Not parsable JSON"}';
111
- try {
112
- return JSON.stringify(object);
113
- } catch (e) {
114
- // Nothing to do
115
- }
116
-
117
- return result;
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
118
13
  };
119
-
120
- class IssueReporter {
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
- constructor() {
138
- addLevelsTo(this);
139
-
140
- this.oldConsoleMethods = null;
141
- this.enabled = false;
142
- this.remoteClientConfiguration = null;
143
- this.buffer = [];
144
- this.bufferTimeout = null;
145
- this._boundProcessBuffer = this._processBuffer.bind(this);
146
- this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
147
- this._callback = null;
148
- }
149
-
150
- init() {
151
- this._catchConsole();
152
- }
153
-
154
- setCallback(cb ) {
155
- this._callback = cb;
156
- }
157
-
158
- configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
159
- this.remoteClientConfiguration = configuration;
160
- }
161
-
162
- enable() {
163
- if (!this.oldConsoleMethods) {
164
- this.init();
165
- }
166
-
167
- this.enabled = true;
168
- }
169
-
170
- disable() {
171
- this.enabled = false;
172
- }
173
-
174
- loggerFor(category ) {
175
- const logger = (level , ...args ) => {
176
- this.log.apply(this, [level, this._makeCategory(category), ...args]);
177
- };
178
-
179
- return addLevelsTo(logger, true);
180
- }
181
-
182
- removeSlashes(str ) {
183
- return str.replace(/"/g, "'").replace(/\\/g, '');
184
- }
185
-
186
- log(level , ...args ) {
187
- if (!this.enabled) {
188
- return;
189
- }
190
-
191
- // Handle category label
192
- let category = null;
193
- let skipSendToRemote = false;
194
- let extra = {};
195
- if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
196
- category = args[0].split('=')[1];
197
- // eslint-disable-next-line no-param-reassign
198
- args.splice(0, 1);
199
- }
200
-
201
- // Handle extra data as object for the last argument
202
- const lastArg = args[args.length - 1];
203
- if (lastArg && ((typeof lastArg === 'object' && Object.keys(lastArg).length) || lastArg instanceof Error)) {
204
- if (lastArg instanceof Error) {
205
- extra = {
206
- errorMessage: lastArg.message,
207
- errorStack: lastArg.stack,
208
- errorType: lastArg.constructor.name,
209
- skipSendToRemote: lastArg.skipSendToRemote,
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const api_requester_1 = __importDefault(require("../utils/api-requester"));
16
+ const Profile_1 = __importDefault(require("../domain/Profile"));
17
+ const SipLine_1 = __importDefault(require("../domain/SipLine"));
18
+ const ExternalApp_1 = __importDefault(require("../domain/ExternalApp"));
19
+ const Meeting_1 = __importDefault(require("../domain/Meeting"));
20
+ const MeetingAuthorization_1 = __importDefault(require("../domain/MeetingAuthorization"));
21
+ const object_1 = require("../utils/object");
22
+ exports.default = ((client, baseUrl) => ({
23
+ listUsers: () => client.get(`${baseUrl}/users`, null),
24
+ getUser: (userUuid) => client.get(`${baseUrl}/users/${userUuid}`, null).then(Profile_1.default.parse),
25
+ updateUser: (userUuid, profile) => {
26
+ const body = {
27
+ firstname: profile.firstName,
28
+ lastname: profile.lastName,
29
+ email: profile.email,
30
+ mobile_phone_number: profile.mobileNumber,
210
31
  };
211
- } else {
212
- extra = lastArg;
213
- }
214
- // eslint-disable-next-line no-param-reassign
215
- args.splice(1, 1);
216
- }
217
-
218
- if (extra.skipSendToRemote) {
219
- skipSendToRemote = true;
220
- delete extra.skipSendToRemote;
221
- }
222
-
223
- const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
224
- const message = args.join(', ');
225
- let consoleMessage = message;
226
-
227
- if (Object.keys(extra).length) {
228
- const parsedExtra = safeStringify(extra);
229
- consoleMessage = `${consoleMessage} (${parsedExtra})`;
230
- }
231
-
232
- if (category) {
233
- consoleMessage = `[${category}] ${consoleMessage}`;
234
- }
235
-
236
- // Log the message in the console anyway (but don't console.error on mobile)
237
- const consoleLevel = isMobile() && level === 'error' ? WARN : level;
238
-
239
- // eslint-disable-next-line
240
- const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
241
- oldMethod.apply(oldMethod, [date, consoleMessage]);
242
-
243
- if (this._callback) {
244
- this._callback(level, consoleMessage);
245
- }
246
-
247
- if (!skipSendToRemote) {
248
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
249
- }
250
- }
251
-
252
- logRequest(url , options , response , start ) {
253
- if (!this.enabled) {
254
- return;
255
- }
256
- const { status } = response;
257
- const duration = new Date() - start;
258
-
259
- let level = TRACE;
260
- if (status >= 400 && status < 500) {
261
- level = WARN;
262
- } else if (status >= 500) {
263
- level = ERROR;
264
- }
265
-
266
- this.log(level, this._makeCategory('http'), url, {
267
- status,
268
- body: this.removeSlashes(JSON.stringify(options.body)),
269
- method: options.method,
270
- headers: options.headers,
271
- duration,
272
- });
273
- }
274
-
275
- // Logs aren't stored anymore
276
- getLogs() {
277
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
278
- return [];
279
- }
280
-
281
- getParsedLogs() {
282
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
283
- return [];
284
- }
285
-
286
- getReport() {
287
- return this.getParsedLogs().join('\r\n');
288
- }
289
-
290
- _catchConsole() {
291
- this.oldConsoleMethods = {};
292
- CONSOLE_METHODS.forEach((methodName ) => {
293
- // eslint-disable-next-line
294
- this.oldConsoleMethods[methodName] = console[methodName];
295
- window.console[methodName] = (...args) => {
296
- // Store message
32
+ return client.put(`${baseUrl}/users/${userUuid}`, body, null, api_requester_1.default.successResponseParser);
33
+ },
34
+ updateForwardOption: (userUuid, key, destination, enabled) => {
35
+ const url = `${baseUrl}/users/${userUuid}/forwards/${key}`;
36
+ return client.put(url, {
37
+ destination,
38
+ enabled,
39
+ }, null, api_requester_1.default.successResponseParser);
40
+ },
41
+ updateDoNotDisturb: (userUuid, enabled) => client.put(`${baseUrl}/users/${userUuid}/services/dnd`, {
42
+ enabled,
43
+ }, null, api_requester_1.default.successResponseParser),
44
+ getUserLineSip: (userUuid, lineId) => client.get(`${baseUrl}/users/${userUuid}/lines/${lineId}/associated/endpoints/sip?view=merged`).then(SipLine_1.default.parse),
45
+ getUserLinesSip(userUuid, lineIds) {
46
+ // We have to catch all exception, unless Promise.all will returns an empty array for 2 lines with a custom one:
47
+ // The custom line will throw a 404 and break the Promise.all.
48
+ return Promise.all(lineIds.map(lineId => this.getUserLineSip(userUuid, lineId).catch(() => null)));
49
+ },
50
+ getUserLineSipFromToken(userUuid) {
51
+ return this.getUser(userUuid).then(user => {
52
+ if (!user.lines.length) {
53
+ console.warn(`No sip line for user: ${userUuid}`);
54
+ return null;
55
+ }
56
+ const line = user.lines[0];
57
+ return this.getUserLineSip(userUuid, line.uuid || line.id);
58
+ });
59
+ },
60
+ listApplications: () => client.get(`${baseUrl}/applications`, null),
61
+ getInfos: () => client.get(`${baseUrl}/infos`, null),
62
+ getExternalApps: (userUuid) => client.get(`${baseUrl}/users/${userUuid}/external/apps`).then(ExternalApp_1.default.parseMany),
63
+ getExternalApp: (userUuid, name) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const url = `${baseUrl}/users/${userUuid}/external/apps/${name}?view=fallback`;
297
65
  try {
298
- this.log(methodName, args.join(' '));
299
- // Use old console method to log it normally
300
- this.oldConsoleMethods[methodName].apply(null, args);
301
- } catch (e) {
302
- // Avoid circular structure issues
66
+ return yield client.get(url).then(ExternalApp_1.default.parse);
303
67
  }
304
- };
305
- });
306
- }
307
-
308
- _sendToRemoteLogger(level , payload = {}) {
309
- if (!this.remoteClientConfiguration) {
310
- return;
311
- }
312
-
313
- const { level: minLevel, bufferSize } = this.remoteClientConfiguration;
314
- if (!minLevel || this._isLevelAbove(minLevel, level)) {
315
- return;
316
- }
317
-
318
- payload.level = level;
319
-
320
- if (bufferSize > 0) {
321
- return this._addToBuffer(payload);
322
- }
323
-
324
- this._sendDebugToGrafana(payload);
325
- }
326
-
327
- _parseLoggerBody(payload ) {
328
- const { level } = payload;
329
- const { maxMessageSize, extra } = this.remoteClientConfiguration || {};
330
-
331
- delete payload.level;
332
-
333
- if (maxMessageSize && typeof payload.message === 'string' && payload.message.length > maxMessageSize) {
334
- payload.message = `${payload.message.substr(0, maxMessageSize)}...`;
335
- }
336
-
337
- return safeStringify({
338
- level,
339
- ...payload,
340
- ...extra,
341
- });
342
- }
343
-
344
- _addToBuffer(payload ) {
345
- // Reset buffer timer
346
- if (this.bufferTimeout) {
347
- clearTimeout(this.bufferTimeout);
348
- this.bufferTimeout = null;
349
- }
350
-
351
- this.buffer.push(payload);
352
-
353
- // $FlowFixMe
354
- const { bufferSize, bufferTimeout } = this.remoteClientConfiguration;
355
-
356
- if (this.buffer.length > bufferSize) {
357
- return this._processBuffer();
358
- }
359
-
360
- if (bufferTimeout > 0) {
361
- this.bufferTimeout = setTimeout(this._boundProcessBuffer, bufferTimeout);
362
- }
363
- }
364
-
365
- _processBuffer() {
366
- this._sendDebugToGrafana(this.buffer);
367
-
368
- this.buffer = [];
369
- if (this.bufferTimeout) {
370
- clearTimeout(this.bufferTimeout);
371
- this.bufferTimeout = null;
372
- }
373
- }
374
-
375
- _sendDebugToGrafana(payload , retry = 0) {
376
- if (!this.remoteClientConfiguration || retry >= MAX_REMOTE_RETRY) {
377
- return;
378
- }
379
-
380
- const { tag, host, port } = this.remoteClientConfiguration;
381
- const isArray = Array.isArray(payload);
382
- const isSecure = +port === 443;
383
- const url = `http${isSecure ? 's' : ''}://${host}${isSecure ? '' : `:${port}`}/${tag}`;
384
- const body = isArray ? `[${payload.map(this._boundParseLoggerBody).join(',')}]` : this._parseLoggerBody(payload);
385
-
386
- realFetch()(url, {
387
- method: 'POST',
388
- headers: {
389
- Accept: 'application/json',
390
- 'Content-Type': 'application/json',
391
- },
392
- // $FlowFixMe
393
- body,
394
- }).catch((e ) => {
395
- // $FlowFixMe
396
- e.skipSendToRemote = true;
397
- this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
398
-
399
- setTimeout(() => {
400
- if (isArray) {
401
- payload = payload.map(message => this._writeRetryCount(message, retry + 1));
402
- } else if (payload && typeof payload === 'object') {
403
- payload = this._writeRetryCount(payload, retry + 1);
68
+ catch (e) {
69
+ return null;
404
70
  }
405
-
406
- this._sendDebugToGrafana(payload, retry + 1);
407
- }, 5000 + retry * 1000);
408
- });
409
- }
410
-
411
- _writeRetryCount(message , count ) {
412
- if (message && typeof message === 'object') {
413
- // $FlowFixMe
414
- message._retry = count;
415
- }
416
-
417
- return message;
418
- }
419
-
420
- _isLevelAbove(level1 , level2 ) {
421
- const index1 = LOG_LEVELS.indexOf(level1);
422
- const index2 = LOG_LEVELS.indexOf(level2);
423
- if (index1 === -1 || index2 === -1) {
424
- return false;
425
- }
426
-
427
- return index1 > index2;
428
- }
429
-
430
- _makeCategory(category ) {
431
- return `${CATEGORY_PREFIX}${category}`;
432
- }
433
- }
434
-
435
- var IssueReporter$1 = new IssueReporter();
436
-
437
- /* */
438
-
439
-
440
-
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
- const methods = ['head', 'get', 'post', 'put', 'delete'];
449
-
450
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
451
-
452
- // Use a function here to be able to mock it in tests
453
- const realFetch = () => {
454
- if (typeof document !== 'undefined' && window.fetch) {
455
- // Browser
456
- return window.fetch;
457
- }
458
-
459
- if (isMobile()) {
460
- // React native
461
- return fetch;
462
- }
463
-
464
- // nodejs
465
- // this package is disable for react-native in package.json because it requires nodejs modules
466
- // Used to trick the optimizer to avoid requiring `node-fetch/lib/index` directly
467
- // It causes to require it on browsers when delivered by a nodejs engine (cf: vitejs).
468
- try {
469
- // $FlowFixMe
470
- return require(Math.random() >= 0 ? 'node-fetch/lib/index' : '');
471
- } catch (e) {
472
- return fetch;
473
- }
474
- };
475
-
476
- class ApiRequester {
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
- // eslint-disable-next-line
494
- static successResponseParser(response , isJson ) {
495
- return response.status === 204 || response.status === 201 || response.status === 200;
496
- }
497
-
498
- static defaultParser(response ) {
499
- return response.json().then((data ) => data);
500
- }
501
-
502
- static getQueryString(obj ) {
503
- return Object.keys(obj)
504
- .filter(key => obj[key])
505
- .map(key => `${key}=${encodeURIComponent(obj[key])}`)
506
- .join('&');
507
- }
508
-
509
- static base64Encode(str ) {
510
- return typeof btoa !== 'undefined' ? btoa(str) : jsBase64.Base64.encode(str);
511
- }
512
-
513
- // @see https://github.com/facebook/flow/issues/183#issuecomment-358607052
514
- constructor({ server, refreshTokenCallback, clientId, agent = null, token = null, fetchOptions } ) {
515
- this.server = server;
516
- this.agent = agent;
517
- this.clientId = clientId;
518
- this.refreshTokenCallback = refreshTokenCallback;
519
- this.refreshTokenPromise = null;
520
- this.fetchOptions = fetchOptions || {};
521
- if (token) {
522
- this.token = token;
523
- }
524
-
525
- this.shouldLogErrors = true;
526
-
527
- methods.forEach(method => {
528
- // $FlowFixMe
529
- ApiRequester.prototype[method] = function sugar(...args) {
530
- // Add method in arguments passed to `call`
531
- args.splice(1, 0, method);
532
-
533
- return this.call.call(this, ...args);
534
- };
535
- });
536
- }
537
-
538
- setTenant(tenant ) {
539
- this.tenant = tenant;
540
- }
541
-
542
- setToken(token ) {
543
- this.token = token;
544
- }
545
-
546
- setFetchOptions(options ) {
547
- this.fetchOptions = options;
548
- }
549
-
550
- disableErrorLogging() {
551
- this.shouldLogErrors = false;
552
- }
553
-
554
- enableErrorLogging() {
555
- this.shouldLogErrors = true;
556
- }
557
-
558
- async call(
559
- path ,
560
- method = 'get',
561
- body = null,
562
- headers = null,
563
- parse = ApiRequester.defaultParser,
564
- firstCall = true,
565
- ) {
566
- const url = this.computeUrl(method, path, body);
567
- const newHeaders = this.getHeaders(headers);
568
- let newBody = method === 'get' ? null : body;
569
- if (newBody && newHeaders['Content-Type'] === 'application/json') {
570
- newBody = JSON.stringify(newBody);
571
- }
572
- const isHead = method === 'head';
573
- const hasEmptyResponse = method === 'delete' || isHead;
574
- const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
575
-
576
- const fetchOptions = { ...this.fetchOptions || {} };
577
- const extraHeaders = fetchOptions.headers || {};
578
- delete fetchOptions.headers;
579
-
580
- const options = {
581
- method,
582
- body: newBody,
583
- headers: { ...this.getHeaders(headers), ...extraHeaders },
584
- agent: this.agent,
585
- ...fetchOptions,
586
- };
587
-
588
- if (this.refreshTokenPromise) {
589
- logger.info('A token is already refreshing, waiting ...', { url });
590
- await this.refreshTokenPromise;
591
- }
592
-
593
- const start = new Date();
594
-
595
- return realFetch()(url, options).then(response => {
596
- const contentType = response.headers.get('content-type') || '';
597
- const isJson = contentType.indexOf('application/json') !== -1;
598
-
599
- IssueReporter$1.logRequest(url, options, response, start);
600
-
601
- // Throw an error only if status >= 400
602
- if ((isHead && response.status >= 500) || (!isHead && response.status >= 400)) {
603
- const promise = isJson ? response.json() : response.text();
604
- const exceptionClass = response.status >= 500 ? ServerError : BadResponse;
605
-
606
- return promise.then(async (err ) => {
607
- // Check if the token is still valid
608
- if (firstCall && this._checkTokenExpired(response, err)) {
609
- logger.warn('token expired', { error: err.reason });
610
- // Replay the call after refreshing the token
611
- return this._replayWithNewToken(err, path, method, body, headers, parse);
612
- }
613
-
614
- const error = typeof err === 'string'
615
- ? exceptionClass.fromText(err, response.status)
616
- : exceptionClass.fromResponse(err, response.status);
617
-
618
- if (this.shouldLogErrors) {
619
- logger.error('API error', error);
620
- }
621
-
622
- throw error;
623
- });
624
- }
625
-
626
- return newParse(response, isJson);
627
- }).catch(error => {
628
- if (this.shouldLogErrors) {
629
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
630
- }
631
-
632
- throw error;
633
- });
634
- }
635
-
636
- _checkTokenExpired(response , err ) {
637
- // Special case when authenticating form a token: we got a 404
638
- const isTokenNotFound = response.status === 404 && this._isTokenNotFound(err);
639
-
640
- return response.status === 401 || isTokenNotFound;
641
- }
642
-
643
- _isTokenNotFound(err ) {
644
- return err && err.reason && err.reason[0] === 'No such token';
645
- }
646
-
647
- _replayWithNewToken(
648
- err ,
649
- path ,
650
- method ,
651
- body = null,
652
- headers = null,
653
- parse ,
654
- ) {
655
- const isTokenNotFound = this._isTokenNotFound(err);
656
- let newPath = path;
657
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
658
-
659
- this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
660
-
661
- return this.refreshTokenPromise.then(() => {
662
- this.refreshTokenPromise = null;
663
- logger.info('token refreshed', { isTokenNotFound });
664
- if (isTokenNotFound) {
665
- const pathParts = path.split('/');
666
- pathParts.pop();
667
- pathParts.push(this.token);
668
- newPath = pathParts.join('/');
669
- }
670
-
671
- return this.call(newPath, method, body, headers, parse, false);
672
- }).catch((e) => {
673
- this.refreshTokenPromise = null;
674
- throw e;
675
- });
676
- }
677
-
678
- getHeaders(header ) {
679
- if (header instanceof Object) {
680
- return header;
681
- }
682
-
683
- return {
684
- 'X-Auth-Token': this.token,
685
- ...(this.tenant ? { 'Wazo-Tenant': this.tenant } : null),
686
- Accept: 'application/json',
687
- 'Content-Type': 'application/json',
688
- };
689
- }
690
-
691
- computeUrl(method , path , body ) {
692
- const url = `${this.baseUrl}/${path}`;
693
-
694
- return method === 'get' && body && Object.keys(body).length ? `${url}?${ApiRequester.getQueryString(body)}` : url;
695
- }
696
-
697
- get baseUrl() {
698
- return `https://${this.server}/api`;
699
- }
700
- }
701
-
702
- //
703
-
704
- var newFrom = (instance , ToClass ) => {
705
- const args = {};
706
- Object.getOwnPropertyNames(instance).forEach(prop => {
707
- args[prop] = instance[prop];
708
- });
709
-
710
- return new ToClass(args);
711
- };
712
-
713
- //
714
-
715
-
716
-
717
-
718
-
719
-
720
-
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
-
730
-
731
-
732
-
733
-
734
-
735
-
736
-
737
-
738
-
739
-
740
-
741
-
742
-
743
-
744
- class Line {
745
-
746
-
747
-
748
-
749
-
750
-
751
-
752
-
753
- static parse(plain ) {
754
- return new Line({
755
- id: plain.id,
756
- extensions: plain.extensions,
757
- endpointCustom: plain.endpoint_custom || null,
758
- endpointSccp: plain.endpoint_sccp || null,
759
- endpointSip: plain.endpoint_sip || null,
760
- });
761
- }
762
-
763
- static newFrom(profile ) {
764
- return newFrom(profile, Line);
765
- }
766
-
767
- is(line ) {
768
- return line ? this.id === line.id : false;
769
- }
770
-
771
- hasExtension(extension ) {
772
- if (!this.extensions) {
773
- return false;
774
- }
775
-
776
- return this.extensions.some(ext => ext.exten === extension);
777
- }
778
-
779
- constructor({ id, extensions, endpointCustom, endpointSccp, endpointSip } = {}) {
780
- this.id = id;
781
- this.extensions = extensions;
782
- this.endpointCustom = endpointCustom || null;
783
- this.endpointSccp = endpointSccp || null;
784
- this.endpointSip = endpointSip || null;
785
-
786
- // Useful to compare instead of instanceof with minified code
787
- this.type = 'Line';
788
- }
789
- }
790
-
791
- //
792
-
793
-
794
-
795
-
796
-
797
-
798
- const FORWARD_KEYS = {
799
- BUSY: 'busy',
800
- NO_ANSWER: 'noanswer',
801
- UNCONDITIONAL: 'unconditional',
802
- };
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
- class ForwardOption {
811
-
812
-
813
-
814
-
815
- static parse(plain , key ) {
816
- return new ForwardOption({
817
- destination: plain.destination || '',
818
- enabled: plain.enabled,
819
- key,
820
- });
821
- }
822
-
823
- static newFrom(profile ) {
824
- return newFrom(profile, ForwardOption);
825
- }
826
-
827
- constructor({ destination, enabled, key } = {}) {
828
- this.destination = destination;
829
- this.enabled = enabled;
830
- this.key = key;
831
- }
832
-
833
- setDestination(number ) {
834
- this.destination = number;
835
-
836
- return this;
837
- }
838
-
839
- setEnabled(enabled ) {
840
- this.enabled = enabled;
841
-
842
- return this;
843
- }
844
-
845
- is(other ) {
846
- return this.key === other.key;
847
- }
848
- }
849
-
850
- //
851
-
852
-
853
- const availableCodecs = ['vp8', 'vp9', 'h264'];
854
-
855
-
856
-
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
- class SipLine {
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
- static parse(plain ) {
901
- let { username, secret, host } = plain;
902
-
903
- // Since 20.13 engine so options are now in section
904
- if (plain.auth_section_options) {
905
- // $FlowFixMe
906
- const findOption = (options , name ) => options.find(option => option[0] === name);
907
-
908
- const usernameOption = findOption(plain.auth_section_options, 'username');
909
- const secretOption = findOption(plain.auth_section_options, 'password');
910
- const hostOption = findOption(plain.endpoint_section_options, 'media_address');
911
-
912
- username = usernameOption ? usernameOption[1] : '';
913
- secret = secretOption ? secretOption[1] : '';
914
- host = hostOption ? hostOption[1] : '';
915
- }
916
-
917
- return new SipLine({
918
- id: plain.id,
919
- uuid: plain.uuid,
920
- tenantUuid: plain.tenant_uuid,
921
- username,
922
- secret,
923
- type: plain.type,
924
- host,
925
- options: plain.options,
926
- endpointSectionOptions: plain.endpoint_section_options,
927
- links: plain.links,
928
- trunk: plain.trunk,
929
- line: plain.line,
930
- });
931
- }
932
-
933
- static newFrom(sipLine ) {
934
- return newFrom(sipLine, SipLine);
935
- }
936
-
937
- is(line ) {
938
- if (line.uuid) {
939
- return this.uuid === line.uuid;
940
- }
941
- return this.id === line.id;
942
- }
943
-
944
- getOptions() {
945
- // `options` params have beend remove since 20.13... we should now use endpointSectionOptions
946
- return this.endpointSectionOptions || this.options || [];
947
- }
948
-
949
- isWebRtc() {
950
- return this.getOptions().some(option => option[0] === 'webrtc' && option[1] === 'yes');
951
- }
952
-
953
- hasVideo() {
954
- const allow = this.getOptions().find(option => option[0] === 'allow');
955
- return Array.isArray(allow) && allow[1].split(',').some(codec => availableCodecs.some(c => c === codec));
956
- }
957
-
958
- hasVideoConference() {
959
- return (
960
- this.getOptions().some(option => option[0] === 'max_audio_streams' && parseInt(option[1], 10) > 0)
961
- && this.getOptions().some(option => option[0] === 'max_video_streams' && parseInt(option[1], 10) > 1)
962
- );
963
- }
964
-
965
- constructor({
966
- id,
967
- uuid,
968
- tenantUuid,
969
- username,
970
- secret,
971
- type,
972
- host,
973
- options,
974
- endpointSectionOptions,
975
- links,
976
- trunk,
977
- line,
978
- } = {}) {
979
- this.id = id;
980
- this.uuid = uuid;
981
- this.tenantUuid = tenantUuid;
982
- this.username = username;
983
- this.secret = secret;
984
- this.type = type;
985
- this.host = host;
986
- this.options = options;
987
- this.endpointSectionOptions = endpointSectionOptions;
988
- this.links = links;
989
- this.trunk = trunk;
990
- this.line = line;
991
-
992
- // Useful to compare instead of instanceof with minified code
993
- this.type = 'SipLine';
994
- }
995
- }
996
-
997
- //
998
-
999
- const LINE_STATE = {
1000
- AVAILABLE: 'available',
1001
- HOLDING: 'holding',
1002
- RINGING: 'ringing',
1003
- TALKING: 'talking',
1004
- UNAVAILABLE: 'unavailable',
1005
- PROGRESSING: 'progressing',
1006
- };
1007
-
1008
-
1009
-
1010
-
1011
-
1012
-
1013
-
1014
-
1015
-
1016
-
1017
-
1018
-
1019
-
1020
-
1021
-
1022
-
1023
-
1024
-
1025
-
1026
-
1027
-
1028
-
1029
-
1030
-
1031
-
1032
-
1033
-
1034
-
1035
-
1036
-
1037
-
1038
-
1039
-
1040
-
1041
-
1042
-
1043
-
1044
-
1045
-
1046
-
1047
-
1048
-
1049
-
1050
-
1051
-
1052
-
1053
-
1054
-
1055
-
1056
-
1057
-
1058
-
1059
-
1060
-
1061
-
1062
-
1063
-
1064
-
1065
-
1066
-
1067
-
1068
-
1069
-
1070
-
1071
-
1072
-
1073
-
1074
-
1075
-
1076
-
1077
-
1078
-
1079
-
1080
-
1081
-
1082
-
1083
-
1084
-
1085
-
1086
-
1087
-
1088
-
1089
-
1090
-
1091
-
1092
-
1093
-
1094
-
1095
-
1096
-
1097
-
1098
- class Profile {
1099
-
1100
-
1101
-
1102
-
1103
-
1104
-
1105
-
1106
-
1107
-
1108
-
1109
-
1110
-
1111
-
1112
-
1113
-
1114
-
1115
-
1116
-
1117
-
1118
-
1119
- static parse(plain ) {
1120
- return new Profile({
1121
- id: plain.uuid,
1122
- firstName: plain.firstName || plain.firstname || '',
1123
- lastName: plain.lastName || plain.lastname || '',
1124
- email: plain.email,
1125
- lines: plain.lines.map(line => Line.parse(line)),
1126
- username: plain.username,
1127
- mobileNumber: plain.mobile_phone_number || '',
1128
- ringSeconds: plain.ring_seconds,
1129
- forwards: [
1130
- ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1131
- ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
1132
- ForwardOption.parse(plain.forwards.busy, FORWARD_KEYS.BUSY),
1133
- ],
1134
- doNotDisturb: plain.services.dnd.enabled,
1135
- subscriptionType: plain.subscription_type,
1136
- voicemail: plain.voicemail,
1137
- switchboards: plain.switchboards || [],
1138
- agent: plain.agent,
1139
- status: '',
1140
- callPickupTargetUsers: plain.call_pickup_target_users || [],
1141
- onlineCallRecordEnabled: plain.online_call_record_enabled,
1142
- });
1143
- }
1144
-
1145
- static newFrom(profile ) {
1146
- return newFrom(profile, Profile);
1147
- }
1148
-
1149
- constructor({
1150
- id,
1151
- firstName,
1152
- lastName,
1153
- email,
1154
- lines,
1155
- username,
1156
- mobileNumber,
1157
- forwards,
1158
- doNotDisturb,
1159
- state,
1160
- subscriptionType,
1161
- voicemail,
1162
- switchboards,
1163
- agent,
1164
- status,
1165
- ringSeconds,
1166
- sipLines,
1167
- callPickupTargetUsers,
1168
- onlineCallRecordEnabled,
1169
- } = {}) {
1170
- this.id = id;
1171
- this.firstName = firstName;
1172
- this.lastName = lastName;
1173
- this.email = email;
1174
- this.lines = lines;
1175
- this.username = username;
1176
- this.mobileNumber = mobileNumber;
1177
- this.forwards = forwards;
1178
- this.doNotDisturb = doNotDisturb;
1179
- this.state = state;
1180
- this.voicemail = voicemail;
1181
- this.subscriptionType = subscriptionType;
1182
- this.switchboards = switchboards;
1183
- this.agent = agent;
1184
- this.status = status;
1185
- this.callPickupTargetUsers = callPickupTargetUsers;
1186
- this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1187
- this.ringSeconds = ringSeconds;
1188
-
1189
- this.sipLines = sipLines || [];
1190
- }
1191
-
1192
- static getLinesState(lines ) {
1193
- let result = LINE_STATE.UNAVAILABLE;
1194
-
1195
- // eslint-disable-next-line
1196
- for (const line of lines) {
1197
- if (line.state === LINE_STATE.RINGING) {
1198
- result = LINE_STATE.RINGING;
1199
- break;
1200
- }
1201
-
1202
- if (line.state === LINE_STATE.TALKING) {
1203
- result = LINE_STATE.TALKING;
1204
- break;
1205
- }
1206
-
1207
- if (line.state === LINE_STATE.AVAILABLE) {
1208
- result = LINE_STATE.AVAILABLE;
1209
- }
1210
- }
1211
-
1212
- return result;
1213
- }
1214
-
1215
- hasId(id ) {
1216
- return id === this.id;
1217
- }
1218
-
1219
- setMobileNumber(number ) {
1220
- this.mobileNumber = number;
1221
-
1222
- return this;
1223
- }
1224
-
1225
- setForwardOption(forwardOption ) {
1226
- const updatedForwardOptions = this.forwards.slice();
1227
- const index = updatedForwardOptions.findIndex(forward => forward.is(forwardOption));
1228
- updatedForwardOptions.splice(index, 1, forwardOption);
1229
-
1230
- this.forwards = updatedForwardOptions;
1231
-
1232
- return this;
1233
- }
1234
-
1235
- setDoNotDisturb(enabled ) {
1236
- this.doNotDisturb = enabled;
1237
-
1238
- return this;
1239
- }
1240
-
1241
- setState(state ) {
1242
- this.state = state;
1243
-
1244
- return this;
1245
- }
1246
- }
1247
-
1248
- //
1249
-
1250
-
1251
-
1252
-
1253
-
1254
-
1255
-
1256
-
1257
-
1258
-
1259
-
1260
-
1261
-
1262
-
1263
-
1264
- class ExternalApp {
1265
-
1266
-
1267
-
1268
-
1269
- static parse(plain ) {
1270
- return new ExternalApp({
1271
- name: plain.name,
1272
- configuration: plain.configuration,
1273
- });
1274
- }
1275
-
1276
- static parseMany(plain ) {
1277
- return plain.items.map(item => ExternalApp.parse(item));
1278
- }
1279
-
1280
- static newFrom(profile ) {
1281
- return newFrom(profile, ExternalApp);
1282
- }
1283
-
1284
- constructor({ name, configuration } = {}) {
1285
- this.name = name;
1286
- this.configuration = configuration;
1287
-
1288
- // Useful to compare instead of instanceof with minified code
1289
- this.type = 'ExternalApp';
1290
- }
1291
- }
1292
-
1293
- //
1294
-
1295
- class MeetingAuthorization {
1296
-
1297
-
1298
-
1299
-
1300
-
1301
-
1302
- constructor({
1303
- meetingUuid,
1304
- uuid,
1305
- userUuid,
1306
- userName,
1307
- } = {}) {
1308
- this.meetingUuid = meetingUuid;
1309
- this.uuid = uuid;
1310
- this.userUuid = userUuid;
1311
- this.userName = userName;
1312
- }
1313
-
1314
- setStatus(status ) {
1315
- this.status = status;
1316
- }
1317
-
1318
- getStatus() {
1319
- return this.status;
1320
- }
1321
-
1322
- static parse(plain ) {
1323
- const {
1324
- meeting_uuid: meetingUuid,
1325
- uuid,
1326
- guest_uuid: userUuid,
1327
- guest_name: userName,
1328
- } = plain;
1329
-
1330
- return new MeetingAuthorization({
1331
- meetingUuid,
1332
- uuid,
1333
- userUuid,
1334
- userName,
1335
- });
1336
- }
1337
-
1338
- static parseMany(items ) {
1339
- if (!items) {
1340
- return [];
1341
- }
1342
- return items.map(MeetingAuthorization.parse);
1343
- }
1344
- }
1345
-
1346
- //
1347
-
1348
-
1349
-
1350
-
1351
-
1352
-
1353
-
1354
-
1355
-
1356
-
1357
-
1358
-
1359
-
1360
-
1361
-
1362
-
1363
-
1364
-
1365
-
1366
-
1367
-
1368
-
1369
-
1370
-
1371
-
1372
- class Meeting {
1373
-
1374
-
1375
-
1376
-
1377
-
1378
-
1379
-
1380
-
1381
-
1382
-
1383
-
1384
-
1385
-
1386
-
1387
- static parse(plain ) {
1388
- return new Meeting({
1389
- guestSipAuthorization: plain.guest_sip_authorization,
1390
- uri: plain.ingress_http_uri,
1391
- name: plain.name,
1392
- ownerUuids: plain.owner_uuids,
1393
- port: plain.port,
1394
- uuid: plain.uuid,
1395
- extension: plain.exten,
1396
- persistent: plain.persistent,
1397
- creationTime: moment__default['default'](plain.creation_time).toDate(),
1398
- requireAuthorization: plain.require_authorization,
1399
- });
1400
- }
1401
-
1402
- static parseMany(items ) {
1403
- if (!items) {
1404
- return [];
1405
- }
1406
- return items.map(plain => Meeting.parse(plain));
1407
- }
1408
-
1409
- static newFrom(meeting ) {
1410
- return newFrom(meeting, Meeting);
1411
- }
1412
-
1413
- constructor({
1414
- uuid,
1415
- name,
1416
- guestSipAuthorization,
1417
- ownerUuids,
1418
- port,
1419
- uri,
1420
- extension,
1421
- persistent,
1422
- creationTime,
1423
- requireAuthorization,
1424
- } = {}) {
1425
- this.guestSipAuthorization = guestSipAuthorization;
1426
- this.uri = uri;
1427
- this.name = name;
1428
- this.ownerUuids = ownerUuids;
1429
- this.port = port;
1430
- this.uuid = uuid;
1431
- this.extension = extension;
1432
- this.persistent = persistent;
1433
- this.creationTime = creationTime;
1434
- this.requireAuthorization = requireAuthorization;
1435
-
1436
- // Useful to compare instead of instanceof with minified code
1437
- this.type = 'Meeting';
1438
- }
1439
-
1440
- getGuestSipCredentials() {
1441
- // eslint-disable-next-line no-undef
1442
- const [username, secret] = atob(this.guestSipAuthorization).split(':');
1443
- return { username, secret };
1444
- }
1445
-
1446
- }
1447
-
1448
- //
1449
-
1450
- const camelToUnderscore = (key ) => {
1451
- if (typeof key !== 'string') {
1452
- throw new Error('Input is not a string');
1453
- }
1454
- return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
1455
- };
1456
-
1457
- //
1458
-
1459
- const convertKeysFromCamelToUnderscore = (args ) => {
1460
- if (!args || typeof args !== 'object' || Array.isArray(args)) {
1461
- throw new Error('Input is not an object');
1462
- }
1463
-
1464
- return Object.keys(args).reduce((acc, key) => {
1465
- acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
1466
- ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
1467
- return acc;
1468
- }, {});
1469
- };
1470
-
1471
- /* */
1472
-
1473
- var confd = (client , baseUrl ) => ({
1474
- listUsers: () => client.get(`${baseUrl}/users`, null),
1475
-
1476
- getUser: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}`, null).then(Profile.parse),
1477
-
1478
- updateUser: (userUuid , profile ) => {
1479
- const body = {
1480
- firstname: profile.firstName,
1481
- lastname: profile.lastName,
1482
- email: profile.email,
1483
- mobile_phone_number: profile.mobileNumber,
1484
- };
1485
-
1486
- return client.put(`${baseUrl}/users/${userUuid}`, body, null, ApiRequester.successResponseParser);
1487
- },
1488
-
1489
- updateForwardOption: (userUuid , key , destination , enabled ) => {
1490
- const url = `${baseUrl}/users/${userUuid}/forwards/${key}`;
1491
- return client.put(url, { destination, enabled }, null, ApiRequester.successResponseParser);
1492
- },
1493
-
1494
- updateDoNotDisturb: (userUuid , enabled ) =>
1495
- client.put(`${baseUrl}/users/${userUuid}/services/dnd`, { enabled }, null, ApiRequester.successResponseParser),
1496
-
1497
- getUserLineSip: (userUuid , lineId ) =>
1498
- client.get(`${baseUrl}/users/${userUuid}/lines/${lineId}/associated/endpoints/sip?view=merged`).then(SipLine.parse),
1499
-
1500
- getUserLinesSip(userUuid , lineIds ) {
1501
- // We have to catch all exception, unless Promise.all will returns an empty array for 2 lines with a custom one:
1502
- // The custom line will throw a 404 and break the Promise.all.
1503
- // $FlowFixMe
1504
- return Promise.all(lineIds.map(lineId => this.getUserLineSip(userUuid, lineId).catch(() => null)));
1505
- },
1506
-
1507
- getUserLineSipFromToken(userUuid ) {
1508
- return this.getUser(userUuid).then(user => {
1509
- if (!user.lines.length) {
1510
- console.warn(`No sip line for user: ${userUuid}`);
1511
- return null;
1512
- }
1513
- const line = user.lines[0];
1514
-
1515
- return this.getUserLineSip(userUuid, line.uuid || line.id);
1516
- });
1517
- },
1518
-
1519
- listApplications: () => client.get(`${baseUrl}/applications`, null),
1520
-
1521
- getInfos: () => client.get(`${baseUrl}/infos`, null),
1522
-
1523
- getExternalApps: (userUuid ) =>
1524
- client.get(`${baseUrl}/users/${userUuid}/external/apps`).then(ExternalApp.parseMany),
1525
-
1526
- getExternalApp: async (userUuid , name ) => {
1527
- const url = `${baseUrl}/users/${userUuid}/external/apps/${name}?view=fallback`;
1528
-
1529
- try {
1530
- return await client.get(url).then(ExternalApp.parse);
1531
- } catch (e) {
1532
- return null;
1533
- }
1534
- },
1535
-
1536
- getMyMeetings: () =>
1537
- client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
1538
-
1539
- createMyMeeting: (args ) =>
1540
- client
1541
- .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
1542
- .then(Meeting.parse),
1543
-
1544
- updateMyMeeting: (meetingUuid , data ) =>
1545
- client.put(
1546
- `${baseUrl}/users/me/meetings/${meetingUuid}`,
1547
- convertKeysFromCamelToUnderscore(data),
1548
- null,
1549
- ApiRequester.successResponseParser,
1550
- ),
1551
-
1552
- deleteMyMeeting: (meetingUuid ) =>
1553
- client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
1554
-
1555
- getMeeting: (meetingUuid ) =>
1556
- client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
1557
-
1558
- meetingAuthorizations: (meetingUuid ) =>
1559
- client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
1560
-
1561
- meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
1562
- client.put(
1563
- `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
1564
- {},
1565
- null,
1566
- ApiRequester.successResponseParser,
1567
- ),
1568
-
1569
- meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
1570
- client.put(
1571
- `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
1572
- {},
1573
- null,
1574
- ApiRequester.successResponseParser,
1575
- ),
1576
-
1577
- guestGetMeeting: (meetingUuid ) =>
1578
- client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
1579
-
1580
- guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
1581
- client
1582
- .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
1583
- .then(MeetingAuthorization.parse),
1584
-
1585
- guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
1586
- client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
1587
-
1588
- });
1589
-
1590
- module.exports = confd;
71
+ }),
72
+ getMyMeetings: () => client.get(`${baseUrl}/users/me/meetings`).then((response) => Meeting_1.default.parseMany(response.items)),
73
+ createMyMeeting: (args) => client.post(`${baseUrl}/users/me/meetings`, (0, object_1.convertKeysFromCamelToUnderscore)(args)).then(Meeting_1.default.parse),
74
+ updateMyMeeting: (meetingUuid, data) => client.put(`${baseUrl}/users/me/meetings/${meetingUuid}`, (0, object_1.convertKeysFromCamelToUnderscore)(data), null, api_requester_1.default.successResponseParser),
75
+ deleteMyMeeting: (meetingUuid) => client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
76
+ getMeeting: (meetingUuid) => client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting_1.default.parse),
77
+ meetingAuthorizations: (meetingUuid) => client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization_1.default.parseMany),
78
+ meetingAuthorizationReject: (meetingUuid, authorizationUuid) => client.put(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`, {}, null, api_requester_1.default.successResponseParser),
79
+ meetingAuthorizationAccept: (meetingUuid, authorizationUuid) => client.put(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`, {}, null, api_requester_1.default.successResponseParser),
80
+ guestGetMeeting: (meetingUuid) => client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting_1.default.parse),
81
+ guestAuthorizationRequest: (userUuid, meetingUuid, username) => client.post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, {
82
+ guest_name: username,
83
+ }).then(MeetingAuthorization_1.default.parse),
84
+ guestAuthorizationCheck: (userUuid, meetingUuid, authorizationUuid) => client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
85
+ }));