@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
package/lib/api/auth.js CHANGED
@@ -1,1226 +1,170 @@
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
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
12
-
13
- /* */
14
-
15
- class BadResponse extends Error {
16
- static fromResponse(error , status ) {
17
- return new BadResponse(
18
- error.message || JSON.stringify(error),
19
- status,
20
- error.timestamp,
21
- error.error_id,
22
- error.details,
23
- error,
24
- );
25
- }
26
-
27
- static fromText(response , status ) {
28
- return new BadResponse(response, status);
29
- }
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
- constructor(
39
- message ,
40
- status ,
41
- timestamp = null,
42
- errorId = null,
43
- details = null,
44
- error = null,
45
- ) {
46
- super(message);
47
-
48
- this.timestamp = timestamp;
49
- this.status = status;
50
- this.errorId = errorId;
51
- this.details = details;
52
- this.error = error;
53
- }
54
- }
55
-
56
- /* */
57
-
58
- class ServerError extends BadResponse {
59
- static fromResponse(error , status ) {
60
- return new ServerError(
61
- error.message || JSON.stringify(error),
62
- status,
63
- error.timestamp,
64
- error.error_id,
65
- error.details,
66
- );
67
- }
68
-
69
- static fromText(response , status ) {
70
- return new ServerError(response, status);
71
- }
72
- }
73
-
74
- /* */
75
- /* global navigator */
76
- const isMobile = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
77
-
78
- /* global window */
79
-
80
- const TRACE = 'trace';
81
- const DEBUG = 'debug';
82
- const INFO = 'info';
83
- const LOG = 'log';
84
- const WARN = 'warn';
85
- const ERROR = 'error';
86
- const CONSOLE_METHODS = [INFO, LOG, WARN, ERROR];
87
- const LOG_LEVELS = [TRACE, DEBUG, INFO, LOG, WARN, ERROR];
88
- const CATEGORY_PREFIX = 'logger-category=';
89
-
90
- const MAX_REMOTE_RETRY = 100;
91
-
92
- const addLevelsTo = (instance , withMethods = false) => {
93
- instance.TRACE = TRACE;
94
- instance.DEBUG = DEBUG;
95
- instance.INFO = INFO;
96
- instance.LOG = LOG;
97
- instance.WARN = WARN;
98
- instance.ERROR = ERROR;
99
-
100
- if (withMethods) {
101
- instance.trace = (...args) => instance.apply(null, [TRACE, ...args]);
102
- instance.debug = (...args) => instance.apply(null, [DEBUG, ...args]);
103
- instance.info = (...args) => instance.apply(null, [INFO, ...args]);
104
- instance.log = (...args) => instance.apply(null, [LOG, ...args]);
105
- instance.warn = (...args) => instance.apply(null, [WARN, ...args]);
106
- instance.error = (...args) => instance.apply(null, [ERROR, ...args]);
107
- }
108
-
109
- return instance;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
110
4
  };
111
-
112
- const safeStringify = (object ) => {
113
- const result = '{"message": "Not parsable JSON"}';
114
- try {
115
- return JSON.stringify(object);
116
- } catch (e) {
117
- // Nothing to do
118
- }
119
-
120
- return result;
121
- };
122
-
123
- class IssueReporter {
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
- constructor() {
141
- addLevelsTo(this);
142
-
143
- this.oldConsoleMethods = null;
144
- this.enabled = false;
145
- this.remoteClientConfiguration = null;
146
- this.buffer = [];
147
- this.bufferTimeout = null;
148
- this._boundProcessBuffer = this._processBuffer.bind(this);
149
- this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
150
- this._callback = null;
151
- }
152
-
153
- init() {
154
- this._catchConsole();
155
- }
156
-
157
- setCallback(cb ) {
158
- this._callback = cb;
159
- }
160
-
161
- configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
162
- this.remoteClientConfiguration = configuration;
163
- }
164
-
165
- enable() {
166
- if (!this.oldConsoleMethods) {
167
- this.init();
168
- }
169
-
170
- this.enabled = true;
171
- }
172
-
173
- disable() {
174
- this.enabled = false;
175
- }
176
-
177
- loggerFor(category ) {
178
- const logger = (level , ...args ) => {
179
- this.log.apply(this, [level, this._makeCategory(category), ...args]);
180
- };
181
-
182
- return addLevelsTo(logger, true);
183
- }
184
-
185
- removeSlashes(str ) {
186
- return str.replace(/"/g, "'").replace(/\\/g, '');
187
- }
188
-
189
- log(level , ...args ) {
190
- if (!this.enabled) {
191
- return;
192
- }
193
-
194
- // Handle category label
195
- let category = null;
196
- let skipSendToRemote = false;
197
- let extra = {};
198
- if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
199
- category = args[0].split('=')[1];
200
- // eslint-disable-next-line no-param-reassign
201
- args.splice(0, 1);
202
- }
203
-
204
- // Handle extra data as object for the last argument
205
- const lastArg = args[args.length - 1];
206
- if (lastArg && ((typeof lastArg === 'object' && Object.keys(lastArg).length) || lastArg instanceof Error)) {
207
- if (lastArg instanceof Error) {
208
- extra = {
209
- errorMessage: lastArg.message,
210
- errorStack: lastArg.stack,
211
- errorType: lastArg.constructor.name,
212
- skipSendToRemote: lastArg.skipSendToRemote,
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DETAULT_EXPIRATION = exports.BACKEND_LDAP_USER = exports.DEFAULT_BACKEND_USER = void 0;
7
+ const api_requester_1 = __importDefault(require("../utils/api-requester"));
8
+ const Session_1 = __importDefault(require("../domain/Session"));
9
+ exports.DEFAULT_BACKEND_USER = 'wazo_user';
10
+ exports.BACKEND_LDAP_USER = 'ldap_user';
11
+ exports.DETAULT_EXPIRATION = 3600;
12
+ exports.default = ((client, baseUrl) => ({
13
+ checkToken: (token) => client.head(`${baseUrl}/token/${token}`, null, {}),
14
+ authenticate: (token) => client.get(`${baseUrl}/token/${token}`, null, {}).then((response) => Session_1.default.parse(response)),
15
+ logIn(params) {
16
+ const body = {
17
+ backend: params.backend || exports.DEFAULT_BACKEND_USER,
18
+ expiration: params.expiration || exports.DETAULT_EXPIRATION,
19
+ };
20
+ const headers = {
21
+ Authorization: `Basic ${api_requester_1.default.base64Encode(`${params.username}:${params.password}`)}`,
22
+ 'Content-Type': 'application/json',
213
23
  };
214
- } else {
215
- extra = lastArg;
216
- }
217
- // eslint-disable-next-line no-param-reassign
218
- args.splice(1, 1);
219
- }
220
-
221
- if (extra.skipSendToRemote) {
222
- skipSendToRemote = true;
223
- delete extra.skipSendToRemote;
224
- }
225
-
226
- const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
227
- const message = args.join(', ');
228
- let consoleMessage = message;
229
-
230
- if (Object.keys(extra).length) {
231
- const parsedExtra = safeStringify(extra);
232
- consoleMessage = `${consoleMessage} (${parsedExtra})`;
233
- }
234
-
235
- if (category) {
236
- consoleMessage = `[${category}] ${consoleMessage}`;
237
- }
238
-
239
- // Log the message in the console anyway (but don't console.error on mobile)
240
- const consoleLevel = isMobile() && level === 'error' ? WARN : level;
241
-
242
- // eslint-disable-next-line
243
- const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
244
- oldMethod.apply(oldMethod, [date, consoleMessage]);
245
-
246
- if (this._callback) {
247
- this._callback(level, consoleMessage);
248
- }
249
-
250
- if (!skipSendToRemote) {
251
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
252
- }
253
- }
254
-
255
- logRequest(url , options , response , start ) {
256
- if (!this.enabled) {
257
- return;
258
- }
259
- const { status } = response;
260
- const duration = new Date() - start;
261
-
262
- let level = TRACE;
263
- if (status >= 400 && status < 500) {
264
- level = WARN;
265
- } else if (status >= 500) {
266
- level = ERROR;
267
- }
268
-
269
- this.log(level, this._makeCategory('http'), url, {
270
- status,
271
- body: this.removeSlashes(JSON.stringify(options.body)),
272
- method: options.method,
273
- headers: options.headers,
274
- duration,
275
- });
276
- }
277
-
278
- // Logs aren't stored anymore
279
- getLogs() {
280
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
281
- return [];
282
- }
283
-
284
- getParsedLogs() {
285
- console.warn('IssueReporter\'s logs aren\'t stored anymore. Please use fluentd to store them');
286
- return [];
287
- }
288
-
289
- getReport() {
290
- return this.getParsedLogs().join('\r\n');
291
- }
292
-
293
- _catchConsole() {
294
- this.oldConsoleMethods = {};
295
- CONSOLE_METHODS.forEach((methodName ) => {
296
- // eslint-disable-next-line
297
- this.oldConsoleMethods[methodName] = console[methodName];
298
- window.console[methodName] = (...args) => {
299
- // Store message
300
- try {
301
- this.log(methodName, args.join(' '));
302
- // Use old console method to log it normally
303
- this.oldConsoleMethods[methodName].apply(null, args);
304
- } catch (e) {
305
- // Avoid circular structure issues
24
+ if (client.clientId) {
25
+ body.access_type = 'offline';
26
+ body.client_id = client.clientId;
306
27
  }
307
- };
308
- });
309
- }
310
-
311
- _sendToRemoteLogger(level , payload = {}) {
312
- if (!this.remoteClientConfiguration) {
313
- return;
314
- }
315
-
316
- const { level: minLevel, bufferSize } = this.remoteClientConfiguration;
317
- if (!minLevel || this._isLevelAbove(minLevel, level)) {
318
- return;
319
- }
320
-
321
- payload.level = level;
322
-
323
- if (bufferSize > 0) {
324
- return this._addToBuffer(payload);
325
- }
326
-
327
- this._sendDebugToGrafana(payload);
328
- }
329
-
330
- _parseLoggerBody(payload ) {
331
- const { level } = payload;
332
- const { maxMessageSize, extra } = this.remoteClientConfiguration || {};
333
-
334
- delete payload.level;
335
-
336
- if (maxMessageSize && typeof payload.message === 'string' && payload.message.length > maxMessageSize) {
337
- payload.message = `${payload.message.substr(0, maxMessageSize)}...`;
338
- }
339
-
340
- return safeStringify({
341
- level,
342
- ...payload,
343
- ...extra,
344
- });
345
- }
346
-
347
- _addToBuffer(payload ) {
348
- // Reset buffer timer
349
- if (this.bufferTimeout) {
350
- clearTimeout(this.bufferTimeout);
351
- this.bufferTimeout = null;
352
- }
353
-
354
- this.buffer.push(payload);
355
-
356
- // $FlowFixMe
357
- const { bufferSize, bufferTimeout } = this.remoteClientConfiguration;
358
-
359
- if (this.buffer.length > bufferSize) {
360
- return this._processBuffer();
361
- }
362
-
363
- if (bufferTimeout > 0) {
364
- this.bufferTimeout = setTimeout(this._boundProcessBuffer, bufferTimeout);
365
- }
366
- }
367
-
368
- _processBuffer() {
369
- this._sendDebugToGrafana(this.buffer);
370
-
371
- this.buffer = [];
372
- if (this.bufferTimeout) {
373
- clearTimeout(this.bufferTimeout);
374
- this.bufferTimeout = null;
375
- }
376
- }
377
-
378
- _sendDebugToGrafana(payload , retry = 0) {
379
- if (!this.remoteClientConfiguration || retry >= MAX_REMOTE_RETRY) {
380
- return;
381
- }
382
-
383
- const { tag, host, port } = this.remoteClientConfiguration;
384
- const isArray = Array.isArray(payload);
385
- const isSecure = +port === 443;
386
- const url = `http${isSecure ? 's' : ''}://${host}${isSecure ? '' : `:${port}`}/${tag}`;
387
- const body = isArray ? `[${payload.map(this._boundParseLoggerBody).join(',')}]` : this._parseLoggerBody(payload);
388
-
389
- realFetch()(url, {
390
- method: 'POST',
391
- headers: {
392
- Accept: 'application/json',
393
- 'Content-Type': 'application/json',
394
- },
395
- // $FlowFixMe
396
- body,
397
- }).catch((e ) => {
398
- // $FlowFixMe
399
- e.skipSendToRemote = true;
400
- this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
401
-
402
- setTimeout(() => {
403
- if (isArray) {
404
- payload = payload.map(message => this._writeRetryCount(message, retry + 1));
405
- } else if (payload && typeof payload === 'object') {
406
- payload = this._writeRetryCount(payload, retry + 1);
28
+ if (params.mobile) {
29
+ headers['Wazo-Session-Type'] = 'mobile';
407
30
  }
408
-
409
- this._sendDebugToGrafana(payload, retry + 1);
410
- }, 5000 + retry * 1000);
411
- });
412
- }
413
-
414
- _writeRetryCount(message , count ) {
415
- if (message && typeof message === 'object') {
416
- // $FlowFixMe
417
- message._retry = count;
418
- }
419
-
420
- return message;
421
- }
422
-
423
- _isLevelAbove(level1 , level2 ) {
424
- const index1 = LOG_LEVELS.indexOf(level1);
425
- const index2 = LOG_LEVELS.indexOf(level2);
426
- if (index1 === -1 || index2 === -1) {
427
- return false;
428
- }
429
-
430
- return index1 > index2;
431
- }
432
-
433
- _makeCategory(category ) {
434
- return `${CATEGORY_PREFIX}${category}`;
435
- }
436
- }
437
-
438
- var IssueReporter$1 = new IssueReporter();
439
-
440
- /* */
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
- const methods = ['head', 'get', 'post', 'put', 'delete'];
452
-
453
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
454
-
455
- // Use a function here to be able to mock it in tests
456
- const realFetch = () => {
457
- if (typeof document !== 'undefined' && window.fetch) {
458
- // Browser
459
- return window.fetch;
460
- }
461
-
462
- if (isMobile()) {
463
- // React native
464
- return fetch;
465
- }
466
-
467
- // nodejs
468
- // this package is disable for react-native in package.json because it requires nodejs modules
469
- // Used to trick the optimizer to avoid requiring `node-fetch/lib/index` directly
470
- // It causes to require it on browsers when delivered by a nodejs engine (cf: vitejs).
471
- try {
472
- // $FlowFixMe
473
- return require(Math.random() >= 0 ? 'node-fetch/lib/index' : '');
474
- } catch (e) {
475
- return fetch;
476
- }
477
- };
478
-
479
- class ApiRequester {
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
- // eslint-disable-next-line
497
- static successResponseParser(response , isJson ) {
498
- return response.status === 204 || response.status === 201 || response.status === 200;
499
- }
500
-
501
- static defaultParser(response ) {
502
- return response.json().then((data ) => data);
503
- }
504
-
505
- static getQueryString(obj ) {
506
- return Object.keys(obj)
507
- .filter(key => obj[key])
508
- .map(key => `${key}=${encodeURIComponent(obj[key])}`)
509
- .join('&');
510
- }
511
-
512
- static base64Encode(str ) {
513
- return typeof btoa !== 'undefined' ? btoa(str) : jsBase64.Base64.encode(str);
514
- }
515
-
516
- // @see https://github.com/facebook/flow/issues/183#issuecomment-358607052
517
- constructor({ server, refreshTokenCallback, clientId, agent = null, token = null, fetchOptions } ) {
518
- this.server = server;
519
- this.agent = agent;
520
- this.clientId = clientId;
521
- this.refreshTokenCallback = refreshTokenCallback;
522
- this.refreshTokenPromise = null;
523
- this.fetchOptions = fetchOptions || {};
524
- if (token) {
525
- this.token = token;
526
- }
527
-
528
- this.shouldLogErrors = true;
529
-
530
- methods.forEach(method => {
531
- // $FlowFixMe
532
- ApiRequester.prototype[method] = function sugar(...args) {
533
- // Add method in arguments passed to `call`
534
- args.splice(1, 0, method);
535
-
536
- return this.call.call(this, ...args);
537
- };
538
- });
539
- }
540
-
541
- setTenant(tenant ) {
542
- this.tenant = tenant;
543
- }
544
-
545
- setToken(token ) {
546
- this.token = token;
547
- }
548
-
549
- setFetchOptions(options ) {
550
- this.fetchOptions = options;
551
- }
552
-
553
- disableErrorLogging() {
554
- this.shouldLogErrors = false;
555
- }
556
-
557
- enableErrorLogging() {
558
- this.shouldLogErrors = true;
559
- }
560
-
561
- async call(
562
- path ,
563
- method = 'get',
564
- body = null,
565
- headers = null,
566
- parse = ApiRequester.defaultParser,
567
- firstCall = true,
568
- ) {
569
- const url = this.computeUrl(method, path, body);
570
- const newHeaders = this.getHeaders(headers);
571
- let newBody = method === 'get' ? null : body;
572
- if (newBody && newHeaders['Content-Type'] === 'application/json') {
573
- newBody = JSON.stringify(newBody);
574
- }
575
- const isHead = method === 'head';
576
- const hasEmptyResponse = method === 'delete' || isHead;
577
- const newParse = hasEmptyResponse ? ApiRequester.successResponseParser : parse;
578
-
579
- const fetchOptions = { ...this.fetchOptions || {} };
580
- const extraHeaders = fetchOptions.headers || {};
581
- delete fetchOptions.headers;
582
-
583
- const options = {
584
- method,
585
- body: newBody,
586
- headers: { ...this.getHeaders(headers), ...extraHeaders },
587
- agent: this.agent,
588
- ...fetchOptions,
589
- };
590
-
591
- if (this.refreshTokenPromise) {
592
- logger.info('A token is already refreshing, waiting ...', { url });
593
- await this.refreshTokenPromise;
594
- }
595
-
596
- const start = new Date();
597
-
598
- return realFetch()(url, options).then(response => {
599
- const contentType = response.headers.get('content-type') || '';
600
- const isJson = contentType.indexOf('application/json') !== -1;
601
-
602
- IssueReporter$1.logRequest(url, options, response, start);
603
-
604
- // Throw an error only if status >= 400
605
- if ((isHead && response.status >= 500) || (!isHead && response.status >= 400)) {
606
- const promise = isJson ? response.json() : response.text();
607
- const exceptionClass = response.status >= 500 ? ServerError : BadResponse;
608
-
609
- return promise.then(async (err ) => {
610
- // Check if the token is still valid
611
- if (firstCall && this._checkTokenExpired(response, err)) {
612
- logger.warn('token expired', { error: err.reason });
613
- // Replay the call after refreshing the token
614
- return this._replayWithNewToken(err, path, method, body, headers, parse);
615
- }
616
-
617
- const error = typeof err === 'string'
618
- ? exceptionClass.fromText(err, response.status)
619
- : exceptionClass.fromResponse(err, response.status);
620
-
621
- if (this.shouldLogErrors) {
622
- logger.error('API error', error);
623
- }
624
-
625
- throw error;
626
- });
627
- }
628
-
629
- return newParse(response, isJson);
630
- }).catch(error => {
631
- if (this.shouldLogErrors) {
632
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
633
- }
634
-
635
- throw error;
636
- });
637
- }
638
-
639
- _checkTokenExpired(response , err ) {
640
- // Special case when authenticating form a token: we got a 404
641
- const isTokenNotFound = response.status === 404 && this._isTokenNotFound(err);
642
-
643
- return response.status === 401 || isTokenNotFound;
644
- }
645
-
646
- _isTokenNotFound(err ) {
647
- return err && err.reason && err.reason[0] === 'No such token';
648
- }
649
-
650
- _replayWithNewToken(
651
- err ,
652
- path ,
653
- method ,
654
- body = null,
655
- headers = null,
656
- parse ,
657
- ) {
658
- const isTokenNotFound = this._isTokenNotFound(err);
659
- let newPath = path;
660
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
661
-
662
- this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
663
-
664
- return this.refreshTokenPromise.then(() => {
665
- this.refreshTokenPromise = null;
666
- logger.info('token refreshed', { isTokenNotFound });
667
- if (isTokenNotFound) {
668
- const pathParts = path.split('/');
669
- pathParts.pop();
670
- pathParts.push(this.token);
671
- newPath = pathParts.join('/');
672
- }
673
-
674
- return this.call(newPath, method, body, headers, parse, false);
675
- }).catch((e) => {
676
- this.refreshTokenPromise = null;
677
- throw e;
678
- });
679
- }
680
-
681
- getHeaders(header ) {
682
- if (header instanceof Object) {
683
- return header;
684
- }
685
-
686
- return {
687
- 'X-Auth-Token': this.token,
688
- ...(this.tenant ? { 'Wazo-Tenant': this.tenant } : null),
689
- Accept: 'application/json',
690
- 'Content-Type': 'application/json',
691
- };
692
- }
693
-
694
- computeUrl(method , path , body ) {
695
- const url = `${this.baseUrl}/${path}`;
696
-
697
- return method === 'get' && body && Object.keys(body).length ? `${url}?${ApiRequester.getQueryString(body)}` : url;
698
- }
699
-
700
- get baseUrl() {
701
- return `https://${this.server}/api`;
702
- }
703
- }
704
-
705
- //
706
-
707
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
708
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
709
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
710
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
711
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
712
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
713
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
714
- BwIDAQAB
715
- -----END PUBLIC KEY-----`;
716
-
717
- //
718
-
719
- var newFrom = (instance , ToClass ) => {
720
- const args = {};
721
- Object.getOwnPropertyNames(instance).forEach(prop => {
722
- args[prop] = instance[prop];
723
- });
724
-
725
- return new ToClass(args);
726
- };
727
-
728
- // Can't use `semver` package as Wazo version aren't in semver format
729
-
730
- const compareVersions = (a, b) => {
731
- let i;
732
- let diff;
733
- const regExStrip0 = /(\.0+)+$/;
734
- const segmentsA = a.replace(regExStrip0, '').split('.');
735
- const segmentsB = b.replace(regExStrip0, '').split('.');
736
- const l = Math.min(segmentsA.length, segmentsB.length);
737
-
738
- for (i = 0; i < l; i++) {
739
- diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
740
- if (diff) {
741
- return diff;
742
- }
743
- }
744
- return segmentsA.length - segmentsB.length;
745
- };
746
-
747
- //
748
-
749
- const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
750
- const MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT = '19.08';
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
-
760
-
761
-
762
-
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
-
772
-
773
-
774
-
775
-
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
-
791
-
792
-
793
-
794
-
795
-
796
-
797
-
798
-
799
-
800
- class Session {
801
-
802
-
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
- static parse(plain ) {
814
- const token = plain.data.metadata ? plain.data.metadata.jwt : null;
815
- let authorizations = [];
816
-
817
- // Add authorizations from JWT
818
- if (token) {
819
- const isValid = jsrsasign.jws.JWS.verifyJWT(token, swarmKey, { alg: ['RS256'], verifyAt: new Date() });
820
- if (isValid) {
821
- const decodedToken = jsrsasign.jws.JWS.readSafeJSONString(jsrsasign.b64utoutf8(token.split('.')[1]));
822
- authorizations = decodedToken ? decodedToken.authorizations : [];
823
- }
824
- }
825
-
826
- return new Session({
827
- token: plain.data.token,
828
- refreshToken: plain.data.refresh_token || null,
829
- uuid: plain.data.metadata ? plain.data.metadata.uuid : null,
830
- sessionUuid: plain.data.session_uuid,
831
- authorizations,
832
- acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
833
- tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
834
- expiresAt: new Date(`${plain.data.utc_expires_at}z`),
835
- engineUuid: plain.data.xivo_uuid,
836
- });
837
- }
838
-
839
- static newFrom(profile ) {
840
- return newFrom(profile, Session);
841
- }
842
-
843
- constructor({
844
- token,
845
- uuid,
846
- tenantUuid,
847
- profile,
848
- expiresAt,
849
- authorizations,
850
- acl,
851
- engineVersion,
852
- refreshToken,
853
- sessionUuid,
854
- engineUuid,
855
- } = {}) {
856
- this.token = token;
857
- this.uuid = uuid;
858
- this.tenantUuid = tenantUuid || null;
859
- this.profile = profile;
860
- this.expiresAt = expiresAt;
861
- this.authorizations = authorizations || [];
862
- this.acl = acl || [];
863
- this.engineVersion = engineVersion;
864
- this.refreshToken = refreshToken;
865
- this.sessionUuid = sessionUuid;
866
- this.engineUuid = engineUuid;
867
- }
868
-
869
- hasExpired(date = new Date()) {
870
- return date >= this.expiresAt;
871
- }
872
-
873
- is(contact ) {
874
- return Boolean(contact) && this.uuid === contact.uuid;
875
- }
876
-
877
- using(profile ) {
878
- this.profile = profile;
879
-
880
- return this;
881
- }
882
-
883
- hasAuthorizations() {
884
- return this.authorizations && !!this.authorizations.length;
885
- }
886
-
887
- displayName() {
888
- return this.profile ? `${this.profile.firstName} ${this.profile.lastName}` : '';
889
- }
890
-
891
- hasAccessToVoicemail() {
892
- if (!this.profile) {
893
- return false;
894
- }
895
- return !!this.profile.voicemail;
896
- }
897
-
898
- primaryLine() {
899
- return this.profile && this.profile.lines.length > 0 ? this.profile.lines[0] : null;
900
- }
901
-
902
- primarySipLine() {
903
- return this.profile && this.profile.sipLines.length > 0 ? this.profile.sipLines[0] : null;
904
- }
905
-
906
- primaryWebRtcLine() {
907
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && sipLine.isWebRtc());
908
- }
909
-
910
- primaryCtiLine() {
911
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && !sipLine.isWebRtc());
912
- }
913
-
914
- primaryContext() {
915
- if (this.engineVersion) {
916
- if (this.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT)) {
917
- return 'default';
918
- }
919
- }
920
-
921
- const line = this.primaryLine();
922
-
923
- return line && line.extensions.length > 0 ? line.extensions[0].context : 'default';
924
- }
925
-
926
- hasEngineVersionGte(version ) {
927
- return this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
928
- }
929
-
930
- primaryNumber() {
931
- const line = this.primaryLine();
932
-
933
- return line && line.extensions.length ? line.extensions[0].exten : null;
934
- }
935
-
936
- allLines() {
937
- return this.profile ? this.profile.lines || [] : [];
938
- }
939
-
940
- allNumbers() {
941
- const extensions = this.allLines().map(line => line.extensions.map(extension => extension.exten));
942
- if (!extensions.length) {
943
- return [];
944
- }
945
-
946
- return extensions.reduce((a, b) => a.concat(b));
947
- }
948
-
949
- hasExtension(extension ) {
950
- return this.allNumbers().some(number => number === extension);
951
- }
952
-
953
- get acls() {
954
- console.warn('`acls` property of Session has been removed in Wazo\'s SDK, please use `acl` instead.');
955
- return this.acl;
956
- }
957
- }
958
-
959
- /* */
960
-
961
- const DEFAULT_BACKEND_USER = 'wazo_user';
962
- const BACKEND_LDAP_USER = 'ldap_user';
963
- const DETAULT_EXPIRATION = 3600;
964
-
965
- var auth = (client , baseUrl ) => ({
966
- checkToken: (token ) => client.head(`${baseUrl}/token/${token}`, null, {}),
967
-
968
- authenticate: (token ) =>
969
- client.get(`${baseUrl}/token/${token}`, null, {}).then(response => Session.parse(response)),
970
-
971
- logIn(params
972
-
973
-
974
-
975
-
976
-
977
-
978
-
979
- ) {
980
- const body = {
981
- backend: params.backend || DEFAULT_BACKEND_USER,
982
- expiration: params.expiration || DETAULT_EXPIRATION,
983
- };
984
- const headers = {
985
- Authorization: `Basic ${ApiRequester.base64Encode(`${params.username}:${params.password}`)}`,
986
- 'Content-Type': 'application/json',
987
- };
988
-
989
- if (client.clientId) {
990
- body.access_type = 'offline';
991
- body.client_id = client.clientId;
992
- }
993
-
994
- if (params.mobile) {
995
- headers['Wazo-Session-Type'] = 'mobile';
996
- }
997
-
998
- if (params.tenantId) {
999
- console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
1000
- body.tenant_id = params.tenantId;
1001
- }
1002
-
1003
- if (params.domainName) {
1004
- body.domain_name = params.domainName;
1005
- }
1006
-
1007
- return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
1008
- },
1009
-
1010
- logOut: (token ) =>
1011
- client.delete(`${baseUrl}/token/${token}`, null, {}, ApiRequester.successResponseParser),
1012
-
1013
- refreshToken: (
1014
- refreshToken ,
1015
- backend ,
1016
- expiration ,
1017
- isMobile = false,
1018
- tenantId ,
1019
- domainName ,
1020
- ) => {
1021
- const body = {
1022
- backend: backend || DEFAULT_BACKEND_USER,
1023
- expiration: expiration || DETAULT_EXPIRATION,
1024
- refresh_token: refreshToken,
1025
- client_id: client.clientId,
1026
- };
1027
-
1028
- if (tenantId) {
1029
- console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
1030
- body.tenant_id = tenantId;
1031
- }
1032
-
1033
- if (domainName) {
1034
- body.domain_name = domainName;
1035
- }
1036
-
1037
- const headers = {
1038
- 'Content-Type': 'application/json',
1039
- ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
1040
- };
1041
-
1042
- return client.post(`${baseUrl}/token`, body, headers, ApiRequester.defaultParser, false).then(Session.parse);
1043
- },
1044
-
1045
- deleteRefreshToken: (clientId ) =>
1046
- client.delete(`${baseUrl}/users/me/tokens/${clientId}`, null, null, ApiRequester.successResponseParser),
1047
-
1048
- updatePassword: (userUuid , oldPassword , newPassword ) => {
1049
- const body = {
1050
- new_password: newPassword,
1051
- old_password: oldPassword,
1052
- };
1053
-
1054
- return client.put(`${baseUrl}/users/${userUuid}/password`, body, null, ApiRequester.successResponseParser);
1055
- },
1056
-
1057
- sendDeviceToken: (userUuid , deviceToken , apnsVoipToken , apnsNotificationToken ) => {
1058
- const body = {
1059
- token: deviceToken,
1060
- };
1061
-
1062
- if (apnsVoipToken) {
1063
- // Should be called `voip_token`, but we can't changed it to be retro-compatible
1064
- body.apns_token = apnsVoipToken;
1065
- body.apns_voip_token = apnsVoipToken;
1066
- }
1067
-
1068
- if (apnsNotificationToken) {
1069
- body.apns_notification_token = apnsNotificationToken;
1070
- }
1071
-
1072
- return client.post(`${baseUrl}/users/${userUuid}/external/mobile`, body);
1073
- },
1074
-
1075
- getPushNotificationSenderId: (userUuid ) =>
1076
- client.get(`${baseUrl}/users/${userUuid}/external/mobile/sender_id`, null).then(response => response.sender_id),
1077
-
1078
- /**
1079
- * `username` or `email` should be set.
1080
- */
1081
- sendResetPasswordEmail: ({ username, email } ) => {
1082
- const body = {};
1083
- if (username) {
1084
- body.username = username;
1085
- }
1086
- if (email) {
1087
- body.email = email;
1088
- }
1089
-
1090
- return client.get(`${baseUrl}/users/password/reset`, body, {}, ApiRequester.successResponseParser);
1091
- },
1092
-
1093
- resetPassword: (userUuid , password ) => {
1094
- const body = {
1095
- password,
1096
- };
1097
-
1098
- return client.post(
1099
- `${baseUrl}/users/password/reset?user_uuid=${userUuid}`,
1100
- body,
1101
- null,
1102
- ApiRequester.successResponseParser,
1103
- );
1104
- },
1105
-
1106
- removeDeviceToken: (userUuid ) => client.delete(`${baseUrl}/users/${userUuid}/external/mobile`),
1107
-
1108
- createUser: (
1109
- username ,
1110
- password ,
1111
- firstname ,
1112
- lastname ,
1113
- ) => {
1114
- const body = {
1115
- username,
1116
- password,
1117
- firstname,
1118
- lastname,
1119
- };
1120
-
1121
- return client.post(`${baseUrl}/users`, body);
1122
- },
1123
-
1124
- addUserEmail: (userUuid , email , main ) => {
1125
- const body = {
1126
- emails: [
1127
- {
1128
- address: email,
1129
- main,
1130
- },
1131
- ],
1132
- };
1133
-
1134
- return client.put(`${baseUrl}/users/${userUuid}/emails`, body);
1135
- },
1136
-
1137
- addUserPolicy: (userUuid , policyUuid ) =>
1138
- client.put(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
1139
-
1140
- getRestrictionPolicies: (scopes ) =>
1141
- client.post(`${baseUrl}/token/${client.token}/scopes/check`, { scopes }),
1142
-
1143
- deleteUserPolicy: (userUuid , policyUuid ) =>
1144
- client.delete(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
1145
-
1146
- addUserGroup: (userUuid , groupUuid ) => client.put(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
1147
-
1148
- listUsersGroup: (groupUuid ) => client.get(`${baseUrl}/groups/${groupUuid}/users`),
1149
-
1150
- deleteUserGroup: (userUuid , groupUuid ) =>
1151
- client.delete(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
1152
-
1153
- getUser: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}`),
1154
-
1155
- getUserSession: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}/sessions`),
1156
-
1157
- deleteUserSession: (userUuid , sessionUuids ) =>
1158
- client.delete(`${baseUrl}/users/${userUuid}/sessions/${sessionUuids}`),
1159
-
1160
- listUsers: () => client.get(`${baseUrl}/users`),
1161
-
1162
- deleteUser: (userUuid ) => client.delete(`${baseUrl}/users/${userUuid}`),
1163
-
1164
- listTenants: () => client.get(`${baseUrl}/tenants`),
1165
-
1166
- getTenant: (tenantUuid ) => client.get(`${baseUrl}/tenants/${tenantUuid}`),
1167
-
1168
- createTenant: (name ) => client.post(`${baseUrl}/tenants`, { name }),
1169
-
1170
- updateTenant: (
1171
- uuid ,
1172
- name ,
1173
- contact ,
1174
- phone ,
1175
- address ,
1176
- ) => {
1177
- const body = {
1178
- name,
1179
- contact,
1180
- phone,
1181
- address,
1182
- };
1183
-
1184
- return client.put(`${baseUrl}/tenants/${uuid}`, body);
1185
- },
1186
-
1187
- deleteTenant: (uuid ) => client.delete(`${baseUrl}/tenants/${uuid}`),
1188
-
1189
- createGroup: (name ) => client.post(`${baseUrl}/groups`, { name }),
1190
-
1191
- listGroups: () => client.get(`${baseUrl}/groups`),
1192
-
1193
- deleteGroup: (uuid ) => client.delete(`${baseUrl}/groups/${uuid}`),
1194
-
1195
- createPolicy: (name , description , aclTemplates ) => {
1196
- const body = {
1197
- name,
1198
- description,
1199
- acl_templates: aclTemplates, // deprecated
1200
- acl: aclTemplates,
1201
- };
1202
-
1203
- client.post(`${baseUrl}/policies`, body);
1204
- },
1205
-
1206
- listPolicies: () => client.get(`${baseUrl}/policies`),
1207
-
1208
- deletePolicy: (policyUuid ) =>
1209
- client.delete(`${baseUrl}/policies/${policyUuid}`),
1210
-
1211
- getProviders: (userUuid ) => client.get(`${baseUrl}/users/${userUuid}/external`),
1212
-
1213
- getProviderToken: (userUuid , provider ) =>
1214
- client.get(`${baseUrl}/users/${userUuid}/external/${provider}`),
1215
-
1216
- getProviderAuthUrl: (userUuid , provider ) =>
1217
- client.post(`${baseUrl}/users/${userUuid}/external/${provider}`, {}),
1218
-
1219
- deleteProviderToken: (userUuid , provider ) =>
1220
- client.delete(`${baseUrl}/users/${userUuid}/external/${provider}`),
1221
- });
1222
-
1223
- exports.BACKEND_LDAP_USER = BACKEND_LDAP_USER;
1224
- exports.DEFAULT_BACKEND_USER = DEFAULT_BACKEND_USER;
1225
- exports.DETAULT_EXPIRATION = DETAULT_EXPIRATION;
1226
- exports.default = auth;
31
+ if (params.tenantId) {
32
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
33
+ body.tenant_id = params.tenantId;
34
+ }
35
+ if (params.domainName) {
36
+ body.domain_name = params.domainName;
37
+ }
38
+ return client.post(`${baseUrl}/token`, body, headers).then((response) => Session_1.default.parse(response));
39
+ },
40
+ logOut: (token) => client.delete(`${baseUrl}/token/${token}`, null, {}, api_requester_1.default.successResponseParser),
41
+ refreshToken: (refreshToken, backend, expiration, isMobile, tenantId, domainName) => {
42
+ const body = {
43
+ backend: backend || exports.DEFAULT_BACKEND_USER,
44
+ expiration: expiration || exports.DETAULT_EXPIRATION,
45
+ refresh_token: refreshToken,
46
+ client_id: client.clientId,
47
+ };
48
+ if (tenantId) {
49
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
50
+ body.tenant_id = tenantId;
51
+ }
52
+ if (domainName) {
53
+ body.domain_name = domainName;
54
+ }
55
+ const headers = Object.assign({ 'Content-Type': 'application/json' }, (isMobile ? {
56
+ 'Wazo-Session-Type': 'mobile',
57
+ } : {}));
58
+ return client.post(`${baseUrl}/token`, body, headers, api_requester_1.default.defaultParser, false).then(Session_1.default.parse);
59
+ },
60
+ deleteRefreshToken: (clientId) => client.delete(`${baseUrl}/users/me/tokens/${clientId}`, null, null, api_requester_1.default.successResponseParser),
61
+ updatePassword: (userUuid, oldPassword, newPassword) => {
62
+ const body = {
63
+ new_password: newPassword,
64
+ old_password: oldPassword,
65
+ };
66
+ return client.put(`${baseUrl}/users/${userUuid}/password`, body, null, api_requester_1.default.successResponseParser);
67
+ },
68
+ sendDeviceToken: (userUuid, deviceToken, apnsVoipToken, apnsNotificationToken) => {
69
+ const body = {
70
+ token: deviceToken,
71
+ };
72
+ if (apnsVoipToken) {
73
+ // Should be called `voip_token`, but we can't changed it to be retro-compatible
74
+ body.apns_token = apnsVoipToken;
75
+ body.apns_voip_token = apnsVoipToken;
76
+ }
77
+ if (apnsNotificationToken) {
78
+ body.apns_notification_token = apnsNotificationToken;
79
+ }
80
+ return client.post(`${baseUrl}/users/${userUuid}/external/mobile`, body);
81
+ },
82
+ getPushNotificationSenderId: (userUuid) => client.get(`${baseUrl}/users/${userUuid}/external/mobile/sender_id`, null).then((response) => response.sender_id),
83
+ /**
84
+ * `username` or `email` should be set.
85
+ */
86
+ sendResetPasswordEmail: ({ username, email, }) => {
87
+ const body = {};
88
+ if (username) {
89
+ body.username = username;
90
+ }
91
+ if (email) {
92
+ body.email = email;
93
+ }
94
+ return client.get(`${baseUrl}/users/password/reset`, body, {}, api_requester_1.default.successResponseParser);
95
+ },
96
+ resetPassword: (userUuid, password) => {
97
+ const body = {
98
+ password,
99
+ };
100
+ return client.post(`${baseUrl}/users/password/reset?user_uuid=${userUuid}`, body, null, api_requester_1.default.successResponseParser);
101
+ },
102
+ removeDeviceToken: (userUuid) => client.delete(`${baseUrl}/users/${userUuid}/external/mobile`),
103
+ createUser: (username, password, firstname, lastname) => {
104
+ const body = {
105
+ username,
106
+ password,
107
+ firstname,
108
+ lastname,
109
+ };
110
+ return client.post(`${baseUrl}/users`, body);
111
+ },
112
+ addUserEmail: (userUuid, email, main) => {
113
+ const body = {
114
+ emails: [{
115
+ address: email,
116
+ main,
117
+ }],
118
+ };
119
+ return client.put(`${baseUrl}/users/${userUuid}/emails`, body);
120
+ },
121
+ addUserPolicy: (userUuid, policyUuid) => client.put(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
122
+ getRestrictionPolicies: (scopes) => client.post(`${baseUrl}/token/${client.token}/scopes/check`, {
123
+ scopes,
124
+ }),
125
+ deleteUserPolicy: (userUuid, policyUuid) => client.delete(`${baseUrl}/users/${userUuid}/policies/${policyUuid}`),
126
+ addUserGroup: (userUuid, groupUuid) => client.put(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
127
+ listUsersGroup: (groupUuid) => client.get(`${baseUrl}/groups/${groupUuid}/users`),
128
+ deleteUserGroup: (userUuid, groupUuid) => client.delete(`${baseUrl}/groups/${groupUuid}/users/${userUuid}`),
129
+ getUser: (userUuid) => client.get(`${baseUrl}/users/${userUuid}`),
130
+ getUserSession: (userUuid) => client.get(`${baseUrl}/users/${userUuid}/sessions`),
131
+ deleteUserSession: (userUuid, sessionUuids) => client.delete(`${baseUrl}/users/${userUuid}/sessions/${sessionUuids}`),
132
+ listUsers: () => client.get(`${baseUrl}/users`),
133
+ deleteUser: (userUuid) => client.delete(`${baseUrl}/users/${userUuid}`),
134
+ listTenants: () => client.get(`${baseUrl}/tenants`),
135
+ getTenant: (tenantUuid) => client.get(`${baseUrl}/tenants/${tenantUuid}`),
136
+ createTenant: (name) => client.post(`${baseUrl}/tenants`, {
137
+ name,
138
+ }),
139
+ updateTenant: (uuid, name, contact, phone, address) => {
140
+ const body = {
141
+ name,
142
+ contact,
143
+ phone,
144
+ address,
145
+ };
146
+ return client.put(`${baseUrl}/tenants/${uuid}`, body);
147
+ },
148
+ deleteTenant: (uuid) => client.delete(`${baseUrl}/tenants/${uuid}`),
149
+ createGroup: (name) => client.post(`${baseUrl}/groups`, {
150
+ name,
151
+ }),
152
+ listGroups: () => client.get(`${baseUrl}/groups`),
153
+ deleteGroup: (uuid) => client.delete(`${baseUrl}/groups/${uuid}`),
154
+ createPolicy: (name, description, aclTemplates) => {
155
+ const body = {
156
+ name,
157
+ description,
158
+ acl_templates: aclTemplates,
159
+ // deprecated
160
+ acl: aclTemplates,
161
+ };
162
+ return client.post(`${baseUrl}/policies`, body);
163
+ },
164
+ listPolicies: () => client.get(`${baseUrl}/policies`),
165
+ deletePolicy: (policyUuid) => client.delete(`${baseUrl}/policies/${policyUuid}`),
166
+ getProviders: (userUuid) => client.get(`${baseUrl}/users/${userUuid}/external`),
167
+ getProviderToken: (userUuid, provider) => client.get(`${baseUrl}/users/${userUuid}/external/${provider}`),
168
+ getProviderAuthUrl: (userUuid, provider) => client.post(`${baseUrl}/users/${userUuid}/external/${provider}`, {}),
169
+ deleteProviderToken: (userUuid, provider) => client.delete(`${baseUrl}/users/${userUuid}/external/${provider}`),
170
+ }));