@wazo/sdk 0.38.22 → 0.39.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (883) hide show
  1. package/README.md +62 -293
  2. package/dist/wazo-sdk.js +9 -25
  3. package/esm/__tests__/api-client.test.js +183 -5059
  4. package/esm/__tests__/web-rtc-client.test.js +177 -7930
  5. package/esm/api/agentd.js +23 -832
  6. package/esm/api/amid.js +9 -411
  7. package/esm/api/application.js +60 -829
  8. package/esm/api/auth.js +164 -1213
  9. package/esm/api/call-logd.js +24 -733
  10. package/esm/api/calld.js +114 -1469
  11. package/esm/api/chatd.js +48 -1311
  12. package/esm/api/confd.js +67 -1580
  13. package/esm/api/ctid-ng.js +92 -1343
  14. package/esm/api/dird.js +100 -1590
  15. package/esm/api/webhookd.js +7 -513
  16. package/esm/api-client.js +143 -4880
  17. package/esm/checker/Checker.js +45 -8727
  18. package/esm/checker/checks/aor.js +24 -4924
  19. package/esm/checker/checks/api.js +70 -4968
  20. package/esm/checker/checks/ice-ipv4.js +63 -117
  21. package/esm/checker/checks/index.js +8 -8677
  22. package/esm/checker/checks/symmetric-nat.js +54 -102
  23. package/esm/checker/checks/wazo-websocket.js +34 -999
  24. package/esm/checker/checks/webrtc-transport.js +28 -7845
  25. package/esm/checker/checks/webrtc.js +31 -7852
  26. package/esm/domain/AdHocAPIConference.js +86 -5115
  27. package/esm/domain/Agent.js +27 -61
  28. package/esm/domain/BadResponse.js +20 -43
  29. package/esm/domain/Call.js +120 -210
  30. package/esm/domain/CallLog.js +123 -305
  31. package/esm/domain/CallSession.js +251 -423
  32. package/esm/domain/ChatMessage.js +52 -105
  33. package/esm/domain/ChatRoom.js +28 -60
  34. package/esm/domain/Contact.js +435 -741
  35. package/esm/domain/Country.js +17 -19
  36. package/esm/domain/Device/DebugDevice.js +31 -47
  37. package/esm/domain/Device/Device.js +1 -1
  38. package/esm/domain/DirectorySource.js +1 -1
  39. package/esm/domain/ExternalApp.js +23 -56
  40. package/esm/domain/Features.js +57 -5009
  41. package/esm/domain/ForwardOption.js +35 -70
  42. package/esm/domain/IndirectTransfer.js +38 -97
  43. package/esm/domain/Line.js +37 -88
  44. package/esm/domain/Meeting.js +58 -113
  45. package/esm/domain/MeetingAuthorization.js +38 -68
  46. package/esm/domain/MeetingStatus.js +13 -28
  47. package/esm/domain/NotificationOptions.js +43 -77
  48. package/esm/domain/Phone/CTIPhone.js +245 -5743
  49. package/esm/domain/Phone/Phone.js +1 -2
  50. package/esm/domain/Phone/WebRTCPhone.js +1457 -2671
  51. package/esm/domain/Profile.js +120 -405
  52. package/esm/domain/Recording.js +27 -51
  53. package/esm/domain/Relocation.js +16 -40
  54. package/esm/domain/Room.js +90 -133
  55. package/esm/domain/SFUNotAvailableError.js +5 -8
  56. package/esm/domain/ServerError.js +8 -61
  57. package/esm/domain/Session.js +125 -251
  58. package/esm/domain/SipLine.js +78 -155
  59. package/esm/domain/Subscription.js +39 -83
  60. package/esm/domain/SwitchboardCall.js +51 -143
  61. package/esm/domain/Voicemail.js +57 -122
  62. package/esm/domain/__tests__/Agent.test.js +31 -101
  63. package/esm/domain/__tests__/Call.test.js +24 -232
  64. package/esm/domain/__tests__/CallLog.test.js +60 -386
  65. package/esm/domain/__tests__/CallSession.test.js +74 -502
  66. package/esm/domain/__tests__/Contact.test.js +220 -902
  67. package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
  68. package/esm/domain/__tests__/Line.test.js +48 -156
  69. package/esm/domain/__tests__/Meeting.test.js +73 -226
  70. package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
  71. package/esm/domain/__tests__/Profile.test.js +135 -496
  72. package/esm/domain/__tests__/Room.test.js +227 -719
  73. package/esm/domain/__tests__/Session.test.js +357 -1025
  74. package/esm/domain/__tests__/SipLine.test.js +24 -179
  75. package/esm/domain/__tests__/Voicemail.test.js +82 -200
  76. package/esm/domain/types.js +1 -1
  77. package/esm/index.js +63 -14985
  78. package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
  79. package/esm/pubkey.js +10 -0
  80. package/esm/service/CallApi.js +42 -5014
  81. package/esm/service/IssueReporter.js +278 -360
  82. package/esm/service/__tests__/IssueReporter.test.js +92 -494
  83. package/esm/service/getApiClient.js +53 -4972
  84. package/esm/simple/Auth.js +212 -14747
  85. package/esm/simple/Configuration.js +8 -14796
  86. package/esm/simple/Directory.js +6 -4964
  87. package/esm/simple/Phone.js +309 -14727
  88. package/esm/simple/Websocket.js +68 -1112
  89. package/esm/simple/index.js +125 -14792
  90. package/esm/simple/room/LocalParticipant.js +1 -14797
  91. package/esm/simple/room/Participant.js +274 -14760
  92. package/esm/simple/room/RemoteParticipant.js +6 -14796
  93. package/esm/simple/room/Room.js +648 -14736
  94. package/esm/simple/room/SipRoom.js +111 -14790
  95. package/esm/simple/room/Stream.js +40 -14792
  96. package/esm/simple/room/__tests__/Participant.test.js +68 -14872
  97. package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14805
  98. package/esm/simple/utils.js +9 -14799
  99. package/esm/types/WebSocketMessage.js +1 -1
  100. package/esm/types/__tests__/api-client.test.d.ts +2 -0
  101. package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
  102. package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
  103. package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  104. package/esm/types/api/agentd.d.ts +17 -0
  105. package/esm/types/api/agentd.d.ts.map +1 -0
  106. package/esm/types/api/amid.d.ts +8 -0
  107. package/esm/types/api/amid.d.ts.map +1 -0
  108. package/esm/types/api/application.d.ts +34 -0
  109. package/esm/types/api/application.d.ts.map +1 -0
  110. package/esm/types/api/auth.d.ts +64 -0
  111. package/esm/types/api/auth.d.ts.map +1 -0
  112. package/esm/types/api/call-logd.d.ts +12 -0
  113. package/esm/types/api/call-logd.d.ts.map +1 -0
  114. package/esm/types/api/calld.d.ts +51 -0
  115. package/esm/types/api/calld.d.ts.map +1 -0
  116. package/esm/types/api/chatd.d.ts +42 -0
  117. package/esm/types/api/chatd.d.ts.map +1 -0
  118. package/esm/types/api/confd.d.ts +39 -0
  119. package/esm/types/api/confd.d.ts.map +1 -0
  120. package/esm/types/api/ctid-ng.d.ts +36 -0
  121. package/esm/types/api/ctid-ng.d.ts.map +1 -0
  122. package/esm/types/api/dird.d.ts +38 -0
  123. package/esm/types/api/dird.d.ts.map +1 -0
  124. package/esm/types/api/webhookd.d.ts +24 -0
  125. package/esm/types/api/webhookd.d.ts.map +1 -0
  126. package/esm/types/api-client.d.ts +63 -0
  127. package/esm/types/api-client.d.ts.map +1 -0
  128. package/esm/types/checker/Checker.d.ts +13 -0
  129. package/esm/types/checker/Checker.d.ts.map +1 -0
  130. package/esm/types/checker/checks/aor.d.ts +6 -0
  131. package/esm/types/checker/checks/aor.d.ts.map +1 -0
  132. package/esm/types/checker/checks/api.d.ts +6 -0
  133. package/esm/types/checker/checks/api.d.ts.map +1 -0
  134. package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
  135. package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  136. package/esm/types/checker/checks/index.d.ts +9 -0
  137. package/esm/types/checker/checks/index.d.ts.map +1 -0
  138. package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
  139. package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  140. package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
  141. package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  142. package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
  143. package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  144. package/esm/types/checker/checks/webrtc.d.ts +6 -0
  145. package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
  146. package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
  147. package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
  148. package/esm/types/domain/Agent.d.ts +31 -0
  149. package/esm/types/domain/Agent.d.ts.map +1 -0
  150. package/esm/types/domain/BadResponse.d.ts +11 -0
  151. package/esm/types/domain/BadResponse.d.ts.map +1 -0
  152. package/esm/types/domain/Call.d.ts +79 -0
  153. package/esm/types/domain/Call.d.ts.map +1 -0
  154. package/esm/types/domain/CallLog.d.ts +91 -0
  155. package/esm/types/domain/CallLog.d.ts.map +1 -0
  156. package/esm/types/domain/CallSession.d.ts +120 -0
  157. package/esm/types/domain/CallSession.d.ts.map +1 -0
  158. package/esm/types/domain/ChatMessage.d.ts +41 -0
  159. package/esm/types/domain/ChatMessage.d.ts.map +1 -0
  160. package/esm/types/domain/ChatRoom.d.ts +22 -0
  161. package/esm/types/domain/ChatRoom.d.ts.map +1 -0
  162. package/esm/types/domain/Contact.d.ts +316 -0
  163. package/esm/types/domain/Contact.d.ts.map +1 -0
  164. package/esm/types/domain/Country.d.ts +20 -0
  165. package/esm/types/domain/Country.d.ts.map +1 -0
  166. package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
  167. package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
  168. package/esm/types/domain/Device/Device.d.ts +13 -0
  169. package/esm/types/domain/Device/Device.d.ts.map +1 -0
  170. package/esm/types/domain/DirectorySource.d.ts +13 -0
  171. package/esm/types/domain/DirectorySource.d.ts.map +1 -0
  172. package/esm/types/domain/ExternalApp.d.ts +22 -0
  173. package/esm/types/domain/ExternalApp.d.ts.map +1 -0
  174. package/esm/types/domain/Features.d.ts +24 -0
  175. package/esm/types/domain/Features.d.ts.map +1 -0
  176. package/esm/types/domain/ForwardOption.d.ts +27 -0
  177. package/esm/types/domain/ForwardOption.d.ts.map +1 -0
  178. package/esm/types/domain/IndirectTransfer.d.ts +31 -0
  179. package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
  180. package/esm/types/domain/Line.d.ts +46 -0
  181. package/esm/types/domain/Line.d.ts.map +1 -0
  182. package/esm/types/domain/Meeting.d.ts +45 -0
  183. package/esm/types/domain/Meeting.d.ts.map +1 -0
  184. package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
  185. package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
  186. package/esm/types/domain/MeetingStatus.d.ts +10 -0
  187. package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
  188. package/esm/types/domain/NotificationOptions.d.ts +22 -0
  189. package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
  190. package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
  191. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  192. package/esm/types/domain/Phone/Phone.d.ts +71 -0
  193. package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
  194. package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  195. package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  196. package/esm/types/domain/Profile.d.ts +151 -0
  197. package/esm/types/domain/Profile.d.ts.map +1 -0
  198. package/esm/types/domain/Recording.d.ts +26 -0
  199. package/esm/types/domain/Recording.d.ts.map +1 -0
  200. package/esm/types/domain/Relocation.d.ts +23 -0
  201. package/esm/types/domain/Relocation.d.ts.map +1 -0
  202. package/esm/types/domain/Room.d.ts +35 -0
  203. package/esm/types/domain/Room.d.ts.map +1 -0
  204. package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
  205. package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  206. package/esm/types/domain/ServerError.d.ts +6 -0
  207. package/esm/types/domain/ServerError.d.ts.map +1 -0
  208. package/esm/types/domain/Session.d.ts +90 -0
  209. package/esm/types/domain/Session.d.ts.map +1 -0
  210. package/esm/types/domain/SipLine.d.ts +54 -0
  211. package/esm/types/domain/SipLine.d.ts.map +1 -0
  212. package/esm/types/domain/Subscription.d.ts +43 -0
  213. package/esm/types/domain/Subscription.d.ts.map +1 -0
  214. package/esm/types/domain/SwitchboardCall.d.ts +62 -0
  215. package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
  216. package/esm/types/domain/Voicemail.d.ts +50 -0
  217. package/esm/types/domain/Voicemail.d.ts.map +1 -0
  218. package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
  219. package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  220. package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
  221. package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
  222. package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
  223. package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  224. package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
  225. package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  226. package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
  227. package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  228. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  229. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  230. package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
  231. package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
  232. package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
  233. package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  234. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  235. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  236. package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
  237. package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  238. package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
  239. package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
  240. package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
  241. package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
  242. package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
  243. package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  244. package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  245. package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  246. package/esm/types/domain/types.d.ts +217 -0
  247. package/esm/types/domain/types.d.ts.map +1 -0
  248. package/esm/types/index.d.ts +304 -0
  249. package/esm/types/index.d.ts.map +1 -0
  250. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  251. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  252. package/esm/types/pubkey.d.ts +3 -0
  253. package/esm/types/pubkey.d.ts.map +1 -0
  254. package/esm/types/service/CallApi.d.ts +28 -0
  255. package/esm/types/service/CallApi.d.ts.map +1 -0
  256. package/esm/types/service/IssueReporter.d.ts +40 -0
  257. package/esm/types/service/IssueReporter.d.ts.map +1 -0
  258. package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  259. package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  260. package/esm/types/service/getApiClient.d.ts +16 -0
  261. package/esm/types/service/getApiClient.d.ts.map +1 -0
  262. package/esm/types/simple/Auth.d.ts +51 -0
  263. package/esm/types/simple/Auth.d.ts.map +1 -0
  264. package/esm/types/simple/Configuration.d.ts +3 -0
  265. package/esm/types/simple/Configuration.d.ts.map +1 -0
  266. package/esm/types/simple/Directory.d.ts +3 -0
  267. package/esm/types/simple/Directory.d.ts.map +1 -0
  268. package/esm/types/simple/Phone.d.ts +115 -0
  269. package/esm/types/simple/Phone.d.ts.map +1 -0
  270. package/esm/types/simple/Websocket.d.ts +19 -0
  271. package/esm/types/simple/Websocket.d.ts.map +1 -0
  272. package/esm/types/simple/index.d.ts +147 -0
  273. package/esm/types/simple/index.d.ts.map +1 -0
  274. package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
  275. package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
  276. package/esm/types/simple/room/Participant.d.ts +76 -0
  277. package/esm/types/simple/room/Participant.d.ts.map +1 -0
  278. package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
  279. package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  280. package/esm/types/simple/room/Room.d.ts +116 -0
  281. package/esm/types/simple/room/Room.d.ts.map +1 -0
  282. package/esm/types/simple/room/SipRoom.d.ts +14 -0
  283. package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
  284. package/esm/types/simple/room/Stream.d.ts +13 -0
  285. package/esm/types/simple/room/Stream.d.ts.map +1 -0
  286. package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  287. package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  288. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  289. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  290. package/esm/types/simple/utils.d.ts +3 -0
  291. package/esm/types/simple/utils.d.ts.map +1 -0
  292. package/esm/types/types/WebSocketMessage.d.ts +285 -0
  293. package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
  294. package/esm/types/utils/Emitter.d.ts +18 -0
  295. package/esm/types/utils/Emitter.d.ts.map +1 -0
  296. package/esm/types/utils/Heartbeat.d.ts +21 -0
  297. package/esm/types/utils/Heartbeat.d.ts.map +1 -0
  298. package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
  299. package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  300. package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  301. package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  302. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  303. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  304. package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
  305. package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  306. package/esm/types/utils/__tests__/array.test.d.ts +2 -0
  307. package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
  308. package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
  309. package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  310. package/esm/types/utils/__tests__/object.test.d.ts +2 -0
  311. package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
  312. package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
  313. package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  314. package/esm/types/utils/__tests__/string.test.d.ts +2 -0
  315. package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
  316. package/esm/types/utils/api-requester.d.ts +45 -0
  317. package/esm/types/utils/api-requester.d.ts.map +1 -0
  318. package/esm/types/utils/array.d.ts +2 -0
  319. package/esm/types/utils/array.d.ts.map +1 -0
  320. package/esm/types/utils/compare-version.d.ts +3 -0
  321. package/esm/types/utils/compare-version.d.ts.map +1 -0
  322. package/esm/types/utils/isMobile.d.ts +3 -0
  323. package/esm/types/utils/isMobile.d.ts.map +1 -0
  324. package/esm/types/utils/new-from.d.ts +3 -0
  325. package/esm/types/utils/new-from.d.ts.map +1 -0
  326. package/esm/types/utils/object.d.ts +2 -0
  327. package/esm/types/utils/object.d.ts.map +1 -0
  328. package/esm/types/utils/once.d.ts +2 -0
  329. package/esm/types/utils/once.d.ts.map +1 -0
  330. package/esm/types/utils/sdp.d.ts +13 -0
  331. package/esm/types/utils/sdp.d.ts.map +1 -0
  332. package/esm/types/utils/string.d.ts +2 -0
  333. package/esm/types/utils/string.d.ts.map +1 -0
  334. package/esm/types/utils/update-from.d.ts +3 -0
  335. package/esm/types/utils/update-from.d.ts.map +1 -0
  336. package/esm/types/utils/webrtc.d.ts +15 -0
  337. package/esm/types/utils/webrtc.d.ts.map +1 -0
  338. package/esm/types/web-rtc-client.d.ts +220 -0
  339. package/esm/types/web-rtc-client.d.ts.map +1 -0
  340. package/esm/types/websocket-client.d.ts +134 -0
  341. package/esm/types/websocket-client.d.ts.map +1 -0
  342. package/esm/utils/Emitter.js +17 -27
  343. package/esm/utils/Heartbeat.js +60 -83
  344. package/esm/utils/PhoneNumberUtil.js +48 -63
  345. package/esm/utils/__tests__/Heartbeat.test.js +59 -168
  346. package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
  347. package/esm/utils/__tests__/api-requester.test.js +127 -780
  348. package/esm/utils/__tests__/array.test.js +16 -19
  349. package/esm/utils/__tests__/compare-version.test.js +8 -26
  350. package/esm/utils/__tests__/object.test.js +73 -54
  351. package/esm/utils/__tests__/sdp.test.js +87 -216
  352. package/esm/utils/__tests__/string.test.js +21 -27
  353. package/esm/utils/api-requester.js +197 -675
  354. package/esm/utils/array.js +7 -11
  355. package/esm/utils/compare-version.js +12 -15
  356. package/esm/utils/isMobile.js +0 -2
  357. package/esm/utils/new-from.js +7 -12
  358. package/esm/utils/object.js +9 -23
  359. package/esm/utils/once.js +12 -13
  360. package/esm/utils/sdp.js +87 -131
  361. package/esm/utils/string.js +5 -9
  362. package/esm/utils/update-from.js +9 -16
  363. package/esm/utils/webrtc.js +35 -36
  364. package/esm/web-rtc-client.js +2038 -7677
  365. package/esm/websocket-client.js +352 -944
  366. package/lib/__tests__/api-client.test.js +199 -5067
  367. package/lib/__tests__/web-rtc-client.test.js +191 -7941
  368. package/lib/api/agentd.js +27 -837
  369. package/lib/api/amid.js +18 -415
  370. package/lib/api/application.js +64 -834
  371. package/lib/api/auth.js +166 -1222
  372. package/lib/api/call-logd.js +28 -738
  373. package/lib/api/calld.js +126 -1473
  374. package/lib/api/chatd.js +65 -1316
  375. package/lib/api/confd.js +79 -1584
  376. package/lib/api/ctid-ng.js +96 -1348
  377. package/lib/api/dird.js +105 -1596
  378. package/lib/api/webhookd.js +11 -518
  379. package/lib/api-client.js +139 -4884
  380. package/lib/checker/Checker.js +61 -8739
  381. package/lib/checker/checks/aor.js +37 -4929
  382. package/lib/checker/checks/api.js +81 -4971
  383. package/lib/checker/checks/ice-ipv4.js +66 -118
  384. package/lib/checker/checks/index.js +13 -8687
  385. package/lib/checker/checks/symmetric-nat.js +56 -104
  386. package/lib/checker/checks/wazo-websocket.js +58 -1006
  387. package/lib/checker/checks/webrtc-transport.js +41 -7853
  388. package/lib/checker/checks/webrtc.js +42 -7858
  389. package/lib/domain/AdHocAPIConference.js +80 -5116
  390. package/lib/domain/Agent.js +23 -64
  391. package/lib/domain/BadResponse.js +17 -44
  392. package/lib/domain/Call.js +108 -215
  393. package/lib/domain/CallLog.js +117 -311
  394. package/lib/domain/CallSession.js +221 -424
  395. package/lib/domain/ChatMessage.js +49 -110
  396. package/lib/domain/ChatRoom.js +28 -60
  397. package/lib/domain/Contact.js +409 -742
  398. package/lib/domain/Country.js +19 -21
  399. package/lib/domain/Device/DebugDevice.js +34 -49
  400. package/lib/domain/Device/Device.js +2 -2
  401. package/lib/domain/DirectorySource.js +2 -2
  402. package/lib/domain/ExternalApp.js +24 -56
  403. package/lib/domain/Features.js +68 -5018
  404. package/lib/domain/ForwardOption.js +36 -71
  405. package/lib/domain/IndirectTransfer.js +39 -98
  406. package/lib/domain/Line.js +35 -88
  407. package/lib/domain/Meeting.js +51 -118
  408. package/lib/domain/MeetingAuthorization.js +35 -75
  409. package/lib/domain/MeetingStatus.js +13 -29
  410. package/lib/domain/NotificationOptions.js +45 -77
  411. package/lib/domain/Phone/CTIPhone.js +283 -5755
  412. package/lib/domain/Phone/Phone.js +2 -5
  413. package/lib/domain/Phone/WebRTCPhone.js +1457 -2716
  414. package/lib/domain/Profile.js +127 -406
  415. package/lib/domain/Recording.js +28 -57
  416. package/lib/domain/Relocation.js +15 -43
  417. package/lib/domain/Room.js +73 -134
  418. package/lib/domain/SFUNotAvailableError.js +7 -9
  419. package/lib/domain/ServerError.js +14 -63
  420. package/lib/domain/Session.js +118 -251
  421. package/lib/domain/SipLine.js +70 -155
  422. package/lib/domain/Subscription.js +32 -86
  423. package/lib/domain/SwitchboardCall.js +45 -145
  424. package/lib/domain/Voicemail.js +56 -127
  425. package/lib/domain/__tests__/Agent.test.js +36 -103
  426. package/lib/domain/__tests__/Call.test.js +28 -237
  427. package/lib/domain/__tests__/CallLog.test.js +65 -392
  428. package/lib/domain/__tests__/CallSession.test.js +78 -503
  429. package/lib/domain/__tests__/Contact.test.js +224 -903
  430. package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
  431. package/lib/domain/__tests__/Line.test.js +52 -157
  432. package/lib/domain/__tests__/Meeting.test.js +78 -232
  433. package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
  434. package/lib/domain/__tests__/Profile.test.js +161 -496
  435. package/lib/domain/__tests__/Room.test.js +239 -719
  436. package/lib/domain/__tests__/Session.test.js +350 -1024
  437. package/lib/domain/__tests__/SipLine.test.js +28 -180
  438. package/lib/domain/__tests__/Voicemail.test.js +86 -205
  439. package/lib/domain/types.js +2 -2
  440. package/lib/index.js +105 -15010
  441. package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
  442. package/lib/pubkey.js +12 -0
  443. package/lib/service/CallApi.js +88 -5015
  444. package/lib/service/IssueReporter.js +264 -366
  445. package/lib/service/__tests__/IssueReporter.test.js +97 -500
  446. package/lib/service/getApiClient.js +70 -4990
  447. package/lib/simple/Auth.js +272 -14777
  448. package/lib/simple/Configuration.js +23 -14805
  449. package/lib/simple/Directory.js +18 -4966
  450. package/lib/simple/Phone.js +345 -14746
  451. package/lib/simple/Websocket.js +98 -1117
  452. package/lib/simple/index.js +151 -14800
  453. package/lib/simple/room/LocalParticipant.js +7 -14808
  454. package/lib/simple/room/Participant.js +269 -14778
  455. package/lib/simple/room/RemoteParticipant.js +11 -14806
  456. package/lib/simple/room/Room.js +655 -14761
  457. package/lib/simple/room/SipRoom.js +136 -14805
  458. package/lib/simple/room/Stream.js +43 -14802
  459. package/lib/simple/room/__tests__/Participant.test.js +79 -14879
  460. package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14814
  461. package/lib/simple/utils.js +22 -14808
  462. package/lib/types/WebSocketMessage.js +2 -4
  463. package/lib/types/__tests__/api-client.test.d.ts +2 -0
  464. package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
  465. package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
  466. package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  467. package/lib/types/api/agentd.d.ts +17 -0
  468. package/lib/types/api/agentd.d.ts.map +1 -0
  469. package/lib/types/api/amid.d.ts +8 -0
  470. package/lib/types/api/amid.d.ts.map +1 -0
  471. package/lib/types/api/application.d.ts +34 -0
  472. package/lib/types/api/application.d.ts.map +1 -0
  473. package/lib/types/api/auth.d.ts +64 -0
  474. package/lib/types/api/auth.d.ts.map +1 -0
  475. package/lib/types/api/call-logd.d.ts +12 -0
  476. package/lib/types/api/call-logd.d.ts.map +1 -0
  477. package/lib/types/api/calld.d.ts +51 -0
  478. package/lib/types/api/calld.d.ts.map +1 -0
  479. package/lib/types/api/chatd.d.ts +42 -0
  480. package/lib/types/api/chatd.d.ts.map +1 -0
  481. package/lib/types/api/confd.d.ts +39 -0
  482. package/lib/types/api/confd.d.ts.map +1 -0
  483. package/lib/types/api/ctid-ng.d.ts +36 -0
  484. package/lib/types/api/ctid-ng.d.ts.map +1 -0
  485. package/lib/types/api/dird.d.ts +38 -0
  486. package/lib/types/api/dird.d.ts.map +1 -0
  487. package/lib/types/api/webhookd.d.ts +24 -0
  488. package/lib/types/api/webhookd.d.ts.map +1 -0
  489. package/lib/types/api-client.d.ts +63 -0
  490. package/lib/types/api-client.d.ts.map +1 -0
  491. package/lib/types/checker/Checker.d.ts +13 -0
  492. package/lib/types/checker/Checker.d.ts.map +1 -0
  493. package/lib/types/checker/checks/aor.d.ts +6 -0
  494. package/lib/types/checker/checks/aor.d.ts.map +1 -0
  495. package/lib/types/checker/checks/api.d.ts +6 -0
  496. package/lib/types/checker/checks/api.d.ts.map +1 -0
  497. package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
  498. package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  499. package/lib/types/checker/checks/index.d.ts +9 -0
  500. package/lib/types/checker/checks/index.d.ts.map +1 -0
  501. package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
  502. package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  503. package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
  504. package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  505. package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
  506. package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  507. package/lib/types/checker/checks/webrtc.d.ts +6 -0
  508. package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
  509. package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
  510. package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
  511. package/lib/types/domain/Agent.d.ts +31 -0
  512. package/lib/types/domain/Agent.d.ts.map +1 -0
  513. package/lib/types/domain/BadResponse.d.ts +11 -0
  514. package/lib/types/domain/BadResponse.d.ts.map +1 -0
  515. package/lib/types/domain/Call.d.ts +79 -0
  516. package/lib/types/domain/Call.d.ts.map +1 -0
  517. package/lib/types/domain/CallLog.d.ts +91 -0
  518. package/lib/types/domain/CallLog.d.ts.map +1 -0
  519. package/lib/types/domain/CallSession.d.ts +120 -0
  520. package/lib/types/domain/CallSession.d.ts.map +1 -0
  521. package/lib/types/domain/ChatMessage.d.ts +41 -0
  522. package/lib/types/domain/ChatMessage.d.ts.map +1 -0
  523. package/lib/types/domain/ChatRoom.d.ts +22 -0
  524. package/lib/types/domain/ChatRoom.d.ts.map +1 -0
  525. package/lib/types/domain/Contact.d.ts +316 -0
  526. package/lib/types/domain/Contact.d.ts.map +1 -0
  527. package/lib/types/domain/Country.d.ts +20 -0
  528. package/lib/types/domain/Country.d.ts.map +1 -0
  529. package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
  530. package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
  531. package/lib/types/domain/Device/Device.d.ts +13 -0
  532. package/lib/types/domain/Device/Device.d.ts.map +1 -0
  533. package/lib/types/domain/DirectorySource.d.ts +13 -0
  534. package/lib/types/domain/DirectorySource.d.ts.map +1 -0
  535. package/lib/types/domain/ExternalApp.d.ts +22 -0
  536. package/lib/types/domain/ExternalApp.d.ts.map +1 -0
  537. package/lib/types/domain/Features.d.ts +24 -0
  538. package/lib/types/domain/Features.d.ts.map +1 -0
  539. package/lib/types/domain/ForwardOption.d.ts +27 -0
  540. package/lib/types/domain/ForwardOption.d.ts.map +1 -0
  541. package/lib/types/domain/IndirectTransfer.d.ts +31 -0
  542. package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
  543. package/lib/types/domain/Line.d.ts +46 -0
  544. package/lib/types/domain/Line.d.ts.map +1 -0
  545. package/lib/types/domain/Meeting.d.ts +45 -0
  546. package/lib/types/domain/Meeting.d.ts.map +1 -0
  547. package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
  548. package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
  549. package/lib/types/domain/MeetingStatus.d.ts +10 -0
  550. package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
  551. package/lib/types/domain/NotificationOptions.d.ts +22 -0
  552. package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
  553. package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
  554. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  555. package/lib/types/domain/Phone/Phone.d.ts +71 -0
  556. package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
  557. package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  558. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  559. package/lib/types/domain/Profile.d.ts +151 -0
  560. package/lib/types/domain/Profile.d.ts.map +1 -0
  561. package/lib/types/domain/Recording.d.ts +26 -0
  562. package/lib/types/domain/Recording.d.ts.map +1 -0
  563. package/lib/types/domain/Relocation.d.ts +23 -0
  564. package/lib/types/domain/Relocation.d.ts.map +1 -0
  565. package/lib/types/domain/Room.d.ts +35 -0
  566. package/lib/types/domain/Room.d.ts.map +1 -0
  567. package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
  568. package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  569. package/lib/types/domain/ServerError.d.ts +6 -0
  570. package/lib/types/domain/ServerError.d.ts.map +1 -0
  571. package/lib/types/domain/Session.d.ts +90 -0
  572. package/lib/types/domain/Session.d.ts.map +1 -0
  573. package/lib/types/domain/SipLine.d.ts +54 -0
  574. package/lib/types/domain/SipLine.d.ts.map +1 -0
  575. package/lib/types/domain/Subscription.d.ts +43 -0
  576. package/lib/types/domain/Subscription.d.ts.map +1 -0
  577. package/lib/types/domain/SwitchboardCall.d.ts +62 -0
  578. package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
  579. package/lib/types/domain/Voicemail.d.ts +50 -0
  580. package/lib/types/domain/Voicemail.d.ts.map +1 -0
  581. package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
  582. package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  583. package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
  584. package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
  585. package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
  586. package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  587. package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
  588. package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  589. package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
  590. package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  591. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  592. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  593. package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
  594. package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
  595. package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
  596. package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  597. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  598. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  599. package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
  600. package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  601. package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
  602. package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
  603. package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
  604. package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
  605. package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
  606. package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  607. package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  608. package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  609. package/lib/types/domain/types.d.ts +217 -0
  610. package/lib/types/domain/types.d.ts.map +1 -0
  611. package/lib/types/index.d.ts +304 -0
  612. package/lib/types/index.d.ts.map +1 -0
  613. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  614. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  615. package/lib/types/pubkey.d.ts +3 -0
  616. package/lib/types/pubkey.d.ts.map +1 -0
  617. package/lib/types/service/CallApi.d.ts +28 -0
  618. package/lib/types/service/CallApi.d.ts.map +1 -0
  619. package/lib/types/service/IssueReporter.d.ts +40 -0
  620. package/lib/types/service/IssueReporter.d.ts.map +1 -0
  621. package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  622. package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  623. package/lib/types/service/getApiClient.d.ts +16 -0
  624. package/lib/types/service/getApiClient.d.ts.map +1 -0
  625. package/lib/types/simple/Auth.d.ts +51 -0
  626. package/lib/types/simple/Auth.d.ts.map +1 -0
  627. package/lib/types/simple/Configuration.d.ts +3 -0
  628. package/lib/types/simple/Configuration.d.ts.map +1 -0
  629. package/lib/types/simple/Directory.d.ts +3 -0
  630. package/lib/types/simple/Directory.d.ts.map +1 -0
  631. package/lib/types/simple/Phone.d.ts +115 -0
  632. package/lib/types/simple/Phone.d.ts.map +1 -0
  633. package/lib/types/simple/Websocket.d.ts +19 -0
  634. package/lib/types/simple/Websocket.d.ts.map +1 -0
  635. package/lib/types/simple/index.d.ts +147 -0
  636. package/lib/types/simple/index.d.ts.map +1 -0
  637. package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
  638. package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
  639. package/lib/types/simple/room/Participant.d.ts +76 -0
  640. package/lib/types/simple/room/Participant.d.ts.map +1 -0
  641. package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
  642. package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  643. package/lib/types/simple/room/Room.d.ts +116 -0
  644. package/lib/types/simple/room/Room.d.ts.map +1 -0
  645. package/lib/types/simple/room/SipRoom.d.ts +14 -0
  646. package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
  647. package/lib/types/simple/room/Stream.d.ts +13 -0
  648. package/lib/types/simple/room/Stream.d.ts.map +1 -0
  649. package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  650. package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  651. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  652. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  653. package/lib/types/simple/utils.d.ts +3 -0
  654. package/lib/types/simple/utils.d.ts.map +1 -0
  655. package/lib/types/types/WebSocketMessage.d.ts +285 -0
  656. package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
  657. package/lib/types/utils/Emitter.d.ts +18 -0
  658. package/lib/types/utils/Emitter.d.ts.map +1 -0
  659. package/lib/types/utils/Heartbeat.d.ts +21 -0
  660. package/lib/types/utils/Heartbeat.d.ts.map +1 -0
  661. package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
  662. package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  663. package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  664. package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  665. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  666. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  667. package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
  668. package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  669. package/lib/types/utils/__tests__/array.test.d.ts +2 -0
  670. package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
  671. package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
  672. package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  673. package/lib/types/utils/__tests__/object.test.d.ts +2 -0
  674. package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
  675. package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
  676. package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  677. package/lib/types/utils/__tests__/string.test.d.ts +2 -0
  678. package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
  679. package/lib/types/utils/api-requester.d.ts +45 -0
  680. package/lib/types/utils/api-requester.d.ts.map +1 -0
  681. package/lib/types/utils/array.d.ts +2 -0
  682. package/lib/types/utils/array.d.ts.map +1 -0
  683. package/lib/types/utils/compare-version.d.ts +3 -0
  684. package/lib/types/utils/compare-version.d.ts.map +1 -0
  685. package/lib/types/utils/isMobile.d.ts +3 -0
  686. package/lib/types/utils/isMobile.d.ts.map +1 -0
  687. package/lib/types/utils/new-from.d.ts +3 -0
  688. package/lib/types/utils/new-from.d.ts.map +1 -0
  689. package/lib/types/utils/object.d.ts +2 -0
  690. package/lib/types/utils/object.d.ts.map +1 -0
  691. package/lib/types/utils/once.d.ts +2 -0
  692. package/lib/types/utils/once.d.ts.map +1 -0
  693. package/lib/types/utils/sdp.d.ts +13 -0
  694. package/lib/types/utils/sdp.d.ts.map +1 -0
  695. package/lib/types/utils/string.d.ts +2 -0
  696. package/lib/types/utils/string.d.ts.map +1 -0
  697. package/lib/types/utils/update-from.d.ts +3 -0
  698. package/lib/types/utils/update-from.d.ts.map +1 -0
  699. package/lib/types/utils/webrtc.d.ts +15 -0
  700. package/lib/types/utils/webrtc.d.ts.map +1 -0
  701. package/lib/types/web-rtc-client.d.ts +220 -0
  702. package/lib/types/web-rtc-client.d.ts.map +1 -0
  703. package/lib/types/websocket-client.d.ts +134 -0
  704. package/lib/types/websocket-client.d.ts.map +1 -0
  705. package/lib/utils/Emitter.js +22 -33
  706. package/lib/utils/Heartbeat.js +54 -86
  707. package/lib/utils/PhoneNumberUtil.js +60 -77
  708. package/lib/utils/__tests__/Heartbeat.test.js +73 -170
  709. package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
  710. package/lib/utils/__tests__/api-requester.test.js +139 -784
  711. package/lib/utils/__tests__/array.test.js +18 -21
  712. package/lib/utils/__tests__/compare-version.test.js +12 -27
  713. package/lib/utils/__tests__/object.test.js +75 -56
  714. package/lib/utils/__tests__/sdp.test.js +99 -220
  715. package/lib/utils/__tests__/string.test.js +23 -29
  716. package/lib/utils/api-requester.js +191 -685
  717. package/lib/utils/array.js +10 -14
  718. package/lib/utils/compare-version.js +15 -18
  719. package/lib/utils/isMobile.js +3 -5
  720. package/lib/utils/new-from.js +9 -14
  721. package/lib/utils/object.js +12 -26
  722. package/lib/utils/once.js +15 -15
  723. package/lib/utils/sdp.js +97 -150
  724. package/lib/utils/string.js +8 -12
  725. package/lib/utils/update-from.js +11 -18
  726. package/lib/utils/webrtc.js +38 -39
  727. package/lib/web-rtc-client.js +2070 -7694
  728. package/lib/websocket-client.js +357 -1021
  729. package/package.json +41 -34
  730. package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
  731. package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
  732. package/src/api/agentd.ts +37 -0
  733. package/src/api/amid.ts +16 -0
  734. package/src/api/application.ts +96 -0
  735. package/src/api/auth.ts +259 -0
  736. package/src/api/call-logd.ts +38 -0
  737. package/src/api/calld.ts +183 -0
  738. package/src/api/chatd.ts +101 -0
  739. package/src/api/confd.ts +110 -0
  740. package/src/api/ctid-ng.ts +152 -0
  741. package/src/api/dird.ts +146 -0
  742. package/src/api/webhookd.ts +30 -0
  743. package/src/{api-client.js → api-client.ts} +103 -67
  744. package/src/checker/{Checker.js → Checker.ts} +27 -20
  745. package/src/checker/checks/{aor.js → aor.ts} +10 -6
  746. package/src/checker/checks/{api.js → api.ts} +18 -17
  747. package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
  748. package/src/checker/checks/{index.js → index.ts} +1 -9
  749. package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
  750. package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
  751. package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
  752. package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
  753. package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
  754. package/src/domain/{Agent.js → Agent.ts} +11 -7
  755. package/src/domain/BadResponse.ts +29 -0
  756. package/src/domain/{Call.js → Call.ts} +62 -46
  757. package/src/domain/{CallLog.js → CallLog.ts} +61 -63
  758. package/src/domain/{CallSession.js → CallSession.ts} +55 -52
  759. package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
  760. package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
  761. package/src/domain/{Contact.js → Contact.ts} +380 -262
  762. package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
  763. package/src/domain/Device/{Device.js → Device.ts} +0 -11
  764. package/src/domain/DirectorySource.ts +13 -0
  765. package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
  766. package/src/domain/{Features.js → Features.ts} +43 -17
  767. package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
  768. package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
  769. package/src/domain/{Line.js → Line.ts} +39 -26
  770. package/src/domain/{Meeting.js → Meeting.ts} +36 -29
  771. package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
  772. package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
  773. package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
  774. package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
  775. package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
  776. package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +456 -422
  777. package/src/domain/{Profile.js → Profile.ts} +117 -100
  778. package/src/domain/{Recording.js → Recording.ts} +25 -16
  779. package/src/domain/{Relocation.js → Relocation.ts} +15 -14
  780. package/src/domain/{Room.js → Room.ts} +58 -27
  781. package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
  782. package/src/domain/ServerError.ts +12 -0
  783. package/src/domain/{Session.js → Session.ts} +89 -67
  784. package/src/domain/{SipLine.js → SipLine.ts} +52 -45
  785. package/src/domain/{Subscription.js → Subscription.ts} +22 -13
  786. package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
  787. package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
  788. package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
  789. package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
  790. package/src/domain/__tests__/CallLog.test.ts +65 -0
  791. package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
  792. package/src/domain/__tests__/Contact.test.ts +238 -0
  793. package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
  794. package/src/domain/__tests__/Line.test.ts +53 -0
  795. package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
  796. package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
  797. package/src/domain/__tests__/Profile.test.ts +139 -0
  798. package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
  799. package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
  800. package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
  801. package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
  802. package/src/domain/types.ts +227 -0
  803. package/src/{index.js → index.ts} +4 -28
  804. package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
  805. package/{config.js → src/pubkey.ts} +3 -3
  806. package/src/service/{CallApi.js → CallApi.ts} +14 -18
  807. package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
  808. package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
  809. package/src/service/getApiClient.ts +94 -0
  810. package/src/simple/{Auth.js → Auth.ts} +130 -101
  811. package/src/simple/{Configuration.js → Configuration.ts} +2 -3
  812. package/src/simple/{Directory.js → Directory.ts} +2 -3
  813. package/src/simple/Phone.ts +623 -0
  814. package/src/simple/Websocket.ts +119 -0
  815. package/src/simple/{index.js → index.ts} +51 -21
  816. package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
  817. package/src/simple/room/{Participant.js → Participant.ts} +108 -46
  818. package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
  819. package/src/simple/room/{Room.js → Room.ts} +266 -183
  820. package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
  821. package/src/simple/room/{Stream.js → Stream.ts} +8 -6
  822. package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
  823. package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
  824. package/src/simple/utils.ts +12 -0
  825. package/src/types/WebSocketMessage.ts +335 -0
  826. package/src/types/global.d.ts +26 -0
  827. package/src/utils/Emitter.ts +34 -0
  828. package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
  829. package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
  830. package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
  831. package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
  832. package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
  833. package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
  834. package/src/utils/__tests__/object.test.ts +77 -0
  835. package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
  836. package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
  837. package/src/utils/{api-requester.js → api-requester.ts} +104 -83
  838. package/src/utils/{array.js → array.ts} +2 -2
  839. package/src/utils/{compare-version.js → compare-version.ts} +3 -2
  840. package/src/utils/{isMobile.js → isMobile.ts} +1 -1
  841. package/src/utils/{new-from.js → new-from.ts} +3 -6
  842. package/src/utils/{object.js → object.ts} +3 -6
  843. package/src/utils/{once.js → once.ts} +5 -5
  844. package/src/utils/sdp.ts +119 -0
  845. package/src/utils/{string.js → string.ts} +2 -3
  846. package/src/utils/update-from.ts +11 -0
  847. package/src/utils/{webrtc.js → webrtc.ts} +21 -3
  848. package/src/{web-rtc-client.js → web-rtc-client.ts} +879 -476
  849. package/src/{websocket-client.js → websocket-client.ts} +146 -144
  850. package/esm/simple/Softphone.js +0 -394
  851. package/lib/simple/Softphone.js +0 -396
  852. package/src/api/agentd.js +0 -74
  853. package/src/api/amid.js +0 -13
  854. package/src/api/application.js +0 -137
  855. package/src/api/auth.js +0 -279
  856. package/src/api/call-logd.js +0 -20
  857. package/src/api/calld.js +0 -214
  858. package/src/api/chatd.js +0 -80
  859. package/src/api/confd.js +0 -127
  860. package/src/api/ctid-ng.js +0 -153
  861. package/src/api/dird.js +0 -159
  862. package/src/api/webhookd.js +0 -31
  863. package/src/domain/BadResponse.js +0 -42
  864. package/src/domain/DirectorySource.js +0 -16
  865. package/src/domain/ServerError.js +0 -18
  866. package/src/domain/__tests__/CallLog.test.js +0 -75
  867. package/src/domain/__tests__/Contact.test.js +0 -170
  868. package/src/domain/__tests__/Line.test.js +0 -73
  869. package/src/domain/__tests__/Profile.test.js +0 -104
  870. package/src/domain/types.js +0 -248
  871. package/src/lib/WazoSessionDescriptionHandler.js +0 -467
  872. package/src/service/getApiClient.js +0 -122
  873. package/src/simple/Phone.js +0 -425
  874. package/src/simple/Softphone.js +0 -392
  875. package/src/simple/Websocket.js +0 -86
  876. package/src/simple/utils.js +0 -17
  877. package/src/types/WebSocketMessage.js +0 -232
  878. package/src/utils/Emitter.js +0 -26
  879. package/src/utils/__tests__/object.test.js +0 -35
  880. package/src/utils/sdp.js +0 -140
  881. package/src/utils/update-from.js +0 -15
  882. /package/src/domain/{Country.js → Country.ts} +0 -0
  883. /package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
@@ -1,4893 +1,11 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsBase64 = require('js-base64');
6
- var moment = require('moment');
7
- var jsrsasign = require('jsrsasign');
8
- require('sip.js/lib/api/session-state');
9
- require('events');
10
- var jsonToGraphQLQuery = require('json-to-graphql-query/lib/jsonToGraphQLQuery');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
15
-
16
- /* */
17
-
18
- class BadResponse extends Error {
19
- static fromResponse(error , status ) {
20
- return new BadResponse(
21
- error.message || JSON.stringify(error),
22
- status,
23
- error.timestamp,
24
- error.error_id,
25
- error.details,
26
- error,
27
- );
28
- }
29
-
30
- static fromText(response , status ) {
31
- return new BadResponse(response, status);
32
- }
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- constructor(
42
- message ,
43
- status ,
44
- timestamp = null,
45
- errorId = null,
46
- details = null,
47
- error = null,
48
- ) {
49
- super(message);
50
-
51
- this.timestamp = timestamp;
52
- this.status = status;
53
- this.errorId = errorId;
54
- this.details = details;
55
- this.error = error;
56
- }
57
- }
58
-
59
- /* */
60
-
61
- class ServerError extends BadResponse {
62
- static fromResponse(error , status ) {
63
- return new ServerError(
64
- error.message || JSON.stringify(error),
65
- status,
66
- error.timestamp,
67
- error.error_id,
68
- error.details,
69
- );
70
- }
71
-
72
- static fromText(response , status ) {
73
- return new ServerError(response, status);
74
- }
75
- }
76
-
77
- /* */
78
- /* global navigator */
79
- const isMobile = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
80
-
81
- /* global window */
82
-
83
- const TRACE = 'trace';
84
- const DEBUG = 'debug';
85
- const INFO = 'info';
86
- const LOG = 'log';
87
- const WARN = 'warn';
88
- const ERROR = 'error';
89
- const CONSOLE_METHODS = [INFO, LOG, WARN, ERROR];
90
- const LOG_LEVELS = [TRACE, DEBUG, INFO, LOG, WARN, ERROR];
91
- const CATEGORY_PREFIX = 'logger-category=';
92
-
93
- const MAX_REMOTE_RETRY = 100;
94
-
95
- const addLevelsTo = (instance , withMethods = false) => {
96
- instance.TRACE = TRACE;
97
- instance.DEBUG = DEBUG;
98
- instance.INFO = INFO;
99
- instance.LOG = LOG;
100
- instance.WARN = WARN;
101
- instance.ERROR = ERROR;
102
-
103
- if (withMethods) {
104
- instance.trace = (...args) => instance.apply(null, [TRACE, ...args]);
105
- instance.debug = (...args) => instance.apply(null, [DEBUG, ...args]);
106
- instance.info = (...args) => instance.apply(null, [INFO, ...args]);
107
- instance.log = (...args) => instance.apply(null, [LOG, ...args]);
108
- instance.warn = (...args) => instance.apply(null, [WARN, ...args]);
109
- instance.error = (...args) => instance.apply(null, [ERROR, ...args]);
110
- }
111
-
112
- return instance;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
113
4
  };
114
-
115
- const safeStringify = (object ) => {
116
- const result = '{"message": "Not parsable JSON"}';
117
- try {
118
- return JSON.stringify(object);
119
- } catch (e) {
120
- // Nothing to do
121
- }
122
-
123
- return result;
124
- };
125
-
126
- class IssueReporter {
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
- constructor() {
144
- addLevelsTo(this);
145
-
146
- this.oldConsoleMethods = null;
147
- this.enabled = false;
148
- this.remoteClientConfiguration = null;
149
- this.buffer = [];
150
- this.bufferTimeout = null;
151
- this._boundProcessBuffer = this._processBuffer.bind(this);
152
- this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
153
- this._callback = null;
154
- }
155
-
156
- init() {
157
- this._catchConsole();
158
- }
159
-
160
- setCallback(cb ) {
161
- this._callback = cb;
162
- }
163
-
164
- configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
165
- this.remoteClientConfiguration = configuration;
166
- }
167
-
168
- enable() {
169
- if (!this.oldConsoleMethods) {
170
- this.init();
171
- }
172
-
173
- this.enabled = true;
174
- }
175
-
176
- disable() {
177
- this.enabled = false;
178
- }
179
-
180
- loggerFor(category ) {
181
- const logger = (level , ...args ) => {
182
- this.log.apply(this, [level, this._makeCategory(category), ...args]);
183
- };
184
-
185
- return addLevelsTo(logger, true);
186
- }
187
-
188
- removeSlashes(str ) {
189
- return str.replace(/"/g, "'").replace(/\\/g, '');
190
- }
191
-
192
- log(level , ...args ) {
193
- if (!this.enabled) {
194
- return;
195
- }
196
-
197
- // Handle category label
198
- let category = null;
199
- let skipSendToRemote = false;
200
- let extra = {};
201
- if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
202
- category = args[0].split('=')[1];
203
- // eslint-disable-next-line no-param-reassign
204
- args.splice(0, 1);
205
- }
206
-
207
- // Handle extra data as object for the last argument
208
- const lastArg = args[args.length - 1];
209
- if (lastArg && ((typeof lastArg === 'object' && Object.keys(lastArg).length) || lastArg instanceof Error)) {
210
- if (lastArg instanceof Error) {
211
- extra = {
212
- errorMessage: lastArg.message,
213
- errorStack: lastArg.stack,
214
- errorType: lastArg.constructor.name,
215
- skipSendToRemote: lastArg.skipSendToRemote,
216
- };
217
- } else {
218
- extra = lastArg;
219
- }
220
- // eslint-disable-next-line no-param-reassign
221
- args.splice(1, 1);
222
- }
223
-
224
- if (extra.skipSendToRemote) {
225
- skipSendToRemote = true;
226
- delete extra.skipSendToRemote;
227
- }
228
-
229
- const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
230
- const message = args.join(', ');
231
- let consoleMessage = message;
232
-
233
- if (Object.keys(extra).length) {
234
- const parsedExtra = safeStringify(extra);
235
- consoleMessage = `${consoleMessage} (${parsedExtra})`;
236
- }
237
-
238
- if (category) {
239
- consoleMessage = `[${category}] ${consoleMessage}`;
240
- }
241
-
242
- // Log the message in the console anyway (but don't console.error on mobile)
243
- const consoleLevel = isMobile() && level === 'error' ? WARN : level;
244
-
245
- // eslint-disable-next-line
246
- const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
247
- oldMethod.apply(oldMethod, [date, consoleMessage]);
248
-
249
- if (this._callback) {
250
- this._callback(level, consoleMessage);
251
- }
252
-
253
- if (!skipSendToRemote) {
254
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
255
- }
256
- }
257
-
258
- logRequest(url , options , response , start ) {
259
- if (!this.enabled) {
260
- return;
261
- }
262
- const { status } = response;
263
- const duration = new Date() - start;
264
-
265
- let level = TRACE;
266
- if (status >= 400 && status < 500) {
267
- level = WARN;
268
- } else if (status >= 500) {
269
- level = ERROR;
270
- }
271
-
272
- this.log(level, this._makeCategory('http'), url, {
273
- status,
274
- body: this.removeSlashes(JSON.stringify(options.body)),
275
- method: options.method,
276
- headers: options.headers,
277
- duration,
278
- });
279
- }
280
-
281
- // Logs aren't stored anymore
282
- getLogs() {
283
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
284
- return [];
285
- }
286
-
287
- getParsedLogs() {
288
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
289
- return [];
290
- }
291
-
292
- getReport() {
293
- return this.getParsedLogs().join('\r\n');
294
- }
295
-
296
- _catchConsole() {
297
- this.oldConsoleMethods = {};
298
- CONSOLE_METHODS.forEach((methodName ) => {
299
- // eslint-disable-next-line
300
- this.oldConsoleMethods[methodName] = console[methodName];
301
- window.console[methodName] = (...args) => {
302
- // Store message
303
- try {
304
- this.log(methodName, args.join(' '));
305
- // Use old console method to log it normally
306
- this.oldConsoleMethods[methodName].apply(null, args);
307
- } catch (e) {
308
- // Avoid circular structure issues
309
- }
310
- };
311
- });
312
- }
313
-
314
- _sendToRemoteLogger(level , payload = {}) {
315
- if (!this.remoteClientConfiguration) {
316
- return;
317
- }
318
-
319
- const { level: minLevel, bufferSize } = this.remoteClientConfiguration;
320
- if (!minLevel || this._isLevelAbove(minLevel, level)) {
321
- return;
322
- }
323
-
324
- payload.level = level;
325
-
326
- if (bufferSize > 0) {
327
- return this._addToBuffer(payload);
328
- }
329
-
330
- this._sendDebugToGrafana(payload);
331
- }
332
-
333
- _parseLoggerBody(payload ) {
334
- const { level } = payload;
335
- const { maxMessageSize, extra } = this.remoteClientConfiguration || {};
336
-
337
- delete payload.level;
338
-
339
- if (maxMessageSize && typeof payload.message === 'string' && payload.message.length > maxMessageSize) {
340
- payload.message = `${payload.message.substr(0, maxMessageSize)}...`;
341
- }
342
-
343
- return safeStringify({
344
- level,
345
- ...payload,
346
- ...extra,
347
- });
348
- }
349
-
350
- _addToBuffer(payload ) {
351
- // Reset buffer timer
352
- if (this.bufferTimeout) {
353
- clearTimeout(this.bufferTimeout);
354
- this.bufferTimeout = null;
355
- }
356
-
357
- this.buffer.push(payload);
358
-
359
- // $FlowFixMe
360
- const { bufferSize, bufferTimeout } = this.remoteClientConfiguration;
361
-
362
- if (this.buffer.length > bufferSize) {
363
- return this._processBuffer();
364
- }
365
-
366
- if (bufferTimeout > 0) {
367
- this.bufferTimeout = setTimeout(this._boundProcessBuffer, bufferTimeout);
368
- }
369
- }
370
-
371
- _processBuffer() {
372
- this._sendDebugToGrafana(this.buffer);
373
-
374
- this.buffer = [];
375
- if (this.bufferTimeout) {
376
- clearTimeout(this.bufferTimeout);
377
- this.bufferTimeout = null;
378
- }
379
- }
380
-
381
- _sendDebugToGrafana(payload , retry = 0) {
382
- if (!this.remoteClientConfiguration || retry >= MAX_REMOTE_RETRY) {
383
- return;
384
- }
385
-
386
- const { tag, host, port } = this.remoteClientConfiguration;
387
- const isArray = Array.isArray(payload);
388
- const isSecure = +port === 443;
389
- const url = `http${isSecure ? 's' : ''}://${host}${isSecure ? '' : `:${port}`}/${tag}`;
390
- const body = isArray ? `[${payload.map(this._boundParseLoggerBody).join(',')}]` : this._parseLoggerBody(payload);
391
-
392
- realFetch()(url, {
393
- method: 'POST',
394
- headers: {
395
- Accept: 'application/json',
396
- 'Content-Type': 'application/json',
397
- },
398
- // $FlowFixMe
399
- body,
400
- }).catch((e ) => {
401
- // $FlowFixMe
402
- e.skipSendToRemote = true;
403
- this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
404
-
405
- setTimeout(() => {
406
- if (isArray) {
407
- payload = payload.map(message => this._writeRetryCount(message, retry + 1));
408
- } else if (payload && typeof payload === 'object') {
409
- payload = this._writeRetryCount(payload, retry + 1);
410
- }
411
-
412
- this._sendDebugToGrafana(payload, retry + 1);
413
- }, 5000 + retry * 1000);
414
- });
415
- }
416
-
417
- _writeRetryCount(message , count ) {
418
- if (message && typeof message === 'object') {
419
- // $FlowFixMe
420
- message._retry = count;
421
- }
422
-
423
- return message;
424
- }
425
-
426
- _isLevelAbove(level1 , level2 ) {
427
- const index1 = LOG_LEVELS.indexOf(level1);
428
- const index2 = LOG_LEVELS.indexOf(level2);
429
- if (index1 === -1 || index2 === -1) {
430
- return false;
431
- }
432
-
433
- return index1 > index2;
434
- }
435
-
436
- _makeCategory(category ) {
437
- return `${CATEGORY_PREFIX}${category}`;
438
- }
439
- }
440
-
441
- var IssueReporter$1 = new IssueReporter();
442
-
443
- /* */
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
- const methods = ['head', 'get', 'post', 'put', 'delete'];
455
-
456
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
457
-
458
- // Use a function here to be able to mock it in tests
459
- const realFetch = () => {
460
- if (typeof document !== 'undefined' && window.fetch) {
461
- // Browser
462
- return window.fetch;
463
- }
464
-
465
- if (isMobile()) {
466
- // React native
467
- return fetch;
468
- }
469
-
470
- // nodejs
471
- // this package is disable for react-native in package.json because it requires nodejs modules
472
- // Used to trick the optimizer to avoid requiring `node-fetch/lib/index` directly
473
- // It causes to require it on browsers when delivered by a nodejs engine (cf: vitejs).
474
- try {
475
- // $FlowFixMe
476
- return require(Math.random() >= 0 ? 'node-fetch/lib/index' : '');
477
- } catch (e) {
478
- return fetch;
479
- }
480
- };
481
-
482
- class ApiRequester {
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
- // eslint-disable-next-line
500
- static successResponseParser(response , isJson ) {
501
- return response.status === 204 || response.status === 201 || response.status === 200;
502
- }
503
-
504
- static defaultParser(response ) {
505
- return response.json().then((data ) => data);
506
- }
507
-
508
- static getQueryString(obj ) {
509
- return Object.keys(obj)
510
- .filter(key => obj[key])
511
- .map(key => `${key}=${encodeURIComponent(obj[key])}`)
512
- .join('&');
513
- }
514
-
515
- static base64Encode(str ) {
516
- return typeof btoa !== 'undefined' ? btoa(str) : jsBase64.Base64.encode(str);
517
- }
518
-
519
- // @see https://github.com/facebook/flow/issues/183#issuecomment-358607052
520
- constructor({ server, refreshTokenCallback, clientId, agent = null, token = null, fetchOptions } ) {
521
- this.server = server;
522
- this.agent = agent;
523
- this.clientId = clientId;
524
- this.refreshTokenCallback = refreshTokenCallback;
525
- this.refreshTokenPromise = null;
526
- this.fetchOptions = fetchOptions || {};
527
- if (token) {
528
- this.token = token;
529
- }
530
-
531
- this.shouldLogErrors = true;
532
-
533
- methods.forEach(method => {
534
- // $FlowFixMe
535
- ApiRequester.prototype[method] = function sugar(...args) {
536
- // Add method in arguments passed to `call`
537
- args.splice(1, 0, method);
538
-
539
- return this.call.call(this, ...args);
540
- };
541
- });
542
- }
543
-
544
- setTenant(tenant ) {
545
- this.tenant = tenant;
546
- }
547
-
548
- setToken(token ) {
549
- this.token = token;
550
- }
551
-
552
- setFetchOptions(options ) {
553
- this.fetchOptions = options;
554
- }
555
-
556
- disableErrorLogging() {
557
- this.shouldLogErrors = false;
558
- }
559
-
560
- enableErrorLogging() {
561
- this.shouldLogErrors = true;
562
- }
563
-
564
- async call(
565
- path ,
566
- method = 'get',
567
- body = null,
568
- headers = null,
569
- parse = ApiRequester.defaultParser,
570
- firstCall = true,
571
- ) {
572
- const url = this.computeUrl(method, path, body);
573
- const newHeaders = this.getHeaders(headers);
574
- let newBody = method === 'get' ? null : body;
575
- if (newBody && newHeaders['Content-Type'] === 'application/json') {
576
- newBody = JSON.stringify(newBody);
577
- }
578
- const isHead = method === 'head';
579
- const hasEmptyResponse = method === 'delete' || isHead;
580
- const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
581
-
582
- const fetchOptions = { ...this.fetchOptions || {} };
583
- const extraHeaders = fetchOptions.headers || {};
584
- delete fetchOptions.headers;
585
-
586
- const options = {
587
- method,
588
- body: newBody,
589
- headers: { ...this.getHeaders(headers), ...extraHeaders },
590
- agent: this.agent,
591
- ...fetchOptions,
592
- };
593
-
594
- if (this.refreshTokenPromise) {
595
- logger$1.info('A token is already refreshing, waiting ...', { url });
596
- await this.refreshTokenPromise;
597
- }
598
-
599
- const start = new Date();
600
-
601
- return realFetch()(url, options).then(response => {
602
- const contentType = response.headers.get('content-type') || '';
603
- const isJson = contentType.indexOf('application/json') !== -1;
604
-
605
- IssueReporter$1.logRequest(url, options, response, start);
606
-
607
- // Throw an error only if status >= 400
608
- if ((isHead && response.status >= 500) || (!isHead && response.status >= 400)) {
609
- const promise = isJson ? response.json() : response.text();
610
- const exceptionClass = response.status >= 500 ? ServerError : BadResponse;
611
-
612
- return promise.then(async (err ) => {
613
- // Check if the token is still valid
614
- if (firstCall && this._checkTokenExpired(response, err)) {
615
- logger$1.warn('token expired', { error: err.reason });
616
- // Replay the call after refreshing the token
617
- return this._replayWithNewToken(err, path, method, body, headers, parse);
618
- }
619
-
620
- const error = typeof err === 'string'
621
- ? exceptionClass.fromText(err, response.status)
622
- : exceptionClass.fromResponse(err, response.status);
623
-
624
- if (this.shouldLogErrors) {
625
- logger$1.error('API error', error);
626
- }
627
-
628
- throw error;
629
- });
630
- }
631
-
632
- return newParse(response, isJson);
633
- }).catch(error => {
634
- if (this.shouldLogErrors) {
635
- logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
636
- }
637
-
638
- throw error;
639
- });
640
- }
641
-
642
- _checkTokenExpired(response , err ) {
643
- // Special case when authenticating form a token: we got a 404
644
- const isTokenNotFound = response.status === 404 && this._isTokenNotFound(err);
645
-
646
- return response.status === 401 || isTokenNotFound;
647
- }
648
-
649
- _isTokenNotFound(err ) {
650
- return err && err.reason && err.reason[0] === 'No such token';
651
- }
652
-
653
- _replayWithNewToken(
654
- err ,
655
- path ,
656
- method ,
657
- body = null,
658
- headers = null,
659
- parse ,
660
- ) {
661
- const isTokenNotFound = this._isTokenNotFound(err);
662
- let newPath = path;
663
- logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
664
-
665
- this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
666
-
667
- return this.refreshTokenPromise.then(() => {
668
- this.refreshTokenPromise = null;
669
- logger$1.info('token refreshed', { isTokenNotFound });
670
- if (isTokenNotFound) {
671
- const pathParts = path.split('/');
672
- pathParts.pop();
673
- pathParts.push(this.token);
674
- newPath = pathParts.join('/');
675
- }
676
-
677
- return this.call(newPath, method, body, headers, parse, false);
678
- }).catch((e) => {
679
- this.refreshTokenPromise = null;
680
- throw e;
681
- });
682
- }
683
-
684
- getHeaders(header ) {
685
- if (header instanceof Object) {
686
- return header;
687
- }
688
-
689
- return {
690
- 'X-Auth-Token': this.token,
691
- ...(this.tenant ? { 'Wazo-Tenant': this.tenant } : null),
692
- Accept: 'application/json',
693
- 'Content-Type': 'application/json',
694
- };
695
- }
696
-
697
- computeUrl(method , path , body ) {
698
- const url = `${this.baseUrl}/${path}`;
699
-
700
- return method === 'get' && body && Object.keys(body).length ? `${url}?${ApiRequester.getQueryString(body)}` : url;
701
- }
702
-
703
- get baseUrl() {
704
- return `https://${this.server}/api`;
705
- }
706
- }
707
-
708
- //
709
-
710
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
711
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
712
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
713
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
714
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
715
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
716
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
717
- BwIDAQAB
718
- -----END PUBLIC KEY-----`;
719
-
720
- //
721
-
722
- var newFrom = (instance , ToClass ) => {
723
- const args = {};
724
- Object.getOwnPropertyNames(instance).forEach(prop => {
725
- args[prop] = instance[prop];
726
- });
727
-
728
- return new ToClass(args);
729
- };
730
-
731
- //
732
-
733
-
734
-
735
-
736
-
737
-
738
-
739
-
740
-
741
-
742
-
743
-
744
-
745
-
746
-
747
-
748
-
749
-
750
-
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
-
760
-
761
-
762
- class Line {
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
- static parse(plain ) {
772
- return new Line({
773
- id: plain.id,
774
- extensions: plain.extensions,
775
- endpointCustom: plain.endpoint_custom || null,
776
- endpointSccp: plain.endpoint_sccp || null,
777
- endpointSip: plain.endpoint_sip || null,
778
- });
779
- }
780
-
781
- static newFrom(profile ) {
782
- return newFrom(profile, Line);
783
- }
784
-
785
- is(line ) {
786
- return line ? this.id === line.id : false;
787
- }
788
-
789
- hasExtension(extension ) {
790
- if (!this.extensions) {
791
- return false;
792
- }
793
-
794
- return this.extensions.some(ext => ext.exten === extension);
795
- }
796
-
797
- constructor({ id, extensions, endpointCustom, endpointSccp, endpointSip } = {}) {
798
- this.id = id;
799
- this.extensions = extensions;
800
- this.endpointCustom = endpointCustom || null;
801
- this.endpointSccp = endpointSccp || null;
802
- this.endpointSip = endpointSip || null;
803
-
804
- // Useful to compare instead of instanceof with minified code
805
- this.type = 'Line';
806
- }
807
- }
808
-
809
- //
810
-
811
-
812
-
813
-
814
-
815
-
816
- const FORWARD_KEYS = {
817
- BUSY: 'busy',
818
- NO_ANSWER: 'noanswer',
819
- UNCONDITIONAL: 'unconditional',
820
- };
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
- class ForwardOption {
829
-
830
-
831
-
832
-
833
- static parse(plain , key ) {
834
- return new ForwardOption({
835
- destination: plain.destination || '',
836
- enabled: plain.enabled,
837
- key,
838
- });
839
- }
840
-
841
- static newFrom(profile ) {
842
- return newFrom(profile, ForwardOption);
843
- }
844
-
845
- constructor({ destination, enabled, key } = {}) {
846
- this.destination = destination;
847
- this.enabled = enabled;
848
- this.key = key;
849
- }
850
-
851
- setDestination(number ) {
852
- this.destination = number;
853
-
854
- return this;
855
- }
856
-
857
- setEnabled(enabled ) {
858
- this.enabled = enabled;
859
-
860
- return this;
861
- }
862
-
863
- is(other ) {
864
- return this.key === other.key;
865
- }
866
- }
867
-
868
- //
869
-
870
-
871
- const availableCodecs = ['vp8', 'vp9', 'h264'];
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
- class SipLine {
905
-
906
-
907
-
908
-
909
-
910
-
911
-
912
-
913
-
914
-
915
-
916
-
917
-
918
- static parse(plain ) {
919
- let { username, secret, host } = plain;
920
-
921
- // Since 20.13 engine so options are now in section
922
- if (plain.auth_section_options) {
923
- // $FlowFixMe
924
- const findOption = (options , name ) => options.find(option => option[0] === name);
925
-
926
- const usernameOption = findOption(plain.auth_section_options, 'username');
927
- const secretOption = findOption(plain.auth_section_options, 'password');
928
- const hostOption = findOption(plain.endpoint_section_options, 'media_address');
929
-
930
- username = usernameOption ? usernameOption[1] : '';
931
- secret = secretOption ? secretOption[1] : '';
932
- host = hostOption ? hostOption[1] : '';
933
- }
934
-
935
- return new SipLine({
936
- id: plain.id,
937
- uuid: plain.uuid,
938
- tenantUuid: plain.tenant_uuid,
939
- username,
940
- secret,
941
- type: plain.type,
942
- host,
943
- options: plain.options,
944
- endpointSectionOptions: plain.endpoint_section_options,
945
- links: plain.links,
946
- trunk: plain.trunk,
947
- line: plain.line,
948
- });
949
- }
950
-
951
- static newFrom(sipLine ) {
952
- return newFrom(sipLine, SipLine);
953
- }
954
-
955
- is(line ) {
956
- if (line.uuid) {
957
- return this.uuid === line.uuid;
958
- }
959
- return this.id === line.id;
960
- }
961
-
962
- getOptions() {
963
- // `options` params have beend remove since 20.13... we should now use endpointSectionOptions
964
- return this.endpointSectionOptions || this.options || [];
965
- }
966
-
967
- isWebRtc() {
968
- return this.getOptions().some(option => option[0] === 'webrtc' && option[1] === 'yes');
969
- }
970
-
971
- hasVideo() {
972
- const allow = this.getOptions().find(option => option[0] === 'allow');
973
- return Array.isArray(allow) && allow[1].split(',').some(codec => availableCodecs.some(c => c === codec));
974
- }
975
-
976
- hasVideoConference() {
977
- return (
978
- this.getOptions().some(option => option[0] === 'max_audio_streams' && parseInt(option[1], 10) > 0)
979
- && this.getOptions().some(option => option[0] === 'max_video_streams' && parseInt(option[1], 10) > 1)
980
- );
981
- }
982
-
983
- constructor({
984
- id,
985
- uuid,
986
- tenantUuid,
987
- username,
988
- secret,
989
- type,
990
- host,
991
- options,
992
- endpointSectionOptions,
993
- links,
994
- trunk,
995
- line,
996
- } = {}) {
997
- this.id = id;
998
- this.uuid = uuid;
999
- this.tenantUuid = tenantUuid;
1000
- this.username = username;
1001
- this.secret = secret;
1002
- this.type = type;
1003
- this.host = host;
1004
- this.options = options;
1005
- this.endpointSectionOptions = endpointSectionOptions;
1006
- this.links = links;
1007
- this.trunk = trunk;
1008
- this.line = line;
1009
-
1010
- // Useful to compare instead of instanceof with minified code
1011
- this.type = 'SipLine';
1012
- }
1013
- }
1014
-
1015
- //
1016
-
1017
- const STATE = {
1018
- AVAILABLE: 'available',
1019
- UNAVAILABLE: 'unavailable',
1020
- INVISIBLE: 'invisible',
1021
- DISCONNECTED: 'disconnected',
1022
- AWAY: 'away',
1023
- };
1024
-
1025
- const LINE_STATE = {
1026
- AVAILABLE: 'available',
1027
- HOLDING: 'holding',
1028
- RINGING: 'ringing',
1029
- TALKING: 'talking',
1030
- UNAVAILABLE: 'unavailable',
1031
- PROGRESSING: 'progressing',
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
-
1099
-
1100
-
1101
-
1102
-
1103
-
1104
-
1105
-
1106
-
1107
-
1108
-
1109
-
1110
-
1111
-
1112
-
1113
-
1114
-
1115
-
1116
-
1117
-
1118
-
1119
-
1120
-
1121
-
1122
-
1123
-
1124
- class Profile {
1125
-
1126
-
1127
-
1128
-
1129
-
1130
-
1131
-
1132
-
1133
-
1134
-
1135
-
1136
-
1137
-
1138
-
1139
-
1140
-
1141
-
1142
-
1143
-
1144
-
1145
- static parse(plain ) {
1146
- return new Profile({
1147
- id: plain.uuid,
1148
- firstName: plain.firstName || plain.firstname || '',
1149
- lastName: plain.lastName || plain.lastname || '',
1150
- email: plain.email,
1151
- lines: plain.lines.map(line => Line.parse(line)),
1152
- username: plain.username,
1153
- mobileNumber: plain.mobile_phone_number || '',
1154
- ringSeconds: plain.ring_seconds,
1155
- forwards: [
1156
- ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1157
- ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
1158
- ForwardOption.parse(plain.forwards.busy, FORWARD_KEYS.BUSY),
1159
- ],
1160
- doNotDisturb: plain.services.dnd.enabled,
1161
- subscriptionType: plain.subscription_type,
1162
- voicemail: plain.voicemail,
1163
- switchboards: plain.switchboards || [],
1164
- agent: plain.agent,
1165
- status: '',
1166
- callPickupTargetUsers: plain.call_pickup_target_users || [],
1167
- onlineCallRecordEnabled: plain.online_call_record_enabled,
1168
- });
1169
- }
1170
-
1171
- static newFrom(profile ) {
1172
- return newFrom(profile, Profile);
1173
- }
1174
-
1175
- constructor({
1176
- id,
1177
- firstName,
1178
- lastName,
1179
- email,
1180
- lines,
1181
- username,
1182
- mobileNumber,
1183
- forwards,
1184
- doNotDisturb,
1185
- state,
1186
- subscriptionType,
1187
- voicemail,
1188
- switchboards,
1189
- agent,
1190
- status,
1191
- ringSeconds,
1192
- sipLines,
1193
- callPickupTargetUsers,
1194
- onlineCallRecordEnabled,
1195
- } = {}) {
1196
- this.id = id;
1197
- this.firstName = firstName;
1198
- this.lastName = lastName;
1199
- this.email = email;
1200
- this.lines = lines;
1201
- this.username = username;
1202
- this.mobileNumber = mobileNumber;
1203
- this.forwards = forwards;
1204
- this.doNotDisturb = doNotDisturb;
1205
- this.state = state;
1206
- this.voicemail = voicemail;
1207
- this.subscriptionType = subscriptionType;
1208
- this.switchboards = switchboards;
1209
- this.agent = agent;
1210
- this.status = status;
1211
- this.callPickupTargetUsers = callPickupTargetUsers;
1212
- this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1213
- this.ringSeconds = ringSeconds;
1214
-
1215
- this.sipLines = sipLines || [];
1216
- }
1217
-
1218
- static getLinesState(lines ) {
1219
- let result = LINE_STATE.UNAVAILABLE;
1220
-
1221
- // eslint-disable-next-line
1222
- for (const line of lines) {
1223
- if (line.state === LINE_STATE.RINGING) {
1224
- result = LINE_STATE.RINGING;
1225
- break;
1226
- }
1227
-
1228
- if (line.state === LINE_STATE.TALKING) {
1229
- result = LINE_STATE.TALKING;
1230
- break;
1231
- }
1232
-
1233
- if (line.state === LINE_STATE.AVAILABLE) {
1234
- result = LINE_STATE.AVAILABLE;
1235
- }
1236
- }
1237
-
1238
- return result;
1239
- }
1240
-
1241
- hasId(id ) {
1242
- return id === this.id;
1243
- }
1244
-
1245
- setMobileNumber(number ) {
1246
- this.mobileNumber = number;
1247
-
1248
- return this;
1249
- }
1250
-
1251
- setForwardOption(forwardOption ) {
1252
- const updatedForwardOptions = this.forwards.slice();
1253
- const index = updatedForwardOptions.findIndex(forward => forward.is(forwardOption));
1254
- updatedForwardOptions.splice(index, 1, forwardOption);
1255
-
1256
- this.forwards = updatedForwardOptions;
1257
-
1258
- return this;
1259
- }
1260
-
1261
- setDoNotDisturb(enabled ) {
1262
- this.doNotDisturb = enabled;
1263
-
1264
- return this;
1265
- }
1266
-
1267
- setState(state ) {
1268
- this.state = state;
1269
-
1270
- return this;
1271
- }
1272
- }
1273
-
1274
- //
1275
-
1276
-
1277
- const BACKEND = {
1278
- OFFICE365: 'office365',
1279
- PERSONAL: 'personal',
1280
- GOOGLE: 'google',
1281
- WAZO: 'wazo',
1282
- };
1283
-
1284
-
1285
-
1286
-
1287
-
1288
-
1289
-
1290
-
1291
-
1292
-
1293
-
1294
-
1295
-
1296
-
1297
-
1298
-
1299
-
1300
-
1301
-
1302
-
1303
-
1304
-
1305
-
1306
-
1307
-
1308
-
1309
-
1310
-
1311
-
1312
-
1313
-
1314
-
1315
-
1316
-
1317
-
1318
-
1319
-
1320
-
1321
-
1322
-
1323
-
1324
-
1325
-
1326
-
1327
-
1328
-
1329
-
1330
-
1331
-
1332
-
1333
-
1334
-
1335
-
1336
-
1337
-
1338
-
1339
-
1340
-
1341
-
1342
-
1343
-
1344
-
1345
-
1346
-
1347
-
1348
-
1349
-
1350
-
1351
-
1352
-
1353
-
1354
-
1355
-
1356
-
1357
- // @see: https://github.com/rt2zz/react-native-contacts#example-contact-record
1358
-
1359
-
1360
-
1361
-
1362
-
1363
-
1364
-
1365
-
1366
-
1367
-
1368
-
1369
-
1370
-
1371
-
1372
-
1373
-
1374
-
1375
-
1376
-
1377
-
1378
-
1379
-
1380
-
1381
-
1382
-
1383
-
1384
-
1385
-
1386
-
1387
-
1388
-
1389
-
1390
-
1391
-
1392
-
1393
-
1394
-
1395
-
1396
-
1397
-
1398
-
1399
-
1400
-
1401
-
1402
-
1403
-
1404
-
1405
-
1406
-
1407
-
1408
-
1409
-
1410
-
1411
-
1412
-
1413
-
1414
-
1415
-
1416
-
1417
-
1418
-
1419
-
1420
-
1421
-
1422
-
1423
-
1424
-
1425
-
1426
-
1427
-
1428
-
1429
-
1430
-
1431
-
1432
-
1433
-
1434
-
1435
-
1436
-
1437
-
1438
-
1439
-
1440
-
1441
-
1442
-
1443
-
1444
-
1445
-
1446
-
1447
-
1448
-
1449
-
1450
-
1451
-
1452
-
1453
-
1454
-
1455
-
1456
-
1457
-
1458
-
1459
-
1460
-
1461
-
1462
-
1463
-
1464
-
1465
-
1466
-
1467
-
1468
-
1469
-
1470
-
1471
-
1472
-
1473
-
1474
-
1475
-
1476
-
1477
-
1478
-
1479
-
1480
-
1481
-
1482
-
1483
-
1484
-
1485
-
1486
-
1487
-
1488
-
1489
-
1490
-
1491
-
1492
-
1493
-
1494
-
1495
- const SOURCE_MOBILE = 'mobile';
1496
-
1497
- class Contact {
1498
-
1499
-
1500
-
1501
-
1502
-
1503
-
1504
-
1505
-
1506
-
1507
-
1508
-
1509
-
1510
-
1511
-
1512
-
1513
-
1514
-
1515
-
1516
-
1517
-
1518
-
1519
-
1520
-
1521
-
1522
-
1523
-
1524
-
1525
-
1526
-
1527
-
1528
-
1529
-
1530
- static merge(oldContacts , newContacts ) {
1531
- return newContacts.map(current => {
1532
- const old = oldContacts.find(contact => contact && contact.is(current));
1533
-
1534
- return old ? current.merge(old) : current;
1535
- });
1536
- }
1537
-
1538
- static sortContacts(a , b ) {
1539
- const aNames = a.separateName();
1540
- const bNames = b.separateName();
1541
- const aLastName = aNames.lastName;
1542
- const bLastName = bNames.lastName;
1543
-
1544
- // last Name can be empty
1545
- if (aLastName === bLastName) {
1546
- return aNames.firstName.localeCompare(bNames.firstName);
1547
- }
1548
-
1549
- return aLastName.localeCompare(bLastName);
1550
- }
1551
-
1552
- static parseMany(response ) {
1553
- if (!response || !response.results) {
1554
- return [];
1555
- }
1556
- return response.results.map(r => Contact.parse(r, response.column_types));
1557
- }
1558
-
1559
- static manyGraphQlWithNumbersParser(numbers ) {
1560
- return (response ) => {
1561
- if (!response.data || !response.data.me || !response.data.me.contacts) {
1562
- return [];
1563
- }
1564
-
1565
- return response.data.me.contacts.edges.map((edge, i) => {
1566
- if (!edge.node) {
1567
- return null;
1568
- }
1569
-
1570
- const { email } = edge.node;
1571
- const name = edge.node.firstname && edge.node.lastname
1572
- ? `${edge.node.firstname || ''} ${edge.node.lastname || ''}` : edge.node.wazoReverse;
1573
-
1574
- return new Contact({
1575
- name,
1576
- number: numbers[i],
1577
- numbers: [{ label: 'primary', number: numbers[i] }],
1578
- backend: edge.node.wazoBackend,
1579
- source: edge.node.wazoSourceName,
1580
- sourceId: edge.node.wazoSourceEntryId || '',
1581
- email: email || '',
1582
- emails: email ? [{ label: 'primary', email }] : [],
1583
- uuid: edge.node.userUuid,
1584
- });
1585
- }).filter(contact => !!contact);
1586
- };
1587
- }
1588
-
1589
- static fetchNumbers(plain , columns ) {
1590
- const numberColumns = columns
1591
- .map((e, index) => ({ index, columnName: e }))
1592
- .filter(e => e.columnName === 'number' || e.columnName === 'callable')
1593
- .map(e => e.index);
1594
-
1595
- return plain.column_values.filter((e, index) => numberColumns.some(i => i === index) && e !== null);
1596
- }
1597
-
1598
- static parse(plain , columns ) {
1599
- const numbers = Contact.fetchNumbers(plain, columns);
1600
- const email = plain.column_values[columns.indexOf('email')];
1601
-
1602
- return new Contact({
1603
- name: plain.column_values[columns.indexOf('name')],
1604
- number: numbers.length ? numbers[0] : '',
1605
- numbers: numbers.map((number, i) => ({ label: i === 0 ? 'primary' : 'secondary', number })),
1606
- favorited: plain.column_values[columns.indexOf('favorite')],
1607
- email: email || '',
1608
- emails: email ? [{ label: 'primary', email }] : [],
1609
- entreprise: plain.column_values[columns.indexOf('entreprise')] || '',
1610
- birthday: plain.column_values[columns.indexOf('birthday')] || '',
1611
- address: plain.column_values[columns.indexOf('address')] || '',
1612
- note: plain.column_values[columns.indexOf('note')] || '',
1613
- endpointId: plain.relations.endpoint_id,
1614
- personal: plain.column_values[columns.indexOf('personal')],
1615
- source: plain.source,
1616
- sourceId: plain.relations.source_entry_id || '',
1617
- uuid: plain.relations.user_uuid,
1618
- backend: plain.backend || '',
1619
- });
1620
- }
1621
-
1622
- static parseManyPersonal(results ) {
1623
- return results.map(r => Contact.parsePersonal(r));
1624
- }
1625
-
1626
- static parsePersonal(plain ) {
1627
- return new Contact({
1628
- name: `${plain.firstName || plain.firstname || ''} ${plain.lastName || plain.lastname || ''}`,
1629
- number: plain.number || '',
1630
- numbers: plain.number ? [{ label: 'primary', number: plain.number }] : [],
1631
- email: plain.email || '',
1632
- emails: plain.email ? [{ label: 'primary', email: plain.email }] : [],
1633
- source: 'personal',
1634
- sourceId: plain.id || '',
1635
- entreprise: plain.entreprise || '',
1636
- birthday: plain.birthday || '',
1637
- address: plain.address || '',
1638
- note: plain.note || '',
1639
- favorited: plain.favorited,
1640
- personal: true,
1641
- backend: plain.backend || BACKEND.PERSONAL,
1642
- });
1643
- }
1644
-
1645
- static parseMobile(plain ) {
1646
- let address = '';
1647
- if (plain.postalAddresses.length) {
1648
- const postalAddress = plain.postalAddresses[0];
1649
-
1650
- address = `${postalAddress.street} ${postalAddress.city} ${postalAddress.postCode} ${postalAddress.country}`;
1651
- }
1652
-
1653
- return new Contact({
1654
- name: `${plain.givenName || ''} ${plain.familyName || ''}`,
1655
- number: plain.phoneNumbers.length ? plain.phoneNumbers[0].number : '',
1656
- numbers: plain.phoneNumbers.length ? [{ label: 'primary', number: plain.phoneNumbers[0].number }] : [],
1657
- email: plain.emailAddresses.length ? plain.emailAddresses[0].email : '',
1658
- emails: plain.emailAddresses.length ? [{ label: 'primary', email: plain.emailAddresses[0].email }] : [],
1659
- source: SOURCE_MOBILE,
1660
- sourceId: plain.recordID || '',
1661
- birthday: plain.birthday ? `${plain.birthday.year}-${plain.birthday.month}-${plain.birthday.day}` : '',
1662
- address,
1663
- note: plain.note || '',
1664
- favorited: false,
1665
- personal: true,
1666
- });
1667
- }
1668
-
1669
- static parseManyOffice365(response , source ) {
1670
- return response.map(r => Contact.parseOffice365(r, source));
1671
- }
1672
-
1673
- static parseOffice365(single , source ) {
1674
- const emails = [];
1675
- const numbers = [];
1676
-
1677
- if (single.emailAddresses) {
1678
- single.emailAddresses.map(email => emails.push({ email: email.address }));
1679
- }
1680
-
1681
- if (single.businessPhones) {
1682
- single.businessPhones.map(phone => numbers.push({ label: 'business', number: phone }));
1683
- }
1684
-
1685
- if (single.mobilePhone) {
1686
- numbers.push({ label: 'mobile', number: single.mobilePhone });
1687
- }
1688
-
1689
- if (single.homePhones) {
1690
- single.homePhones.map(phone => numbers.push({ label: 'home', number: phone }));
1691
- }
1692
-
1693
- return new Contact({
1694
- sourceId: single.id || '',
1695
- name: single.displayName || '',
1696
- number: numbers.length ? numbers[0].number : '',
1697
- numbers,
1698
- emails,
1699
- source: source.name,
1700
- backend: BACKEND.OFFICE365,
1701
- });
1702
- }
1703
-
1704
- static parseManyGoogle(response , source ) {
1705
- return response.map(r => Contact.parseGoogle(r, source));
1706
- }
1707
-
1708
- static parseGoogle(single , source ) {
1709
- const emails = [];
1710
- const numbers = [];
1711
-
1712
- if (single.emails) {
1713
- single.emails.forEach(email =>
1714
- (typeof email === 'object' ? { email: email.address, label: email.label } : { email }));
1715
- }
1716
-
1717
- if (single.numbers_by_label) {
1718
- Object.keys(single.numbers_by_label).forEach(label =>
1719
- numbers.push({ label, number: single.numbers_by_label[label] }));
1720
- } else if (single.numbers) {
1721
- single.numbers.forEach(phone => numbers.push({ number: phone }));
1722
- }
1723
-
1724
- return new Contact({
1725
- sourceId: single.id || '',
1726
- name: single.name || '',
1727
- number: numbers.length ? numbers[0].number : '',
1728
- numbers,
1729
- emails,
1730
- source: source.name,
1731
- backend: BACKEND.GOOGLE,
1732
- });
1733
- }
1734
-
1735
- static parseManyWazo(response , source ) {
1736
- return response.map(r => Contact.parseWazo(r, source));
1737
- }
1738
-
1739
- static parseWazo(single , source ) {
1740
- const emails = [];
1741
- const numbers = [];
1742
-
1743
- if (single.email) {
1744
- emails.push({ label: 'email', email: single.email });
1745
- }
1746
-
1747
- if (single.exten) {
1748
- numbers.push({ label: 'exten', number: single.exten });
1749
- }
1750
-
1751
- if (single.mobile_phone_number) {
1752
- numbers.push({ label: 'mobile', number: single.mobile_phone_number });
1753
- }
1754
-
1755
- return new Contact({
1756
- uuid: single.uuid,
1757
- sourceId: String(single.id) || '',
1758
- name: `${single.firstname}${single.lastname ? ` ${single.lastname}` : ''}`,
1759
- number: numbers.length ? numbers[0].number : '',
1760
- numbers,
1761
- emails,
1762
- source: source.name,
1763
- backend: BACKEND.WAZO,
1764
- });
1765
- }
1766
-
1767
- static parseManyConference(response , source ) {
1768
- return response.map(r => Contact.parseConference(r, source));
1769
- }
1770
-
1771
- static parseConference(single , source ) {
1772
- const numbers = [];
1773
- let firstNumber = '';
1774
-
1775
- if (single && single.extensions && single.extensions.length > 0 && single.extensions[0].exten) {
1776
- firstNumber = single.extensions[0].exten;
1777
- numbers.push({ label: 'exten', number: firstNumber });
1778
- }
1779
-
1780
- return new Contact({
1781
- sourceId: String(single.id),
1782
- name: single.name,
1783
- number: firstNumber,
1784
- numbers,
1785
- source: source.name,
1786
- backend: 'conference',
1787
- });
1788
- }
1789
-
1790
- static newFrom(contact ) {
1791
- return newFrom(contact, Contact);
1792
- }
1793
-
1794
- constructor({
1795
- id,
1796
- uuid,
1797
- name,
1798
- number,
1799
- numbers,
1800
- email,
1801
- emails,
1802
- source,
1803
- sourceId,
1804
- entreprise,
1805
- birthday,
1806
- address,
1807
- note,
1808
- state,
1809
- lineState,
1810
- lastActivity,
1811
- mobile,
1812
- status,
1813
- endpointId,
1814
- personal,
1815
- favorited,
1816
- backend,
1817
- personalStatus,
1818
- sessions,
1819
- connected,
1820
- doNotDisturb,
1821
- ringing,
1822
- previousPresential,
1823
- lines,
1824
- } = {}) {
1825
- this.id = id;
1826
- this.uuid = uuid;
1827
- this.name = name || '';
1828
- this.number = number;
1829
- this.numbers = numbers;
1830
- this.email = email;
1831
- this.emails = emails;
1832
- this.source = source;
1833
- this.sourceId = sourceId;
1834
- this.entreprise = entreprise;
1835
- this.birthday = birthday;
1836
- this.address = address;
1837
- this.note = note;
1838
- this.state = state;
1839
- this.lineState = lineState;
1840
- this.lastActivity = lastActivity;
1841
- this.mobile = mobile;
1842
- this.status = status;
1843
- this.endpointId = endpointId;
1844
- this.personal = personal;
1845
- this.favorited = favorited;
1846
- this.backend = backend;
1847
- this.personalStatus = personalStatus || '';
1848
- this.sessions = sessions || [];
1849
- this.connected = connected;
1850
- this.doNotDisturb = doNotDisturb;
1851
- this.ringing = ringing;
1852
- this.previousPresential = previousPresential;
1853
- this.lines = lines || [];
1854
-
1855
- // Useful to compare instead of instanceof with minified code
1856
- this.type = 'Contact';
1857
- }
1858
-
1859
- setFavorite(value ) {
1860
- this.favorited = value;
1861
-
1862
- return this;
1863
- }
1864
-
1865
- is(other ) {
1866
- const sameSourceId = this.sourceId !== null && other.sourceId !== null && this.sourceId === other.sourceId;
1867
- const sameUuid = !!this.uuid && !!other.uuid && this.uuid === other.uuid;
1868
-
1869
- const hasSameId = sameSourceId || sameUuid;
1870
- const hasSameBackend = !!this.backend && !!other.backend && this.backend === other.backend;
1871
- const hasSameSource = !!this.source && !!other.source && this.source === other.source;
1872
-
1873
- return !!other && hasSameId && hasSameBackend && hasSameSource;
1874
- }
1875
-
1876
- hasId(id ) {
1877
- return this.uuid === id;
1878
- }
1879
-
1880
- hasNumber(number ) {
1881
- return this.number === number;
1882
- }
1883
-
1884
- hasEndpointId(endpointId ) {
1885
- return this.endpointId === endpointId;
1886
- }
1887
-
1888
- isAvailable() {
1889
- return this.state === STATE.AVAILABLE;
1890
- }
1891
-
1892
- isAway() {
1893
- return this.state === STATE.AWAY;
1894
- }
1895
-
1896
- isUnavailable() {
1897
- return this.state === STATE.UNAVAILABLE;
1898
- }
1899
-
1900
- isInvisible() {
1901
- return this.state === STATE.INVISIBLE;
1902
- }
1903
-
1904
- isInCall() {
1905
- return this.lineState === LINE_STATE.TALKING || this.lineState === LINE_STATE.HOLDING;
1906
- }
1907
-
1908
- isRinging() {
1909
- return this.ringing;
1910
- }
1911
-
1912
- isInUseOrRinging() {
1913
- return this.lineState === LINE_STATE.TALKING || this.lineState === LINE_STATE.RINGING;
1914
- }
1915
-
1916
- isProgressing() {
1917
- return this.lineState === LINE_STATE.PROGRESSING;
1918
- }
1919
-
1920
- merge(old ) {
1921
- Object.keys(old).filter(key => key !== 'lineState').forEach(key => {
1922
- // $FlowFixMe
1923
- this[key] = old[key] || this[key];
1924
- });
1925
-
1926
- if (old.lineState) {
1927
- this.lineState = old.lineState;
1928
- }
1929
-
1930
- return this;
1931
- }
1932
-
1933
- isIntern() {
1934
- return !!this.uuid;
1935
- }
1936
-
1937
- hasSourceId() {
1938
- return !!this.sourceId;
1939
- }
1940
-
1941
- isCallable(session ) {
1942
- return !!this.number && !!session && !session.is(this);
1943
- }
1944
-
1945
- isFromMobile() {
1946
- return this.source === SOURCE_MOBILE;
1947
- }
1948
-
1949
- isFavorite() {
1950
- return this.favorited;
1951
- }
1952
-
1953
- separateName() {
1954
- if (!this.name) {
1955
- return {
1956
- firstName: '',
1957
- lastName: '',
1958
- };
1959
- }
1960
- const names = this.name.split(/\s+/);
1961
- const firstName = names[0];
1962
- const lastName = names.slice(1).join(' ');
1963
-
1964
- return {
1965
- firstName,
1966
- lastName,
1967
- };
1968
- }
1969
- }
1970
-
1971
- // Can't use `semver` package as Wazo version aren't in semver format
1972
-
1973
- const compareVersions = (a, b) => {
1974
- let i;
1975
- let diff;
1976
- const regExStrip0 = /(\.0+)+$/;
1977
- const segmentsA = a.replace(regExStrip0, '').split('.');
1978
- const segmentsB = b.replace(regExStrip0, '').split('.');
1979
- const l = Math.min(segmentsA.length, segmentsB.length);
1980
-
1981
- for (i = 0; i < l; i++) {
1982
- diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
1983
- if (diff) {
1984
- return diff;
1985
- }
1986
- }
1987
- return segmentsA.length - segmentsB.length;
1988
- };
1989
-
1990
- //
1991
-
1992
- const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
1993
- const MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT = '19.08';
1994
-
1995
-
1996
-
1997
-
1998
-
1999
-
2000
-
2001
-
2002
-
2003
-
2004
-
2005
-
2006
-
2007
-
2008
-
2009
-
2010
-
2011
-
2012
-
2013
-
2014
-
2015
-
2016
-
2017
-
2018
-
2019
-
2020
-
2021
-
2022
-
2023
-
2024
-
2025
-
2026
-
2027
-
2028
-
2029
-
2030
-
2031
-
2032
-
2033
-
2034
-
2035
-
2036
-
2037
-
2038
-
2039
-
2040
-
2041
-
2042
-
2043
- class Session {
2044
-
2045
-
2046
-
2047
-
2048
-
2049
-
2050
-
2051
-
2052
-
2053
-
2054
-
2055
-
2056
- static parse(plain ) {
2057
- const token = plain.data.metadata ? plain.data.metadata.jwt : null;
2058
- let authorizations = [];
2059
-
2060
- // Add authorizations from JWT
2061
- if (token) {
2062
- const isValid = jsrsasign.jws.JWS.verifyJWT(token, swarmKey, { alg: ['RS256'], verifyAt: new Date() });
2063
- if (isValid) {
2064
- const decodedToken = jsrsasign.jws.JWS.readSafeJSONString(jsrsasign.b64utoutf8(token.split('.')[1]));
2065
- authorizations = decodedToken ? decodedToken.authorizations : [];
2066
- }
2067
- }
2068
-
2069
- return new Session({
2070
- token: plain.data.token,
2071
- refreshToken: plain.data.refresh_token || null,
2072
- uuid: plain.data.metadata ? plain.data.metadata.uuid : null,
2073
- sessionUuid: plain.data.session_uuid,
2074
- authorizations,
2075
- acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
2076
- tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
2077
- expiresAt: new Date(`${plain.data.utc_expires_at}z`),
2078
- engineUuid: plain.data.xivo_uuid,
2079
- });
2080
- }
2081
-
2082
- static newFrom(profile ) {
2083
- return newFrom(profile, Session);
2084
- }
2085
-
2086
- constructor({
2087
- token,
2088
- uuid,
2089
- tenantUuid,
2090
- profile,
2091
- expiresAt,
2092
- authorizations,
2093
- acl,
2094
- engineVersion,
2095
- refreshToken,
2096
- sessionUuid,
2097
- engineUuid,
2098
- } = {}) {
2099
- this.token = token;
2100
- this.uuid = uuid;
2101
- this.tenantUuid = tenantUuid || null;
2102
- this.profile = profile;
2103
- this.expiresAt = expiresAt;
2104
- this.authorizations = authorizations || [];
2105
- this.acl = acl || [];
2106
- this.engineVersion = engineVersion;
2107
- this.refreshToken = refreshToken;
2108
- this.sessionUuid = sessionUuid;
2109
- this.engineUuid = engineUuid;
2110
- }
2111
-
2112
- hasExpired(date = new Date()) {
2113
- return date >= this.expiresAt;
2114
- }
2115
-
2116
- is(contact ) {
2117
- return Boolean(contact) && this.uuid === contact.uuid;
2118
- }
2119
-
2120
- using(profile ) {
2121
- this.profile = profile;
2122
-
2123
- return this;
2124
- }
2125
-
2126
- hasAuthorizations() {
2127
- return this.authorizations && !!this.authorizations.length;
2128
- }
2129
-
2130
- displayName() {
2131
- return this.profile ? `${this.profile.firstName} ${this.profile.lastName}` : '';
2132
- }
2133
-
2134
- hasAccessToVoicemail() {
2135
- if (!this.profile) {
2136
- return false;
2137
- }
2138
- return !!this.profile.voicemail;
2139
- }
2140
-
2141
- primaryLine() {
2142
- return this.profile && this.profile.lines.length > 0 ? this.profile.lines[0] : null;
2143
- }
2144
-
2145
- primarySipLine() {
2146
- return this.profile && this.profile.sipLines.length > 0 ? this.profile.sipLines[0] : null;
2147
- }
2148
-
2149
- primaryWebRtcLine() {
2150
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && sipLine.isWebRtc());
2151
- }
2152
-
2153
- primaryCtiLine() {
2154
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && !sipLine.isWebRtc());
2155
- }
2156
-
2157
- primaryContext() {
2158
- if (this.engineVersion) {
2159
- if (this.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT)) {
2160
- return 'default';
2161
- }
2162
- }
2163
-
2164
- const line = this.primaryLine();
2165
-
2166
- return line && line.extensions.length > 0 ? line.extensions[0].context : 'default';
2167
- }
2168
-
2169
- hasEngineVersionGte(version ) {
2170
- return this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
2171
- }
2172
-
2173
- primaryNumber() {
2174
- const line = this.primaryLine();
2175
-
2176
- return line && line.extensions.length ? line.extensions[0].exten : null;
2177
- }
2178
-
2179
- allLines() {
2180
- return this.profile ? this.profile.lines || [] : [];
2181
- }
2182
-
2183
- allNumbers() {
2184
- const extensions = this.allLines().map(line => line.extensions.map(extension => extension.exten));
2185
- if (!extensions.length) {
2186
- return [];
2187
- }
2188
-
2189
- return extensions.reduce((a, b) => a.concat(b));
2190
- }
2191
-
2192
- hasExtension(extension ) {
2193
- return this.allNumbers().some(number => number === extension);
2194
- }
2195
-
2196
- get acls() {
2197
- console.warn('`acls` property of Session has been removed in Wazo\'s SDK, please use `acl` instead.');
2198
- return this.acl;
2199
- }
2200
- }
2201
-
2202
- /* */
2203
-
2204
- const DEFAULT_BACKEND_USER = 'wazo_user';
2205
- const DETAULT_EXPIRATION = 3600;
2206
-
2207
- var authMethods = (client , baseUrl ) => ({
2208
- checkToken: (token ) => client.head(`${baseUrl}/token/${token}`, null, {}),
2209
-
2210
- authenticate: (token ) =>
2211
- client.get(`${baseUrl}/token/${token}`, null, {}).then(response => Session.parse(response)),
2212
-
2213
- logIn(params
2214
-
2215
-
2216
-
2217
-
2218
-
2219
-
2220
-
2221
- ) {
2222
- const body = {
2223
- backend: params.backend || DEFAULT_BACKEND_USER,
2224
- expiration: params.expiration || DETAULT_EXPIRATION,
2225
- };
2226
- const headers = {
2227
- Authorization: `Basic ${ApiRequester.base64Encode(`${params.username}:${params.password}`)}`,
2228
- 'Content-Type': 'application/json',
2229
- };
2230
-
2231
- if (client.clientId) {
2232
- body.access_type = 'offline';
2233
- body.client_id = client.clientId;
2234
- }
2235
-
2236
- if (params.mobile) {
2237
- headers['Wazo-Session-Type'] = 'mobile';
2238
- }
2239
-
2240
- if (params.tenantId) {
2241
- console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2242
- body.tenant_id = params.tenantId;
2243
- }
2244
-
2245
- if (params.domainName) {
2246
- body.domain_name = params.domainName;
2247
- }
2248
-
2249
- return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2250
- },
2251
-
2252
- logOut: (token ) =>
2253
- client.delete(`${baseUrl}/token/${token}`, null, {}, ApiRequester.successResponseParser),
2254
-
2255
- refreshToken: (
2256
- refreshToken ,
2257
- backend ,
2258
- expiration ,
2259
- isMobile = false,
2260
- tenantId ,
2261
- domainName ,
2262
- ) => {
2263
- const body = {
2264
- backend: backend || DEFAULT_BACKEND_USER,
2265
- expiration: expiration || DETAULT_EXPIRATION,
2266
- refresh_token: refreshToken,
2267
- client_id: client.clientId,
2268
- };
2269
-
2270
- if (tenantId) {
2271
- console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2272
- body.tenant_id = tenantId;
2273
- }
2274
-
2275
- if (domainName) {
2276
- body.domain_name = domainName;
2277
- }
2278
-
2279
- const headers = {
2280
- 'Content-Type': 'application/json',
2281
- ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
2282
- };
2283
-
2284
- return client.post(`${baseUrl}/token`, body, headers, ApiRequester.defaultParser, false).then(Session.parse);
2285
- },
2286
-
2287
- deleteRefreshToken: (clientId ) =>
2288
- client.delete(`${baseUrl}/users/me/tokens/${clientId}`, null, null, ApiRequester.successResponseParser),
2289
-
2290
- updatePassword: (userUuid , oldPassword , newPassword ) => {
2291
- const body = {
2292
- new_password: newPassword,
2293
- old_password: oldPassword,
2294
- };
2295
-
2296
- return client.put(`${baseUrl}/users/${userUuid}/password`, body, null, ApiRequester.successResponseParser);
2297
- },
2298
-
2299
- sendDeviceToken: (userUuid , deviceToken , apnsVoipToken , apnsNotificationToken ) => {
2300
- const body = {
2301
- token: deviceToken,
2302
- };
2303
-
2304
- if (apnsVoipToken) {
2305
- // Should be called `voip_token`, but we can't changed it to be retro-compatible
2306
- body.apns_token = apnsVoipToken;
2307
- body.apns_voip_token = apnsVoipToken;
2308
- }
2309
-
2310
- if (apnsNotificationToken) {
2311
- body.apns_notification_token = apnsNotificationToken;
2312
- }
2313
-
2314
- return client.post(`${baseUrl}/users/${userUuid}/external/mobile`, body);
2315
- },
2316
-
2317
- getPushNotificationSenderId: (userUuid ) =>
2318
- client.get(`${baseUrl}/users/${userUuid}/external/mobile/sender_id`, null).then(response => response.sender_id),
2319
-
2320
- /**
2321
- * `username` or `email` should be set.
2322
- */
2323
- sendResetPasswordEmail: ({ username, email } ) => {
2324
- const body = {};
2325
- if (username) {
2326
- body.username = username;
2327
- }
2328
- if (email) {
2329
- body.email = email;
2330
- }
2331
-
2332
- return client.get(`${baseUrl}/users/password/reset`, body, {}, ApiRequester.successResponseParser);
2333
- },
2334
-
2335
- resetPassword: (userUuid , password ) => {
2336
- const body = {
2337
- password,
2338
- };
2339
-
2340
- return client.post(
2341
- `${baseUrl}/users/password/reset?user_uuid=${userUuid}`,
2342
- body,
2343
- null,
2344
- ApiRequester.successResponseParser,
2345
- );
2346
- },
2347
-
2348
- removeDeviceToken: (userUuid ) => client.delete(`${baseUrl}/users/${userUuid}/external/mobile`),
2349
-
2350
- createUser: (
2351
- username ,
2352
- password ,
2353
- firstname ,
2354
- lastname ,
2355
- ) => {
2356
- const body = {
2357
- username,
2358
- password,
2359
- firstname,
2360
- lastname,
2361
- };
2362
-
2363
- return client.post(`${baseUrl}/users`, body);
2364
- },
2365
-
2366
- addUserEmail: (userUuid , email , main ) => {
2367
- const body = {
2368
- emails: [
2369
- {
2370
- address: email,
2371
- main,
2372
- },
2373
- ],
2374
- };
2375
-
2376
- return client.put(`${baseUrl}/users/${userUuid}/emails`, body);
2377
- },
2378
-
2379
- addUserPolicy: (userUuid , policyUuid ) =>
2380
- client.put(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
2381
-
2382
- getRestrictionPolicies: (scopes ) =>
2383
- client.post(`${baseUrl}/token/${client.token}/scopes/check`, { scopes }),
2384
-
2385
- deleteUserPolicy: (userUuid , policyUuid ) =>
2386
- client.delete(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
2387
-
2388
- addUserGroup: (userUuid , groupUuid ) => client.put(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
2389
-
2390
- listUsersGroup: (groupUuid ) => client.get(`${baseUrl}/groups/${groupUuid}/users`),
2391
-
2392
- deleteUserGroup: (userUuid , groupUuid ) =>
2393
- client.delete(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
2394
-
2395
- getUser: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}`),
2396
-
2397
- getUserSession: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}/sessions`),
2398
-
2399
- deleteUserSession: (userUuid , sessionUuids ) =>
2400
- client.delete(`${baseUrl}/users/${userUuid}/sessions/${sessionUuids}`),
2401
-
2402
- listUsers: () => client.get(`${baseUrl}/users`),
2403
-
2404
- deleteUser: (userUuid ) => client.delete(`${baseUrl}/users/${userUuid}`),
2405
-
2406
- listTenants: () => client.get(`${baseUrl}/tenants`),
2407
-
2408
- getTenant: (tenantUuid ) => client.get(`${baseUrl}/tenants/${tenantUuid}`),
2409
-
2410
- createTenant: (name ) => client.post(`${baseUrl}/tenants`, { name }),
2411
-
2412
- updateTenant: (
2413
- uuid ,
2414
- name ,
2415
- contact ,
2416
- phone ,
2417
- address ,
2418
- ) => {
2419
- const body = {
2420
- name,
2421
- contact,
2422
- phone,
2423
- address,
2424
- };
2425
-
2426
- return client.put(`${baseUrl}/tenants/${uuid}`, body);
2427
- },
2428
-
2429
- deleteTenant: (uuid ) => client.delete(`${baseUrl}/tenants/${uuid}`),
2430
-
2431
- createGroup: (name ) => client.post(`${baseUrl}/groups`, { name }),
2432
-
2433
- listGroups: () => client.get(`${baseUrl}/groups`),
2434
-
2435
- deleteGroup: (uuid ) => client.delete(`${baseUrl}/groups/${uuid}`),
2436
-
2437
- createPolicy: (name , description , aclTemplates ) => {
2438
- const body = {
2439
- name,
2440
- description,
2441
- acl_templates: aclTemplates, // deprecated
2442
- acl: aclTemplates,
2443
- };
2444
-
2445
- client.post(`${baseUrl}/policies`, body);
2446
- },
2447
-
2448
- listPolicies: () => client.get(`${baseUrl}/policies`),
2449
-
2450
- deletePolicy: (policyUuid ) =>
2451
- client.delete(`${baseUrl}/policies/${policyUuid}`),
2452
-
2453
- getProviders: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}/external`),
2454
-
2455
- getProviderToken: (userUuid , provider ) =>
2456
- client.get(`${baseUrl}/users/${userUuid}/external/${provider}`),
2457
-
2458
- getProviderAuthUrl: (userUuid , provider ) =>
2459
- client.post(`${baseUrl}/users/${userUuid}/external/${provider}`, {}),
2460
-
2461
- deleteProviderToken: (userUuid , provider ) =>
2462
- client.delete(`${baseUrl}/users/${userUuid}/external/${provider}`),
2463
- });
2464
-
2465
- /* */
2466
-
2467
-
2468
- var applicationMethods = (client , baseUrl ) => ({
2469
- bridgeCall(
2470
- applicationUuid ,
2471
- callId ,
2472
- context ,
2473
- exten ,
2474
- autoanswer ,
2475
- displayed_caller_id_number ,
2476
- ) {
2477
- const url = `${baseUrl}/${applicationUuid}/nodes`;
2478
- const body = { calls: [{ id: callId }] };
2479
-
2480
- return client
2481
- .post(url, body, null, res => res.json().then(response => response.uuid))
2482
- .then(nodeUuid =>
2483
- client
2484
- .post(`${url}/${nodeUuid}/calls`, { context, exten, autoanswer, displayed_caller_id_number })
2485
- .then(data => ({
2486
- nodeUuid,
2487
- data,
2488
- })));
2489
- },
2490
-
2491
- answerCall: (applicationUuid , callId ) =>
2492
- client.put(`${baseUrl}/${applicationUuid}/calls/${callId}/answer`, {}, null, ApiRequester.successResponseParser),
2493
-
2494
- calls: (applicationUuid ) => client.get(`${baseUrl}/${applicationUuid}/calls`),
2495
-
2496
- hangupCall: (applicationUuid , callId ) =>
2497
- client.delete(`${baseUrl}/${applicationUuid}/calls/${callId}`),
2498
-
2499
- startPlaybackCall: (applicationUuid , callId , language , uri ) =>
2500
- client.post(`${baseUrl}/${applicationUuid}/calls/${callId}/playbacks`, { language, uri }),
2501
-
2502
- stopPlaybackCall: (applicationUuid , playbackUuid ) =>
2503
- client.delete(`${baseUrl}/${applicationUuid}/playbacks/${playbackUuid}`),
2504
-
2505
- startProgressCall: (applicationUuid , callId ) =>
2506
- client.put(
2507
- `${baseUrl}/${applicationUuid}/calls/${callId}/progress/start`,
2508
- {},
2509
- null,
2510
- ApiRequester.successResponseParser,
2511
- ),
2512
-
2513
- stopProgressCall: (applicationUuid , callId ) =>
2514
- client.put(
2515
- `${baseUrl}/${applicationUuid}/calls/${callId}/progress/stop`,
2516
- {},
2517
- null,
2518
- ApiRequester.successResponseParser,
2519
- ),
2520
-
2521
- startMohCall: (applicationUuid , callId , mohUuid ) =>
2522
- client.put(
2523
- `${baseUrl}/${applicationUuid}/calls/${callId}/moh/${mohUuid}/start`,
2524
- {},
2525
- null,
2526
- ApiRequester.successResponseParser,
2527
- ),
2528
-
2529
- stopMohCall: (applicationUuid , callId ) =>
2530
- client.put(`${baseUrl}/${applicationUuid}/calls/${callId}/moh/stop`, {}, null, ApiRequester.successResponseParser),
2531
-
2532
- startHoldCall: (applicationUuid , callId ) =>
2533
- client.put(
2534
- `${baseUrl}/${applicationUuid}/calls/${callId}/hold/start`,
2535
- {},
2536
- null,
2537
- ApiRequester.successResponseParser,
2538
- ),
2539
-
2540
- stopHoldCall: (applicationUuid , callId ) =>
2541
- client.put(`${baseUrl}/${applicationUuid}/calls/${callId}/hold/stop`, {}, null, ApiRequester.successResponseParser),
2542
-
2543
- startMuteCall: (applicationUuid , callId ) =>
2544
- client.put(
2545
- `${baseUrl}/${applicationUuid}/calls/${callId}/mute/start`,
2546
- {},
2547
- null,
2548
- ApiRequester.successResponseParser,
2549
- ),
2550
-
2551
- stopMuteCall: (applicationUuid , callId ) =>
2552
- client.put(`${baseUrl}/${applicationUuid}/calls/${callId}/mute/stop`, {}, null, ApiRequester.successResponseParser),
2553
-
2554
- sendDTMFCall: (applicationUuid , callId , digits ) =>
2555
- client.put(`${baseUrl}/${applicationUuid}/calls/${callId}/dtmf`, { digits }, null,
2556
- ApiRequester.successResponseParser),
2557
-
2558
- addCallNodes: (applicationUuid , nodeUuid , callId ) =>
2559
- client.put(
2560
- `${baseUrl}/${applicationUuid}/nodes/${nodeUuid}/calls/${callId}`,
2561
- {},
2562
- null,
2563
- ApiRequester.successResponseParser,
2564
- ),
2565
-
2566
- createNewNodeWithCall: (applicationUuid , calls ) =>
2567
- client.post(`${baseUrl}/${applicationUuid}/nodes`, { calls }),
2568
-
2569
- addNewCallNodes: (applicationUuid , nodeUuid , context , exten , autoanswer ) =>
2570
- client.post(`${baseUrl}/${applicationUuid}/nodes/${nodeUuid}/calls`, { context, exten, autoanswer }),
2571
-
2572
- listCallsNodes: (applicationUuid , nodeUuid ) =>
2573
- client.get(`${baseUrl}/${applicationUuid}/nodes/${nodeUuid}`),
2574
-
2575
- listNodes: (applicationUuid ) => client.get(`${baseUrl}/${applicationUuid}/nodes`),
2576
-
2577
- removeNode: (applicationUuid , nodeUuid ) =>
2578
- client.delete(`${baseUrl}/${applicationUuid}/nodes/${nodeUuid}`),
2579
-
2580
- removeCallNodes: (applicationUuid , nodeUuid , callId ) =>
2581
- client.delete(`${baseUrl}/${applicationUuid}/nodes/${nodeUuid}/calls/${callId}`),
2582
-
2583
- listSnoop: (applicationUuid ) =>
2584
- client.get(`${baseUrl}/${applicationUuid}/snoops`),
2585
-
2586
- removeSnoop: (applicationUuid , snoopUuid ) =>
2587
- client.delete(`${baseUrl}/${applicationUuid}/snoops/${snoopUuid}`),
2588
-
2589
- viewSnoop: (applicationUuid , snoopUuid ) =>
2590
- client.get(`${baseUrl}/${applicationUuid}/snoops/${snoopUuid}`),
2591
-
2592
- createSnoop: (applicationUuid , callId , snoopingCallId , whisperMode ) =>
2593
- client.post(`${baseUrl}/${applicationUuid}/calls/${callId}/snoops`,
2594
- { snooping_call_id: snoopingCallId, whisper_mode: whisperMode }),
2595
-
2596
- updateSnoop: (applicationUuid , snoopUuid , whisperMode ) =>
2597
- client.put(`${baseUrl}/${applicationUuid}/snoops/${snoopUuid}`, { whisper_mode: whisperMode }, null,
2598
- ApiRequester.successResponseParser),
2599
- });
2600
-
2601
- //
2602
-
2603
-
2604
-
2605
-
2606
-
2607
-
2608
-
2609
-
2610
-
2611
-
2612
-
2613
-
2614
-
2615
-
2616
-
2617
- class ExternalApp {
2618
-
2619
-
2620
-
2621
-
2622
- static parse(plain ) {
2623
- return new ExternalApp({
2624
- name: plain.name,
2625
- configuration: plain.configuration,
2626
- });
2627
- }
2628
-
2629
- static parseMany(plain ) {
2630
- return plain.items.map(item => ExternalApp.parse(item));
2631
- }
2632
-
2633
- static newFrom(profile ) {
2634
- return newFrom(profile, ExternalApp);
2635
- }
2636
-
2637
- constructor({ name, configuration } = {}) {
2638
- this.name = name;
2639
- this.configuration = configuration;
2640
-
2641
- // Useful to compare instead of instanceof with minified code
2642
- this.type = 'ExternalApp';
2643
- }
2644
- }
2645
-
2646
- //
2647
-
2648
- class MeetingAuthorization {
2649
-
2650
-
2651
-
2652
-
2653
-
2654
-
2655
- constructor({
2656
- meetingUuid,
2657
- uuid,
2658
- userUuid,
2659
- userName,
2660
- } = {}) {
2661
- this.meetingUuid = meetingUuid;
2662
- this.uuid = uuid;
2663
- this.userUuid = userUuid;
2664
- this.userName = userName;
2665
- }
2666
-
2667
- setStatus(status ) {
2668
- this.status = status;
2669
- }
2670
-
2671
- getStatus() {
2672
- return this.status;
2673
- }
2674
-
2675
- static parse(plain ) {
2676
- const {
2677
- meeting_uuid: meetingUuid,
2678
- uuid,
2679
- guest_uuid: userUuid,
2680
- guest_name: userName,
2681
- } = plain;
2682
-
2683
- return new MeetingAuthorization({
2684
- meetingUuid,
2685
- uuid,
2686
- userUuid,
2687
- userName,
2688
- });
2689
- }
2690
-
2691
- static parseMany(items ) {
2692
- if (!items) {
2693
- return [];
2694
- }
2695
- return items.map(MeetingAuthorization.parse);
2696
- }
2697
- }
2698
-
2699
- //
2700
-
2701
-
2702
-
2703
-
2704
-
2705
-
2706
-
2707
-
2708
-
2709
-
2710
-
2711
-
2712
-
2713
-
2714
-
2715
-
2716
-
2717
-
2718
-
2719
-
2720
-
2721
-
2722
-
2723
-
2724
-
2725
- class Meeting {
2726
-
2727
-
2728
-
2729
-
2730
-
2731
-
2732
-
2733
-
2734
-
2735
-
2736
-
2737
-
2738
-
2739
-
2740
- static parse(plain ) {
2741
- return new Meeting({
2742
- guestSipAuthorization: plain.guest_sip_authorization,
2743
- uri: plain.ingress_http_uri,
2744
- name: plain.name,
2745
- ownerUuids: plain.owner_uuids,
2746
- port: plain.port,
2747
- uuid: plain.uuid,
2748
- extension: plain.exten,
2749
- persistent: plain.persistent,
2750
- creationTime: moment__default['default'](plain.creation_time).toDate(),
2751
- requireAuthorization: plain.require_authorization,
2752
- });
2753
- }
2754
-
2755
- static parseMany(items ) {
2756
- if (!items) {
2757
- return [];
2758
- }
2759
- return items.map(plain => Meeting.parse(plain));
2760
- }
2761
-
2762
- static newFrom(meeting ) {
2763
- return newFrom(meeting, Meeting);
2764
- }
2765
-
2766
- constructor({
2767
- uuid,
2768
- name,
2769
- guestSipAuthorization,
2770
- ownerUuids,
2771
- port,
2772
- uri,
2773
- extension,
2774
- persistent,
2775
- creationTime,
2776
- requireAuthorization,
2777
- } = {}) {
2778
- this.guestSipAuthorization = guestSipAuthorization;
2779
- this.uri = uri;
2780
- this.name = name;
2781
- this.ownerUuids = ownerUuids;
2782
- this.port = port;
2783
- this.uuid = uuid;
2784
- this.extension = extension;
2785
- this.persistent = persistent;
2786
- this.creationTime = creationTime;
2787
- this.requireAuthorization = requireAuthorization;
2788
-
2789
- // Useful to compare instead of instanceof with minified code
2790
- this.type = 'Meeting';
2791
- }
2792
-
2793
- getGuestSipCredentials() {
2794
- // eslint-disable-next-line no-undef
2795
- const [username, secret] = atob(this.guestSipAuthorization).split(':');
2796
- return { username, secret };
2797
- }
2798
-
2799
- }
2800
-
2801
- //
2802
-
2803
- const camelToUnderscore = (key ) => {
2804
- if (typeof key !== 'string') {
2805
- throw new Error('Input is not a string');
2806
- }
2807
- return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2808
- };
2809
-
2810
- //
2811
-
2812
- const convertKeysFromCamelToUnderscore = (args ) => {
2813
- if (!args || typeof args !== 'object' || Array.isArray(args)) {
2814
- throw new Error('Input is not an object');
2815
- }
2816
-
2817
- return Object.keys(args).reduce((acc, key) => {
2818
- acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2819
- ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2820
- return acc;
2821
- }, {});
2822
- };
2823
-
2824
- /* */
2825
-
2826
- var confdMethods = (client , baseUrl ) => ({
2827
- listUsers: () => client.get(`${baseUrl}/users`, null),
2828
-
2829
- getUser: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}`, null).then(Profile.parse),
2830
-
2831
- updateUser: (userUuid , profile ) => {
2832
- const body = {
2833
- firstname: profile.firstName,
2834
- lastname: profile.lastName,
2835
- email: profile.email,
2836
- mobile_phone_number: profile.mobileNumber,
2837
- };
2838
-
2839
- return client.put(`${baseUrl}/users/${userUuid}`, body, null, ApiRequester.successResponseParser);
2840
- },
2841
-
2842
- updateForwardOption: (userUuid , key , destination , enabled ) => {
2843
- const url = `${baseUrl}/users/${userUuid}/forwards/${key}`;
2844
- return client.put(url, { destination, enabled }, null, ApiRequester.successResponseParser);
2845
- },
2846
-
2847
- updateDoNotDisturb: (userUuid , enabled ) =>
2848
- client.put(`${baseUrl}/users/${userUuid}/services/dnd`, { enabled }, null, ApiRequester.successResponseParser),
2849
-
2850
- getUserLineSip: (userUuid , lineId ) =>
2851
- client.get(`${baseUrl}/users/${userUuid}/lines/${lineId}/associated/endpoints/sip?view=merged`).then(SipLine.parse),
2852
-
2853
- getUserLinesSip(userUuid , lineIds ) {
2854
- // We have to catch all exception, unless Promise.all will returns an empty array for 2 lines with a custom one:
2855
- // The custom line will throw a 404 and break the Promise.all.
2856
- // $FlowFixMe
2857
- return Promise.all(lineIds.map(lineId => this.getUserLineSip(userUuid, lineId).catch(() => null)));
2858
- },
2859
-
2860
- getUserLineSipFromToken(userUuid ) {
2861
- return this.getUser(userUuid).then(user => {
2862
- if (!user.lines.length) {
2863
- console.warn(`No sip line for user: ${userUuid}`);
2864
- return null;
2865
- }
2866
- const line = user.lines[0];
2867
-
2868
- return this.getUserLineSip(userUuid, line.uuid || line.id);
2869
- });
2870
- },
2871
-
2872
- listApplications: () => client.get(`${baseUrl}/applications`, null),
2873
-
2874
- getInfos: () => client.get(`${baseUrl}/infos`, null),
2875
-
2876
- getExternalApps: (userUuid ) =>
2877
- client.get(`${baseUrl}/users/${userUuid}/external/apps`).then(ExternalApp.parseMany),
2878
-
2879
- getExternalApp: async (userUuid , name ) => {
2880
- const url = `${baseUrl}/users/${userUuid}/external/apps/${name}?view=fallback`;
2881
-
2882
- try {
2883
- return await client.get(url).then(ExternalApp.parse);
2884
- } catch (e) {
2885
- return null;
2886
- }
2887
- },
2888
-
2889
- getMyMeetings: () =>
2890
- client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2891
-
2892
- createMyMeeting: (args ) =>
2893
- client
2894
- .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2895
- .then(Meeting.parse),
2896
-
2897
- updateMyMeeting: (meetingUuid , data ) =>
2898
- client.put(
2899
- `${baseUrl}/users/me/meetings/${meetingUuid}`,
2900
- convertKeysFromCamelToUnderscore(data),
2901
- null,
2902
- ApiRequester.successResponseParser,
2903
- ),
2904
-
2905
- deleteMyMeeting: (meetingUuid ) =>
2906
- client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
2907
-
2908
- getMeeting: (meetingUuid ) =>
2909
- client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2910
-
2911
- meetingAuthorizations: (meetingUuid ) =>
2912
- client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2913
-
2914
- meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2915
- client.put(
2916
- `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2917
- {},
2918
- null,
2919
- ApiRequester.successResponseParser,
2920
- ),
2921
-
2922
- meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2923
- client.put(
2924
- `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2925
- {},
2926
- null,
2927
- ApiRequester.successResponseParser,
2928
- ),
2929
-
2930
- guestGetMeeting: (meetingUuid ) =>
2931
- client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2932
-
2933
- guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2934
- client
2935
- .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2936
- .then(MeetingAuthorization.parse),
2937
-
2938
- guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2939
- client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2940
-
2941
- });
2942
-
2943
- //
2944
-
2945
-
2946
-
2947
-
2948
-
2949
-
2950
-
2951
-
2952
-
2953
-
2954
-
2955
-
2956
-
2957
-
2958
-
2959
-
2960
- class Relocation {
2961
-
2962
-
2963
-
2964
-
2965
-
2966
-
2967
-
2968
-
2969
- static parse(response ) {
2970
- return new Relocation({
2971
- initiatorCall: response.initiator_call,
2972
- recipientCall: response.recipient_call,
2973
- relocatedCall: response.relocated_call,
2974
- });
2975
- }
2976
-
2977
- constructor({ relocatedCall, initiatorCall, recipientCall } ) {
2978
- this.initiatorCall = initiatorCall || '';
2979
- this.relocatedCall = relocatedCall || '';
2980
- this.recipientCall = recipientCall || '';
2981
- }
2982
- }
2983
-
2984
- Relocation.MIN_ENGINE_VERSION_REQUIRED = '19.09';
2985
-
2986
- //
2987
-
2988
-
2989
-
2990
-
2991
-
2992
-
2993
-
2994
-
2995
-
2996
-
2997
-
2998
-
2999
-
3000
-
3001
-
3002
-
3003
-
3004
-
3005
-
3006
-
3007
-
3008
-
3009
-
3010
-
3011
-
3012
-
3013
-
3014
-
3015
- class ChatMessage {
3016
-
3017
-
3018
-
3019
-
3020
-
3021
-
3022
-
3023
-
3024
-
3025
-
3026
- static parseMany(plain ) {
3027
- if (!plain || !plain.items) {
3028
- return [];
3029
- }
3030
-
3031
- return plain.items.map(item => ChatMessage.parse(item));
3032
- }
3033
-
3034
- static parse(plain ) {
3035
- return new ChatMessage({
3036
- uuid: plain.uuid,
3037
- date: moment__default['default'](plain.created_at).toDate(),
3038
- content: plain.content,
3039
- alias: plain.alias,
3040
- userUuid: plain.user_uuid,
3041
- read: true,
3042
- roomUuid: plain.room ? plain.room.uuid : null,
3043
- });
3044
- }
3045
-
3046
- static newFrom(message ) {
3047
- return newFrom(message, ChatMessage);
3048
- }
3049
-
3050
- constructor({ uuid, date, content, userUuid, alias, roomUuid, read } = {}) {
3051
- this.uuid = uuid;
3052
- this.date = date;
3053
- this.content = content;
3054
- this.userUuid = userUuid;
3055
- this.alias = alias;
3056
- this.roomUuid = roomUuid;
3057
-
3058
- // @TODO: change after message read status available
3059
- this.read = read;
3060
-
3061
- // Useful to compare instead of instanceof with minified code
3062
- this.type = 'ChatMessage';
3063
- }
3064
-
3065
- is(other ) {
3066
- return this.uuid === other.uuid;
3067
- }
3068
-
3069
- isIncoming(userUuid ) {
3070
- return this.userUuid !== userUuid;
3071
- }
3072
-
3073
- acknowledge() {
3074
- // @TODO: change after message read status available
3075
- this.read = true;
3076
- return this;
3077
- }
3078
- }
3079
-
3080
- //
3081
-
3082
-
3083
-
3084
-
3085
-
3086
-
3087
-
3088
-
3089
-
3090
-
3091
-
3092
-
3093
-
3094
-
3095
-
3096
-
3097
-
3098
-
3099
-
3100
-
3101
-
3102
-
3103
-
3104
-
3105
-
3106
-
3107
-
3108
-
3109
-
3110
-
3111
-
3112
-
3113
-
3114
- class Voicemail {
3115
-
3116
-
3117
-
3118
-
3119
-
3120
-
3121
-
3122
-
3123
-
3124
-
3125
-
3126
- static parse(plain ) {
3127
- return new Voicemail({
3128
- id: plain.id,
3129
- date: moment__default['default'](plain.timestamp * 1000).toDate(),
3130
- duration: plain.duration * 1000,
3131
- caller: {
3132
- name: plain.caller_id_name,
3133
- number: plain.caller_id_num,
3134
- },
3135
- unread: plain.folder ? plain.folder.type === 'new' : null,
3136
- });
3137
- }
3138
-
3139
- static parseMany(plain ) {
3140
- if (!plain) {
3141
- return [];
3142
- }
3143
- const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3144
- const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3145
-
3146
- const unread = plainUnread.map(message => Voicemail.parse(message)).map(voicemail => voicemail.makeAsUnRead());
3147
- const read = plainRead.map(message => Voicemail.parse(message)).map(voicemail => voicemail.acknowledge());
3148
-
3149
- return [...unread, ...read];
3150
- }
3151
-
3152
- static newFrom(profile ) {
3153
- return newFrom(profile, Voicemail);
3154
- }
3155
-
3156
- constructor({ id, date, duration, caller, unread } = {}) {
3157
- this.id = id;
3158
- this.date = date;
3159
- this.duration = duration;
3160
- this.caller = caller;
3161
- this.unread = unread;
3162
-
3163
- // Useful to compare instead of instanceof with minified code
3164
- this.type = 'Voicemail';
3165
- }
3166
-
3167
- is(other ) {
3168
- return other && this.id === other.id;
3169
- }
3170
-
3171
- acknowledge() {
3172
- this.unread = false;
3173
-
3174
- return this;
3175
- }
3176
-
3177
- makeAsUnRead() {
3178
- this.unread = true;
3179
-
3180
- return this;
3181
- }
3182
-
3183
- contains(query ) {
3184
- if (!query) {
3185
- return true;
3186
- }
3187
-
3188
- return this.caller.name.toUpperCase().includes(query.toUpperCase()) || this.caller.number.includes(query);
3189
- }
3190
- }
3191
-
3192
- //
3193
-
3194
- const RECORD_STATE_ACTIVE = 'active';
3195
-
3196
-
3197
-
3198
-
3199
-
3200
-
3201
-
3202
-
3203
-
3204
-
3205
-
3206
-
3207
-
3208
-
3209
-
3210
-
3211
-
3212
-
3213
-
3214
-
3215
-
3216
-
3217
-
3218
-
3219
-
3220
-
3221
-
3222
-
3223
-
3224
-
3225
-
3226
-
3227
-
3228
-
3229
-
3230
-
3231
-
3232
-
3233
-
3234
- class Call {
3235
-
3236
-
3237
-
3238
-
3239
-
3240
-
3241
-
3242
-
3243
-
3244
-
3245
-
3246
-
3247
-
3248
-
3249
-
3250
-
3251
-
3252
-
3253
-
3254
- static parseMany(plain ) {
3255
- if (!plain) {
3256
- return [];
3257
- }
3258
- return plain.map((plainCall ) => Call.parse(plainCall));
3259
- }
3260
-
3261
- static parse(plain ) {
3262
- return new Call({
3263
- id: plain.call_id,
3264
- sipCallId: plain.sip_call_id,
3265
- callerName: plain.caller_id_name,
3266
- callerNumber: plain.caller_id_number,
3267
- calleeName: plain.peer_caller_id_name,
3268
- calleeNumber: plain.peer_caller_id_number,
3269
- dialedExtension: plain.dialed_extension,
3270
- isCaller: plain.is_caller,
3271
- isVideo: plain.is_video,
3272
- muted: plain.muted,
3273
- onHold: plain.on_hold,
3274
- status: plain.status,
3275
- lineId: plain.line_id,
3276
- startingTime: moment__default['default'](plain.creation_time).toDate(),
3277
- talkingToIds: Object.keys(plain.talking_to || {}),
3278
- recording: plain.record_state === RECORD_STATE_ACTIVE,
3279
- });
3280
- }
3281
-
3282
- static newFrom(call ) {
3283
- return newFrom(call, Call);
3284
- }
3285
-
3286
- constructor({
3287
- id,
3288
- sipCallId,
3289
- callerName,
3290
- callerNumber,
3291
- calleeName,
3292
- calleeNumber,
3293
- dialedExtension,
3294
- isCaller,
3295
- isVideo,
3296
- lineId,
3297
- muted,
3298
- onHold,
3299
- status,
3300
- startingTime,
3301
- talkingToIds,
3302
- recording,
3303
- } = {}) {
3304
- this.id = id;
3305
- this.sipCallId = sipCallId;
3306
- this.callerName = callerName;
3307
- this.callerNumber = callerNumber;
3308
- this.calleeName = calleeName;
3309
- this.calleeNumber = calleeNumber;
3310
- this.dialedExtension = dialedExtension;
3311
- this.muted = muted;
3312
- this.onHold = onHold;
3313
- this.isCaller = isCaller;
3314
- this.lineId = lineId;
3315
- this.status = status;
3316
- this.startingTime = startingTime;
3317
- this.talkingToIds = talkingToIds || [];
3318
- this.recording = recording;
3319
- this.isVideo = !!isVideo;
3320
-
3321
- // Useful to compare instead of instanceof with minified code
3322
- this.type = 'Call';
3323
- }
3324
-
3325
- getElapsedTimeInSeconds() {
3326
- const now = Date.now();
3327
- return (now - this.startingTime) / 1000;
3328
- }
3329
-
3330
- separateCalleeName() {
3331
- const names = this.calleeName.split(' ');
3332
- const firstName = names[0];
3333
- const lastName = names.slice(1).join(' ');
3334
-
3335
- return { firstName, lastName };
3336
- }
3337
-
3338
- is(other ) {
3339
- return !!other && this.id === other.id;
3340
- }
3341
-
3342
- hasACalleeName() {
3343
- return this.calleeName.length > 0;
3344
- }
3345
-
3346
- hasNumber(number ) {
3347
- return this.calleeNumber === number;
3348
- }
3349
-
3350
- isUp() {
3351
- return this.status === 'Up';
3352
- }
3353
-
3354
- isDown() {
3355
- return this.status === 'Down';
3356
- }
3357
-
3358
- isRinging() {
3359
- return this.isRingingIncoming() || this.isRingingOutgoing();
3360
- }
3361
-
3362
- isRingingIncoming() {
3363
- return this.status === 'Ringing';
3364
- }
3365
-
3366
- isRingingOutgoing() {
3367
- return this.status === 'Ring';
3368
- }
3369
-
3370
- isFromTransfer() {
3371
- return this.status === 'Down' || this.status === 'Ringing';
3372
- }
3373
-
3374
- isOnHold() {
3375
- return this.onHold;
3376
- }
3377
-
3378
- putOnHold() {
3379
- this.onHold = true;
3380
- }
3381
-
3382
- resume() {
3383
- this.onHold = false;
3384
- }
3385
-
3386
- isRecording() {
3387
- return this.recording;
3388
- }
3389
- }
3390
-
3391
- //
3392
- /* eslint-disable no-param-reassign */
3393
-
3394
- var updateFrom = (instance , from ) => {
3395
- Object.keys(from).forEach(key => {
3396
- // $FlowFixMe
3397
- if (
3398
- (!instance[key] && from[key])
3399
- || (typeof instance[key] !== 'undefined' && typeof from[key] !== 'undefined' && instance[key] !== from[key])
3400
- ) {
3401
- // $FlowFixMe
3402
- instance[key] = from[key];
3403
- }
3404
- });
3405
- };
3406
-
3407
- //
3408
-
3409
-
3410
-
3411
-
3412
-
3413
-
3414
-
3415
-
3416
-
3417
-
3418
-
3419
-
3420
-
3421
-
3422
-
3423
-
3424
-
3425
- class Recording {
3426
-
3427
-
3428
-
3429
-
3430
-
3431
-
3432
- static parseMany(recordings = []) {
3433
- if (!recordings) {
3434
- return [];
3435
- }
3436
- return recordings.map(item => Recording.parse(item));
3437
- }
3438
-
3439
- static parse(plain ) {
3440
- return new Recording({
3441
- deleted: plain.deleted,
3442
- fileName: plain.filename,
3443
- end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
3444
- start: moment__default['default'](plain.start_time).toDate(),
3445
- uuid: plain.uuid,
3446
- });
3447
- }
3448
-
3449
- constructor({ deleted, end, fileName, start, uuid } ) {
3450
- this.deleted = deleted;
3451
- this.end = end;
3452
- this.fileName = fileName;
3453
- this.start = start;
3454
- this.uuid = uuid;
3455
- }
3456
- }
3457
-
3458
- //
3459
-
3460
-
3461
-
3462
-
3463
-
3464
-
3465
-
3466
-
3467
-
3468
-
3469
-
3470
-
3471
-
3472
-
3473
-
3474
-
3475
-
3476
-
3477
-
3478
-
3479
-
3480
-
3481
-
3482
-
3483
-
3484
-
3485
-
3486
-
3487
-
3488
-
3489
-
3490
-
3491
-
3492
-
3493
-
3494
-
3495
-
3496
-
3497
-
3498
-
3499
-
3500
-
3501
-
3502
-
3503
-
3504
-
3505
-
3506
-
3507
- class CallLog {
3508
-
3509
-
3510
-
3511
-
3512
-
3513
-
3514
-
3515
-
3516
-
3517
-
3518
-
3519
-
3520
-
3521
-
3522
-
3523
-
3524
-
3525
-
3526
-
3527
-
3528
-
3529
-
3530
-
3531
- static merge(current , toMerge ) {
3532
- const onlyUnique = (value, index, self) => self.indexOf(value) === index;
3533
-
3534
- const allLogs = current.concat(toMerge);
3535
- const onlyUniqueIds = allLogs.map(c => c.id).filter(onlyUnique);
3536
-
3537
- return onlyUniqueIds.map(id => allLogs.find(log => log && log.id === id));
3538
- }
3539
-
3540
- static parseMany(plain ) {
3541
- if (!plain || !plain.items) {
3542
- return [];
3543
- }
3544
-
3545
- return plain.items.map(item => CallLog.parse(item));
3546
- }
3547
-
3548
- static parse(plain ) {
3549
- return new CallLog({
3550
- answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3551
- answered: plain.answered,
3552
- callDirection: plain.call_direction,
3553
- destination: {
3554
- // @TEMP: Temporarily assuming empty numbers are meetings
3555
- // which is admittedly a very dangerous assumption. Did i mention it was temporary?
3556
- extension: plain.requested_extension
3557
- || plain.destination_extension
3558
- || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3559
- name: plain.requested_name || plain.destination_name || '',
3560
- uuid: plain.destination_user_uuid,
3561
- },
3562
- source: {
3563
- extension: plain.source_extension,
3564
- name: plain.source_name,
3565
- uuid: plain.source_user_uuid,
3566
- },
3567
- id: plain.id,
3568
- duration: (plain.duration || 0) * 1000, // duration is in seconds
3569
- start: moment__default['default'](plain.start).toDate(),
3570
- end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3571
- recordings: Recording.parseMany(plain.recordings || []),
3572
- });
3573
- }
3574
-
3575
- static parseNew(plain , session ) {
3576
- const callLog = CallLog.parse(plain);
3577
- // @TODO: FIXME add verification declined vs missed call
3578
- callLog.newMissedCall = session
3579
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
3580
- return callLog;
3581
- }
3582
-
3583
- static newFrom(profile ) {
3584
- return newFrom(profile, CallLog);
3585
- }
3586
-
3587
- constructor({
3588
- answer,
3589
- answered,
3590
- callDirection,
3591
- destination,
3592
- source,
3593
- id,
3594
- duration,
3595
- start,
3596
- end,
3597
- recordings,
3598
- } = {}) {
3599
- this.answer = answer;
3600
- this.answered = answered;
3601
- this.callDirection = callDirection;
3602
- this.destination = destination;
3603
- this.source = source;
3604
- this.id = id;
3605
- this.duration = duration;
3606
- this.start = start;
3607
- this.end = end;
3608
- this.recordings = recordings || [];
3609
-
3610
- // Useful to compare instead of instanceof with minified code
3611
- this.type = 'CallLog';
3612
- }
3613
-
3614
- isFromSameParty(other , session ) {
3615
- return this.theOtherParty(session).extension === other.theOtherParty(session).extension;
3616
- }
3617
-
3618
- theOtherParty(session ) {
3619
- if (this.callDirection === 'inbound') {
3620
- return this.source;
3621
- }
3622
-
3623
- if (this.callDirection === 'outbound') {
3624
- return this.destination;
3625
- }
3626
-
3627
- return session && session.hasExtension(this.source.extension) ? this.destination : this.source;
3628
- }
3629
-
3630
- isNewMissedCall() {
3631
- return this.newMissedCall;
3632
- }
3633
-
3634
- acknowledgeCall() {
3635
- this.newMissedCall = false;
3636
-
3637
- return this;
3638
- }
3639
-
3640
- isAcknowledged() {
3641
- return this.newMissedCall;
3642
- }
3643
-
3644
- isAnswered() {
3645
- return this.answered;
3646
- }
3647
-
3648
- isOutgoing(session ) {
3649
- if (this.callDirection === 'internal') {
3650
- return session.hasExtension(this.source.extension);
3651
- }
3652
-
3653
- return this.callDirection === 'outbound';
3654
- }
3655
-
3656
- isIncoming(session ) {
3657
- if (this.callDirection === 'internal') {
3658
- return session.hasExtension(this.destination.extension);
3659
- }
3660
-
3661
- return this.callDirection === 'inbound';
3662
- }
3663
-
3664
- isAnOutgoingCall(session ) {
3665
- console.warn(`@wazo/sdk
3666
- CallLog.isAnOutgoingcall(session) method is obsolete.
3667
- Please use CallLog.isOutgoing(session).
3668
- `);
3669
-
3670
- return session.hasExtension(this.source.extension) && this.answered;
3671
- }
3672
-
3673
- isAMissedOutgoingCall(session ) {
3674
- return session.hasExtension(this.source.extension) && !this.answered;
3675
- }
3676
-
3677
- isAnIncomingCall(session ) {
3678
- console.warn(`@wazo/sdk
3679
- CallLog.isAnIncomingCall(session) method is obsolete.
3680
- Please use CallLog.isIncoming(session).
3681
- `);
3682
-
3683
- return session.hasExtension(this.destination.extension) && this.answered;
3684
- }
3685
-
3686
- isADeclinedCall(session ) {
3687
- return !this.answered && session.hasExtension(this.destination.extension);
3688
- }
3689
-
3690
- getRecordings() {
3691
- return this.recordings;
3692
- }
3693
- }
3694
-
3695
- //
3696
-
3697
-
3698
-
3699
-
3700
-
3701
-
3702
-
3703
-
3704
-
3705
-
3706
-
3707
-
3708
-
3709
-
3710
-
3711
-
3712
-
3713
-
3714
- class IndirectTransfer {
3715
-
3716
-
3717
-
3718
-
3719
-
3720
-
3721
-
3722
-
3723
- constructor({ sourceId, destinationId, status, id } ) {
3724
- this.sourceId = sourceId;
3725
- this.destinationId = destinationId;
3726
- this.status = status;
3727
- this.id = id;
3728
- }
3729
-
3730
- static parseFromCallSession(source , destination ) {
3731
- return new IndirectTransfer({
3732
- sourceId: source.getId(),
3733
- destinationId: destination.getId(),
3734
- });
3735
- }
3736
-
3737
- static parseFromApi(plain ) {
3738
- return new IndirectTransfer({
3739
- id: plain.id,
3740
- status: plain.status,
3741
- sourceId: plain.initiator_call,
3742
- destinationId: plain.recipient_call,
3743
- });
3744
- }
3745
-
3746
- destinationIs(callSession ) {
3747
- return callSession.isId(this.destinationId);
3748
- }
3749
-
3750
- sourceIs(callSession ) {
3751
- return callSession.isId(this.sourceId);
3752
- }
3753
-
3754
- updateFrom(indirectTransfer ) {
3755
- updateFrom(this, indirectTransfer);
3756
- }
3757
-
3758
- static newFrom(indirectTransfer ) {
3759
- return newFrom(indirectTransfer, IndirectTransfer);
3760
- }
3761
- }
3762
-
3763
- //
3764
- const TRANSFER_FLOW_BLIND = 'blind';
3765
-
3766
- // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
3767
-
3768
- IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
3769
-
3770
- /* */
3771
-
3772
-
3773
-
3774
-
3775
-
3776
-
3777
-
3778
-
3779
- var ctidNgMethods = (client , baseUrl ) => ({
3780
- updatePresence: (presence ) =>
3781
- client.put(`${baseUrl}/users/me/presences`, { presence }, null, ApiRequester.successResponseParser),
3782
-
3783
- listMessages: (participantUuid , limit ) => {
3784
- const query = {};
3785
-
3786
- if (participantUuid) {
3787
- query.participant_user_uuid = participantUuid;
3788
- }
3789
-
3790
- if (limit) {
3791
- query.limit = limit;
3792
- }
3793
-
3794
- return client.get(`${baseUrl}/users/me/chats`, query).then(ChatMessage.parseMany);
3795
- },
3796
-
3797
- sendMessage: (alias , msg , toUserId ) => {
3798
- const body = { alias, msg, to: toUserId };
3799
-
3800
- return client.post(`${baseUrl}/users/me/chats`, body, null, ApiRequester.successResponseParser);
3801
- },
3802
-
3803
- makeCall: (extension , fromMobile , lineId , allLines = false) => {
3804
- const query = {
3805
- from_mobile: fromMobile,
3806
- extension,
3807
- };
3808
-
3809
- if (lineId) {
3810
- query.line_id = lineId;
3811
- }
3812
-
3813
- if (allLines) {
3814
- query.all_lines = true;
3815
- }
3816
-
3817
- return client.post(`${baseUrl}/users/me/calls`, query);
3818
- },
3819
-
3820
- cancelCall: (callId ) => client.delete(`${baseUrl}/users/me/calls/${callId}`),
3821
-
3822
- listCalls: () =>
3823
- client.get(`${baseUrl}/users/me/calls`).then(response => Call.parseMany(response.items)),
3824
-
3825
- relocateCall(callId , destination , lineId , contact ) {
3826
- const body = {
3827
- completions: ['answer'],
3828
- destination,
3829
- initiator_call: callId,
3830
- auto_answer: true,
3831
- };
3832
-
3833
- if (lineId || contact) {
3834
- body.location = {};
3835
- }
3836
-
3837
- if (lineId) {
3838
- body.location.line_id = lineId;
3839
- }
3840
-
3841
- if (contact) {
3842
- body.location.contact = contact;
3843
- }
3844
-
3845
- return client.post(`${baseUrl}/users/me/relocates`, body).then(response => Relocation.parse(response));
3846
- },
3847
-
3848
- transferCall(
3849
- callId ,
3850
- number ,
3851
- flow = TRANSFER_FLOW_BLIND,
3852
- ) {
3853
- const body = {
3854
- exten: number,
3855
- flow,
3856
- initiator_call: callId,
3857
- };
3858
-
3859
- return client.post(`${baseUrl}/users/me/transfers`, body).then(response => response);
3860
- },
3861
-
3862
- // @TODO: fix response type
3863
- cancelCallTransfer: (transferId ) =>
3864
- client.delete(`${baseUrl}/users/me/transfers/${transferId}`),
3865
-
3866
- // @TODO: fix response type
3867
- confirmCallTransfer: (transferId ) =>
3868
- client.put(`${baseUrl}/users/me/transfers/${transferId}/complete`),
3869
-
3870
- listVoicemails: () =>
3871
- client.get(`${baseUrl}/users/me/voicemails`, null).then(response => Voicemail.parseMany(response)),
3872
-
3873
- deleteVoicemail: (voicemailId ) =>
3874
- client.delete(`${baseUrl}/users/me/voicemails/messages/${voicemailId}`, null),
3875
-
3876
- getPresence: (contactUuid ) =>
3877
- client.get(`${baseUrl}/users/${contactUuid}/presences`, null),
3878
-
3879
- getStatus: (lineUuid ) => client.get(`${baseUrl}/lines/${lineUuid}/presences`, null),
3880
-
3881
- fetchSwitchboardHeldCalls: (switchboardUuid ) =>
3882
- client.get(`${baseUrl}/switchboards/${switchboardUuid}/calls/held`, null),
3883
-
3884
- holdSwitchboardCall: (switchboardUuid , callId ) =>
3885
- client.put(
3886
- `${baseUrl}/switchboards/${switchboardUuid}/calls/held/${callId}`,
3887
- null,
3888
- null,
3889
- ApiRequester.successResponseParser,
3890
- ),
3891
-
3892
- answerSwitchboardHeldCall: (switchboardUuid , callId ) =>
3893
- client.put(`${baseUrl}/switchboards/${switchboardUuid}/calls/held/${callId}/answer`, null),
3894
-
3895
- fetchSwitchboardQueuedCalls: (switchboardUuid ) =>
3896
- client.get(`${baseUrl}/switchboards/${switchboardUuid}/calls/queued`, null),
3897
-
3898
- answerSwitchboardQueuedCall: (switchboardUuid , callId ) =>
3899
- client.put(`${baseUrl}/switchboards/${switchboardUuid}/calls/queued/${callId}/answer`, null),
3900
-
3901
- sendFax: (extension , fax , callerId = null) => {
3902
- const headers = {
3903
- 'Content-type': 'application/pdf',
3904
- 'X-Auth-Token': client.token,
3905
- };
3906
- const params = ApiRequester.getQueryString({ extension, caller_id: callerId });
3907
-
3908
- return client.post(`${baseUrl}/users/me/faxes?${params}`, fax, headers);
3909
- },
3910
-
3911
- });
3912
-
3913
- /* */
3914
-
3915
-
3916
-
3917
-
3918
- const getContactPayload = (contact ) => ({
3919
- email: contact.email,
3920
- firstname: contact.firstName ? contact.firstName : '',
3921
- lastname: contact.lastName ? contact.lastName : '',
3922
- number: contact.phoneNumber ? contact.phoneNumber : '',
3923
- entreprise: contact.entreprise ? contact.entreprise : '',
3924
- birthday: contact.birthday ? contact.birthday : '',
3925
- address: contact.address ? contact.address : '',
3926
- note: contact.note ? contact.note : '',
3927
- });
3928
-
3929
-
3930
-
3931
-
3932
-
3933
-
3934
-
3935
-
3936
-
3937
-
3938
- var dirdMethods = (client , baseUrl ) => ({
3939
- search: (context , term ) =>
3940
- client.get(`${baseUrl}/directories/lookup/${context}`, { term }).then(Contact.parseMany),
3941
-
3942
- listPersonalContacts: (queryParams = null) =>
3943
- client.get(`${baseUrl}/personal`, queryParams).then(response => Contact.parseManyPersonal(response.items)),
3944
-
3945
- fetchPersonalContact: (contactUuid ) =>
3946
- client
3947
- .get(`${baseUrl}/personal/${contactUuid}`)
3948
- .then(Contact.parsePersonal),
3949
-
3950
- addContact: (contact ) =>
3951
- client.post(`${baseUrl}/personal`, getContactPayload(contact)).then(Contact.parsePersonal),
3952
-
3953
- editContact: (contact ) =>
3954
- client
3955
- .put(`${baseUrl}/personal/${contact.sourceId || contact.id || ''}`, getContactPayload(contact))
3956
- .then(Contact.parsePersonal),
3957
-
3958
- importContacts: (csv ) => {
3959
- const headers = {
3960
- 'Content-Type': 'text/csv; charset=utf-8',
3961
- 'X-Auth-Token': client.token,
3962
- };
3963
-
3964
- return client.post(`${baseUrl}/personal/import`, csv, headers)
3965
- .then(result => Contact.parseManyPersonal(result.created));
3966
- },
3967
-
3968
- deleteContact: (contactUuid ) => client.delete(`${baseUrl}/personal/${contactUuid}`),
3969
-
3970
- listFavorites: (context ) =>
3971
- client.get(`${baseUrl}/directories/favorites/${context}`).then(Contact.parseMany),
3972
-
3973
- markAsFavorite: (source , sourceId ) => {
3974
- const url = `${baseUrl}/directories/favorites/${source}/${sourceId}`;
3975
-
3976
- return client.put(url, null, null, ApiRequester.successResponseParser);
3977
- },
3978
-
3979
- removeFavorite: (source , sourceId ) =>
3980
- client.delete(`${baseUrl}/directories/favorites/${source}/${sourceId}`),
3981
-
3982
- fetchOffice365Source: (context ) =>
3983
- client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'office365' }),
3984
-
3985
- fetchOffice365Contacts: (source ,
3986
- queryParams = null) => {
3987
- if (!source) {
3988
- return null;
3989
- }
3990
-
3991
- return client
3992
- .get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams)
3993
- .then(response => Contact.parseManyOffice365(response.items, source));
3994
- },
3995
-
3996
- fetchWazoSource: (context ) =>
3997
- client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'wazo' }),
3998
-
3999
- // Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
4000
- fetchWazoContacts: (source , queryParams = null) => {
4001
- if (!source) {
4002
- return null;
4003
- }
4004
- return client
4005
- .get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams)
4006
- .then(response => Contact.parseManyWazo(response.items, source));
4007
- },
4008
-
4009
- fetchGoogleSource: (context ) =>
4010
- client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'google' }),
4011
-
4012
- fetchGoogleContacts: (source , queryParams = null) => {
4013
- if (!source) {
4014
- return null;
4015
- }
4016
-
4017
- return client
4018
- .get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams)
4019
- .then(response => Contact.parseManyGoogle(response.items, source));
4020
- },
4021
-
4022
- fetchConferenceSource: (context ) =>
4023
- client.get(`${baseUrl}/directories/${context}/sources`, { backend: 'conference' }),
4024
-
4025
- fetchConferenceContacts: (source ) => {
4026
- if (!source) {
4027
- return null;
4028
- }
4029
-
4030
- return client
4031
- .get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`)
4032
- .then(response => Contact.parseManyConference(response.items, source));
4033
- },
4034
-
4035
- // Graphql
4036
- findMultipleContactsByNumber: (numbers , fields = null) => {
4037
- const query = jsonToGraphQLQuery.jsonToGraphQLQuery({
4038
- me: {
4039
- contacts: {
4040
- __args: {
4041
- profile: 'default',
4042
- extens: numbers,
4043
- },
4044
- edges: {
4045
- node: fields || {
4046
- firstname: true,
4047
- lastname: true,
4048
- wazoReverse: true,
4049
- wazoBackend: true,
4050
- email: true,
4051
- wazoSourceEntryId: true,
4052
- wazoSourceName: true,
4053
- '... on WazoContact': {
4054
- userUuid: true,
4055
- },
4056
- },
4057
- },
4058
- },
4059
- },
4060
- });
4061
-
4062
- return client.post(`${baseUrl}/graphql`, { query: `{${query}}` })
4063
- .then(Contact.manyGraphQlWithNumbersParser(numbers));
4064
- },
4065
-
4066
- });
4067
-
4068
- /* */
4069
-
4070
- var callLogdMethods = (client , baseUrl ) => ({
4071
- search: (search , limit = 5) =>
4072
- client.get(`${baseUrl}/users/me/cdr`, { search, limit }).then(CallLog.parseMany),
4073
-
4074
- searchBy: (field , value , limit = 5) =>
4075
- client.get(`${baseUrl}/users/me/cdr`, { [field]: value, limit }).then(CallLog.parseMany),
4076
-
4077
- listCallLogs: (offset , limit = 5) =>
4078
- client.get(`${baseUrl}/users/me/cdr`, { offset, limit }).then(CallLog.parseMany),
4079
-
4080
- listDistinctCallLogs: (offset , limit = 5, distinct ) =>
4081
- client.get(`${baseUrl}/users/me/cdr`, { offset, limit, distinct }).then(CallLog.parseMany),
4082
-
4083
- listCallLogsFromDate: (from , number ) =>
4084
- client.get(`${baseUrl}/users/me/cdr`, { from: from.toISOString(), number }).then(CallLog.parseMany),
4085
- });
4086
-
4087
- //
4088
-
4089
-
4090
-
4091
-
4092
-
4093
-
4094
-
4095
-
4096
-
4097
-
4098
-
4099
-
4100
-
4101
- class ChatRoom {
4102
-
4103
-
4104
-
4105
-
4106
-
4107
-
4108
- static parseMany(plain ) {
4109
- if (!plain || !plain.items) {
4110
- return [];
4111
- }
4112
- return plain.items.map(item => ChatRoom.parse(item));
4113
- }
4114
-
4115
- static parse(plain ) {
4116
- return new ChatRoom({
4117
- uuid: plain.uuid,
4118
- name: plain.name,
4119
- users: plain.users,
4120
- });
4121
- }
4122
-
4123
- static newFrom(room ) {
4124
- return newFrom(room, ChatRoom);
4125
- }
4126
-
4127
- constructor({ uuid, name, users } = {}) {
4128
- this.uuid = uuid;
4129
- this.name = name;
4130
- this.users = users;
4131
-
4132
- // Useful to compare instead of instanceof with minified code
4133
- this.type = 'ChatRoom';
4134
- }
4135
- }
4136
-
4137
- /* */
4138
-
4139
-
4140
-
4141
-
4142
-
4143
-
4144
-
4145
-
4146
-
4147
-
4148
-
4149
-
4150
-
4151
-
4152
-
4153
-
4154
-
4155
-
4156
-
4157
-
4158
-
4159
-
4160
-
4161
-
4162
- var chatdMethods = (client , baseUrl ) => ({
4163
- updateState: (contactUuid , state ) =>
4164
- client.put(`${baseUrl}/users/${contactUuid}/presences`, { state }, null, ApiRequester.successResponseParser),
4165
-
4166
- updateStatus: (contactUuid , state , status ) => {
4167
- const body = { state, status };
4168
-
4169
- return client.put(`${baseUrl}/users/${contactUuid}/presences`, body, null, ApiRequester.successResponseParser);
4170
- },
4171
-
4172
- getState: async (contactUuid ) =>
4173
- client.get(`${baseUrl}/users/${contactUuid}/presences`).then((response ) => response.state),
4174
-
4175
- getContactStatusInfo: async (contactUuid ) =>
4176
- client.get(`${baseUrl}/users/${contactUuid}/presences`).then((response ) => response),
4177
-
4178
- getLineState: async (contactUuid ) =>
4179
- client
4180
- .get(`${baseUrl}/users/${contactUuid}/presences`)
4181
- .then((response ) => Profile.getLinesState(response.lines)),
4182
-
4183
- getMultipleLineState: async (contactUuids ) => {
4184
- const body = {};
4185
- if (contactUuids && contactUuids.length) {
4186
- body.user_uuid = contactUuids.join(',');
4187
- }
4188
-
4189
- return client.get(`${baseUrl}/users/presences`, body).then((response ) => response.items);
4190
- },
4191
-
4192
- getUserRooms: async () => client.get(`${baseUrl}/users/me/rooms`).then(ChatRoom.parseMany),
4193
-
4194
- createRoom: async (name , users ) =>
4195
- client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4196
-
4197
- getRoomMessages: async (roomUuid , params = {}) => {
4198
- const qs = ApiRequester.getQueryString(params);
4199
-
4200
- return client
4201
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4202
- .then((response ) => ChatMessage.parseMany(response));
4203
- },
4204
-
4205
- sendRoomMessage: async (roomUuid , message ) =>
4206
- client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
4207
-
4208
- getMessages: async (options ) =>
4209
- client.get(`${baseUrl}/users/me/rooms/messages`, options),
4210
- });
4211
-
4212
- //
4213
-
4214
-
4215
-
4216
-
4217
-
4218
- class MeetingStatus {
4219
-
4220
-
4221
-
4222
-
4223
- constructor({
4224
- full,
4225
- } = {}) {
4226
- this.full = full;
4227
-
4228
- // Useful to compare instead of instanceof with minified code
4229
- this.type = 'MeetingStatus';
4230
- }
4231
-
4232
- static parse(plain ) {
4233
- return new MeetingStatus({
4234
- full: plain.full,
4235
- });
4236
- }
4237
-
4238
- }
4239
-
4240
- /* */
4241
-
4242
-
4243
-
4244
-
4245
-
4246
-
4247
-
4248
-
4249
- var calldMethods = (client , baseUrl ) => ({
4250
- updatePresence: (presence ) =>
4251
- client.put(`${baseUrl}/users/me/presences`, { presence }, null, ApiRequester.successResponseParser),
4252
-
4253
- listMessages: (participantUuid , limit ) => {
4254
- const query = {};
4255
-
4256
- if (participantUuid) {
4257
- query.participant_user_uuid = participantUuid;
4258
- }
4259
-
4260
- if (limit) {
4261
- query.limit = limit;
4262
- }
4263
-
4264
- return client.get(`${baseUrl}/users/me/chats`, query).then(response => ChatMessage.parseMany(response));
4265
- },
4266
-
4267
- sendMessage: (alias , msg , toUserId ) => {
4268
- const body = { alias, msg, to: toUserId };
4269
-
4270
- return client.post(`${baseUrl}/users/me/chats`, body, null, ApiRequester.successResponseParser);
4271
- },
4272
-
4273
- makeCall: (extension , fromMobile , lineId , allLines = false) => {
4274
- const query = {
4275
- from_mobile: fromMobile,
4276
- extension,
4277
- };
4278
-
4279
- if (lineId) {
4280
- query.line_id = lineId;
4281
- }
4282
-
4283
- if (allLines) {
4284
- query.all_lines = true;
4285
- }
4286
-
4287
- return client.post(`${baseUrl}/users/me/calls`, query);
4288
- },
4289
-
4290
- cancelCall: (callId ) => client.delete(`${baseUrl}/users/me/calls/${callId}`, null),
4291
-
4292
- listCalls: () =>
4293
- client.get(`${baseUrl}/users/me/calls`, null).then(response => Call.parseMany(response.items)),
4294
-
4295
- relocateCall(callId , destination , lineId , contact ) {
4296
- const body = {
4297
- completions: ['answer'],
4298
- destination,
4299
- initiator_call: callId,
4300
- auto_answer: true,
4301
- };
4302
-
4303
- if (lineId || contact) {
4304
- body.location = {};
4305
- }
4306
-
4307
- if (lineId) {
4308
- body.location.line_id = lineId;
4309
- }
4310
-
4311
- if (contact) {
4312
- body.location.contact = contact;
4313
- }
4314
-
4315
- return client.post(`${baseUrl}/users/me/relocates`, body).then(response => Relocation.parse(response));
4316
- },
4317
-
4318
- listVoicemails: () =>
4319
- client.get(`${baseUrl}/users/me/voicemails`).then(response => Voicemail.parseMany(response)),
4320
-
4321
- deleteVoicemail: (voicemailId ) =>
4322
- client.delete(`${baseUrl}/users/me/voicemails/messages/${voicemailId}`),
4323
-
4324
- getVoicemailUrl: (voicemail ) => {
4325
- const body = { token: client.token };
4326
-
4327
- return client.computeUrl('get', `${baseUrl}/users/me/voicemails/messages/${voicemail.id}/recording`, body);
4328
- },
4329
-
4330
- fetchSwitchboardHeldCalls: (switchboardUuid ) =>
4331
- client.get(`${baseUrl}/switchboards/${switchboardUuid}/calls/held`),
4332
-
4333
- holdSwitchboardCall: (switchboardUuid , callId ) =>
4334
- client.put(
4335
- `${baseUrl}/switchboards/${switchboardUuid}/calls/held/${callId}`,
4336
- null,
4337
- null,
4338
- ApiRequester.successResponseParser,
4339
- ),
4340
-
4341
- answerSwitchboardHeldCall: (switchboardUuid , callId , lineId = null) =>
4342
- client.put(
4343
- `${baseUrl}/switchboards/${switchboardUuid}/calls/held/${callId}/answer${lineId ? `?line_id=${lineId}` : ''}`,
4344
- ),
4345
-
4346
- fetchSwitchboardQueuedCalls: (switchboardUuid ) =>
4347
- client.get(`${baseUrl}/switchboards/${switchboardUuid}/calls/queued`),
4348
-
4349
- answerSwitchboardQueuedCall: (switchboardUuid , callId , lineId = null) =>
4350
- client.put(
4351
- `${baseUrl}/switchboards/${switchboardUuid}/calls/queued/${callId}/answer${lineId ? `?line_id=${lineId}` : ''}`,
4352
- ),
4353
-
4354
- sendFax: (extension , fax , callerId = null) => {
4355
- const headers = {
4356
- 'Content-type': 'application/pdf',
4357
- 'X-Auth-Token': client.token,
4358
- };
4359
- const params = ApiRequester.getQueryString({ extension, caller_id: callerId });
4360
-
4361
- return client.post(`${baseUrl}/users/me/faxes?${params}`, fax, headers);
4362
- },
4363
-
4364
- getConferenceParticipantsAsUser: async (conferenceId ) =>
4365
- client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
4366
-
4367
- getMeetingParticipantsAsUser: async (meetingUuid ) =>
4368
- client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4369
-
4370
- banMeetingParticipant: (meetingUuid , participantUuid ) =>
4371
- client.delete(
4372
- `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4373
- null,
4374
- null,
4375
- ApiRequester.successResponseParser,
4376
- ),
4377
-
4378
- listTrunks: () => client.get(`${baseUrl}/trunks`),
4379
-
4380
- mute: (callId ) =>
4381
- client.put(`${baseUrl}/users/me/calls/${callId}/mute/start`, null, null, ApiRequester.successResponseParser),
4382
-
4383
- unmute: (callId ) =>
4384
- client.put(`${baseUrl}/users/me/calls/${callId}/mute/stop`, null, null, ApiRequester.successResponseParser),
4385
-
4386
- hold: (callId ) =>
4387
- client.put(`${baseUrl}/users/me/calls/${callId}/hold/start`, null, null, ApiRequester.successResponseParser),
4388
-
4389
- resume: (callId ) =>
4390
- client.put(`${baseUrl}/users/me/calls/${callId}/hold/stop`, null, null, ApiRequester.successResponseParser),
4391
-
4392
- // eslint-disable-next-line camelcase
4393
- transferCall: (initiator_call , exten , flow ) =>
4394
- client.post(`${baseUrl}/users/me/transfers`, { initiator_call, exten, flow }).then(IndirectTransfer.parseFromApi),
4395
-
4396
- confirmCallTransfer: (transferId ) => client.put(`${baseUrl}/users/me/transfers/${transferId}/complete`),
4397
-
4398
- cancelCallTransfer: (transferId ) => client.delete(`${baseUrl}/users/me/transfers/${transferId}`),
4399
-
4400
- sendDTMF: (callId , digits ) =>
4401
- client.put(`${baseUrl}/users/me/calls/${callId}/dtmf?digits=${encodeURIComponent(digits)}`,
4402
- null, null, ApiRequester.successResponseParser),
4403
-
4404
- // @deprecated: check for engine version >= 20.12 instead
4405
- isAhHocConferenceAPIEnabled: () => client.head(`${baseUrl}/users/me/conferences/adhoc`, null, null,
4406
- ApiRequester.successResponseParser),
4407
-
4408
- createAdHocConference: (hostCallId , participantCallIds ) =>
4409
- client.post(`${baseUrl}/users/me/conferences/adhoc`, {
4410
- host_call_id: hostCallId,
4411
- participant_call_ids: participantCallIds,
4412
- }),
4413
-
4414
- addAdHocConferenceParticipant: (conferenceId , callId ) =>
4415
- client.put(`${baseUrl}/users/me/conferences/adhoc/${conferenceId}/participants/${callId}`, null, null,
4416
- ApiRequester.successResponseParser),
4417
-
4418
- removeAdHocConferenceParticipant: (conferenceId , participantCallId ) =>
4419
- client.delete(`${baseUrl}/users/me/conferences/adhoc/${conferenceId}/participants/${participantCallId}`, null, null,
4420
- ApiRequester.successResponseParser),
4421
-
4422
- deleteAdHocConference: (conferenceId ) =>
4423
- client.delete(`${baseUrl}/users/me/conferences/adhoc/${conferenceId}`, null, null,
4424
- ApiRequester.successResponseParser),
4425
-
4426
- startRecording: (callId ) =>
4427
- client.put(`${baseUrl}/users/me/calls/${callId}/record/start`, null, null,
4428
- ApiRequester.successResponseParser),
4429
-
4430
- stopRecording: (callId ) =>
4431
- client.put(`${baseUrl}/users/me/calls/${callId}/record/stop`, null, null,
4432
- ApiRequester.successResponseParser),
4433
-
4434
- pauseRecording: (callId ) =>
4435
- client.put(`${baseUrl}/users/me/calls/${callId}/record/pause`, null, null,
4436
- ApiRequester.successResponseParser),
4437
-
4438
- resumeRecording: (callId ) =>
4439
- client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
4440
- ApiRequester.successResponseParser),
4441
-
4442
- guestGetMeetingStatus: (meetingUuid ) =>
4443
- client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
4444
- });
4445
-
4446
- //
4447
-
4448
-
4449
-
4450
-
4451
-
4452
-
4453
-
4454
-
4455
-
4456
-
4457
-
4458
-
4459
-
4460
-
4461
-
4462
-
4463
-
4464
-
4465
-
4466
-
4467
-
4468
- class Agent {
4469
-
4470
-
4471
-
4472
-
4473
-
4474
-
4475
-
4476
-
4477
-
4478
- static parse(plain ) {
4479
- return new Agent({
4480
- context: plain.context,
4481
- extension: plain.extension,
4482
- id: plain.id,
4483
- logged: plain.logged,
4484
- number: plain.number,
4485
- paused: plain.paused,
4486
- pausedReason: plain.paused_reason,
4487
- });
4488
- }
4489
-
4490
- constructor({
4491
- context,
4492
- extension,
4493
- id,
4494
- logged,
4495
- number,
4496
- paused,
4497
- pausedReason,
4498
- } ) {
4499
- this.context = context;
4500
- this.extension = extension;
4501
- this.id = id;
4502
- this.logged = logged;
4503
- this.number = number;
4504
- this.paused = paused;
4505
- this.pausedReason = pausedReason;
4506
- }
4507
- }
4508
-
4509
- /* */
4510
-
4511
- var agentdMethods = (client , baseUrl ) => ({
4512
- getAgent: (agentId ) =>
4513
- client.get(`${baseUrl}/agents/by-id/${agentId}`, null).then(Agent.parse),
4514
-
4515
- login: (agentNumber , context , extension ) =>
4516
- client.post(
4517
- `${baseUrl}/agents/by-number/${agentNumber}/login`,
4518
- { context, extension },
4519
- null,
4520
- ApiRequester.successResponseParser,
4521
- ),
4522
-
4523
- loginWithLineId: (lineId ) =>
4524
- client.post(
4525
- `${baseUrl}/users/me/agents/login`,
4526
- { line_id: lineId },
4527
- null,
4528
- ApiRequester.successResponseParser,
4529
- ),
4530
-
4531
- logout: (agentNumber ) =>
4532
- client.post(
4533
- `${baseUrl}/agents/by-number/${agentNumber}/logoff`,
4534
- null,
4535
- null,
4536
- ApiRequester.successResponseParser,
4537
- ),
4538
-
4539
- pause: (agentNumber ) =>
4540
- client.post(
4541
- `${baseUrl}/agents/by-number/${agentNumber}/pause`,
4542
- { reason: 'songbird_reason' },
4543
- null,
4544
- ApiRequester.successResponseParser,
4545
- ),
4546
-
4547
- resume: (agentNumber ) =>
4548
- client.post(
4549
- `${baseUrl}/agents/by-number/${agentNumber}/unpause`,
4550
- null,
4551
- null,
4552
- ApiRequester.successResponseParser,
4553
- ),
4554
-
4555
- getStatus: () => client.get(`${baseUrl}/users/me/agents`, null).then(Agent.parse),
4556
-
4557
- staticLogout: () =>
4558
- client.post(
4559
- `${baseUrl}/users/me/agents/logoff`,
4560
- null,
4561
- null,
4562
- ApiRequester.successResponseParser,
4563
- ),
4564
-
4565
- staticPause: () =>
4566
- client.post(
4567
- `${baseUrl}/users/me/agents/pause`,
4568
- { reason: 'songbird_reason' },
4569
- null,
4570
- ApiRequester.successResponseParser,
4571
- ),
4572
-
4573
- staticResume: () =>
4574
- client.post(
4575
- `${baseUrl}/users/me/agents/unpause`,
4576
- null,
4577
- null,
4578
- ApiRequester.successResponseParser,
4579
- ),
4580
- });
4581
-
4582
- //
4583
-
4584
-
4585
-
4586
-
4587
-
4588
-
4589
-
4590
-
4591
-
4592
-
4593
-
4594
-
4595
-
4596
-
4597
-
4598
-
4599
-
4600
-
4601
-
4602
-
4603
-
4604
-
4605
-
4606
-
4607
-
4608
-
4609
-
4610
- class Subscription {
4611
-
4612
-
4613
-
4614
-
4615
-
4616
-
4617
-
4618
-
4619
-
4620
-
4621
-
4622
-
4623
- static parse(plain ) {
4624
- return new Subscription({
4625
- name: plain.name,
4626
- events: plain.events,
4627
- config: plain.config,
4628
- uuid: plain.uuid,
4629
- service: plain.service,
4630
- eventsUserUuid: plain.events_user_uuid,
4631
- eventsWazoUuid: plain.events_wazo_uuid,
4632
- metadata: plain.metadata,
4633
- ownerTenantUuid: plain.owner_tenant_uuid,
4634
- ownerUserUuid: plain.owner_user_uuid,
4635
- });
4636
- }
4637
-
4638
- static parseMany(response ) {
4639
- return response.items.map(payload => Subscription.parse(payload));
4640
- }
4641
-
4642
- constructor({
4643
- name,
4644
- events,
4645
- config,
4646
- uuid,
4647
- service,
4648
- eventsUserUuid,
4649
- eventsWazoUuid,
4650
- metadata,
4651
- ownerTenantUuid,
4652
- ownerUserUuid,
4653
- } ) {
4654
- this.name = name;
4655
- this.events = events;
4656
- this.config = config;
4657
- this.uuid = uuid;
4658
- this.service = service;
4659
- this.eventsUserUuid = eventsUserUuid;
4660
- this.eventsWazoUuid = eventsWazoUuid;
4661
- this.metadata = metadata;
4662
- this.ownerTenantUuid = ownerTenantUuid;
4663
- this.ownerUserUuid = ownerUserUuid;
4664
- }
4665
- }
4666
-
4667
- /* */
4668
-
4669
-
4670
-
4671
-
4672
-
4673
-
4674
-
4675
-
4676
-
4677
-
4678
-
4679
-
4680
-
4681
-
4682
-
4683
- var webhookdMethods = (client , baseUrl ) => ({
4684
- getSubscriptions: () =>
4685
- client.get(`${baseUrl}/users/me/subscriptions`).then(Subscription.parseMany),
4686
-
4687
- getSubscription: (uuid ) =>
4688
- client.get(`${baseUrl}/users/me/subscriptions/${uuid}`).then(Subscription.parse),
4689
-
4690
- createSubscription: (payload ) =>
4691
- client.post(`${baseUrl}/users/me/subscriptions`, payload),
4692
-
4693
- removeSubscription: (uuid ) =>
4694
- client.delete(`${baseUrl}/users/me/subscriptions/${uuid}`),
4695
- });
4696
-
4697
- /* */
4698
-
4699
- var amidMethods = (client , baseUrl ) => ({
4700
- action: (action , args = {}) =>
4701
- client.post(`${baseUrl}/action/${action}`, args),
4702
-
4703
- getAors: async (endpoint ) => {
4704
- const rawEvents = await client.post(`${baseUrl}/action/PJSIPShowEndpoint`, { Endpoint: endpoint });
4705
-
4706
- return rawEvents.filter(event => event.Event === 'ContactStatusDetail');
4707
- },
4708
- });
4709
-
4710
- /* */
4711
-
4712
-
4713
-
4714
-
4715
-
4716
-
4717
-
4718
-
4719
-
4720
-
4721
- const AUTH_VERSION = '0.1';
4722
- const APPLICATION_VERSION = '1.0';
4723
- const CONFD_VERSION = '1.1';
4724
- const CTIDNG_VERSION = '1.0';
4725
- const DIRD_VERSION = '0.1';
4726
- const CALL_LOGD_VERSION = '1.0';
4727
- const CHATD_VERSION = '1.0';
4728
- const CALLD_VERSION = '1.0';
4729
- const AGENTD_VERSION = '1.0';
4730
- const WEBHOOKD_VERSION = '1.0';
4731
- const AMID_VERSION = '1.0';
4732
-
4733
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
4734
-
4735
- class ApiClient {
4736
-
4737
-
4738
-
4739
-
4740
-
4741
-
4742
-
4743
-
4744
-
4745
-
4746
-
4747
-
4748
-
4749
-
4750
-
4751
-
4752
-
4753
-
4754
-
4755
-
4756
-
4757
-
4758
-
4759
- // @see https://github.com/facebook/flow/issues/183#issuecomment-358607052
4760
- constructor({ server, agent = null, refreshToken, clientId, isMobile = false, fetchOptions } ) {
4761
- this.updateParameters({ server, agent, clientId, fetchOptions });
4762
- this.refreshToken = refreshToken;
4763
- this.isMobile = isMobile || false;
4764
- }
4765
-
4766
- initializeEndpoints() {
4767
- this.auth = authMethods(this.client, `auth/${AUTH_VERSION}`);
4768
- this.application = applicationMethods(this.client, `calld/${APPLICATION_VERSION}/applications`);
4769
- this.confd = confdMethods(this.client, `confd/${CONFD_VERSION}`);
4770
- this.ctidNg = ctidNgMethods(this.client, `ctid-ng/${CTIDNG_VERSION}`);
4771
- this.dird = dirdMethods(this.client, `dird/${DIRD_VERSION}`);
4772
- this.callLogd = callLogdMethods(this.client, `call-logd/${CALL_LOGD_VERSION}`);
4773
- this.chatd = chatdMethods(this.client, `chatd/${CHATD_VERSION}`);
4774
- this.calld = calldMethods(this.client, `calld/${CALLD_VERSION}`);
4775
- this.agentd = agentdMethods(this.client, `agentd/${AGENTD_VERSION}`);
4776
- this.webhookd = webhookdMethods(this.client, `webhookd/${WEBHOOKD_VERSION}`);
4777
- this.amid = amidMethods(this.client, `amid/${AMID_VERSION}`);
4778
- }
4779
-
4780
- updateParameters({ server, agent, clientId, fetchOptions } ) {
4781
- const refreshTokenCallback = this.refreshTokenCallback.bind(this);
4782
- this.client = new ApiRequester({ server, agent, refreshTokenCallback, clientId, fetchOptions });
4783
-
4784
- this.initializeEndpoints();
4785
- }
4786
-
4787
- async forceRefreshToken() {
4788
- logger.info('forcing refresh token, calling callback');
4789
- return this.refreshTokenCallback();
4790
- }
4791
-
4792
- async refreshTokenCallback() {
4793
- logger.info('refresh token callback called', {
4794
- refreshToken: this.refreshToken,
4795
- refreshBackend: this.refreshBackend,
4796
- refreshTenantId: this.refreshTenantId,
4797
- refreshDomainName: this.refreshDomainName,
4798
- refreshExpiration: this.refreshExpiration,
4799
- isMobile: this.isMobile,
4800
- });
4801
-
4802
- if (!this.refreshToken) {
4803
- return null;
4804
- }
4805
-
4806
- try {
4807
- const session = await this.auth.refreshToken(
4808
- this.refreshToken,
4809
- this.refreshBackend,
4810
- this.refreshExpiration,
4811
- this.isMobile,
4812
- this.refreshTenantId,
4813
- this.refreshDomainName,
4814
- );
4815
-
4816
- logger.info('token refreshed', { token: session.token });
4817
-
4818
- if (this.onRefreshToken) {
4819
- this.onRefreshToken(session.token, session);
4820
- }
4821
-
4822
- this.setToken(session.token);
4823
-
4824
- return session.token;
4825
- } catch (error) {
4826
- logger.error('token refresh, error', error);
4827
-
4828
- if (this.onRefreshTokenError) {
4829
- this.onRefreshTokenError(error);
4830
- }
4831
- }
4832
- }
4833
-
4834
- setToken(token ) {
4835
- this.client.setToken(token);
4836
- }
4837
-
4838
- setTenant(tenant ) {
4839
- this.client.setTenant(tenant);
4840
- }
4841
-
4842
- setRefreshToken(refreshToken ) {
4843
- this.refreshToken = refreshToken;
4844
- }
4845
-
4846
- setClientId(clientId ) {
4847
- this.client.clientId = clientId;
4848
- }
4849
-
4850
- setOnRefreshToken(onRefreshToken ) {
4851
- this.onRefreshToken = onRefreshToken;
4852
- }
4853
-
4854
- setOnRefreshTokenError(callback ) {
4855
- this.onRefreshTokenError = callback;
4856
- }
4857
-
4858
- setRefreshExpiration(refreshExpiration ) {
4859
- this.refreshExpiration = refreshExpiration;
4860
- }
4861
-
4862
- setRefreshBackend(refreshBackend ) {
4863
- this.refreshBackend = refreshBackend;
4864
- }
4865
-
4866
- setRefreshTenantId(tenantId ) {
4867
- console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4868
- this.refreshTenantId = tenantId;
4869
- }
4870
-
4871
- setRefreshDomainName(domainName ) {
4872
- this.refreshDomainName = domainName;
4873
- }
4874
-
4875
- setIsMobile(isMobile ) {
4876
- this.isMobile = isMobile;
4877
- }
4878
-
4879
- setFetchOptions(fetchOptions ) {
4880
- this.fetchOptions = fetchOptions;
4881
- this.client.setFetchOptions(fetchOptions);
4882
- }
4883
-
4884
- disableErrorLogging() {
4885
- this.client.disableErrorLogging();
4886
- }
4887
- }
4888
-
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setFetchOptions = exports.setIsMobile = exports.setRefreshBackend = exports.setRefreshExpiration = exports.setOnRefreshTokenError = exports.setOnRefreshToken = exports.setRefreshDomainName = exports.setRefreshTenantId = exports.setRefreshToken = exports.setApiToken = exports.setCurrentServer = exports.setApiClientId = void 0;
4889
7
  /* eslint-disable dot-notation */
4890
-
8
+ const api_client_1 = __importDefault(require("../api-client"));
4891
9
  // Can't use node cache mechanism here because when requiring lib/CallApi.js
4892
10
  // this file will be merge with CallApi.js and the cache will be lost.
4893
11
  // So we have to store values in global scope.
@@ -4903,119 +21,81 @@ global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
4903
21
  global.wazoRefreshBackend = global.wazoRefreshBackend || {};
4904
22
  global.wazoIsMobile = global.wazoIsMobile || {};
4905
23
  global.wazoFetchOptions = global.wazoFetchOptions || {};
4906
-
4907
- const setApiClientId = (clientId , forServer = null) => {
4908
- global.wazoClientId[forServer] = clientId;
24
+ const setApiClientId = (clientId, forServer = null) => {
25
+ global.wazoClientId[String(forServer)] = clientId;
4909
26
  };
4910
-
4911
- const setCurrentServer = (newServer ) => {
4912
- global.wazoCurrentServer = newServer;
27
+ exports.setApiClientId = setApiClientId;
28
+ const setCurrentServer = (newServer) => {
29
+ global.wazoCurrentServer = newServer;
4913
30
  };
4914
-
4915
- const setApiToken = (newToken , forServer = null) => {
4916
- global.wazoClientToken[forServer] = newToken;
31
+ exports.setCurrentServer = setCurrentServer;
32
+ const setApiToken = (newToken, forServer = null) => {
33
+ global.wazoClientToken[String(forServer)] = newToken;
4917
34
  };
4918
-
4919
- const setRefreshToken = (newRefreshToken , forServer = null) => {
4920
- global.wazoRefreshToken[forServer] = newRefreshToken;
35
+ exports.setApiToken = setApiToken;
36
+ const setRefreshToken = (newRefreshToken, forServer = null) => {
37
+ global.wazoRefreshToken[String(forServer)] = newRefreshToken;
4921
38
  };
4922
-
4923
- const setRefreshTenantId = (refreshTenantId , forServer = null) => {
4924
- console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
4925
- global.wazoRefreshTenantId[forServer] = refreshTenantId;
39
+ exports.setRefreshToken = setRefreshToken;
40
+ const setRefreshTenantId = (refreshTenantId, forServer = null) => {
41
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
42
+ global.wazoRefreshTenantId[String(forServer)] = refreshTenantId;
4926
43
  };
4927
-
4928
- const setRefreshDomainName = (refreshDomainName , forServer = null) => {
4929
- global.wazoRefreshDomainName[forServer] = refreshDomainName;
44
+ exports.setRefreshTenantId = setRefreshTenantId;
45
+ const setRefreshDomainName = (refreshDomainName, forServer = null) => {
46
+ global.wazoRefreshDomainName[String(forServer)] = refreshDomainName;
4930
47
  };
4931
-
4932
- const setOnRefreshToken = (onRefreshToken , forServer = null) => {
4933
- global.wazoOnRefreshToken[forServer] = onRefreshToken;
48
+ exports.setRefreshDomainName = setRefreshDomainName;
49
+ const setOnRefreshToken = (onRefreshToken, forServer = null) => {
50
+ global.wazoOnRefreshToken[String(forServer)] = onRefreshToken;
4934
51
  };
4935
-
4936
- const setOnRefreshTokenError = (callback , forServer = null) => {
4937
- global.wazoOnRefreshTokenError[forServer] = callback;
52
+ exports.setOnRefreshToken = setOnRefreshToken;
53
+ const setOnRefreshTokenError = (callback, forServer = null) => {
54
+ global.wazoOnRefreshTokenError[String(forServer)] = callback;
4938
55
  };
4939
-
4940
- const setRefreshExpiration = (refreshExpiration , forServer = null) => {
4941
- global.wazoRefreshExpiration[forServer] = refreshExpiration;
56
+ exports.setOnRefreshTokenError = setOnRefreshTokenError;
57
+ const setRefreshExpiration = (refreshExpiration, forServer = null) => {
58
+ global.wazoRefreshExpiration[String(forServer)] = refreshExpiration;
4942
59
  };
4943
-
4944
- const setRefreshBackend = (refreshBackend , forServer = null) => {
4945
- global.wazoRefreshBackend[forServer] = refreshBackend;
60
+ exports.setRefreshExpiration = setRefreshExpiration;
61
+ const setRefreshBackend = (refreshBackend, forServer = null) => {
62
+ global.wazoRefreshBackend[String(forServer)] = refreshBackend;
4946
63
  };
4947
-
4948
- const setIsMobile = (isMobile , forServer = null) => {
4949
- global.wazoIsMobile[forServer] = isMobile;
64
+ exports.setRefreshBackend = setRefreshBackend;
65
+ const setIsMobile = (isMobile, forServer = null) => {
66
+ global.wazoIsMobile[String(forServer)] = isMobile;
4950
67
  };
4951
-
4952
- const setFetchOptions = (fetchOptions , forServer = null) => {
4953
- global.wazoFetchOptions[forServer] = fetchOptions;
68
+ exports.setIsMobile = setIsMobile;
69
+ const setFetchOptions = (fetchOptions, forServer = null) => {
70
+ global.wazoFetchOptions[String(forServer)] = fetchOptions;
4954
71
  };
4955
-
4956
- const fillClient = (apiClient ) => {
4957
- const { server, token, clientId } = apiClient.client;
4958
- const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4959
-
4960
- // try with null server when dealing with non-related server info
4961
- apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
4962
-
4963
- apiClient.setClientId(global.wazoClientId[server] || global.wazoClientId[null] || clientId);
4964
-
4965
- apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4966
-
4967
- if (tenantId) {
4968
- apiClient.setRefreshTenantId(tenantId);
4969
- }
4970
-
4971
- apiClient.setRefreshDomainName(
4972
- global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4973
- );
4974
-
4975
- apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
4976
-
4977
- apiClient.setOnRefreshToken(
4978
- global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
4979
- );
4980
-
4981
- apiClient.setOnRefreshTokenError(
4982
- global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
4983
- );
4984
-
4985
- apiClient.setRefreshExpiration(
4986
- global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
4987
- );
4988
-
4989
- apiClient.setRefreshBackend(
4990
- global.wazoRefreshBackend[server] || global.wazoRefreshBackend[null] || apiClient.refreshBackend,
4991
- );
4992
-
4993
- apiClient.setIsMobile(global.wazoIsMobile[server] || global.wazoIsMobile[null] || apiClient.isMobile);
4994
-
4995
- return apiClient;
72
+ exports.setFetchOptions = setFetchOptions;
73
+ const fillClient = (apiClient) => {
74
+ const { server, token, clientId, } = apiClient.client;
75
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId.null || apiClient.refreshTenantId;
76
+ // try with null server when dealing with non-related server info
77
+ apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken.null || token);
78
+ apiClient.setClientId(global.wazoClientId[server] || global.wazoClientId.null || clientId);
79
+ apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken.null || apiClient.refreshToken);
80
+ if (tenantId) {
81
+ apiClient.setRefreshTenantId(tenantId);
82
+ }
83
+ apiClient.setRefreshDomainName(global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName.null || apiClient.refreshDomainName);
84
+ apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions.null || apiClient.fetchOptions);
85
+ apiClient.setOnRefreshToken(global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken.null || apiClient.onRefreshToken);
86
+ apiClient.setOnRefreshTokenError(global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError.null || apiClient.onRefreshTokenError);
87
+ apiClient.setRefreshExpiration(global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration.null || apiClient.refreshExpiration);
88
+ apiClient.setRefreshBackend(global.wazoRefreshBackend[server] || global.wazoRefreshBackend.null || apiClient.refreshBackend);
89
+ apiClient.setIsMobile(global.wazoIsMobile[server] || global.wazoIsMobile.null || apiClient.isMobile);
90
+ return apiClient;
4996
91
  };
4997
-
4998
- var getApiClient = (forServer = null) => {
4999
- const server = forServer || global.wazoCurrentServer || '';
5000
- if (server in global.wazoClients) {
92
+ exports.default = ((forServer = null) => {
93
+ const server = forServer || global.wazoCurrentServer || '';
94
+ if (server in global.wazoClients) {
95
+ return fillClient(global.wazoClients[server]);
96
+ }
97
+ global.wazoClients[server] = new api_client_1.default({
98
+ server,
99
+ });
5001
100
  return fillClient(global.wazoClients[server]);
5002
- }
5003
-
5004
- global.wazoClients[server] = new ApiClient({ server });
5005
-
5006
- return fillClient(global.wazoClients[server]);
5007
- };
5008
-
5009
- exports.default = getApiClient;
5010
- exports.setApiClientId = setApiClientId;
5011
- exports.setApiToken = setApiToken;
5012
- exports.setCurrentServer = setCurrentServer;
5013
- exports.setFetchOptions = setFetchOptions;
5014
- exports.setIsMobile = setIsMobile;
5015
- exports.setOnRefreshToken = setOnRefreshToken;
5016
- exports.setOnRefreshTokenError = setOnRefreshTokenError;
5017
- exports.setRefreshBackend = setRefreshBackend;
5018
- exports.setRefreshDomainName = setRefreshDomainName;
5019
- exports.setRefreshExpiration = setRefreshExpiration;
5020
- exports.setRefreshTenantId = setRefreshTenantId;
5021
- exports.setRefreshToken = setRefreshToken;
101
+ });