@wazo/sdk 0.39.14 → 0.40.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 (288) hide show
  1. package/README.md +2 -2
  2. package/dist/wazo-sdk.js +12 -12
  3. package/esm/__tests__/api-client.test.js +0 -10
  4. package/esm/__tests__/web-rtc-client.test.js +2 -15
  5. package/esm/api/amid.js +12 -4
  6. package/esm/api/chatd.js +0 -1
  7. package/esm/api/dird.js +7 -10
  8. package/esm/checker/checks/ice-ipv4.js +2 -3
  9. package/esm/checker/checks/symmetric-nat.js +7 -4
  10. package/esm/domain/AdHocAPIConference.js +1 -1
  11. package/esm/domain/CallLog.js +1 -1
  12. package/esm/domain/Contact.js +2 -1
  13. package/esm/domain/MeetingAuthorization.js +6 -0
  14. package/esm/domain/Phone/CTIPhone.js +2 -0
  15. package/esm/domain/Phone/WebRTCPhone.js +23 -18
  16. package/esm/domain/Session.js +2 -2
  17. package/esm/domain/__tests__/Agent.test.js +0 -2
  18. package/esm/domain/__tests__/Call.test.js +0 -1
  19. package/esm/domain/__tests__/CallLog.test.js +0 -1
  20. package/esm/domain/__tests__/CallSession.test.js +1 -2
  21. package/esm/domain/__tests__/Contact.test.js +2 -4
  22. package/esm/domain/__tests__/IndirectTransfer.test.js +0 -1
  23. package/esm/domain/__tests__/Profile.test.js +0 -1
  24. package/esm/domain/__tests__/Room.test.js +1 -25
  25. package/esm/domain/__tests__/Session.test.js +13 -14
  26. package/esm/domain/__tests__/SipLine.test.js +2 -3
  27. package/esm/index.js +42 -88
  28. package/esm/lib/WazoSessionDescriptionHandler.js +9 -15
  29. package/esm/service/IssueReporter.js +1 -3
  30. package/esm/service/__tests__/IssueReporter.test.js +0 -1
  31. package/esm/simple/Phone.js +1 -1
  32. package/esm/simple/Websocket.js +2 -2
  33. package/esm/simple/index.js +5 -4
  34. package/esm/simple/room/Room.js +15 -15
  35. package/esm/simple/room/SipRoom.js +1 -1
  36. package/esm/simple/room/Stream.js +1 -2
  37. package/esm/simple/room/__tests__/Participant.test.js +0 -2
  38. package/esm/simple/room/__tests__/RemoteParticipant.test.js +1 -2
  39. package/esm/types/api/amid.d.ts.map +1 -1
  40. package/esm/types/api/auth.d.ts +2 -2
  41. package/esm/types/api/auth.d.ts.map +1 -1
  42. package/esm/types/api/call-logd.d.ts +3 -3
  43. package/esm/types/api/call-logd.d.ts.map +1 -1
  44. package/esm/types/api/chatd.d.ts +9 -22
  45. package/esm/types/api/chatd.d.ts.map +1 -1
  46. package/esm/types/api/dird.d.ts +21 -14
  47. package/esm/types/api/dird.d.ts.map +1 -1
  48. package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -1
  49. package/esm/types/checker/checks/index.d.ts +1 -1
  50. package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -1
  51. package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
  52. package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
  53. package/esm/types/domain/Agent.d.ts +1 -1
  54. package/esm/types/domain/Agent.d.ts.map +1 -1
  55. package/esm/types/domain/CallLog.d.ts +14 -26
  56. package/esm/types/domain/CallLog.d.ts.map +1 -1
  57. package/esm/types/domain/CallSession.d.ts +3 -4
  58. package/esm/types/domain/CallSession.d.ts.map +1 -1
  59. package/esm/types/domain/Contact.d.ts +8 -0
  60. package/esm/types/domain/Contact.d.ts.map +1 -1
  61. package/esm/types/domain/MeetingAuthorization.d.ts +6 -0
  62. package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -1
  63. package/esm/types/domain/Phone/CTIPhone.d.ts +2 -0
  64. package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  65. package/esm/types/domain/Phone/Phone.d.ts +12 -2
  66. package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
  67. package/esm/types/domain/Phone/WebRTCPhone.d.ts +24 -20
  68. package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
  69. package/esm/types/domain/Room.d.ts +10 -12
  70. package/esm/types/domain/Room.d.ts.map +1 -1
  71. package/esm/types/domain/Session.d.ts +1 -1
  72. package/esm/types/domain/Session.d.ts.map +1 -1
  73. package/esm/types/domain/SipLine.d.ts +3 -3
  74. package/esm/types/domain/SipLine.d.ts.map +1 -1
  75. package/esm/types/domain/types.d.ts +64 -10
  76. package/esm/types/domain/types.d.ts.map +1 -1
  77. package/esm/types/index.d.ts +51 -314
  78. package/esm/types/index.d.ts.map +1 -1
  79. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
  80. package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
  81. package/esm/types/service/CallApi.d.ts +3 -3
  82. package/esm/types/service/CallApi.d.ts.map +1 -1
  83. package/esm/types/service/IssueReporter.d.ts.map +1 -1
  84. package/esm/types/simple/Auth.d.ts +0 -40
  85. package/esm/types/simple/Auth.d.ts.map +1 -1
  86. package/esm/types/simple/Phone.d.ts +0 -113
  87. package/esm/types/simple/Phone.d.ts.map +1 -1
  88. package/esm/types/simple/Websocket.d.ts +0 -16
  89. package/esm/types/simple/Websocket.d.ts.map +1 -1
  90. package/esm/types/simple/index.d.ts +8 -8
  91. package/esm/types/simple/index.d.ts.map +1 -1
  92. package/esm/types/simple/room/Participant.d.ts +4 -3
  93. package/esm/types/simple/room/Participant.d.ts.map +1 -1
  94. package/esm/types/simple/room/Room.d.ts +29 -18
  95. package/esm/types/simple/room/Room.d.ts.map +1 -1
  96. package/esm/types/simple/room/SipRoom.d.ts +1 -1
  97. package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
  98. package/esm/types/simple/room/Stream.d.ts +1 -1
  99. package/esm/types/simple/room/Stream.d.ts.map +1 -1
  100. package/esm/types/utils/PhoneNumberUtil.d.ts +1 -1
  101. package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -1
  102. package/esm/types/utils/api-requester.d.ts +1 -1
  103. package/esm/types/utils/api-requester.d.ts.map +1 -1
  104. package/esm/types/utils/sdp.d.ts +20 -5
  105. package/esm/types/utils/sdp.d.ts.map +1 -1
  106. package/esm/types/web-rtc-client.d.ts +51 -49
  107. package/esm/types/web-rtc-client.d.ts.map +1 -1
  108. package/esm/types/websocket-client.d.ts.map +1 -1
  109. package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -6
  110. package/esm/utils/__tests__/api-requester.test.js +0 -2
  111. package/esm/utils/__tests__/sdp.test.js +4 -18
  112. package/esm/utils/api-requester.js +1 -2
  113. package/esm/utils/sdp.js +8 -3
  114. package/esm/web-rtc-client.js +99 -136
  115. package/esm/websocket-client.js +1 -2
  116. package/index.js +1 -0
  117. package/lib/__tests__/api-client.test.js +0 -10
  118. package/lib/__tests__/web-rtc-client.test.js +2 -15
  119. package/lib/api/amid.js +12 -4
  120. package/lib/api/chatd.js +0 -1
  121. package/lib/api/dird.js +19 -22
  122. package/lib/checker/checks/ice-ipv4.js +2 -3
  123. package/lib/checker/checks/symmetric-nat.js +7 -4
  124. package/lib/domain/AdHocAPIConference.js +1 -1
  125. package/lib/domain/CallLog.js +1 -1
  126. package/lib/domain/Contact.js +2 -1
  127. package/lib/domain/MeetingAuthorization.js +6 -0
  128. package/lib/domain/Phone/CTIPhone.js +2 -0
  129. package/lib/domain/Phone/WebRTCPhone.js +23 -18
  130. package/lib/domain/Session.js +2 -2
  131. package/lib/domain/__tests__/Agent.test.js +0 -2
  132. package/lib/domain/__tests__/Call.test.js +0 -1
  133. package/lib/domain/__tests__/CallLog.test.js +0 -1
  134. package/lib/domain/__tests__/CallSession.test.js +1 -2
  135. package/lib/domain/__tests__/Contact.test.js +2 -4
  136. package/lib/domain/__tests__/IndirectTransfer.test.js +0 -1
  137. package/lib/domain/__tests__/Profile.test.js +0 -1
  138. package/lib/domain/__tests__/Room.test.js +1 -25
  139. package/lib/domain/__tests__/Session.test.js +13 -14
  140. package/lib/domain/__tests__/SipLine.test.js +2 -3
  141. package/lib/index.js +93 -99
  142. package/lib/lib/WazoSessionDescriptionHandler.js +9 -15
  143. package/lib/service/IssueReporter.js +1 -3
  144. package/lib/service/__tests__/IssueReporter.test.js +0 -1
  145. package/lib/simple/Phone.js +1 -1
  146. package/lib/simple/Websocket.js +2 -2
  147. package/lib/simple/index.js +2 -1
  148. package/lib/simple/room/Room.js +17 -15
  149. package/lib/simple/room/SipRoom.js +1 -1
  150. package/lib/simple/room/Stream.js +1 -2
  151. package/lib/simple/room/__tests__/Participant.test.js +0 -2
  152. package/lib/simple/room/__tests__/RemoteParticipant.test.js +1 -2
  153. package/lib/types/api/amid.d.ts.map +1 -1
  154. package/lib/types/api/auth.d.ts +2 -2
  155. package/lib/types/api/auth.d.ts.map +1 -1
  156. package/lib/types/api/call-logd.d.ts +3 -3
  157. package/lib/types/api/call-logd.d.ts.map +1 -1
  158. package/lib/types/api/chatd.d.ts +9 -22
  159. package/lib/types/api/chatd.d.ts.map +1 -1
  160. package/lib/types/api/dird.d.ts +21 -14
  161. package/lib/types/api/dird.d.ts.map +1 -1
  162. package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -1
  163. package/lib/types/checker/checks/index.d.ts +1 -1
  164. package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -1
  165. package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
  166. package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
  167. package/lib/types/domain/Agent.d.ts +1 -1
  168. package/lib/types/domain/Agent.d.ts.map +1 -1
  169. package/lib/types/domain/CallLog.d.ts +14 -26
  170. package/lib/types/domain/CallLog.d.ts.map +1 -1
  171. package/lib/types/domain/CallSession.d.ts +3 -4
  172. package/lib/types/domain/CallSession.d.ts.map +1 -1
  173. package/lib/types/domain/Contact.d.ts +8 -0
  174. package/lib/types/domain/Contact.d.ts.map +1 -1
  175. package/lib/types/domain/MeetingAuthorization.d.ts +6 -0
  176. package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -1
  177. package/lib/types/domain/Phone/CTIPhone.d.ts +2 -0
  178. package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
  179. package/lib/types/domain/Phone/Phone.d.ts +12 -2
  180. package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
  181. package/lib/types/domain/Phone/WebRTCPhone.d.ts +24 -20
  182. package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
  183. package/lib/types/domain/Room.d.ts +10 -12
  184. package/lib/types/domain/Room.d.ts.map +1 -1
  185. package/lib/types/domain/Session.d.ts +1 -1
  186. package/lib/types/domain/Session.d.ts.map +1 -1
  187. package/lib/types/domain/SipLine.d.ts +3 -3
  188. package/lib/types/domain/SipLine.d.ts.map +1 -1
  189. package/lib/types/domain/types.d.ts +64 -10
  190. package/lib/types/domain/types.d.ts.map +1 -1
  191. package/lib/types/index.d.ts +51 -314
  192. package/lib/types/index.d.ts.map +1 -1
  193. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
  194. package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
  195. package/lib/types/service/CallApi.d.ts +3 -3
  196. package/lib/types/service/CallApi.d.ts.map +1 -1
  197. package/lib/types/service/IssueReporter.d.ts.map +1 -1
  198. package/lib/types/simple/Auth.d.ts +0 -40
  199. package/lib/types/simple/Auth.d.ts.map +1 -1
  200. package/lib/types/simple/Phone.d.ts +0 -113
  201. package/lib/types/simple/Phone.d.ts.map +1 -1
  202. package/lib/types/simple/Websocket.d.ts +0 -16
  203. package/lib/types/simple/Websocket.d.ts.map +1 -1
  204. package/lib/types/simple/index.d.ts +8 -8
  205. package/lib/types/simple/index.d.ts.map +1 -1
  206. package/lib/types/simple/room/Participant.d.ts +4 -3
  207. package/lib/types/simple/room/Participant.d.ts.map +1 -1
  208. package/lib/types/simple/room/Room.d.ts +29 -18
  209. package/lib/types/simple/room/Room.d.ts.map +1 -1
  210. package/lib/types/simple/room/SipRoom.d.ts +1 -1
  211. package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
  212. package/lib/types/simple/room/Stream.d.ts +1 -1
  213. package/lib/types/simple/room/Stream.d.ts.map +1 -1
  214. package/lib/types/utils/PhoneNumberUtil.d.ts +1 -1
  215. package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -1
  216. package/lib/types/utils/api-requester.d.ts +1 -1
  217. package/lib/types/utils/api-requester.d.ts.map +1 -1
  218. package/lib/types/utils/sdp.d.ts +20 -5
  219. package/lib/types/utils/sdp.d.ts.map +1 -1
  220. package/lib/types/web-rtc-client.d.ts +51 -49
  221. package/lib/types/web-rtc-client.d.ts.map +1 -1
  222. package/lib/types/websocket-client.d.ts.map +1 -1
  223. package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -6
  224. package/lib/utils/__tests__/api-requester.test.js +0 -2
  225. package/lib/utils/__tests__/sdp.test.js +6 -18
  226. package/lib/utils/api-requester.js +2 -3
  227. package/lib/utils/sdp.js +9 -3
  228. package/lib/web-rtc-client.js +105 -140
  229. package/lib/websocket-client.js +1 -2
  230. package/package.json +5 -18
  231. package/src/__tests__/api-client.test.ts +10 -19
  232. package/src/__tests__/web-rtc-client.test.ts +13 -25
  233. package/src/api/amid.ts +13 -4
  234. package/src/api/auth.ts +2 -5
  235. package/src/api/call-logd.ts +3 -3
  236. package/src/api/chatd.ts +10 -24
  237. package/src/api/dird.ts +33 -39
  238. package/src/checker/checks/ice-ipv4.ts +4 -5
  239. package/src/checker/checks/symmetric-nat.ts +11 -7
  240. package/src/checker/checks/webrtc-transport.ts +2 -2
  241. package/src/domain/AdHocAPIConference.ts +1 -1
  242. package/src/domain/Agent.ts +1 -1
  243. package/src/domain/CallLog.ts +19 -27
  244. package/src/domain/CallSession.ts +3 -4
  245. package/src/domain/Contact.ts +3 -1
  246. package/src/domain/MeetingAuthorization.ts +13 -0
  247. package/src/domain/Phone/CTIPhone.ts +4 -0
  248. package/src/domain/Phone/Phone.ts +11 -2
  249. package/src/domain/Phone/WebRTCPhone.ts +60 -52
  250. package/src/domain/Room.ts +12 -14
  251. package/src/domain/Session.ts +3 -3
  252. package/src/domain/SipLine.ts +3 -3
  253. package/src/domain/__tests__/Agent.test.ts +3 -5
  254. package/src/domain/__tests__/Call.test.ts +4 -5
  255. package/src/domain/__tests__/CallLog.test.ts +1 -3
  256. package/src/domain/__tests__/CallSession.test.ts +10 -11
  257. package/src/domain/__tests__/Contact.test.ts +2 -4
  258. package/src/domain/__tests__/IndirectTransfer.test.ts +6 -7
  259. package/src/domain/__tests__/Profile.test.ts +3 -4
  260. package/src/domain/__tests__/Room.test.ts +27 -51
  261. package/src/domain/__tests__/Session.test.ts +27 -28
  262. package/src/domain/__tests__/SipLine.test.ts +4 -5
  263. package/src/domain/types.ts +64 -11
  264. package/src/index.ts +51 -111
  265. package/src/lib/WazoSessionDescriptionHandler.ts +24 -30
  266. package/src/service/CallApi.ts +3 -3
  267. package/src/service/IssueReporter.ts +3 -5
  268. package/src/service/__tests__/IssueReporter.test.ts +1 -2
  269. package/src/simple/Auth.ts +1 -41
  270. package/src/simple/Phone.ts +9 -116
  271. package/src/simple/Websocket.ts +4 -20
  272. package/src/simple/index.ts +8 -7
  273. package/src/simple/room/Participant.ts +4 -3
  274. package/src/simple/room/Room.ts +44 -36
  275. package/src/simple/room/SipRoom.ts +4 -4
  276. package/src/simple/room/Stream.ts +2 -3
  277. package/src/simple/room/__tests__/Participant.test.ts +2 -4
  278. package/src/simple/room/__tests__/RemoteParticipant.test.ts +4 -3
  279. package/src/types/wazo.d.ts +1 -0
  280. package/src/utils/PhoneNumberUtil.ts +1 -1
  281. package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -6
  282. package/src/utils/__tests__/api-requester.test.ts +3 -4
  283. package/src/utils/__tests__/sdp.test.ts +16 -30
  284. package/src/utils/api-requester.ts +1 -4
  285. package/src/utils/sdp.ts +38 -17
  286. package/src/web-rtc-client.ts +196 -234
  287. package/src/websocket-client.ts +2 -3
  288. package/lib/.DS_Store +0 -0
@@ -1,5 +1,4 @@
1
1
  import { SessionState } from 'sip.js/lib/api/session-state';
2
- import { Inviter, Invitation } from 'sip.js/lib/api';
3
2
  import { OutgoingInviteRequest } from 'sip.js/lib/core';
4
3
  import type SipLine from '../domain/SipLine';
5
4
  import type Session from '../domain/Session';
@@ -9,123 +8,17 @@ import WebRTCPhone, * as PHONE_EVENTS from '../domain/Phone/WebRTCPhone';
9
8
  import { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL } from '../domain/Phone/WebRTCPhone';
10
9
  import WazoWebRTCClient, { events as clientEvents, transportEvents } from '../web-rtc-client';
11
10
  import IssueReporter from '../service/IssueReporter';
12
- import Emitter, { IEmitter } from '../utils/Emitter';
11
+ import Emitter from '../utils/Emitter';
13
12
  import Wazo from './index';
14
13
  import SFUNotAvailableError from '../domain/SFUNotAvailableError';
15
- import { ConnectionOptions } from '../domain/types';
14
+ import { ConnectionOptions, WazoSession } from '../domain/types';
16
15
 
17
16
  const logger = IssueReporter.loggerFor('simple-phone');
18
17
  const sipLogger = IssueReporter.loggerFor('sip.js');
19
18
  const protocolLogger = IssueReporter.loggerFor('sip');
20
19
  const protocolDebugMessages = ['Received WebSocket text message:', 'Sending WebSocket message:'];
21
20
 
22
- export interface IPhone extends IEmitter {
23
- client: WazoWebRTCClient;
24
- phone: WebRTCPhone | null | undefined;
25
- session: Session;
26
- sipLine: SipLine | null | undefined;
27
- SessionState: Record<string, any>;
28
-
29
- ON_USER_AGENT: string;
30
- ON_REGISTERED: string;
31
- ON_UNREGISTERED: string;
32
- ON_PROGRESS: string;
33
- ON_CALL_ACCEPTED: string;
34
- ON_CALL_ANSWERED: string;
35
- ON_CALL_INCOMING: string;
36
- ON_CALL_OUTGOING: string;
37
- ON_CALL_MUTED: string;
38
- ON_CALL_UNMUTED: string;
39
- ON_CALL_RESUMED: string;
40
- ON_CALL_HELD: string;
41
- ON_CALL_UNHELD: string;
42
- ON_CAMERA_DISABLED: string;
43
- ON_CAMERA_RESUMED: string;
44
- ON_CALL_CANCELED: string;
45
- ON_CALL_FAILED: string;
46
- ON_CALL_REJECTED: string;
47
- ON_CALL_ENDED: string;
48
- ON_CALL_ENDING: string;
49
- ON_MESSAGE: string;
50
- ON_REINVITE: string;
51
- ON_TRACK: string;
52
- ON_AUDIO_STREAM: string;
53
- ON_VIDEO_STREAM: string;
54
- ON_REMOVE_STREAM: string;
55
- ON_SHARE_SCREEN_STARTED: string;
56
- ON_SHARE_SCREEN_ENDING: string;
57
- ON_SHARE_SCREEN_ENDED: string;
58
- ON_TERMINATE_SOUND: string;
59
- ON_PLAY_RING_SOUND: string;
60
- ON_PLAY_INBOUND_CALL_SIGNAL_SOUND: string;
61
- ON_PLAY_HANGUP_SOUND: string;
62
- ON_PLAY_PROGRESS_SOUND: string;
63
- ON_VIDEO_INPUT_CHANGE: string;
64
- ON_CALL_ERROR: string;
65
- ON_MESSAGE_TRACK_UPDATED: string;
66
- ON_NETWORK_STATS: string;
67
- ON_CHAT: string;
68
- ON_SIGNAL: string;
69
- ON_DISCONNECTED: string;
70
- ON_EARLY_MEDIA: string;
71
- MESSAGE_TYPE_CHAT: string;
72
- MESSAGE_TYPE_SIGNAL: string;
73
-
74
- connect: (options: Partial<ConnectionOptions>, sipLine?: SipLine | null | undefined) => Promise<void>;
75
- connectWithCredentials: (server: string, sipLine: SipLine, displayName: string, rawOptions: Partial<ConnectionOptions>) => void;
76
- disconnect: () => Promise<void>;
77
- call: (extension: string, withCamera: boolean, rawSipLine: SipLine | null | undefined, audioOnly: boolean, conference: boolean) => Promise<CallSession | null | undefined>;
78
- hangup: (callSession: CallSession) => Promise<boolean> ;
79
- startConference: (host: CallSession, otherCalls: CallSession[]) => Promise<AdHocAPIConference>;
80
- mute: (callSession: CallSession, withApi?: boolean) => void;
81
- unmute: (callSession: CallSession, withApi?: boolean) => void;
82
- muteViaAPI: (callSession: CallSession) => void;
83
- unmuteViaAPI: (callSession: CallSession) => void;
84
- hold: (callSession: CallSession) => Promise<void | OutgoingInviteRequest> | null | undefined;
85
- unhold: (callSession: CallSession) => Promise<MediaStream | void | null | undefined>;
86
- resume: (callSession: CallSession) => Promise<MediaStream | null | void>;
87
- reject: (callSession: CallSession) => Promise<void> | undefined;
88
- transfer: (callSession: CallSession, target: string) => void;
89
- atxfer: (callSession: CallSession) => Record<string, any> | null;
90
- reinvite: (callSession: CallSession, constraints: (Record<string, any> | null), conference: boolean) => Promise<OutgoingInviteRequest | void | null>;
91
- getStats: (callSession: CallSession) => Promise<RTCStatsReport | null | undefined>;
92
- startNetworkMonitoring: (callSession: CallSession, interval: number) => void;
93
- stopNetworkMonitoring: (callSession: CallSession) => void;
94
- getSipSessionId: (sipSession: Invitation | Inviter) => string | null | undefined;
95
- sendMessage: (body: string, sipSession?: Inviter | Invitation, contentType?: string) => void;
96
- sendChat: (content: string, sipSession?: Inviter | Invitation) => void;
97
- sendSignal: (content: any, sipSession?: Inviter | Invitation) => void ;
98
- turnCameraOff: (callSession: CallSession) => void;
99
- turnCameraOn: (callSession: CallSession) => void;
100
- startScreenSharing: (constraints: Record<string, any>, callSession?: CallSession) => Promise<MediaStream | null>;
101
- stopScreenSharing: (callSession?: CallSession, restoreLocalStream?: boolean) => Promise<OutgoingInviteRequest | void | null>;
102
- sendDTMF: (tone: string, callSession: CallSession) => void;
103
- getLocalStream: (callSession: CallSession) => MediaStream | null | undefined ;
104
- hasLocalVideo: (callSession: CallSession) => boolean;
105
- hasALocalVideoTrack: (callSession: CallSession) => boolean;
106
- getLocalMediaStream: (callSession: CallSession) => MediaStream | null | undefined;
107
- getLocalVideoStream: (callSession: CallSession) => MediaStream | null;
108
- getRemoteStream: (callSession: CallSession) => MediaStream | null;
109
- getRemoteVideoStream: (callSession: CallSession) => MediaStream | null ;
110
- isVideoRemotelyHeld: (callSession: CallSession) => boolean;
111
- getRemoteStreamForCall: (callSession: CallSession) => MediaStream | null;
112
- getRemoteStreamsForCall: (callSession: CallSession) => MediaStream | null;
113
- getRemoteVideoStreamForCall: (callSession: CallSession) => MediaStream | null;
114
- getRemoteVideoStreamFromPc: (callSession: CallSession) => MediaStream | null;
115
- hasVideo: (callSession: CallSession) => boolean;
116
- hasAVideoTrack: (callSession: CallSession) => boolean;
117
- getCurrentSipSession: () => Invitation | Inviter | null;
118
- getPrimaryWebRtcLine: () => SipLine | null;
119
- getOutputDevice: () => string | null ;
120
- getPrimaryLine: () => SipLine | null;
121
- getLineById: (lineId: string) => SipLine | null;
122
- getSipLines: () => SipLine[];
123
- hasSfu: () => boolean;
124
- checkSfu: () => void;
125
- _transferEvents: () => void;
126
- }
127
-
128
- class Phone extends Emitter implements IPhone {
21
+ class Phone extends Emitter {
129
22
  client: WazoWebRTCClient;
130
23
 
131
24
  phone: WebRTCPhone | null | undefined;
@@ -228,7 +121,7 @@ class Phone extends Emitter implements IPhone {
228
121
  super();
229
122
  // Sugar syntax for `Wazo.Phone.EVENT_NAME`
230
123
  Object.keys(PHONE_EVENTS).forEach((key: string) => {
231
- // @ts-ignore
124
+ // @ts-ignore: keys
232
125
  this[key] = PHONE_EVENTS[key];
233
126
  });
234
127
  this.SessionState = SessionState;
@@ -435,14 +328,14 @@ class Phone extends Emitter implements IPhone {
435
328
  return this.phone ? this.phone.stopNetworkMonitoring(callSession) : null;
436
329
  }
437
330
 
438
- getSipSessionId(sipSession: Invitation | Inviter): string | null | undefined {
331
+ getSipSessionId(sipSession: WazoSession): string | null | undefined {
439
332
  if (!sipSession || !this.phone) {
440
333
  return null;
441
334
  }
442
335
  return this.phone.getSipSessionId(sipSession);
443
336
  }
444
337
 
445
- sendMessage(body: string, sipSession?: Inviter | Invitation, contentType = 'text/plain'): void {
338
+ sendMessage(body: string, sipSession?: WazoSession, contentType = 'text/plain'): void {
446
339
  const toSipSession = sipSession || this.getCurrentSipSession();
447
340
 
448
341
  if (!toSipSession || !this.phone) {
@@ -452,14 +345,14 @@ class Phone extends Emitter implements IPhone {
452
345
  this.phone.sendMessage(toSipSession, body, contentType);
453
346
  }
454
347
 
455
- sendChat(content: string, sipSession?: Inviter | Invitation): void {
348
+ sendChat(content: string, sipSession?: WazoSession): void {
456
349
  this.sendMessage(JSON.stringify({
457
350
  type: MESSAGE_TYPE_CHAT,
458
351
  content,
459
352
  }), sipSession, 'application/json');
460
353
  }
461
354
 
462
- sendSignal(content: any, sipSession?: Inviter | Invitation): void {
355
+ sendSignal(content: any, sipSession?: WazoSession): void {
463
356
  this.sendMessage(JSON.stringify({
464
357
  type: MESSAGE_TYPE_SIGNAL,
465
358
  content,
@@ -552,7 +445,7 @@ class Phone extends Emitter implements IPhone {
552
445
  return this.phone ? this.phone.hasAVideoTrack(callSession) : false;
553
446
  }
554
447
 
555
- getCurrentSipSession(): Invitation | Inviter | null {
448
+ getCurrentSipSession(): WazoSession | null {
556
449
  return this.phone?.currentSipSession || null;
557
450
  }
558
451
 
@@ -1,6 +1,6 @@
1
1
  import type Session from '../domain/Session';
2
2
  import WazoWebSocketClient, * as WebSocketClient from '../websocket-client';
3
- import Emitter, { IEmitter } from '../utils/Emitter';
3
+ import Emitter from '../utils/Emitter';
4
4
  import IssueReporter from '../service/IssueReporter';
5
5
  import { obfuscateToken } from '../utils/string';
6
6
 
@@ -11,23 +11,7 @@ const {
11
11
  const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
12
12
  const logger = IssueReporter.loggerFor('simple-ws-client');
13
13
 
14
- export interface IWebsocket extends IEmitter {
15
- ws: WazoWebSocketClient | null | undefined;
16
- eventLists: string[];
17
-
18
- CONFERENCE_USER_PARTICIPANT_JOINED: string;
19
- CONFERENCE_USER_PARTICIPANT_LEFT: string;
20
- MEETING_USER_PARTICIPANT_JOINED: string;
21
- MEETING_USER_PARTICIPANT_LEFT: string;
22
- CALL_CREATED: string;
23
-
24
- open: (host: string, session: Session) => void;
25
- updateToken: (token: string) => void;
26
- isOpen: () => boolean;
27
- close: (force?: boolean) => void;
28
- }
29
-
30
- class Websocket extends Emitter implements IWebsocket {
14
+ class Websocket extends Emitter {
31
15
  ws: WazoWebSocketClient | null | undefined;
32
16
 
33
17
  eventLists: string[];
@@ -46,11 +30,11 @@ class Websocket extends Emitter implements IWebsocket {
46
30
  super();
47
31
  // Sugar syntax for `Wazo.WebSocket.EVENT_NAME`
48
32
  Object.keys(OTHER_EVENTS).forEach(key => {
49
- // @ts-ignore
33
+ // @ts-ignore: keys
50
34
  this[key] = OTHER_EVENTS[key];
51
35
  });
52
36
  Object.keys(SOCKET_EVENTS).forEach(key => {
53
- // @ts-ignore
37
+ // @ts-ignore: keys
54
38
  this[key] = SOCKET_EVENTS[key];
55
39
  });
56
40
  this.eventLists = WazoWebSocketClient.eventLists;
@@ -1,11 +1,12 @@
1
1
  /* global window */
2
- import Auth, { IAuth, InvalidSubscription, InvalidAuthorization, NoTenantIdError, NoDomainNameError } from './Auth';
3
- import Phone, { IPhone } from './Phone';
4
- import Websocket, { IWebsocket } from './Websocket';
2
+ import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError, NoDomainNameError } from './Auth';
3
+ import Phone from './Phone';
4
+ import Websocket from './Websocket';
5
5
  import Room from './room/Room';
6
6
  import SipRoom from './room/SipRoom';
7
7
  import RemoteParticipant from './room/RemoteParticipant';
8
8
  import LocalParticipant from './room/LocalParticipant';
9
+ import Participant from './room/Participant';
9
10
  import Stream from './room/Stream';
10
11
  import Directory from './Directory';
11
12
  import Configuration from './Configuration';
@@ -40,13 +41,14 @@ import Meeting from '../domain/Meeting';
40
41
  import Checker from '../checker/Checker';
41
42
 
42
43
  const Wazo = {
43
- Auth: Auth as IAuth,
44
- Phone: Phone as IPhone,
45
- Websocket: Websocket as IWebsocket,
44
+ Auth,
45
+ Phone,
46
+ Websocket,
46
47
  Room,
47
48
  SipRoom,
48
49
  RemoteParticipant,
49
50
  LocalParticipant,
51
+ Participant,
50
52
  Stream,
51
53
  createLocalVideoStream,
52
54
  createLocalAudioStream,
@@ -138,7 +140,6 @@ const Wazo = {
138
140
  };
139
141
 
140
142
  if (window) {
141
- // @ts-ignore
142
143
  window.Wazo = Wazo;
143
144
  }
144
145
 
@@ -4,6 +4,7 @@ import Phone from '../Phone';
4
4
  import Room, { SIGNAL_TYPE_PARTICIPANT_UPDATE } from './Room';
5
5
  import Contact from '../../domain/Contact';
6
6
  import getApiClient from '../../service/getApiClient';
7
+ import Stream from './Stream';
7
8
 
8
9
  const logger = IssueReporter.loggerFor('room');
9
10
 
@@ -27,9 +28,9 @@ class Participant extends Emitter {
27
28
 
28
29
  isTalking: boolean;
29
30
 
30
- streams: any[];
31
+ streams: Stream[];
31
32
 
32
- videoStreams: any[];
33
+ videoStreams: Stream[];
33
34
 
34
35
  audioMuted: boolean;
35
36
 
@@ -371,7 +372,7 @@ class Participant extends Emitter {
371
372
  });
372
373
  }
373
374
 
374
- resetStreams(streams: any[]) {
375
+ resetStreams(streams: Stream[]) {
375
376
  this.streams = streams;
376
377
  this.videoStreams = streams;
377
378
  }
@@ -1,6 +1,6 @@
1
1
  import type { Message } from 'sip.js/lib/api/message';
2
2
  import sdpParser from 'sdp-transform';
3
- import { Invitation, Inviter } from 'sip.js';
3
+ import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
4
4
  import type CallSession from '../../domain/CallSession';
5
5
  import getApiClient from '../../service/getApiClient';
6
6
  import Emitter from '../../utils/Emitter';
@@ -9,11 +9,21 @@ import Participant, { RawParticipant } from './Participant';
9
9
  import RemoteParticipant from './RemoteParticipant';
10
10
  import IssueReporter from '../../service/IssueReporter';
11
11
  import LocalParticipant from './LocalParticipant';
12
+ import { PeerConnection, WazoSession } from '../../domain/types';
12
13
 
13
14
  export const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
14
15
  export const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
15
16
  const logger = IssueReporter.loggerFor('sdk-room');
16
17
 
18
+ type ConnectArgs = {
19
+ extension: string;
20
+ constraints: Record<string, any>;
21
+ audioOnly?: boolean;
22
+ extra?: Record<string, any>;
23
+ room: Room;
24
+ meeting: any;
25
+ };
26
+
17
27
  class Room extends Emitter {
18
28
  callSession: CallSession | null | undefined;
19
29
 
@@ -31,13 +41,13 @@ class Room extends Emitter {
31
41
 
32
42
  connected: boolean;
33
43
 
34
- localParticipant: Participant | null | undefined;
44
+ localParticipant: LocalParticipant | null | undefined;
35
45
 
36
46
  _callIdStreamIdMap: Record<string, any>;
37
47
 
38
- _unassociatedVideoStreams: Record<string, any>;
48
+ _unassociatedVideoStreams: Record<string, MediaStream>;
39
49
 
40
- _unassociatedParticipants: Record<string, any>;
50
+ _unassociatedParticipants: Record<string, Participant>;
41
51
 
42
52
  _boundOnParticipantJoined: (...args: Array<any>) => any;
43
53
 
@@ -53,12 +63,12 @@ class Room extends Emitter {
53
63
 
54
64
  _boundOnReinvite: (...args: Array<any>) => any;
55
65
 
56
- audioStream: any | null | undefined;
66
+ audioStream: MediaStream | null | undefined;
57
67
 
58
68
  extra: Record<string, any>;
59
69
 
60
70
  // video tag representing the room audio stream
61
- roomAudioElement: any;
71
+ roomAudioElement: HTMLAudioElement;
62
72
 
63
73
  CONFERENCE_USER_PARTICIPANT_JOINED: string;
64
74
 
@@ -170,7 +180,7 @@ class Room extends Emitter {
170
180
  extra,
171
181
  room,
172
182
  meeting,
173
- }: Record<string, any>) {
183
+ }: ConnectArgs) {
174
184
  logger.info('connecting to room', {
175
185
  extension,
176
186
  audioOnly,
@@ -190,7 +200,7 @@ class Room extends Emitter {
190
200
  // Call_created is triggered before call_accepted, so we have to listen for it here.
191
201
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({
192
202
  data,
193
- }) => {
203
+ }: { data: Record<string, any> }) => {
194
204
  logger.info('room call received via WS', {
195
205
  callId: data.call_id,
196
206
  });
@@ -200,8 +210,9 @@ class Room extends Emitter {
200
210
  }
201
211
  });
202
212
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
213
+ // @ts-fix: heads up: added an extra `null` here
203
214
  // eslint-disable-next-line no-param-reassign
204
- room = new Room(callSession as CallSession, extension, null, null, extra);
215
+ room = new Room(callSession as CallSession, extension, null, null, null, extra);
205
216
  // Wait for the call to be accepted
206
217
  await new Promise((resolve, reject) => {
207
218
  Wazo.Phone.once(Wazo.Phone.ON_CALL_ACCEPTED, resolve);
@@ -226,8 +237,8 @@ class Room extends Emitter {
226
237
  });
227
238
 
228
239
  if (conference) {
229
- room.setSourceId(conference.sourceId);
230
- room.setName(conference.name);
240
+ room.setSourceId(parseInt(`${conference.sourceId}`, 10));
241
+ room.setName(`${conference.name}`);
231
242
  }
232
243
  } else if (meeting) {
233
244
  logger.info('Already connected to meeting', {
@@ -467,8 +478,7 @@ class Room extends Emitter {
467
478
  }
468
479
 
469
480
  // Retrieve mapping
470
- // @ts-ignore
471
- Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.on('setDescription', ({
481
+ (Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler as SessionDescriptionHandler & { on: (input: string, options?: Record<string, any>) => void })?.on('setDescription', ({
472
482
  type,
473
483
  sdp: rawSdp,
474
484
  }: any) => {
@@ -486,7 +496,7 @@ class Room extends Emitter {
486
496
  this.audioStream = stream;
487
497
 
488
498
  if (!this.roomAudioElement) {
489
- const sessionId = Wazo.Phone.phone?.getSipSessionId(Wazo.Phone.phone?.currentSipSession as Inviter | Invitation);
499
+ const sessionId = Wazo.Phone.phone?.getSipSessionId(Wazo.Phone.phone?.currentSipSession as WazoSession);
490
500
  this.roomAudioElement = Wazo.Phone.phone?.createAudioElementFor(sessionId as string);
491
501
  this.roomAudioElement.srcObject = stream;
492
502
  } else {
@@ -546,13 +556,11 @@ class Room extends Emitter {
546
556
 
547
557
  _mapMsid(rawSdp: string) {
548
558
  const sdp = sdpParser.parse(rawSdp);
549
- const labelMsidArray = sdp.media.filter((media: any) => !!media.label).map(({
550
- label,
551
- msid,
552
- }: any) => ({
559
+ // @ts-ignore: Property 'label' does not exist
560
+ const labelMsidArray = sdp.media.filter((media) => !!media.label).map(({ label, msid }) => ({
553
561
  label: String(label),
554
- streamId: msid.split(' ')[0],
555
- trackId: msid.split(' ')[1],
562
+ streamId: msid?.split(' ')[0],
563
+ trackId: msid?.split(' ')[1],
556
564
  }));
557
565
  labelMsidArray.forEach(({
558
566
  label,
@@ -583,21 +591,19 @@ class Room extends Emitter {
583
591
  Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
584
592
  Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
585
593
  Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
586
- [this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
594
+ [this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args: any[]) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
587
595
  }
588
596
 
589
- _onMessage(message: Message): Record<string, any> | null | undefined {
590
- // @ts-ignore
597
+ _onMessage(message: Message & { method?: string, body?: string }): Record<string, any> | null | undefined {
591
598
  if (message.method !== 'MESSAGE') {
592
599
  return null;
593
600
  }
594
601
 
595
- let body: any;
602
+ let body;
596
603
 
597
604
  try {
598
- // @ts-ignore
599
- body = JSON.parse(message.body);
600
- } catch (e: any) {
605
+ body = JSON.parse(message.body as string);
606
+ } catch (e) {
601
607
  return null;
602
608
  }
603
609
 
@@ -731,7 +737,7 @@ class Room extends Emitter {
731
737
  });
732
738
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
733
739
  }
734
- } catch (e: any) {
740
+ } catch (e) {
735
741
  logger.error('room participants fetching, error', e);
736
742
  }
737
743
 
@@ -744,7 +750,7 @@ class Room extends Emitter {
744
750
  return isMe && item.call_id ? new Wazo.LocalParticipant(this, item, this.extra) : new Wazo.RemoteParticipant(this, item);
745
751
  });
746
752
  this.participants = participants;
747
- const localParticipant = participants.find((someParticipant: any) => someParticipant instanceof Wazo.LocalParticipant);
753
+ const localParticipant = participants.find((someParticipant: Participant) => someParticipant instanceof Wazo.LocalParticipant);
748
754
 
749
755
  if (!this.localParticipant && localParticipant) {
750
756
  this._onLocalParticipantJoined(localParticipant);
@@ -839,10 +845,10 @@ class Room extends Emitter {
839
845
  trackId,
840
846
  streamId,
841
847
  } = this._callIdStreamIdMap[newParticipant.callId] || {};
842
- // @ts-ignore
843
- const pc = Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.peerConnection;
848
+
849
+ const pc = (Wazo.Phone.phone?.currentSipSession?.sessionDescriptionHandler as SessionDescriptionHandler)?.peerConnection as PeerConnection;
844
850
  // Can't use `getReceivers` here because on FF we make the mapping based on the streamId
845
- const stream = pc.getRemoteStreams().find((someStream: any) => someStream.id === streamId || someStream.getTracks().some((track: any) => track.id === trackId));
851
+ const stream = pc.getRemoteStreams().find(someStream => someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
846
852
 
847
853
  if (update === 'downgrade') {
848
854
  newParticipant.resetStreams([]);
@@ -875,15 +881,17 @@ class Room extends Emitter {
875
881
 
876
882
  const streamId = this._getStreamIdFrTrackId(trackId);
877
883
 
878
- const key: any = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
884
+ const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
879
885
 
880
- const stream = this._unassociatedVideoStreams[key];
886
+ const stream = key ? this._unassociatedVideoStreams[key] : null;
881
887
 
882
888
  if (stream) {
883
889
  // Try to associate stream
884
890
  this._associateStreamTo(stream, participant);
885
891
 
886
- delete this._unassociatedVideoStreams[key];
892
+ if (key) {
893
+ delete this._unassociatedVideoStreams[key];
894
+ }
887
895
  delete this._unassociatedParticipants[participant.callId];
888
896
  }
889
897
  }
@@ -909,7 +917,7 @@ class Room extends Emitter {
909
917
  return mapping ? mapping.streamId : null;
910
918
  }
911
919
 
912
- _associateStreamTo(rawStream: any, participant: Participant) {
920
+ _associateStreamTo(rawStream: MediaStream, participant: Participant) {
913
921
  const stream = new Wazo.Stream(rawStream, participant);
914
922
  participant.streams.push(stream);
915
923
  participant.videoStreams.push(stream);
@@ -1,9 +1,9 @@
1
- import { Invitation, Inviter } from 'sip.js';
2
1
  import type { Message } from 'sip.js/lib/api/message';
3
2
  import CallSession from '../../domain/CallSession';
4
3
  import IssueReporter from '../../service/IssueReporter';
5
4
  import Wazo from '../index';
6
5
  import Room from './Room';
6
+ import { WazoSession } from '../../domain/types';
7
7
 
8
8
  const logger = IssueReporter.loggerFor('sdk-sip-room');
9
9
 
@@ -54,7 +54,7 @@ class SipRoom extends Room {
54
54
  }
55
55
 
56
56
  getLocalGuestName(): string | null {
57
- // @ts-ignore
57
+ // @ts-ignore: private
58
58
  return Wazo.Phone.phone?.client.userAgent?.options.displayName || null;
59
59
  }
60
60
 
@@ -65,7 +65,7 @@ class SipRoom extends Room {
65
65
  Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
66
66
  Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
67
67
  Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
68
- [this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
68
+ [this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args: any[]) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
69
69
  }
70
70
 
71
71
  _onMessage(message: Message): Record<string, any> | null | undefined {
@@ -156,7 +156,7 @@ class SipRoom extends Room {
156
156
  }
157
157
 
158
158
  _getCurrentSipCallIs() {
159
- return Wazo.Phone.getSipSessionId(Wazo.Phone.phone?.currentSipSession as Invitation | Inviter);
159
+ return Wazo.Phone.getSipSessionId(Wazo.Phone.phone?.currentSipSession as WazoSession);
160
160
  }
161
161
 
162
162
  }
@@ -9,7 +9,7 @@ class Stream {
9
9
 
10
10
  participant: Participant | undefined;
11
11
 
12
- static detachStream(stream: any) {
12
+ static detachStream(stream: MediaStream) {
13
13
  stream.getTracks()
14
14
  .filter((track: MediaStreamTrack) => track.enabled)
15
15
  .forEach((track: MediaStreamTrack) => track.stop());
@@ -34,9 +34,8 @@ class Stream {
34
34
 
35
35
  element.onloadedmetadata = () => {
36
36
  const tracks = this.htmlStream ? this.htmlStream.getVideoTracks() : [];
37
- tracks.forEach(track => {
37
+ tracks.forEach((track: MediaStreamTrack & { loaded?: boolean }) => {
38
38
  track.enabled = true;
39
- // @ts-ignore
40
39
  track.loaded = true;
41
40
  });
42
41
  };
@@ -26,8 +26,7 @@ describe('Participant', () => {
26
26
  const room = new Room();
27
27
  room.setMeetingUuid(meetingUuid);
28
28
  const banMeetingParticipant = jest.fn();
29
- // @ts-expect-error
30
- getApiClient.mockImplementation(() => ({
29
+ (getApiClient as any).mockImplementation(() => ({
31
30
  calld: {
32
31
  banMeetingParticipant,
33
32
  },
@@ -52,8 +51,7 @@ describe('Participant', () => {
52
51
  const room = new Room();
53
52
  room.setMeetingUuid(meetingUuid);
54
53
  const banMeetingParticipant = jest.fn();
55
- // @ts-expect-error
56
- getApiClient.mockImplementation(() => ({
54
+ (getApiClient as any).mockImplementation(() => ({
57
55
  calld: {
58
56
  banMeetingParticipant,
59
57
  },
@@ -1,14 +1,15 @@
1
1
  // Using directly Wazo to avoid issues with require cycle
2
2
  import Wazo from '../../index';
3
+ import { RawParticipant } from '../Participant';
4
+ import Room from '../Room';
3
5
 
4
6
  describe('RemoteParticipant', () => {
5
7
  it('should fall back on number when name is <unknown>', () => {
6
8
  const number = '1234';
7
- // @ts-expect-error
8
- const participant = new Wazo.RemoteParticipant(null, {
9
+ const participant = new Wazo.RemoteParticipant({} as Room, {
9
10
  caller_id_name: '<unknown>',
10
11
  caller_id_number: number,
11
- });
12
+ } as RawParticipant);
12
13
  expect(participant.name).toEqual(number);
13
14
  });
14
15
  });
@@ -0,0 +1 @@
1
+ declare module '@wazo/sdk';
@@ -59,7 +59,7 @@ const getDisplayableNumber = (rawNumber: string, country: string, asYouType = fa
59
59
 
60
60
  const parsePhoneNumber = (phoneNumber: string): string => phoneNumber.replace(EXTRA_CHAR_REGEXP, '');
61
61
 
62
- const getCallableNumber = (number: string, country: string | null | undefined): string | null | undefined => {
62
+ const getCallableNumber = (number: string, country?: string | null): string | null | undefined => {
63
63
  try {
64
64
  if (country) {
65
65
  return getDisplayableNumber(number, country).replace(EXTRA_CHAR_REGEXP, '');
@@ -44,17 +44,11 @@ describe('getCallableNumber', () => {
44
44
  expect(getCallableNumber('9000', 'US')).toBe('9000');
45
45
  });
46
46
  it('works without a country', () => {
47
- // @ts-expect-error
48
47
  expect(getCallableNumber('06 75 45')).toBe('067545');
49
- // @ts-expect-error
50
48
  expect(getCallableNumber('067-545')).toBe('067545');
51
- // @ts-expect-error
52
49
  expect(getCallableNumber('8008')).toBe('8008');
53
- // @ts-expect-error
54
50
  expect(getCallableNumber('80.08')).toBe('8008');
55
- // @ts-expect-error
56
51
  expect(getCallableNumber('*10')).toBe('*10');
57
- // @ts-expect-error
58
52
  expect(getCallableNumber('9000')).toBe('9000');
59
53
  });
60
54
  });