@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
@@ -2265,6 +2265,7 @@ var authMethods = (client , baseUrl ) => ({
2265
2265
 
2266
2266
 
2267
2267
 
2268
+
2268
2269
  ) {
2269
2270
  const body = {
2270
2271
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2286,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2286
  }
2286
2287
 
2287
2288
  if (params.tenantId) {
2289
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2288
2290
  body.tenant_id = params.tenantId;
2289
2291
  }
2290
2292
 
2293
+ if (params.domainName) {
2294
+ body.domain_name = params.domainName;
2295
+ }
2296
+
2291
2297
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2292
2298
  },
2293
2299
 
@@ -2300,6 +2306,7 @@ var authMethods = (client , baseUrl ) => ({
2300
2306
  expiration ,
2301
2307
  isMobile = false,
2302
2308
  tenantId ,
2309
+ domainName ,
2303
2310
  ) => {
2304
2311
  const body = {
2305
2312
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2309,9 +2316,14 @@ var authMethods = (client , baseUrl ) => ({
2309
2316
  };
2310
2317
 
2311
2318
  if (tenantId) {
2319
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2312
2320
  body.tenant_id = tenantId;
2313
2321
  }
2314
2322
 
2323
+ if (domainName) {
2324
+ body.domain_name = domainName;
2325
+ }
2326
+
2315
2327
  const headers = {
2316
2328
  'Content-Type': 'application/json',
2317
2329
  ...(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);
@@ -5815,6 +5846,7 @@ var getApiClient = (forServer = null) => {
5815
5846
  class InvalidSubscription extends Error {}
5816
5847
  class InvalidAuthorization extends Error {}
5817
5848
  class NoTenantIdError extends Error {}
5849
+ class NoDomainNameError extends Error {}
5818
5850
 
5819
5851
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5820
5852
 
@@ -5878,9 +5910,24 @@ class Auth {
5878
5910
  setFetchOptions(options);
5879
5911
  }
5880
5912
 
5881
- async logIn(username , password , backend , tenantId ) {
5882
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5883
- throw new NoTenantIdError('No tenant id');
5913
+ async logIn(username , password , backend , extra ) {
5914
+ let tenantId = null;
5915
+ let domainName = null;
5916
+ if (typeof extra === 'string') {
5917
+ tenantId = extra;
5918
+ }
5919
+ if (extra && typeof extra === 'object') {
5920
+ domainName = extra.domainName;
5921
+ }
5922
+
5923
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5924
+ if (!tenantId) {
5925
+ throw new NoTenantIdError('No tenant id');
5926
+ }
5927
+
5928
+ if (!domainName) {
5929
+ throw new NoDomainNameError('No domain name');
5930
+ }
5884
5931
  }
5885
5932
 
5886
5933
  this.authenticated = false;
@@ -5890,6 +5937,7 @@ class Auth {
5890
5937
  password,
5891
5938
  backend,
5892
5939
  tenantId,
5940
+ domainName,
5893
5941
  expiration: this.expiration,
5894
5942
  mobile: this.mobile,
5895
5943
  });
@@ -5898,7 +5946,13 @@ class Auth {
5898
5946
  getApiClient().setRefreshBackend(backend);
5899
5947
  }
5900
5948
 
5901
- getApiClient().setRefreshTenantId(tenantId);
5949
+ if (tenantId) {
5950
+ getApiClient().setRefreshTenantId(tenantId);
5951
+ }
5952
+
5953
+ if (domainName) {
5954
+ getApiClient().setRefreshDomainName(domainName);
5955
+ }
5902
5956
 
5903
5957
  return this._onAuthenticated(rawSession);
5904
5958
  }
@@ -5997,11 +6051,18 @@ class Auth {
5997
6051
  }
5998
6052
 
5999
6053
  setRefreshTenantId(refreshTenantId ) {
6054
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
6000
6055
  setRefreshTenantId(refreshTenantId);
6001
6056
 
6002
6057
  getApiClient().setRefreshTenantId(refreshTenantId);
6003
6058
  }
6004
6059
 
6060
+ setRefreshDomainName(domainName ) {
6061
+ setRefreshDomainName(domainName);
6062
+
6063
+ getApiClient().setRefreshDomainName(domainName);
6064
+ }
6065
+
6005
6066
  forceRefreshToken() {
6006
6067
  getApiClient().forceRefreshToken();
6007
6068
  }
@@ -7771,9 +7832,11 @@ class WebRTCClient extends Emitter {
7771
7832
  const videoTracks = localStream.getVideoTracks();
7772
7833
 
7773
7834
  // Remove video senders
7774
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7775
- videoSender.replaceTrack(null);
7776
- });
7835
+ if (pc.getSenders) {
7836
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7837
+ videoSender.replaceTrack(null);
7838
+ });
7839
+ }
7777
7840
 
7778
7841
  videoTracks.forEach(videoTrack => {
7779
7842
  videoTrack.enabled = false;
@@ -8006,7 +8069,8 @@ class WebRTCClient extends Emitter {
8006
8069
  const constraints = { audio: { deviceId: { exact: deviceId } } };
8007
8070
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
8008
8071
  const audioTrack = stream.getAudioTracks()[0];
8009
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8072
+ const sender = pc && pc.getSenders
8073
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8010
8074
 
8011
8075
  if (sender) {
8012
8076
  if (sender.track) {
@@ -8069,10 +8133,11 @@ class WebRTCClient extends Emitter {
8069
8133
  // $FlowFixMe
8070
8134
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
8071
8135
  const videoTrack = stream.getVideoTracks()[0];
8072
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8136
+ let sender = pc && pc.getSenders
8137
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8073
8138
  let wasTrackEnabled = false;
8074
8139
  if (!sender) {
8075
- sender = pc && pc.getSenders().find(s => !s.track);
8140
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
8076
8141
  }
8077
8142
 
8078
8143
  if (sender) {
@@ -9606,7 +9671,7 @@ class WebRTCPhone extends Emitter {
9606
9671
  const screenTrack = screenShareStream.getVideoTracks()[0];
9607
9672
  const sipSession = this.currentSipSession;
9608
9673
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9609
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9674
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9610
9675
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9611
9676
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9612
9677
  const hadVideo = !!videoTrack;
@@ -9644,9 +9709,7 @@ class WebRTCPhone extends Emitter {
9644
9709
 
9645
9710
  try {
9646
9711
  if (this.currentScreenShare.stream) {
9647
- this.currentScreenShare.stream.getTracks()
9648
- .filter(track => track.kind === 'video')
9649
- .forEach(track => track.stop());
9712
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9650
9713
  }
9651
9714
 
9652
9715
  if (restoreLocalStream) {
@@ -9690,7 +9753,7 @@ class WebRTCPhone extends Emitter {
9690
9753
  const screenTrack = screenStream.getVideoTracks()[0];
9691
9754
  const sipSessionId = this.getSipSessionId(sipSession);
9692
9755
  const pc = this.client.getPeerConnection(sipSessionId);
9693
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9756
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9694
9757
 
9695
9758
  logger$7.info('WebRTC phone - on screensharing', {
9696
9759
  hadVideo,
@@ -13157,6 +13220,7 @@ class Softphone {
13157
13220
  wrapUpDuration,
13158
13221
  enableAgent = true,
13159
13222
  tenantId,
13223
+ domainName,
13160
13224
  debug = false,
13161
13225
  } = {}) {
13162
13226
  this.url = url || 'https://softphone.wazo.io';
@@ -13181,8 +13245,12 @@ class Softphone {
13181
13245
  config.port = port;
13182
13246
  }
13183
13247
  if (tenantId) {
13248
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13184
13249
  config.tenantId = tenantId;
13185
13250
  }
13251
+ if (domainName) {
13252
+ config.domainName = domainName;
13253
+ }
13186
13254
  if (wrapUpDuration) {
13187
13255
  config.wrapUpDuration = wrapUpDuration;
13188
13256
  }
@@ -13503,6 +13571,7 @@ const Wazo = {
13503
13571
  CanceledCallError,
13504
13572
  SFUNotAvailableError,
13505
13573
  NoTenantIdError,
13574
+ NoDomainNameError,
13506
13575
  };
13507
13576
 
13508
13577
  if (window) {
@@ -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);
@@ -5815,6 +5846,7 @@ var getApiClient = (forServer = null) => {
5815
5846
  class InvalidSubscription extends Error {}
5816
5847
  class InvalidAuthorization extends Error {}
5817
5848
  class NoTenantIdError extends Error {}
5849
+ class NoDomainNameError extends Error {}
5818
5850
 
5819
5851
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5820
5852
 
@@ -5878,9 +5910,24 @@ class Auth {
5878
5910
  setFetchOptions(options);
5879
5911
  }
5880
5912
 
5881
- async logIn(username , password , backend , tenantId ) {
5882
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5883
- throw new NoTenantIdError('No tenant id');
5913
+ async logIn(username , password , backend , extra ) {
5914
+ let tenantId = null;
5915
+ let domainName = null;
5916
+ if (typeof extra === 'string') {
5917
+ tenantId = extra;
5918
+ }
5919
+ if (extra && typeof extra === 'object') {
5920
+ domainName = extra.domainName;
5921
+ }
5922
+
5923
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5924
+ if (!tenantId) {
5925
+ throw new NoTenantIdError('No tenant id');
5926
+ }
5927
+
5928
+ if (!domainName) {
5929
+ throw new NoDomainNameError('No domain name');
5930
+ }
5884
5931
  }
5885
5932
 
5886
5933
  this.authenticated = false;
@@ -5890,6 +5937,7 @@ class Auth {
5890
5937
  password,
5891
5938
  backend,
5892
5939
  tenantId,
5940
+ domainName,
5893
5941
  expiration: this.expiration,
5894
5942
  mobile: this.mobile,
5895
5943
  });
@@ -5898,7 +5946,13 @@ class Auth {
5898
5946
  getApiClient().setRefreshBackend(backend);
5899
5947
  }
5900
5948
 
5901
- getApiClient().setRefreshTenantId(tenantId);
5949
+ if (tenantId) {
5950
+ getApiClient().setRefreshTenantId(tenantId);
5951
+ }
5952
+
5953
+ if (domainName) {
5954
+ getApiClient().setRefreshDomainName(domainName);
5955
+ }
5902
5956
 
5903
5957
  return this._onAuthenticated(rawSession);
5904
5958
  }
@@ -5997,11 +6051,18 @@ class Auth {
5997
6051
  }
5998
6052
 
5999
6053
  setRefreshTenantId(refreshTenantId ) {
6054
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
6000
6055
  setRefreshTenantId(refreshTenantId);
6001
6056
 
6002
6057
  getApiClient().setRefreshTenantId(refreshTenantId);
6003
6058
  }
6004
6059
 
6060
+ setRefreshDomainName(domainName ) {
6061
+ setRefreshDomainName(domainName);
6062
+
6063
+ getApiClient().setRefreshDomainName(domainName);
6064
+ }
6065
+
6005
6066
  forceRefreshToken() {
6006
6067
  getApiClient().forceRefreshToken();
6007
6068
  }
@@ -7771,9 +7832,11 @@ class WebRTCClient extends Emitter {
7771
7832
  const videoTracks = localStream.getVideoTracks();
7772
7833
 
7773
7834
  // Remove video senders
7774
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7775
- videoSender.replaceTrack(null);
7776
- });
7835
+ if (pc.getSenders) {
7836
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7837
+ videoSender.replaceTrack(null);
7838
+ });
7839
+ }
7777
7840
 
7778
7841
  videoTracks.forEach(videoTrack => {
7779
7842
  videoTrack.enabled = false;
@@ -8006,7 +8069,8 @@ class WebRTCClient extends Emitter {
8006
8069
  const constraints = { audio: { deviceId: { exact: deviceId } } };
8007
8070
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
8008
8071
  const audioTrack = stream.getAudioTracks()[0];
8009
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8072
+ const sender = pc && pc.getSenders
8073
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8010
8074
 
8011
8075
  if (sender) {
8012
8076
  if (sender.track) {
@@ -8069,10 +8133,11 @@ class WebRTCClient extends Emitter {
8069
8133
  // $FlowFixMe
8070
8134
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
8071
8135
  const videoTrack = stream.getVideoTracks()[0];
8072
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8136
+ let sender = pc && pc.getSenders
8137
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
8073
8138
  let wasTrackEnabled = false;
8074
8139
  if (!sender) {
8075
- sender = pc && pc.getSenders().find(s => !s.track);
8140
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
8076
8141
  }
8077
8142
 
8078
8143
  if (sender) {
@@ -9606,7 +9671,7 @@ class WebRTCPhone extends Emitter {
9606
9671
  const screenTrack = screenShareStream.getVideoTracks()[0];
9607
9672
  const sipSession = this.currentSipSession;
9608
9673
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9609
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9674
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9610
9675
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9611
9676
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9612
9677
  const hadVideo = !!videoTrack;
@@ -9644,9 +9709,7 @@ class WebRTCPhone extends Emitter {
9644
9709
 
9645
9710
  try {
9646
9711
  if (this.currentScreenShare.stream) {
9647
- this.currentScreenShare.stream.getTracks()
9648
- .filter(track => track.kind === 'video')
9649
- .forEach(track => track.stop());
9712
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9650
9713
  }
9651
9714
 
9652
9715
  if (restoreLocalStream) {
@@ -9690,7 +9753,7 @@ class WebRTCPhone extends Emitter {
9690
9753
  const screenTrack = screenStream.getVideoTracks()[0];
9691
9754
  const sipSessionId = this.getSipSessionId(sipSession);
9692
9755
  const pc = this.client.getPeerConnection(sipSessionId);
9693
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9756
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9694
9757
 
9695
9758
  logger$7.info('WebRTC phone - on screensharing', {
9696
9759
  hadVideo,
@@ -13475,6 +13538,7 @@ class Softphone {
13475
13538
  wrapUpDuration,
13476
13539
  enableAgent = true,
13477
13540
  tenantId,
13541
+ domainName,
13478
13542
  debug = false,
13479
13543
  } = {}) {
13480
13544
  this.url = url || 'https://softphone.wazo.io';
@@ -13499,8 +13563,12 @@ class Softphone {
13499
13563
  config.port = port;
13500
13564
  }
13501
13565
  if (tenantId) {
13566
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13502
13567
  config.tenantId = tenantId;
13503
13568
  }
13569
+ if (domainName) {
13570
+ config.domainName = domainName;
13571
+ }
13504
13572
  if (wrapUpDuration) {
13505
13573
  config.wrapUpDuration = wrapUpDuration;
13506
13574
  }
@@ -13821,6 +13889,7 @@ const Wazo = {
13821
13889
  CanceledCallError,
13822
13890
  SFUNotAvailableError,
13823
13891
  NoTenantIdError,
13892
+ NoDomainNameError,
13824
13893
  };
13825
13894
 
13826
13895
  if (window) {