@wazo/sdk 0.37.0 → 0.37.4

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 (144) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +91 -23
  3. package/esm/__tests__/web-rtc-client.test.js +165 -56
  4. package/esm/api/agentd.js +7 -1
  5. package/esm/api/amid.js +7 -1
  6. package/esm/api/application.js +7 -1
  7. package/esm/api/auth.js +7 -1
  8. package/esm/api/call-logd.js +17 -23
  9. package/esm/api/calld.js +10 -18
  10. package/esm/api/chatd.js +7 -1
  11. package/esm/api/confd.js +78 -1
  12. package/esm/api/ctid-ng.js +7 -1
  13. package/esm/api/dird.js +7 -1
  14. package/esm/api/webhookd.js +7 -1
  15. package/esm/api-client.js +91 -23
  16. package/esm/checker/Checker.js +169 -56
  17. package/esm/checker/checks/aor.js +91 -23
  18. package/esm/checker/checks/api.js +91 -23
  19. package/esm/checker/checks/index.js +169 -56
  20. package/esm/checker/checks/wazo-websocket.js +11 -1
  21. package/esm/checker/checks/webrtc-transport.js +165 -56
  22. package/esm/checker/checks/webrtc.js +165 -56
  23. package/esm/domain/AdHocAPIConference.js +1722 -1654
  24. package/esm/domain/CallLog.js +10 -22
  25. package/esm/domain/CallSession.js +1 -18
  26. package/esm/domain/Features.js +91 -23
  27. package/esm/domain/IndirectTransfer.js +0 -17
  28. package/esm/domain/Meeting.js +71 -0
  29. package/esm/domain/Phone/CTIPhone.js +98 -26
  30. package/esm/domain/Phone/Phone.js +0 -17
  31. package/esm/domain/Phone/WebRTCPhone.js +47 -27
  32. package/esm/domain/Room.js +0 -17
  33. package/esm/domain/SwitchboardCall.js +0 -17
  34. package/esm/domain/__tests__/CallLog.test.js +10 -22
  35. package/esm/domain/__tests__/CallSession.test.js +1 -18
  36. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
  37. package/esm/domain/__tests__/Room.test.js +1 -18
  38. package/esm/index.js +3880 -3111
  39. package/esm/lib/WazoSessionDescriptionHandler.js +24 -10
  40. package/esm/service/CallApi.js +91 -23
  41. package/esm/service/IssueReporter.js +7 -1
  42. package/esm/service/__tests__/IssueReporter.test.js +9 -1
  43. package/esm/service/getApiClient.js +91 -23
  44. package/esm/simple/Auth.js +1126 -360
  45. package/esm/simple/Configuration.js +1126 -360
  46. package/esm/simple/Directory.js +91 -23
  47. package/esm/simple/Phone.js +3724 -2958
  48. package/esm/simple/Websocket.js +13 -1
  49. package/esm/simple/index.js +1128 -362
  50. package/esm/simple/room/LocalParticipant.js +1097 -331
  51. package/esm/simple/room/Participant.js +1097 -331
  52. package/esm/simple/room/RemoteParticipant.js +1097 -331
  53. package/esm/simple/room/Room.js +1097 -331
  54. package/esm/simple/room/SipRoom.js +12996 -0
  55. package/esm/simple/room/Stream.js +1128 -362
  56. package/esm/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
  57. package/esm/simple/utils.js +1128 -362
  58. package/esm/utils/__tests__/api-requester.test.js +7 -1
  59. package/esm/utils/api-requester.js +7 -1
  60. package/esm/web-rtc-client.js +165 -56
  61. package/esm/websocket-client.js +12 -2
  62. package/lib/__tests__/api-client.test.js +91 -23
  63. package/lib/__tests__/web-rtc-client.test.js +165 -56
  64. package/lib/api/agentd.js +7 -1
  65. package/lib/api/amid.js +7 -1
  66. package/lib/api/application.js +7 -1
  67. package/lib/api/auth.js +7 -1
  68. package/lib/api/call-logd.js +17 -23
  69. package/lib/api/calld.js +10 -18
  70. package/lib/api/chatd.js +7 -1
  71. package/lib/api/confd.js +78 -1
  72. package/lib/api/ctid-ng.js +7 -1
  73. package/lib/api/dird.js +7 -1
  74. package/lib/api/webhookd.js +7 -1
  75. package/lib/api-client.js +91 -23
  76. package/lib/checker/Checker.js +169 -56
  77. package/lib/checker/checks/aor.js +91 -23
  78. package/lib/checker/checks/api.js +91 -23
  79. package/lib/checker/checks/index.js +169 -56
  80. package/lib/checker/checks/wazo-websocket.js +11 -1
  81. package/lib/checker/checks/webrtc-transport.js +165 -56
  82. package/lib/checker/checks/webrtc.js +165 -56
  83. package/lib/domain/AdHocAPIConference.js +1722 -1654
  84. package/lib/domain/CallLog.js +10 -22
  85. package/lib/domain/CallSession.js +1 -18
  86. package/lib/domain/Features.js +91 -23
  87. package/lib/domain/IndirectTransfer.js +0 -17
  88. package/lib/domain/Meeting.js +73 -0
  89. package/lib/domain/Phone/CTIPhone.js +98 -26
  90. package/lib/domain/Phone/Phone.js +0 -16
  91. package/lib/domain/Phone/WebRTCPhone.js +47 -27
  92. package/lib/domain/Room.js +0 -17
  93. package/lib/domain/SwitchboardCall.js +0 -17
  94. package/lib/domain/__tests__/CallLog.test.js +10 -22
  95. package/lib/domain/__tests__/CallSession.test.js +1 -18
  96. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
  97. package/lib/domain/__tests__/Room.test.js +1 -18
  98. package/lib/index.js +3880 -3111
  99. package/lib/lib/WazoSessionDescriptionHandler.js +24 -10
  100. package/lib/service/CallApi.js +91 -23
  101. package/lib/service/IssueReporter.js +7 -1
  102. package/lib/service/__tests__/IssueReporter.test.js +9 -1
  103. package/lib/service/getApiClient.js +91 -23
  104. package/lib/simple/Auth.js +1126 -360
  105. package/lib/simple/Configuration.js +1126 -360
  106. package/lib/simple/Directory.js +91 -23
  107. package/lib/simple/Phone.js +3724 -2958
  108. package/lib/simple/Websocket.js +13 -1
  109. package/lib/simple/index.js +1128 -362
  110. package/lib/simple/room/LocalParticipant.js +1097 -331
  111. package/lib/simple/room/Participant.js +1097 -331
  112. package/lib/simple/room/RemoteParticipant.js +1097 -331
  113. package/lib/simple/room/Room.js +1097 -331
  114. package/lib/simple/room/SipRoom.js +13006 -0
  115. package/lib/simple/room/Stream.js +1128 -362
  116. package/lib/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
  117. package/lib/simple/utils.js +1128 -362
  118. package/lib/utils/__tests__/api-requester.test.js +7 -1
  119. package/lib/utils/api-requester.js +7 -1
  120. package/lib/web-rtc-client.js +165 -56
  121. package/lib/websocket-client.js +13 -1
  122. package/package.json +1 -1
  123. package/src/api/calld.js +3 -0
  124. package/src/api/confd.js +13 -0
  125. package/src/domain/CallLog.js +10 -22
  126. package/src/domain/CallSession.js +1 -2
  127. package/src/domain/Meeting.js +59 -0
  128. package/src/domain/Phone/CTIPhone.js +6 -2
  129. package/src/domain/Phone/Phone.js +2 -0
  130. package/src/domain/Phone/WebRTCPhone.js +22 -8
  131. package/src/index.js +6 -0
  132. package/src/lib/WazoSessionDescriptionHandler.js +17 -9
  133. package/src/service/IssueReporter.js +7 -1
  134. package/src/service/__tests__/IssueReporter.test.js +2 -0
  135. package/src/simple/Phone.js +13 -4
  136. package/src/simple/index.js +8 -0
  137. package/src/simple/room/Participant.js +7 -0
  138. package/src/simple/room/Room.js +157 -79
  139. package/src/simple/room/SipRoom.js +147 -0
  140. package/src/simple/room/Stream.js +1 -3
  141. package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
  142. package/src/types/WebSocketMessage.js +21 -0
  143. package/src/web-rtc-client.js +57 -24
  144. package/src/websocket-client.js +4 -0
@@ -96,6 +96,7 @@ type WebRtcConfig = {
96
96
  heartbeatDelay: number,
97
97
  heartbeatTimeout: number,
98
98
  maxHeartbeats: number,
99
+ skipRegister: boolean,
99
100
  };
100
101
 
101
102
  // @see https://github.com/onsip/SIP.js/blob/master/src/Web/Simple.js
@@ -121,6 +122,7 @@ export default class WebRTCClient extends Emitter {
121
122
  statsIntervals: Object;
122
123
  sipSessions: { [string]: Session };
123
124
  conferences: { [string]: boolean };
125
+ skipRegister: boolean;
124
126
 
125
127
  // sugar
126
128
  ON_USER_AGENT: string;
@@ -159,6 +161,8 @@ export default class WebRTCClient extends Emitter {
159
161
  super();
160
162
  this.uaConfigOverrides = uaConfigOverrides;
161
163
  this.config = config;
164
+ this.skipRegister = config.skipRegister;
165
+
162
166
  this._buildConfig(config, session).then((newConfig: WebRtcConfig) => {
163
167
  this.config = newConfig;
164
168
  this.userAgent = this.createUserAgent(uaConfigOverrides);
@@ -286,14 +290,22 @@ export default class WebRTCClient extends Emitter {
286
290
  }
287
291
 
288
292
  register(tries: number = 0): Promise<any> {
289
- logger.info('sdk webrtc registering...', {
293
+ const logInfo = {
290
294
  userAgent: !!this.userAgent,
291
295
  registered: this.isRegistered(),
292
296
  connectionPromise: !!this.connectionPromise,
293
297
  registerer: !!this.registerer,
294
298
  waiting: this.registerer && this.registerer.waiting,
295
299
  tries,
296
- });
300
+ skipRegister: this.skipRegister,
301
+ };
302
+
303
+ if (this.skipRegister) {
304
+ logger.info('sdk webrtc skip register...', logInfo);
305
+ return Promise.resolve();
306
+ }
307
+
308
+ logger.info('sdk webrtc registering...', logInfo);
297
309
 
298
310
  if (!this.userAgent) {
299
311
  logger.info('sdk webrtc recreating User Agent');
@@ -624,12 +636,18 @@ export default class WebRTCClient extends Emitter {
624
636
  }
625
637
 
626
638
  if (pc.getSenders) {
639
+ if (!pc.getSenders().length) {
640
+ return false;
641
+ }
627
642
  pc.getSenders().forEach(sender => {
628
643
  if (sender && sender.track && sender.track.kind === 'audio') {
629
644
  muted = muted && !sender.track.enabled;
630
645
  }
631
646
  });
632
647
  } else {
648
+ if (!pc.getLocalStreams().length) {
649
+ return false;
650
+ }
633
651
  pc.getLocalStreams().forEach(stream => {
634
652
  stream.getAudioTracks().forEach(track => {
635
653
  muted = muted && !track.enabled;
@@ -686,6 +704,9 @@ export default class WebRTCClient extends Emitter {
686
704
  if (!this._isWeb()) {
687
705
  options.sessionDescriptionHandlerModifiers = [holdModifier];
688
706
  }
707
+ options.sessionDescriptionHandlerOptions = {
708
+ constraints: options.constraints,
709
+ };
689
710
 
690
711
  // Send re-INVITE
691
712
  return session.invite(options);
@@ -725,6 +746,9 @@ export default class WebRTCClient extends Emitter {
725
746
  // (eg: holdModifier)
726
747
  options.sessionDescriptionHandlerModifiers = [];
727
748
  }
749
+ options.sessionDescriptionHandlerOptions = {
750
+ constraints: options.constraints,
751
+ };
728
752
 
729
753
  // Send re-INVITE
730
754
  return session.invite(options);
@@ -907,7 +931,8 @@ export default class WebRTCClient extends Emitter {
907
931
  }
908
932
  const sdh = session.sessionDescriptionHandler;
909
933
  const pc = sdh.peerConnection;
910
- const localStream = this.getLocalStream(this.getSipSessionId(session));
934
+ const sessionId = this.getSipSessionId(session);
935
+ const localStream = this.getLocalStream(sessionId);
911
936
 
912
937
  // Release old video stream
913
938
  if (localStream) {
@@ -933,11 +958,8 @@ export default class WebRTCClient extends Emitter {
933
958
 
934
959
  // let's update the local stream
935
960
  this.eventEmitter.emit('onVideoInputChange', stream);
936
- try {
937
- await sdh.setLocalMediaStream(stream);
938
- } catch (_) {
939
- // Nothing to do
940
- }
961
+ this.setLocalMediaStream(sessionId, stream);
962
+
941
963
  return stream;
942
964
  });
943
965
  }
@@ -1239,9 +1261,11 @@ export default class WebRTCClient extends Emitter {
1239
1261
  remoteStream.removeTrack(track);
1240
1262
  });
1241
1263
 
1242
- pc.getReceivers().forEach(receiver => {
1243
- remoteStream.addTrack(receiver.track);
1244
- });
1264
+ if (pc.getReceivers) {
1265
+ pc.getReceivers().forEach(receiver => {
1266
+ remoteStream.addTrack(receiver.track);
1267
+ });
1268
+ }
1245
1269
  }
1246
1270
 
1247
1271
  getMediaConfiguration(enableVideo: boolean, conference: boolean = false, constraints: ?Object = null): Object {
@@ -1276,6 +1300,25 @@ export default class WebRTCClient extends Emitter {
1276
1300
  return sessionId in this.conferences;
1277
1301
  }
1278
1302
 
1303
+ createAudioElementFor(sessionId: string) {
1304
+ const audio: any = document.createElement('audio');
1305
+ audio.setAttribute('id', `audio-${sessionId}`);
1306
+
1307
+ if (audio.setSinkId && this.audioOutputDeviceId) {
1308
+ audio.setSinkId(this.audioOutputDeviceId);
1309
+ }
1310
+
1311
+ if (document.body) {
1312
+ document.body.appendChild(audio);
1313
+ }
1314
+ this.audioElements[sessionId] = audio;
1315
+
1316
+ audio.volume = this.audioOutputVolume;
1317
+ audio.autoplay = true;
1318
+
1319
+ return audio;
1320
+ }
1321
+
1279
1322
  _onTransportError() {
1280
1323
  this.eventEmitter.emit(TRANSPORT_ERROR);
1281
1324
  this.attemptReconnection();
@@ -1505,7 +1548,7 @@ export default class WebRTCClient extends Emitter {
1505
1548
  let hadRemoteVideo = false;
1506
1549
 
1507
1550
  // Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
1508
- // Becase when `onInvite` is called we already got the video track
1551
+ // Because when `onInvite` is called we already got the video track
1509
1552
  session.onInviteRequest = (request) => {
1510
1553
  hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
1511
1554
 
@@ -1580,20 +1623,10 @@ export default class WebRTCClient extends Emitter {
1580
1623
  const isConference = this.isConference(sessionId);
1581
1624
 
1582
1625
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
1583
- const audio: any = document.createElement('audio');
1584
- audio.setAttribute('id', `audio-${sessionId}`);
1585
-
1586
- if (audio.setSinkId && this.audioOutputDeviceId) {
1587
- audio.setSinkId(this.audioOutputDeviceId);
1588
- }
1589
-
1590
- if (document.body) {
1591
- document.body.appendChild(audio);
1592
- }
1593
- this.audioElements[sessionId] = audio;
1626
+ this.createAudioElementFor(sessionId);
1594
1627
  }
1595
1628
 
1596
- const audioElement = this.audioElements[this.getSipSessionId(session)];
1629
+ const audioElement = this.audioElements[sessionId];
1597
1630
  const stream = newStream || this.getRemoteStream(sessionId);
1598
1631
 
1599
1632
  if (!this._isWeb() || !stream) {
@@ -59,6 +59,8 @@ export const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_j
59
59
  export const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
60
60
  export const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
61
61
  export const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
62
+ export const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
63
+ export const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
62
64
  export const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
63
65
  export const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
64
66
  export const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
@@ -408,6 +410,8 @@ WebSocketClient.eventLists = [
408
410
  CHATD_USER_ROOM_CREATED,
409
411
  CONFERENCE_USER_PARTICIPANT_JOINED,
410
412
  CONFERENCE_USER_PARTICIPANT_LEFT,
413
+ MEETING_USER_PARTICIPANT_JOINED,
414
+ MEETING_USER_PARTICIPANT_LEFT,
411
415
  CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
412
416
  CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
413
417
  SWITCHBOARD_QUEUED_CALLS_UPDATED,