@wazo/sdk 0.37.38 → 0.37.41

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 (70) hide show
  1. package/README.md +2 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +9 -0
  4. package/esm/__tests__/web-rtc-client.test.js +15 -3
  5. package/esm/api/auth.js +2 -0
  6. package/esm/api-client.js +9 -0
  7. package/esm/checker/Checker.js +15 -3
  8. package/esm/checker/checks/aor.js +9 -0
  9. package/esm/checker/checks/api.js +9 -0
  10. package/esm/checker/checks/index.js +15 -3
  11. package/esm/checker/checks/webrtc-transport.js +15 -3
  12. package/esm/checker/checks/webrtc.js +15 -3
  13. package/esm/domain/AdHocAPIConference.js +9 -0
  14. package/esm/domain/Features.js +9 -0
  15. package/esm/domain/Phone/CTIPhone.js +9 -0
  16. package/esm/domain/Phone/WebRTCPhone.js +3 -3
  17. package/esm/index.js +25 -6
  18. package/esm/service/CallApi.js +9 -0
  19. package/esm/service/getApiClient.js +9 -0
  20. package/esm/simple/Auth.js +25 -6
  21. package/esm/simple/Configuration.js +25 -6
  22. package/esm/simple/Directory.js +9 -0
  23. package/esm/simple/Phone.js +25 -6
  24. package/esm/simple/index.js +25 -6
  25. package/esm/simple/room/LocalParticipant.js +25 -6
  26. package/esm/simple/room/Participant.js +25 -6
  27. package/esm/simple/room/RemoteParticipant.js +25 -6
  28. package/esm/simple/room/Room.js +25 -6
  29. package/esm/simple/room/SipRoom.js +25 -6
  30. package/esm/simple/room/Stream.js +25 -6
  31. package/esm/simple/room/__tests__/RemoteParticipant.test.js +25 -6
  32. package/esm/simple/utils.js +25 -6
  33. package/esm/web-rtc-client.js +15 -3
  34. package/lib/__tests__/api-client.test.js +9 -0
  35. package/lib/__tests__/web-rtc-client.test.js +15 -3
  36. package/lib/api/auth.js +2 -0
  37. package/lib/api-client.js +9 -0
  38. package/lib/checker/Checker.js +15 -3
  39. package/lib/checker/checks/aor.js +9 -0
  40. package/lib/checker/checks/api.js +9 -0
  41. package/lib/checker/checks/index.js +15 -3
  42. package/lib/checker/checks/webrtc-transport.js +15 -3
  43. package/lib/checker/checks/webrtc.js +15 -3
  44. package/lib/domain/AdHocAPIConference.js +9 -0
  45. package/lib/domain/Features.js +9 -0
  46. package/lib/domain/Phone/CTIPhone.js +9 -0
  47. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  48. package/lib/index.js +25 -6
  49. package/lib/service/CallApi.js +9 -0
  50. package/lib/service/getApiClient.js +9 -0
  51. package/lib/simple/Auth.js +25 -6
  52. package/lib/simple/Configuration.js +25 -6
  53. package/lib/simple/Directory.js +9 -0
  54. package/lib/simple/Phone.js +25 -6
  55. package/lib/simple/index.js +25 -6
  56. package/lib/simple/room/LocalParticipant.js +25 -6
  57. package/lib/simple/room/Participant.js +25 -6
  58. package/lib/simple/room/RemoteParticipant.js +25 -6
  59. package/lib/simple/room/Room.js +25 -6
  60. package/lib/simple/room/SipRoom.js +25 -6
  61. package/lib/simple/room/Stream.js +25 -6
  62. package/lib/simple/room/__tests__/RemoteParticipant.test.js +25 -6
  63. package/lib/simple/utils.js +25 -6
  64. package/lib/web-rtc-client.js +15 -3
  65. package/package.json +1 -1
  66. package/src/api/auth.js +2 -0
  67. package/src/api-client.js +7 -0
  68. package/src/domain/Phone/WebRTCPhone.js +3 -3
  69. package/src/simple/Auth.js +7 -0
  70. package/src/web-rtc-client.js +7 -4
@@ -2268,12 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
2268
2268
  backend ,
2269
2269
  expiration ,
2270
2270
  isMobile = false,
2271
+ tenantId ,
2271
2272
  ) => {
2272
2273
  const body = {
2273
2274
  backend: backend || DEFAULT_BACKEND_USER,
2274
2275
  expiration: expiration || DETAULT_EXPIRATION,
2275
2276
  refresh_token: refreshToken,
2276
2277
  client_id: client.clientId,
2278
+ tenant_id: tenantId,
2277
2279
  };
2278
2280
 
2279
2281
  const headers = {
@@ -5425,6 +5427,7 @@ class ApiClient {
5425
5427
 
5426
5428
 
5427
5429
 
5430
+
5428
5431
 
5429
5432
 
5430
5433
 
@@ -5465,6 +5468,7 @@ class ApiClient {
5465
5468
  logger$a.info('refresh token callback called', {
5466
5469
  refreshToken: this.refreshToken,
5467
5470
  refreshBackend: this.refreshBackend,
5471
+ refreshTenantId: this.refreshTenantId,
5468
5472
  refreshExpiration: this.refreshExpiration,
5469
5473
  isMobile: this.isMobile,
5470
5474
  });
@@ -5478,6 +5482,7 @@ class ApiClient {
5478
5482
  this.refreshBackend,
5479
5483
  this.refreshExpiration,
5480
5484
  this.isMobile,
5485
+ this.refreshTenantId,
5481
5486
  );
5482
5487
 
5483
5488
  logger$a.info('token refreshed', { token: session.token });
@@ -5519,6 +5524,10 @@ class ApiClient {
5519
5524
  this.refreshBackend = refreshBackend;
5520
5525
  }
5521
5526
 
5527
+ setRefreshTenantId(tenantId ) {
5528
+ this.refreshTenantId = tenantId;
5529
+ }
5530
+
5522
5531
  setIsMobile(isMobile ) {
5523
5532
  this.isMobile = isMobile;
5524
5533
  }
@@ -5690,6 +5699,13 @@ class Auth {
5690
5699
  expiration: this.expiration,
5691
5700
  mobile: this.mobile,
5692
5701
  });
5702
+
5703
+ if (backend) {
5704
+ getApiClient().setRefreshBackend(backend);
5705
+ }
5706
+
5707
+ getApiClient().setRefreshTenantId(tenantId);
5708
+
5693
5709
  return this._onAuthenticated(rawSession);
5694
5710
  }
5695
5711
 
@@ -8729,11 +8745,14 @@ class WebRTCClient extends Emitter {
8729
8745
  }
8730
8746
 
8731
8747
  async _disconnectTransport(force = false) {
8732
- if (force) {
8748
+ if (force && this.userAgent && this.userAgent.transport) {
8733
8749
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8734
8750
  this.userAgent.transport.disconnectResolve = () => {};
8735
- // eslint-disable-next-line
8736
- this.userAgent.transport._ws.close(1000);
8751
+
8752
+ if (this.userAgent.transport._ws) {
8753
+ this.userAgent.transport._ws.close(1000);
8754
+ }
8755
+
8737
8756
  return;
8738
8757
  }
8739
8758
 
@@ -9385,7 +9404,7 @@ class WebRTCPhone extends Emitter {
9385
9404
  // When stopping screenshare and we had video before that, we have to re-upgrade
9386
9405
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9387
9406
  // We have to downgrade to audio.
9388
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9407
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9389
9408
  const constraints = { audio: false, video: screenshareStopped };
9390
9409
 
9391
9410
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9829,7 +9848,7 @@ class WebRTCPhone extends Emitter {
9829
9848
 
9830
9849
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9831
9850
 
9832
- // Stop screenshre if needed
9851
+ // Stop screenshare if needed
9833
9852
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9834
9853
  this.lastScreenShare = this.currentScreenShare;
9835
9854
  await this.stopScreenSharing(false, callSession);
@@ -10591,7 +10610,7 @@ class WebRTCPhone extends Emitter {
10591
10610
  endTime: fromSession ? fromSession.endTime : null,
10592
10611
  answered: state === sessionState.SessionState.Established,
10593
10612
  paused: this.client.isCallHeld(sipSession),
10594
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10613
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10595
10614
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10596
10615
  number,
10597
10616
  ringing: false,
@@ -2270,12 +2270,14 @@ var authMethods = (client , baseUrl ) => ({
2270
2270
  backend ,
2271
2271
  expiration ,
2272
2272
  isMobile = false,
2273
+ tenantId ,
2273
2274
  ) => {
2274
2275
  const body = {
2275
2276
  backend: backend || DEFAULT_BACKEND_USER,
2276
2277
  expiration: expiration || DETAULT_EXPIRATION,
2277
2278
  refresh_token: refreshToken,
2278
2279
  client_id: client.clientId,
2280
+ tenant_id: tenantId,
2279
2281
  };
2280
2282
 
2281
2283
  const headers = {
@@ -5427,6 +5429,7 @@ class ApiClient {
5427
5429
 
5428
5430
 
5429
5431
 
5432
+
5430
5433
 
5431
5434
 
5432
5435
 
@@ -5467,6 +5470,7 @@ class ApiClient {
5467
5470
  logger$a.info('refresh token callback called', {
5468
5471
  refreshToken: this.refreshToken,
5469
5472
  refreshBackend: this.refreshBackend,
5473
+ refreshTenantId: this.refreshTenantId,
5470
5474
  refreshExpiration: this.refreshExpiration,
5471
5475
  isMobile: this.isMobile,
5472
5476
  });
@@ -5480,6 +5484,7 @@ class ApiClient {
5480
5484
  this.refreshBackend,
5481
5485
  this.refreshExpiration,
5482
5486
  this.isMobile,
5487
+ this.refreshTenantId,
5483
5488
  );
5484
5489
 
5485
5490
  logger$a.info('token refreshed', { token: session.token });
@@ -5521,6 +5526,10 @@ class ApiClient {
5521
5526
  this.refreshBackend = refreshBackend;
5522
5527
  }
5523
5528
 
5529
+ setRefreshTenantId(tenantId ) {
5530
+ this.refreshTenantId = tenantId;
5531
+ }
5532
+
5524
5533
  setIsMobile(isMobile ) {
5525
5534
  this.isMobile = isMobile;
5526
5535
  }
@@ -5692,6 +5701,13 @@ class Auth {
5692
5701
  expiration: this.expiration,
5693
5702
  mobile: this.mobile,
5694
5703
  });
5704
+
5705
+ if (backend) {
5706
+ getApiClient().setRefreshBackend(backend);
5707
+ }
5708
+
5709
+ getApiClient().setRefreshTenantId(tenantId);
5710
+
5695
5711
  return this._onAuthenticated(rawSession);
5696
5712
  }
5697
5713
 
@@ -8731,11 +8747,14 @@ class WebRTCClient extends Emitter {
8731
8747
  }
8732
8748
 
8733
8749
  async _disconnectTransport(force = false) {
8734
- if (force) {
8750
+ if (force && this.userAgent && this.userAgent.transport) {
8735
8751
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8736
8752
  this.userAgent.transport.disconnectResolve = () => {};
8737
- // eslint-disable-next-line
8738
- this.userAgent.transport._ws.close(1000);
8753
+
8754
+ if (this.userAgent.transport._ws) {
8755
+ this.userAgent.transport._ws.close(1000);
8756
+ }
8757
+
8739
8758
  return;
8740
8759
  }
8741
8760
 
@@ -9387,7 +9406,7 @@ class WebRTCPhone extends Emitter {
9387
9406
  // When stopping screenshare and we had video before that, we have to re-upgrade
9388
9407
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9389
9408
  // We have to downgrade to audio.
9390
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9409
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9391
9410
  const constraints = { audio: false, video: screenshareStopped };
9392
9411
 
9393
9412
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9831,7 +9850,7 @@ class WebRTCPhone extends Emitter {
9831
9850
 
9832
9851
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9833
9852
 
9834
- // Stop screenshre if needed
9853
+ // Stop screenshare if needed
9835
9854
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9836
9855
  this.lastScreenShare = this.currentScreenShare;
9837
9856
  await this.stopScreenSharing(false, callSession);
@@ -10593,7 +10612,7 @@ class WebRTCPhone extends Emitter {
10593
10612
  endTime: fromSession ? fromSession.endTime : null,
10594
10613
  answered: state === sessionState.SessionState.Established,
10595
10614
  paused: this.client.isCallHeld(sipSession),
10596
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10615
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10597
10616
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10598
10617
  number,
10599
10618
  ringing: false,
@@ -2268,12 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
2268
2268
  backend ,
2269
2269
  expiration ,
2270
2270
  isMobile = false,
2271
+ tenantId ,
2271
2272
  ) => {
2272
2273
  const body = {
2273
2274
  backend: backend || DEFAULT_BACKEND_USER,
2274
2275
  expiration: expiration || DETAULT_EXPIRATION,
2275
2276
  refresh_token: refreshToken,
2276
2277
  client_id: client.clientId,
2278
+ tenant_id: tenantId,
2277
2279
  };
2278
2280
 
2279
2281
  const headers = {
@@ -5425,6 +5427,7 @@ class ApiClient {
5425
5427
 
5426
5428
 
5427
5429
 
5430
+
5428
5431
 
5429
5432
 
5430
5433
 
@@ -5465,6 +5468,7 @@ class ApiClient {
5465
5468
  logger$a.info('refresh token callback called', {
5466
5469
  refreshToken: this.refreshToken,
5467
5470
  refreshBackend: this.refreshBackend,
5471
+ refreshTenantId: this.refreshTenantId,
5468
5472
  refreshExpiration: this.refreshExpiration,
5469
5473
  isMobile: this.isMobile,
5470
5474
  });
@@ -5478,6 +5482,7 @@ class ApiClient {
5478
5482
  this.refreshBackend,
5479
5483
  this.refreshExpiration,
5480
5484
  this.isMobile,
5485
+ this.refreshTenantId,
5481
5486
  );
5482
5487
 
5483
5488
  logger$a.info('token refreshed', { token: session.token });
@@ -5519,6 +5524,10 @@ class ApiClient {
5519
5524
  this.refreshBackend = refreshBackend;
5520
5525
  }
5521
5526
 
5527
+ setRefreshTenantId(tenantId ) {
5528
+ this.refreshTenantId = tenantId;
5529
+ }
5530
+
5522
5531
  setIsMobile(isMobile ) {
5523
5532
  this.isMobile = isMobile;
5524
5533
  }
@@ -5690,6 +5699,13 @@ class Auth {
5690
5699
  expiration: this.expiration,
5691
5700
  mobile: this.mobile,
5692
5701
  });
5702
+
5703
+ if (backend) {
5704
+ getApiClient().setRefreshBackend(backend);
5705
+ }
5706
+
5707
+ getApiClient().setRefreshTenantId(tenantId);
5708
+
5693
5709
  return this._onAuthenticated(rawSession);
5694
5710
  }
5695
5711
 
@@ -8729,11 +8745,14 @@ class WebRTCClient extends Emitter {
8729
8745
  }
8730
8746
 
8731
8747
  async _disconnectTransport(force = false) {
8732
- if (force) {
8748
+ if (force && this.userAgent && this.userAgent.transport) {
8733
8749
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8734
8750
  this.userAgent.transport.disconnectResolve = () => {};
8735
- // eslint-disable-next-line
8736
- this.userAgent.transport._ws.close(1000);
8751
+
8752
+ if (this.userAgent.transport._ws) {
8753
+ this.userAgent.transport._ws.close(1000);
8754
+ }
8755
+
8737
8756
  return;
8738
8757
  }
8739
8758
 
@@ -9385,7 +9404,7 @@ class WebRTCPhone extends Emitter {
9385
9404
  // When stopping screenshare and we had video before that, we have to re-upgrade
9386
9405
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9387
9406
  // We have to downgrade to audio.
9388
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9407
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9389
9408
  const constraints = { audio: false, video: screenshareStopped };
9390
9409
 
9391
9410
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9829,7 +9848,7 @@ class WebRTCPhone extends Emitter {
9829
9848
 
9830
9849
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9831
9850
 
9832
- // Stop screenshre if needed
9851
+ // Stop screenshare if needed
9833
9852
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9834
9853
  this.lastScreenShare = this.currentScreenShare;
9835
9854
  await this.stopScreenSharing(false, callSession);
@@ -10591,7 +10610,7 @@ class WebRTCPhone extends Emitter {
10591
10610
  endTime: fromSession ? fromSession.endTime : null,
10592
10611
  answered: state === sessionState.SessionState.Established,
10593
10612
  paused: this.client.isCallHeld(sipSession),
10594
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10613
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10595
10614
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10596
10615
  number,
10597
10616
  ringing: false,
@@ -2268,12 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
2268
2268
  backend ,
2269
2269
  expiration ,
2270
2270
  isMobile = false,
2271
+ tenantId ,
2271
2272
  ) => {
2272
2273
  const body = {
2273
2274
  backend: backend || DEFAULT_BACKEND_USER,
2274
2275
  expiration: expiration || DETAULT_EXPIRATION,
2275
2276
  refresh_token: refreshToken,
2276
2277
  client_id: client.clientId,
2278
+ tenant_id: tenantId,
2277
2279
  };
2278
2280
 
2279
2281
  const headers = {
@@ -5425,6 +5427,7 @@ class ApiClient {
5425
5427
 
5426
5428
 
5427
5429
 
5430
+
5428
5431
 
5429
5432
 
5430
5433
 
@@ -5465,6 +5468,7 @@ class ApiClient {
5465
5468
  logger$a.info('refresh token callback called', {
5466
5469
  refreshToken: this.refreshToken,
5467
5470
  refreshBackend: this.refreshBackend,
5471
+ refreshTenantId: this.refreshTenantId,
5468
5472
  refreshExpiration: this.refreshExpiration,
5469
5473
  isMobile: this.isMobile,
5470
5474
  });
@@ -5478,6 +5482,7 @@ class ApiClient {
5478
5482
  this.refreshBackend,
5479
5483
  this.refreshExpiration,
5480
5484
  this.isMobile,
5485
+ this.refreshTenantId,
5481
5486
  );
5482
5487
 
5483
5488
  logger$a.info('token refreshed', { token: session.token });
@@ -5519,6 +5524,10 @@ class ApiClient {
5519
5524
  this.refreshBackend = refreshBackend;
5520
5525
  }
5521
5526
 
5527
+ setRefreshTenantId(tenantId ) {
5528
+ this.refreshTenantId = tenantId;
5529
+ }
5530
+
5522
5531
  setIsMobile(isMobile ) {
5523
5532
  this.isMobile = isMobile;
5524
5533
  }
@@ -5690,6 +5699,13 @@ class Auth {
5690
5699
  expiration: this.expiration,
5691
5700
  mobile: this.mobile,
5692
5701
  });
5702
+
5703
+ if (backend) {
5704
+ getApiClient().setRefreshBackend(backend);
5705
+ }
5706
+
5707
+ getApiClient().setRefreshTenantId(tenantId);
5708
+
5693
5709
  return this._onAuthenticated(rawSession);
5694
5710
  }
5695
5711
 
@@ -8729,11 +8745,14 @@ class WebRTCClient extends Emitter {
8729
8745
  }
8730
8746
 
8731
8747
  async _disconnectTransport(force = false) {
8732
- if (force) {
8748
+ if (force && this.userAgent && this.userAgent.transport) {
8733
8749
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8734
8750
  this.userAgent.transport.disconnectResolve = () => {};
8735
- // eslint-disable-next-line
8736
- this.userAgent.transport._ws.close(1000);
8751
+
8752
+ if (this.userAgent.transport._ws) {
8753
+ this.userAgent.transport._ws.close(1000);
8754
+ }
8755
+
8737
8756
  return;
8738
8757
  }
8739
8758
 
@@ -9385,7 +9404,7 @@ class WebRTCPhone extends Emitter {
9385
9404
  // When stopping screenshare and we had video before that, we have to re-upgrade
9386
9405
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9387
9406
  // We have to downgrade to audio.
9388
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9407
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9389
9408
  const constraints = { audio: false, video: screenshareStopped };
9390
9409
 
9391
9410
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9829,7 +9848,7 @@ class WebRTCPhone extends Emitter {
9829
9848
 
9830
9849
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9831
9850
 
9832
- // Stop screenshre if needed
9851
+ // Stop screenshare if needed
9833
9852
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9834
9853
  this.lastScreenShare = this.currentScreenShare;
9835
9854
  await this.stopScreenSharing(false, callSession);
@@ -10591,7 +10610,7 @@ class WebRTCPhone extends Emitter {
10591
10610
  endTime: fromSession ? fromSession.endTime : null,
10592
10611
  answered: state === sessionState.SessionState.Established,
10593
10612
  paused: this.client.isCallHeld(sipSession),
10594
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10613
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10595
10614
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10596
10615
  number,
10597
10616
  ringing: false,
@@ -2268,12 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
2268
2268
  backend ,
2269
2269
  expiration ,
2270
2270
  isMobile = false,
2271
+ tenantId ,
2271
2272
  ) => {
2272
2273
  const body = {
2273
2274
  backend: backend || DEFAULT_BACKEND_USER,
2274
2275
  expiration: expiration || DETAULT_EXPIRATION,
2275
2276
  refresh_token: refreshToken,
2276
2277
  client_id: client.clientId,
2278
+ tenant_id: tenantId,
2277
2279
  };
2278
2280
 
2279
2281
  const headers = {
@@ -5425,6 +5427,7 @@ class ApiClient {
5425
5427
 
5426
5428
 
5427
5429
 
5430
+
5428
5431
 
5429
5432
 
5430
5433
 
@@ -5465,6 +5468,7 @@ class ApiClient {
5465
5468
  logger$a.info('refresh token callback called', {
5466
5469
  refreshToken: this.refreshToken,
5467
5470
  refreshBackend: this.refreshBackend,
5471
+ refreshTenantId: this.refreshTenantId,
5468
5472
  refreshExpiration: this.refreshExpiration,
5469
5473
  isMobile: this.isMobile,
5470
5474
  });
@@ -5478,6 +5482,7 @@ class ApiClient {
5478
5482
  this.refreshBackend,
5479
5483
  this.refreshExpiration,
5480
5484
  this.isMobile,
5485
+ this.refreshTenantId,
5481
5486
  );
5482
5487
 
5483
5488
  logger$a.info('token refreshed', { token: session.token });
@@ -5519,6 +5524,10 @@ class ApiClient {
5519
5524
  this.refreshBackend = refreshBackend;
5520
5525
  }
5521
5526
 
5527
+ setRefreshTenantId(tenantId ) {
5528
+ this.refreshTenantId = tenantId;
5529
+ }
5530
+
5522
5531
  setIsMobile(isMobile ) {
5523
5532
  this.isMobile = isMobile;
5524
5533
  }
@@ -5690,6 +5699,13 @@ class Auth {
5690
5699
  expiration: this.expiration,
5691
5700
  mobile: this.mobile,
5692
5701
  });
5702
+
5703
+ if (backend) {
5704
+ getApiClient().setRefreshBackend(backend);
5705
+ }
5706
+
5707
+ getApiClient().setRefreshTenantId(tenantId);
5708
+
5693
5709
  return this._onAuthenticated(rawSession);
5694
5710
  }
5695
5711
 
@@ -8729,11 +8745,14 @@ class WebRTCClient extends Emitter {
8729
8745
  }
8730
8746
 
8731
8747
  async _disconnectTransport(force = false) {
8732
- if (force) {
8748
+ if (force && this.userAgent && this.userAgent.transport) {
8733
8749
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8734
8750
  this.userAgent.transport.disconnectResolve = () => {};
8735
- // eslint-disable-next-line
8736
- this.userAgent.transport._ws.close(1000);
8751
+
8752
+ if (this.userAgent.transport._ws) {
8753
+ this.userAgent.transport._ws.close(1000);
8754
+ }
8755
+
8737
8756
  return;
8738
8757
  }
8739
8758
 
@@ -9385,7 +9404,7 @@ class WebRTCPhone extends Emitter {
9385
9404
  // When stopping screenshare and we had video before that, we have to re-upgrade
9386
9405
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9387
9406
  // We have to downgrade to audio.
9388
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9407
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9389
9408
  const constraints = { audio: false, video: screenshareStopped };
9390
9409
 
9391
9410
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9829,7 +9848,7 @@ class WebRTCPhone extends Emitter {
9829
9848
 
9830
9849
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9831
9850
 
9832
- // Stop screenshre if needed
9851
+ // Stop screenshare if needed
9833
9852
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9834
9853
  this.lastScreenShare = this.currentScreenShare;
9835
9854
  await this.stopScreenSharing(false, callSession);
@@ -10591,7 +10610,7 @@ class WebRTCPhone extends Emitter {
10591
10610
  endTime: fromSession ? fromSession.endTime : null,
10592
10611
  answered: state === sessionState.SessionState.Established,
10593
10612
  paused: this.client.isCallHeld(sipSession),
10594
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10613
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10595
10614
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10596
10615
  number,
10597
10616
  ringing: false,
@@ -2270,12 +2270,14 @@ var authMethods = (client , baseUrl ) => ({
2270
2270
  backend ,
2271
2271
  expiration ,
2272
2272
  isMobile = false,
2273
+ tenantId ,
2273
2274
  ) => {
2274
2275
  const body = {
2275
2276
  backend: backend || DEFAULT_BACKEND_USER,
2276
2277
  expiration: expiration || DETAULT_EXPIRATION,
2277
2278
  refresh_token: refreshToken,
2278
2279
  client_id: client.clientId,
2280
+ tenant_id: tenantId,
2279
2281
  };
2280
2282
 
2281
2283
  const headers = {
@@ -5427,6 +5429,7 @@ class ApiClient {
5427
5429
 
5428
5430
 
5429
5431
 
5432
+
5430
5433
 
5431
5434
 
5432
5435
 
@@ -5467,6 +5470,7 @@ class ApiClient {
5467
5470
  logger$a.info('refresh token callback called', {
5468
5471
  refreshToken: this.refreshToken,
5469
5472
  refreshBackend: this.refreshBackend,
5473
+ refreshTenantId: this.refreshTenantId,
5470
5474
  refreshExpiration: this.refreshExpiration,
5471
5475
  isMobile: this.isMobile,
5472
5476
  });
@@ -5480,6 +5484,7 @@ class ApiClient {
5480
5484
  this.refreshBackend,
5481
5485
  this.refreshExpiration,
5482
5486
  this.isMobile,
5487
+ this.refreshTenantId,
5483
5488
  );
5484
5489
 
5485
5490
  logger$a.info('token refreshed', { token: session.token });
@@ -5521,6 +5526,10 @@ class ApiClient {
5521
5526
  this.refreshBackend = refreshBackend;
5522
5527
  }
5523
5528
 
5529
+ setRefreshTenantId(tenantId ) {
5530
+ this.refreshTenantId = tenantId;
5531
+ }
5532
+
5524
5533
  setIsMobile(isMobile ) {
5525
5534
  this.isMobile = isMobile;
5526
5535
  }
@@ -5692,6 +5701,13 @@ class Auth {
5692
5701
  expiration: this.expiration,
5693
5702
  mobile: this.mobile,
5694
5703
  });
5704
+
5705
+ if (backend) {
5706
+ getApiClient().setRefreshBackend(backend);
5707
+ }
5708
+
5709
+ getApiClient().setRefreshTenantId(tenantId);
5710
+
5695
5711
  return this._onAuthenticated(rawSession);
5696
5712
  }
5697
5713
 
@@ -8731,11 +8747,14 @@ class WebRTCClient extends Emitter {
8731
8747
  }
8732
8748
 
8733
8749
  async _disconnectTransport(force = false) {
8734
- if (force) {
8750
+ if (force && this.userAgent && this.userAgent.transport) {
8735
8751
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8736
8752
  this.userAgent.transport.disconnectResolve = () => {};
8737
- // eslint-disable-next-line
8738
- this.userAgent.transport._ws.close(1000);
8753
+
8754
+ if (this.userAgent.transport._ws) {
8755
+ this.userAgent.transport._ws.close(1000);
8756
+ }
8757
+
8739
8758
  return;
8740
8759
  }
8741
8760
 
@@ -9387,7 +9406,7 @@ class WebRTCPhone extends Emitter {
9387
9406
  // When stopping screenshare and we had video before that, we have to re-upgrade
9388
9407
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9389
9408
  // We have to downgrade to audio.
9390
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9409
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9391
9410
  const constraints = { audio: false, video: screenshareStopped };
9392
9411
 
9393
9412
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9831,7 +9850,7 @@ class WebRTCPhone extends Emitter {
9831
9850
 
9832
9851
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9833
9852
 
9834
- // Stop screenshre if needed
9853
+ // Stop screenshare if needed
9835
9854
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9836
9855
  this.lastScreenShare = this.currentScreenShare;
9837
9856
  await this.stopScreenSharing(false, callSession);
@@ -10593,7 +10612,7 @@ class WebRTCPhone extends Emitter {
10593
10612
  endTime: fromSession ? fromSession.endTime : null,
10594
10613
  answered: state === sessionState.SessionState.Established,
10595
10614
  paused: this.client.isCallHeld(sipSession),
10596
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10615
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10597
10616
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10598
10617
  number,
10599
10618
  ringing: false,