@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
@@ -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
  }
@@ -8456,11 +8465,14 @@ class WebRTCClient extends Emitter {
8456
8465
  }
8457
8466
 
8458
8467
  async _disconnectTransport(force = false) {
8459
- if (force) {
8468
+ if (force && this.userAgent && this.userAgent.transport) {
8460
8469
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8461
8470
  this.userAgent.transport.disconnectResolve = () => {};
8462
- // eslint-disable-next-line
8463
- this.userAgent.transport._ws.close(1000);
8471
+
8472
+ if (this.userAgent.transport._ws) {
8473
+ this.userAgent.transport._ws.close(1000);
8474
+ }
8475
+
8464
8476
  return;
8465
8477
  }
8466
8478
 
@@ -9112,7 +9124,7 @@ class WebRTCPhone extends Emitter {
9112
9124
  // When stopping screenshare and we had video before that, we have to re-upgrade
9113
9125
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9114
9126
  // We have to downgrade to audio.
9115
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9127
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9116
9128
  const constraints = { audio: false, video: screenshareStopped };
9117
9129
 
9118
9130
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9556,7 +9568,7 @@ class WebRTCPhone extends Emitter {
9556
9568
 
9557
9569
  logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9558
9570
 
9559
- // Stop screenshre if needed
9571
+ // Stop screenshare if needed
9560
9572
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9561
9573
  this.lastScreenShare = this.currentScreenShare;
9562
9574
  await this.stopScreenSharing(false, callSession);
@@ -10318,7 +10330,7 @@ class WebRTCPhone extends Emitter {
10318
10330
  endTime: fromSession ? fromSession.endTime : null,
10319
10331
  answered: state === sessionState.SessionState.Established,
10320
10332
  paused: this.client.isCallHeld(sipSession),
10321
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10333
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10322
10334
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10323
10335
  number,
10324
10336
  ringing: false,
@@ -13776,6 +13788,13 @@ class Auth {
13776
13788
  expiration: this.expiration,
13777
13789
  mobile: this.mobile,
13778
13790
  });
13791
+
13792
+ if (backend) {
13793
+ getApiClient().setRefreshBackend(backend);
13794
+ }
13795
+
13796
+ getApiClient().setRefreshTenantId(tenantId);
13797
+
13779
13798
  return this._onAuthenticated(rawSession);
13780
13799
  }
13781
13800
 
@@ -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
  }
@@ -8454,11 +8463,14 @@ class WebRTCClient extends Emitter {
8454
8463
  }
8455
8464
 
8456
8465
  async _disconnectTransport(force = false) {
8457
- if (force) {
8466
+ if (force && this.userAgent && this.userAgent.transport) {
8458
8467
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8459
8468
  this.userAgent.transport.disconnectResolve = () => {};
8460
- // eslint-disable-next-line
8461
- this.userAgent.transport._ws.close(1000);
8469
+
8470
+ if (this.userAgent.transport._ws) {
8471
+ this.userAgent.transport._ws.close(1000);
8472
+ }
8473
+
8462
8474
  return;
8463
8475
  }
8464
8476
 
@@ -9110,7 +9122,7 @@ class WebRTCPhone extends Emitter {
9110
9122
  // When stopping screenshare and we had video before that, we have to re-upgrade
9111
9123
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9112
9124
  // We have to downgrade to audio.
9113
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9125
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9114
9126
  const constraints = { audio: false, video: screenshareStopped };
9115
9127
 
9116
9128
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9554,7 +9566,7 @@ class WebRTCPhone extends Emitter {
9554
9566
 
9555
9567
  logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9556
9568
 
9557
- // Stop screenshre if needed
9569
+ // Stop screenshare if needed
9558
9570
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9559
9571
  this.lastScreenShare = this.currentScreenShare;
9560
9572
  await this.stopScreenSharing(false, callSession);
@@ -10316,7 +10328,7 @@ class WebRTCPhone extends Emitter {
10316
10328
  endTime: fromSession ? fromSession.endTime : null,
10317
10329
  answered: state === sessionState.SessionState.Established,
10318
10330
  paused: this.client.isCallHeld(sipSession),
10319
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10331
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10320
10332
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10321
10333
  number,
10322
10334
  ringing: false,
@@ -13757,6 +13769,13 @@ class Auth {
13757
13769
  expiration: this.expiration,
13758
13770
  mobile: this.mobile,
13759
13771
  });
13772
+
13773
+ if (backend) {
13774
+ getApiClient().setRefreshBackend(backend);
13775
+ }
13776
+
13777
+ getApiClient().setRefreshTenantId(tenantId);
13778
+
13760
13779
  return this._onAuthenticated(rawSession);
13761
13780
  }
13762
13781
 
@@ -2244,12 +2244,14 @@ var authMethods = (client , baseUrl ) => ({
2244
2244
  backend ,
2245
2245
  expiration ,
2246
2246
  isMobile = false,
2247
+ tenantId ,
2247
2248
  ) => {
2248
2249
  const body = {
2249
2250
  backend: backend || DEFAULT_BACKEND_USER,
2250
2251
  expiration: expiration || DETAULT_EXPIRATION,
2251
2252
  refresh_token: refreshToken,
2252
2253
  client_id: client.clientId,
2254
+ tenant_id: tenantId,
2253
2255
  };
2254
2256
 
2255
2257
  const headers = {
@@ -4572,6 +4574,7 @@ class ApiClient {
4572
4574
 
4573
4575
 
4574
4576
 
4577
+
4575
4578
 
4576
4579
 
4577
4580
 
@@ -4612,6 +4615,7 @@ class ApiClient {
4612
4615
  logger.info('refresh token callback called', {
4613
4616
  refreshToken: this.refreshToken,
4614
4617
  refreshBackend: this.refreshBackend,
4618
+ refreshTenantId: this.refreshTenantId,
4615
4619
  refreshExpiration: this.refreshExpiration,
4616
4620
  isMobile: this.isMobile,
4617
4621
  });
@@ -4625,6 +4629,7 @@ class ApiClient {
4625
4629
  this.refreshBackend,
4626
4630
  this.refreshExpiration,
4627
4631
  this.isMobile,
4632
+ this.refreshTenantId,
4628
4633
  );
4629
4634
 
4630
4635
  logger.info('token refreshed', { token: session.token });
@@ -4666,6 +4671,10 @@ class ApiClient {
4666
4671
  this.refreshBackend = refreshBackend;
4667
4672
  }
4668
4673
 
4674
+ setRefreshTenantId(tenantId ) {
4675
+ this.refreshTenantId = tenantId;
4676
+ }
4677
+
4669
4678
  setIsMobile(isMobile ) {
4670
4679
  this.isMobile = isMobile;
4671
4680
  }
@@ -2871,12 +2871,14 @@ var authMethods = (client , baseUrl ) => ({
2871
2871
  backend ,
2872
2872
  expiration ,
2873
2873
  isMobile = false,
2874
+ tenantId ,
2874
2875
  ) => {
2875
2876
  const body = {
2876
2877
  backend: backend || DEFAULT_BACKEND_USER,
2877
2878
  expiration: expiration || DETAULT_EXPIRATION,
2878
2879
  refresh_token: refreshToken,
2879
2880
  client_id: client.clientId,
2881
+ tenant_id: tenantId,
2880
2882
  };
2881
2883
 
2882
2884
  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
  }
@@ -8454,11 +8463,14 @@ class WebRTCClient extends Emitter {
8454
8463
  }
8455
8464
 
8456
8465
  async _disconnectTransport(force = false) {
8457
- if (force) {
8466
+ if (force && this.userAgent && this.userAgent.transport) {
8458
8467
  // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8459
8468
  this.userAgent.transport.disconnectResolve = () => {};
8460
- // eslint-disable-next-line
8461
- this.userAgent.transport._ws.close(1000);
8469
+
8470
+ if (this.userAgent.transport._ws) {
8471
+ this.userAgent.transport._ws.close(1000);
8472
+ }
8473
+
8462
8474
  return;
8463
8475
  }
8464
8476
 
@@ -9110,7 +9122,7 @@ class WebRTCPhone extends Emitter {
9110
9122
  // When stopping screenshare and we had video before that, we have to re-upgrade
9111
9123
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9112
9124
  // We have to downgrade to audio.
9113
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9125
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9114
9126
  const constraints = { audio: false, video: screenshareStopped };
9115
9127
 
9116
9128
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9554,7 +9566,7 @@ class WebRTCPhone extends Emitter {
9554
9566
 
9555
9567
  logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9556
9568
 
9557
- // Stop screenshre if needed
9569
+ // Stop screenshare if needed
9558
9570
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9559
9571
  this.lastScreenShare = this.currentScreenShare;
9560
9572
  await this.stopScreenSharing(false, callSession);
@@ -10316,7 +10328,7 @@ class WebRTCPhone extends Emitter {
10316
10328
  endTime: fromSession ? fromSession.endTime : null,
10317
10329
  answered: state === sessionState.SessionState.Established,
10318
10330
  paused: this.client.isCallHeld(sipSession),
10319
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10331
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10320
10332
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10321
10333
  number,
10322
10334
  ringing: false,
@@ -10458,6 +10470,13 @@ class Auth {
10458
10470
  expiration: this.expiration,
10459
10471
  mobile: this.mobile,
10460
10472
  });
10473
+
10474
+ if (backend) {
10475
+ getApiClient().setRefreshBackend(backend);
10476
+ }
10477
+
10478
+ getApiClient().setRefreshTenantId(tenantId);
10479
+
10461
10480
  return this._onAuthenticated(rawSession);
10462
10481
  }
10463
10482
 
@@ -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,
@@ -2294,12 +2294,14 @@ var authMethods = (client , baseUrl ) => ({
2294
2294
  backend ,
2295
2295
  expiration ,
2296
2296
  isMobile = false,
2297
+ tenantId ,
2297
2298
  ) => {
2298
2299
  const body = {
2299
2300
  backend: backend || DEFAULT_BACKEND_USER,
2300
2301
  expiration: expiration || DETAULT_EXPIRATION,
2301
2302
  refresh_token: refreshToken,
2302
2303
  client_id: client.clientId,
2304
+ tenant_id: tenantId,
2303
2305
  };
2304
2306
 
2305
2307
  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,
@@ -2294,12 +2294,14 @@ var authMethods = (client , baseUrl ) => ({
2294
2294
  backend ,
2295
2295
  expiration ,
2296
2296
  isMobile = false,
2297
+ tenantId ,
2297
2298
  ) => {
2298
2299
  const body = {
2299
2300
  backend: backend || DEFAULT_BACKEND_USER,
2300
2301
  expiration: expiration || DETAULT_EXPIRATION,
2301
2302
  refresh_token: refreshToken,
2302
2303
  client_id: client.clientId,
2304
+ tenant_id: tenantId,
2303
2305
  };
2304
2306
 
2305
2307
  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,