@wazo/sdk 0.38.9 → 0.38.12

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 +32 -7
  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 +32 -7
  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 +32 -7
  11. package/esm/checker/checks/webrtc-transport.js +32 -7
  12. package/esm/checker/checks/webrtc.js +32 -7
  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 +3 -2
  17. package/esm/index.js +86 -15
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +87 -16
  21. package/esm/simple/Configuration.js +86 -15
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +86 -15
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +86 -15
  26. package/esm/simple/room/LocalParticipant.js +86 -15
  27. package/esm/simple/room/Participant.js +86 -15
  28. package/esm/simple/room/RemoteParticipant.js +86 -15
  29. package/esm/simple/room/Room.js +86 -15
  30. package/esm/simple/room/SipRoom.js +86 -15
  31. package/esm/simple/room/Stream.js +86 -15
  32. package/esm/simple/room/__tests__/Participant.test.js +86 -15
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -15
  34. package/esm/simple/utils.js +86 -15
  35. package/esm/web-rtc-client.js +32 -7
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +32 -7
  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 +32 -7
  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 +32 -7
  45. package/lib/checker/checks/webrtc-transport.js +32 -7
  46. package/lib/checker/checks/webrtc.js +32 -7
  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 +3 -2
  51. package/lib/index.js +86 -15
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +87 -15
  55. package/lib/simple/Configuration.js +86 -15
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +86 -15
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +86 -15
  60. package/lib/simple/room/LocalParticipant.js +86 -15
  61. package/lib/simple/room/Participant.js +86 -15
  62. package/lib/simple/room/RemoteParticipant.js +86 -15
  63. package/lib/simple/room/Room.js +86 -15
  64. package/lib/simple/room/SipRoom.js +86 -15
  65. package/lib/simple/room/Stream.js +86 -15
  66. package/lib/simple/room/__tests__/Participant.test.js +86 -15
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -15
  68. package/lib/simple/utils.js +86 -15
  69. package/lib/web-rtc-client.js +32 -7
  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 +2 -2
  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 +11 -7
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
2229
2229
 
2230
2230
 
2231
2231
 
2232
+
2232
2233
  ) {
2233
2234
  const body = {
2234
2235
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
2249
2250
  }
2250
2251
 
2251
2252
  if (params.tenantId) {
2253
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2252
2254
  body.tenant_id = params.tenantId;
2253
2255
  }
2254
2256
 
2257
+ if (params.domainName) {
2258
+ body.domain_name = params.domainName;
2259
+ }
2260
+
2255
2261
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2256
2262
  },
2257
2263
 
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
2264
2270
  expiration ,
2265
2271
  isMobile = false,
2266
2272
  tenantId ,
2273
+ domainName ,
2267
2274
  ) => {
2268
2275
  const body = {
2269
2276
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
2273
2280
  };
2274
2281
 
2275
2282
  if (tenantId) {
2283
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2276
2284
  body.tenant_id = tenantId;
2277
2285
  }
2278
2286
 
2287
+ if (domainName) {
2288
+ body.domain_name = domainName;
2289
+ }
2290
+
2279
2291
  const headers = {
2280
2292
  'Content-Type': 'application/json',
2281
2293
  ...(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
  }
@@ -7720,7 +7781,7 @@ class WebRTCClient extends Emitter {
7720
7781
 
7721
7782
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
7722
7783
  } else {
7723
- videoSender = pc.getSenders().find(sender => sender.track === null);
7784
+ videoSender = pc && pc.getSenders && pc.getSenders().find(sender => sender.track === null);
7724
7785
  }
7725
7786
 
7726
7787
  if (!videoSender) {
@@ -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;
@@ -9678,7 +9743,7 @@ class WebRTCPhone extends Emitter {
9678
9743
  const screenTrack = screenStream.getVideoTracks()[0];
9679
9744
  const sipSessionId = this.getSipSessionId(sipSession);
9680
9745
  const pc = this.client.getPeerConnection(sipSessionId);
9681
- 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');
9682
9747
 
9683
9748
  logger$7.info('WebRTC phone - on screensharing', {
9684
9749
  hadVideo,
@@ -14310,6 +14375,7 @@ class Softphone {
14310
14375
  wrapUpDuration,
14311
14376
  enableAgent = true,
14312
14377
  tenantId,
14378
+ domainName,
14313
14379
  debug = false,
14314
14380
  } = {}) {
14315
14381
  this.url = url || 'https://softphone.wazo.io';
@@ -14334,8 +14400,12 @@ class Softphone {
14334
14400
  config.port = port;
14335
14401
  }
14336
14402
  if (tenantId) {
14403
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14337
14404
  config.tenantId = tenantId;
14338
14405
  }
14406
+ if (domainName) {
14407
+ config.domainName = domainName;
14408
+ }
14339
14409
  if (wrapUpDuration) {
14340
14410
  config.wrapUpDuration = wrapUpDuration;
14341
14411
  }
@@ -14656,6 +14726,7 @@ const Wazo = {
14656
14726
  CanceledCallError,
14657
14727
  SFUNotAvailableError,
14658
14728
  NoTenantIdError,
14729
+ NoDomainNameError,
14659
14730
  };
14660
14731
 
14661
14732
  if (window) {
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
2229
2229
 
2230
2230
 
2231
2231
 
2232
+
2232
2233
  ) {
2233
2234
  const body = {
2234
2235
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
2249
2250
  }
2250
2251
 
2251
2252
  if (params.tenantId) {
2253
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2252
2254
  body.tenant_id = params.tenantId;
2253
2255
  }
2254
2256
 
2257
+ if (params.domainName) {
2258
+ body.domain_name = params.domainName;
2259
+ }
2260
+
2255
2261
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2256
2262
  },
2257
2263
 
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
2264
2270
  expiration ,
2265
2271
  isMobile = false,
2266
2272
  tenantId ,
2273
+ domainName ,
2267
2274
  ) => {
2268
2275
  const body = {
2269
2276
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
2273
2280
  };
2274
2281
 
2275
2282
  if (tenantId) {
2283
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2276
2284
  body.tenant_id = tenantId;
2277
2285
  }
2278
2286
 
2287
+ if (domainName) {
2288
+ body.domain_name = domainName;
2289
+ }
2290
+
2279
2291
  const headers = {
2280
2292
  'Content-Type': 'application/json',
2281
2293
  ...(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
  }
@@ -7720,7 +7781,7 @@ class WebRTCClient extends Emitter {
7720
7781
 
7721
7782
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
7722
7783
  } else {
7723
- videoSender = pc.getSenders().find(sender => sender.track === null);
7784
+ videoSender = pc && pc.getSenders && pc.getSenders().find(sender => sender.track === null);
7724
7785
  }
7725
7786
 
7726
7787
  if (!videoSender) {
@@ -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;
@@ -9678,7 +9743,7 @@ class WebRTCPhone extends Emitter {
9678
9743
  const screenTrack = screenStream.getVideoTracks()[0];
9679
9744
  const sipSessionId = this.getSipSessionId(sipSession);
9680
9745
  const pc = this.client.getPeerConnection(sipSessionId);
9681
- 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');
9682
9747
 
9683
9748
  logger$7.info('WebRTC phone - on screensharing', {
9684
9749
  hadVideo,
@@ -14294,6 +14359,7 @@ class Softphone {
14294
14359
  wrapUpDuration,
14295
14360
  enableAgent = true,
14296
14361
  tenantId,
14362
+ domainName,
14297
14363
  debug = false,
14298
14364
  } = {}) {
14299
14365
  this.url = url || 'https://softphone.wazo.io';
@@ -14318,8 +14384,12 @@ class Softphone {
14318
14384
  config.port = port;
14319
14385
  }
14320
14386
  if (tenantId) {
14387
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14321
14388
  config.tenantId = tenantId;
14322
14389
  }
14390
+ if (domainName) {
14391
+ config.domainName = domainName;
14392
+ }
14323
14393
  if (wrapUpDuration) {
14324
14394
  config.wrapUpDuration = wrapUpDuration;
14325
14395
  }
@@ -14640,6 +14710,7 @@ const Wazo = {
14640
14710
  CanceledCallError,
14641
14711
  SFUNotAvailableError,
14642
14712
  NoTenantIdError,
14713
+ NoDomainNameError,
14643
14714
  };
14644
14715
 
14645
14716
  if (window) {