@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
@@ -2255,6 +2255,7 @@ var authMethods = (client , baseUrl ) => ({
2255
2255
 
2256
2256
 
2257
2257
 
2258
+
2258
2259
  ) {
2259
2260
  const body = {
2260
2261
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2275,9 +2276,14 @@ var authMethods = (client , baseUrl ) => ({
2275
2276
  }
2276
2277
 
2277
2278
  if (params.tenantId) {
2279
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2278
2280
  body.tenant_id = params.tenantId;
2279
2281
  }
2280
2282
 
2283
+ if (params.domainName) {
2284
+ body.domain_name = params.domainName;
2285
+ }
2286
+
2281
2287
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2282
2288
  },
2283
2289
 
@@ -2290,6 +2296,7 @@ var authMethods = (client , baseUrl ) => ({
2290
2296
  expiration ,
2291
2297
  isMobile = false,
2292
2298
  tenantId ,
2299
+ domainName ,
2293
2300
  ) => {
2294
2301
  const body = {
2295
2302
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2299,9 +2306,14 @@ var authMethods = (client , baseUrl ) => ({
2299
2306
  };
2300
2307
 
2301
2308
  if (tenantId) {
2309
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2302
2310
  body.tenant_id = tenantId;
2303
2311
  }
2304
2312
 
2313
+ if (domainName) {
2314
+ body.domain_name = domainName;
2315
+ }
2316
+
2305
2317
  const headers = {
2306
2318
  'Content-Type': 'application/json',
2307
2319
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5573,6 +5585,7 @@ class ApiClient {
5573
5585
 
5574
5586
 
5575
5587
 
5588
+
5576
5589
 
5577
5590
 
5578
5591
 
@@ -5614,6 +5627,7 @@ class ApiClient {
5614
5627
  refreshToken: this.refreshToken,
5615
5628
  refreshBackend: this.refreshBackend,
5616
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5617
5631
  refreshExpiration: this.refreshExpiration,
5618
5632
  isMobile: this.isMobile,
5619
5633
  });
@@ -5629,6 +5643,7 @@ class ApiClient {
5629
5643
  this.refreshExpiration,
5630
5644
  this.isMobile,
5631
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5632
5647
  );
5633
5648
 
5634
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5682,9 +5697,14 @@ class ApiClient {
5682
5697
  }
5683
5698
 
5684
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5685
5701
  this.refreshTenantId = tenantId;
5686
5702
  }
5687
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5688
5708
  setIsMobile(isMobile ) {
5689
5709
  this.isMobile = isMobile;
5690
5710
  }
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5709
5729
  global.wazoClientToken = global.wazoClientToken || {};
5710
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5711
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5712
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5713
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5714
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5733
5754
  };
5734
5755
 
5735
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5736
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5737
5759
  };
5738
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5739
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5740
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5741
5767
  };
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5754
5780
 
5755
5781
  const fillClient = (apiClient ) => {
5756
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5757
5784
 
5758
5785
  // try with null server when dealing with non-related server info
5759
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
5762
5789
 
5763
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5764
5791
 
5765
- apiClient.setRefreshTenantId(
5766
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5792
+ if (tenantId) {
5793
+ apiClient.setRefreshTenantId(tenantId);
5794
+ }
5795
+
5796
+ apiClient.setRefreshDomainName(
5797
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5767
5798
  );
5768
5799
 
5769
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5805,6 +5836,7 @@ var getApiClient = (forServer = null) => {
5805
5836
  class InvalidSubscription extends Error {}
5806
5837
  class InvalidAuthorization extends Error {}
5807
5838
  class NoTenantIdError extends Error {}
5839
+ class NoDomainNameError extends Error {}
5808
5840
 
5809
5841
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5810
5842
 
@@ -5868,9 +5900,24 @@ class Auth {
5868
5900
  setFetchOptions(options);
5869
5901
  }
5870
5902
 
5871
- async logIn(username , password , backend , tenantId ) {
5872
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5873
- throw new NoTenantIdError('No tenant id');
5903
+ async logIn(username , password , backend , extra ) {
5904
+ let tenantId = null;
5905
+ let domainName = null;
5906
+ if (typeof extra === 'string') {
5907
+ tenantId = extra;
5908
+ }
5909
+ if (extra && typeof extra === 'object') {
5910
+ domainName = extra.domainName;
5911
+ }
5912
+
5913
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5914
+ if (!tenantId) {
5915
+ throw new NoTenantIdError('No tenant id');
5916
+ }
5917
+
5918
+ if (!domainName) {
5919
+ throw new NoDomainNameError('No domain name');
5920
+ }
5874
5921
  }
5875
5922
 
5876
5923
  this.authenticated = false;
@@ -5880,6 +5927,7 @@ class Auth {
5880
5927
  password,
5881
5928
  backend,
5882
5929
  tenantId,
5930
+ domainName,
5883
5931
  expiration: this.expiration,
5884
5932
  mobile: this.mobile,
5885
5933
  });
@@ -5888,7 +5936,13 @@ class Auth {
5888
5936
  getApiClient().setRefreshBackend(backend);
5889
5937
  }
5890
5938
 
5891
- getApiClient().setRefreshTenantId(tenantId);
5939
+ if (tenantId) {
5940
+ getApiClient().setRefreshTenantId(tenantId);
5941
+ }
5942
+
5943
+ if (domainName) {
5944
+ getApiClient().setRefreshDomainName(domainName);
5945
+ }
5892
5946
 
5893
5947
  return this._onAuthenticated(rawSession);
5894
5948
  }
@@ -5987,11 +6041,18 @@ class Auth {
5987
6041
  }
5988
6042
 
5989
6043
  setRefreshTenantId(refreshTenantId ) {
6044
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
5990
6045
  setRefreshTenantId(refreshTenantId);
5991
6046
 
5992
6047
  getApiClient().setRefreshTenantId(refreshTenantId);
5993
6048
  }
5994
6049
 
6050
+ setRefreshDomainName(domainName ) {
6051
+ setRefreshDomainName(domainName);
6052
+
6053
+ getApiClient().setRefreshDomainName(domainName);
6054
+ }
6055
+
5995
6056
  forceRefreshToken() {
5996
6057
  getApiClient().forceRefreshToken();
5997
6058
  }
@@ -7761,9 +7822,11 @@ class WebRTCClient extends Emitter {
7761
7822
  const videoTracks = localStream.getVideoTracks();
7762
7823
 
7763
7824
  // Remove video senders
7764
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7765
- videoSender.replaceTrack(null);
7766
- });
7825
+ if (pc.getSenders) {
7826
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7827
+ videoSender.replaceTrack(null);
7828
+ });
7829
+ }
7767
7830
 
7768
7831
  videoTracks.forEach(videoTrack => {
7769
7832
  videoTrack.enabled = false;
@@ -7996,7 +8059,8 @@ class WebRTCClient extends Emitter {
7996
8059
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7997
8060
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7998
8061
  const audioTrack = stream.getAudioTracks()[0];
7999
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8062
+ const sender = pc && pc.getSenders
8063
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8000
8064
 
8001
8065
  if (sender) {
8002
8066
  if (sender.track) {
@@ -8059,10 +8123,11 @@ class WebRTCClient extends Emitter {
8059
8123
  // $FlowFixMe
8060
8124
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
8061
8125
  const videoTrack = stream.getVideoTracks()[0];
8062
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8126
+ let sender = pc && pc.getSenders
8127
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8063
8128
  let wasTrackEnabled = false;
8064
8129
  if (!sender) {
8065
- sender = pc && pc.getSenders().find(s => !s.track);
8130
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
8066
8131
  }
8067
8132
 
8068
8133
  if (sender) {
@@ -9596,7 +9661,7 @@ class WebRTCPhone extends Emitter {
9596
9661
  const screenTrack = screenShareStream.getVideoTracks()[0];
9597
9662
  const sipSession = this.currentSipSession;
9598
9663
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9599
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9664
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9600
9665
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9601
9666
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9602
9667
  const hadVideo = !!videoTrack;
@@ -9634,9 +9699,7 @@ class WebRTCPhone extends Emitter {
9634
9699
 
9635
9700
  try {
9636
9701
  if (this.currentScreenShare.stream) {
9637
- this.currentScreenShare.stream.getTracks()
9638
- .filter(track => track.kind === 'video')
9639
- .forEach(track => track.stop());
9702
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9640
9703
  }
9641
9704
 
9642
9705
  if (restoreLocalStream) {
@@ -9680,7 +9743,7 @@ class WebRTCPhone extends Emitter {
9680
9743
  const screenTrack = screenStream.getVideoTracks()[0];
9681
9744
  const sipSessionId = this.getSipSessionId(sipSession);
9682
9745
  const pc = this.client.getPeerConnection(sipSessionId);
9683
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9746
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9684
9747
 
9685
9748
  logger$7.info('WebRTC phone - on screensharing', {
9686
9749
  hadVideo,
@@ -13142,6 +13205,7 @@ class Softphone {
13142
13205
  wrapUpDuration,
13143
13206
  enableAgent = true,
13144
13207
  tenantId,
13208
+ domainName,
13145
13209
  debug = false,
13146
13210
  } = {}) {
13147
13211
  this.url = url || 'https://softphone.wazo.io';
@@ -13166,8 +13230,12 @@ class Softphone {
13166
13230
  config.port = port;
13167
13231
  }
13168
13232
  if (tenantId) {
13233
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13169
13234
  config.tenantId = tenantId;
13170
13235
  }
13236
+ if (domainName) {
13237
+ config.domainName = domainName;
13238
+ }
13171
13239
  if (wrapUpDuration) {
13172
13240
  config.wrapUpDuration = wrapUpDuration;
13173
13241
  }
@@ -13488,6 +13556,7 @@ const Wazo = {
13488
13556
  CanceledCallError,
13489
13557
  SFUNotAvailableError,
13490
13558
  NoTenantIdError,
13559
+ NoDomainNameError,
13491
13560
  };
13492
13561
 
13493
13562
  if (window) {
@@ -2255,6 +2255,7 @@ var authMethods = (client , baseUrl ) => ({
2255
2255
 
2256
2256
 
2257
2257
 
2258
+
2258
2259
  ) {
2259
2260
  const body = {
2260
2261
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2275,9 +2276,14 @@ var authMethods = (client , baseUrl ) => ({
2275
2276
  }
2276
2277
 
2277
2278
  if (params.tenantId) {
2279
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2278
2280
  body.tenant_id = params.tenantId;
2279
2281
  }
2280
2282
 
2283
+ if (params.domainName) {
2284
+ body.domain_name = params.domainName;
2285
+ }
2286
+
2281
2287
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2282
2288
  },
2283
2289
 
@@ -2290,6 +2296,7 @@ var authMethods = (client , baseUrl ) => ({
2290
2296
  expiration ,
2291
2297
  isMobile = false,
2292
2298
  tenantId ,
2299
+ domainName ,
2293
2300
  ) => {
2294
2301
  const body = {
2295
2302
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2299,9 +2306,14 @@ var authMethods = (client , baseUrl ) => ({
2299
2306
  };
2300
2307
 
2301
2308
  if (tenantId) {
2309
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2302
2310
  body.tenant_id = tenantId;
2303
2311
  }
2304
2312
 
2313
+ if (domainName) {
2314
+ body.domain_name = domainName;
2315
+ }
2316
+
2305
2317
  const headers = {
2306
2318
  'Content-Type': 'application/json',
2307
2319
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5573,6 +5585,7 @@ class ApiClient {
5573
5585
 
5574
5586
 
5575
5587
 
5588
+
5576
5589
 
5577
5590
 
5578
5591
 
@@ -5614,6 +5627,7 @@ class ApiClient {
5614
5627
  refreshToken: this.refreshToken,
5615
5628
  refreshBackend: this.refreshBackend,
5616
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5617
5631
  refreshExpiration: this.refreshExpiration,
5618
5632
  isMobile: this.isMobile,
5619
5633
  });
@@ -5629,6 +5643,7 @@ class ApiClient {
5629
5643
  this.refreshExpiration,
5630
5644
  this.isMobile,
5631
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5632
5647
  );
5633
5648
 
5634
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5682,9 +5697,14 @@ class ApiClient {
5682
5697
  }
5683
5698
 
5684
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5685
5701
  this.refreshTenantId = tenantId;
5686
5702
  }
5687
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5688
5708
  setIsMobile(isMobile ) {
5689
5709
  this.isMobile = isMobile;
5690
5710
  }
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5709
5729
  global.wazoClientToken = global.wazoClientToken || {};
5710
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5711
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5712
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5713
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5714
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5733
5754
  };
5734
5755
 
5735
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5736
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5737
5759
  };
5738
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5739
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5740
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5741
5767
  };
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5754
5780
 
5755
5781
  const fillClient = (apiClient ) => {
5756
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5757
5784
 
5758
5785
  // try with null server when dealing with non-related server info
5759
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
5762
5789
 
5763
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5764
5791
 
5765
- apiClient.setRefreshTenantId(
5766
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5792
+ if (tenantId) {
5793
+ apiClient.setRefreshTenantId(tenantId);
5794
+ }
5795
+
5796
+ apiClient.setRefreshDomainName(
5797
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5767
5798
  );
5768
5799
 
5769
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5805,6 +5836,7 @@ var getApiClient = (forServer = null) => {
5805
5836
  class InvalidSubscription extends Error {}
5806
5837
  class InvalidAuthorization extends Error {}
5807
5838
  class NoTenantIdError extends Error {}
5839
+ class NoDomainNameError extends Error {}
5808
5840
 
5809
5841
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5810
5842
 
@@ -5868,9 +5900,24 @@ class Auth {
5868
5900
  setFetchOptions(options);
5869
5901
  }
5870
5902
 
5871
- async logIn(username , password , backend , tenantId ) {
5872
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5873
- throw new NoTenantIdError('No tenant id');
5903
+ async logIn(username , password , backend , extra ) {
5904
+ let tenantId = null;
5905
+ let domainName = null;
5906
+ if (typeof extra === 'string') {
5907
+ tenantId = extra;
5908
+ }
5909
+ if (extra && typeof extra === 'object') {
5910
+ domainName = extra.domainName;
5911
+ }
5912
+
5913
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5914
+ if (!tenantId) {
5915
+ throw new NoTenantIdError('No tenant id');
5916
+ }
5917
+
5918
+ if (!domainName) {
5919
+ throw new NoDomainNameError('No domain name');
5920
+ }
5874
5921
  }
5875
5922
 
5876
5923
  this.authenticated = false;
@@ -5880,6 +5927,7 @@ class Auth {
5880
5927
  password,
5881
5928
  backend,
5882
5929
  tenantId,
5930
+ domainName,
5883
5931
  expiration: this.expiration,
5884
5932
  mobile: this.mobile,
5885
5933
  });
@@ -5888,7 +5936,13 @@ class Auth {
5888
5936
  getApiClient().setRefreshBackend(backend);
5889
5937
  }
5890
5938
 
5891
- getApiClient().setRefreshTenantId(tenantId);
5939
+ if (tenantId) {
5940
+ getApiClient().setRefreshTenantId(tenantId);
5941
+ }
5942
+
5943
+ if (domainName) {
5944
+ getApiClient().setRefreshDomainName(domainName);
5945
+ }
5892
5946
 
5893
5947
  return this._onAuthenticated(rawSession);
5894
5948
  }
@@ -5987,11 +6041,18 @@ class Auth {
5987
6041
  }
5988
6042
 
5989
6043
  setRefreshTenantId(refreshTenantId ) {
6044
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
5990
6045
  setRefreshTenantId(refreshTenantId);
5991
6046
 
5992
6047
  getApiClient().setRefreshTenantId(refreshTenantId);
5993
6048
  }
5994
6049
 
6050
+ setRefreshDomainName(domainName ) {
6051
+ setRefreshDomainName(domainName);
6052
+
6053
+ getApiClient().setRefreshDomainName(domainName);
6054
+ }
6055
+
5995
6056
  forceRefreshToken() {
5996
6057
  getApiClient().forceRefreshToken();
5997
6058
  }
@@ -7761,9 +7822,11 @@ class WebRTCClient extends Emitter {
7761
7822
  const videoTracks = localStream.getVideoTracks();
7762
7823
 
7763
7824
  // Remove video senders
7764
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7765
- videoSender.replaceTrack(null);
7766
- });
7825
+ if (pc.getSenders) {
7826
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7827
+ videoSender.replaceTrack(null);
7828
+ });
7829
+ }
7767
7830
 
7768
7831
  videoTracks.forEach(videoTrack => {
7769
7832
  videoTrack.enabled = false;
@@ -7996,7 +8059,8 @@ class WebRTCClient extends Emitter {
7996
8059
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7997
8060
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7998
8061
  const audioTrack = stream.getAudioTracks()[0];
7999
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8062
+ const sender = pc && pc.getSenders
8063
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8000
8064
 
8001
8065
  if (sender) {
8002
8066
  if (sender.track) {
@@ -8059,10 +8123,11 @@ class WebRTCClient extends Emitter {
8059
8123
  // $FlowFixMe
8060
8124
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
8061
8125
  const videoTrack = stream.getVideoTracks()[0];
8062
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8126
+ let sender = pc && pc.getSenders
8127
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8063
8128
  let wasTrackEnabled = false;
8064
8129
  if (!sender) {
8065
- sender = pc && pc.getSenders().find(s => !s.track);
8130
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
8066
8131
  }
8067
8132
 
8068
8133
  if (sender) {
@@ -9596,7 +9661,7 @@ class WebRTCPhone extends Emitter {
9596
9661
  const screenTrack = screenShareStream.getVideoTracks()[0];
9597
9662
  const sipSession = this.currentSipSession;
9598
9663
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9599
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9664
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9600
9665
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9601
9666
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9602
9667
  const hadVideo = !!videoTrack;
@@ -9634,9 +9699,7 @@ class WebRTCPhone extends Emitter {
9634
9699
 
9635
9700
  try {
9636
9701
  if (this.currentScreenShare.stream) {
9637
- this.currentScreenShare.stream.getTracks()
9638
- .filter(track => track.kind === 'video')
9639
- .forEach(track => track.stop());
9702
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9640
9703
  }
9641
9704
 
9642
9705
  if (restoreLocalStream) {
@@ -9680,7 +9743,7 @@ class WebRTCPhone extends Emitter {
9680
9743
  const screenTrack = screenStream.getVideoTracks()[0];
9681
9744
  const sipSessionId = this.getSipSessionId(sipSession);
9682
9745
  const pc = this.client.getPeerConnection(sipSessionId);
9683
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9746
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9684
9747
 
9685
9748
  logger$7.info('WebRTC phone - on screensharing', {
9686
9749
  hadVideo,
@@ -13147,6 +13210,7 @@ class Softphone {
13147
13210
  wrapUpDuration,
13148
13211
  enableAgent = true,
13149
13212
  tenantId,
13213
+ domainName,
13150
13214
  debug = false,
13151
13215
  } = {}) {
13152
13216
  this.url = url || 'https://softphone.wazo.io';
@@ -13171,8 +13235,12 @@ class Softphone {
13171
13235
  config.port = port;
13172
13236
  }
13173
13237
  if (tenantId) {
13238
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13174
13239
  config.tenantId = tenantId;
13175
13240
  }
13241
+ if (domainName) {
13242
+ config.domainName = domainName;
13243
+ }
13176
13244
  if (wrapUpDuration) {
13177
13245
  config.wrapUpDuration = wrapUpDuration;
13178
13246
  }
@@ -13493,6 +13561,7 @@ const Wazo = {
13493
13561
  CanceledCallError,
13494
13562
  SFUNotAvailableError,
13495
13563
  NoTenantIdError,
13564
+ NoDomainNameError,
13496
13565
  };
13497
13566
 
13498
13567
  if (window) {