@wazo/sdk 0.43.14 → 0.44.0

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 (887) hide show
  1. package/README.md +84 -57
  2. package/dist/index.js +10630 -0
  3. package/dist/index.mjs +10541 -0
  4. package/dist/types/api-client.d.ts +26 -0
  5. package/dist/types/api-client.d.ts.map +1 -0
  6. package/{lib/types/api-client.d.ts → dist/types/base-api-client.d.ts} +3 -24
  7. package/dist/types/base-api-client.d.ts.map +1 -0
  8. package/dist/types/constants.d.ts +12 -0
  9. package/dist/types/constants.d.ts.map +1 -0
  10. package/{lib → dist}/types/domain/Contact.d.ts +3 -1
  11. package/dist/types/domain/Contact.d.ts.map +1 -0
  12. package/{lib → dist}/types/index.d.ts +14 -13
  13. package/dist/types/index.d.ts.map +1 -0
  14. package/dist/types/service/__tests__/getApiclient.test.d.ts +2 -0
  15. package/dist/types/service/__tests__/getApiclient.test.d.ts.map +1 -0
  16. package/{lib → dist}/types/service/getApiClient.d.ts +5 -2
  17. package/dist/types/service/getApiClient.d.ts.map +1 -0
  18. package/{esm → dist}/types/simple/index.d.ts +1 -1
  19. package/{lib → dist}/types/utils/api-requester.d.ts.map +1 -1
  20. package/dist/wazo-sdk.js +69378 -43
  21. package/dist/wazo-sdk.js.LICENSE.txt +684 -0
  22. package/package.json +10 -21
  23. package/esm/__tests__/api-client.test.js +0 -281
  24. package/esm/__tests__/web-rtc-client.test.js +0 -192
  25. package/esm/api/agentd.js +0 -23
  26. package/esm/api/amid.js +0 -17
  27. package/esm/api/application.js +0 -63
  28. package/esm/api/auth.js +0 -198
  29. package/esm/api/call-logd.js +0 -24
  30. package/esm/api/calld.js +0 -120
  31. package/esm/api/chatd.js +0 -50
  32. package/esm/api/confd.js +0 -77
  33. package/esm/api/ctid-ng.js +0 -96
  34. package/esm/api/dird.js +0 -110
  35. package/esm/api/webhookd.js +0 -7
  36. package/esm/api-client.js +0 -166
  37. package/esm/checker/Checker.js +0 -54
  38. package/esm/checker/checks/aor.js +0 -28
  39. package/esm/checker/checks/api.js +0 -76
  40. package/esm/checker/checks/ice-ipv4.js +0 -69
  41. package/esm/checker/checks/index.js +0 -8
  42. package/esm/checker/checks/symmetric-nat.js +0 -59
  43. package/esm/checker/checks/wazo-websocket.js +0 -38
  44. package/esm/checker/checks/webrtc-transport.js +0 -35
  45. package/esm/checker/checks/webrtc.js +0 -40
  46. package/esm/domain/AdHocAPIConference.js +0 -102
  47. package/esm/domain/Agent.js +0 -30
  48. package/esm/domain/BadResponse.js +0 -21
  49. package/esm/domain/Call.js +0 -123
  50. package/esm/domain/CallLog.js +0 -157
  51. package/esm/domain/CallSession.js +0 -253
  52. package/esm/domain/CallerID.js +0 -24
  53. package/esm/domain/ChatMessage.js +0 -55
  54. package/esm/domain/ChatRoom.js +0 -30
  55. package/esm/domain/Contact.js +0 -464
  56. package/esm/domain/Country.js +0 -19
  57. package/esm/domain/Device/DebugDevice.js +0 -32
  58. package/esm/domain/Device/Device.js +0 -1
  59. package/esm/domain/DirectorySource.js +0 -1
  60. package/esm/domain/ExternalApp.js +0 -24
  61. package/esm/domain/Features.js +0 -77
  62. package/esm/domain/ForwardOption.js +0 -37
  63. package/esm/domain/Incall.js +0 -28
  64. package/esm/domain/IndirectTransfer.js +0 -40
  65. package/esm/domain/Line.js +0 -39
  66. package/esm/domain/Meeting.js +0 -61
  67. package/esm/domain/MeetingAuthorization.js +0 -46
  68. package/esm/domain/MeetingStatus.js +0 -14
  69. package/esm/domain/NotificationOptions.js +0 -45
  70. package/esm/domain/Phone/CTIPhone.js +0 -288
  71. package/esm/domain/Phone/Phone.js +0 -1
  72. package/esm/domain/Phone/WebRTCPhone.js +0 -1482
  73. package/esm/domain/Profile.js +0 -128
  74. package/esm/domain/Recording.js +0 -30
  75. package/esm/domain/Relocation.js +0 -20
  76. package/esm/domain/Room.js +0 -97
  77. package/esm/domain/SFUNotAvailableError.js +0 -6
  78. package/esm/domain/ServerError.js +0 -9
  79. package/esm/domain/Session.js +0 -174
  80. package/esm/domain/SipLine.js +0 -82
  81. package/esm/domain/Subscription.js +0 -42
  82. package/esm/domain/SwitchboardCall.js +0 -56
  83. package/esm/domain/Voicemail.js +0 -76
  84. package/esm/domain/__tests__/Agent.test.js +0 -37
  85. package/esm/domain/__tests__/Call.test.js +0 -25
  86. package/esm/domain/__tests__/CallLog.test.js +0 -181
  87. package/esm/domain/__tests__/CallSession.test.js +0 -78
  88. package/esm/domain/__tests__/Contact.test.js +0 -393
  89. package/esm/domain/__tests__/IndirectTransfer.test.js +0 -67
  90. package/esm/domain/__tests__/Line.test.js +0 -52
  91. package/esm/domain/__tests__/Meeting.test.js +0 -77
  92. package/esm/domain/__tests__/MeetingAuthorization.test.js +0 -49
  93. package/esm/domain/__tests__/Profile.test.js +0 -169
  94. package/esm/domain/__tests__/Room.test.js +0 -206
  95. package/esm/domain/__tests__/Session.test.js +0 -382
  96. package/esm/domain/__tests__/SipLine.test.js +0 -27
  97. package/esm/domain/__tests__/Voicemail.test.js +0 -90
  98. package/esm/domain/types.js +0 -2
  99. package/esm/index.js +0 -50
  100. package/esm/lib/WazoSessionDescriptionHandler.js +0 -429
  101. package/esm/pubkey.js +0 -10
  102. package/esm/service/CallApi.js +0 -61
  103. package/esm/service/IssueReporter.js +0 -331
  104. package/esm/service/__tests__/IssueReporter.test.js +0 -112
  105. package/esm/service/getApiClient.js +0 -92
  106. package/esm/simple/Auth.js +0 -384
  107. package/esm/simple/Configuration.js +0 -13
  108. package/esm/simple/Directory.js +0 -11
  109. package/esm/simple/Phone.js +0 -389
  110. package/esm/simple/Websocket.js +0 -81
  111. package/esm/simple/__tests__/Auth.test.js +0 -144
  112. package/esm/simple/index.js +0 -137
  113. package/esm/simple/room/LocalParticipant.js +0 -4
  114. package/esm/simple/room/Participant.js +0 -315
  115. package/esm/simple/room/RemoteParticipant.js +0 -10
  116. package/esm/simple/room/Room.js +0 -714
  117. package/esm/simple/room/SipRoom.js +0 -121
  118. package/esm/simple/room/Stream.js +0 -47
  119. package/esm/simple/room/__tests__/Participant.test.js +0 -71
  120. package/esm/simple/room/__tests__/RemoteParticipant.test.js +0 -12
  121. package/esm/simple/utils.js +0 -10
  122. package/esm/types/WebSocketMessage.js +0 -1
  123. package/esm/types/api-client.d.ts +0 -64
  124. package/esm/types/api-client.d.ts.map +0 -1
  125. package/esm/types/domain/Contact.d.ts +0 -332
  126. package/esm/types/domain/Contact.d.ts.map +0 -1
  127. package/esm/types/index.d.ts +0 -58
  128. package/esm/types/index.d.ts.map +0 -1
  129. package/esm/types/service/getApiClient.d.ts +0 -18
  130. package/esm/types/service/getApiClient.d.ts.map +0 -1
  131. package/esm/types/utils/api-requester.d.ts.map +0 -1
  132. package/esm/utils/Emitter.js +0 -19
  133. package/esm/utils/Heartbeat.js +0 -73
  134. package/esm/utils/PhoneNumberUtil.js +0 -67
  135. package/esm/utils/__tests__/Heartbeat.test.js +0 -65
  136. package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -70
  137. package/esm/utils/__tests__/api-requester.test.js +0 -166
  138. package/esm/utils/__tests__/array.test.js +0 -18
  139. package/esm/utils/__tests__/compare-version.test.js +0 -10
  140. package/esm/utils/__tests__/object.test.js +0 -76
  141. package/esm/utils/__tests__/sdp.test.js +0 -172
  142. package/esm/utils/__tests__/string.test.js +0 -49
  143. package/esm/utils/api-requester.js +0 -214
  144. package/esm/utils/array.js +0 -9
  145. package/esm/utils/compare-version.js +0 -17
  146. package/esm/utils/isMobile.js +0 -3
  147. package/esm/utils/new-from.js +0 -7
  148. package/esm/utils/object.js +0 -10
  149. package/esm/utils/once.js +0 -15
  150. package/esm/utils/sdp.js +0 -104
  151. package/esm/utils/string.js +0 -12
  152. package/esm/utils/update-from.js +0 -10
  153. package/esm/utils/webrtc.js +0 -37
  154. package/esm/web-rtc-client.js +0 -2200
  155. package/esm/websocket-client.js +0 -385
  156. package/index.js +0 -1
  157. package/lib/__tests__/api-client.test.js +0 -295
  158. package/lib/__tests__/web-rtc-client.test.js +0 -210
  159. package/lib/api/agentd.js +0 -28
  160. package/lib/api/amid.js +0 -28
  161. package/lib/api/application.js +0 -68
  162. package/lib/api/auth.js +0 -210
  163. package/lib/api/call-logd.js +0 -29
  164. package/lib/api/calld.js +0 -134
  165. package/lib/api/chatd.js +0 -68
  166. package/lib/api/confd.js +0 -91
  167. package/lib/api/ctid-ng.js +0 -101
  168. package/lib/api/dird.js +0 -124
  169. package/lib/api/webhookd.js +0 -12
  170. package/lib/api-client.js +0 -164
  171. package/lib/checker/Checker.js +0 -68
  172. package/lib/checker/checks/aor.js +0 -42
  173. package/lib/checker/checks/api.js +0 -90
  174. package/lib/checker/checks/ice-ipv4.js +0 -73
  175. package/lib/checker/checks/index.js +0 -13
  176. package/lib/checker/checks/symmetric-nat.js +0 -61
  177. package/lib/checker/checks/wazo-websocket.js +0 -63
  178. package/lib/checker/checks/webrtc-transport.js +0 -49
  179. package/lib/checker/checks/webrtc.js +0 -54
  180. package/lib/domain/AdHocAPIConference.js +0 -101
  181. package/lib/domain/Agent.js +0 -25
  182. package/lib/domain/BadResponse.js +0 -19
  183. package/lib/domain/Call.js +0 -112
  184. package/lib/domain/CallLog.js +0 -151
  185. package/lib/domain/CallSession.js +0 -224
  186. package/lib/domain/CallerID.js +0 -27
  187. package/lib/domain/ChatMessage.js +0 -53
  188. package/lib/domain/ChatRoom.js +0 -32
  189. package/lib/domain/Contact.js +0 -439
  190. package/lib/domain/Country.js +0 -21
  191. package/lib/domain/Device/DebugDevice.js +0 -35
  192. package/lib/domain/Device/Device.js +0 -2
  193. package/lib/domain/DirectorySource.js +0 -2
  194. package/lib/domain/ExternalApp.js +0 -27
  195. package/lib/domain/Features.js +0 -87
  196. package/lib/domain/ForwardOption.js +0 -41
  197. package/lib/domain/Incall.js +0 -32
  198. package/lib/domain/IndirectTransfer.js +0 -42
  199. package/lib/domain/Line.js +0 -39
  200. package/lib/domain/Meeting.js +0 -55
  201. package/lib/domain/MeetingAuthorization.js +0 -45
  202. package/lib/domain/MeetingStatus.js +0 -15
  203. package/lib/domain/NotificationOptions.js +0 -49
  204. package/lib/domain/Phone/CTIPhone.js +0 -324
  205. package/lib/domain/Phone/Phone.js +0 -2
  206. package/lib/domain/Phone/WebRTCPhone.js +0 -1492
  207. package/lib/domain/Profile.js +0 -138
  208. package/lib/domain/Recording.js +0 -31
  209. package/lib/domain/Relocation.js +0 -18
  210. package/lib/domain/Room.js +0 -81
  211. package/lib/domain/SFUNotAvailableError.js +0 -9
  212. package/lib/domain/ServerError.js +0 -15
  213. package/lib/domain/Session.js +0 -166
  214. package/lib/domain/SipLine.js +0 -76
  215. package/lib/domain/Subscription.js +0 -34
  216. package/lib/domain/SwitchboardCall.js +0 -50
  217. package/lib/domain/Voicemail.js +0 -77
  218. package/lib/domain/__tests__/Agent.test.js +0 -42
  219. package/lib/domain/__tests__/Call.test.js +0 -30
  220. package/lib/domain/__tests__/CallLog.test.js +0 -166
  221. package/lib/domain/__tests__/CallSession.test.js +0 -83
  222. package/lib/domain/__tests__/Contact.test.js +0 -371
  223. package/lib/domain/__tests__/IndirectTransfer.test.js +0 -81
  224. package/lib/domain/__tests__/Line.test.js +0 -57
  225. package/lib/domain/__tests__/Meeting.test.js +0 -82
  226. package/lib/domain/__tests__/MeetingAuthorization.test.js +0 -54
  227. package/lib/domain/__tests__/Profile.test.js +0 -197
  228. package/lib/domain/__tests__/Room.test.js +0 -220
  229. package/lib/domain/__tests__/Session.test.js +0 -378
  230. package/lib/domain/__tests__/SipLine.test.js +0 -32
  231. package/lib/domain/__tests__/Voicemail.test.js +0 -95
  232. package/lib/domain/types.js +0 -38
  233. package/lib/index.js +0 -125
  234. package/lib/lib/WazoSessionDescriptionHandler.js +0 -434
  235. package/lib/pubkey.js +0 -12
  236. package/lib/service/CallApi.js +0 -112
  237. package/lib/service/IssueReporter.js +0 -317
  238. package/lib/service/__tests__/IssueReporter.test.js +0 -117
  239. package/lib/service/getApiClient.js +0 -112
  240. package/lib/simple/Auth.js +0 -433
  241. package/lib/simple/Configuration.js +0 -31
  242. package/lib/simple/Directory.js +0 -29
  243. package/lib/simple/Phone.js +0 -418
  244. package/lib/simple/Websocket.js +0 -116
  245. package/lib/simple/__tests__/Auth.test.js +0 -181
  246. package/lib/simple/index.js +0 -165
  247. package/lib/simple/room/LocalParticipant.js +0 -9
  248. package/lib/simple/room/Participant.js +0 -302
  249. package/lib/simple/room/RemoteParticipant.js +0 -15
  250. package/lib/simple/room/Room.js +0 -711
  251. package/lib/simple/room/SipRoom.js +0 -141
  252. package/lib/simple/room/Stream.js +0 -50
  253. package/lib/simple/room/__tests__/Participant.test.js +0 -85
  254. package/lib/simple/room/__tests__/RemoteParticipant.test.js +0 -17
  255. package/lib/simple/utils.js +0 -27
  256. package/lib/types/WebSocketMessage.js +0 -2
  257. package/lib/types/__tests__/api-client.test.d.ts +0 -2
  258. package/lib/types/__tests__/api-client.test.d.ts.map +0 -1
  259. package/lib/types/__tests__/web-rtc-client.test.d.ts +0 -2
  260. package/lib/types/__tests__/web-rtc-client.test.d.ts.map +0 -1
  261. package/lib/types/api/agentd.d.ts +0 -17
  262. package/lib/types/api/agentd.d.ts.map +0 -1
  263. package/lib/types/api/amid.d.ts +0 -8
  264. package/lib/types/api/amid.d.ts.map +0 -1
  265. package/lib/types/api/application.d.ts +0 -34
  266. package/lib/types/api/application.d.ts.map +0 -1
  267. package/lib/types/api/auth.d.ts +0 -69
  268. package/lib/types/api/auth.d.ts.map +0 -1
  269. package/lib/types/api/call-logd.d.ts +0 -12
  270. package/lib/types/api/call-logd.d.ts.map +0 -1
  271. package/lib/types/api/calld.d.ts +0 -52
  272. package/lib/types/api/calld.d.ts.map +0 -1
  273. package/lib/types/api/chatd.d.ts +0 -29
  274. package/lib/types/api/chatd.d.ts.map +0 -1
  275. package/lib/types/api/confd.d.ts +0 -46
  276. package/lib/types/api/confd.d.ts.map +0 -1
  277. package/lib/types/api/ctid-ng.d.ts +0 -36
  278. package/lib/types/api/ctid-ng.d.ts.map +0 -1
  279. package/lib/types/api/dird.d.ts +0 -33
  280. package/lib/types/api/dird.d.ts.map +0 -1
  281. package/lib/types/api/webhookd.d.ts +0 -24
  282. package/lib/types/api/webhookd.d.ts.map +0 -1
  283. package/lib/types/api-client.d.ts.map +0 -1
  284. package/lib/types/checker/Checker.d.ts +0 -13
  285. package/lib/types/checker/Checker.d.ts.map +0 -1
  286. package/lib/types/checker/checks/aor.d.ts +0 -6
  287. package/lib/types/checker/checks/aor.d.ts.map +0 -1
  288. package/lib/types/checker/checks/api.d.ts +0 -6
  289. package/lib/types/checker/checks/api.d.ts.map +0 -1
  290. package/lib/types/checker/checks/ice-ipv4.d.ts +0 -6
  291. package/lib/types/checker/checks/ice-ipv4.d.ts.map +0 -1
  292. package/lib/types/checker/checks/index.d.ts +0 -9
  293. package/lib/types/checker/checks/index.d.ts.map +0 -1
  294. package/lib/types/checker/checks/symmetric-nat.d.ts +0 -6
  295. package/lib/types/checker/checks/symmetric-nat.d.ts.map +0 -1
  296. package/lib/types/checker/checks/wazo-websocket.d.ts +0 -6
  297. package/lib/types/checker/checks/wazo-websocket.d.ts.map +0 -1
  298. package/lib/types/checker/checks/webrtc-transport.d.ts +0 -7
  299. package/lib/types/checker/checks/webrtc-transport.d.ts.map +0 -1
  300. package/lib/types/checker/checks/webrtc.d.ts +0 -6
  301. package/lib/types/checker/checks/webrtc.d.ts.map +0 -1
  302. package/lib/types/domain/AdHocAPIConference.d.ts +0 -54
  303. package/lib/types/domain/AdHocAPIConference.d.ts.map +0 -1
  304. package/lib/types/domain/Agent.d.ts +0 -31
  305. package/lib/types/domain/Agent.d.ts.map +0 -1
  306. package/lib/types/domain/BadResponse.d.ts +0 -11
  307. package/lib/types/domain/BadResponse.d.ts.map +0 -1
  308. package/lib/types/domain/Call.d.ts +0 -79
  309. package/lib/types/domain/Call.d.ts.map +0 -1
  310. package/lib/types/domain/CallLog.d.ts +0 -88
  311. package/lib/types/domain/CallLog.d.ts.map +0 -1
  312. package/lib/types/domain/CallSession.d.ts +0 -119
  313. package/lib/types/domain/CallSession.d.ts.map +0 -1
  314. package/lib/types/domain/CallerID.d.ts +0 -22
  315. package/lib/types/domain/CallerID.d.ts.map +0 -1
  316. package/lib/types/domain/ChatMessage.d.ts +0 -41
  317. package/lib/types/domain/ChatMessage.d.ts.map +0 -1
  318. package/lib/types/domain/ChatRoom.d.ts +0 -22
  319. package/lib/types/domain/ChatRoom.d.ts.map +0 -1
  320. package/lib/types/domain/Contact.d.ts.map +0 -1
  321. package/lib/types/domain/Country.d.ts +0 -21
  322. package/lib/types/domain/Country.d.ts.map +0 -1
  323. package/lib/types/domain/Device/DebugDevice.d.ts +0 -14
  324. package/lib/types/domain/Device/DebugDevice.d.ts.map +0 -1
  325. package/lib/types/domain/Device/Device.d.ts +0 -13
  326. package/lib/types/domain/Device/Device.d.ts.map +0 -1
  327. package/lib/types/domain/DirectorySource.d.ts +0 -13
  328. package/lib/types/domain/DirectorySource.d.ts.map +0 -1
  329. package/lib/types/domain/ExternalApp.d.ts +0 -22
  330. package/lib/types/domain/ExternalApp.d.ts.map +0 -1
  331. package/lib/types/domain/Features.d.ts +0 -26
  332. package/lib/types/domain/Features.d.ts.map +0 -1
  333. package/lib/types/domain/ForwardOption.d.ts +0 -28
  334. package/lib/types/domain/ForwardOption.d.ts.map +0 -1
  335. package/lib/types/domain/Incall.d.ts +0 -21
  336. package/lib/types/domain/Incall.d.ts.map +0 -1
  337. package/lib/types/domain/IndirectTransfer.d.ts +0 -31
  338. package/lib/types/domain/IndirectTransfer.d.ts.map +0 -1
  339. package/lib/types/domain/Line.d.ts +0 -35
  340. package/lib/types/domain/Line.d.ts.map +0 -1
  341. package/lib/types/domain/Meeting.d.ts +0 -45
  342. package/lib/types/domain/Meeting.d.ts.map +0 -1
  343. package/lib/types/domain/MeetingAuthorization.d.ts +0 -32
  344. package/lib/types/domain/MeetingAuthorization.d.ts.map +0 -1
  345. package/lib/types/domain/MeetingStatus.d.ts +0 -10
  346. package/lib/types/domain/MeetingStatus.d.ts.map +0 -1
  347. package/lib/types/domain/NotificationOptions.d.ts +0 -22
  348. package/lib/types/domain/NotificationOptions.d.ts.map +0 -1
  349. package/lib/types/domain/Phone/CTIPhone.d.ts +0 -79
  350. package/lib/types/domain/Phone/CTIPhone.d.ts.map +0 -1
  351. package/lib/types/domain/Phone/Phone.d.ts +0 -83
  352. package/lib/types/domain/Phone/Phone.d.ts.map +0 -1
  353. package/lib/types/domain/Phone/WebRTCPhone.d.ts +0 -183
  354. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +0 -1
  355. package/lib/types/domain/Profile.d.ts +0 -155
  356. package/lib/types/domain/Profile.d.ts.map +0 -1
  357. package/lib/types/domain/Recording.d.ts +0 -26
  358. package/lib/types/domain/Recording.d.ts.map +0 -1
  359. package/lib/types/domain/Relocation.d.ts +0 -23
  360. package/lib/types/domain/Relocation.d.ts.map +0 -1
  361. package/lib/types/domain/Room.d.ts +0 -33
  362. package/lib/types/domain/Room.d.ts.map +0 -1
  363. package/lib/types/domain/SFUNotAvailableError.d.ts +0 -4
  364. package/lib/types/domain/SFUNotAvailableError.d.ts.map +0 -1
  365. package/lib/types/domain/ServerError.d.ts +0 -6
  366. package/lib/types/domain/ServerError.d.ts.map +0 -1
  367. package/lib/types/domain/Session.d.ts +0 -100
  368. package/lib/types/domain/Session.d.ts.map +0 -1
  369. package/lib/types/domain/SipLine.d.ts +0 -54
  370. package/lib/types/domain/SipLine.d.ts.map +0 -1
  371. package/lib/types/domain/Subscription.d.ts +0 -43
  372. package/lib/types/domain/Subscription.d.ts.map +0 -1
  373. package/lib/types/domain/SwitchboardCall.d.ts +0 -62
  374. package/lib/types/domain/SwitchboardCall.d.ts.map +0 -1
  375. package/lib/types/domain/Voicemail.d.ts +0 -58
  376. package/lib/types/domain/Voicemail.d.ts.map +0 -1
  377. package/lib/types/domain/__tests__/Agent.test.d.ts +0 -2
  378. package/lib/types/domain/__tests__/Agent.test.d.ts.map +0 -1
  379. package/lib/types/domain/__tests__/Call.test.d.ts +0 -2
  380. package/lib/types/domain/__tests__/Call.test.d.ts.map +0 -1
  381. package/lib/types/domain/__tests__/CallLog.test.d.ts +0 -2
  382. package/lib/types/domain/__tests__/CallLog.test.d.ts.map +0 -1
  383. package/lib/types/domain/__tests__/CallSession.test.d.ts +0 -2
  384. package/lib/types/domain/__tests__/CallSession.test.d.ts.map +0 -1
  385. package/lib/types/domain/__tests__/Contact.test.d.ts +0 -2
  386. package/lib/types/domain/__tests__/Contact.test.d.ts.map +0 -1
  387. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +0 -2
  388. package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +0 -1
  389. package/lib/types/domain/__tests__/Line.test.d.ts +0 -2
  390. package/lib/types/domain/__tests__/Line.test.d.ts.map +0 -1
  391. package/lib/types/domain/__tests__/Meeting.test.d.ts +0 -2
  392. package/lib/types/domain/__tests__/Meeting.test.d.ts.map +0 -1
  393. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +0 -2
  394. package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +0 -1
  395. package/lib/types/domain/__tests__/Profile.test.d.ts +0 -2
  396. package/lib/types/domain/__tests__/Profile.test.d.ts.map +0 -1
  397. package/lib/types/domain/__tests__/Room.test.d.ts +0 -2
  398. package/lib/types/domain/__tests__/Room.test.d.ts.map +0 -1
  399. package/lib/types/domain/__tests__/Session.test.d.ts +0 -2
  400. package/lib/types/domain/__tests__/Session.test.d.ts.map +0 -1
  401. package/lib/types/domain/__tests__/SipLine.test.d.ts +0 -2
  402. package/lib/types/domain/__tests__/SipLine.test.d.ts.map +0 -1
  403. package/lib/types/domain/__tests__/Voicemail.test.d.ts +0 -2
  404. package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +0 -1
  405. package/lib/types/domain/types.d.ts +0 -378
  406. package/lib/types/domain/types.d.ts.map +0 -1
  407. package/lib/types/index.d.ts.map +0 -1
  408. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +0 -31
  409. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +0 -1
  410. package/lib/types/pubkey.d.ts +0 -3
  411. package/lib/types/pubkey.d.ts.map +0 -1
  412. package/lib/types/service/CallApi.d.ts +0 -28
  413. package/lib/types/service/CallApi.d.ts.map +0 -1
  414. package/lib/types/service/IssueReporter.d.ts +0 -42
  415. package/lib/types/service/IssueReporter.d.ts.map +0 -1
  416. package/lib/types/service/__tests__/IssueReporter.test.d.ts +0 -2
  417. package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +0 -1
  418. package/lib/types/service/getApiClient.d.ts.map +0 -1
  419. package/lib/types/simple/Auth.d.ts +0 -75
  420. package/lib/types/simple/Auth.d.ts.map +0 -1
  421. package/lib/types/simple/Configuration.d.ts +0 -7
  422. package/lib/types/simple/Configuration.d.ts.map +0 -1
  423. package/lib/types/simple/Directory.d.ts +0 -7
  424. package/lib/types/simple/Directory.d.ts.map +0 -1
  425. package/lib/types/simple/Phone.d.ts +0 -119
  426. package/lib/types/simple/Phone.d.ts.map +0 -1
  427. package/lib/types/simple/Websocket.d.ts +0 -21
  428. package/lib/types/simple/Websocket.d.ts.map +0 -1
  429. package/lib/types/simple/__tests__/Auth.test.d.ts +0 -2
  430. package/lib/types/simple/__tests__/Auth.test.d.ts.map +0 -1
  431. package/lib/types/simple/index.d.ts +0 -153
  432. package/lib/types/simple/index.d.ts.map +0 -1
  433. package/lib/types/simple/room/LocalParticipant.d.ts +0 -5
  434. package/lib/types/simple/room/LocalParticipant.d.ts.map +0 -1
  435. package/lib/types/simple/room/Participant.d.ts +0 -77
  436. package/lib/types/simple/room/Participant.d.ts.map +0 -1
  437. package/lib/types/simple/room/RemoteParticipant.d.ts +0 -7
  438. package/lib/types/simple/room/RemoteParticipant.d.ts.map +0 -1
  439. package/lib/types/simple/room/Room.d.ts +0 -127
  440. package/lib/types/simple/room/Room.d.ts.map +0 -1
  441. package/lib/types/simple/room/SipRoom.d.ts +0 -14
  442. package/lib/types/simple/room/SipRoom.d.ts.map +0 -1
  443. package/lib/types/simple/room/Stream.d.ts +0 -13
  444. package/lib/types/simple/room/Stream.d.ts.map +0 -1
  445. package/lib/types/simple/room/__tests__/Participant.test.d.ts +0 -2
  446. package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +0 -1
  447. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +0 -2
  448. package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +0 -1
  449. package/lib/types/simple/utils.d.ts +0 -3
  450. package/lib/types/simple/utils.d.ts.map +0 -1
  451. package/lib/types/types/WebSocketMessage.d.ts +0 -285
  452. package/lib/types/types/WebSocketMessage.d.ts.map +0 -1
  453. package/lib/types/utils/Emitter.d.ts +0 -18
  454. package/lib/types/utils/Emitter.d.ts.map +0 -1
  455. package/lib/types/utils/Heartbeat.d.ts +0 -22
  456. package/lib/types/utils/Heartbeat.d.ts.map +0 -1
  457. package/lib/types/utils/PhoneNumberUtil.d.ts +0 -7
  458. package/lib/types/utils/PhoneNumberUtil.d.ts.map +0 -1
  459. package/lib/types/utils/__tests__/Heartbeat.test.d.ts +0 -2
  460. package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +0 -1
  461. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +0 -2
  462. package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +0 -1
  463. package/lib/types/utils/__tests__/api-requester.test.d.ts +0 -2
  464. package/lib/types/utils/__tests__/api-requester.test.d.ts.map +0 -1
  465. package/lib/types/utils/__tests__/array.test.d.ts +0 -2
  466. package/lib/types/utils/__tests__/array.test.d.ts.map +0 -1
  467. package/lib/types/utils/__tests__/compare-version.test.d.ts +0 -2
  468. package/lib/types/utils/__tests__/compare-version.test.d.ts.map +0 -1
  469. package/lib/types/utils/__tests__/object.test.d.ts +0 -2
  470. package/lib/types/utils/__tests__/object.test.d.ts.map +0 -1
  471. package/lib/types/utils/__tests__/sdp.test.d.ts +0 -2
  472. package/lib/types/utils/__tests__/sdp.test.d.ts.map +0 -1
  473. package/lib/types/utils/__tests__/string.test.d.ts +0 -2
  474. package/lib/types/utils/__tests__/string.test.d.ts.map +0 -1
  475. package/lib/types/utils/api-requester.d.ts +0 -48
  476. package/lib/types/utils/array.d.ts +0 -2
  477. package/lib/types/utils/array.d.ts.map +0 -1
  478. package/lib/types/utils/compare-version.d.ts +0 -3
  479. package/lib/types/utils/compare-version.d.ts.map +0 -1
  480. package/lib/types/utils/isMobile.d.ts +0 -3
  481. package/lib/types/utils/isMobile.d.ts.map +0 -1
  482. package/lib/types/utils/new-from.d.ts +0 -3
  483. package/lib/types/utils/new-from.d.ts.map +0 -1
  484. package/lib/types/utils/object.d.ts +0 -2
  485. package/lib/types/utils/object.d.ts.map +0 -1
  486. package/lib/types/utils/once.d.ts +0 -2
  487. package/lib/types/utils/once.d.ts.map +0 -1
  488. package/lib/types/utils/sdp.d.ts +0 -28
  489. package/lib/types/utils/sdp.d.ts.map +0 -1
  490. package/lib/types/utils/string.d.ts +0 -3
  491. package/lib/types/utils/string.d.ts.map +0 -1
  492. package/lib/types/utils/update-from.d.ts +0 -3
  493. package/lib/types/utils/update-from.d.ts.map +0 -1
  494. package/lib/types/utils/webrtc.d.ts +0 -15
  495. package/lib/types/utils/webrtc.d.ts.map +0 -1
  496. package/lib/types/web-rtc-client.d.ts +0 -198
  497. package/lib/types/web-rtc-client.d.ts.map +0 -1
  498. package/lib/types/websocket-client.d.ts +0 -138
  499. package/lib/types/websocket-client.d.ts.map +0 -1
  500. package/lib/utils/Emitter.js +0 -24
  501. package/lib/utils/Heartbeat.js +0 -66
  502. package/lib/utils/PhoneNumberUtil.js +0 -73
  503. package/lib/utils/__tests__/Heartbeat.test.js +0 -79
  504. package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -72
  505. package/lib/utils/__tests__/api-requester.test.js +0 -180
  506. package/lib/utils/__tests__/array.test.js +0 -20
  507. package/lib/utils/__tests__/compare-version.test.js +0 -15
  508. package/lib/utils/__tests__/object.test.js +0 -78
  509. package/lib/utils/__tests__/sdp.test.js +0 -188
  510. package/lib/utils/__tests__/string.test.js +0 -51
  511. package/lib/utils/api-requester.js +0 -201
  512. package/lib/utils/array.js +0 -13
  513. package/lib/utils/compare-version.js +0 -19
  514. package/lib/utils/isMobile.js +0 -5
  515. package/lib/utils/new-from.js +0 -9
  516. package/lib/utils/object.js +0 -14
  517. package/lib/utils/once.js +0 -18
  518. package/lib/utils/sdp.js +0 -115
  519. package/lib/utils/string.js +0 -17
  520. package/lib/utils/update-from.js +0 -12
  521. package/lib/utils/webrtc.js +0 -41
  522. package/lib/web-rtc-client.js +0 -2239
  523. package/lib/websocket-client.js +0 -390
  524. package/src/__tests__/api-client.test.ts +0 -315
  525. package/src/__tests__/web-rtc-client.test.ts +0 -198
  526. package/src/api/agentd.ts +0 -37
  527. package/src/api/amid.ts +0 -25
  528. package/src/api/application.ts +0 -96
  529. package/src/api/auth.ts +0 -305
  530. package/src/api/call-logd.ts +0 -38
  531. package/src/api/calld.ts +0 -185
  532. package/src/api/chatd.ts +0 -87
  533. package/src/api/confd.ts +0 -119
  534. package/src/api/ctid-ng.ts +0 -152
  535. package/src/api/dird.ts +0 -143
  536. package/src/api/webhookd.ts +0 -30
  537. package/src/api-client.ts +0 -233
  538. package/src/checker/Checker.ts +0 -73
  539. package/src/checker/checks/aor.ts +0 -34
  540. package/src/checker/checks/api.ts +0 -78
  541. package/src/checker/checks/ice-ipv4.ts +0 -80
  542. package/src/checker/checks/index.ts +0 -9
  543. package/src/checker/checks/symmetric-nat.ts +0 -69
  544. package/src/checker/checks/wazo-websocket.ts +0 -41
  545. package/src/checker/checks/webrtc-transport.ts +0 -42
  546. package/src/checker/checks/webrtc.ts +0 -48
  547. package/src/domain/AdHocAPIConference.ts +0 -166
  548. package/src/domain/Agent.ts +0 -68
  549. package/src/domain/BadResponse.ts +0 -29
  550. package/src/domain/Call.ts +0 -217
  551. package/src/domain/CallLog.ts +0 -265
  552. package/src/domain/CallSession.ts +0 -401
  553. package/src/domain/CallerID.ts +0 -49
  554. package/src/domain/ChatMessage.ts +0 -107
  555. package/src/domain/ChatRoom.ts +0 -55
  556. package/src/domain/Contact.ts +0 -851
  557. package/src/domain/Country.ts +0 -19
  558. package/src/domain/Device/DebugDevice.ts +0 -44
  559. package/src/domain/Device/Device.ts +0 -12
  560. package/src/domain/DirectorySource.ts +0 -13
  561. package/src/domain/ExternalApp.ts +0 -46
  562. package/src/domain/Features.ts +0 -105
  563. package/src/domain/ForwardOption.ts +0 -65
  564. package/src/domain/Incall.ts +0 -50
  565. package/src/domain/IndirectTransfer.ts +0 -73
  566. package/src/domain/Line.ts +0 -79
  567. package/src/domain/Meeting.ts +0 -113
  568. package/src/domain/MeetingAuthorization.ts +0 -81
  569. package/src/domain/MeetingStatus.ts +0 -23
  570. package/src/domain/NotificationOptions.ts +0 -68
  571. package/src/domain/Phone/CTIPhone.ts +0 -381
  572. package/src/domain/Phone/Phone.ts +0 -81
  573. package/src/domain/Phone/WebRTCPhone.ts +0 -1830
  574. package/src/domain/Profile.ts +0 -289
  575. package/src/domain/Recording.ts +0 -60
  576. package/src/domain/Relocation.ts +0 -45
  577. package/src/domain/Room.ts +0 -141
  578. package/src/domain/SFUNotAvailableError.ts +0 -7
  579. package/src/domain/ServerError.ts +0 -12
  580. package/src/domain/Session.ts +0 -297
  581. package/src/domain/SipLine.ts +0 -154
  582. package/src/domain/Subscription.ts +0 -95
  583. package/src/domain/SwitchboardCall.ts +0 -127
  584. package/src/domain/Voicemail.ts +0 -138
  585. package/src/domain/__tests__/Agent.test.ts +0 -38
  586. package/src/domain/__tests__/Call.test.ts +0 -26
  587. package/src/domain/__tests__/CallLog.test.ts +0 -203
  588. package/src/domain/__tests__/CallSession.test.ts +0 -80
  589. package/src/domain/__tests__/Contact.test.ts +0 -407
  590. package/src/domain/__tests__/IndirectTransfer.test.ts +0 -68
  591. package/src/domain/__tests__/Line.test.ts +0 -53
  592. package/src/domain/__tests__/Meeting.test.ts +0 -93
  593. package/src/domain/__tests__/MeetingAuthorization.test.ts +0 -50
  594. package/src/domain/__tests__/Profile.test.ts +0 -170
  595. package/src/domain/__tests__/Room.test.ts +0 -207
  596. package/src/domain/__tests__/Session.test.ts +0 -385
  597. package/src/domain/__tests__/SipLine.test.ts +0 -30
  598. package/src/domain/__tests__/Voicemail.test.ts +0 -91
  599. package/src/domain/types.ts +0 -331
  600. package/src/index.ts +0 -59
  601. package/src/lib/WazoSessionDescriptionHandler.ts +0 -532
  602. package/src/pubkey.ts +0 -11
  603. package/src/service/CallApi.ts +0 -86
  604. package/src/service/IssueReporter.ts +0 -434
  605. package/src/service/__tests__/IssueReporter.test.ts +0 -127
  606. package/src/service/getApiClient.ts +0 -106
  607. package/src/simple/Auth.ts +0 -496
  608. package/src/simple/Configuration.ts +0 -18
  609. package/src/simple/Directory.ts +0 -16
  610. package/src/simple/Phone.ts +0 -531
  611. package/src/simple/Websocket.ts +0 -107
  612. package/src/simple/__tests__/Auth.test.ts +0 -168
  613. package/src/simple/index.ts +0 -153
  614. package/src/simple/room/LocalParticipant.ts +0 -5
  615. package/src/simple/room/Participant.ts +0 -409
  616. package/src/simple/room/RemoteParticipant.ts +0 -15
  617. package/src/simple/room/Room.ts +0 -942
  618. package/src/simple/room/SipRoom.ts +0 -164
  619. package/src/simple/room/Stream.ts +0 -64
  620. package/src/simple/room/__tests__/Participant.test.ts +0 -73
  621. package/src/simple/room/__tests__/RemoteParticipant.test.ts +0 -15
  622. package/src/simple/utils.ts +0 -12
  623. package/src/types/WebSocketMessage.ts +0 -335
  624. package/src/types/global.d.ts +0 -33
  625. package/src/types/wazo.d.ts +0 -1
  626. package/src/utils/Emitter.ts +0 -34
  627. package/src/utils/Heartbeat.ts +0 -102
  628. package/src/utils/PhoneNumberUtil.ts +0 -81
  629. package/src/utils/__tests__/Heartbeat.test.ts +0 -66
  630. package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -79
  631. package/src/utils/__tests__/api-requester.test.ts +0 -180
  632. package/src/utils/__tests__/array.test.ts +0 -19
  633. package/src/utils/__tests__/compare-version.test.ts +0 -11
  634. package/src/utils/__tests__/object.test.ts +0 -77
  635. package/src/utils/__tests__/sdp.test.ts +0 -173
  636. package/src/utils/__tests__/string.test.ts +0 -55
  637. package/src/utils/api-requester.ts +0 -295
  638. package/src/utils/array.ts +0 -11
  639. package/src/utils/compare-version.ts +0 -21
  640. package/src/utils/isMobile.ts +0 -4
  641. package/src/utils/new-from.ts +0 -7
  642. package/src/utils/object.ts +0 -12
  643. package/src/utils/once.ts +0 -14
  644. package/src/utils/sdp.ts +0 -140
  645. package/src/utils/string.ts +0 -15
  646. package/src/utils/update-from.ts +0 -11
  647. package/src/utils/webrtc.ts +0 -56
  648. package/src/web-rtc-client.ts +0 -2687
  649. package/src/websocket-client.ts +0 -475
  650. /package/{esm → dist}/types/__tests__/api-client.test.d.ts +0 -0
  651. /package/{esm → dist}/types/__tests__/api-client.test.d.ts.map +0 -0
  652. /package/{esm → dist}/types/__tests__/web-rtc-client.test.d.ts +0 -0
  653. /package/{esm → dist}/types/__tests__/web-rtc-client.test.d.ts.map +0 -0
  654. /package/{esm → dist}/types/api/agentd.d.ts +0 -0
  655. /package/{esm → dist}/types/api/agentd.d.ts.map +0 -0
  656. /package/{esm → dist}/types/api/amid.d.ts +0 -0
  657. /package/{esm → dist}/types/api/amid.d.ts.map +0 -0
  658. /package/{esm → dist}/types/api/application.d.ts +0 -0
  659. /package/{esm → dist}/types/api/application.d.ts.map +0 -0
  660. /package/{esm → dist}/types/api/auth.d.ts +0 -0
  661. /package/{esm → dist}/types/api/auth.d.ts.map +0 -0
  662. /package/{esm → dist}/types/api/call-logd.d.ts +0 -0
  663. /package/{esm → dist}/types/api/call-logd.d.ts.map +0 -0
  664. /package/{esm → dist}/types/api/calld.d.ts +0 -0
  665. /package/{esm → dist}/types/api/calld.d.ts.map +0 -0
  666. /package/{esm → dist}/types/api/chatd.d.ts +0 -0
  667. /package/{esm → dist}/types/api/chatd.d.ts.map +0 -0
  668. /package/{esm → dist}/types/api/confd.d.ts +0 -0
  669. /package/{esm → dist}/types/api/confd.d.ts.map +0 -0
  670. /package/{esm → dist}/types/api/ctid-ng.d.ts +0 -0
  671. /package/{esm → dist}/types/api/ctid-ng.d.ts.map +0 -0
  672. /package/{esm → dist}/types/api/dird.d.ts +0 -0
  673. /package/{esm → dist}/types/api/dird.d.ts.map +0 -0
  674. /package/{esm → dist}/types/api/webhookd.d.ts +0 -0
  675. /package/{esm → dist}/types/api/webhookd.d.ts.map +0 -0
  676. /package/{esm → dist}/types/checker/Checker.d.ts +0 -0
  677. /package/{esm → dist}/types/checker/Checker.d.ts.map +0 -0
  678. /package/{esm → dist}/types/checker/checks/aor.d.ts +0 -0
  679. /package/{esm → dist}/types/checker/checks/aor.d.ts.map +0 -0
  680. /package/{esm → dist}/types/checker/checks/api.d.ts +0 -0
  681. /package/{esm → dist}/types/checker/checks/api.d.ts.map +0 -0
  682. /package/{esm → dist}/types/checker/checks/ice-ipv4.d.ts +0 -0
  683. /package/{esm → dist}/types/checker/checks/ice-ipv4.d.ts.map +0 -0
  684. /package/{esm → dist}/types/checker/checks/index.d.ts +0 -0
  685. /package/{esm → dist}/types/checker/checks/index.d.ts.map +0 -0
  686. /package/{esm → dist}/types/checker/checks/symmetric-nat.d.ts +0 -0
  687. /package/{esm → dist}/types/checker/checks/symmetric-nat.d.ts.map +0 -0
  688. /package/{esm → dist}/types/checker/checks/wazo-websocket.d.ts +0 -0
  689. /package/{esm → dist}/types/checker/checks/wazo-websocket.d.ts.map +0 -0
  690. /package/{esm → dist}/types/checker/checks/webrtc-transport.d.ts +0 -0
  691. /package/{esm → dist}/types/checker/checks/webrtc-transport.d.ts.map +0 -0
  692. /package/{esm → dist}/types/checker/checks/webrtc.d.ts +0 -0
  693. /package/{esm → dist}/types/checker/checks/webrtc.d.ts.map +0 -0
  694. /package/{esm → dist}/types/domain/AdHocAPIConference.d.ts +0 -0
  695. /package/{esm → dist}/types/domain/AdHocAPIConference.d.ts.map +0 -0
  696. /package/{esm → dist}/types/domain/Agent.d.ts +0 -0
  697. /package/{esm → dist}/types/domain/Agent.d.ts.map +0 -0
  698. /package/{esm → dist}/types/domain/BadResponse.d.ts +0 -0
  699. /package/{esm → dist}/types/domain/BadResponse.d.ts.map +0 -0
  700. /package/{esm → dist}/types/domain/Call.d.ts +0 -0
  701. /package/{esm → dist}/types/domain/Call.d.ts.map +0 -0
  702. /package/{esm → dist}/types/domain/CallLog.d.ts +0 -0
  703. /package/{esm → dist}/types/domain/CallLog.d.ts.map +0 -0
  704. /package/{esm → dist}/types/domain/CallSession.d.ts +0 -0
  705. /package/{esm → dist}/types/domain/CallSession.d.ts.map +0 -0
  706. /package/{esm → dist}/types/domain/CallerID.d.ts +0 -0
  707. /package/{esm → dist}/types/domain/CallerID.d.ts.map +0 -0
  708. /package/{esm → dist}/types/domain/ChatMessage.d.ts +0 -0
  709. /package/{esm → dist}/types/domain/ChatMessage.d.ts.map +0 -0
  710. /package/{esm → dist}/types/domain/ChatRoom.d.ts +0 -0
  711. /package/{esm → dist}/types/domain/ChatRoom.d.ts.map +0 -0
  712. /package/{esm → dist}/types/domain/Country.d.ts +0 -0
  713. /package/{esm → dist}/types/domain/Country.d.ts.map +0 -0
  714. /package/{esm → dist}/types/domain/Device/DebugDevice.d.ts +0 -0
  715. /package/{esm → dist}/types/domain/Device/DebugDevice.d.ts.map +0 -0
  716. /package/{esm → dist}/types/domain/Device/Device.d.ts +0 -0
  717. /package/{esm → dist}/types/domain/Device/Device.d.ts.map +0 -0
  718. /package/{esm → dist}/types/domain/DirectorySource.d.ts +0 -0
  719. /package/{esm → dist}/types/domain/DirectorySource.d.ts.map +0 -0
  720. /package/{esm → dist}/types/domain/ExternalApp.d.ts +0 -0
  721. /package/{esm → dist}/types/domain/ExternalApp.d.ts.map +0 -0
  722. /package/{esm → dist}/types/domain/Features.d.ts +0 -0
  723. /package/{esm → dist}/types/domain/Features.d.ts.map +0 -0
  724. /package/{esm → dist}/types/domain/ForwardOption.d.ts +0 -0
  725. /package/{esm → dist}/types/domain/ForwardOption.d.ts.map +0 -0
  726. /package/{esm → dist}/types/domain/Incall.d.ts +0 -0
  727. /package/{esm → dist}/types/domain/Incall.d.ts.map +0 -0
  728. /package/{esm → dist}/types/domain/IndirectTransfer.d.ts +0 -0
  729. /package/{esm → dist}/types/domain/IndirectTransfer.d.ts.map +0 -0
  730. /package/{esm → dist}/types/domain/Line.d.ts +0 -0
  731. /package/{esm → dist}/types/domain/Line.d.ts.map +0 -0
  732. /package/{esm → dist}/types/domain/Meeting.d.ts +0 -0
  733. /package/{esm → dist}/types/domain/Meeting.d.ts.map +0 -0
  734. /package/{esm → dist}/types/domain/MeetingAuthorization.d.ts +0 -0
  735. /package/{esm → dist}/types/domain/MeetingAuthorization.d.ts.map +0 -0
  736. /package/{esm → dist}/types/domain/MeetingStatus.d.ts +0 -0
  737. /package/{esm → dist}/types/domain/MeetingStatus.d.ts.map +0 -0
  738. /package/{esm → dist}/types/domain/NotificationOptions.d.ts +0 -0
  739. /package/{esm → dist}/types/domain/NotificationOptions.d.ts.map +0 -0
  740. /package/{esm → dist}/types/domain/Phone/CTIPhone.d.ts +0 -0
  741. /package/{esm → dist}/types/domain/Phone/CTIPhone.d.ts.map +0 -0
  742. /package/{esm → dist}/types/domain/Phone/Phone.d.ts +0 -0
  743. /package/{esm → dist}/types/domain/Phone/Phone.d.ts.map +0 -0
  744. /package/{esm → dist}/types/domain/Phone/WebRTCPhone.d.ts +0 -0
  745. /package/{esm → dist}/types/domain/Phone/WebRTCPhone.d.ts.map +0 -0
  746. /package/{esm → dist}/types/domain/Profile.d.ts +0 -0
  747. /package/{esm → dist}/types/domain/Profile.d.ts.map +0 -0
  748. /package/{esm → dist}/types/domain/Recording.d.ts +0 -0
  749. /package/{esm → dist}/types/domain/Recording.d.ts.map +0 -0
  750. /package/{esm → dist}/types/domain/Relocation.d.ts +0 -0
  751. /package/{esm → dist}/types/domain/Relocation.d.ts.map +0 -0
  752. /package/{esm → dist}/types/domain/Room.d.ts +0 -0
  753. /package/{esm → dist}/types/domain/Room.d.ts.map +0 -0
  754. /package/{esm → dist}/types/domain/SFUNotAvailableError.d.ts +0 -0
  755. /package/{esm → dist}/types/domain/SFUNotAvailableError.d.ts.map +0 -0
  756. /package/{esm → dist}/types/domain/ServerError.d.ts +0 -0
  757. /package/{esm → dist}/types/domain/ServerError.d.ts.map +0 -0
  758. /package/{esm → dist}/types/domain/Session.d.ts +0 -0
  759. /package/{esm → dist}/types/domain/Session.d.ts.map +0 -0
  760. /package/{esm → dist}/types/domain/SipLine.d.ts +0 -0
  761. /package/{esm → dist}/types/domain/SipLine.d.ts.map +0 -0
  762. /package/{esm → dist}/types/domain/Subscription.d.ts +0 -0
  763. /package/{esm → dist}/types/domain/Subscription.d.ts.map +0 -0
  764. /package/{esm → dist}/types/domain/SwitchboardCall.d.ts +0 -0
  765. /package/{esm → dist}/types/domain/SwitchboardCall.d.ts.map +0 -0
  766. /package/{esm → dist}/types/domain/Voicemail.d.ts +0 -0
  767. /package/{esm → dist}/types/domain/Voicemail.d.ts.map +0 -0
  768. /package/{esm → dist}/types/domain/__tests__/Agent.test.d.ts +0 -0
  769. /package/{esm → dist}/types/domain/__tests__/Agent.test.d.ts.map +0 -0
  770. /package/{esm → dist}/types/domain/__tests__/Call.test.d.ts +0 -0
  771. /package/{esm → dist}/types/domain/__tests__/Call.test.d.ts.map +0 -0
  772. /package/{esm → dist}/types/domain/__tests__/CallLog.test.d.ts +0 -0
  773. /package/{esm → dist}/types/domain/__tests__/CallLog.test.d.ts.map +0 -0
  774. /package/{esm → dist}/types/domain/__tests__/CallSession.test.d.ts +0 -0
  775. /package/{esm → dist}/types/domain/__tests__/CallSession.test.d.ts.map +0 -0
  776. /package/{esm → dist}/types/domain/__tests__/Contact.test.d.ts +0 -0
  777. /package/{esm → dist}/types/domain/__tests__/Contact.test.d.ts.map +0 -0
  778. /package/{esm → dist}/types/domain/__tests__/IndirectTransfer.test.d.ts +0 -0
  779. /package/{esm → dist}/types/domain/__tests__/IndirectTransfer.test.d.ts.map +0 -0
  780. /package/{esm → dist}/types/domain/__tests__/Line.test.d.ts +0 -0
  781. /package/{esm → dist}/types/domain/__tests__/Line.test.d.ts.map +0 -0
  782. /package/{esm → dist}/types/domain/__tests__/Meeting.test.d.ts +0 -0
  783. /package/{esm → dist}/types/domain/__tests__/Meeting.test.d.ts.map +0 -0
  784. /package/{esm → dist}/types/domain/__tests__/MeetingAuthorization.test.d.ts +0 -0
  785. /package/{esm → dist}/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +0 -0
  786. /package/{esm → dist}/types/domain/__tests__/Profile.test.d.ts +0 -0
  787. /package/{esm → dist}/types/domain/__tests__/Profile.test.d.ts.map +0 -0
  788. /package/{esm → dist}/types/domain/__tests__/Room.test.d.ts +0 -0
  789. /package/{esm → dist}/types/domain/__tests__/Room.test.d.ts.map +0 -0
  790. /package/{esm → dist}/types/domain/__tests__/Session.test.d.ts +0 -0
  791. /package/{esm → dist}/types/domain/__tests__/Session.test.d.ts.map +0 -0
  792. /package/{esm → dist}/types/domain/__tests__/SipLine.test.d.ts +0 -0
  793. /package/{esm → dist}/types/domain/__tests__/SipLine.test.d.ts.map +0 -0
  794. /package/{esm → dist}/types/domain/__tests__/Voicemail.test.d.ts +0 -0
  795. /package/{esm → dist}/types/domain/__tests__/Voicemail.test.d.ts.map +0 -0
  796. /package/{esm → dist}/types/domain/types.d.ts +0 -0
  797. /package/{esm → dist}/types/domain/types.d.ts.map +0 -0
  798. /package/{esm → dist}/types/lib/WazoSessionDescriptionHandler.d.ts +0 -0
  799. /package/{esm → dist}/types/lib/WazoSessionDescriptionHandler.d.ts.map +0 -0
  800. /package/{esm → dist}/types/pubkey.d.ts +0 -0
  801. /package/{esm → dist}/types/pubkey.d.ts.map +0 -0
  802. /package/{esm → dist}/types/service/CallApi.d.ts +0 -0
  803. /package/{esm → dist}/types/service/CallApi.d.ts.map +0 -0
  804. /package/{esm → dist}/types/service/IssueReporter.d.ts +0 -0
  805. /package/{esm → dist}/types/service/IssueReporter.d.ts.map +0 -0
  806. /package/{esm → dist}/types/service/__tests__/IssueReporter.test.d.ts +0 -0
  807. /package/{esm → dist}/types/service/__tests__/IssueReporter.test.d.ts.map +0 -0
  808. /package/{esm → dist}/types/simple/Auth.d.ts +0 -0
  809. /package/{esm → dist}/types/simple/Auth.d.ts.map +0 -0
  810. /package/{esm → dist}/types/simple/Configuration.d.ts +0 -0
  811. /package/{esm → dist}/types/simple/Configuration.d.ts.map +0 -0
  812. /package/{esm → dist}/types/simple/Directory.d.ts +0 -0
  813. /package/{esm → dist}/types/simple/Directory.d.ts.map +0 -0
  814. /package/{esm → dist}/types/simple/Phone.d.ts +0 -0
  815. /package/{esm → dist}/types/simple/Phone.d.ts.map +0 -0
  816. /package/{esm → dist}/types/simple/Websocket.d.ts +0 -0
  817. /package/{esm → dist}/types/simple/Websocket.d.ts.map +0 -0
  818. /package/{esm → dist}/types/simple/__tests__/Auth.test.d.ts +0 -0
  819. /package/{esm → dist}/types/simple/__tests__/Auth.test.d.ts.map +0 -0
  820. /package/{esm → dist}/types/simple/index.d.ts.map +0 -0
  821. /package/{esm → dist}/types/simple/room/LocalParticipant.d.ts +0 -0
  822. /package/{esm → dist}/types/simple/room/LocalParticipant.d.ts.map +0 -0
  823. /package/{esm → dist}/types/simple/room/Participant.d.ts +0 -0
  824. /package/{esm → dist}/types/simple/room/Participant.d.ts.map +0 -0
  825. /package/{esm → dist}/types/simple/room/RemoteParticipant.d.ts +0 -0
  826. /package/{esm → dist}/types/simple/room/RemoteParticipant.d.ts.map +0 -0
  827. /package/{esm → dist}/types/simple/room/Room.d.ts +0 -0
  828. /package/{esm → dist}/types/simple/room/Room.d.ts.map +0 -0
  829. /package/{esm → dist}/types/simple/room/SipRoom.d.ts +0 -0
  830. /package/{esm → dist}/types/simple/room/SipRoom.d.ts.map +0 -0
  831. /package/{esm → dist}/types/simple/room/Stream.d.ts +0 -0
  832. /package/{esm → dist}/types/simple/room/Stream.d.ts.map +0 -0
  833. /package/{esm → dist}/types/simple/room/__tests__/Participant.test.d.ts +0 -0
  834. /package/{esm → dist}/types/simple/room/__tests__/Participant.test.d.ts.map +0 -0
  835. /package/{esm → dist}/types/simple/room/__tests__/RemoteParticipant.test.d.ts +0 -0
  836. /package/{esm → dist}/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +0 -0
  837. /package/{esm → dist}/types/simple/utils.d.ts +0 -0
  838. /package/{esm → dist}/types/simple/utils.d.ts.map +0 -0
  839. /package/{esm → dist}/types/types/WebSocketMessage.d.ts +0 -0
  840. /package/{esm → dist}/types/types/WebSocketMessage.d.ts.map +0 -0
  841. /package/{esm → dist}/types/utils/Emitter.d.ts +0 -0
  842. /package/{esm → dist}/types/utils/Emitter.d.ts.map +0 -0
  843. /package/{esm → dist}/types/utils/Heartbeat.d.ts +0 -0
  844. /package/{esm → dist}/types/utils/Heartbeat.d.ts.map +0 -0
  845. /package/{esm → dist}/types/utils/PhoneNumberUtil.d.ts +0 -0
  846. /package/{esm → dist}/types/utils/PhoneNumberUtil.d.ts.map +0 -0
  847. /package/{esm → dist}/types/utils/__tests__/Heartbeat.test.d.ts +0 -0
  848. /package/{esm → dist}/types/utils/__tests__/Heartbeat.test.d.ts.map +0 -0
  849. /package/{esm → dist}/types/utils/__tests__/PhoneNumberUtil.test.d.ts +0 -0
  850. /package/{esm → dist}/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +0 -0
  851. /package/{esm → dist}/types/utils/__tests__/api-requester.test.d.ts +0 -0
  852. /package/{esm → dist}/types/utils/__tests__/api-requester.test.d.ts.map +0 -0
  853. /package/{esm → dist}/types/utils/__tests__/array.test.d.ts +0 -0
  854. /package/{esm → dist}/types/utils/__tests__/array.test.d.ts.map +0 -0
  855. /package/{esm → dist}/types/utils/__tests__/compare-version.test.d.ts +0 -0
  856. /package/{esm → dist}/types/utils/__tests__/compare-version.test.d.ts.map +0 -0
  857. /package/{esm → dist}/types/utils/__tests__/object.test.d.ts +0 -0
  858. /package/{esm → dist}/types/utils/__tests__/object.test.d.ts.map +0 -0
  859. /package/{esm → dist}/types/utils/__tests__/sdp.test.d.ts +0 -0
  860. /package/{esm → dist}/types/utils/__tests__/sdp.test.d.ts.map +0 -0
  861. /package/{esm → dist}/types/utils/__tests__/string.test.d.ts +0 -0
  862. /package/{esm → dist}/types/utils/__tests__/string.test.d.ts.map +0 -0
  863. /package/{esm → dist}/types/utils/api-requester.d.ts +0 -0
  864. /package/{esm → dist}/types/utils/array.d.ts +0 -0
  865. /package/{esm → dist}/types/utils/array.d.ts.map +0 -0
  866. /package/{esm → dist}/types/utils/compare-version.d.ts +0 -0
  867. /package/{esm → dist}/types/utils/compare-version.d.ts.map +0 -0
  868. /package/{esm → dist}/types/utils/isMobile.d.ts +0 -0
  869. /package/{esm → dist}/types/utils/isMobile.d.ts.map +0 -0
  870. /package/{esm → dist}/types/utils/new-from.d.ts +0 -0
  871. /package/{esm → dist}/types/utils/new-from.d.ts.map +0 -0
  872. /package/{esm → dist}/types/utils/object.d.ts +0 -0
  873. /package/{esm → dist}/types/utils/object.d.ts.map +0 -0
  874. /package/{esm → dist}/types/utils/once.d.ts +0 -0
  875. /package/{esm → dist}/types/utils/once.d.ts.map +0 -0
  876. /package/{esm → dist}/types/utils/sdp.d.ts +0 -0
  877. /package/{esm → dist}/types/utils/sdp.d.ts.map +0 -0
  878. /package/{esm → dist}/types/utils/string.d.ts +0 -0
  879. /package/{esm → dist}/types/utils/string.d.ts.map +0 -0
  880. /package/{esm → dist}/types/utils/update-from.d.ts +0 -0
  881. /package/{esm → dist}/types/utils/update-from.d.ts.map +0 -0
  882. /package/{esm → dist}/types/utils/webrtc.d.ts +0 -0
  883. /package/{esm → dist}/types/utils/webrtc.d.ts.map +0 -0
  884. /package/{esm → dist}/types/web-rtc-client.d.ts +0 -0
  885. /package/{esm → dist}/types/web-rtc-client.d.ts.map +0 -0
  886. /package/{esm → dist}/types/websocket-client.d.ts +0 -0
  887. /package/{esm → dist}/types/websocket-client.d.ts.map +0 -0
@@ -1,1492 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.events = exports.MESSAGE_TYPE_SIGNAL = exports.MESSAGE_TYPE_CHAT = exports.ON_EARLY_MEDIA = exports.ON_DISCONNECTED = exports.ON_SIGNAL = exports.ON_CHAT = exports.ON_NETWORK_STATS = exports.ON_MESSAGE_TRACK_UPDATED = exports.ON_CALL_ERROR = exports.ON_VIDEO_INPUT_CHANGE = exports.ON_PLAY_PROGRESS_SOUND = exports.ON_PLAY_HANGUP_SOUND = exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND = exports.ON_PLAY_RING_SOUND = exports.ON_TERMINATE_SOUND = exports.ON_SHARE_SCREEN_ENDED = exports.ON_SHARE_SCREEN_ENDING = exports.ON_SHARE_SCREEN_STARTED = exports.ON_REMOVE_STREAM = exports.ON_VIDEO_STREAM = exports.ON_AUDIO_STREAM = exports.ON_TRACK = exports.ON_REINVITE = exports.ON_MESSAGE = exports.ON_CALL_ENDING = exports.ON_CALL_ENDED = exports.ON_CALL_REJECTED = exports.ON_CALL_FAILED = exports.ON_CALL_CANCELED = exports.ON_CAMERA_RESUMED = exports.ON_CAMERA_DISABLED = exports.ON_CALL_UNHELD = exports.ON_CALL_HELD = exports.ON_CALL_RESUMED = exports.ON_CALL_UNMUTED = exports.ON_CALL_MUTED = exports.ON_CALL_OUTGOING = exports.ON_CALL_INCOMING = exports.ON_CALL_ANSWERED = exports.ON_CALL_ACCEPTED = exports.ON_PROGRESS = exports.ON_UNREGISTERED = exports.ON_REGISTERED = exports.ON_USER_AGENT = void 0;
16
- const session_state_1 = require("sip.js/lib/api/session-state");
17
- const api_1 = require("sip.js/lib/api");
18
- const CallSession_1 = __importDefault(require("../CallSession"));
19
- const Emitter_1 = __importDefault(require("../../utils/Emitter"));
20
- const IssueReporter_1 = __importDefault(require("../../service/IssueReporter"));
21
- exports.ON_USER_AGENT = 'onUserAgent';
22
- exports.ON_REGISTERED = 'onRegistered';
23
- exports.ON_UNREGISTERED = 'onUnRegistered';
24
- exports.ON_PROGRESS = 'onProgress';
25
- exports.ON_CALL_ACCEPTED = 'onCallAccepted';
26
- exports.ON_CALL_ANSWERED = 'onCallAnswered';
27
- exports.ON_CALL_INCOMING = 'onCallIncoming';
28
- exports.ON_CALL_OUTGOING = 'onCallOutgoing';
29
- exports.ON_CALL_MUTED = 'onCallMuted';
30
- exports.ON_CALL_UNMUTED = 'onCallUnmuted';
31
- exports.ON_CALL_RESUMED = 'onCallResumed';
32
- exports.ON_CALL_HELD = 'onCallHeld';
33
- exports.ON_CALL_UNHELD = 'onCallUnHeld';
34
- exports.ON_CAMERA_DISABLED = 'onCameraDisabled';
35
- exports.ON_CAMERA_RESUMED = 'onCameraResumed';
36
- exports.ON_CALL_CANCELED = 'onCallCanceled';
37
- exports.ON_CALL_FAILED = 'onCallFailed';
38
- exports.ON_CALL_REJECTED = 'onCallRejected';
39
- exports.ON_CALL_ENDED = 'onCallEnded';
40
- exports.ON_CALL_ENDING = 'onCallEnding';
41
- exports.ON_MESSAGE = 'onMessage';
42
- exports.ON_REINVITE = 'reinvite';
43
- exports.ON_TRACK = 'onTrack';
44
- exports.ON_AUDIO_STREAM = 'onAudioStream';
45
- exports.ON_VIDEO_STREAM = 'onVideoStream';
46
- exports.ON_REMOVE_STREAM = 'onRemoveStream';
47
- exports.ON_SHARE_SCREEN_STARTED = 'onScreenShareStarted';
48
- exports.ON_SHARE_SCREEN_ENDING = 'onScreenShareEnding';
49
- exports.ON_SHARE_SCREEN_ENDED = 'onScreenShareEnded';
50
- exports.ON_TERMINATE_SOUND = 'terminateSound';
51
- exports.ON_PLAY_RING_SOUND = 'playRingingSound';
52
- exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND = 'playInboundCallSignalSound';
53
- exports.ON_PLAY_HANGUP_SOUND = 'playHangupSound';
54
- exports.ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
55
- exports.ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
56
- exports.ON_CALL_ERROR = 'onCallError';
57
- exports.ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
58
- exports.ON_NETWORK_STATS = 'onNetworkStats';
59
- exports.ON_CHAT = 'phone/ON_CHAT';
60
- exports.ON_SIGNAL = 'phone/ON_SIGNAL';
61
- exports.ON_DISCONNECTED = 'onDisconnected';
62
- exports.ON_EARLY_MEDIA = 'onEarlyMedia';
63
- exports.MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
64
- exports.MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
65
- exports.events = [exports.ON_USER_AGENT, exports.ON_REGISTERED, exports.ON_UNREGISTERED, exports.ON_PROGRESS, exports.ON_CALL_ACCEPTED, exports.ON_CALL_ANSWERED, exports.ON_CALL_INCOMING, exports.ON_CALL_OUTGOING, exports.ON_CALL_MUTED, exports.ON_CALL_UNMUTED, exports.ON_CALL_RESUMED, exports.ON_CALL_HELD, exports.ON_CALL_UNHELD, exports.ON_CAMERA_DISABLED, exports.ON_CALL_FAILED, exports.ON_CALL_ENDED, exports.ON_CALL_REJECTED, exports.ON_MESSAGE, exports.ON_REINVITE, exports.ON_TRACK, exports.ON_AUDIO_STREAM, exports.ON_VIDEO_STREAM, exports.ON_REMOVE_STREAM, exports.ON_SHARE_SCREEN_ENDED, exports.ON_TERMINATE_SOUND, exports.ON_PLAY_RING_SOUND, exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, exports.ON_PLAY_HANGUP_SOUND, exports.ON_PLAY_PROGRESS_SOUND, exports.ON_VIDEO_INPUT_CHANGE, exports.ON_SHARE_SCREEN_STARTED, exports.ON_CALL_ERROR, exports.ON_CHAT, exports.ON_SIGNAL, exports.ON_NETWORK_STATS, exports.ON_DISCONNECTED, exports.ON_EARLY_MEDIA];
66
- const logger = IssueReporter_1.default.loggerFor('webrtc-phone');
67
- class WebRTCPhone extends Emitter_1.default {
68
- constructor(client, audioOutputDeviceId, allowVideo = false, audioRingDeviceId) {
69
- super();
70
- this.client = client;
71
- this.allowVideo = allowVideo;
72
- this.callSessions = {};
73
- this.audioOutputDeviceId = audioOutputDeviceId;
74
- this.audioRingDeviceId = audioRingDeviceId || audioOutputDeviceId;
75
- this.audioOutputVolume = 1;
76
- this.audioRingVolume = 1;
77
- this.incomingSessions = [];
78
- this.ringingEnabled = true;
79
- this.shouldSendReinvite = false;
80
- this.bindClientEvents();
81
- this.acceptedSessions = {};
82
- this.rejectedSessions = {};
83
- this.ignoredSessions = {};
84
- }
85
- register() {
86
- logger.info('WebRTC register', { client: !!this.client });
87
- if (!this.client) {
88
- return Promise.resolve();
89
- }
90
- return this.client.register().then(() => {
91
- logger.info('WebRTC register, registered');
92
- return this.bindClientEvents();
93
- }).catch(error => {
94
- // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
95
- console.error('register error', error, error.message, error.stack);
96
- logger.error('WebRTC register error', {
97
- message: error.message,
98
- stack: error.stack,
99
- });
100
- });
101
- }
102
- unregister() {
103
- if (!this.client || !this.client.isRegistered()) {
104
- return null;
105
- }
106
- return this.client.unregister();
107
- }
108
- stop() {
109
- if (!this.client) {
110
- return;
111
- }
112
- logger.info('WebRTC phone stop');
113
- this.client.stop();
114
- }
115
- removeIncomingSessions(id) {
116
- this.incomingSessions = this.incomingSessions.filter(sessionId => sessionId !== id);
117
- }
118
- isWebRTC() {
119
- return true;
120
- }
121
- sendReinvite(callSession_1) {
122
- return __awaiter(this, arguments, void 0, function* (callSession, constraints = null, conference = false, audioOnly = false, iceRestart = false) {
123
- const sipSession = this.findSipSession(callSession);
124
- logger.info('WebRTC phone - send reinvite', {
125
- sessionId: this.getSipSessionId(sipSession),
126
- constraints,
127
- audioOnly,
128
- conference,
129
- iceRestart,
130
- });
131
- if (!sipSession) {
132
- return;
133
- }
134
- const shouldScreenShare = constraints === null || constraints === void 0 ? void 0 : constraints.screen;
135
- const isUpgrade = shouldScreenShare || (constraints === null || constraints === void 0 ? void 0 : constraints.video);
136
- // Downgrade
137
- if (constraints && !isUpgrade) {
138
- // No reinvite needed
139
- this._downgradeToAudio(callSession);
140
- return;
141
- }
142
- if (isUpgrade) {
143
- const shouldReinvite = yield this._upgradeToVideo(callSession, constraints, conference);
144
- if (!shouldReinvite) {
145
- return;
146
- }
147
- }
148
- return this.client.reinvite(sipSession, constraints, conference, audioOnly, iceRestart);
149
- });
150
- }
151
- getUserAgent() {
152
- var _a, _b;
153
- return ((_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.userAgentString) || 'webrtc-phone';
154
- }
155
- startHeartbeat() {
156
- logger.info('WebRTC phone - start heartbeat', {
157
- client: !!this.client,
158
- hasHeartbeat: this.client.hasHeartbeat(),
159
- });
160
- if (!this.client || this.client.hasHeartbeat()) {
161
- return;
162
- }
163
- this.client.startHeartbeat();
164
- }
165
- stopHeartbeat() {
166
- logger.info('WebRTC phone - stopHeartbeat', {
167
- client: !!this.client,
168
- });
169
- if (!this.client) {
170
- return;
171
- }
172
- this.client.stopHeartbeat();
173
- }
174
- setOnHeartbeatTimeout(cb) {
175
- this.client.setOnHeartbeatTimeout(cb);
176
- }
177
- setOnHeartbeatCallback(cb) {
178
- this.client.setOnHeartbeatCallback(cb);
179
- }
180
- reconnect() {
181
- logger.info('WebRTC phone - reconnect', {
182
- client: !!this.client,
183
- });
184
- if (!this.client) {
185
- return;
186
- }
187
- this.client.attemptReconnection();
188
- }
189
- getOptions() {
190
- return {
191
- accept: true,
192
- decline: true,
193
- mute: true,
194
- hold: true,
195
- transfer: true,
196
- sendKey: true,
197
- addParticipant: false,
198
- record: true,
199
- merge: true,
200
- };
201
- }
202
- onConnect() {
203
- if (!this.client) {
204
- return Promise.reject(new Error('No webrtc client'));
205
- }
206
- return this.client.onConnect();
207
- }
208
- onDisconnect() {
209
- if (!this.client) {
210
- return Promise.reject(new Error('No webrtc client'));
211
- }
212
- return this.client.onDisconnect();
213
- }
214
- _downgradeToAudio(callSession, withMessage = true) {
215
- const sipSession = this.findSipSession(callSession);
216
- if (!sipSession) {
217
- return false;
218
- }
219
- logger.info('Downgrade to audio', {
220
- id: callSession ? callSession.getId() : null,
221
- withMessage,
222
- });
223
- this.client.downgradeToAudio(sipSession);
224
- if (callSession) {
225
- callSession.cameraEnabled = false;
226
- this._updateCallSession(callSession);
227
- }
228
- if (withMessage) {
229
- this._sendReinviteMessage(callSession, false);
230
- }
231
- return true;
232
- }
233
- // Returns true if we need to send a re-INVITE request
234
- _upgradeToVideo(callSession, constraints, isConference) {
235
- return __awaiter(this, void 0, void 0, function* () {
236
- const sipSession = this.findSipSession(callSession);
237
- if (!sipSession) {
238
- return Promise.resolve(false);
239
- }
240
- logger.info('Upgrade to video', {
241
- id: callSession ? callSession.getId() : null,
242
- constraints,
243
- isConference,
244
- });
245
- const shouldScreenShare = constraints && !!constraints.screen;
246
- const desktop = constraints && constraints.desktop;
247
- const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
248
- const wasAudioOnly = options === null || options === void 0 ? void 0 : options.audioOnly;
249
- const newStream = yield this.client.upgradeToVideo(sipSession, constraints, isConference);
250
- if (callSession) {
251
- callSession.cameraEnabled = true;
252
- this._updateCallSession(callSession);
253
- }
254
- // If no stream is returned, it means we have to reinvite
255
- if (!newStream) {
256
- return true;
257
- }
258
- this._sendReinviteMessage(callSession, true);
259
- if (shouldScreenShare) {
260
- this._onScreenSharing(newStream, sipSession, callSession, false, desktop);
261
- }
262
- // We have to reinvite to change the direction on the bundle when upgrading from an audioOnly conference
263
- if (isConference && wasAudioOnly) {
264
- return true;
265
- }
266
- // No reinvite needed here
267
- return false;
268
- });
269
- }
270
- _sendReinviteMessage(callSession, isUpgrade) {
271
- const sipSession = this.findSipSession(callSession);
272
- logger.info('Sending reinvite message', {
273
- id: callSession ? callSession.getId() : null,
274
- isUpgrade,
275
- });
276
- // Have to send the message after a delay due to latency to update the remote peer
277
- setTimeout(() => {
278
- this.sendMessage(sipSession, JSON.stringify({
279
- type: exports.MESSAGE_TYPE_SIGNAL,
280
- content: {
281
- type: exports.ON_MESSAGE_TRACK_UPDATED,
282
- update: isUpgrade ? 'upgrade' : 'downgrade',
283
- sipCallId: sipSession && this.getSipSessionId(sipSession),
284
- callId: callSession ? callSession.callId : null,
285
- number: callSession ? callSession.number : null,
286
- callerNumber: callSession ? callSession.callerNumber : null,
287
- },
288
- }));
289
- }, 2500);
290
- }
291
- _bindEvents(sipSession) {
292
- const sipSessionId = this.getSipSessionId(sipSession);
293
- if (sipSession instanceof api_1.Invitation) {
294
- // Monkey patch to know when canceled with the CANCEL message
295
- const onCancel = sipSession._onCancel.bind(sipSession);
296
- sipSession._onCancel = (message) => {
297
- logger.trace('on sip session canceled', {
298
- callId: message.callId,
299
- sipSessionId,
300
- });
301
- onCancel(message);
302
- const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
303
- const callSession = this._createCallSession(sipSession);
304
- if (sipSessionId) {
305
- delete this.callSessions[sipSessionId];
306
- }
307
- this.eventEmitter.emit(exports.ON_CALL_CANCELED, callSession, elsewhere);
308
- };
309
- }
310
- sipSession.stateChange.addListener((newState) => {
311
- switch (newState) {
312
- case session_state_1.SessionState.Terminating:
313
- logger.info('WebRTC phone - call terminating', {
314
- sipId: this.getSipSessionId(sipSession),
315
- });
316
- this.eventEmitter.emit(exports.ON_CALL_ENDING, this._createCallSession(sipSession));
317
- break;
318
- case session_state_1.SessionState.Terminated:
319
- {
320
- logger.info('WebRTC phone - call terminated', {
321
- sipId: this.getSipSessionId(sipSession),
322
- });
323
- // Should be called before `_onCallTerminated` or the callCount will not decrement...
324
- const callSession = this._createCallSession(sipSession);
325
- callSession.endTime = new Date();
326
- const wasCurrentSession = this._onCallTerminated(sipSession);
327
- return this.eventEmitter.emit(exports.ON_CALL_ENDED, callSession, wasCurrentSession);
328
- }
329
- default:
330
- break;
331
- }
332
- });
333
- if (!sipSession.sessionDescriptionHandler) {
334
- return;
335
- }
336
- // Video events
337
- const sdh = sipSession.sessionDescriptionHandler;
338
- const peerConnection = sdh.peerConnection;
339
- if (!peerConnection) {
340
- logger.info('null peer connection');
341
- return;
342
- }
343
- peerConnection.ontrack = (rawEvent) => {
344
- const event = rawEvent;
345
- const [stream] = event.streams;
346
- const kind = event && event.track && event.track.kind;
347
- logger.info('on track stream called on the peer connection', {
348
- callId: this.getSipSessionId(sipSession),
349
- streamId: stream ? stream.id : null,
350
- tracks: stream ? stream.getTracks() : null,
351
- kind,
352
- });
353
- if (kind === 'audio') {
354
- return this.eventEmitter.emit(exports.ON_AUDIO_STREAM, stream);
355
- }
356
- return this.eventEmitter.emit(exports.ON_VIDEO_STREAM, stream, event.track.id, event, sipSession);
357
- };
358
- peerConnection.onremovestream = (event) => {
359
- logger.info('on remove stream called on the peer connection', {
360
- id: event.stream.id,
361
- tracks: event.stream.getTracks(),
362
- });
363
- this.eventEmitter.emit(exports.ON_REMOVE_STREAM, event.stream);
364
- };
365
- }
366
- startScreenSharing(constraints, callSession) {
367
- return __awaiter(this, void 0, void 0, function* () {
368
- logger.info('WebRTC - start screen sharing', {
369
- constraints,
370
- id: callSession ? callSession.getId() : null,
371
- });
372
- const screenShareStream = yield this.client.getStreamFromConstraints(constraints);
373
- if (!screenShareStream) {
374
- throw new Error(`Can't create media stream for screensharing with: ${JSON.stringify(constraints)}`);
375
- }
376
- const screenTrack = screenShareStream.getVideoTracks()[0];
377
- const sipSession = this.currentSipSession;
378
- const pc = sipSession && this.client.getPeerConnection(this.getSipSessionId(sipSession));
379
- const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
380
- const localStream = sipSession && this.client.getLocalStream(this.getSipSessionId(sipSession));
381
- const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
382
- const hadVideo = !!videoTrack;
383
- // Stop local video tracks
384
- if (videoTrack && localStream) {
385
- videoTrack.enabled = false;
386
- videoTrack.stop();
387
- localStream.removeTrack(videoTrack);
388
- }
389
- if (localStream) {
390
- localStream.addTrack(screenTrack);
391
- }
392
- if (sender) {
393
- sender.replaceTrack(screenTrack);
394
- }
395
- this._onScreenSharing(screenShareStream, sipSession, callSession, hadVideo, constraints.desktop);
396
- return screenShareStream;
397
- });
398
- }
399
- stopScreenSharing() {
400
- return __awaiter(this, arguments, void 0, function* (restoreLocalStream = true, callSession) {
401
- if (!this.currentScreenShare) {
402
- return;
403
- }
404
- logger.info('WebRTC phone - stop screen sharing', {
405
- restoreLocalStream,
406
- });
407
- let reinvited = null;
408
- try {
409
- if (this.currentScreenShare.stream) {
410
- this.currentScreenShare.stream.getTracks()
411
- .filter((track) => track.enabled && track.kind === 'video')
412
- .forEach((track) => track.stop());
413
- }
414
- if (restoreLocalStream) {
415
- const targetCallSession = callSession || this.currentCallSession;
416
- const conference = this.isConference(targetCallSession);
417
- // When stopping screenshare and we had video before that, we have to re-upgrade
418
- // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
419
- // We have to downgrade to audio.
420
- const screenshareStopped = this.currentScreenShare.hadVideo;
421
- const constraints = {
422
- audio: false,
423
- video: screenshareStopped,
424
- };
425
- // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
426
- this._downgradeToAudio(targetCallSession, false);
427
- // Wait for the track to be removed, unless the video sender won't have a null track in `_upgradeToVideo`.
428
- yield new Promise(resolve => setTimeout(resolve, 500));
429
- reinvited = yield this.sendReinvite(targetCallSession, constraints, conference);
430
- }
431
- }
432
- catch (e) {
433
- console.warn(e);
434
- }
435
- const sipSession = this.currentSipSession;
436
- this.eventEmitter.emit(exports.ON_SHARE_SCREEN_ENDED, callSession && sipSession ? this._createCallSession(sipSession, callSession, {
437
- screensharing: false,
438
- }) : null);
439
- this.currentScreenShare = null;
440
- return reinvited;
441
- });
442
- }
443
- _onScreenSharing(screenStream, sipSession, callSession, hadVideo, desktop) {
444
- const screenTrack = screenStream.getVideoTracks()[0];
445
- const sipSessionId = this.getSipSessionId(sipSession);
446
- const pc = this.client.getPeerConnection(sipSessionId);
447
- const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
448
- logger.info('WebRTC phone - on screensharing', {
449
- hadVideo,
450
- id: this.getSipSessionId(sipSession),
451
- screenTrack,
452
- });
453
- if (screenTrack) {
454
- screenTrack.onended = () => {
455
- logger.info('WebRTC phone - on screenshare ended', {
456
- hadVideo,
457
- id: this.getSipSessionId(sipSession),
458
- screenTrack,
459
- });
460
- this.eventEmitter.emit(exports.ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
461
- };
462
- }
463
- this.currentScreenShare = {
464
- stream: screenStream,
465
- hadVideo,
466
- sender,
467
- sipSessionId,
468
- desktop,
469
- };
470
- this.client.setLocalMediaStream(this.getSipSessionId(sipSession), screenStream);
471
- this.eventEmitter.emit(exports.ON_SHARE_SCREEN_STARTED, this._createCallSession(sipSession, callSession, {
472
- screensharing: true,
473
- }), screenStream);
474
- }
475
- _onCallAccepted(sipSession, cameraEnabled) {
476
- logger.info('WebRTC phone - on call accepted', {
477
- sipId: this.getSipSessionId(sipSession),
478
- cameraEnabled,
479
- });
480
- const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
481
- if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
482
- logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
483
- sipId: this.getSipSessionId(sipSession),
484
- cameraEnabled,
485
- });
486
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
487
- }
488
- this.currentSipSession = sipSession;
489
- this.currentCallSession = callSession;
490
- this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'call accepted');
491
- const sipSessionId = this.getSipSessionId(sipSession);
492
- if (sipSessionId) {
493
- this.removeIncomingSessions(sipSessionId);
494
- }
495
- callSession.answerTime = new Date();
496
- this._updateCallSession(callSession);
497
- this.eventEmitter.emit(exports.ON_CALL_ACCEPTED, callSession, cameraEnabled);
498
- return callSession;
499
- }
500
- changeAudioDevice(id) {
501
- return __awaiter(this, void 0, void 0, function* () {
502
- logger.info('WebRTC phone - change audio device', {
503
- deviceId: id,
504
- });
505
- this.audioOutputDeviceId = id;
506
- return this.client.changeAudioOutputDevice(id);
507
- });
508
- }
509
- createAudioElementFor(sessionId) {
510
- return this.client.createAudioElementFor(sessionId);
511
- }
512
- changeRingDevice(id) {
513
- logger.info('WebRTC phone - changing ring device', {
514
- id,
515
- });
516
- this.audioRingDeviceId = id;
517
- }
518
- // volume is a value between 0 and 1
519
- changeAudioVolume(volume) {
520
- logger.info('WebRTC phone - changing audio volume', {
521
- volume,
522
- });
523
- this.audioOutputVolume = volume;
524
- this.client.changeAudioOutputVolume(volume);
525
- }
526
- // volume is a value between 0 and 1
527
- changeRingVolume(volume) {
528
- logger.info('WebRTC phone - changing ring volume', {
529
- volume,
530
- });
531
- this.audioRingVolume = volume;
532
- }
533
- changeAudioInputDevice(id, force) {
534
- logger.info('WebRTC phone - changeAudio input device', {
535
- deviceId: id,
536
- });
537
- return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
538
- }
539
- changeVideoInputDevice(id) {
540
- return __awaiter(this, void 0, void 0, function* () {
541
- logger.info('WebRTC phone - change video input device', {
542
- deviceId: id,
543
- });
544
- return this.client.changeVideoInputDevice(id, this.currentSipSession);
545
- });
546
- }
547
- changeSessionVideoInputDevice(id) {
548
- logger.info('WebRTC phone - change session video input device', {
549
- deviceId: id,
550
- });
551
- return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
552
- }
553
- _onCallTerminated(sipSession) {
554
- const sipSessionId = this.getSipSessionId(sipSession);
555
- logger.info('WebRTC phone - on call terminated', {
556
- sipId: this.getSipSessionId(sipSession),
557
- sipSessionId,
558
- ids: Object.keys(this.callSessions),
559
- });
560
- const callSession = this._createCallSession(sipSession);
561
- const isCurrentSession = this.isCurrentCallSipSession(callSession);
562
- const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
563
- // If the terminated call was an incoming call, we have to re-trigger if it's was the first incoming call
564
- // Otherwise, we have to re-trigger an incoming call event if another call is incoming
565
- const shouldRetrigger = isCurrentSession ? this.incomingSessions.length : isCurrentIncomingCall;
566
- // Terminate incoming sound only for the ringing call
567
- // (so another terminated call won't stop the incoming call sound)
568
- if (isCurrentIncomingCall) {
569
- setTimeout(() => {
570
- // Avoid race condition when the other is calling and hanging up immediately
571
- this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'call terminated');
572
- }, 5);
573
- }
574
- if (sipSessionId) {
575
- this.removeIncomingSessions(sipSessionId);
576
- delete this.callSessions[sipSessionId];
577
- }
578
- if (isCurrentSession) {
579
- this.currentSipSession = undefined;
580
- this.currentCallSession = undefined;
581
- }
582
- const hasIncomingCallSession = this.hasIncomingCallSession();
583
- // Re-trigger incoming call event for remaining incoming calls
584
- logger.info('WebRTC phone - check to re-trigger incoming call', {
585
- sipId: this.getSipSessionId(sipSession),
586
- shouldRetrigger,
587
- hasIncomingCallSession,
588
- });
589
- this.client.onCallEnded(sipSession);
590
- if (hasIncomingCallSession && shouldRetrigger) {
591
- const nextCallSession = this.getIncomingCallSession();
592
- // Avoid race condition
593
- setTimeout(() => {
594
- if (this.ringingEnabled) {
595
- if (!this.currentCallSession) {
596
- this.eventEmitter.emit(exports.ON_PLAY_RING_SOUND, this.audioRingDeviceId, this.audioRingVolume, nextCallSession);
597
- }
598
- else {
599
- this.eventEmitter.emit(exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, nextCallSession);
600
- }
601
- }
602
- this.eventEmitter.emit(exports.ON_CALL_INCOMING, nextCallSession, nextCallSession === null || nextCallSession === void 0 ? void 0 : nextCallSession.cameraEnabled);
603
- }, 100);
604
- }
605
- if (callSession.getId() in this.ignoredSessions) {
606
- return false;
607
- }
608
- // @ts-ignore: does not exist
609
- if (!sipSession.isCanceled) {
610
- setTimeout(() => {
611
- this.eventEmitter.emit(exports.ON_PLAY_HANGUP_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
612
- }, 10);
613
- }
614
- return isCurrentSession;
615
- }
616
- setActiveSipSession(callSession) {
617
- const sipSessionId = this.findSipSession(callSession);
618
- if (!sipSessionId) {
619
- return;
620
- }
621
- this.currentSipSession = sipSessionId;
622
- this.currentCallSession = callSession;
623
- }
624
- hasAnActiveCall() {
625
- return !!this.currentSipSession;
626
- }
627
- // /!\ In some case with react-native webrtc the session will have only one audio stream set
628
- // Maybe due to https://github.com/react-native-webrtc/react-native-webrtc/issues/401
629
- hasActiveRemoteVideoStream() {
630
- const sipSession = this.currentSipSession;
631
- if (!sipSession) {
632
- return false;
633
- }
634
- const sdh = sipSession.sessionDescriptionHandler;
635
- const peerConnection = sdh.peerConnection;
636
- const remoteStream = peerConnection.getRemoteStreams().find((stream) => !!stream.getVideoTracks().length);
637
- return remoteStream && remoteStream.getVideoTracks().some(track => !track.muted);
638
- }
639
- callCount() {
640
- return Object.keys(this.callSessions).length;
641
- }
642
- isCurrentCallSipSession(callSession) {
643
- if (!this.currentSipSession) {
644
- return false;
645
- }
646
- return this.currentSipSession && this.getSipSessionId(this.currentSipSession) === callSession.getId();
647
- }
648
- hasVideo(callSession) {
649
- return this.client.hasVideo(callSession.getId());
650
- }
651
- hasAVideoTrack(callSession) {
652
- return this.client.hasAVideoTrack(callSession.getId());
653
- }
654
- // Deprecated
655
- getLocalStreamForCall(callSession) {
656
- logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
657
- return this.getLocalStream(callSession);
658
- }
659
- // Deprecated
660
- getRemoteStreamForCall(callSession) {
661
- logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
662
- return this.getRemoteVideoStream(callSession);
663
- }
664
- getRemoteStreamsForCall(callSession) {
665
- logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
666
- return this.getRemoteStream(callSession);
667
- }
668
- accept(callSession, cameraEnabled) {
669
- logger.info('WebRTC phone - accept call', {
670
- id: callSession ? callSession.getId() : 'n/a',
671
- cameraEnabled,
672
- });
673
- if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
674
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
675
- }
676
- if (!callSession) {
677
- logger.warn('no CallSession to accept.');
678
- return Promise.resolve(null);
679
- }
680
- const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
681
- if (sipSessionId && !(sipSessionId in this.callSessions)) {
682
- logger.warn('Call session already ended or not found, can\'t accept it.', {
683
- sipSessionId,
684
- });
685
- return Promise.resolve(null);
686
- }
687
- if (callSession.getId() in this.acceptedSessions) {
688
- logger.warn('CallSession already accepted.', {
689
- id: callSession ? callSession.getId() : 'n/a',
690
- });
691
- return Promise.resolve(callSession.sipCallId);
692
- }
693
- this.shouldSendReinvite = false;
694
- callSession.answerTime = new Date();
695
- this._updateCallSession(callSession);
696
- this.acceptedSessions[callSession.getId()] = true;
697
- this.eventEmitter.emit(exports.ON_CALL_ANSWERED, callSession);
698
- const sipSession = this.client.getSipSession(callSession.getId());
699
- if (sipSession) {
700
- logger.info('accept call, session found', { sipId: this.getSipSessionId(sipSession) });
701
- return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
702
- return callSession.sipCallId;
703
- }).catch(e => {
704
- logger.error(e);
705
- this.endCurrentCall(callSession);
706
- throw e;
707
- });
708
- }
709
- const error = 'No CallSession found to accept.';
710
- logger.warn(error, {
711
- id: callSession ? callSession.getId() : 'n/a',
712
- ids: this.client.getSipSessionIds(),
713
- });
714
- if (callSession) {
715
- this.eventEmitter.emit(exports.ON_CALL_ERROR, new Error(error), callSession);
716
- }
717
- return Promise.resolve(null);
718
- }
719
- isAccepted(callSession) {
720
- return callSession && callSession.getId() in this.acceptedSessions;
721
- }
722
- reject(callSession) {
723
- return __awaiter(this, void 0, void 0, function* () {
724
- logger.info('reject WebRTC called', {
725
- id: callSession.getId(),
726
- });
727
- this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'call rejected locally');
728
- if (!callSession || callSession.getId() in this.rejectedSessions) {
729
- return;
730
- }
731
- this.shouldSendReinvite = false;
732
- this.rejectedSessions[callSession.getId()] = true;
733
- const sipSession = this.findSipSession(callSession);
734
- if (sipSession) {
735
- logger.info('WebRTC rejecting', {
736
- sipId: this.getSipSessionId(sipSession),
737
- });
738
- this.client.hangup(sipSession);
739
- }
740
- });
741
- }
742
- ignore(callSession) {
743
- return __awaiter(this, void 0, void 0, function* () {
744
- logger.info('WebRTC ignore', {
745
- id: callSession.getId(),
746
- });
747
- // kill the ring
748
- this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'ignoring call');
749
- this.ignoredSessions[callSession.getId()] = true;
750
- callSession.ignore();
751
- });
752
- }
753
- atxfer(callSession) {
754
- const sipSession = this.findSipSession(callSession);
755
- if (sipSession) {
756
- logger.info('WebRTC atxfer', {
757
- sipId: this.getSipSessionId(sipSession),
758
- });
759
- return this.client.atxfer(sipSession);
760
- }
761
- }
762
- hold(callSession, withEvent = true) {
763
- logger.info('WebRTC hold', {
764
- id: callSession.getId(),
765
- });
766
- const sipSession = this.findSipSession(callSession);
767
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
768
- }
769
- // @Deprecated
770
- unhold(callSession, withEvent = true) {
771
- console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
772
- return this.resume(callSession, withEvent);
773
- }
774
- resume(callSession, withEvent = true) {
775
- logger.info('WebRTC resume called', {
776
- id: callSession ? callSession.getId() : null,
777
- });
778
- const sipSession = this.findSipSession(callSession);
779
- if (!sipSession) {
780
- return new Promise((resolve, reject) => reject(new Error('No session to resume')));
781
- }
782
- logger.info('WebRTC resuming', {
783
- sipId: this.getSipSessionId(sipSession),
784
- });
785
- // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
786
- if (this.currentSipSession && this.getSipSessionId(this.currentSipSession) !== this.getSipSessionId(sipSession)) {
787
- logger.info('WebRTC hold call after resume', {
788
- id: this.getSipSessionId(this.currentSipSession),
789
- });
790
- this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
791
- }
792
- const promise = this.unholdSipSession(sipSession, callSession, withEvent);
793
- this.currentSipSession = sipSession;
794
- if (callSession) {
795
- this.currentCallSession = callSession;
796
- }
797
- return promise;
798
- }
799
- holdSipSession(sipSession_1, callSession_1) {
800
- return __awaiter(this, arguments, void 0, function* (sipSession, callSession, withEvent = true) {
801
- if (!sipSession) {
802
- return new Promise((resolve, reject) => reject(new Error('No session to hold')));
803
- }
804
- const sessionId = this.getSipSessionId(sipSession);
805
- const hasVideo = this.client.hasLocalVideo(sessionId);
806
- logger.info('WebRTC hold sip session', {
807
- sipId: this.getSipSessionId(sipSession),
808
- hasVideo,
809
- });
810
- // Stop screenshare if needed
811
- if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
812
- this.lastScreenShare = this.currentScreenShare;
813
- yield this.stopScreenSharing(false, callSession);
814
- }
815
- // Downgrade to audio if needed
816
- if (hasVideo) {
817
- yield this.client.downgradeToAudio(sipSession);
818
- }
819
- const isConference = !!callSession && callSession.isConference();
820
- const promise = this.client.hold(sipSession, isConference, hasVideo);
821
- if (withEvent) {
822
- this.eventEmitter.emit(exports.ON_CALL_HELD, this._createCallSession(sipSession, callSession));
823
- }
824
- return promise;
825
- });
826
- }
827
- unholdSipSession(sipSession_1, callSession_1) {
828
- return __awaiter(this, arguments, void 0, function* (sipSession, callSession, withEvent = true) {
829
- if (!sipSession) {
830
- return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
831
- }
832
- const isConference = !!callSession && callSession.isConference();
833
- const sessionId = this.getSipSessionId(sipSession);
834
- logger.info('WebRTC unhold sip session', {
835
- sessionId,
836
- isConference,
837
- });
838
- const { hasVideo, } = this.client.getHeldSession(sessionId) || {};
839
- const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
840
- const wasDesktop = this.lastScreenShare && this.lastScreenShare.desktop;
841
- const promise = this.client.unhold(sipSession, isConference);
842
- if (hasVideo) {
843
- const constraints = {
844
- audio: false,
845
- video: true,
846
- screen: wasScreensharing,
847
- desktop: wasDesktop,
848
- };
849
- yield this.client.upgradeToVideo(sipSession, constraints, isConference);
850
- }
851
- const onScreenSharing = (stream) => {
852
- const hadVideo = this.lastScreenShare && this.lastScreenShare.hadVideo;
853
- if (stream) {
854
- this._onScreenSharing(stream, sipSession, callSession, hadVideo);
855
- }
856
- this.lastScreenShare = null;
857
- };
858
- if (withEvent) {
859
- // Calling webRtcClient.unhold will unmute the call; let's make sure the call session reflects that state
860
- if (callSession) {
861
- callSession.muted = false;
862
- }
863
- const updatedCallSession = this._createCallSession(sipSession, callSession);
864
- // Deprecated event
865
- this.eventEmitter.emit(exports.ON_CALL_UNHELD, updatedCallSession);
866
- this.eventEmitter.emit(exports.ON_CALL_RESUMED, updatedCallSession);
867
- }
868
- return promise.then(() => {
869
- const stream = callSession ? this.getLocalVideoStream(callSession) : null;
870
- if (wasScreensharing) {
871
- onScreenSharing(stream);
872
- }
873
- return stream;
874
- });
875
- });
876
- }
877
- mute(callSession, withEvent = true) {
878
- logger.info('WebRTC mute called', {
879
- id: callSession ? callSession.getId() : null,
880
- });
881
- const sipSession = this.findSipSession(callSession);
882
- if (!sipSession) {
883
- return;
884
- }
885
- logger.info('WebRTC muting', {
886
- sipId: this.getSipSessionId(sipSession),
887
- });
888
- this.client.mute(sipSession);
889
- const newCallSession = this._createCallSession(sipSession, callSession, {
890
- muted: true,
891
- });
892
- if (this.currentCallSession && newCallSession.is(this.currentCallSession)) {
893
- this.currentCallSession = newCallSession;
894
- }
895
- if (withEvent) {
896
- this.eventEmitter.emit(exports.ON_CALL_MUTED, newCallSession);
897
- }
898
- }
899
- unmute(callSession, withEvent = true) {
900
- logger.info('WebRTC unmute called', {
901
- id: callSession ? callSession.getId() : null,
902
- });
903
- const sipSession = this.findSipSession(callSession);
904
- if (!sipSession) {
905
- return;
906
- }
907
- logger.info('WebRTC unmuting', {
908
- sipId: this.getSipSessionId(sipSession),
909
- });
910
- this.client.unmute(sipSession);
911
- const newCallSession = this._createCallSession(sipSession, callSession, {
912
- muted: false,
913
- });
914
- if (this.currentCallSession && newCallSession.is(this.currentCallSession)) {
915
- this.currentCallSession = newCallSession;
916
- }
917
- if (withEvent) {
918
- this.eventEmitter.emit(exports.ON_CALL_UNMUTED, newCallSession);
919
- }
920
- }
921
- isAudioMuted(callSession) {
922
- const sipSession = this.findSipSession(callSession);
923
- if (!sipSession) {
924
- return true;
925
- }
926
- return this.client.isAudioMuted(sipSession);
927
- }
928
- turnCameraOn(callSession) {
929
- const sipSession = this.findSipSession(callSession);
930
- if (!sipSession) {
931
- return;
932
- }
933
- logger.info('WebRTC turn camera on', {
934
- sipId: this.getSipSessionId(sipSession),
935
- });
936
- this.client.toggleCameraOn(sipSession);
937
- this.eventEmitter.emit(exports.ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
938
- }
939
- turnCameraOff(callSession) {
940
- const sipSession = this.findSipSession(callSession);
941
- if (!sipSession) {
942
- return;
943
- }
944
- logger.info('WebRTC turn camera off', {
945
- sipId: this.getSipSessionId(sipSession),
946
- });
947
- this.client.toggleCameraOff(sipSession);
948
- this.eventEmitter.emit(exports.ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
949
- }
950
- sendKey(callSession, tone) {
951
- const sipSession = this.findSipSession(callSession);
952
- if (!sipSession) {
953
- return;
954
- }
955
- logger.info('WebRTC send key', {
956
- sipId: this.getSipSessionId(sipSession),
957
- tone,
958
- });
959
- this.client.sendDTMF(sipSession, tone);
960
- }
961
- // Should be async to match CTIPhone definition
962
- // @TODO: line is not used here
963
- makeCall(number_1, line_1, cameraEnabled_1) {
964
- return __awaiter(this, arguments, void 0, function* (number, line, cameraEnabled, audioOnly = false, conference = false, options = {}) {
965
- logger.info('make WebRTC call', {
966
- number,
967
- lineId: line ? line.id : null,
968
- cameraEnabled,
969
- audioOnly,
970
- conference,
971
- options,
972
- });
973
- if (!number) {
974
- return Promise.resolve(null);
975
- }
976
- if (!this.client.isRegistered()) {
977
- yield this.client.register();
978
- }
979
- if (this.currentSipSession) {
980
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
981
- logger.warn('Unable to hold current session when making another call', e);
982
- });
983
- }
984
- let sipSession;
985
- try {
986
- sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference, options);
987
- this._bindEvents(sipSession);
988
- }
989
- catch (error) {
990
- logger.warn('make WebRTC call, error', {
991
- message: error.message,
992
- stack: error.stack,
993
- });
994
- return Promise.resolve(null);
995
- }
996
- const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
997
- callSession.setIsConference(conference);
998
- callSession.creationTime = new Date();
999
- this._updateCallSession(callSession);
1000
- this.eventEmitter.emit(exports.ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
1001
- this.currentSipSession = sipSession;
1002
- this.currentCallSession = callSession;
1003
- this.eventEmitter.emit(exports.ON_CALL_OUTGOING, callSession);
1004
- // If an invite promise exists, catch exceptions on it to trigger error like OverConstraintsError.
1005
- // @ts-ignore: does not exist
1006
- if (sipSession.invitePromise) {
1007
- // @ts-ignore: does not exist
1008
- sipSession.invitePromise.catch(error => {
1009
- this.eventEmitter.emit(exports.ON_CALL_ERROR, error, callSession);
1010
- });
1011
- }
1012
- return Promise.resolve(callSession);
1013
- });
1014
- }
1015
- transfer(callSession, target) {
1016
- const sipSession = this.findSipSession(callSession);
1017
- if (!sipSession) {
1018
- return;
1019
- }
1020
- logger.info('WebRTC transfer', {
1021
- sipId: this.getSipSessionId(sipSession),
1022
- target,
1023
- });
1024
- this.client.transfer(sipSession, target);
1025
- }
1026
- indirectTransfer(source, destination) {
1027
- return __awaiter(this, void 0, void 0, function* () {
1028
- const sipSession = this.client.getSipSession(source.sipCallId);
1029
- const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
1030
- logger.info('WebRTC indirect transfer', {
1031
- sipId: sipSession ? this.getSipSessionId(sipSession) : null,
1032
- target: sipSessionTarget ? this.getSipSessionId(sipSessionTarget) : null,
1033
- });
1034
- if (!sipSessionTarget) {
1035
- return Promise.reject();
1036
- }
1037
- return new Promise(resolve => {
1038
- const options = {
1039
- requestDelegate: {
1040
- onAccept: () => {
1041
- // Wait a little so the REFER will take effect
1042
- setTimeout(() => {
1043
- this.hangup(destination).then(resolve);
1044
- }, 200);
1045
- },
1046
- },
1047
- };
1048
- return sipSessionTarget.refer(sipSession, options);
1049
- });
1050
- });
1051
- }
1052
- initiateCTIIndirectTransfer() { return Promise.resolve(null); }
1053
- cancelCTIIndirectTransfer() { }
1054
- confirmCTIIndirectTransfer() { }
1055
- hangup(callSession) {
1056
- return __awaiter(this, void 0, void 0, function* () {
1057
- const sipSession = this.findSipSession(callSession);
1058
- if (!sipSession) {
1059
- console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
1060
- return false;
1061
- }
1062
- const sipSessionId = this.getSipSessionId(sipSession);
1063
- logger.info('WebRTC hangup', {
1064
- sipId: this.getSipSessionId(sipSession),
1065
- sipSessionId,
1066
- });
1067
- yield this.client.hangup(sipSession);
1068
- if (callSession) {
1069
- // Removal of `this.callSessions` will be done in `_onCallTerminated`.
1070
- this.endCurrentCall(callSession);
1071
- }
1072
- else if (sipSessionId) {
1073
- delete this.callSessions[sipSessionId];
1074
- }
1075
- this.shouldSendReinvite = false;
1076
- return true;
1077
- });
1078
- }
1079
- getStats(callSession) {
1080
- return __awaiter(this, void 0, void 0, function* () {
1081
- const sipSession = this.findSipSession(callSession);
1082
- return sipSession ? this.client.getStats(sipSession) : null;
1083
- });
1084
- }
1085
- startNetworkMonitoring(callSession, interval = 1000) {
1086
- const sipSession = this.findSipSession(callSession);
1087
- return sipSession ? this.client.startNetworkMonitoring(sipSession, interval) : null;
1088
- }
1089
- stopNetworkMonitoring(callSession) {
1090
- const sipSession = this.findSipSession(callSession);
1091
- return sipSession ? this.client.stopNetworkMonitoring(sipSession) : null;
1092
- }
1093
- forceCancel(sipSession) {
1094
- // @ts-ignore: private
1095
- if (!sipSession || !sipSession.outgoingInviteRequest) {
1096
- return;
1097
- }
1098
- try {
1099
- // @ts-ignore: private
1100
- sipSession.outgoingInviteRequest.cancel();
1101
- }
1102
- catch (e) {
1103
- logger.info('force cancel, error', e);
1104
- }
1105
- }
1106
- endCurrentCall(callSession) {
1107
- const isCurrent = this.isCurrentCallSipSession(callSession);
1108
- logger.info('Ending current call', {
1109
- id: callSession ? callSession.getId() : null,
1110
- isCurrent,
1111
- });
1112
- if (isCurrent) {
1113
- this.currentSipSession = undefined;
1114
- this.currentCallSession = undefined;
1115
- }
1116
- this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'locally ended');
1117
- }
1118
- onConnectionMade() { }
1119
- isConference(callSession) {
1120
- if (!callSession) {
1121
- return false;
1122
- }
1123
- return this.client && this.client.isConference(callSession.sipCallId);
1124
- }
1125
- close() {
1126
- return __awaiter(this, arguments, void 0, function* (force = false) {
1127
- logger.info('WebRTC close');
1128
- try {
1129
- yield Promise.race([
1130
- this.unregister(),
1131
- new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
1132
- ]);
1133
- }
1134
- catch (e) {
1135
- logger.error('WebRTC close, unregister error', e);
1136
- }
1137
- yield this.client.close(force);
1138
- this.unbind();
1139
- this.incomingSessions = [];
1140
- this.currentSipSession = undefined;
1141
- this.currentCallSession = undefined;
1142
- this.shouldSendReinvite = false;
1143
- this.rejectedSessions = {};
1144
- });
1145
- }
1146
- isRegistered() {
1147
- return this.client && this.client.isRegistered();
1148
- }
1149
- enableRinging() {
1150
- logger.info('WebRTC enable ringing');
1151
- this.ringingEnabled = true;
1152
- }
1153
- disableRinging() {
1154
- logger.info('WebRTC disable ringing');
1155
- this.ringingEnabled = false;
1156
- }
1157
- getCurrentCallSession() {
1158
- if (!this.currentSipSession) {
1159
- return null;
1160
- }
1161
- return this._createCallSession(this.currentSipSession, this.currentCallSession);
1162
- }
1163
- hasIncomingCallSession() {
1164
- return this.incomingSessions.length > 0;
1165
- }
1166
- getIncomingCallSession() {
1167
- if (!this.hasIncomingCallSession()) {
1168
- return null;
1169
- }
1170
- const sessionId = this.incomingSessions[0];
1171
- const sipSession = this.client.getSipSession(sessionId);
1172
- if (!sipSession) {
1173
- return null;
1174
- }
1175
- return this._createCallSession(sipSession);
1176
- }
1177
- // eslint-disable-next-line @typescript-eslint/default-param-last
1178
- sendMessage(sipSession = null, body, contentType = 'text/plain') {
1179
- return this.client.sendMessage(sipSession, body, contentType);
1180
- }
1181
- getLocalStream(callSession) {
1182
- return callSession ? this.client.getLocalStream(callSession.sipCallId) : null;
1183
- }
1184
- getLocalVideoStream(callSession) {
1185
- return callSession ? this.client.getLocalVideoStream(callSession.sipCallId) : null;
1186
- }
1187
- // Deprecated
1188
- getLocalMediaStream(callSession) {
1189
- logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
1190
- return this.getLocalStream(callSession);
1191
- }
1192
- hasLocalVideo(callSession) {
1193
- return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : false;
1194
- }
1195
- hasALocalVideoTrack(callSession) {
1196
- return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : false;
1197
- }
1198
- getRemoteStream(callSession) {
1199
- return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
1200
- }
1201
- getRemoteVideoStream(callSession) {
1202
- return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
1203
- }
1204
- getRemoteVideoStreamFromPc(callSession) {
1205
- return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
1206
- }
1207
- hasRemoteVideo(callSession) {
1208
- return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
1209
- }
1210
- setMediaConstraints(media) {
1211
- this.client.setMediaConstraints(media);
1212
- }
1213
- isVideoRemotelyHeld(callSession) {
1214
- return callSession ? this.client.isVideoRemotelyHeld(callSession.sipCallId) : false;
1215
- }
1216
- bindClientEvents() {
1217
- this.client.unbind();
1218
- this.client.on(this.client.INVITE, (sipSession, wantsToDoVideo) => {
1219
- const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
1220
- const withVideo = this.allowVideo ? wantsToDoVideo : false;
1221
- logger.info('WebRTC invite received', {
1222
- sipId: this.getSipSessionId(sipSession),
1223
- withVideo,
1224
- autoAnswer,
1225
- });
1226
- const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
1227
- this.incomingSessions.push(callSession.getId());
1228
- this._bindEvents(sipSession);
1229
- this.client.storeSipSession(sipSession);
1230
- callSession.creationTime = new Date();
1231
- this._updateCallSession(callSession);
1232
- this.eventEmitter.emit(exports.ON_CALL_INCOMING, callSession, wantsToDoVideo);
1233
- if (!this.currentSipSession) {
1234
- if (this.ringingEnabled) {
1235
- this.eventEmitter.emit(exports.ON_PLAY_RING_SOUND, this.audioRingDeviceId, this.audioRingVolume, callSession);
1236
- }
1237
- }
1238
- else {
1239
- this.eventEmitter.emit(exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
1240
- }
1241
- });
1242
- this.client.on(this.client.ON_REINVITE, (...args) => {
1243
- logger.info('WebRTC on reinvite', {
1244
- sessionId: args[0].id,
1245
- inviteId: args[1].id,
1246
- updatedCalleeName: args[2],
1247
- updatedNumber: args[3],
1248
- });
1249
- const sipSession = args[0];
1250
- // Give some time for the stream to be mounted.
1251
- // if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
1252
- setTimeout(() => {
1253
- // Update callSession
1254
- this._createCallSession(sipSession, this.callSessions[this.getSipSessionId(sipSession)]);
1255
- this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
1256
- }, 2000);
1257
- });
1258
- this.client.on(this.client.ACCEPTED, (sipSession) => __awaiter(this, void 0, void 0, function* () {
1259
- const sessionId = this.getSipSessionId(sipSession);
1260
- const hasSession = (sessionId in this.callSessions);
1261
- logger.info('WebRTC call accepted', {
1262
- sipId: sessionId,
1263
- hasSession,
1264
- });
1265
- if (!hasSession) {
1266
- logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', {
1267
- sessionId,
1268
- });
1269
- return;
1270
- }
1271
- this._onCallAccepted(sipSession, this.client.hasVideo(sessionId));
1272
- if (this.audioOutputDeviceId) {
1273
- yield this.client.changeAudioOutputDevice(this.audioOutputDeviceId);
1274
- }
1275
- }));
1276
- this.client.on('ended', () => { });
1277
- this.client.on(this.client.ON_ERROR, e => {
1278
- logger.error('WebRTC error', e);
1279
- this.eventEmitter.emit(exports.ON_CALL_ERROR, e);
1280
- });
1281
- this.client.on(this.client.REJECTED, session => {
1282
- logger.info('WebRTC call rejected', { id: this.getSipSessionId(session) });
1283
- const callSession = this._createCallSession(session);
1284
- // `_createCallSession` add the CallSession in `this.callSessions`.
1285
- // so we have to remove it or `callCount` will always return 1 even if the call was rejected
1286
- delete this.callSessions[this.getSipSessionId(session)];
1287
- callSession.endTime = new Date();
1288
- this.eventEmitter.emit(exports.ON_CALL_REJECTED, callSession);
1289
- });
1290
- this.client.on(this.client.UNREGISTERED, () => {
1291
- logger.info('WebRTC unregistered');
1292
- this.eventEmitter.emit(exports.ON_UNREGISTERED);
1293
- });
1294
- this.client.on(this.client.ON_DISCONNECTED, () => {
1295
- logger.info('WebRTC disconnected');
1296
- this.eventEmitter.emit(exports.ON_DISCONNECTED);
1297
- });
1298
- this.client.on(this.client.ON_PROGRESS, session => {
1299
- logger.info('WebRTC progress (180)');
1300
- const callSession = this._createCallSession(session, null, {
1301
- incoming: false,
1302
- ringing: true,
1303
- callId: this.getSipSessionId(session),
1304
- });
1305
- this.eventEmitter.emit(exports.ON_PROGRESS, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
1306
- });
1307
- this.client.on(this.client.ON_EARLY_MEDIA, session => {
1308
- logger.info('WebRTC early media');
1309
- const callSession = this._createCallSession(session, null, {
1310
- incoming: false,
1311
- ringing: true,
1312
- callId: this.getSipSessionId(session),
1313
- });
1314
- this.eventEmitter.emit(exports.ON_EARLY_MEDIA, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
1315
- });
1316
- this.client.on(this.client.REGISTERED, () => {
1317
- var _a, _b;
1318
- logger.info('WebRTC registered', {
1319
- shouldSendReinvite: this.shouldSendReinvite,
1320
- state: this.currentSipSession ? this.currentSipSession.state : null,
1321
- currentSipSession: !!this.currentSipSession,
1322
- });
1323
- this.stopHeartbeat();
1324
- this.eventEmitter.emit(exports.ON_REGISTERED);
1325
- // If the phone registered with a current callSession (eg: when switching network):
1326
- // send a reinvite to renegociate ICE with new IP
1327
- if (this.shouldSendReinvite && this.currentSipSession && this.currentSipSession.state === session_state_1.SessionState.Established) {
1328
- this.shouldSendReinvite = false;
1329
- const pc = (_b = (_a = this.currentSipSession) === null || _a === void 0 ? void 0 : _a.sessionDescriptionHandler) === null || _b === void 0 ? void 0 : _b.peerConnection;
1330
- const isConference = pc ? pc.sfu : false;
1331
- const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
1332
- try {
1333
- // Send reinvite with iceRestart
1334
- this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
1335
- }
1336
- catch (e) {
1337
- logger.error('WebRTC reinvite after register, error', {
1338
- message: e.message,
1339
- stack: e.stack,
1340
- });
1341
- }
1342
- }
1343
- });
1344
- this.client.on(this.client.CONNECTED, () => {
1345
- logger.info('WebRTC client connected');
1346
- this.stopHeartbeat();
1347
- });
1348
- this.client.on(this.client.DISCONNECTED, () => {
1349
- logger.info('WebRTC client disconnected');
1350
- this.eventEmitter.emit(exports.ON_UNREGISTERED);
1351
- // Do not trigger heartbeat if already running
1352
- if (!this.client.hasHeartbeat()) {
1353
- this.startHeartbeat();
1354
- }
1355
- // Tell to send reinvite when reconnecting
1356
- this.shouldSendReinvite = true;
1357
- });
1358
- this.client.on(this.client.ON_TRACK, (session, event) => {
1359
- this.eventEmitter.emit(exports.ON_TRACK, session, event);
1360
- });
1361
- this.client.on('onVideoInputChange', stream => {
1362
- this.eventEmitter.emit(exports.ON_VIDEO_INPUT_CHANGE, stream);
1363
- });
1364
- this.client.on(this.client.MESSAGE, (message) => {
1365
- this._onMessage(message);
1366
- this.eventEmitter.emit(exports.ON_MESSAGE, message);
1367
- });
1368
- this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
1369
- const callSession = this.getCallSession(this.getSipSessionId(session));
1370
- this.eventEmitter.emit(exports.ON_NETWORK_STATS, callSession, stats, previousStats);
1371
- });
1372
- // Used when upgrading directly in screenshare mode
1373
- this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession, response, desktop) => {
1374
- const sipSessionId = this.getSipSessionId(sipSession);
1375
- const localStream = this.client.getLocalStream(sipSessionId);
1376
- const callSession = this.callSessions[sipSessionId];
1377
- logger.info('Updrading directly in screensharing mode', {
1378
- sipSessionId,
1379
- tracks: (localStream === null || localStream === void 0 ? void 0 : localStream.getTracks()) || null,
1380
- });
1381
- this._onScreenSharing(localStream, sipSession, callSession, false, desktop);
1382
- });
1383
- }
1384
- // Find a corresponding sipSession from a CallSession
1385
- findSipSession(callSession) {
1386
- const keys = this.client.getSipSessionIds();
1387
- const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
1388
- if (keyIndex === -1) {
1389
- const currentSipSessionId = this.currentSipSession ? this.getSipSessionId(this.currentSipSession) : this.client.getSipSessionIds()[0];
1390
- return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
1391
- }
1392
- return this.client.getSipSession(keys[keyIndex]);
1393
- }
1394
- getCallSession(sipSessionId) {
1395
- return this.callSessions[sipSessionId];
1396
- }
1397
- getSipSessionId(sipSession) {
1398
- if (!sipSession) {
1399
- return '';
1400
- }
1401
- return this.client.getSipSessionId(sipSession);
1402
- }
1403
- getSipSessionIdFromCallSession(callSession) {
1404
- const sipSession = this.findSipSession(callSession);
1405
- return sipSession ? this.getSipSessionId(sipSession) : null;
1406
- }
1407
- _updateCallSession(callSession) {
1408
- const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
1409
- if (sipSessionId) {
1410
- this.callSessions[sipSessionId] = callSession;
1411
- }
1412
- }
1413
- _onMessage(message) {
1414
- if (!message || message.method !== 'MESSAGE') {
1415
- return;
1416
- }
1417
- let body;
1418
- try {
1419
- body = JSON.parse(message.body || '');
1420
- }
1421
- catch (e) {
1422
- return;
1423
- }
1424
- const { type, content, } = body;
1425
- switch (type) {
1426
- case exports.MESSAGE_TYPE_CHAT:
1427
- this.eventEmitter.emit(exports.ON_CHAT, content);
1428
- break;
1429
- case exports.MESSAGE_TYPE_SIGNAL:
1430
- {
1431
- this.eventEmitter.emit(exports.ON_SIGNAL, content);
1432
- break;
1433
- }
1434
- default:
1435
- }
1436
- }
1437
- _createIncomingCallSession(sipSession, cameraEnabled, fromSession, autoAnswer = false) {
1438
- return this._createCallSession(sipSession, fromSession, {
1439
- incoming: true,
1440
- ringing: true,
1441
- cameraEnabled,
1442
- autoAnswer,
1443
- });
1444
- }
1445
- _createOutgoingCallSession(sipSession, cameraEnabled, fromSession) {
1446
- return this._createCallSession(sipSession, fromSession, {
1447
- incoming: false,
1448
- ringing: true,
1449
- cameraEnabled,
1450
- });
1451
- }
1452
- _createAcceptedCallSession(sipSession, cameraEnabled, fromSession) {
1453
- return this._createCallSession(sipSession, fromSession, {
1454
- cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
1455
- });
1456
- }
1457
- _createMutedCallSession(sipSession, fromSession) {
1458
- return this._createCallSession(sipSession, fromSession, {
1459
- muted: true,
1460
- });
1461
- }
1462
- _createUnmutedCallSession(sipSession, fromSession) {
1463
- return this._createCallSession(sipSession, fromSession, {
1464
- muted: false,
1465
- });
1466
- }
1467
- _createCameraResumedCallSession(sipSession, fromSession) {
1468
- return this._createCallSession(sipSession, fromSession, {
1469
- videoMuted: false,
1470
- });
1471
- }
1472
- _createCameraDisabledCallSession(sipSession, fromSession) {
1473
- return this._createCallSession(sipSession, fromSession, {
1474
- videoMuted: true,
1475
- });
1476
- }
1477
- _createCallSession(sipSession, fromSession, extra = {}) {
1478
- // eslint-disable-next-line
1479
- const identity = sipSession ? sipSession.remoteIdentity || sipSession.assertedIdentity : null;
1480
- // @ts-ignore: private
1481
- const number = identity ? identity.uri._normal.user : null;
1482
- const { state, } = sipSession || {};
1483
- const sessionId = this.getSipSessionId(sipSession);
1484
- fromSession = fromSession || this.callSessions[sessionId];
1485
- const callSession = new CallSession_1.default(Object.assign({ callId: fromSession && fromSession.callId, sipCallId: sessionId, sipStatus: state, displayName: identity ? identity.displayName || number : number,
1486
- // @ts-ignore: date / number
1487
- startTime: fromSession ? fromSession.startTime : new Date(), creationTime: fromSession ? fromSession.creationTime : null, answerTime: fromSession ? fromSession.answerTime : null, endTime: fromSession ? fromSession.endTime : null, answered: state === session_state_1.SessionState.Established, paused: this.client.isCallHeld(sipSession), isCaller: fromSession ? fromSession.isCaller : 'incoming' in extra ? !extra.incoming : false, cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId), number, ringing: false, muted: fromSession ? fromSession.isMuted() : this.client.isAudioMuted(sipSession), videoMuted: fromSession ? fromSession.isVideoMuted() : false, recording: fromSession ? fromSession.isRecording() : false, recordingPaused: false, sipSession, conference: !!fromSession && fromSession.isConference() }, extra));
1488
- this.callSessions[sessionId] = callSession;
1489
- return callSession;
1490
- }
1491
- }
1492
- exports.default = WebRTCPhone;