@wazo/sdk 0.38.22 → 0.39.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (883) hide show
  1. package/README.md +62 -293
  2. package/dist/wazo-sdk.js +9 -25
  3. package/esm/__tests__/api-client.test.js +183 -5059
  4. package/esm/__tests__/web-rtc-client.test.js +177 -7930
  5. package/esm/api/agentd.js +23 -832
  6. package/esm/api/amid.js +9 -411
  7. package/esm/api/application.js +60 -829
  8. package/esm/api/auth.js +164 -1213
  9. package/esm/api/call-logd.js +24 -733
  10. package/esm/api/calld.js +114 -1469
  11. package/esm/api/chatd.js +48 -1311
  12. package/esm/api/confd.js +67 -1580
  13. package/esm/api/ctid-ng.js +92 -1343
  14. package/esm/api/dird.js +100 -1590
  15. package/esm/api/webhookd.js +7 -513
  16. package/esm/api-client.js +143 -4880
  17. package/esm/checker/Checker.js +45 -8727
  18. package/esm/checker/checks/aor.js +24 -4924
  19. package/esm/checker/checks/api.js +70 -4968
  20. package/esm/checker/checks/ice-ipv4.js +63 -117
  21. package/esm/checker/checks/index.js +8 -8677
  22. package/esm/checker/checks/symmetric-nat.js +54 -102
  23. package/esm/checker/checks/wazo-websocket.js +34 -999
  24. package/esm/checker/checks/webrtc-transport.js +28 -7845
  25. package/esm/checker/checks/webrtc.js +31 -7852
  26. package/esm/domain/AdHocAPIConference.js +86 -5115
  27. package/esm/domain/Agent.js +27 -61
  28. package/esm/domain/BadResponse.js +20 -43
  29. package/esm/domain/Call.js +120 -210
  30. package/esm/domain/CallLog.js +123 -305
  31. package/esm/domain/CallSession.js +251 -423
  32. package/esm/domain/ChatMessage.js +52 -105
  33. package/esm/domain/ChatRoom.js +28 -60
  34. package/esm/domain/Contact.js +435 -741
  35. package/esm/domain/Country.js +17 -19
  36. package/esm/domain/Device/DebugDevice.js +31 -47
  37. package/esm/domain/Device/Device.js +1 -1
  38. package/esm/domain/DirectorySource.js +1 -1
  39. package/esm/domain/ExternalApp.js +23 -56
  40. package/esm/domain/Features.js +57 -5009
  41. package/esm/domain/ForwardOption.js +35 -70
  42. package/esm/domain/IndirectTransfer.js +38 -97
  43. package/esm/domain/Line.js +37 -88
  44. package/esm/domain/Meeting.js +58 -113
  45. package/esm/domain/MeetingAuthorization.js +38 -68
  46. package/esm/domain/MeetingStatus.js +13 -28
  47. package/esm/domain/NotificationOptions.js +43 -77
  48. package/esm/domain/Phone/CTIPhone.js +245 -5743
  49. package/esm/domain/Phone/Phone.js +1 -2
  50. package/esm/domain/Phone/WebRTCPhone.js +1457 -2671
  51. package/esm/domain/Profile.js +120 -405
  52. package/esm/domain/Recording.js +27 -51
  53. package/esm/domain/Relocation.js +16 -40
  54. package/esm/domain/Room.js +90 -133
  55. package/esm/domain/SFUNotAvailableError.js +5 -8
  56. package/esm/domain/ServerError.js +8 -61
  57. package/esm/domain/Session.js +125 -251
  58. package/esm/domain/SipLine.js +78 -155
  59. package/esm/domain/Subscription.js +39 -83
  60. package/esm/domain/SwitchboardCall.js +51 -143
  61. package/esm/domain/Voicemail.js +57 -122
  62. package/esm/domain/__tests__/Agent.test.js +31 -101
  63. package/esm/domain/__tests__/Call.test.js +24 -232
  64. package/esm/domain/__tests__/CallLog.test.js +60 -386
  65. package/esm/domain/__tests__/CallSession.test.js +74 -502
  66. package/esm/domain/__tests__/Contact.test.js +220 -902
  67. package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
  68. package/esm/domain/__tests__/Line.test.js +48 -156
  69. package/esm/domain/__tests__/Meeting.test.js +73 -226
  70. package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
  71. package/esm/domain/__tests__/Profile.test.js +135 -496
  72. package/esm/domain/__tests__/Room.test.js +227 -719
  73. package/esm/domain/__tests__/Session.test.js +357 -1025
  74. package/esm/domain/__tests__/SipLine.test.js +24 -179
  75. package/esm/domain/__tests__/Voicemail.test.js +82 -200
  76. package/esm/domain/types.js +1 -1
  77. package/esm/index.js +63 -14985
  78. package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
  79. package/esm/pubkey.js +10 -0
  80. package/esm/service/CallApi.js +42 -5014
  81. package/esm/service/IssueReporter.js +278 -360
  82. package/esm/service/__tests__/IssueReporter.test.js +92 -494
  83. package/esm/service/getApiClient.js +53 -4972
  84. package/esm/simple/Auth.js +212 -14747
  85. package/esm/simple/Configuration.js +8 -14796
  86. package/esm/simple/Directory.js +6 -4964
  87. package/esm/simple/Phone.js +309 -14727
  88. package/esm/simple/Websocket.js +68 -1112
  89. package/esm/simple/index.js +125 -14792
  90. package/esm/simple/room/LocalParticipant.js +1 -14797
  91. package/esm/simple/room/Participant.js +274 -14760
  92. package/esm/simple/room/RemoteParticipant.js +6 -14796
  93. package/esm/simple/room/Room.js +648 -14736
  94. package/esm/simple/room/SipRoom.js +111 -14790
  95. package/esm/simple/room/Stream.js +40 -14792
  96. package/esm/simple/room/__tests__/Participant.test.js +68 -14872
  97. package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14805
  98. package/esm/simple/utils.js +9 -14799
  99. package/esm/types/WebSocketMessage.js +1 -1
  100. package/esm/types/__tests__/api-client.test.d.ts +2 -0
  101. package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
  102. package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
  103. package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  104. package/esm/types/api/agentd.d.ts +17 -0
  105. package/esm/types/api/agentd.d.ts.map +1 -0
  106. package/esm/types/api/amid.d.ts +8 -0
  107. package/esm/types/api/amid.d.ts.map +1 -0
  108. package/esm/types/api/application.d.ts +34 -0
  109. package/esm/types/api/application.d.ts.map +1 -0
  110. package/esm/types/api/auth.d.ts +64 -0
  111. package/esm/types/api/auth.d.ts.map +1 -0
  112. package/esm/types/api/call-logd.d.ts +12 -0
  113. package/esm/types/api/call-logd.d.ts.map +1 -0
  114. package/esm/types/api/calld.d.ts +51 -0
  115. package/esm/types/api/calld.d.ts.map +1 -0
  116. package/esm/types/api/chatd.d.ts +42 -0
  117. package/esm/types/api/chatd.d.ts.map +1 -0
  118. package/esm/types/api/confd.d.ts +39 -0
  119. package/esm/types/api/confd.d.ts.map +1 -0
  120. package/esm/types/api/ctid-ng.d.ts +36 -0
  121. package/esm/types/api/ctid-ng.d.ts.map +1 -0
  122. package/esm/types/api/dird.d.ts +38 -0
  123. package/esm/types/api/dird.d.ts.map +1 -0
  124. package/esm/types/api/webhookd.d.ts +24 -0
  125. package/esm/types/api/webhookd.d.ts.map +1 -0
  126. package/esm/types/api-client.d.ts +63 -0
  127. package/esm/types/api-client.d.ts.map +1 -0
  128. package/esm/types/checker/Checker.d.ts +13 -0
  129. package/esm/types/checker/Checker.d.ts.map +1 -0
  130. package/esm/types/checker/checks/aor.d.ts +6 -0
  131. package/esm/types/checker/checks/aor.d.ts.map +1 -0
  132. package/esm/types/checker/checks/api.d.ts +6 -0
  133. package/esm/types/checker/checks/api.d.ts.map +1 -0
  134. package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
  135. package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  136. package/esm/types/checker/checks/index.d.ts +9 -0
  137. package/esm/types/checker/checks/index.d.ts.map +1 -0
  138. package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
  139. package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  140. package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
  141. package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  142. package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
  143. package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  144. package/esm/types/checker/checks/webrtc.d.ts +6 -0
  145. package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
  146. package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
  147. package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
  148. package/esm/types/domain/Agent.d.ts +31 -0
  149. package/esm/types/domain/Agent.d.ts.map +1 -0
  150. package/esm/types/domain/BadResponse.d.ts +11 -0
  151. package/esm/types/domain/BadResponse.d.ts.map +1 -0
  152. package/esm/types/domain/Call.d.ts +79 -0
  153. package/esm/types/domain/Call.d.ts.map +1 -0
  154. package/esm/types/domain/CallLog.d.ts +91 -0
  155. package/esm/types/domain/CallLog.d.ts.map +1 -0
  156. package/esm/types/domain/CallSession.d.ts +120 -0
  157. package/esm/types/domain/CallSession.d.ts.map +1 -0
  158. package/esm/types/domain/ChatMessage.d.ts +41 -0
  159. package/esm/types/domain/ChatMessage.d.ts.map +1 -0
  160. package/esm/types/domain/ChatRoom.d.ts +22 -0
  161. package/esm/types/domain/ChatRoom.d.ts.map +1 -0
  162. package/esm/types/domain/Contact.d.ts +316 -0
  163. package/esm/types/domain/Contact.d.ts.map +1 -0
  164. package/esm/types/domain/Country.d.ts +20 -0
  165. package/esm/types/domain/Country.d.ts.map +1 -0
  166. package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
  167. package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
  168. package/esm/types/domain/Device/Device.d.ts +13 -0
  169. package/esm/types/domain/Device/Device.d.ts.map +1 -0
  170. package/esm/types/domain/DirectorySource.d.ts +13 -0
  171. package/esm/types/domain/DirectorySource.d.ts.map +1 -0
  172. package/esm/types/domain/ExternalApp.d.ts +22 -0
  173. package/esm/types/domain/ExternalApp.d.ts.map +1 -0
  174. package/esm/types/domain/Features.d.ts +24 -0
  175. package/esm/types/domain/Features.d.ts.map +1 -0
  176. package/esm/types/domain/ForwardOption.d.ts +27 -0
  177. package/esm/types/domain/ForwardOption.d.ts.map +1 -0
  178. package/esm/types/domain/IndirectTransfer.d.ts +31 -0
  179. package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
  180. package/esm/types/domain/Line.d.ts +46 -0
  181. package/esm/types/domain/Line.d.ts.map +1 -0
  182. package/esm/types/domain/Meeting.d.ts +45 -0
  183. package/esm/types/domain/Meeting.d.ts.map +1 -0
  184. package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
  185. package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
  186. package/esm/types/domain/MeetingStatus.d.ts +10 -0
  187. package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
  188. package/esm/types/domain/NotificationOptions.d.ts +22 -0
  189. package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
  190. package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
  191. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  192. package/esm/types/domain/Phone/Phone.d.ts +71 -0
  193. package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
  194. package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  195. package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  196. package/esm/types/domain/Profile.d.ts +151 -0
  197. package/esm/types/domain/Profile.d.ts.map +1 -0
  198. package/esm/types/domain/Recording.d.ts +26 -0
  199. package/esm/types/domain/Recording.d.ts.map +1 -0
  200. package/esm/types/domain/Relocation.d.ts +23 -0
  201. package/esm/types/domain/Relocation.d.ts.map +1 -0
  202. package/esm/types/domain/Room.d.ts +35 -0
  203. package/esm/types/domain/Room.d.ts.map +1 -0
  204. package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
  205. package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  206. package/esm/types/domain/ServerError.d.ts +6 -0
  207. package/esm/types/domain/ServerError.d.ts.map +1 -0
  208. package/esm/types/domain/Session.d.ts +90 -0
  209. package/esm/types/domain/Session.d.ts.map +1 -0
  210. package/esm/types/domain/SipLine.d.ts +54 -0
  211. package/esm/types/domain/SipLine.d.ts.map +1 -0
  212. package/esm/types/domain/Subscription.d.ts +43 -0
  213. package/esm/types/domain/Subscription.d.ts.map +1 -0
  214. package/esm/types/domain/SwitchboardCall.d.ts +62 -0
  215. package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
  216. package/esm/types/domain/Voicemail.d.ts +50 -0
  217. package/esm/types/domain/Voicemail.d.ts.map +1 -0
  218. package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
  219. package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  220. package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
  221. package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
  222. package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
  223. package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  224. package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
  225. package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  226. package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
  227. package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  228. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  229. package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  230. package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
  231. package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
  232. package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
  233. package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  234. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  235. package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  236. package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
  237. package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  238. package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
  239. package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
  240. package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
  241. package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
  242. package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
  243. package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  244. package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  245. package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  246. package/esm/types/domain/types.d.ts +217 -0
  247. package/esm/types/domain/types.d.ts.map +1 -0
  248. package/esm/types/index.d.ts +304 -0
  249. package/esm/types/index.d.ts.map +1 -0
  250. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  251. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  252. package/esm/types/pubkey.d.ts +3 -0
  253. package/esm/types/pubkey.d.ts.map +1 -0
  254. package/esm/types/service/CallApi.d.ts +28 -0
  255. package/esm/types/service/CallApi.d.ts.map +1 -0
  256. package/esm/types/service/IssueReporter.d.ts +40 -0
  257. package/esm/types/service/IssueReporter.d.ts.map +1 -0
  258. package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  259. package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  260. package/esm/types/service/getApiClient.d.ts +16 -0
  261. package/esm/types/service/getApiClient.d.ts.map +1 -0
  262. package/esm/types/simple/Auth.d.ts +51 -0
  263. package/esm/types/simple/Auth.d.ts.map +1 -0
  264. package/esm/types/simple/Configuration.d.ts +3 -0
  265. package/esm/types/simple/Configuration.d.ts.map +1 -0
  266. package/esm/types/simple/Directory.d.ts +3 -0
  267. package/esm/types/simple/Directory.d.ts.map +1 -0
  268. package/esm/types/simple/Phone.d.ts +115 -0
  269. package/esm/types/simple/Phone.d.ts.map +1 -0
  270. package/esm/types/simple/Websocket.d.ts +19 -0
  271. package/esm/types/simple/Websocket.d.ts.map +1 -0
  272. package/esm/types/simple/index.d.ts +147 -0
  273. package/esm/types/simple/index.d.ts.map +1 -0
  274. package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
  275. package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
  276. package/esm/types/simple/room/Participant.d.ts +76 -0
  277. package/esm/types/simple/room/Participant.d.ts.map +1 -0
  278. package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
  279. package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  280. package/esm/types/simple/room/Room.d.ts +116 -0
  281. package/esm/types/simple/room/Room.d.ts.map +1 -0
  282. package/esm/types/simple/room/SipRoom.d.ts +14 -0
  283. package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
  284. package/esm/types/simple/room/Stream.d.ts +13 -0
  285. package/esm/types/simple/room/Stream.d.ts.map +1 -0
  286. package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  287. package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  288. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  289. package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  290. package/esm/types/simple/utils.d.ts +3 -0
  291. package/esm/types/simple/utils.d.ts.map +1 -0
  292. package/esm/types/types/WebSocketMessage.d.ts +285 -0
  293. package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
  294. package/esm/types/utils/Emitter.d.ts +18 -0
  295. package/esm/types/utils/Emitter.d.ts.map +1 -0
  296. package/esm/types/utils/Heartbeat.d.ts +21 -0
  297. package/esm/types/utils/Heartbeat.d.ts.map +1 -0
  298. package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
  299. package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  300. package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  301. package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  302. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  303. package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  304. package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
  305. package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  306. package/esm/types/utils/__tests__/array.test.d.ts +2 -0
  307. package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
  308. package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
  309. package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  310. package/esm/types/utils/__tests__/object.test.d.ts +2 -0
  311. package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
  312. package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
  313. package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  314. package/esm/types/utils/__tests__/string.test.d.ts +2 -0
  315. package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
  316. package/esm/types/utils/api-requester.d.ts +45 -0
  317. package/esm/types/utils/api-requester.d.ts.map +1 -0
  318. package/esm/types/utils/array.d.ts +2 -0
  319. package/esm/types/utils/array.d.ts.map +1 -0
  320. package/esm/types/utils/compare-version.d.ts +3 -0
  321. package/esm/types/utils/compare-version.d.ts.map +1 -0
  322. package/esm/types/utils/isMobile.d.ts +3 -0
  323. package/esm/types/utils/isMobile.d.ts.map +1 -0
  324. package/esm/types/utils/new-from.d.ts +3 -0
  325. package/esm/types/utils/new-from.d.ts.map +1 -0
  326. package/esm/types/utils/object.d.ts +2 -0
  327. package/esm/types/utils/object.d.ts.map +1 -0
  328. package/esm/types/utils/once.d.ts +2 -0
  329. package/esm/types/utils/once.d.ts.map +1 -0
  330. package/esm/types/utils/sdp.d.ts +13 -0
  331. package/esm/types/utils/sdp.d.ts.map +1 -0
  332. package/esm/types/utils/string.d.ts +2 -0
  333. package/esm/types/utils/string.d.ts.map +1 -0
  334. package/esm/types/utils/update-from.d.ts +3 -0
  335. package/esm/types/utils/update-from.d.ts.map +1 -0
  336. package/esm/types/utils/webrtc.d.ts +15 -0
  337. package/esm/types/utils/webrtc.d.ts.map +1 -0
  338. package/esm/types/web-rtc-client.d.ts +220 -0
  339. package/esm/types/web-rtc-client.d.ts.map +1 -0
  340. package/esm/types/websocket-client.d.ts +134 -0
  341. package/esm/types/websocket-client.d.ts.map +1 -0
  342. package/esm/utils/Emitter.js +17 -27
  343. package/esm/utils/Heartbeat.js +60 -83
  344. package/esm/utils/PhoneNumberUtil.js +48 -63
  345. package/esm/utils/__tests__/Heartbeat.test.js +59 -168
  346. package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
  347. package/esm/utils/__tests__/api-requester.test.js +127 -780
  348. package/esm/utils/__tests__/array.test.js +16 -19
  349. package/esm/utils/__tests__/compare-version.test.js +8 -26
  350. package/esm/utils/__tests__/object.test.js +73 -54
  351. package/esm/utils/__tests__/sdp.test.js +87 -216
  352. package/esm/utils/__tests__/string.test.js +21 -27
  353. package/esm/utils/api-requester.js +197 -675
  354. package/esm/utils/array.js +7 -11
  355. package/esm/utils/compare-version.js +12 -15
  356. package/esm/utils/isMobile.js +0 -2
  357. package/esm/utils/new-from.js +7 -12
  358. package/esm/utils/object.js +9 -23
  359. package/esm/utils/once.js +12 -13
  360. package/esm/utils/sdp.js +87 -131
  361. package/esm/utils/string.js +5 -9
  362. package/esm/utils/update-from.js +9 -16
  363. package/esm/utils/webrtc.js +35 -36
  364. package/esm/web-rtc-client.js +2038 -7677
  365. package/esm/websocket-client.js +352 -944
  366. package/lib/__tests__/api-client.test.js +199 -5067
  367. package/lib/__tests__/web-rtc-client.test.js +191 -7941
  368. package/lib/api/agentd.js +27 -837
  369. package/lib/api/amid.js +18 -415
  370. package/lib/api/application.js +64 -834
  371. package/lib/api/auth.js +166 -1222
  372. package/lib/api/call-logd.js +28 -738
  373. package/lib/api/calld.js +126 -1473
  374. package/lib/api/chatd.js +65 -1316
  375. package/lib/api/confd.js +79 -1584
  376. package/lib/api/ctid-ng.js +96 -1348
  377. package/lib/api/dird.js +105 -1596
  378. package/lib/api/webhookd.js +11 -518
  379. package/lib/api-client.js +139 -4884
  380. package/lib/checker/Checker.js +61 -8739
  381. package/lib/checker/checks/aor.js +37 -4929
  382. package/lib/checker/checks/api.js +81 -4971
  383. package/lib/checker/checks/ice-ipv4.js +66 -118
  384. package/lib/checker/checks/index.js +13 -8687
  385. package/lib/checker/checks/symmetric-nat.js +56 -104
  386. package/lib/checker/checks/wazo-websocket.js +58 -1006
  387. package/lib/checker/checks/webrtc-transport.js +41 -7853
  388. package/lib/checker/checks/webrtc.js +42 -7858
  389. package/lib/domain/AdHocAPIConference.js +80 -5116
  390. package/lib/domain/Agent.js +23 -64
  391. package/lib/domain/BadResponse.js +17 -44
  392. package/lib/domain/Call.js +108 -215
  393. package/lib/domain/CallLog.js +117 -311
  394. package/lib/domain/CallSession.js +221 -424
  395. package/lib/domain/ChatMessage.js +49 -110
  396. package/lib/domain/ChatRoom.js +28 -60
  397. package/lib/domain/Contact.js +409 -742
  398. package/lib/domain/Country.js +19 -21
  399. package/lib/domain/Device/DebugDevice.js +34 -49
  400. package/lib/domain/Device/Device.js +2 -2
  401. package/lib/domain/DirectorySource.js +2 -2
  402. package/lib/domain/ExternalApp.js +24 -56
  403. package/lib/domain/Features.js +68 -5018
  404. package/lib/domain/ForwardOption.js +36 -71
  405. package/lib/domain/IndirectTransfer.js +39 -98
  406. package/lib/domain/Line.js +35 -88
  407. package/lib/domain/Meeting.js +51 -118
  408. package/lib/domain/MeetingAuthorization.js +35 -75
  409. package/lib/domain/MeetingStatus.js +13 -29
  410. package/lib/domain/NotificationOptions.js +45 -77
  411. package/lib/domain/Phone/CTIPhone.js +283 -5755
  412. package/lib/domain/Phone/Phone.js +2 -5
  413. package/lib/domain/Phone/WebRTCPhone.js +1457 -2716
  414. package/lib/domain/Profile.js +127 -406
  415. package/lib/domain/Recording.js +28 -57
  416. package/lib/domain/Relocation.js +15 -43
  417. package/lib/domain/Room.js +73 -134
  418. package/lib/domain/SFUNotAvailableError.js +7 -9
  419. package/lib/domain/ServerError.js +14 -63
  420. package/lib/domain/Session.js +118 -251
  421. package/lib/domain/SipLine.js +70 -155
  422. package/lib/domain/Subscription.js +32 -86
  423. package/lib/domain/SwitchboardCall.js +45 -145
  424. package/lib/domain/Voicemail.js +56 -127
  425. package/lib/domain/__tests__/Agent.test.js +36 -103
  426. package/lib/domain/__tests__/Call.test.js +28 -237
  427. package/lib/domain/__tests__/CallLog.test.js +65 -392
  428. package/lib/domain/__tests__/CallSession.test.js +78 -503
  429. package/lib/domain/__tests__/Contact.test.js +224 -903
  430. package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
  431. package/lib/domain/__tests__/Line.test.js +52 -157
  432. package/lib/domain/__tests__/Meeting.test.js +78 -232
  433. package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
  434. package/lib/domain/__tests__/Profile.test.js +161 -496
  435. package/lib/domain/__tests__/Room.test.js +239 -719
  436. package/lib/domain/__tests__/Session.test.js +350 -1024
  437. package/lib/domain/__tests__/SipLine.test.js +28 -180
  438. package/lib/domain/__tests__/Voicemail.test.js +86 -205
  439. package/lib/domain/types.js +2 -2
  440. package/lib/index.js +105 -15010
  441. package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
  442. package/lib/pubkey.js +12 -0
  443. package/lib/service/CallApi.js +88 -5015
  444. package/lib/service/IssueReporter.js +264 -366
  445. package/lib/service/__tests__/IssueReporter.test.js +97 -500
  446. package/lib/service/getApiClient.js +70 -4990
  447. package/lib/simple/Auth.js +272 -14777
  448. package/lib/simple/Configuration.js +23 -14805
  449. package/lib/simple/Directory.js +18 -4966
  450. package/lib/simple/Phone.js +345 -14746
  451. package/lib/simple/Websocket.js +98 -1117
  452. package/lib/simple/index.js +151 -14800
  453. package/lib/simple/room/LocalParticipant.js +7 -14808
  454. package/lib/simple/room/Participant.js +269 -14778
  455. package/lib/simple/room/RemoteParticipant.js +11 -14806
  456. package/lib/simple/room/Room.js +655 -14761
  457. package/lib/simple/room/SipRoom.js +136 -14805
  458. package/lib/simple/room/Stream.js +43 -14802
  459. package/lib/simple/room/__tests__/Participant.test.js +79 -14879
  460. package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14814
  461. package/lib/simple/utils.js +22 -14808
  462. package/lib/types/WebSocketMessage.js +2 -4
  463. package/lib/types/__tests__/api-client.test.d.ts +2 -0
  464. package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
  465. package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
  466. package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
  467. package/lib/types/api/agentd.d.ts +17 -0
  468. package/lib/types/api/agentd.d.ts.map +1 -0
  469. package/lib/types/api/amid.d.ts +8 -0
  470. package/lib/types/api/amid.d.ts.map +1 -0
  471. package/lib/types/api/application.d.ts +34 -0
  472. package/lib/types/api/application.d.ts.map +1 -0
  473. package/lib/types/api/auth.d.ts +64 -0
  474. package/lib/types/api/auth.d.ts.map +1 -0
  475. package/lib/types/api/call-logd.d.ts +12 -0
  476. package/lib/types/api/call-logd.d.ts.map +1 -0
  477. package/lib/types/api/calld.d.ts +51 -0
  478. package/lib/types/api/calld.d.ts.map +1 -0
  479. package/lib/types/api/chatd.d.ts +42 -0
  480. package/lib/types/api/chatd.d.ts.map +1 -0
  481. package/lib/types/api/confd.d.ts +39 -0
  482. package/lib/types/api/confd.d.ts.map +1 -0
  483. package/lib/types/api/ctid-ng.d.ts +36 -0
  484. package/lib/types/api/ctid-ng.d.ts.map +1 -0
  485. package/lib/types/api/dird.d.ts +38 -0
  486. package/lib/types/api/dird.d.ts.map +1 -0
  487. package/lib/types/api/webhookd.d.ts +24 -0
  488. package/lib/types/api/webhookd.d.ts.map +1 -0
  489. package/lib/types/api-client.d.ts +63 -0
  490. package/lib/types/api-client.d.ts.map +1 -0
  491. package/lib/types/checker/Checker.d.ts +13 -0
  492. package/lib/types/checker/Checker.d.ts.map +1 -0
  493. package/lib/types/checker/checks/aor.d.ts +6 -0
  494. package/lib/types/checker/checks/aor.d.ts.map +1 -0
  495. package/lib/types/checker/checks/api.d.ts +6 -0
  496. package/lib/types/checker/checks/api.d.ts.map +1 -0
  497. package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
  498. package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
  499. package/lib/types/checker/checks/index.d.ts +9 -0
  500. package/lib/types/checker/checks/index.d.ts.map +1 -0
  501. package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
  502. package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
  503. package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
  504. package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
  505. package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
  506. package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
  507. package/lib/types/checker/checks/webrtc.d.ts +6 -0
  508. package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
  509. package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
  510. package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
  511. package/lib/types/domain/Agent.d.ts +31 -0
  512. package/lib/types/domain/Agent.d.ts.map +1 -0
  513. package/lib/types/domain/BadResponse.d.ts +11 -0
  514. package/lib/types/domain/BadResponse.d.ts.map +1 -0
  515. package/lib/types/domain/Call.d.ts +79 -0
  516. package/lib/types/domain/Call.d.ts.map +1 -0
  517. package/lib/types/domain/CallLog.d.ts +91 -0
  518. package/lib/types/domain/CallLog.d.ts.map +1 -0
  519. package/lib/types/domain/CallSession.d.ts +120 -0
  520. package/lib/types/domain/CallSession.d.ts.map +1 -0
  521. package/lib/types/domain/ChatMessage.d.ts +41 -0
  522. package/lib/types/domain/ChatMessage.d.ts.map +1 -0
  523. package/lib/types/domain/ChatRoom.d.ts +22 -0
  524. package/lib/types/domain/ChatRoom.d.ts.map +1 -0
  525. package/lib/types/domain/Contact.d.ts +316 -0
  526. package/lib/types/domain/Contact.d.ts.map +1 -0
  527. package/lib/types/domain/Country.d.ts +20 -0
  528. package/lib/types/domain/Country.d.ts.map +1 -0
  529. package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
  530. package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
  531. package/lib/types/domain/Device/Device.d.ts +13 -0
  532. package/lib/types/domain/Device/Device.d.ts.map +1 -0
  533. package/lib/types/domain/DirectorySource.d.ts +13 -0
  534. package/lib/types/domain/DirectorySource.d.ts.map +1 -0
  535. package/lib/types/domain/ExternalApp.d.ts +22 -0
  536. package/lib/types/domain/ExternalApp.d.ts.map +1 -0
  537. package/lib/types/domain/Features.d.ts +24 -0
  538. package/lib/types/domain/Features.d.ts.map +1 -0
  539. package/lib/types/domain/ForwardOption.d.ts +27 -0
  540. package/lib/types/domain/ForwardOption.d.ts.map +1 -0
  541. package/lib/types/domain/IndirectTransfer.d.ts +31 -0
  542. package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
  543. package/lib/types/domain/Line.d.ts +46 -0
  544. package/lib/types/domain/Line.d.ts.map +1 -0
  545. package/lib/types/domain/Meeting.d.ts +45 -0
  546. package/lib/types/domain/Meeting.d.ts.map +1 -0
  547. package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
  548. package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
  549. package/lib/types/domain/MeetingStatus.d.ts +10 -0
  550. package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
  551. package/lib/types/domain/NotificationOptions.d.ts +22 -0
  552. package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
  553. package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
  554. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
  555. package/lib/types/domain/Phone/Phone.d.ts +71 -0
  556. package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
  557. package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
  558. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
  559. package/lib/types/domain/Profile.d.ts +151 -0
  560. package/lib/types/domain/Profile.d.ts.map +1 -0
  561. package/lib/types/domain/Recording.d.ts +26 -0
  562. package/lib/types/domain/Recording.d.ts.map +1 -0
  563. package/lib/types/domain/Relocation.d.ts +23 -0
  564. package/lib/types/domain/Relocation.d.ts.map +1 -0
  565. package/lib/types/domain/Room.d.ts +35 -0
  566. package/lib/types/domain/Room.d.ts.map +1 -0
  567. package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
  568. package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
  569. package/lib/types/domain/ServerError.d.ts +6 -0
  570. package/lib/types/domain/ServerError.d.ts.map +1 -0
  571. package/lib/types/domain/Session.d.ts +90 -0
  572. package/lib/types/domain/Session.d.ts.map +1 -0
  573. package/lib/types/domain/SipLine.d.ts +54 -0
  574. package/lib/types/domain/SipLine.d.ts.map +1 -0
  575. package/lib/types/domain/Subscription.d.ts +43 -0
  576. package/lib/types/domain/Subscription.d.ts.map +1 -0
  577. package/lib/types/domain/SwitchboardCall.d.ts +62 -0
  578. package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
  579. package/lib/types/domain/Voicemail.d.ts +50 -0
  580. package/lib/types/domain/Voicemail.d.ts.map +1 -0
  581. package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
  582. package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
  583. package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
  584. package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
  585. package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
  586. package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
  587. package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
  588. package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
  589. package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
  590. package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
  591. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
  592. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
  593. package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
  594. package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
  595. package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
  596. package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
  597. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
  598. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
  599. package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
  600. package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
  601. package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
  602. package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
  603. package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
  604. package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
  605. package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
  606. package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
  607. package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
  608. package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
  609. package/lib/types/domain/types.d.ts +217 -0
  610. package/lib/types/domain/types.d.ts.map +1 -0
  611. package/lib/types/index.d.ts +304 -0
  612. package/lib/types/index.d.ts.map +1 -0
  613. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
  614. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
  615. package/lib/types/pubkey.d.ts +3 -0
  616. package/lib/types/pubkey.d.ts.map +1 -0
  617. package/lib/types/service/CallApi.d.ts +28 -0
  618. package/lib/types/service/CallApi.d.ts.map +1 -0
  619. package/lib/types/service/IssueReporter.d.ts +40 -0
  620. package/lib/types/service/IssueReporter.d.ts.map +1 -0
  621. package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
  622. package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
  623. package/lib/types/service/getApiClient.d.ts +16 -0
  624. package/lib/types/service/getApiClient.d.ts.map +1 -0
  625. package/lib/types/simple/Auth.d.ts +51 -0
  626. package/lib/types/simple/Auth.d.ts.map +1 -0
  627. package/lib/types/simple/Configuration.d.ts +3 -0
  628. package/lib/types/simple/Configuration.d.ts.map +1 -0
  629. package/lib/types/simple/Directory.d.ts +3 -0
  630. package/lib/types/simple/Directory.d.ts.map +1 -0
  631. package/lib/types/simple/Phone.d.ts +115 -0
  632. package/lib/types/simple/Phone.d.ts.map +1 -0
  633. package/lib/types/simple/Websocket.d.ts +19 -0
  634. package/lib/types/simple/Websocket.d.ts.map +1 -0
  635. package/lib/types/simple/index.d.ts +147 -0
  636. package/lib/types/simple/index.d.ts.map +1 -0
  637. package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
  638. package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
  639. package/lib/types/simple/room/Participant.d.ts +76 -0
  640. package/lib/types/simple/room/Participant.d.ts.map +1 -0
  641. package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
  642. package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
  643. package/lib/types/simple/room/Room.d.ts +116 -0
  644. package/lib/types/simple/room/Room.d.ts.map +1 -0
  645. package/lib/types/simple/room/SipRoom.d.ts +14 -0
  646. package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
  647. package/lib/types/simple/room/Stream.d.ts +13 -0
  648. package/lib/types/simple/room/Stream.d.ts.map +1 -0
  649. package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
  650. package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
  651. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
  652. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
  653. package/lib/types/simple/utils.d.ts +3 -0
  654. package/lib/types/simple/utils.d.ts.map +1 -0
  655. package/lib/types/types/WebSocketMessage.d.ts +285 -0
  656. package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
  657. package/lib/types/utils/Emitter.d.ts +18 -0
  658. package/lib/types/utils/Emitter.d.ts.map +1 -0
  659. package/lib/types/utils/Heartbeat.d.ts +21 -0
  660. package/lib/types/utils/Heartbeat.d.ts.map +1 -0
  661. package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
  662. package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
  663. package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
  664. package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
  665. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
  666. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
  667. package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
  668. package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
  669. package/lib/types/utils/__tests__/array.test.d.ts +2 -0
  670. package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
  671. package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
  672. package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
  673. package/lib/types/utils/__tests__/object.test.d.ts +2 -0
  674. package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
  675. package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
  676. package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
  677. package/lib/types/utils/__tests__/string.test.d.ts +2 -0
  678. package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
  679. package/lib/types/utils/api-requester.d.ts +45 -0
  680. package/lib/types/utils/api-requester.d.ts.map +1 -0
  681. package/lib/types/utils/array.d.ts +2 -0
  682. package/lib/types/utils/array.d.ts.map +1 -0
  683. package/lib/types/utils/compare-version.d.ts +3 -0
  684. package/lib/types/utils/compare-version.d.ts.map +1 -0
  685. package/lib/types/utils/isMobile.d.ts +3 -0
  686. package/lib/types/utils/isMobile.d.ts.map +1 -0
  687. package/lib/types/utils/new-from.d.ts +3 -0
  688. package/lib/types/utils/new-from.d.ts.map +1 -0
  689. package/lib/types/utils/object.d.ts +2 -0
  690. package/lib/types/utils/object.d.ts.map +1 -0
  691. package/lib/types/utils/once.d.ts +2 -0
  692. package/lib/types/utils/once.d.ts.map +1 -0
  693. package/lib/types/utils/sdp.d.ts +13 -0
  694. package/lib/types/utils/sdp.d.ts.map +1 -0
  695. package/lib/types/utils/string.d.ts +2 -0
  696. package/lib/types/utils/string.d.ts.map +1 -0
  697. package/lib/types/utils/update-from.d.ts +3 -0
  698. package/lib/types/utils/update-from.d.ts.map +1 -0
  699. package/lib/types/utils/webrtc.d.ts +15 -0
  700. package/lib/types/utils/webrtc.d.ts.map +1 -0
  701. package/lib/types/web-rtc-client.d.ts +220 -0
  702. package/lib/types/web-rtc-client.d.ts.map +1 -0
  703. package/lib/types/websocket-client.d.ts +134 -0
  704. package/lib/types/websocket-client.d.ts.map +1 -0
  705. package/lib/utils/Emitter.js +22 -33
  706. package/lib/utils/Heartbeat.js +54 -86
  707. package/lib/utils/PhoneNumberUtil.js +60 -77
  708. package/lib/utils/__tests__/Heartbeat.test.js +73 -170
  709. package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
  710. package/lib/utils/__tests__/api-requester.test.js +139 -784
  711. package/lib/utils/__tests__/array.test.js +18 -21
  712. package/lib/utils/__tests__/compare-version.test.js +12 -27
  713. package/lib/utils/__tests__/object.test.js +75 -56
  714. package/lib/utils/__tests__/sdp.test.js +99 -220
  715. package/lib/utils/__tests__/string.test.js +23 -29
  716. package/lib/utils/api-requester.js +191 -685
  717. package/lib/utils/array.js +10 -14
  718. package/lib/utils/compare-version.js +15 -18
  719. package/lib/utils/isMobile.js +3 -5
  720. package/lib/utils/new-from.js +9 -14
  721. package/lib/utils/object.js +12 -26
  722. package/lib/utils/once.js +15 -15
  723. package/lib/utils/sdp.js +97 -150
  724. package/lib/utils/string.js +8 -12
  725. package/lib/utils/update-from.js +11 -18
  726. package/lib/utils/webrtc.js +38 -39
  727. package/lib/web-rtc-client.js +2070 -7694
  728. package/lib/websocket-client.js +357 -1021
  729. package/package.json +41 -34
  730. package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
  731. package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
  732. package/src/api/agentd.ts +37 -0
  733. package/src/api/amid.ts +16 -0
  734. package/src/api/application.ts +96 -0
  735. package/src/api/auth.ts +259 -0
  736. package/src/api/call-logd.ts +38 -0
  737. package/src/api/calld.ts +183 -0
  738. package/src/api/chatd.ts +101 -0
  739. package/src/api/confd.ts +110 -0
  740. package/src/api/ctid-ng.ts +152 -0
  741. package/src/api/dird.ts +146 -0
  742. package/src/api/webhookd.ts +30 -0
  743. package/src/{api-client.js → api-client.ts} +103 -67
  744. package/src/checker/{Checker.js → Checker.ts} +27 -20
  745. package/src/checker/checks/{aor.js → aor.ts} +10 -6
  746. package/src/checker/checks/{api.js → api.ts} +18 -17
  747. package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
  748. package/src/checker/checks/{index.js → index.ts} +1 -9
  749. package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
  750. package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
  751. package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
  752. package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
  753. package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
  754. package/src/domain/{Agent.js → Agent.ts} +11 -7
  755. package/src/domain/BadResponse.ts +29 -0
  756. package/src/domain/{Call.js → Call.ts} +62 -46
  757. package/src/domain/{CallLog.js → CallLog.ts} +61 -63
  758. package/src/domain/{CallSession.js → CallSession.ts} +55 -52
  759. package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
  760. package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
  761. package/src/domain/{Contact.js → Contact.ts} +380 -262
  762. package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
  763. package/src/domain/Device/{Device.js → Device.ts} +0 -11
  764. package/src/domain/DirectorySource.ts +13 -0
  765. package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
  766. package/src/domain/{Features.js → Features.ts} +43 -17
  767. package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
  768. package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
  769. package/src/domain/{Line.js → Line.ts} +39 -26
  770. package/src/domain/{Meeting.js → Meeting.ts} +36 -29
  771. package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
  772. package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
  773. package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
  774. package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
  775. package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
  776. package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +456 -422
  777. package/src/domain/{Profile.js → Profile.ts} +117 -100
  778. package/src/domain/{Recording.js → Recording.ts} +25 -16
  779. package/src/domain/{Relocation.js → Relocation.ts} +15 -14
  780. package/src/domain/{Room.js → Room.ts} +58 -27
  781. package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
  782. package/src/domain/ServerError.ts +12 -0
  783. package/src/domain/{Session.js → Session.ts} +89 -67
  784. package/src/domain/{SipLine.js → SipLine.ts} +52 -45
  785. package/src/domain/{Subscription.js → Subscription.ts} +22 -13
  786. package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
  787. package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
  788. package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
  789. package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
  790. package/src/domain/__tests__/CallLog.test.ts +65 -0
  791. package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
  792. package/src/domain/__tests__/Contact.test.ts +238 -0
  793. package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
  794. package/src/domain/__tests__/Line.test.ts +53 -0
  795. package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
  796. package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
  797. package/src/domain/__tests__/Profile.test.ts +139 -0
  798. package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
  799. package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
  800. package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
  801. package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
  802. package/src/domain/types.ts +227 -0
  803. package/src/{index.js → index.ts} +4 -28
  804. package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
  805. package/{config.js → src/pubkey.ts} +3 -3
  806. package/src/service/{CallApi.js → CallApi.ts} +14 -18
  807. package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
  808. package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
  809. package/src/service/getApiClient.ts +94 -0
  810. package/src/simple/{Auth.js → Auth.ts} +130 -101
  811. package/src/simple/{Configuration.js → Configuration.ts} +2 -3
  812. package/src/simple/{Directory.js → Directory.ts} +2 -3
  813. package/src/simple/Phone.ts +623 -0
  814. package/src/simple/Websocket.ts +119 -0
  815. package/src/simple/{index.js → index.ts} +51 -21
  816. package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
  817. package/src/simple/room/{Participant.js → Participant.ts} +108 -46
  818. package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
  819. package/src/simple/room/{Room.js → Room.ts} +266 -183
  820. package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
  821. package/src/simple/room/{Stream.js → Stream.ts} +8 -6
  822. package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
  823. package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
  824. package/src/simple/utils.ts +12 -0
  825. package/src/types/WebSocketMessage.ts +335 -0
  826. package/src/types/global.d.ts +26 -0
  827. package/src/utils/Emitter.ts +34 -0
  828. package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
  829. package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
  830. package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
  831. package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
  832. package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
  833. package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
  834. package/src/utils/__tests__/object.test.ts +77 -0
  835. package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
  836. package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
  837. package/src/utils/{api-requester.js → api-requester.ts} +104 -83
  838. package/src/utils/{array.js → array.ts} +2 -2
  839. package/src/utils/{compare-version.js → compare-version.ts} +3 -2
  840. package/src/utils/{isMobile.js → isMobile.ts} +1 -1
  841. package/src/utils/{new-from.js → new-from.ts} +3 -6
  842. package/src/utils/{object.js → object.ts} +3 -6
  843. package/src/utils/{once.js → once.ts} +5 -5
  844. package/src/utils/sdp.ts +119 -0
  845. package/src/utils/{string.js → string.ts} +2 -3
  846. package/src/utils/update-from.ts +11 -0
  847. package/src/utils/{webrtc.js → webrtc.ts} +21 -3
  848. package/src/{web-rtc-client.js → web-rtc-client.ts} +879 -476
  849. package/src/{websocket-client.js → websocket-client.ts} +146 -144
  850. package/esm/simple/Softphone.js +0 -394
  851. package/lib/simple/Softphone.js +0 -396
  852. package/src/api/agentd.js +0 -74
  853. package/src/api/amid.js +0 -13
  854. package/src/api/application.js +0 -137
  855. package/src/api/auth.js +0 -279
  856. package/src/api/call-logd.js +0 -20
  857. package/src/api/calld.js +0 -214
  858. package/src/api/chatd.js +0 -80
  859. package/src/api/confd.js +0 -127
  860. package/src/api/ctid-ng.js +0 -153
  861. package/src/api/dird.js +0 -159
  862. package/src/api/webhookd.js +0 -31
  863. package/src/domain/BadResponse.js +0 -42
  864. package/src/domain/DirectorySource.js +0 -16
  865. package/src/domain/ServerError.js +0 -18
  866. package/src/domain/__tests__/CallLog.test.js +0 -75
  867. package/src/domain/__tests__/Contact.test.js +0 -170
  868. package/src/domain/__tests__/Line.test.js +0 -73
  869. package/src/domain/__tests__/Profile.test.js +0 -104
  870. package/src/domain/types.js +0 -248
  871. package/src/lib/WazoSessionDescriptionHandler.js +0 -467
  872. package/src/service/getApiClient.js +0 -122
  873. package/src/simple/Phone.js +0 -425
  874. package/src/simple/Softphone.js +0 -392
  875. package/src/simple/Websocket.js +0 -86
  876. package/src/simple/utils.js +0 -17
  877. package/src/types/WebSocketMessage.js +0 -232
  878. package/src/utils/Emitter.js +0 -26
  879. package/src/utils/__tests__/object.test.js +0 -35
  880. package/src/utils/sdp.js +0 -140
  881. package/src/utils/update-from.js +0 -15
  882. /package/src/domain/{Country.js → Country.ts} +0 -0
  883. /package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
@@ -1,1049 +1,375 @@
1
- 'use strict';
2
-
3
- var jsrsasign = require('jsrsasign');
4
-
5
- //
6
-
7
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
8
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
9
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
10
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
11
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
12
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
13
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
14
- BwIDAQAB
15
- -----END PUBLIC KEY-----`;
16
-
17
- //
18
-
19
- var newFrom = (instance , ToClass ) => {
20
- const args = {};
21
- Object.getOwnPropertyNames(instance).forEach(prop => {
22
- args[prop] = instance[prop];
23
- });
24
-
25
- return new ToClass(args);
26
- };
27
-
28
- //
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
- class Line {
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
- static parse(plain ) {
69
- return new Line({
70
- id: plain.id,
71
- extensions: plain.extensions,
72
- endpointCustom: plain.endpoint_custom || null,
73
- endpointSccp: plain.endpoint_sccp || null,
74
- endpointSip: plain.endpoint_sip || null,
75
- });
76
- }
77
-
78
- static newFrom(profile ) {
79
- return newFrom(profile, Line);
80
- }
81
-
82
- is(line ) {
83
- return line ? this.id === line.id : false;
84
- }
85
-
86
- hasExtension(extension ) {
87
- if (!this.extensions) {
88
- return false;
89
- }
90
-
91
- return this.extensions.some(ext => ext.exten === extension);
92
- }
93
-
94
- constructor({ id, extensions, endpointCustom, endpointSccp, endpointSip } = {}) {
95
- this.id = id;
96
- this.extensions = extensions;
97
- this.endpointCustom = endpointCustom || null;
98
- this.endpointSccp = endpointSccp || null;
99
- this.endpointSip = endpointSip || null;
100
-
101
- // Useful to compare instead of instanceof with minified code
102
- this.type = 'Line';
103
- }
104
- }
105
-
106
- //
107
-
108
-
109
-
110
-
111
-
112
-
113
- const FORWARD_KEYS = {
114
- BUSY: 'busy',
115
- NO_ANSWER: 'noanswer',
116
- UNCONDITIONAL: 'unconditional',
117
- };
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
- class ForwardOption {
126
-
127
-
128
-
129
-
130
- static parse(plain , key ) {
131
- return new ForwardOption({
132
- destination: plain.destination || '',
133
- enabled: plain.enabled,
134
- key,
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
135
9
  });
136
- }
137
-
138
- static newFrom(profile ) {
139
- return newFrom(profile, ForwardOption);
140
- }
141
-
142
- constructor({ destination, enabled, key } = {}) {
143
- this.destination = destination;
144
- this.enabled = enabled;
145
- this.key = key;
146
- }
147
-
148
- setDestination(number ) {
149
- this.destination = number;
150
-
151
- return this;
152
- }
153
-
154
- setEnabled(enabled ) {
155
- this.enabled = enabled;
156
-
157
- return this;
158
- }
159
-
160
- is(other ) {
161
- return this.key === other.key;
162
- }
163
- }
164
-
165
- //
166
-
167
- const LINE_STATE = {
168
- AVAILABLE: 'available',
169
- HOLDING: 'holding',
170
- RINGING: 'ringing',
171
- TALKING: 'talking',
172
- UNAVAILABLE: 'unavailable',
173
- PROGRESSING: 'progressing',
174
10
  };
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
- class Profile {
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
- static parse(plain ) {
288
- return new Profile({
289
- id: plain.uuid,
290
- firstName: plain.firstName || plain.firstname || '',
291
- lastName: plain.lastName || plain.lastname || '',
292
- email: plain.email,
293
- lines: plain.lines.map(line => Line.parse(line)),
294
- username: plain.username,
295
- mobileNumber: plain.mobile_phone_number || '',
296
- ringSeconds: plain.ring_seconds,
297
- forwards: [
298
- ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
299
- ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
300
- ForwardOption.parse(plain.forwards.busy, FORWARD_KEYS.BUSY),
301
- ],
302
- doNotDisturb: plain.services.dnd.enabled,
303
- subscriptionType: plain.subscription_type,
304
- voicemail: plain.voicemail,
305
- switchboards: plain.switchboards || [],
306
- agent: plain.agent,
307
- status: '',
308
- callPickupTargetUsers: plain.call_pickup_target_users || [],
309
- onlineCallRecordEnabled: plain.online_call_record_enabled,
310
- });
311
- }
312
-
313
- static newFrom(profile ) {
314
- return newFrom(profile, Profile);
315
- }
316
-
317
- constructor({
318
- id,
319
- firstName,
320
- lastName,
321
- email,
322
- lines,
323
- username,
324
- mobileNumber,
325
- forwards,
326
- doNotDisturb,
327
- state,
328
- subscriptionType,
329
- voicemail,
330
- switchboards,
331
- agent,
332
- status,
333
- ringSeconds,
334
- sipLines,
335
- callPickupTargetUsers,
336
- onlineCallRecordEnabled,
337
- } = {}) {
338
- this.id = id;
339
- this.firstName = firstName;
340
- this.lastName = lastName;
341
- this.email = email;
342
- this.lines = lines;
343
- this.username = username;
344
- this.mobileNumber = mobileNumber;
345
- this.forwards = forwards;
346
- this.doNotDisturb = doNotDisturb;
347
- this.state = state;
348
- this.voicemail = voicemail;
349
- this.subscriptionType = subscriptionType;
350
- this.switchboards = switchboards;
351
- this.agent = agent;
352
- this.status = status;
353
- this.callPickupTargetUsers = callPickupTargetUsers;
354
- this.onlineCallRecordEnabled = onlineCallRecordEnabled;
355
- this.ringSeconds = ringSeconds;
356
-
357
- this.sipLines = sipLines || [];
358
- }
359
-
360
- static getLinesState(lines ) {
361
- let result = LINE_STATE.UNAVAILABLE;
362
-
363
- // eslint-disable-next-line
364
- for (const line of lines) {
365
- if (line.state === LINE_STATE.RINGING) {
366
- result = LINE_STATE.RINGING;
367
- break;
368
- }
369
-
370
- if (line.state === LINE_STATE.TALKING) {
371
- result = LINE_STATE.TALKING;
372
- break;
373
- }
374
-
375
- if (line.state === LINE_STATE.AVAILABLE) {
376
- result = LINE_STATE.AVAILABLE;
377
- }
378
- }
379
-
380
- return result;
381
- }
382
-
383
- hasId(id ) {
384
- return id === this.id;
385
- }
386
-
387
- setMobileNumber(number ) {
388
- this.mobileNumber = number;
389
-
390
- return this;
391
- }
392
-
393
- setForwardOption(forwardOption ) {
394
- const updatedForwardOptions = this.forwards.slice();
395
- const index = updatedForwardOptions.findIndex(forward => forward.is(forwardOption));
396
- updatedForwardOptions.splice(index, 1, forwardOption);
397
-
398
- this.forwards = updatedForwardOptions;
399
-
400
- return this;
401
- }
402
-
403
- setDoNotDisturb(enabled ) {
404
- this.doNotDisturb = enabled;
405
-
406
- return this;
407
- }
408
-
409
- setState(state ) {
410
- this.state = state;
411
-
412
- return this;
413
- }
414
- }
415
-
416
- // Can't use `semver` package as Wazo version aren't in semver format
417
-
418
- const compareVersions = (a, b) => {
419
- let i;
420
- let diff;
421
- const regExStrip0 = /(\.0+)+$/;
422
- const segmentsA = a.replace(regExStrip0, '').split('.');
423
- const segmentsB = b.replace(regExStrip0, '').split('.');
424
- const l = Math.min(segmentsA.length, segmentsB.length);
425
-
426
- for (i = 0; i < l; i++) {
427
- diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
428
- if (diff) {
429
- return diff;
430
- }
431
- }
432
- return segmentsA.length - segmentsB.length;
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
433
13
  };
434
-
435
- //
436
-
437
- const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
438
- const MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT = '19.08';
439
-
440
-
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
- class Session {
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
-
500
-
501
- static parse(plain ) {
502
- const token = plain.data.metadata ? plain.data.metadata.jwt : null;
503
- let authorizations = [];
504
-
505
- // Add authorizations from JWT
506
- if (token) {
507
- const isValid = jsrsasign.jws.JWS.verifyJWT(token, swarmKey, { alg: ['RS256'], verifyAt: new Date() });
508
- if (isValid) {
509
- const decodedToken = jsrsasign.jws.JWS.readSafeJSONString(jsrsasign.b64utoutf8(token.split('.')[1]));
510
- authorizations = decodedToken ? decodedToken.authorizations : [];
511
- }
512
- }
513
-
514
- return new Session({
515
- token: plain.data.token,
516
- refreshToken: plain.data.refresh_token || null,
517
- uuid: plain.data.metadata ? plain.data.metadata.uuid : null,
518
- sessionUuid: plain.data.session_uuid,
519
- authorizations,
520
- acl: plain.data.acls ? plain.data.acls : plain.data.acl ? plain.data.acl : [],
521
- tenantUuid: plain.data.metadata ? plain.data.metadata.tenant_uuid : undefined,
522
- expiresAt: new Date(`${plain.data.utc_expires_at}z`),
523
- engineUuid: plain.data.xivo_uuid,
524
- });
525
- }
526
-
527
- static newFrom(profile ) {
528
- return newFrom(profile, Session);
529
- }
530
-
531
- constructor({
532
- token,
533
- uuid,
534
- tenantUuid,
535
- profile,
536
- expiresAt,
537
- authorizations,
538
- acl,
539
- engineVersion,
540
- refreshToken,
541
- sessionUuid,
542
- engineUuid,
543
- } = {}) {
544
- this.token = token;
545
- this.uuid = uuid;
546
- this.tenantUuid = tenantUuid || null;
547
- this.profile = profile;
548
- this.expiresAt = expiresAt;
549
- this.authorizations = authorizations || [];
550
- this.acl = acl || [];
551
- this.engineVersion = engineVersion;
552
- this.refreshToken = refreshToken;
553
- this.sessionUuid = sessionUuid;
554
- this.engineUuid = engineUuid;
555
- }
556
-
557
- hasExpired(date = new Date()) {
558
- return date >= this.expiresAt;
559
- }
560
-
561
- is(contact ) {
562
- return Boolean(contact) && this.uuid === contact.uuid;
563
- }
564
-
565
- using(profile ) {
566
- this.profile = profile;
567
-
568
- return this;
569
- }
570
-
571
- hasAuthorizations() {
572
- return this.authorizations && !!this.authorizations.length;
573
- }
574
-
575
- displayName() {
576
- return this.profile ? `${this.profile.firstName} ${this.profile.lastName}` : '';
577
- }
578
-
579
- hasAccessToVoicemail() {
580
- if (!this.profile) {
581
- return false;
582
- }
583
- return !!this.profile.voicemail;
584
- }
585
-
586
- primaryLine() {
587
- return this.profile && this.profile.lines.length > 0 ? this.profile.lines[0] : null;
588
- }
589
-
590
- primarySipLine() {
591
- return this.profile && this.profile.sipLines.length > 0 ? this.profile.sipLines[0] : null;
592
- }
593
-
594
- primaryWebRtcLine() {
595
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && sipLine.isWebRtc());
596
- }
597
-
598
- primaryCtiLine() {
599
- return this.profile && (this.profile.sipLines || []).find(sipLine => sipLine && !sipLine.isWebRtc());
600
- }
601
-
602
- primaryContext() {
603
- if (this.engineVersion) {
604
- if (this.hasEngineVersionGte(MINIMUM_WAZO_ENGINE_VERSION_FOR_DEFAULT_CONTEXT)) {
605
- return 'default';
606
- }
607
- }
608
-
609
- const line = this.primaryLine();
610
-
611
- return line && line.extensions.length > 0 ? line.extensions[0].context : 'default';
612
- }
613
-
614
- hasEngineVersionGte(version ) {
615
- return this.engineVersion && compareVersions(String(this.engineVersion), String(version)) >= 0;
616
- }
617
-
618
- primaryNumber() {
619
- const line = this.primaryLine();
620
-
621
- return line && line.extensions.length ? line.extensions[0].exten : null;
622
- }
623
-
624
- allLines() {
625
- return this.profile ? this.profile.lines || [] : [];
626
- }
627
-
628
- allNumbers() {
629
- const extensions = this.allLines().map(line => line.extensions.map(extension => extension.exten));
630
- if (!extensions.length) {
631
- return [];
632
- }
633
-
634
- return extensions.reduce((a, b) => a.concat(b));
635
- }
636
-
637
- hasExtension(extension ) {
638
- return this.allNumbers().some(number => number === extension);
639
- }
640
-
641
- get acls() {
642
- console.warn('`acls` property of Session has been removed in Wazo\'s SDK, please use `acl` instead.');
643
- return this.acl;
644
- }
645
- }
646
-
647
- //
648
-
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const Session_1 = __importDefault(require("../Session"));
16
+ const Profile_1 = __importDefault(require("../Profile"));
17
+ const Line_1 = __importDefault(require("../Line"));
649
18
  describe('Session domain', () => {
650
- it('can parse a plain session to domain', () => {
651
- const plain = {
652
- data: {
653
- token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
654
- acl: [
655
- 'calld.lines.*.presences.read',
656
- 'calld.switchboards.#',
657
- 'calld.transfers.*.complete.update',
658
- 'calld.transfers.*.delete',
659
- 'calld.transfers.*.read',
660
- 'calld.users.*.presences.read',
661
- 'calld.users.me.#',
662
- 'confd.infos.read',
663
- 'confd.users.me.#.read',
664
- 'confd.users.me.forwards.*.*',
665
- 'confd.users.me.funckeys.*',
666
- 'confd.users.me.funckeys.*.*',
667
- 'confd.users.me.read',
668
- 'confd.users.me.services.*.*',
669
- 'confd.users.me.update',
670
- 'dird.#.me.read',
671
- 'dird.directories.favorites.#',
672
- 'dird.directories.lookup.*.headers.read',
673
- 'dird.directories.lookup.*.read',
674
- 'dird.directories.personal.*.read',
675
- 'dird.personal.#',
676
- 'events.calls.me',
677
- 'events.chat.message.*.me',
678
- 'events.config.users.me.#',
679
- 'events.statuses.*',
680
- 'events.switchboards.#',
681
- 'events.transfers.me',
682
- 'events.users.me.#',
683
- 'events.directory.me.#',
684
- 'websocketd',
685
- 'call-logd.users.me.cdr.read',
686
- ],
687
- utc_expires_at: '2017-07-19T21:27:53.086990',
688
- session_uuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
689
- xivo_uuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
690
- issued_at: '2017-07-19T16:27:53.086990',
691
- utc_issued_at: '2017-07-19T20:27:53.086990',
692
- auth_id: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
693
- metadata: {
694
- uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
695
- },
696
- expires_at: '2017-07-19T17:27:53.086990',
697
- xivo_user_uuid: null,
698
- },
699
- };
700
-
701
- const session = Session.parse(plain);
702
-
703
- expect(session).toEqual(
704
- new Session({
705
- token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
706
- refreshToken: null,
707
- acl: [
708
- 'calld.lines.*.presences.read',
709
- 'calld.switchboards.#',
710
- 'calld.transfers.*.complete.update',
711
- 'calld.transfers.*.delete',
712
- 'calld.transfers.*.read',
713
- 'calld.users.*.presences.read',
714
- 'calld.users.me.#',
715
- 'confd.infos.read',
716
- 'confd.users.me.#.read',
717
- 'confd.users.me.forwards.*.*',
718
- 'confd.users.me.funckeys.*',
719
- 'confd.users.me.funckeys.*.*',
720
- 'confd.users.me.read',
721
- 'confd.users.me.services.*.*',
722
- 'confd.users.me.update',
723
- 'dird.#.me.read',
724
- 'dird.directories.favorites.#',
725
- 'dird.directories.lookup.*.headers.read',
726
- 'dird.directories.lookup.*.read',
727
- 'dird.directories.personal.*.read',
728
- 'dird.personal.#',
729
- 'events.calls.me',
730
- 'events.chat.message.*.me',
731
- 'events.config.users.me.#',
732
- 'events.statuses.*',
733
- 'events.switchboards.#',
734
- 'events.transfers.me',
735
- 'events.users.me.#',
736
- 'events.directory.me.#',
737
- 'websocketd',
738
- 'call-logd.users.me.cdr.read',
739
- ],
740
- uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
741
- expiresAt: new Date('2017-07-19T21:27:53.086990z'),
742
- sessionUuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
743
- engineUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
744
- }),
745
- );
746
- });
747
-
748
- describe('about voicemails', () => {
749
- const A_DATE = new Date(2999, 5, 6, 14, 30, 1);
750
- it('has access to voicemail given there is a voicemail configured', () => {
751
- const session = new Session({
752
- token: 'ref-12345',
753
- uuid: '1234',
754
- profile: new Profile({
755
- voicemail: {
756
- id: 1234,
757
- name: 'inbox',
758
- },
759
- }),
760
- expiresAt: A_DATE,
761
- });
762
-
763
- expect(session.hasAccessToVoicemail()).toBeTruthy();
19
+ it('can parse a plain session to domain', () => {
20
+ const plain = {
21
+ data: {
22
+ token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
23
+ acl: ['calld.lines.*.presences.read', 'calld.switchboards.#', 'calld.transfers.*.complete.update', 'calld.transfers.*.delete', 'calld.transfers.*.read', 'calld.users.*.presences.read', 'calld.users.me.#', 'confd.infos.read', 'confd.users.me.#.read', 'confd.users.me.forwards.*.*', 'confd.users.me.funckeys.*', 'confd.users.me.funckeys.*.*', 'confd.users.me.read', 'confd.users.me.services.*.*', 'confd.users.me.update', 'dird.#.me.read', 'dird.directories.favorites.#', 'dird.directories.lookup.*.headers.read', 'dird.directories.lookup.*.read', 'dird.directories.personal.*.read', 'dird.personal.#', 'events.calls.me', 'events.chat.message.*.me', 'events.config.users.me.#', 'events.statuses.*', 'events.switchboards.#', 'events.transfers.me', 'events.users.me.#', 'events.directory.me.#', 'websocketd', 'call-logd.users.me.cdr.read'],
24
+ utc_expires_at: '2017-07-19T21:27:53.086990',
25
+ session_uuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
26
+ xivo_uuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
27
+ issued_at: '2017-07-19T16:27:53.086990',
28
+ utc_issued_at: '2017-07-19T20:27:53.086990',
29
+ auth_id: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
30
+ metadata: {
31
+ uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
32
+ },
33
+ expires_at: '2017-07-19T17:27:53.086990',
34
+ xivo_user_uuid: null,
35
+ },
36
+ };
37
+ const session = Session_1.default.parse(plain);
38
+ expect(session).toEqual(new Session_1.default({
39
+ token: 'b93ae6bd-08d7-4001-9e61-057e72bbc4b3',
40
+ refreshToken: null,
41
+ acl: ['calld.lines.*.presences.read', 'calld.switchboards.#', 'calld.transfers.*.complete.update', 'calld.transfers.*.delete', 'calld.transfers.*.read', 'calld.users.*.presences.read', 'calld.users.me.#', 'confd.infos.read', 'confd.users.me.#.read', 'confd.users.me.forwards.*.*', 'confd.users.me.funckeys.*', 'confd.users.me.funckeys.*.*', 'confd.users.me.read', 'confd.users.me.services.*.*', 'confd.users.me.update', 'dird.#.me.read', 'dird.directories.favorites.#', 'dird.directories.lookup.*.headers.read', 'dird.directories.lookup.*.read', 'dird.directories.personal.*.read', 'dird.personal.#', 'events.calls.me', 'events.chat.message.*.me', 'events.config.users.me.#', 'events.statuses.*', 'events.switchboards.#', 'events.transfers.me', 'events.users.me.#', 'events.directory.me.#', 'websocketd', 'call-logd.users.me.cdr.read'],
42
+ uuid: 'a14dd6d6-547c-434d-bd5c-e882b5b83b54',
43
+ expiresAt: new Date('2017-07-19T21:27:53.086990z'),
44
+ sessionUuid: 'f14dd6d6-547c-434d-bd5c-e882b5b83b32',
45
+ engineUuid: '6cd695d2-cdb9-4444-8b2d-27425ab85fa8',
46
+ }));
764
47
  });
765
-
766
- describe('When getting all numbers', () => {
767
- describe('and the user has multiple lines', () => {
768
- it('should return multiple extensions', () => {
769
- const session = new Session({
770
- token: 'ref-12345',
771
- uuid: '1234',
772
- profile: new Profile({
773
- lines: [
774
- new Line({ id: 9012, extensions: [{ id: 1, exten: '8000', context: 'default' }] }),
775
- new Line({ id: 3421, extensions: [{ id: 2, exten: '9980', context: 'internal' }] }),
776
- ],
777
- }),
778
- expiresAt: A_DATE,
779
- });
780
-
781
- expect(session.allNumbers().length).toBeGreaterThan(1);
782
- });
783
- });
784
- describe('and the user has one line', () => {
785
- it('should return only one extension', () => {
786
- const session = new Session({
787
- token: 'ref-12345',
788
- uuid: '1234',
789
- profile: new Profile({
790
- lines: [new Line({ id: 9012, extensions: [{ id: 1, exten: '8000', context: 'default' }] })],
791
- }),
792
- expiresAt: A_DATE,
793
- });
794
-
795
- expect(session.allNumbers().length).toEqual(1);
48
+ describe('about voicemails', () => {
49
+ const A_DATE = new Date(2999, 5, 6, 14, 30, 1);
50
+ it('has access to voicemail given there is a voicemail configured', () => {
51
+ const session = new Session_1.default({
52
+ token: 'ref-12345',
53
+ uuid: '1234',
54
+ // @ts-expect-error
55
+ profile: new Profile_1.default({
56
+ voicemail: {
57
+ id: 1234,
58
+ name: 'inbox',
59
+ },
60
+ }),
61
+ expiresAt: A_DATE,
62
+ });
63
+ expect(session.hasAccessToVoicemail()).toBeTruthy();
796
64
  });
797
- });
798
- });
799
-
800
- it('does not have access to voicemail given there is no voicemail configured', () => {
801
- const session = new Session({
802
- token: 'ref-12345',
803
- uuid: '1234',
804
- profile: new Profile({
805
- voicemail: undefined,
806
- }),
807
- expiresAt: A_DATE,
808
- });
809
-
810
- expect(session.hasAccessToVoicemail()).toBeFalsy();
811
- });
812
-
813
- it('does not have access to voicemail given there is no profile', () => {
814
- const session = new Session({
815
- token: 'ref-12345',
816
- uuid: '1234',
817
- expiresAt: A_DATE,
818
- });
819
-
820
- expect(session.hasAccessToVoicemail()).toBeFalsy();
821
- });
822
- });
823
-
824
- describe('Session expiration', () => {
825
- const EXPIRATION_DATE = new Date(2006, 5, 6, 14, 30, 1);
826
-
827
- it('session should be expired given date is equal to expiration date', () => {
828
- const session = new Session({
829
- token: 'ref-12345',
830
- uuid: '1234',
831
- expiresAt: EXPIRATION_DATE,
832
- });
833
- const currentDate = new Date(2006, 5, 6, 14, 30, 1);
834
-
835
- expect(session.hasExpired(currentDate)).toBeTruthy();
836
- });
837
-
838
- it('session should be expired given date is after expiration', () => {
839
- const session = new Session({
840
- token: 'ref-12345',
841
- uuid: '1234',
842
- expiresAt: EXPIRATION_DATE,
843
- });
844
- const currentDate = new Date(2006, 5, 6, 14, 32, 0);
845
-
846
- expect(session.hasExpired(currentDate)).toBeTruthy();
847
- });
848
-
849
- it('session should not be expired given date is before expiration', () => {
850
- const session = new Session({
851
- token: 'ref-12345',
852
- uuid: '1234',
853
- expiresAt: EXPIRATION_DATE,
854
- });
855
- const currentDate = new Date(2006, 5, 6, 14, 29, 0);
856
-
857
- expect(session.hasExpired(currentDate)).toBeFalsy();
858
- });
859
- });
860
-
861
- describe('when checking if session has a specific extension', () => {
862
- const session = new Session({
863
- token: 'ref-12345',
864
- uuid: '1234',
865
- profile: new Profile({
866
- lines: [
867
- new Line({ id: 9012, extensions: [{ id: 1, exten: '8000', context: 'default' }] }),
868
- new Line({ id: 3421, extensions: [{ id: 2, exten: '9980', context: 'internal' }] }),
869
- ],
870
- }),
871
- expiresAt: new Date(9999, 0, 1),
872
- });
873
-
874
- it('should return true given it owns the extension', () => {
875
- expect(session.hasExtension('8000')).toBeTruthy();
876
- });
877
-
878
- it("should return true given it owns the extension even if it's not the default one", () => {
879
- expect(session.hasExtension('9980')).toBeTruthy();
880
- });
881
-
882
- it("should return false given it does't own the extension", () => {
883
- expect(session.hasExtension('12')).toBeFalsy();
884
- });
885
- });
886
-
887
- describe('when getting the primary context', () => {
888
- const DEFAULT_CONTEXT = 'default';
889
- const SOME_CONTEXT = 'some-context';
890
-
891
- let A_SESSION;
892
-
893
- beforeEach(() => {
894
- A_SESSION = new Session({
895
- token: 'ref-12345',
896
- uuid: '1234',
897
- expiresAt: new Date(9999, 0, 1),
898
- engineVersion: null,
899
- });
900
- });
901
-
902
- describe('given NO engine version', () => {
903
- beforeEach(() => {
904
- A_SESSION = new Session({ ...A_SESSION, engineVersion: null });
905
- });
906
-
907
- describe('and NO profile', () => {
908
- beforeEach(() => {
909
- A_SESSION = new Session({ ...A_SESSION, profile: null });
65
+ describe('When getting all numbers', () => {
66
+ describe('and the user has multiple lines', () => {
67
+ it('should return multiple extensions', () => {
68
+ const session = new Session_1.default({
69
+ token: 'ref-12345',
70
+ uuid: '1234',
71
+ // @ts-expect-error
72
+ profile: new Profile_1.default({
73
+ lines: [new Line_1.default({
74
+ id: 9012,
75
+ extensions: [{
76
+ id: 1,
77
+ exten: '8000',
78
+ context: 'default',
79
+ }],
80
+ }), new Line_1.default({
81
+ id: 3421,
82
+ extensions: [{
83
+ id: 2,
84
+ exten: '9980',
85
+ context: 'internal',
86
+ }],
87
+ })],
88
+ }),
89
+ expiresAt: A_DATE,
90
+ });
91
+ expect(session.allNumbers().length).toBeGreaterThan(1);
92
+ });
93
+ });
94
+ describe('and the user has one line', () => {
95
+ it('should return only one extension', () => {
96
+ const session = new Session_1.default({
97
+ token: 'ref-12345',
98
+ uuid: '1234',
99
+ // @ts-expect-error
100
+ profile: new Profile_1.default({
101
+ lines: [new Line_1.default({
102
+ id: 9012,
103
+ extensions: [{
104
+ id: 1,
105
+ exten: '8000',
106
+ context: 'default',
107
+ }],
108
+ })],
109
+ }),
110
+ expiresAt: A_DATE,
111
+ });
112
+ expect(session.allNumbers().length).toEqual(1);
113
+ });
114
+ });
910
115
  });
911
-
912
- it('should return default context', async () => {
913
- const context = A_SESSION.primaryContext();
914
-
915
- expect(context).toEqual(DEFAULT_CONTEXT);
116
+ it('does not have access to voicemail given there is no voicemail configured', () => {
117
+ const session = new Session_1.default({
118
+ token: 'ref-12345',
119
+ uuid: '1234',
120
+ // @ts-expect-error
121
+ profile: new Profile_1.default({
122
+ voicemail: undefined,
123
+ }),
124
+ expiresAt: A_DATE,
125
+ });
126
+ expect(session.hasAccessToVoicemail()).toBeFalsy();
916
127
  });
917
- });
918
-
919
- describe('and NO lines', () => {
920
- beforeEach(() => {
921
- A_SESSION = new Session({ ...A_SESSION, profile: new Profile({ lines: [] }) });
128
+ it('does not have access to voicemail given there is no profile', () => {
129
+ const session = new Session_1.default({
130
+ token: 'ref-12345',
131
+ uuid: '1234',
132
+ expiresAt: A_DATE,
133
+ });
134
+ expect(session.hasAccessToVoicemail()).toBeFalsy();
922
135
  });
923
-
924
- it('should return default context', async () => {
925
- const context = A_SESSION.primaryContext();
926
-
927
- expect(context).toEqual(DEFAULT_CONTEXT);
136
+ });
137
+ describe('Session expiration', () => {
138
+ const EXPIRATION_DATE = new Date(2006, 5, 6, 14, 30, 1);
139
+ it('session should be expired given date is equal to expiration date', () => {
140
+ const session = new Session_1.default({
141
+ token: 'ref-12345',
142
+ uuid: '1234',
143
+ expiresAt: EXPIRATION_DATE,
144
+ });
145
+ const currentDate = new Date(2006, 5, 6, 14, 30, 1);
146
+ expect(session.hasExpired(currentDate)).toBeTruthy();
928
147
  });
929
- });
930
-
931
- describe('and some lines', () => {
932
- beforeEach(() => {
933
- const line = new Line({ extensions: [{ context: SOME_CONTEXT, id: 1, exten: '1' }], id: 1, exten: 1 });
934
- const profile = new Profile({ lines: [line] });
935
- A_SESSION = new Session({ ...A_SESSION, profile });
148
+ it('session should be expired given date is after expiration', () => {
149
+ const session = new Session_1.default({
150
+ token: 'ref-12345',
151
+ uuid: '1234',
152
+ expiresAt: EXPIRATION_DATE,
153
+ });
154
+ const currentDate = new Date(2006, 5, 6, 14, 32, 0);
155
+ expect(session.hasExpired(currentDate)).toBeTruthy();
936
156
  });
937
-
938
- it('should return line context', async () => {
939
- const context = A_SESSION.primaryContext();
940
-
941
- expect(context).toEqual(SOME_CONTEXT);
157
+ it('session should not be expired given date is before expiration', () => {
158
+ const session = new Session_1.default({
159
+ token: 'ref-12345',
160
+ uuid: '1234',
161
+ expiresAt: EXPIRATION_DATE,
162
+ });
163
+ const currentDate = new Date(2006, 5, 6, 14, 29, 0);
164
+ expect(session.hasExpired(currentDate)).toBeFalsy();
942
165
  });
943
- });
944
166
  });
945
-
946
- describe('given an engine version', () => {
947
- describe('that is invalid', () => {
948
- beforeEach(() => {
949
- A_SESSION = new Session({ ...A_SESSION, engineVersion: '19.09' });
167
+ describe('when checking if session has a specific extension', () => {
168
+ const session = new Session_1.default({
169
+ token: 'ref-12345',
170
+ uuid: '1234',
171
+ // @ts-expect-error
172
+ profile: new Profile_1.default({
173
+ lines: [new Line_1.default({
174
+ id: 9012,
175
+ extensions: [{
176
+ id: 1,
177
+ exten: '8000',
178
+ context: 'default',
179
+ }],
180
+ }), new Line_1.default({
181
+ id: 3421,
182
+ extensions: [{
183
+ id: 2,
184
+ exten: '9980',
185
+ context: 'internal',
186
+ }],
187
+ })],
188
+ }),
189
+ expiresAt: new Date(9999, 0, 1),
190
+ });
191
+ it('should return true given it owns the extension', () => {
192
+ expect(session.hasExtension('8000')).toBeTruthy();
950
193
  });
951
-
952
- describe('and NO lines', () => {
953
- beforeEach(() => {
954
- const profile = new Profile({ lines: [] });
955
- A_SESSION = new Session({ ...A_SESSION, profile });
956
- });
957
-
958
- it('should return default context', async () => {
959
- const context = A_SESSION.primaryContext();
960
-
961
- expect(context).toEqual(DEFAULT_CONTEXT);
962
- });
194
+ it("should return true given it owns the extension even if it's not the default one", () => {
195
+ expect(session.hasExtension('9980')).toBeTruthy();
963
196
  });
964
-
965
- describe('and some lines', () => {
966
- beforeEach(() => {
967
- const line = new Line({ extensions: [{ context: SOME_CONTEXT, id: 1, exten: '1' }], id: 1, exten: 1 });
968
- const profile = new Profile({ lines: [line] });
969
- A_SESSION = new Session({ ...A_SESSION, profile, engineVersion: '18.08' });
970
- });
971
-
972
- it('should return line context', async () => {
973
- const context = A_SESSION.primaryContext();
974
-
975
- expect(context).toEqual(SOME_CONTEXT);
976
- });
197
+ it("should return false given it does't own the extension", () => {
198
+ expect(session.hasExtension('12')).toBeFalsy();
977
199
  });
978
- });
979
-
980
- describe('that is valid', () => {
981
- describe('and under 19.08', () => {
982
- describe('and NO lines', () => {
983
- it('should return default context', async () => {
984
- const context = A_SESSION.primaryContext();
985
-
986
- expect(context).toEqual(DEFAULT_CONTEXT);
200
+ });
201
+ describe('when getting the primary context', () => {
202
+ const DEFAULT_CONTEXT = 'default';
203
+ const SOME_CONTEXT = 'some-context';
204
+ let A_SESSION;
205
+ beforeEach(() => {
206
+ A_SESSION = new Session_1.default({
207
+ token: 'ref-12345',
208
+ uuid: '1234',
209
+ expiresAt: new Date(9999, 0, 1),
210
+ engineVersion: null,
987
211
  });
988
- });
989
-
990
- describe('and some lines', () => {
212
+ });
213
+ describe('given NO engine version', () => {
991
214
  beforeEach(() => {
992
- const line = new Line({ extensions: [{ context: SOME_CONTEXT, id: 1, exten: '1' }], id: 1, exten: 1 });
993
- const profile = new Profile({ lines: [line] });
994
- A_SESSION = new Session({ ...A_SESSION, profile });
215
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { engineVersion: null }));
995
216
  });
996
-
997
- it('should return line context', async () => {
998
- const context = A_SESSION.primaryContext();
999
-
1000
- expect(context).toEqual(SOME_CONTEXT);
217
+ describe('and NO profile', () => {
218
+ beforeEach(() => {
219
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { profile: null }));
220
+ });
221
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
222
+ const context = A_SESSION.primaryContext();
223
+ expect(context).toEqual(DEFAULT_CONTEXT);
224
+ }));
225
+ });
226
+ describe('and NO lines', () => {
227
+ beforeEach(() => {
228
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), {
229
+ // @ts-expect-error
230
+ profile: new Profile_1.default({
231
+ lines: [],
232
+ }) }));
233
+ });
234
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
235
+ const context = A_SESSION.primaryContext();
236
+ expect(context).toEqual(DEFAULT_CONTEXT);
237
+ }));
238
+ });
239
+ describe('and some lines', () => {
240
+ beforeEach(() => {
241
+ const line = new Line_1.default({
242
+ extensions: [{
243
+ context: SOME_CONTEXT,
244
+ id: 1,
245
+ exten: '1',
246
+ }],
247
+ id: 1,
248
+ // @ts-expect-error
249
+ exten: 1,
250
+ });
251
+ // @ts-expect-error
252
+ const profile = new Profile_1.default({
253
+ lines: [line],
254
+ });
255
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { profile }));
256
+ });
257
+ it('should return line context', () => __awaiter(void 0, void 0, void 0, function* () {
258
+ const context = A_SESSION.primaryContext();
259
+ expect(context).toEqual(SOME_CONTEXT);
260
+ }));
1001
261
  });
1002
- });
1003
- });
1004
-
1005
- describe('and equal to 19.08', () => {
1006
- it('should return default context', async () => {
1007
- const context = A_SESSION.primaryContext();
1008
-
1009
- expect(context).toEqual(DEFAULT_CONTEXT);
1010
- });
1011
262
  });
1012
-
1013
- describe('and higher then 19.08', () => {
1014
- it('should return default context', async () => {
1015
- const context = A_SESSION.primaryContext();
1016
-
1017
- expect(context).toEqual(DEFAULT_CONTEXT);
1018
- });
263
+ describe('given an engine version', () => {
264
+ describe('that is invalid', () => {
265
+ beforeEach(() => {
266
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { engineVersion: '19.09' }));
267
+ });
268
+ describe('and NO lines', () => {
269
+ beforeEach(() => {
270
+ // @ts-expect-error
271
+ const profile = new Profile_1.default({
272
+ lines: [],
273
+ });
274
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { profile }));
275
+ });
276
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
277
+ const context = A_SESSION.primaryContext();
278
+ expect(context).toEqual(DEFAULT_CONTEXT);
279
+ }));
280
+ });
281
+ describe('and some lines', () => {
282
+ beforeEach(() => {
283
+ const line = new Line_1.default({
284
+ extensions: [{
285
+ context: SOME_CONTEXT,
286
+ id: 1,
287
+ exten: '1',
288
+ }],
289
+ id: 1,
290
+ // @ts-expect-error
291
+ exten: 1,
292
+ });
293
+ // @ts-expect-error
294
+ const profile = new Profile_1.default({
295
+ lines: [line],
296
+ });
297
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { profile, engineVersion: '18.08' }));
298
+ });
299
+ it('should return line context', () => __awaiter(void 0, void 0, void 0, function* () {
300
+ const context = A_SESSION.primaryContext();
301
+ expect(context).toEqual(SOME_CONTEXT);
302
+ }));
303
+ });
304
+ });
305
+ describe('that is valid', () => {
306
+ describe('and under 19.08', () => {
307
+ describe('and NO lines', () => {
308
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
309
+ const context = A_SESSION.primaryContext();
310
+ expect(context).toEqual(DEFAULT_CONTEXT);
311
+ }));
312
+ });
313
+ describe('and some lines', () => {
314
+ beforeEach(() => {
315
+ const line = new Line_1.default({
316
+ extensions: [{
317
+ context: SOME_CONTEXT,
318
+ id: 1,
319
+ exten: '1',
320
+ }],
321
+ id: 1,
322
+ // @ts-expect-error
323
+ exten: 1,
324
+ });
325
+ // @ts-expect-error
326
+ const profile = new Profile_1.default({
327
+ lines: [line],
328
+ });
329
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { profile }));
330
+ });
331
+ it('should return line context', () => __awaiter(void 0, void 0, void 0, function* () {
332
+ const context = A_SESSION.primaryContext();
333
+ expect(context).toEqual(SOME_CONTEXT);
334
+ }));
335
+ });
336
+ });
337
+ describe('and equal to 19.08', () => {
338
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
339
+ const context = A_SESSION.primaryContext();
340
+ expect(context).toEqual(DEFAULT_CONTEXT);
341
+ }));
342
+ });
343
+ describe('and higher then 19.08', () => {
344
+ it('should return default context', () => __awaiter(void 0, void 0, void 0, function* () {
345
+ const context = A_SESSION.primaryContext();
346
+ expect(context).toEqual(DEFAULT_CONTEXT);
347
+ }));
348
+ });
349
+ });
350
+ describe('when version is 19.10', () => {
351
+ it('should not consider that version is 19.1', () => {
352
+ A_SESSION = new Session_1.default(Object.assign(Object.assign({}, A_SESSION), { engineVersion: '19.10' }));
353
+ expect(A_SESSION.hasEngineVersionGte('19.10')).toBeTruthy();
354
+ expect(A_SESSION.hasEngineVersionGte('19.11')).toBeFalsy();
355
+ expect(A_SESSION.hasEngineVersionGte('19.09')).toBeTruthy();
356
+ expect(A_SESSION.hasEngineVersionGte('19.1')).toBeTruthy();
357
+ expect(A_SESSION.hasEngineVersionGte('19.2')).toBeTruthy();
358
+ });
359
+ });
1019
360
  });
1020
- });
1021
-
1022
- describe('when version is 19.10', () => {
1023
- it('should not consider that version is 19.1', () => {
1024
- A_SESSION = new Session({ ...A_SESSION, engineVersion: '19.10' });
1025
- expect(A_SESSION.hasEngineVersionGte('19.10')).toBeTruthy();
1026
- expect(A_SESSION.hasEngineVersionGte('19.11')).toBeFalsy();
1027
- expect(A_SESSION.hasEngineVersionGte('19.09')).toBeTruthy();
1028
- expect(A_SESSION.hasEngineVersionGte('19.1')).toBeTruthy();
1029
- expect(A_SESSION.hasEngineVersionGte('19.2')).toBeTruthy();
361
+ });
362
+ it('Should return `acl` when accessing `acls` property since it\'s deprecated', () => {
363
+ const acl = ['calld.lines.*.presences.read'];
364
+ const session = new Session_1.default({
365
+ acl,
366
+ expiresAt: new Date(),
367
+ token: 'abc',
1030
368
  });
1031
- });
369
+ const oldWarn = console.warn;
370
+ console.warn = () => { };
371
+ expect(session.acls).toEqual(acl);
372
+ expect(session.acl).toEqual(acl);
373
+ console.warn = oldWarn;
1032
374
  });
1033
- });
1034
-
1035
- it('Should return `acl` when accessing `acls` property since it\'s deprecated', () => {
1036
- const acl = ['calld.lines.*.presences.read'];
1037
- const session = new Session({ acl, expiresAt: new Date(), token: 'abc' });
1038
-
1039
- const oldWarn = console.warn;
1040
- // $FlowFixMe
1041
- console.warn = () => {};
1042
-
1043
- expect(session.acls).toEqual(acl);
1044
- expect(session.acl).toEqual(acl);
1045
-
1046
- // $FlowFixMe
1047
- console.warn = oldWarn;
1048
- });
1049
375
  });