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