@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
@@ -410,7 +410,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
410
410
 
411
411
  /* */
412
412
 
413
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
413
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
414
414
 
415
415
  // Use a function here to be able to mock it in tests
416
416
  const realFetch = () => {
@@ -795,7 +795,7 @@ var IssueReporter$1 = new IssueReporter();
795
795
 
796
796
  /* global RTCSessionDescriptionInit, navigator */
797
797
 
798
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
798
+ const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
799
799
 
800
800
  //
801
801
 
@@ -837,7 +837,7 @@ BwIDAQAB
837
837
 
838
838
  //
839
839
 
840
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
840
+ const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
841
841
 
842
842
  /* eslint-disable dot-notation */
843
843
 
@@ -858,15 +858,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
858
858
 
859
859
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
860
860
 
861
- IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
861
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
862
862
 
863
863
  /* */
864
864
 
865
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
865
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
866
866
 
867
867
  //
868
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
869
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
868
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
869
+ const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
870
870
 
871
871
  /* eslint-disable no-param-reassign */
872
872
 
@@ -952,7 +952,7 @@ const events = [
952
952
  ON_DISCONNECTED,
953
953
  ];
954
954
 
955
- const logger = IssueReporter$1.loggerFor('webrtc-phone');
955
+ const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
956
956
 
957
957
  class WebRTCPhone extends Emitter {
958
958
 
@@ -1025,7 +1025,7 @@ class WebRTCPhone extends Emitter {
1025
1025
  }).catch(error => {
1026
1026
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
1027
1027
  console.error('register error', error, error.message, error.stack);
1028
- logger.error('WebRTC register error', { message: error.message, stack: error.stack });
1028
+ logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
1029
1029
  });
1030
1030
  }
1031
1031
 
@@ -1040,7 +1040,7 @@ class WebRTCPhone extends Emitter {
1040
1040
  if (!this.client) {
1041
1041
  return;
1042
1042
  }
1043
- logger.info('WebRTC phone stop');
1043
+ logger$4.info('WebRTC phone stop');
1044
1044
  this.client.stop();
1045
1045
  }
1046
1046
 
@@ -1055,7 +1055,7 @@ class WebRTCPhone extends Emitter {
1055
1055
  async sendReinvite(callSession , constraints = null, conference = false,
1056
1056
  audioOnly = false, iceRestart = false) {
1057
1057
  const sipSession = this.findSipSession(callSession);
1058
- logger.info('WebRTC phone - send reinvite', {
1058
+ logger$4.info('WebRTC phone - send reinvite', {
1059
1059
  sessionId: sipSession ? sipSession.id : null,
1060
1060
  constraints,
1061
1061
  audioOnly,
@@ -1092,7 +1092,7 @@ class WebRTCPhone extends Emitter {
1092
1092
  }
1093
1093
 
1094
1094
  startHeartbeat() {
1095
- logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1095
+ logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1096
1096
  if (!this.client || this.client.hasHeartbeat()) {
1097
1097
  return;
1098
1098
  }
@@ -1101,7 +1101,7 @@ class WebRTCPhone extends Emitter {
1101
1101
  }
1102
1102
 
1103
1103
  stopHeartbeat() {
1104
- logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1104
+ logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1105
1105
  if (!this.client) {
1106
1106
  return;
1107
1107
  }
@@ -1118,7 +1118,7 @@ class WebRTCPhone extends Emitter {
1118
1118
  }
1119
1119
 
1120
1120
  reconnect() {
1121
- logger.info('WebRTC phone - reconnect', { client: !!this.client });
1121
+ logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
1122
1122
  if (!this.client) {
1123
1123
  return;
1124
1124
  }
@@ -1159,10 +1159,15 @@ class WebRTCPhone extends Emitter {
1159
1159
  return false;
1160
1160
  }
1161
1161
 
1162
- logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1162
+ logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1163
1163
 
1164
1164
  this.client.downgradeToAudio(sipSession);
1165
1165
 
1166
+ if (callSession) {
1167
+ callSession.cameraEnabled = false;
1168
+ this._updateCallSession(callSession);
1169
+ }
1170
+
1166
1171
  if (withMessage) {
1167
1172
  this._sendReinviteMessage(callSession, false);
1168
1173
  }
@@ -1177,7 +1182,7 @@ class WebRTCPhone extends Emitter {
1177
1182
  return Promise.resolve(false);
1178
1183
  }
1179
1184
 
1180
- logger.info('Upgrade to video', {
1185
+ logger$4.info('Upgrade to video', {
1181
1186
  id: callSession ? callSession.getId() : null,
1182
1187
  constraints,
1183
1188
  isConference,
@@ -1190,6 +1195,11 @@ class WebRTCPhone extends Emitter {
1190
1195
 
1191
1196
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
1192
1197
 
1198
+ if (callSession) {
1199
+ callSession.cameraEnabled = true;
1200
+ this._updateCallSession(callSession);
1201
+ }
1202
+
1193
1203
  // If no stream is returned, it means we have to reinvite
1194
1204
  if (!newStream) {
1195
1205
  return true;
@@ -1212,7 +1222,7 @@ class WebRTCPhone extends Emitter {
1212
1222
 
1213
1223
  _sendReinviteMessage(callSession , isUpgrade ) {
1214
1224
  const sipSession = this.findSipSession(callSession);
1215
- logger.info('Sending reinvite message', {
1225
+ logger$4.info('Sending reinvite message', {
1216
1226
  id: callSession ? callSession.getId() : null,
1217
1227
  isUpgrade,
1218
1228
  });
@@ -1238,7 +1248,7 @@ class WebRTCPhone extends Emitter {
1238
1248
  // Monkey patch to know when canceled with the CANCEL message
1239
1249
  const onCancel = sipSession._onCancel.bind(sipSession);
1240
1250
  sipSession._onCancel = (message ) => {
1241
- logger.trace('on sip session canceled', { callId: message.callId });
1251
+ logger$4.trace('on sip session canceled', { callId: message.callId });
1242
1252
 
1243
1253
  onCancel(message);
1244
1254
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -1266,13 +1276,13 @@ class WebRTCPhone extends Emitter {
1266
1276
  this.audioOutputVolume,
1267
1277
  );
1268
1278
  case sessionState.SessionState.Terminating:
1269
- logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1279
+ logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1270
1280
 
1271
1281
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
1272
1282
 
1273
1283
  break;
1274
1284
  case sessionState.SessionState.Terminated: {
1275
- logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1285
+ logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1276
1286
 
1277
1287
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
1278
1288
  const callSession = this._createCallSession(sipSession);
@@ -1294,7 +1304,7 @@ class WebRTCPhone extends Emitter {
1294
1304
  const [stream] = event.streams;
1295
1305
  const kind = event && event.track && event.track.kind;
1296
1306
 
1297
- logger.info('on track stream called on the peer connection', {
1307
+ logger$4.info('on track stream called on the peer connection', {
1298
1308
  callId: this.getSipSessionId(sipSession),
1299
1309
  streamId: stream ? stream.id : null,
1300
1310
  tracks: stream ? stream.getTracks() : null,
@@ -1314,7 +1324,7 @@ class WebRTCPhone extends Emitter {
1314
1324
  };
1315
1325
 
1316
1326
  peerConnection.onremovestream = event => {
1317
- logger.info('on remove stream called on the peer connection', {
1327
+ logger$4.info('on remove stream called on the peer connection', {
1318
1328
  id: event.stream.id,
1319
1329
  tracks: event.stream.getTracks(),
1320
1330
  });
@@ -1324,7 +1334,7 @@ class WebRTCPhone extends Emitter {
1324
1334
  }
1325
1335
 
1326
1336
  async startScreenSharing(constraints , callSession ) {
1327
- logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1337
+ logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1328
1338
 
1329
1339
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
1330
1340
  if (!screenShareStream) {
@@ -1364,7 +1374,7 @@ class WebRTCPhone extends Emitter {
1364
1374
  return;
1365
1375
  }
1366
1376
 
1367
- logger.info('WebRTC phone - stop screen sharing', {
1377
+ logger$4.info('WebRTC phone - stop screen sharing', {
1368
1378
  restoreLocalStream,
1369
1379
  });
1370
1380
 
@@ -1420,7 +1430,7 @@ class WebRTCPhone extends Emitter {
1420
1430
  const pc = this.client.getPeerConnection(sipSessionId);
1421
1431
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1422
1432
 
1423
- logger.info('WebRTC phone - on screensharing', {
1433
+ logger$4.info('WebRTC phone - on screensharing', {
1424
1434
  hadVideo,
1425
1435
  id: this.getSipSessionId(sipSession),
1426
1436
  screenTrack,
@@ -1428,7 +1438,7 @@ class WebRTCPhone extends Emitter {
1428
1438
 
1429
1439
  if (screenTrack) {
1430
1440
  screenTrack.onended = () => {
1431
- logger.info('WebRTC phone - on screenshare ended', {
1441
+ logger$4.info('WebRTC phone - on screenshare ended', {
1432
1442
  hadVideo,
1433
1443
  id: this.getSipSessionId(sipSession),
1434
1444
  screenTrack,
@@ -1459,7 +1469,7 @@ class WebRTCPhone extends Emitter {
1459
1469
  }
1460
1470
 
1461
1471
  _onCallAccepted(sipSession , cameraEnabled ) {
1462
- logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1472
+ logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1463
1473
 
1464
1474
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
1465
1475
  this.currentSipSession = sipSession;
@@ -1477,7 +1487,7 @@ class WebRTCPhone extends Emitter {
1477
1487
  }
1478
1488
 
1479
1489
  changeAudioDevice(id ) {
1480
- logger.info('WebRTC phone - change audio device', { deviceId: id });
1490
+ logger$4.info('WebRTC phone - change audio device', { deviceId: id });
1481
1491
  this.audioOutputDeviceId = id;
1482
1492
  this.client.changeAudioOutputDevice(id);
1483
1493
  }
@@ -1487,14 +1497,14 @@ class WebRTCPhone extends Emitter {
1487
1497
  }
1488
1498
 
1489
1499
  changeRingDevice(id ) {
1490
- logger.info('WebRTC phone - changing ring device', { id });
1500
+ logger$4.info('WebRTC phone - changing ring device', { id });
1491
1501
 
1492
1502
  this.audioRingDeviceId = id;
1493
1503
  }
1494
1504
 
1495
1505
  // volume is a value between 0 and 1
1496
1506
  changeAudioVolume(volume ) {
1497
- logger.info('WebRTC phone - changing audio volume', { volume });
1507
+ logger$4.info('WebRTC phone - changing audio volume', { volume });
1498
1508
 
1499
1509
  this.audioOutputVolume = volume;
1500
1510
  this.client.changeAudioOutputVolume(volume);
@@ -1502,31 +1512,31 @@ class WebRTCPhone extends Emitter {
1502
1512
 
1503
1513
  // volume is a value between 0 and 1
1504
1514
  changeRingVolume(volume ) {
1505
- logger.info('WebRTC phone - changing ring volume', { volume });
1515
+ logger$4.info('WebRTC phone - changing ring volume', { volume });
1506
1516
 
1507
1517
  this.audioRingVolume = volume;
1508
1518
  }
1509
1519
 
1510
1520
  changeAudioInputDevice(id ) {
1511
- logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
1521
+ logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
1512
1522
 
1513
1523
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
1514
1524
  }
1515
1525
 
1516
1526
  changeVideoInputDevice(id ) {
1517
- logger.info('WebRTC phone - change video input device', { deviceId: id });
1527
+ logger$4.info('WebRTC phone - change video input device', { deviceId: id });
1518
1528
 
1519
1529
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
1520
1530
  }
1521
1531
 
1522
1532
  changeSessionVideoInputDevice(id ) {
1523
- logger.info('WebRTC phone - change session video input device', { deviceId: id });
1533
+ logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
1524
1534
 
1525
1535
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
1526
1536
  }
1527
1537
 
1528
1538
  _onCallTerminated(sipSession ) {
1529
- logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1539
+ logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1530
1540
 
1531
1541
  const callSession = this._createCallSession(sipSession);
1532
1542
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -1560,7 +1570,7 @@ class WebRTCPhone extends Emitter {
1560
1570
  const hasIncomingCallSession = this.hasIncomingCallSession();
1561
1571
 
1562
1572
  // Re-trigger incoming call event for remaining incoming calls
1563
- logger.info('WebRTC phone - check to re-trigger incoming call', {
1573
+ logger$4.info('WebRTC phone - check to re-trigger incoming call', {
1564
1574
  sipId: sipSession.id,
1565
1575
  shouldRetrigger,
1566
1576
  hasIncomingCallSession,
@@ -1651,37 +1661,37 @@ class WebRTCPhone extends Emitter {
1651
1661
 
1652
1662
  // Deprecated
1653
1663
  getLocalStreamForCall(callSession ) {
1654
- logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1664
+ logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1655
1665
 
1656
1666
  return this.getLocalStream(callSession);
1657
1667
  }
1658
1668
 
1659
1669
  // Deprecated
1660
1670
  getRemoteStreamForCall(callSession ) {
1661
- logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1671
+ logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1662
1672
 
1663
1673
  return this.getRemoteVideoStream(callSession);
1664
1674
  }
1665
1675
 
1666
1676
  getRemoteStreamsForCall(callSession ) {
1667
- logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1677
+ logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1668
1678
 
1669
1679
  return this.getRemoteStream(callSession);
1670
1680
  }
1671
1681
 
1672
1682
  accept(callSession , cameraEnabled ) {
1673
- logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1683
+ logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1674
1684
  if (this.currentSipSession) {
1675
1685
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
1676
1686
  }
1677
1687
 
1678
1688
  if (!callSession) {
1679
- logger.warn('no CallSession to accept.');
1689
+ logger$4.warn('no CallSession to accept.');
1680
1690
  return Promise.resolve(null);
1681
1691
  }
1682
1692
 
1683
1693
  if (callSession.getId() in this.acceptedSessions) {
1684
- logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1694
+ logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1685
1695
  return Promise.resolve(callSession.sipCallId);
1686
1696
  }
1687
1697
 
@@ -1693,24 +1703,24 @@ class WebRTCPhone extends Emitter {
1693
1703
  const sipSession = this.client.getSipSession(callSession.getId());
1694
1704
  if (sipSession) {
1695
1705
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
1696
- logger.warn('Trying to answer a terminated sipSession.');
1706
+ logger$4.warn('Trying to answer a terminated sipSession.');
1697
1707
 
1698
1708
  return Promise.resolve(null);
1699
1709
  }
1700
1710
 
1701
- logger.info('accept call, session found', { sipId: sipSession.id });
1711
+ logger$4.info('accept call, session found', { sipId: sipSession.id });
1702
1712
 
1703
1713
  // $FlowFixMe
1704
1714
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
1705
1715
  return callSession.sipCallId;
1706
1716
  }).catch(e => {
1707
- logger.error(e);
1717
+ logger$4.error(e);
1708
1718
  this.endCurrentCall(callSession);
1709
1719
  throw e;
1710
1720
  });
1711
1721
  }
1712
1722
 
1713
- logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1723
+ logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1714
1724
 
1715
1725
  return Promise.resolve(null);
1716
1726
  }
@@ -1720,7 +1730,7 @@ class WebRTCPhone extends Emitter {
1720
1730
  }
1721
1731
 
1722
1732
  async reject(callSession ) {
1723
- logger.info('reject WebRTC called', { id: callSession.getId() });
1733
+ logger$4.info('reject WebRTC called', { id: callSession.getId() });
1724
1734
 
1725
1735
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
1726
1736
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -1732,14 +1742,14 @@ class WebRTCPhone extends Emitter {
1732
1742
 
1733
1743
  const sipSession = this.findSipSession(callSession);
1734
1744
  if (sipSession) {
1735
- logger.info('WebRTC rejecting', { sipId: sipSession.id });
1745
+ logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
1736
1746
 
1737
1747
  this.client.hangup(sipSession);
1738
1748
  }
1739
1749
  }
1740
1750
 
1741
1751
  async ignore(callSession ) {
1742
- logger.info('WebRTC ignore', { id: callSession.getId() });
1752
+ logger$4.info('WebRTC ignore', { id: callSession.getId() });
1743
1753
 
1744
1754
  // kill the ring
1745
1755
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -1751,14 +1761,14 @@ class WebRTCPhone extends Emitter {
1751
1761
  const sipSession = this.findSipSession(callSession);
1752
1762
 
1753
1763
  if (sipSession) {
1754
- logger.info('WebRTC atxfer', { sipId: sipSession.id });
1764
+ logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
1755
1765
 
1756
1766
  return this.client.atxfer(sipSession);
1757
1767
  }
1758
1768
  }
1759
1769
 
1760
1770
  hold(callSession , withEvent = true, isConference = false) {
1761
- logger.info('WebRTC hold', { id: callSession.getId() });
1771
+ logger$4.info('WebRTC hold', { id: callSession.getId() });
1762
1772
 
1763
1773
  const sipSession = this.findSipSession(callSession);
1764
1774
 
@@ -1773,18 +1783,18 @@ class WebRTCPhone extends Emitter {
1773
1783
  }
1774
1784
 
1775
1785
  resume(callSession , isConference = false, withEvent = true) {
1776
- logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1786
+ logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1777
1787
 
1778
1788
  const sipSession = this.findSipSession(callSession);
1779
1789
  if (!sipSession) {
1780
1790
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
1781
1791
  }
1782
1792
 
1783
- logger.info('WebRTC resuming', { sipId: sipSession.id });
1793
+ logger$4.info('WebRTC resuming', { sipId: sipSession.id });
1784
1794
 
1785
1795
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
1786
1796
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
1787
- logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1797
+ logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1788
1798
  this.holdSipSession(this.currentSipSession, callSession);
1789
1799
  }
1790
1800
 
@@ -1809,7 +1819,7 @@ class WebRTCPhone extends Emitter {
1809
1819
  const sessionId = this.getSipSessionId(sipSession);
1810
1820
  const hasVideo = this.client.hasLocalVideo(sessionId);
1811
1821
 
1812
- logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1822
+ logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1813
1823
 
1814
1824
  // Stop screenshre if needed
1815
1825
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -1840,7 +1850,7 @@ class WebRTCPhone extends Emitter {
1840
1850
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
1841
1851
  }
1842
1852
  const sessionId = this.getSipSessionId(sipSession);
1843
- logger.info('WebRTC unhold sip session', { sessionId, isConference });
1853
+ logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
1844
1854
 
1845
1855
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
1846
1856
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -1884,14 +1894,14 @@ class WebRTCPhone extends Emitter {
1884
1894
  }
1885
1895
 
1886
1896
  mute(callSession , withEvent = true) {
1887
- logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1897
+ logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1888
1898
 
1889
1899
  const sipSession = this.findSipSession(callSession);
1890
1900
  if (!sipSession) {
1891
1901
  return;
1892
1902
  }
1893
1903
 
1894
- logger.info('WebRTC muting', { sipId: sipSession.id });
1904
+ logger$4.info('WebRTC muting', { sipId: sipSession.id });
1895
1905
  this.client.mute(sipSession);
1896
1906
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
1897
1907
 
@@ -1905,14 +1915,14 @@ class WebRTCPhone extends Emitter {
1905
1915
  }
1906
1916
 
1907
1917
  unmute(callSession , withEvent = true) {
1908
- logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1918
+ logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1909
1919
 
1910
1920
  const sipSession = this.findSipSession(callSession);
1911
1921
  if (!sipSession) {
1912
1922
  return;
1913
1923
  }
1914
1924
 
1915
- logger.info('WebRTC unmuting', { sipId: sipSession.id });
1925
+ logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
1916
1926
  this.client.unmute(sipSession);
1917
1927
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
1918
1928
 
@@ -1939,7 +1949,7 @@ class WebRTCPhone extends Emitter {
1939
1949
  if (!sipSession) {
1940
1950
  return;
1941
1951
  }
1942
- logger.info('WebRTC turn camera on', { sipId: sipSession.id });
1952
+ logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
1943
1953
 
1944
1954
  this.client.toggleCameraOn(sipSession);
1945
1955
 
@@ -1951,7 +1961,7 @@ class WebRTCPhone extends Emitter {
1951
1961
  if (!sipSession) {
1952
1962
  return;
1953
1963
  }
1954
- logger.info('WebRTC turn camera off', { sipId: sipSession.id });
1964
+ logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
1955
1965
 
1956
1966
  this.client.toggleCameraOff(sipSession);
1957
1967
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -1963,7 +1973,7 @@ class WebRTCPhone extends Emitter {
1963
1973
  return;
1964
1974
  }
1965
1975
 
1966
- logger.info('WebRTC send key', { sipId: sipSession.id, tone });
1976
+ logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
1967
1977
  this.client.sendDTMF(sipSession, tone);
1968
1978
  }
1969
1979
 
@@ -1971,7 +1981,7 @@ class WebRTCPhone extends Emitter {
1971
1981
  // @TODO: line is not used here
1972
1982
  async makeCall(number , line , cameraEnabled ,
1973
1983
  audioOnly = false, conference = false) {
1974
- logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1984
+ logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1975
1985
  if (!number) {
1976
1986
  return Promise.resolve(null);
1977
1987
  }
@@ -1981,7 +1991,7 @@ class WebRTCPhone extends Emitter {
1981
1991
  }
1982
1992
  if (this.currentSipSession) {
1983
1993
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
1984
- logger.warn('Unable to hold current session when making another call', e);
1994
+ logger$4.warn('Unable to hold current session when making another call', e);
1985
1995
  });
1986
1996
  }
1987
1997
 
@@ -1991,7 +2001,7 @@ class WebRTCPhone extends Emitter {
1991
2001
  this._bindEvents(sipSession);
1992
2002
  } catch (error) {
1993
2003
  console.warn(error);
1994
- logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
2004
+ logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
1995
2005
  return Promise.resolve(null);
1996
2006
  }
1997
2007
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -2019,7 +2029,7 @@ class WebRTCPhone extends Emitter {
2019
2029
  return;
2020
2030
  }
2021
2031
 
2022
- logger.info('WebRTC transfer', { sipId: sipSession.id, target });
2032
+ logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
2023
2033
 
2024
2034
  this.client.transfer(sipSession, target);
2025
2035
  }
@@ -2028,7 +2038,7 @@ class WebRTCPhone extends Emitter {
2028
2038
  const sipSession = this.client.getSipSession(source.sipCallId);
2029
2039
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
2030
2040
 
2031
- logger.info('WebRTC indirect transfer', {
2041
+ logger$4.info('WebRTC indirect transfer', {
2032
2042
  sipId: sipSession ? sipSession.id : null,
2033
2043
  target: sipSessionTarget ? sipSessionTarget.id : null,
2034
2044
  });
@@ -2067,7 +2077,7 @@ class WebRTCPhone extends Emitter {
2067
2077
  return false;
2068
2078
  }
2069
2079
 
2070
- logger.info('WebRTC hangup', { sipId: sipSession.id });
2080
+ logger$4.info('WebRTC hangup', { sipId: sipSession.id });
2071
2081
 
2072
2082
  const sipSessionId = this.getSipSessionId(sipSession);
2073
2083
 
@@ -2113,7 +2123,7 @@ class WebRTCPhone extends Emitter {
2113
2123
  endCurrentCall(callSession ) {
2114
2124
  const isCurrent = this.isCurrentCallSipSession(callSession);
2115
2125
 
2116
- logger.info('Ending current call', {
2126
+ logger$4.info('Ending current call', {
2117
2127
  id: callSession ? callSession.getId() : null,
2118
2128
  isCurrent,
2119
2129
  });
@@ -2137,7 +2147,7 @@ class WebRTCPhone extends Emitter {
2137
2147
  }
2138
2148
 
2139
2149
  async close() {
2140
- logger.info('WebRTC close');
2150
+ logger$4.info('WebRTC close');
2141
2151
 
2142
2152
  try {
2143
2153
  await Promise.race([
@@ -2145,7 +2155,7 @@ class WebRTCPhone extends Emitter {
2145
2155
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
2146
2156
  ]);
2147
2157
  } catch (e) {
2148
- logger.error('WebRTC close, unregister error', e);
2158
+ logger$4.error('WebRTC close, unregister error', e);
2149
2159
  }
2150
2160
 
2151
2161
  this.client.close();
@@ -2163,12 +2173,12 @@ class WebRTCPhone extends Emitter {
2163
2173
  }
2164
2174
 
2165
2175
  enableRinging() {
2166
- logger.info('WebRTC enable ringing');
2176
+ logger$4.info('WebRTC enable ringing');
2167
2177
  this.ringingEnabled = true;
2168
2178
  }
2169
2179
 
2170
2180
  disableRinging() {
2171
- logger.info('WebRTC disable ringing');
2181
+ logger$4.info('WebRTC disable ringing');
2172
2182
  this.ringingEnabled = false;
2173
2183
  }
2174
2184
 
@@ -2208,7 +2218,7 @@ class WebRTCPhone extends Emitter {
2208
2218
 
2209
2219
  // Deprecated
2210
2220
  getLocalMediaStream(callSession ) {
2211
- logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2221
+ logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2212
2222
  return this.getLocalStream(callSession);
2213
2223
  }
2214
2224
 
@@ -2250,7 +2260,7 @@ class WebRTCPhone extends Emitter {
2250
2260
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
2251
2261
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
2252
2262
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
2253
- logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2263
+ logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2254
2264
 
2255
2265
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
2256
2266
  this.incomingSessions.push(callSession.getId());
@@ -2273,7 +2283,7 @@ class WebRTCPhone extends Emitter {
2273
2283
  });
2274
2284
 
2275
2285
  this.client.on(this.client.ON_REINVITE, (...args) => {
2276
- logger.info('WebRTC on reinvite', {
2286
+ logger$4.info('WebRTC on reinvite', {
2277
2287
  sessionId: args[0].id,
2278
2288
  inviteId: args[1].id,
2279
2289
  updatedCalleeName: args[2],
@@ -2293,7 +2303,7 @@ class WebRTCPhone extends Emitter {
2293
2303
  });
2294
2304
 
2295
2305
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
2296
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
2306
+ logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
2297
2307
 
2298
2308
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
2299
2309
 
@@ -2304,22 +2314,22 @@ class WebRTCPhone extends Emitter {
2304
2314
  this.client.on('ended', () => {});
2305
2315
 
2306
2316
  this.client.on(this.client.ON_ERROR, e => {
2307
- logger.error('WebRTC error', e);
2317
+ logger$4.error('WebRTC error', e);
2308
2318
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2309
2319
  });
2310
2320
 
2311
2321
  this.client.on(this.client.UNREGISTERED, () => {
2312
- logger.info('WebRTC unregistered');
2322
+ logger$4.info('WebRTC unregistered');
2313
2323
  this.eventEmitter.emit(ON_UNREGISTERED);
2314
2324
  });
2315
2325
 
2316
2326
  this.client.on(this.client.ON_DISCONNECTED, () => {
2317
- logger.info('WebRTC disconnected');
2327
+ logger$4.info('WebRTC disconnected');
2318
2328
  this.eventEmitter.emit(ON_DISCONNECTED);
2319
2329
  });
2320
2330
 
2321
2331
  this.client.on(this.client.REGISTERED, () => {
2322
- logger.info('WebRTC registered', {
2332
+ logger$4.info('WebRTC registered', {
2323
2333
  shouldSendReinvite: this.shouldSendReinvite,
2324
2334
  state: this.currentSipSession ? this.currentSipSession.state : null,
2325
2335
  currentSipSession: !!this.currentSipSession,
@@ -2332,23 +2342,27 @@ class WebRTCPhone extends Emitter {
2332
2342
  if (this.shouldSendReinvite && this.currentSipSession
2333
2343
  && this.currentSipSession.state === sessionState.SessionState.Established) {
2334
2344
  this.shouldSendReinvite = false;
2345
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
2346
+ const isConference = pc ? pc.sfu : false;
2347
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
2348
+
2335
2349
  try {
2336
2350
  // Send reinvite with iceRestart
2337
- this.sendReinvite(this.currentCallSession, null, false, false, true);
2351
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
2338
2352
  } catch (e) {
2339
- logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2353
+ logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2340
2354
  }
2341
2355
  }
2342
2356
  });
2343
2357
 
2344
2358
  this.client.on(this.client.CONNECTED, () => {
2345
- logger.info('WebRTC client connected');
2359
+ logger$4.info('WebRTC client connected');
2346
2360
 
2347
2361
  this.stopHeartbeat();
2348
2362
  });
2349
2363
 
2350
2364
  this.client.on(this.client.DISCONNECTED, () => {
2351
- logger.info('WebRTC client disconnected');
2365
+ logger$4.info('WebRTC client disconnected');
2352
2366
 
2353
2367
  this.eventEmitter.emit(ON_UNREGISTERED);
2354
2368
 
@@ -2386,7 +2400,7 @@ class WebRTCPhone extends Emitter {
2386
2400
  const localStream = this.client.getLocalStream(sipSessionId);
2387
2401
  const callSession = this.callSessions[sipSessionId];
2388
2402
 
2389
- logger.info('Updrading directly in screensharing mode', {
2403
+ logger$4.info('Updrading directly in screensharing mode', {
2390
2404
  sipSessionId,
2391
2405
  tracks: localStream ? localStream.getTracks() : null,
2392
2406
  });
@@ -2418,6 +2432,15 @@ class WebRTCPhone extends Emitter {
2418
2432
  return this.client.getSipSessionId(sipSession);
2419
2433
  }
2420
2434
 
2435
+ _updateCallSession(callSession ) {
2436
+ const sipSession = this.findSipSession(callSession);
2437
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
2438
+
2439
+ if (sipSessionId) {
2440
+ this.callSessions[sipSessionId] = callSession;
2441
+ }
2442
+ }
2443
+
2421
2444
  _onMessage(message ) {
2422
2445
  if (!message || message.method !== 'MESSAGE') {
2423
2446
  return;