@wazo/sdk 0.37.23 → 0.37.24

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 (103) hide show
  1. package/dist/wazo-sdk.js +6 -6
  2. package/esm/__tests__/api-client.test.js +22 -17
  3. package/esm/__tests__/web-rtc-client.test.js +105 -100
  4. package/esm/api/amid.js +1 -1
  5. package/esm/api/call-logd.js +2 -2
  6. package/esm/api/confd.js +10 -5
  7. package/esm/api/ctid-ng.js +3 -3
  8. package/esm/api/dird.js +1 -1
  9. package/esm/api/webhookd.js +1 -1
  10. package/esm/api-client.js +22 -17
  11. package/esm/checker/Checker.js +130 -125
  12. package/esm/checker/checks/aor.js +22 -17
  13. package/esm/checker/checks/api.js +22 -17
  14. package/esm/checker/checks/index.js +120 -115
  15. package/esm/checker/checks/wazo-websocket.js +15 -15
  16. package/esm/checker/checks/webrtc-transport.js +105 -100
  17. package/esm/checker/checks/webrtc.js +105 -100
  18. package/esm/domain/AdHocAPIConference.js +22 -17
  19. package/esm/domain/CallLog.js +1 -1
  20. package/esm/domain/Contact.js +1 -1
  21. package/esm/domain/Features.js +22 -17
  22. package/esm/domain/Meeting.js +12 -5
  23. package/esm/domain/Phone/CTIPhone.js +36 -31
  24. package/esm/domain/Phone/WebRTCPhone.js +110 -87
  25. package/esm/domain/__tests__/CallLog.test.js +1 -1
  26. package/esm/domain/__tests__/Contact.test.js +1 -1
  27. package/esm/domain/__tests__/Meeting.test.js +144 -0
  28. package/esm/index.js +365 -337
  29. package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
  30. package/esm/service/CallApi.js +22 -17
  31. package/esm/service/IssueReporter.js +1 -1
  32. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  33. package/esm/service/getApiClient.js +22 -17
  34. package/esm/simple/Auth.js +355 -327
  35. package/esm/simple/Configuration.js +355 -327
  36. package/esm/simple/Directory.js +22 -17
  37. package/esm/simple/Phone.js +355 -327
  38. package/esm/simple/Websocket.js +17 -17
  39. package/esm/simple/index.js +359 -331
  40. package/esm/simple/room/LocalParticipant.js +359 -331
  41. package/esm/simple/room/Participant.js +359 -331
  42. package/esm/simple/room/RemoteParticipant.js +359 -331
  43. package/esm/simple/room/Room.js +360 -332
  44. package/esm/simple/room/SipRoom.js +359 -331
  45. package/esm/simple/room/Stream.js +359 -331
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +359 -331
  47. package/esm/simple/utils.js +359 -331
  48. package/esm/types/WebSocketMessage.js +1 -1
  49. package/esm/web-rtc-client.js +105 -100
  50. package/esm/websocket-client.js +15 -15
  51. package/lib/__tests__/api-client.test.js +22 -17
  52. package/lib/__tests__/web-rtc-client.test.js +105 -100
  53. package/lib/api/amid.js +1 -1
  54. package/lib/api/call-logd.js +2 -2
  55. package/lib/api/confd.js +10 -5
  56. package/lib/api/ctid-ng.js +3 -3
  57. package/lib/api/dird.js +1 -1
  58. package/lib/api/webhookd.js +1 -1
  59. package/lib/api-client.js +22 -17
  60. package/lib/checker/Checker.js +130 -125
  61. package/lib/checker/checks/aor.js +22 -17
  62. package/lib/checker/checks/api.js +22 -17
  63. package/lib/checker/checks/index.js +120 -115
  64. package/lib/checker/checks/wazo-websocket.js +15 -15
  65. package/lib/checker/checks/webrtc-transport.js +105 -100
  66. package/lib/checker/checks/webrtc.js +105 -100
  67. package/lib/domain/AdHocAPIConference.js +22 -17
  68. package/lib/domain/CallLog.js +1 -1
  69. package/lib/domain/Contact.js +1 -1
  70. package/lib/domain/Features.js +22 -17
  71. package/lib/domain/Meeting.js +16 -5
  72. package/lib/domain/Phone/CTIPhone.js +36 -31
  73. package/lib/domain/Phone/WebRTCPhone.js +110 -87
  74. package/lib/domain/__tests__/CallLog.test.js +1 -1
  75. package/lib/domain/__tests__/Contact.test.js +1 -1
  76. package/lib/domain/__tests__/Meeting.test.js +150 -0
  77. package/lib/index.js +365 -337
  78. package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
  79. package/lib/service/CallApi.js +22 -17
  80. package/lib/service/IssueReporter.js +1 -1
  81. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  82. package/lib/service/getApiClient.js +22 -17
  83. package/lib/simple/Auth.js +355 -327
  84. package/lib/simple/Configuration.js +355 -327
  85. package/lib/simple/Directory.js +22 -17
  86. package/lib/simple/Phone.js +355 -327
  87. package/lib/simple/Websocket.js +17 -17
  88. package/lib/simple/index.js +359 -331
  89. package/lib/simple/room/LocalParticipant.js +359 -331
  90. package/lib/simple/room/Participant.js +359 -331
  91. package/lib/simple/room/RemoteParticipant.js +359 -331
  92. package/lib/simple/room/Room.js +360 -332
  93. package/lib/simple/room/SipRoom.js +359 -331
  94. package/lib/simple/room/Stream.js +359 -331
  95. package/lib/simple/room/__tests__/RemoteParticipant.test.js +359 -331
  96. package/lib/simple/utils.js +359 -331
  97. package/lib/types/WebSocketMessage.js +2 -0
  98. package/lib/web-rtc-client.js +105 -100
  99. package/lib/websocket-client.js +15 -15
  100. package/package.json +1 -1
  101. package/src/domain/Meeting.js +12 -5
  102. package/src/domain/Phone/WebRTCPhone.js +24 -1
  103. package/src/domain/__tests__/Meeting.test.js +50 -0
@@ -401,7 +401,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
401
401
 
402
402
  /* */
403
403
 
404
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
404
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
405
405
 
406
406
  // Use a function here to be able to mock it in tests
407
407
  const realFetch = () => {
@@ -786,7 +786,7 @@ var IssueReporter$1 = new IssueReporter();
786
786
 
787
787
  /* global RTCSessionDescriptionInit, navigator */
788
788
 
789
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
789
+ const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
790
790
 
791
791
  //
792
792
 
@@ -828,7 +828,7 @@ BwIDAQAB
828
828
 
829
829
  //
830
830
 
831
- KEYUTIL.getKey(swarmPublicKey);
831
+ const swarmKey = KEYUTIL.getKey(swarmPublicKey);
832
832
 
833
833
  /* eslint-disable dot-notation */
834
834
 
@@ -849,15 +849,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
849
849
 
850
850
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
851
851
 
852
- IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
852
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
853
853
 
854
854
  /* */
855
855
 
856
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
856
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
857
857
 
858
858
  //
859
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
860
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
859
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
860
+ const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
861
861
 
862
862
  /* eslint-disable no-param-reassign */
863
863
 
@@ -943,7 +943,7 @@ const events = [
943
943
  ON_DISCONNECTED,
944
944
  ];
945
945
 
946
- const logger = IssueReporter$1.loggerFor('webrtc-phone');
946
+ const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
947
947
 
948
948
  class WebRTCPhone extends Emitter {
949
949
 
@@ -1016,7 +1016,7 @@ class WebRTCPhone extends Emitter {
1016
1016
  }).catch(error => {
1017
1017
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
1018
1018
  console.error('register error', error, error.message, error.stack);
1019
- logger.error('WebRTC register error', { message: error.message, stack: error.stack });
1019
+ logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
1020
1020
  });
1021
1021
  }
1022
1022
 
@@ -1031,7 +1031,7 @@ class WebRTCPhone extends Emitter {
1031
1031
  if (!this.client) {
1032
1032
  return;
1033
1033
  }
1034
- logger.info('WebRTC phone stop');
1034
+ logger$4.info('WebRTC phone stop');
1035
1035
  this.client.stop();
1036
1036
  }
1037
1037
 
@@ -1046,7 +1046,7 @@ class WebRTCPhone extends Emitter {
1046
1046
  async sendReinvite(callSession , constraints = null, conference = false,
1047
1047
  audioOnly = false, iceRestart = false) {
1048
1048
  const sipSession = this.findSipSession(callSession);
1049
- logger.info('WebRTC phone - send reinvite', {
1049
+ logger$4.info('WebRTC phone - send reinvite', {
1050
1050
  sessionId: sipSession ? sipSession.id : null,
1051
1051
  constraints,
1052
1052
  audioOnly,
@@ -1083,7 +1083,7 @@ class WebRTCPhone extends Emitter {
1083
1083
  }
1084
1084
 
1085
1085
  startHeartbeat() {
1086
- logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1086
+ logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1087
1087
  if (!this.client || this.client.hasHeartbeat()) {
1088
1088
  return;
1089
1089
  }
@@ -1092,7 +1092,7 @@ class WebRTCPhone extends Emitter {
1092
1092
  }
1093
1093
 
1094
1094
  stopHeartbeat() {
1095
- logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1095
+ logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1096
1096
  if (!this.client) {
1097
1097
  return;
1098
1098
  }
@@ -1109,7 +1109,7 @@ class WebRTCPhone extends Emitter {
1109
1109
  }
1110
1110
 
1111
1111
  reconnect() {
1112
- logger.info('WebRTC phone - reconnect', { client: !!this.client });
1112
+ logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
1113
1113
  if (!this.client) {
1114
1114
  return;
1115
1115
  }
@@ -1150,10 +1150,15 @@ class WebRTCPhone extends Emitter {
1150
1150
  return false;
1151
1151
  }
1152
1152
 
1153
- logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1153
+ logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1154
1154
 
1155
1155
  this.client.downgradeToAudio(sipSession);
1156
1156
 
1157
+ if (callSession) {
1158
+ callSession.cameraEnabled = false;
1159
+ this._updateCallSession(callSession);
1160
+ }
1161
+
1157
1162
  if (withMessage) {
1158
1163
  this._sendReinviteMessage(callSession, false);
1159
1164
  }
@@ -1168,7 +1173,7 @@ class WebRTCPhone extends Emitter {
1168
1173
  return Promise.resolve(false);
1169
1174
  }
1170
1175
 
1171
- logger.info('Upgrade to video', {
1176
+ logger$4.info('Upgrade to video', {
1172
1177
  id: callSession ? callSession.getId() : null,
1173
1178
  constraints,
1174
1179
  isConference,
@@ -1181,6 +1186,11 @@ class WebRTCPhone extends Emitter {
1181
1186
 
1182
1187
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
1183
1188
 
1189
+ if (callSession) {
1190
+ callSession.cameraEnabled = true;
1191
+ this._updateCallSession(callSession);
1192
+ }
1193
+
1184
1194
  // If no stream is returned, it means we have to reinvite
1185
1195
  if (!newStream) {
1186
1196
  return true;
@@ -1203,7 +1213,7 @@ class WebRTCPhone extends Emitter {
1203
1213
 
1204
1214
  _sendReinviteMessage(callSession , isUpgrade ) {
1205
1215
  const sipSession = this.findSipSession(callSession);
1206
- logger.info('Sending reinvite message', {
1216
+ logger$4.info('Sending reinvite message', {
1207
1217
  id: callSession ? callSession.getId() : null,
1208
1218
  isUpgrade,
1209
1219
  });
@@ -1229,7 +1239,7 @@ class WebRTCPhone extends Emitter {
1229
1239
  // Monkey patch to know when canceled with the CANCEL message
1230
1240
  const onCancel = sipSession._onCancel.bind(sipSession);
1231
1241
  sipSession._onCancel = (message ) => {
1232
- logger.trace('on sip session canceled', { callId: message.callId });
1242
+ logger$4.trace('on sip session canceled', { callId: message.callId });
1233
1243
 
1234
1244
  onCancel(message);
1235
1245
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -1257,13 +1267,13 @@ class WebRTCPhone extends Emitter {
1257
1267
  this.audioOutputVolume,
1258
1268
  );
1259
1269
  case SessionState.Terminating:
1260
- logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1270
+ logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1261
1271
 
1262
1272
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
1263
1273
 
1264
1274
  break;
1265
1275
  case SessionState.Terminated: {
1266
- logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1276
+ logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1267
1277
 
1268
1278
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
1269
1279
  const callSession = this._createCallSession(sipSession);
@@ -1285,7 +1295,7 @@ class WebRTCPhone extends Emitter {
1285
1295
  const [stream] = event.streams;
1286
1296
  const kind = event && event.track && event.track.kind;
1287
1297
 
1288
- logger.info('on track stream called on the peer connection', {
1298
+ logger$4.info('on track stream called on the peer connection', {
1289
1299
  callId: this.getSipSessionId(sipSession),
1290
1300
  streamId: stream ? stream.id : null,
1291
1301
  tracks: stream ? stream.getTracks() : null,
@@ -1305,7 +1315,7 @@ class WebRTCPhone extends Emitter {
1305
1315
  };
1306
1316
 
1307
1317
  peerConnection.onremovestream = event => {
1308
- logger.info('on remove stream called on the peer connection', {
1318
+ logger$4.info('on remove stream called on the peer connection', {
1309
1319
  id: event.stream.id,
1310
1320
  tracks: event.stream.getTracks(),
1311
1321
  });
@@ -1315,7 +1325,7 @@ class WebRTCPhone extends Emitter {
1315
1325
  }
1316
1326
 
1317
1327
  async startScreenSharing(constraints , callSession ) {
1318
- logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1328
+ logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1319
1329
 
1320
1330
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
1321
1331
  if (!screenShareStream) {
@@ -1355,7 +1365,7 @@ class WebRTCPhone extends Emitter {
1355
1365
  return;
1356
1366
  }
1357
1367
 
1358
- logger.info('WebRTC phone - stop screen sharing', {
1368
+ logger$4.info('WebRTC phone - stop screen sharing', {
1359
1369
  restoreLocalStream,
1360
1370
  });
1361
1371
 
@@ -1411,7 +1421,7 @@ class WebRTCPhone extends Emitter {
1411
1421
  const pc = this.client.getPeerConnection(sipSessionId);
1412
1422
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1413
1423
 
1414
- logger.info('WebRTC phone - on screensharing', {
1424
+ logger$4.info('WebRTC phone - on screensharing', {
1415
1425
  hadVideo,
1416
1426
  id: this.getSipSessionId(sipSession),
1417
1427
  screenTrack,
@@ -1419,7 +1429,7 @@ class WebRTCPhone extends Emitter {
1419
1429
 
1420
1430
  if (screenTrack) {
1421
1431
  screenTrack.onended = () => {
1422
- logger.info('WebRTC phone - on screenshare ended', {
1432
+ logger$4.info('WebRTC phone - on screenshare ended', {
1423
1433
  hadVideo,
1424
1434
  id: this.getSipSessionId(sipSession),
1425
1435
  screenTrack,
@@ -1450,7 +1460,7 @@ class WebRTCPhone extends Emitter {
1450
1460
  }
1451
1461
 
1452
1462
  _onCallAccepted(sipSession , cameraEnabled ) {
1453
- logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1463
+ logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1454
1464
 
1455
1465
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
1456
1466
  this.currentSipSession = sipSession;
@@ -1468,7 +1478,7 @@ class WebRTCPhone extends Emitter {
1468
1478
  }
1469
1479
 
1470
1480
  changeAudioDevice(id ) {
1471
- logger.info('WebRTC phone - change audio device', { deviceId: id });
1481
+ logger$4.info('WebRTC phone - change audio device', { deviceId: id });
1472
1482
  this.audioOutputDeviceId = id;
1473
1483
  this.client.changeAudioOutputDevice(id);
1474
1484
  }
@@ -1478,14 +1488,14 @@ class WebRTCPhone extends Emitter {
1478
1488
  }
1479
1489
 
1480
1490
  changeRingDevice(id ) {
1481
- logger.info('WebRTC phone - changing ring device', { id });
1491
+ logger$4.info('WebRTC phone - changing ring device', { id });
1482
1492
 
1483
1493
  this.audioRingDeviceId = id;
1484
1494
  }
1485
1495
 
1486
1496
  // volume is a value between 0 and 1
1487
1497
  changeAudioVolume(volume ) {
1488
- logger.info('WebRTC phone - changing audio volume', { volume });
1498
+ logger$4.info('WebRTC phone - changing audio volume', { volume });
1489
1499
 
1490
1500
  this.audioOutputVolume = volume;
1491
1501
  this.client.changeAudioOutputVolume(volume);
@@ -1493,31 +1503,31 @@ class WebRTCPhone extends Emitter {
1493
1503
 
1494
1504
  // volume is a value between 0 and 1
1495
1505
  changeRingVolume(volume ) {
1496
- logger.info('WebRTC phone - changing ring volume', { volume });
1506
+ logger$4.info('WebRTC phone - changing ring volume', { volume });
1497
1507
 
1498
1508
  this.audioRingVolume = volume;
1499
1509
  }
1500
1510
 
1501
1511
  changeAudioInputDevice(id ) {
1502
- logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
1512
+ logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
1503
1513
 
1504
1514
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
1505
1515
  }
1506
1516
 
1507
1517
  changeVideoInputDevice(id ) {
1508
- logger.info('WebRTC phone - change video input device', { deviceId: id });
1518
+ logger$4.info('WebRTC phone - change video input device', { deviceId: id });
1509
1519
 
1510
1520
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
1511
1521
  }
1512
1522
 
1513
1523
  changeSessionVideoInputDevice(id ) {
1514
- logger.info('WebRTC phone - change session video input device', { deviceId: id });
1524
+ logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
1515
1525
 
1516
1526
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
1517
1527
  }
1518
1528
 
1519
1529
  _onCallTerminated(sipSession ) {
1520
- logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1530
+ logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1521
1531
 
1522
1532
  const callSession = this._createCallSession(sipSession);
1523
1533
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -1551,7 +1561,7 @@ class WebRTCPhone extends Emitter {
1551
1561
  const hasIncomingCallSession = this.hasIncomingCallSession();
1552
1562
 
1553
1563
  // Re-trigger incoming call event for remaining incoming calls
1554
- logger.info('WebRTC phone - check to re-trigger incoming call', {
1564
+ logger$4.info('WebRTC phone - check to re-trigger incoming call', {
1555
1565
  sipId: sipSession.id,
1556
1566
  shouldRetrigger,
1557
1567
  hasIncomingCallSession,
@@ -1642,37 +1652,37 @@ class WebRTCPhone extends Emitter {
1642
1652
 
1643
1653
  // Deprecated
1644
1654
  getLocalStreamForCall(callSession ) {
1645
- logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1655
+ logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1646
1656
 
1647
1657
  return this.getLocalStream(callSession);
1648
1658
  }
1649
1659
 
1650
1660
  // Deprecated
1651
1661
  getRemoteStreamForCall(callSession ) {
1652
- logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1662
+ logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1653
1663
 
1654
1664
  return this.getRemoteVideoStream(callSession);
1655
1665
  }
1656
1666
 
1657
1667
  getRemoteStreamsForCall(callSession ) {
1658
- logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1668
+ logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1659
1669
 
1660
1670
  return this.getRemoteStream(callSession);
1661
1671
  }
1662
1672
 
1663
1673
  accept(callSession , cameraEnabled ) {
1664
- logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1674
+ logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1665
1675
  if (this.currentSipSession) {
1666
1676
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
1667
1677
  }
1668
1678
 
1669
1679
  if (!callSession) {
1670
- logger.warn('no CallSession to accept.');
1680
+ logger$4.warn('no CallSession to accept.');
1671
1681
  return Promise.resolve(null);
1672
1682
  }
1673
1683
 
1674
1684
  if (callSession.getId() in this.acceptedSessions) {
1675
- logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1685
+ logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1676
1686
  return Promise.resolve(callSession.sipCallId);
1677
1687
  }
1678
1688
 
@@ -1684,24 +1694,24 @@ class WebRTCPhone extends Emitter {
1684
1694
  const sipSession = this.client.getSipSession(callSession.getId());
1685
1695
  if (sipSession) {
1686
1696
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
1687
- logger.warn('Trying to answer a terminated sipSession.');
1697
+ logger$4.warn('Trying to answer a terminated sipSession.');
1688
1698
 
1689
1699
  return Promise.resolve(null);
1690
1700
  }
1691
1701
 
1692
- logger.info('accept call, session found', { sipId: sipSession.id });
1702
+ logger$4.info('accept call, session found', { sipId: sipSession.id });
1693
1703
 
1694
1704
  // $FlowFixMe
1695
1705
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
1696
1706
  return callSession.sipCallId;
1697
1707
  }).catch(e => {
1698
- logger.error(e);
1708
+ logger$4.error(e);
1699
1709
  this.endCurrentCall(callSession);
1700
1710
  throw e;
1701
1711
  });
1702
1712
  }
1703
1713
 
1704
- logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1714
+ logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1705
1715
 
1706
1716
  return Promise.resolve(null);
1707
1717
  }
@@ -1711,7 +1721,7 @@ class WebRTCPhone extends Emitter {
1711
1721
  }
1712
1722
 
1713
1723
  async reject(callSession ) {
1714
- logger.info('reject WebRTC called', { id: callSession.getId() });
1724
+ logger$4.info('reject WebRTC called', { id: callSession.getId() });
1715
1725
 
1716
1726
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
1717
1727
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -1723,14 +1733,14 @@ class WebRTCPhone extends Emitter {
1723
1733
 
1724
1734
  const sipSession = this.findSipSession(callSession);
1725
1735
  if (sipSession) {
1726
- logger.info('WebRTC rejecting', { sipId: sipSession.id });
1736
+ logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
1727
1737
 
1728
1738
  this.client.hangup(sipSession);
1729
1739
  }
1730
1740
  }
1731
1741
 
1732
1742
  async ignore(callSession ) {
1733
- logger.info('WebRTC ignore', { id: callSession.getId() });
1743
+ logger$4.info('WebRTC ignore', { id: callSession.getId() });
1734
1744
 
1735
1745
  // kill the ring
1736
1746
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -1742,14 +1752,14 @@ class WebRTCPhone extends Emitter {
1742
1752
  const sipSession = this.findSipSession(callSession);
1743
1753
 
1744
1754
  if (sipSession) {
1745
- logger.info('WebRTC atxfer', { sipId: sipSession.id });
1755
+ logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
1746
1756
 
1747
1757
  return this.client.atxfer(sipSession);
1748
1758
  }
1749
1759
  }
1750
1760
 
1751
1761
  hold(callSession , withEvent = true, isConference = false) {
1752
- logger.info('WebRTC hold', { id: callSession.getId() });
1762
+ logger$4.info('WebRTC hold', { id: callSession.getId() });
1753
1763
 
1754
1764
  const sipSession = this.findSipSession(callSession);
1755
1765
 
@@ -1764,18 +1774,18 @@ class WebRTCPhone extends Emitter {
1764
1774
  }
1765
1775
 
1766
1776
  resume(callSession , isConference = false, withEvent = true) {
1767
- logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1777
+ logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1768
1778
 
1769
1779
  const sipSession = this.findSipSession(callSession);
1770
1780
  if (!sipSession) {
1771
1781
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
1772
1782
  }
1773
1783
 
1774
- logger.info('WebRTC resuming', { sipId: sipSession.id });
1784
+ logger$4.info('WebRTC resuming', { sipId: sipSession.id });
1775
1785
 
1776
1786
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
1777
1787
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
1778
- logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1788
+ logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1779
1789
  this.holdSipSession(this.currentSipSession, callSession);
1780
1790
  }
1781
1791
 
@@ -1800,7 +1810,7 @@ class WebRTCPhone extends Emitter {
1800
1810
  const sessionId = this.getSipSessionId(sipSession);
1801
1811
  const hasVideo = this.client.hasLocalVideo(sessionId);
1802
1812
 
1803
- logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1813
+ logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1804
1814
 
1805
1815
  // Stop screenshre if needed
1806
1816
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -1831,7 +1841,7 @@ class WebRTCPhone extends Emitter {
1831
1841
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
1832
1842
  }
1833
1843
  const sessionId = this.getSipSessionId(sipSession);
1834
- logger.info('WebRTC unhold sip session', { sessionId, isConference });
1844
+ logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
1835
1845
 
1836
1846
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
1837
1847
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -1875,14 +1885,14 @@ class WebRTCPhone extends Emitter {
1875
1885
  }
1876
1886
 
1877
1887
  mute(callSession , withEvent = true) {
1878
- logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1888
+ logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1879
1889
 
1880
1890
  const sipSession = this.findSipSession(callSession);
1881
1891
  if (!sipSession) {
1882
1892
  return;
1883
1893
  }
1884
1894
 
1885
- logger.info('WebRTC muting', { sipId: sipSession.id });
1895
+ logger$4.info('WebRTC muting', { sipId: sipSession.id });
1886
1896
  this.client.mute(sipSession);
1887
1897
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
1888
1898
 
@@ -1896,14 +1906,14 @@ class WebRTCPhone extends Emitter {
1896
1906
  }
1897
1907
 
1898
1908
  unmute(callSession , withEvent = true) {
1899
- logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1909
+ logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1900
1910
 
1901
1911
  const sipSession = this.findSipSession(callSession);
1902
1912
  if (!sipSession) {
1903
1913
  return;
1904
1914
  }
1905
1915
 
1906
- logger.info('WebRTC unmuting', { sipId: sipSession.id });
1916
+ logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
1907
1917
  this.client.unmute(sipSession);
1908
1918
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
1909
1919
 
@@ -1930,7 +1940,7 @@ class WebRTCPhone extends Emitter {
1930
1940
  if (!sipSession) {
1931
1941
  return;
1932
1942
  }
1933
- logger.info('WebRTC turn camera on', { sipId: sipSession.id });
1943
+ logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
1934
1944
 
1935
1945
  this.client.toggleCameraOn(sipSession);
1936
1946
 
@@ -1942,7 +1952,7 @@ class WebRTCPhone extends Emitter {
1942
1952
  if (!sipSession) {
1943
1953
  return;
1944
1954
  }
1945
- logger.info('WebRTC turn camera off', { sipId: sipSession.id });
1955
+ logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
1946
1956
 
1947
1957
  this.client.toggleCameraOff(sipSession);
1948
1958
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -1954,7 +1964,7 @@ class WebRTCPhone extends Emitter {
1954
1964
  return;
1955
1965
  }
1956
1966
 
1957
- logger.info('WebRTC send key', { sipId: sipSession.id, tone });
1967
+ logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
1958
1968
  this.client.sendDTMF(sipSession, tone);
1959
1969
  }
1960
1970
 
@@ -1962,7 +1972,7 @@ class WebRTCPhone extends Emitter {
1962
1972
  // @TODO: line is not used here
1963
1973
  async makeCall(number , line , cameraEnabled ,
1964
1974
  audioOnly = false, conference = false) {
1965
- logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1975
+ logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1966
1976
  if (!number) {
1967
1977
  return Promise.resolve(null);
1968
1978
  }
@@ -1972,7 +1982,7 @@ class WebRTCPhone extends Emitter {
1972
1982
  }
1973
1983
  if (this.currentSipSession) {
1974
1984
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
1975
- logger.warn('Unable to hold current session when making another call', e);
1985
+ logger$4.warn('Unable to hold current session when making another call', e);
1976
1986
  });
1977
1987
  }
1978
1988
 
@@ -1982,7 +1992,7 @@ class WebRTCPhone extends Emitter {
1982
1992
  this._bindEvents(sipSession);
1983
1993
  } catch (error) {
1984
1994
  console.warn(error);
1985
- logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
1995
+ logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
1986
1996
  return Promise.resolve(null);
1987
1997
  }
1988
1998
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -2010,7 +2020,7 @@ class WebRTCPhone extends Emitter {
2010
2020
  return;
2011
2021
  }
2012
2022
 
2013
- logger.info('WebRTC transfer', { sipId: sipSession.id, target });
2023
+ logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
2014
2024
 
2015
2025
  this.client.transfer(sipSession, target);
2016
2026
  }
@@ -2019,7 +2029,7 @@ class WebRTCPhone extends Emitter {
2019
2029
  const sipSession = this.client.getSipSession(source.sipCallId);
2020
2030
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
2021
2031
 
2022
- logger.info('WebRTC indirect transfer', {
2032
+ logger$4.info('WebRTC indirect transfer', {
2023
2033
  sipId: sipSession ? sipSession.id : null,
2024
2034
  target: sipSessionTarget ? sipSessionTarget.id : null,
2025
2035
  });
@@ -2058,7 +2068,7 @@ class WebRTCPhone extends Emitter {
2058
2068
  return false;
2059
2069
  }
2060
2070
 
2061
- logger.info('WebRTC hangup', { sipId: sipSession.id });
2071
+ logger$4.info('WebRTC hangup', { sipId: sipSession.id });
2062
2072
 
2063
2073
  const sipSessionId = this.getSipSessionId(sipSession);
2064
2074
 
@@ -2104,7 +2114,7 @@ class WebRTCPhone extends Emitter {
2104
2114
  endCurrentCall(callSession ) {
2105
2115
  const isCurrent = this.isCurrentCallSipSession(callSession);
2106
2116
 
2107
- logger.info('Ending current call', {
2117
+ logger$4.info('Ending current call', {
2108
2118
  id: callSession ? callSession.getId() : null,
2109
2119
  isCurrent,
2110
2120
  });
@@ -2128,7 +2138,7 @@ class WebRTCPhone extends Emitter {
2128
2138
  }
2129
2139
 
2130
2140
  async close() {
2131
- logger.info('WebRTC close');
2141
+ logger$4.info('WebRTC close');
2132
2142
 
2133
2143
  try {
2134
2144
  await Promise.race([
@@ -2136,7 +2146,7 @@ class WebRTCPhone extends Emitter {
2136
2146
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
2137
2147
  ]);
2138
2148
  } catch (e) {
2139
- logger.error('WebRTC close, unregister error', e);
2149
+ logger$4.error('WebRTC close, unregister error', e);
2140
2150
  }
2141
2151
 
2142
2152
  this.client.close();
@@ -2154,12 +2164,12 @@ class WebRTCPhone extends Emitter {
2154
2164
  }
2155
2165
 
2156
2166
  enableRinging() {
2157
- logger.info('WebRTC enable ringing');
2167
+ logger$4.info('WebRTC enable ringing');
2158
2168
  this.ringingEnabled = true;
2159
2169
  }
2160
2170
 
2161
2171
  disableRinging() {
2162
- logger.info('WebRTC disable ringing');
2172
+ logger$4.info('WebRTC disable ringing');
2163
2173
  this.ringingEnabled = false;
2164
2174
  }
2165
2175
 
@@ -2199,7 +2209,7 @@ class WebRTCPhone extends Emitter {
2199
2209
 
2200
2210
  // Deprecated
2201
2211
  getLocalMediaStream(callSession ) {
2202
- logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2212
+ logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2203
2213
  return this.getLocalStream(callSession);
2204
2214
  }
2205
2215
 
@@ -2241,7 +2251,7 @@ class WebRTCPhone extends Emitter {
2241
2251
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
2242
2252
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
2243
2253
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
2244
- logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2254
+ logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2245
2255
 
2246
2256
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
2247
2257
  this.incomingSessions.push(callSession.getId());
@@ -2264,7 +2274,7 @@ class WebRTCPhone extends Emitter {
2264
2274
  });
2265
2275
 
2266
2276
  this.client.on(this.client.ON_REINVITE, (...args) => {
2267
- logger.info('WebRTC on reinvite', {
2277
+ logger$4.info('WebRTC on reinvite', {
2268
2278
  sessionId: args[0].id,
2269
2279
  inviteId: args[1].id,
2270
2280
  updatedCalleeName: args[2],
@@ -2284,7 +2294,7 @@ class WebRTCPhone extends Emitter {
2284
2294
  });
2285
2295
 
2286
2296
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
2287
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
2297
+ logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
2288
2298
 
2289
2299
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
2290
2300
 
@@ -2295,22 +2305,22 @@ class WebRTCPhone extends Emitter {
2295
2305
  this.client.on('ended', () => {});
2296
2306
 
2297
2307
  this.client.on(this.client.ON_ERROR, e => {
2298
- logger.error('WebRTC error', e);
2308
+ logger$4.error('WebRTC error', e);
2299
2309
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2300
2310
  });
2301
2311
 
2302
2312
  this.client.on(this.client.UNREGISTERED, () => {
2303
- logger.info('WebRTC unregistered');
2313
+ logger$4.info('WebRTC unregistered');
2304
2314
  this.eventEmitter.emit(ON_UNREGISTERED);
2305
2315
  });
2306
2316
 
2307
2317
  this.client.on(this.client.ON_DISCONNECTED, () => {
2308
- logger.info('WebRTC disconnected');
2318
+ logger$4.info('WebRTC disconnected');
2309
2319
  this.eventEmitter.emit(ON_DISCONNECTED);
2310
2320
  });
2311
2321
 
2312
2322
  this.client.on(this.client.REGISTERED, () => {
2313
- logger.info('WebRTC registered', {
2323
+ logger$4.info('WebRTC registered', {
2314
2324
  shouldSendReinvite: this.shouldSendReinvite,
2315
2325
  state: this.currentSipSession ? this.currentSipSession.state : null,
2316
2326
  currentSipSession: !!this.currentSipSession,
@@ -2323,23 +2333,27 @@ class WebRTCPhone extends Emitter {
2323
2333
  if (this.shouldSendReinvite && this.currentSipSession
2324
2334
  && this.currentSipSession.state === SessionState.Established) {
2325
2335
  this.shouldSendReinvite = false;
2336
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
2337
+ const isConference = pc ? pc.sfu : false;
2338
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
2339
+
2326
2340
  try {
2327
2341
  // Send reinvite with iceRestart
2328
- this.sendReinvite(this.currentCallSession, null, false, false, true);
2342
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
2329
2343
  } catch (e) {
2330
- logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2344
+ logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2331
2345
  }
2332
2346
  }
2333
2347
  });
2334
2348
 
2335
2349
  this.client.on(this.client.CONNECTED, () => {
2336
- logger.info('WebRTC client connected');
2350
+ logger$4.info('WebRTC client connected');
2337
2351
 
2338
2352
  this.stopHeartbeat();
2339
2353
  });
2340
2354
 
2341
2355
  this.client.on(this.client.DISCONNECTED, () => {
2342
- logger.info('WebRTC client disconnected');
2356
+ logger$4.info('WebRTC client disconnected');
2343
2357
 
2344
2358
  this.eventEmitter.emit(ON_UNREGISTERED);
2345
2359
 
@@ -2377,7 +2391,7 @@ class WebRTCPhone extends Emitter {
2377
2391
  const localStream = this.client.getLocalStream(sipSessionId);
2378
2392
  const callSession = this.callSessions[sipSessionId];
2379
2393
 
2380
- logger.info('Updrading directly in screensharing mode', {
2394
+ logger$4.info('Updrading directly in screensharing mode', {
2381
2395
  sipSessionId,
2382
2396
  tracks: localStream ? localStream.getTracks() : null,
2383
2397
  });
@@ -2409,6 +2423,15 @@ class WebRTCPhone extends Emitter {
2409
2423
  return this.client.getSipSessionId(sipSession);
2410
2424
  }
2411
2425
 
2426
+ _updateCallSession(callSession ) {
2427
+ const sipSession = this.findSipSession(callSession);
2428
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
2429
+
2430
+ if (sipSessionId) {
2431
+ this.callSessions[sipSessionId] = callSession;
2432
+ }
2433
+ }
2434
+
2412
2435
  _onMessage(message ) {
2413
2436
  if (!message || message.method !== 'MESSAGE') {
2414
2437
  return;