@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
@@ -2838,6 +2838,7 @@ var authMethods = (client , baseUrl ) => ({
2838
2838
 
2839
2839
 
2840
2840
 
2841
+
2841
2842
  ) {
2842
2843
  const body = {
2843
2844
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2858,9 +2859,14 @@ var authMethods = (client , baseUrl ) => ({
2858
2859
  }
2859
2860
 
2860
2861
  if (params.tenantId) {
2862
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2861
2863
  body.tenant_id = params.tenantId;
2862
2864
  }
2863
2865
 
2866
+ if (params.domainName) {
2867
+ body.domain_name = params.domainName;
2868
+ }
2869
+
2864
2870
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2865
2871
  },
2866
2872
 
@@ -2873,6 +2879,7 @@ var authMethods = (client , baseUrl ) => ({
2873
2879
  expiration ,
2874
2880
  isMobile = false,
2875
2881
  tenantId ,
2882
+ domainName ,
2876
2883
  ) => {
2877
2884
  const body = {
2878
2885
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2882,9 +2889,14 @@ var authMethods = (client , baseUrl ) => ({
2882
2889
  };
2883
2890
 
2884
2891
  if (tenantId) {
2892
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2885
2893
  body.tenant_id = tenantId;
2886
2894
  }
2887
2895
 
2896
+ if (domainName) {
2897
+ body.domain_name = domainName;
2898
+ }
2899
+
2888
2900
  const headers = {
2889
2901
  'Content-Type': 'application/json',
2890
2902
  ...(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);
@@ -7460,9 +7491,11 @@ class WebRTCClient extends Emitter {
7460
7491
  const videoTracks = localStream.getVideoTracks();
7461
7492
 
7462
7493
  // Remove video senders
7463
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7464
- videoSender.replaceTrack(null);
7465
- });
7494
+ if (pc.getSenders) {
7495
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7496
+ videoSender.replaceTrack(null);
7497
+ });
7498
+ }
7466
7499
 
7467
7500
  videoTracks.forEach(videoTrack => {
7468
7501
  videoTrack.enabled = false;
@@ -7695,7 +7728,8 @@ class WebRTCClient extends Emitter {
7695
7728
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7696
7729
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7697
7730
  const audioTrack = stream.getAudioTracks()[0];
7698
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7731
+ const sender = pc && pc.getSenders
7732
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7699
7733
 
7700
7734
  if (sender) {
7701
7735
  if (sender.track) {
@@ -7758,10 +7792,11 @@ class WebRTCClient extends Emitter {
7758
7792
  // $FlowFixMe
7759
7793
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
7760
7794
  const videoTrack = stream.getVideoTracks()[0];
7761
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7795
+ let sender = pc && pc.getSenders
7796
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7762
7797
  let wasTrackEnabled = false;
7763
7798
  if (!sender) {
7764
- sender = pc && pc.getSenders().find(s => !s.track);
7799
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
7765
7800
  }
7766
7801
 
7767
7802
  if (sender) {
@@ -9295,7 +9330,7 @@ class WebRTCPhone extends Emitter {
9295
9330
  const screenTrack = screenShareStream.getVideoTracks()[0];
9296
9331
  const sipSession = this.currentSipSession;
9297
9332
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
9298
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9333
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9299
9334
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
9300
9335
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
9301
9336
  const hadVideo = !!videoTrack;
@@ -9333,9 +9368,7 @@ class WebRTCPhone extends Emitter {
9333
9368
 
9334
9369
  try {
9335
9370
  if (this.currentScreenShare.stream) {
9336
- this.currentScreenShare.stream.getTracks()
9337
- .filter(track => track.kind === 'video')
9338
- .forEach(track => track.stop());
9371
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9339
9372
  }
9340
9373
 
9341
9374
  if (restoreLocalStream) {
@@ -9379,7 +9412,7 @@ class WebRTCPhone extends Emitter {
9379
9412
  const screenTrack = screenStream.getVideoTracks()[0];
9380
9413
  const sipSessionId = this.getSipSessionId(sipSession);
9381
9414
  const pc = this.client.getPeerConnection(sipSessionId);
9382
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9415
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9383
9416
 
9384
9417
  logger$8.info('WebRTC phone - on screensharing', {
9385
9418
  hadVideo,
@@ -10624,6 +10657,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10624
10657
  class InvalidSubscription extends Error {}
10625
10658
  class InvalidAuthorization extends Error {}
10626
10659
  class NoTenantIdError extends Error {}
10660
+ class NoDomainNameError extends Error {}
10627
10661
 
10628
10662
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10629
10663
 
@@ -10687,9 +10721,24 @@ class Auth {
10687
10721
  setFetchOptions(options);
10688
10722
  }
10689
10723
 
10690
- async logIn(username , password , backend , tenantId ) {
10691
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
10692
- throw new NoTenantIdError('No tenant id');
10724
+ async logIn(username , password , backend , extra ) {
10725
+ let tenantId = null;
10726
+ let domainName = null;
10727
+ if (typeof extra === 'string') {
10728
+ tenantId = extra;
10729
+ }
10730
+ if (extra && typeof extra === 'object') {
10731
+ domainName = extra.domainName;
10732
+ }
10733
+
10734
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
10735
+ if (!tenantId) {
10736
+ throw new NoTenantIdError('No tenant id');
10737
+ }
10738
+
10739
+ if (!domainName) {
10740
+ throw new NoDomainNameError('No domain name');
10741
+ }
10693
10742
  }
10694
10743
 
10695
10744
  this.authenticated = false;
@@ -10699,6 +10748,7 @@ class Auth {
10699
10748
  password,
10700
10749
  backend,
10701
10750
  tenantId,
10751
+ domainName,
10702
10752
  expiration: this.expiration,
10703
10753
  mobile: this.mobile,
10704
10754
  });
@@ -10707,7 +10757,13 @@ class Auth {
10707
10757
  getApiClient().setRefreshBackend(backend);
10708
10758
  }
10709
10759
 
10710
- getApiClient().setRefreshTenantId(tenantId);
10760
+ if (tenantId) {
10761
+ getApiClient().setRefreshTenantId(tenantId);
10762
+ }
10763
+
10764
+ if (domainName) {
10765
+ getApiClient().setRefreshDomainName(domainName);
10766
+ }
10711
10767
 
10712
10768
  return this._onAuthenticated(rawSession);
10713
10769
  }
@@ -10806,11 +10862,18 @@ class Auth {
10806
10862
  }
10807
10863
 
10808
10864
  setRefreshTenantId(refreshTenantId ) {
10865
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
10809
10866
  setRefreshTenantId(refreshTenantId);
10810
10867
 
10811
10868
  getApiClient().setRefreshTenantId(refreshTenantId);
10812
10869
  }
10813
10870
 
10871
+ setRefreshDomainName(domainName ) {
10872
+ setRefreshDomainName(domainName);
10873
+
10874
+ getApiClient().setRefreshDomainName(domainName);
10875
+ }
10876
+
10814
10877
  forceRefreshToken() {
10815
10878
  getApiClient().forceRefreshToken();
10816
10879
  }
@@ -13902,6 +13965,7 @@ class Softphone {
13902
13965
  wrapUpDuration,
13903
13966
  enableAgent = true,
13904
13967
  tenantId,
13968
+ domainName,
13905
13969
  debug = false,
13906
13970
  } = {}) {
13907
13971
  this.url = url || 'https://softphone.wazo.io';
@@ -13926,8 +13990,12 @@ class Softphone {
13926
13990
  config.port = port;
13927
13991
  }
13928
13992
  if (tenantId) {
13993
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13929
13994
  config.tenantId = tenantId;
13930
13995
  }
13996
+ if (domainName) {
13997
+ config.domainName = domainName;
13998
+ }
13931
13999
  if (wrapUpDuration) {
13932
14000
  config.wrapUpDuration = wrapUpDuration;
13933
14001
  }
@@ -14248,6 +14316,7 @@ const Wazo = {
14248
14316
  CanceledCallError,
14249
14317
  SFUNotAvailableError,
14250
14318
  NoTenantIdError,
14319
+ NoDomainNameError,
14251
14320
  };
14252
14321
 
14253
14322
  if (window) {
@@ -107,6 +107,7 @@ class Softphone {
107
107
  wrapUpDuration,
108
108
  enableAgent = true,
109
109
  tenantId,
110
+ domainName,
110
111
  debug = false,
111
112
  } = {}) {
112
113
  this.url = url || 'https://softphone.wazo.io';
@@ -131,8 +132,12 @@ class Softphone {
131
132
  config.port = port;
132
133
  }
133
134
  if (tenantId) {
135
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
134
136
  config.tenantId = tenantId;
135
137
  }
138
+ if (domainName) {
139
+ config.domainName = domainName;
140
+ }
136
141
  if (wrapUpDuration) {
137
142
  config.wrapUpDuration = wrapUpDuration;
138
143
  }
@@ -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
  }
@@ -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,
@@ -14312,6 +14375,7 @@ class Softphone {
14312
14375
  wrapUpDuration,
14313
14376
  enableAgent = true,
14314
14377
  tenantId,
14378
+ domainName,
14315
14379
  debug = false,
14316
14380
  } = {}) {
14317
14381
  this.url = url || 'https://softphone.wazo.io';
@@ -14336,8 +14400,12 @@ class Softphone {
14336
14400
  config.port = port;
14337
14401
  }
14338
14402
  if (tenantId) {
14403
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14339
14404
  config.tenantId = tenantId;
14340
14405
  }
14406
+ if (domainName) {
14407
+ config.domainName = domainName;
14408
+ }
14341
14409
  if (wrapUpDuration) {
14342
14410
  config.wrapUpDuration = wrapUpDuration;
14343
14411
  }
@@ -14658,6 +14726,7 @@ const Wazo = {
14658
14726
  CanceledCallError,
14659
14727
  SFUNotAvailableError,
14660
14728
  NoTenantIdError,
14729
+ NoDomainNameError,
14661
14730
  };
14662
14731
 
14663
14732
  if (window) {