@wazo/sdk 0.38.8 → 0.38.11

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 (78) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +21 -0
  3. package/esm/__tests__/web-rtc-client.test.js +31 -6
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/ctid-ng.js +1 -0
  6. package/esm/api-client.js +21 -0
  7. package/esm/checker/Checker.js +31 -6
  8. package/esm/checker/checks/aor.js +21 -0
  9. package/esm/checker/checks/api.js +21 -0
  10. package/esm/checker/checks/index.js +31 -6
  11. package/esm/checker/checks/webrtc-transport.js +31 -6
  12. package/esm/checker/checks/webrtc.js +31 -6
  13. package/esm/domain/AdHocAPIConference.js +28 -2
  14. package/esm/domain/Features.js +28 -2
  15. package/esm/domain/Phone/CTIPhone.js +28 -2
  16. package/esm/domain/Phone/WebRTCPhone.js +4 -5
  17. package/esm/index.js +86 -17
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +87 -18
  21. package/esm/simple/Configuration.js +86 -17
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +86 -17
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +86 -17
  26. package/esm/simple/room/LocalParticipant.js +86 -17
  27. package/esm/simple/room/Participant.js +86 -17
  28. package/esm/simple/room/RemoteParticipant.js +86 -17
  29. package/esm/simple/room/Room.js +86 -17
  30. package/esm/simple/room/SipRoom.js +86 -17
  31. package/esm/simple/room/Stream.js +86 -17
  32. package/esm/simple/room/__tests__/Participant.test.js +86 -17
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -17
  34. package/esm/simple/utils.js +86 -17
  35. package/esm/web-rtc-client.js +31 -6
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +31 -6
  38. package/lib/api/auth.js +12 -0
  39. package/lib/api/ctid-ng.js +1 -0
  40. package/lib/api-client.js +21 -0
  41. package/lib/checker/Checker.js +31 -6
  42. package/lib/checker/checks/aor.js +21 -0
  43. package/lib/checker/checks/api.js +21 -0
  44. package/lib/checker/checks/index.js +31 -6
  45. package/lib/checker/checks/webrtc-transport.js +31 -6
  46. package/lib/checker/checks/webrtc.js +31 -6
  47. package/lib/domain/AdHocAPIConference.js +28 -2
  48. package/lib/domain/Features.js +28 -2
  49. package/lib/domain/Phone/CTIPhone.js +28 -2
  50. package/lib/domain/Phone/WebRTCPhone.js +4 -5
  51. package/lib/index.js +86 -17
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +87 -17
  55. package/lib/simple/Configuration.js +86 -17
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +86 -17
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +86 -17
  60. package/lib/simple/room/LocalParticipant.js +86 -17
  61. package/lib/simple/room/Participant.js +86 -17
  62. package/lib/simple/room/RemoteParticipant.js +86 -17
  63. package/lib/simple/room/Room.js +86 -17
  64. package/lib/simple/room/SipRoom.js +86 -17
  65. package/lib/simple/room/Stream.js +86 -17
  66. package/lib/simple/room/__tests__/Participant.test.js +86 -17
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -17
  68. package/lib/simple/utils.js +86 -17
  69. package/lib/web-rtc-client.js +31 -6
  70. package/package.json +2 -2
  71. package/src/api/auth.js +12 -0
  72. package/src/api-client.js +8 -0
  73. package/src/domain/Phone/WebRTCPhone.js +3 -5
  74. package/src/service/getApiClient.js +13 -2
  75. package/src/simple/Auth.js +35 -4
  76. package/src/simple/Softphone.js +5 -0
  77. package/src/simple/index.js +2 -1
  78. package/src/web-rtc-client.js +10 -6
@@ -2241,6 +2241,7 @@ var authMethods = (client , baseUrl ) => ({
2241
2241
 
2242
2242
 
2243
2243
 
2244
+
2244
2245
  ) {
2245
2246
  const body = {
2246
2247
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2261,9 +2262,14 @@ var authMethods = (client , baseUrl ) => ({
2261
2262
  }
2262
2263
 
2263
2264
  if (params.tenantId) {
2265
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2264
2266
  body.tenant_id = params.tenantId;
2265
2267
  }
2266
2268
 
2269
+ if (params.domainName) {
2270
+ body.domain_name = params.domainName;
2271
+ }
2272
+
2267
2273
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2268
2274
  },
2269
2275
 
@@ -2276,6 +2282,7 @@ var authMethods = (client , baseUrl ) => ({
2276
2282
  expiration ,
2277
2283
  isMobile = false,
2278
2284
  tenantId ,
2285
+ domainName ,
2279
2286
  ) => {
2280
2287
  const body = {
2281
2288
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2292,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2292
  };
2286
2293
 
2287
2294
  if (tenantId) {
2295
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2288
2296
  body.tenant_id = tenantId;
2289
2297
  }
2290
2298
 
2299
+ if (domainName) {
2300
+ body.domain_name = domainName;
2301
+ }
2302
+
2291
2303
  const headers = {
2292
2304
  'Content-Type': 'application/json',
2293
2305
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5585,6 +5597,7 @@ class ApiClient {
5585
5597
 
5586
5598
 
5587
5599
 
5600
+
5588
5601
 
5589
5602
 
5590
5603
 
@@ -5626,6 +5639,7 @@ class ApiClient {
5626
5639
  refreshToken: this.refreshToken,
5627
5640
  refreshBackend: this.refreshBackend,
5628
5641
  refreshTenantId: this.refreshTenantId,
5642
+ refreshDomainName: this.refreshDomainName,
5629
5643
  refreshExpiration: this.refreshExpiration,
5630
5644
  isMobile: this.isMobile,
5631
5645
  });
@@ -5641,6 +5655,7 @@ class ApiClient {
5641
5655
  this.refreshExpiration,
5642
5656
  this.isMobile,
5643
5657
  this.refreshTenantId,
5658
+ this.refreshDomainName,
5644
5659
  );
5645
5660
 
5646
5661
  logger$a.info('token refreshed', { token: session.token });
@@ -5694,9 +5709,14 @@ class ApiClient {
5694
5709
  }
5695
5710
 
5696
5711
  setRefreshTenantId(tenantId ) {
5712
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5697
5713
  this.refreshTenantId = tenantId;
5698
5714
  }
5699
5715
 
5716
+ setRefreshDomainName(domainName ) {
5717
+ this.refreshDomainName = domainName;
5718
+ }
5719
+
5700
5720
  setIsMobile(isMobile ) {
5701
5721
  this.isMobile = isMobile;
5702
5722
  }
@@ -5721,6 +5741,7 @@ global.wazoClientId = global.wazoClientId || {};
5721
5741
  global.wazoClientToken = global.wazoClientToken || {};
5722
5742
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5723
5743
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5744
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5724
5745
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5725
5746
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5726
5747
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5745,9 +5766,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5745
5766
  };
5746
5767
 
5747
5768
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5769
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5748
5770
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5749
5771
  };
5750
5772
 
5773
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5774
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5775
+ };
5776
+
5751
5777
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5752
5778
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5753
5779
  };
@@ -5766,6 +5792,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5766
5792
 
5767
5793
  const fillClient = (apiClient ) => {
5768
5794
  const { server, token, clientId } = apiClient.client;
5795
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5769
5796
 
5770
5797
  // try with null server when dealing with non-related server info
5771
5798
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5774,8 +5801,12 @@ const fillClient = (apiClient ) => {
5774
5801
 
5775
5802
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5776
5803
 
5777
- apiClient.setRefreshTenantId(
5778
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5804
+ if (tenantId) {
5805
+ apiClient.setRefreshTenantId(tenantId);
5806
+ }
5807
+
5808
+ apiClient.setRefreshDomainName(
5809
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5779
5810
  );
5780
5811
 
5781
5812
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7472,9 +7503,11 @@ class WebRTCClient extends Emitter {
7472
7503
  const videoTracks = localStream.getVideoTracks();
7473
7504
 
7474
7505
  // Remove video senders
7475
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7476
- videoSender.replaceTrack(null);
7477
- });
7506
+ if (pc.getSenders) {
7507
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7508
+ videoSender.replaceTrack(null);
7509
+ });
7510
+ }
7478
7511
 
7479
7512
  videoTracks.forEach(videoTrack => {
7480
7513
  videoTrack.enabled = false;
@@ -7707,7 +7740,8 @@ class WebRTCClient extends Emitter {
7707
7740
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7708
7741
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7709
7742
  const audioTrack = stream.getAudioTracks()[0];
7710
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7743
+ const sender = pc && pc.getSenders
7744
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7711
7745
 
7712
7746
  if (sender) {
7713
7747
  if (sender.track) {
@@ -7770,10 +7804,11 @@ class WebRTCClient extends Emitter {
7770
7804
  // $FlowFixMe
7771
7805
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
7772
7806
  const videoTrack = stream.getVideoTracks()[0];
7773
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7807
+ let sender = pc && pc.getSenders
7808
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7774
7809
  let wasTrackEnabled = false;
7775
7810
  if (!sender) {
7776
- sender = pc && pc.getSenders().find(s => !s.track);
7811
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
7777
7812
  }
7778
7813
 
7779
7814
  if (sender) {
@@ -9307,7 +9342,7 @@ class WebRTCPhone extends Emitter {
9307
9342
  const screenTrack = screenShareStream.getVideoTracks()[0];
9308
9343
  const sipSession = this.currentSipSession;
9309
9344
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9310
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9345
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9311
9346
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9312
9347
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9313
9348
  const hadVideo = !!videoTrack;
@@ -9345,9 +9380,7 @@ class WebRTCPhone extends Emitter {
9345
9380
 
9346
9381
  try {
9347
9382
  if (this.currentScreenShare.stream) {
9348
- this.currentScreenShare.stream.getTracks()
9349
- .filter(track => track.kind === 'video')
9350
- .forEach(track => track.stop());
9383
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9351
9384
  }
9352
9385
 
9353
9386
  if (restoreLocalStream) {
@@ -9391,7 +9424,7 @@ class WebRTCPhone extends Emitter {
9391
9424
  const screenTrack = screenStream.getVideoTracks()[0];
9392
9425
  const sipSessionId = this.getSipSessionId(sipSession);
9393
9426
  const pc = this.client.getPeerConnection(sipSessionId);
9394
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9427
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9395
9428
 
9396
9429
  logger$8.info('WebRTC phone - on screensharing', {
9397
9430
  hadVideo,
@@ -14023,6 +14056,7 @@ class Softphone {
14023
14056
  wrapUpDuration,
14024
14057
  enableAgent = true,
14025
14058
  tenantId,
14059
+ domainName,
14026
14060
  debug = false,
14027
14061
  } = {}) {
14028
14062
  this.url = url || 'https://softphone.wazo.io';
@@ -14047,8 +14081,12 @@ class Softphone {
14047
14081
  config.port = port;
14048
14082
  }
14049
14083
  if (tenantId) {
14084
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14050
14085
  config.tenantId = tenantId;
14051
14086
  }
14087
+ if (domainName) {
14088
+ config.domainName = domainName;
14089
+ }
14052
14090
  if (wrapUpDuration) {
14053
14091
  config.wrapUpDuration = wrapUpDuration;
14054
14092
  }
@@ -14369,6 +14407,7 @@ const Wazo = {
14369
14407
  CanceledCallError,
14370
14408
  SFUNotAvailableError,
14371
14409
  NoTenantIdError,
14410
+ NoDomainNameError,
14372
14411
  };
14373
14412
 
14374
14413
  if (window) {
@@ -14383,6 +14422,7 @@ if (global) {
14383
14422
  class InvalidSubscription extends Error {}
14384
14423
  class InvalidAuthorization extends Error {}
14385
14424
  class NoTenantIdError extends Error {}
14425
+ class NoDomainNameError extends Error {}
14386
14426
 
14387
14427
  const logger = IssueReporter$1.loggerFor('simple-auth');
14388
14428
 
@@ -14446,9 +14486,24 @@ class Auth {
14446
14486
  setFetchOptions(options);
14447
14487
  }
14448
14488
 
14449
- async logIn(username , password , backend , tenantId ) {
14450
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14451
- throw new NoTenantIdError('No tenant id');
14489
+ async logIn(username , password , backend , extra ) {
14490
+ let tenantId = null;
14491
+ let domainName = null;
14492
+ if (typeof extra === 'string') {
14493
+ tenantId = extra;
14494
+ }
14495
+ if (extra && typeof extra === 'object') {
14496
+ domainName = extra.domainName;
14497
+ }
14498
+
14499
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14500
+ if (!tenantId) {
14501
+ throw new NoTenantIdError('No tenant id');
14502
+ }
14503
+
14504
+ if (!domainName) {
14505
+ throw new NoDomainNameError('No domain name');
14506
+ }
14452
14507
  }
14453
14508
 
14454
14509
  this.authenticated = false;
@@ -14458,6 +14513,7 @@ class Auth {
14458
14513
  password,
14459
14514
  backend,
14460
14515
  tenantId,
14516
+ domainName,
14461
14517
  expiration: this.expiration,
14462
14518
  mobile: this.mobile,
14463
14519
  });
@@ -14466,7 +14522,13 @@ class Auth {
14466
14522
  getApiClient().setRefreshBackend(backend);
14467
14523
  }
14468
14524
 
14469
- getApiClient().setRefreshTenantId(tenantId);
14525
+ if (tenantId) {
14526
+ getApiClient().setRefreshTenantId(tenantId);
14527
+ }
14528
+
14529
+ if (domainName) {
14530
+ getApiClient().setRefreshDomainName(domainName);
14531
+ }
14470
14532
 
14471
14533
  return this._onAuthenticated(rawSession);
14472
14534
  }
@@ -14565,11 +14627,18 @@ class Auth {
14565
14627
  }
14566
14628
 
14567
14629
  setRefreshTenantId(refreshTenantId ) {
14630
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14568
14631
  setRefreshTenantId(refreshTenantId);
14569
14632
 
14570
14633
  getApiClient().setRefreshTenantId(refreshTenantId);
14571
14634
  }
14572
14635
 
14636
+ setRefreshDomainName(domainName ) {
14637
+ setRefreshDomainName(domainName);
14638
+
14639
+ getApiClient().setRefreshDomainName(domainName);
14640
+ }
14641
+
14573
14642
  forceRefreshToken() {
14574
14643
  getApiClient().forceRefreshToken();
14575
14644
  }
@@ -14681,5 +14750,6 @@ var Auth$1 = global.wazoAuthInstance;
14681
14750
 
14682
14751
  exports.InvalidAuthorization = InvalidAuthorization;
14683
14752
  exports.InvalidSubscription = InvalidSubscription;
14753
+ exports.NoDomainNameError = NoDomainNameError;
14684
14754
  exports.NoTenantIdError = NoTenantIdError;
14685
14755
  exports.default = Auth$1;
@@ -2239,6 +2239,7 @@ var authMethods = (client , baseUrl ) => ({
2239
2239
 
2240
2240
 
2241
2241
 
2242
+
2242
2243
  ) {
2243
2244
  const body = {
2244
2245
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2259,9 +2260,14 @@ var authMethods = (client , baseUrl ) => ({
2259
2260
  }
2260
2261
 
2261
2262
  if (params.tenantId) {
2263
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2262
2264
  body.tenant_id = params.tenantId;
2263
2265
  }
2264
2266
 
2267
+ if (params.domainName) {
2268
+ body.domain_name = params.domainName;
2269
+ }
2270
+
2265
2271
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2266
2272
  },
2267
2273
 
@@ -2274,6 +2280,7 @@ var authMethods = (client , baseUrl ) => ({
2274
2280
  expiration ,
2275
2281
  isMobile = false,
2276
2282
  tenantId ,
2283
+ domainName ,
2277
2284
  ) => {
2278
2285
  const body = {
2279
2286
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2283,9 +2290,14 @@ var authMethods = (client , baseUrl ) => ({
2283
2290
  };
2284
2291
 
2285
2292
  if (tenantId) {
2293
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2286
2294
  body.tenant_id = tenantId;
2287
2295
  }
2288
2296
 
2297
+ if (domainName) {
2298
+ body.domain_name = domainName;
2299
+ }
2300
+
2289
2301
  const headers = {
2290
2302
  'Content-Type': 'application/json',
2291
2303
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5583,6 +5595,7 @@ class ApiClient {
5583
5595
 
5584
5596
 
5585
5597
 
5598
+
5586
5599
 
5587
5600
 
5588
5601
 
@@ -5624,6 +5637,7 @@ class ApiClient {
5624
5637
  refreshToken: this.refreshToken,
5625
5638
  refreshBackend: this.refreshBackend,
5626
5639
  refreshTenantId: this.refreshTenantId,
5640
+ refreshDomainName: this.refreshDomainName,
5627
5641
  refreshExpiration: this.refreshExpiration,
5628
5642
  isMobile: this.isMobile,
5629
5643
  });
@@ -5639,6 +5653,7 @@ class ApiClient {
5639
5653
  this.refreshExpiration,
5640
5654
  this.isMobile,
5641
5655
  this.refreshTenantId,
5656
+ this.refreshDomainName,
5642
5657
  );
5643
5658
 
5644
5659
  logger$a.info('token refreshed', { token: session.token });
@@ -5692,9 +5707,14 @@ class ApiClient {
5692
5707
  }
5693
5708
 
5694
5709
  setRefreshTenantId(tenantId ) {
5710
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5695
5711
  this.refreshTenantId = tenantId;
5696
5712
  }
5697
5713
 
5714
+ setRefreshDomainName(domainName ) {
5715
+ this.refreshDomainName = domainName;
5716
+ }
5717
+
5698
5718
  setIsMobile(isMobile ) {
5699
5719
  this.isMobile = isMobile;
5700
5720
  }
@@ -5719,6 +5739,7 @@ global.wazoClientId = global.wazoClientId || {};
5719
5739
  global.wazoClientToken = global.wazoClientToken || {};
5720
5740
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5721
5741
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5742
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5722
5743
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5723
5744
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5724
5745
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5743,9 +5764,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5743
5764
  };
5744
5765
 
5745
5766
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5767
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5746
5768
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5747
5769
  };
5748
5770
 
5771
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5772
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5773
+ };
5774
+
5749
5775
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5750
5776
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5751
5777
  };
@@ -5764,6 +5790,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5764
5790
 
5765
5791
  const fillClient = (apiClient ) => {
5766
5792
  const { server, token, clientId } = apiClient.client;
5793
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5767
5794
 
5768
5795
  // try with null server when dealing with non-related server info
5769
5796
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5772,8 +5799,12 @@ const fillClient = (apiClient ) => {
5772
5799
 
5773
5800
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5774
5801
 
5775
- apiClient.setRefreshTenantId(
5776
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5802
+ if (tenantId) {
5803
+ apiClient.setRefreshTenantId(tenantId);
5804
+ }
5805
+
5806
+ apiClient.setRefreshDomainName(
5807
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5777
5808
  );
5778
5809
 
5779
5810
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7470,9 +7501,11 @@ class WebRTCClient extends Emitter {
7470
7501
  const videoTracks = localStream.getVideoTracks();
7471
7502
 
7472
7503
  // Remove video senders
7473
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7474
- videoSender.replaceTrack(null);
7475
- });
7504
+ if (pc.getSenders) {
7505
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7506
+ videoSender.replaceTrack(null);
7507
+ });
7508
+ }
7476
7509
 
7477
7510
  videoTracks.forEach(videoTrack => {
7478
7511
  videoTrack.enabled = false;
@@ -7705,7 +7738,8 @@ class WebRTCClient extends Emitter {
7705
7738
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7706
7739
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7707
7740
  const audioTrack = stream.getAudioTracks()[0];
7708
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7741
+ const sender = pc && pc.getSenders
7742
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7709
7743
 
7710
7744
  if (sender) {
7711
7745
  if (sender.track) {
@@ -7768,10 +7802,11 @@ class WebRTCClient extends Emitter {
7768
7802
  // $FlowFixMe
7769
7803
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
7770
7804
  const videoTrack = stream.getVideoTracks()[0];
7771
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7805
+ let sender = pc && pc.getSenders
7806
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7772
7807
  let wasTrackEnabled = false;
7773
7808
  if (!sender) {
7774
- sender = pc && pc.getSenders().find(s => !s.track);
7809
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
7775
7810
  }
7776
7811
 
7777
7812
  if (sender) {
@@ -9305,7 +9340,7 @@ class WebRTCPhone extends Emitter {
9305
9340
  const screenTrack = screenShareStream.getVideoTracks()[0];
9306
9341
  const sipSession = this.currentSipSession;
9307
9342
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9308
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9343
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9309
9344
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9310
9345
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9311
9346
  const hadVideo = !!videoTrack;
@@ -9343,9 +9378,7 @@ class WebRTCPhone extends Emitter {
9343
9378
 
9344
9379
  try {
9345
9380
  if (this.currentScreenShare.stream) {
9346
- this.currentScreenShare.stream.getTracks()
9347
- .filter(track => track.kind === 'video')
9348
- .forEach(track => track.stop());
9381
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9349
9382
  }
9350
9383
 
9351
9384
  if (restoreLocalStream) {
@@ -9389,7 +9422,7 @@ class WebRTCPhone extends Emitter {
9389
9422
  const screenTrack = screenStream.getVideoTracks()[0];
9390
9423
  const sipSessionId = this.getSipSessionId(sipSession);
9391
9424
  const pc = this.client.getPeerConnection(sipSessionId);
9392
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9425
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9393
9426
 
9394
9427
  logger$8.info('WebRTC phone - on screensharing', {
9395
9428
  hadVideo,
@@ -14004,6 +14037,7 @@ class Softphone {
14004
14037
  wrapUpDuration,
14005
14038
  enableAgent = true,
14006
14039
  tenantId,
14040
+ domainName,
14007
14041
  debug = false,
14008
14042
  } = {}) {
14009
14043
  this.url = url || 'https://softphone.wazo.io';
@@ -14028,8 +14062,12 @@ class Softphone {
14028
14062
  config.port = port;
14029
14063
  }
14030
14064
  if (tenantId) {
14065
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14031
14066
  config.tenantId = tenantId;
14032
14067
  }
14068
+ if (domainName) {
14069
+ config.domainName = domainName;
14070
+ }
14033
14071
  if (wrapUpDuration) {
14034
14072
  config.wrapUpDuration = wrapUpDuration;
14035
14073
  }
@@ -14350,6 +14388,7 @@ const Wazo = {
14350
14388
  CanceledCallError,
14351
14389
  SFUNotAvailableError,
14352
14390
  NoTenantIdError,
14391
+ NoDomainNameError,
14353
14392
  };
14354
14393
 
14355
14394
  if (window) {
@@ -14364,6 +14403,7 @@ if (global) {
14364
14403
  class InvalidSubscription extends Error {}
14365
14404
  class InvalidAuthorization extends Error {}
14366
14405
  class NoTenantIdError extends Error {}
14406
+ class NoDomainNameError extends Error {}
14367
14407
 
14368
14408
  const logger = IssueReporter$1.loggerFor('simple-auth');
14369
14409
 
@@ -14427,9 +14467,24 @@ class Auth {
14427
14467
  setFetchOptions(options);
14428
14468
  }
14429
14469
 
14430
- async logIn(username , password , backend , tenantId ) {
14431
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14432
- throw new NoTenantIdError('No tenant id');
14470
+ async logIn(username , password , backend , extra ) {
14471
+ let tenantId = null;
14472
+ let domainName = null;
14473
+ if (typeof extra === 'string') {
14474
+ tenantId = extra;
14475
+ }
14476
+ if (extra && typeof extra === 'object') {
14477
+ domainName = extra.domainName;
14478
+ }
14479
+
14480
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14481
+ if (!tenantId) {
14482
+ throw new NoTenantIdError('No tenant id');
14483
+ }
14484
+
14485
+ if (!domainName) {
14486
+ throw new NoDomainNameError('No domain name');
14487
+ }
14433
14488
  }
14434
14489
 
14435
14490
  this.authenticated = false;
@@ -14439,6 +14494,7 @@ class Auth {
14439
14494
  password,
14440
14495
  backend,
14441
14496
  tenantId,
14497
+ domainName,
14442
14498
  expiration: this.expiration,
14443
14499
  mobile: this.mobile,
14444
14500
  });
@@ -14447,7 +14503,13 @@ class Auth {
14447
14503
  getApiClient().setRefreshBackend(backend);
14448
14504
  }
14449
14505
 
14450
- getApiClient().setRefreshTenantId(tenantId);
14506
+ if (tenantId) {
14507
+ getApiClient().setRefreshTenantId(tenantId);
14508
+ }
14509
+
14510
+ if (domainName) {
14511
+ getApiClient().setRefreshDomainName(domainName);
14512
+ }
14451
14513
 
14452
14514
  return this._onAuthenticated(rawSession);
14453
14515
  }
@@ -14546,11 +14608,18 @@ class Auth {
14546
14608
  }
14547
14609
 
14548
14610
  setRefreshTenantId(refreshTenantId ) {
14611
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14549
14612
  setRefreshTenantId(refreshTenantId);
14550
14613
 
14551
14614
  getApiClient().setRefreshTenantId(refreshTenantId);
14552
14615
  }
14553
14616
 
14617
+ setRefreshDomainName(domainName ) {
14618
+ setRefreshDomainName(domainName);
14619
+
14620
+ getApiClient().setRefreshDomainName(domainName);
14621
+ }
14622
+
14554
14623
  forceRefreshToken() {
14555
14624
  getApiClient().forceRefreshToken();
14556
14625
  }