@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
@@ -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,
@@ -14296,6 +14359,7 @@ class Softphone {
14296
14359
  wrapUpDuration,
14297
14360
  enableAgent = true,
14298
14361
  tenantId,
14362
+ domainName,
14299
14363
  debug = false,
14300
14364
  } = {}) {
14301
14365
  this.url = url || 'https://softphone.wazo.io';
@@ -14320,8 +14384,12 @@ class Softphone {
14320
14384
  config.port = port;
14321
14385
  }
14322
14386
  if (tenantId) {
14387
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14323
14388
  config.tenantId = tenantId;
14324
14389
  }
14390
+ if (domainName) {
14391
+ config.domainName = domainName;
14392
+ }
14325
14393
  if (wrapUpDuration) {
14326
14394
  config.wrapUpDuration = wrapUpDuration;
14327
14395
  }
@@ -14642,6 +14710,7 @@ const Wazo = {
14642
14710
  CanceledCallError,
14643
14711
  SFUNotAvailableError,
14644
14712
  NoTenantIdError,
14713
+ NoDomainNameError,
14645
14714
  };
14646
14715
 
14647
14716
  if (window) {
@@ -2786,6 +2786,7 @@ var authMethods = (client , baseUrl ) => ({
2786
2786
 
2787
2787
 
2788
2788
 
2789
+
2789
2790
  ) {
2790
2791
  const body = {
2791
2792
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2806,9 +2807,14 @@ var authMethods = (client , baseUrl ) => ({
2806
2807
  }
2807
2808
 
2808
2809
  if (params.tenantId) {
2810
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2809
2811
  body.tenant_id = params.tenantId;
2810
2812
  }
2811
2813
 
2814
+ if (params.domainName) {
2815
+ body.domain_name = params.domainName;
2816
+ }
2817
+
2812
2818
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2813
2819
  },
2814
2820
 
@@ -2821,6 +2827,7 @@ var authMethods = (client , baseUrl ) => ({
2821
2827
  expiration ,
2822
2828
  isMobile = false,
2823
2829
  tenantId ,
2830
+ domainName ,
2824
2831
  ) => {
2825
2832
  const body = {
2826
2833
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2830,9 +2837,14 @@ var authMethods = (client , baseUrl ) => ({
2830
2837
  };
2831
2838
 
2832
2839
  if (tenantId) {
2840
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2833
2841
  body.tenant_id = tenantId;
2834
2842
  }
2835
2843
 
2844
+ if (domainName) {
2845
+ body.domain_name = domainName;
2846
+ }
2847
+
2836
2848
  const headers = {
2837
2849
  'Content-Type': 'application/json',
2838
2850
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4259,6 +4271,7 @@ global.wazoClientId = global.wazoClientId || {};
4259
4271
  global.wazoClientToken = global.wazoClientToken || {};
4260
4272
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4261
4273
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4274
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4262
4275
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4263
4276
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4264
4277
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5318,6 +5331,7 @@ class ApiClient {
5318
5331
 
5319
5332
 
5320
5333
 
5334
+
5321
5335
 
5322
5336
 
5323
5337
 
@@ -5359,6 +5373,7 @@ class ApiClient {
5359
5373
  refreshToken: this.refreshToken,
5360
5374
  refreshBackend: this.refreshBackend,
5361
5375
  refreshTenantId: this.refreshTenantId,
5376
+ refreshDomainName: this.refreshDomainName,
5362
5377
  refreshExpiration: this.refreshExpiration,
5363
5378
  isMobile: this.isMobile,
5364
5379
  });
@@ -5374,6 +5389,7 @@ class ApiClient {
5374
5389
  this.refreshExpiration,
5375
5390
  this.isMobile,
5376
5391
  this.refreshTenantId,
5392
+ this.refreshDomainName,
5377
5393
  );
5378
5394
 
5379
5395
  logger$1.info('token refreshed', { token: session.token });
@@ -5427,9 +5443,14 @@ class ApiClient {
5427
5443
  }
5428
5444
 
5429
5445
  setRefreshTenantId(tenantId ) {
5446
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5430
5447
  this.refreshTenantId = tenantId;
5431
5448
  }
5432
5449
 
5450
+ setRefreshDomainName(domainName ) {
5451
+ this.refreshDomainName = domainName;
5452
+ }
5453
+
5433
5454
  setIsMobile(isMobile ) {
5434
5455
  this.isMobile = isMobile;
5435
5456
  }
@@ -6391,9 +6412,11 @@ class WebRTCClient extends Emitter {
6391
6412
  const videoTracks = localStream.getVideoTracks();
6392
6413
 
6393
6414
  // Remove video senders
6394
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
6395
- videoSender.replaceTrack(null);
6396
- });
6415
+ if (pc.getSenders) {
6416
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
6417
+ videoSender.replaceTrack(null);
6418
+ });
6419
+ }
6397
6420
 
6398
6421
  videoTracks.forEach(videoTrack => {
6399
6422
  videoTrack.enabled = false;
@@ -6626,7 +6649,8 @@ class WebRTCClient extends Emitter {
6626
6649
  const constraints = { audio: { deviceId: { exact: deviceId } } };
6627
6650
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
6628
6651
  const audioTrack = stream.getAudioTracks()[0];
6629
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6652
+ const sender = pc && pc.getSenders
6653
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6630
6654
 
6631
6655
  if (sender) {
6632
6656
  if (sender.track) {
@@ -6689,10 +6713,11 @@ class WebRTCClient extends Emitter {
6689
6713
  // $FlowFixMe
6690
6714
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
6691
6715
  const videoTrack = stream.getVideoTracks()[0];
6692
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
6716
+ let sender = pc && pc.getSenders
6717
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
6693
6718
  let wasTrackEnabled = false;
6694
6719
  if (!sender) {
6695
- sender = pc && pc.getSenders().find(s => !s.track);
6720
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
6696
6721
  }
6697
6722
 
6698
6723
  if (sender) {
@@ -2215,6 +2215,7 @@ var authMethods = (client , baseUrl ) => ({
2215
2215
 
2216
2216
 
2217
2217
 
2218
+
2218
2219
  ) {
2219
2220
  const body = {
2220
2221
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2235,9 +2236,14 @@ var authMethods = (client , baseUrl ) => ({
2235
2236
  }
2236
2237
 
2237
2238
  if (params.tenantId) {
2239
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2238
2240
  body.tenant_id = params.tenantId;
2239
2241
  }
2240
2242
 
2243
+ if (params.domainName) {
2244
+ body.domain_name = params.domainName;
2245
+ }
2246
+
2241
2247
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2242
2248
  },
2243
2249
 
@@ -2250,6 +2256,7 @@ var authMethods = (client , baseUrl ) => ({
2250
2256
  expiration ,
2251
2257
  isMobile = false,
2252
2258
  tenantId ,
2259
+ domainName ,
2253
2260
  ) => {
2254
2261
  const body = {
2255
2262
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2259,9 +2266,14 @@ var authMethods = (client , baseUrl ) => ({
2259
2266
  };
2260
2267
 
2261
2268
  if (tenantId) {
2269
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2262
2270
  body.tenant_id = tenantId;
2263
2271
  }
2264
2272
 
2273
+ if (domainName) {
2274
+ body.domain_name = domainName;
2275
+ }
2276
+
2265
2277
  const headers = {
2266
2278
  'Content-Type': 'application/json',
2267
2279
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -3688,6 +3700,7 @@ global.wazoClientId = global.wazoClientId || {};
3688
3700
  global.wazoClientToken = global.wazoClientToken || {};
3689
3701
  global.wazoRefreshToken = global.wazoRefreshToken || {};
3690
3702
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
3703
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
3691
3704
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
3692
3705
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
3693
3706
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4747,6 +4760,7 @@ class ApiClient {
4747
4760
 
4748
4761
 
4749
4762
 
4763
+
4750
4764
 
4751
4765
 
4752
4766
 
@@ -4788,6 +4802,7 @@ class ApiClient {
4788
4802
  refreshToken: this.refreshToken,
4789
4803
  refreshBackend: this.refreshBackend,
4790
4804
  refreshTenantId: this.refreshTenantId,
4805
+ refreshDomainName: this.refreshDomainName,
4791
4806
  refreshExpiration: this.refreshExpiration,
4792
4807
  isMobile: this.isMobile,
4793
4808
  });
@@ -4803,6 +4818,7 @@ class ApiClient {
4803
4818
  this.refreshExpiration,
4804
4819
  this.isMobile,
4805
4820
  this.refreshTenantId,
4821
+ this.refreshDomainName,
4806
4822
  );
4807
4823
 
4808
4824
  logger.info('token refreshed', { token: session.token });
@@ -4856,9 +4872,14 @@ class ApiClient {
4856
4872
  }
4857
4873
 
4858
4874
  setRefreshTenantId(tenantId ) {
4875
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4859
4876
  this.refreshTenantId = tenantId;
4860
4877
  }
4861
4878
 
4879
+ setRefreshDomainName(domainName ) {
4880
+ this.refreshDomainName = domainName;
4881
+ }
4882
+
4862
4883
  setIsMobile(isMobile ) {
4863
4884
  this.isMobile = isMobile;
4864
4885
  }
@@ -2795,6 +2795,7 @@ var authMethods = (client , baseUrl ) => ({
2795
2795
 
2796
2796
 
2797
2797
 
2798
+
2798
2799
  ) {
2799
2800
  const body = {
2800
2801
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2815,9 +2816,14 @@ var authMethods = (client , baseUrl ) => ({
2815
2816
  }
2816
2817
 
2817
2818
  if (params.tenantId) {
2819
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2818
2820
  body.tenant_id = params.tenantId;
2819
2821
  }
2820
2822
 
2823
+ if (params.domainName) {
2824
+ body.domain_name = params.domainName;
2825
+ }
2826
+
2821
2827
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2822
2828
  },
2823
2829
 
@@ -2830,6 +2836,7 @@ var authMethods = (client , baseUrl ) => ({
2830
2836
  expiration ,
2831
2837
  isMobile = false,
2832
2838
  tenantId ,
2839
+ domainName ,
2833
2840
  ) => {
2834
2841
  const body = {
2835
2842
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2839,9 +2846,14 @@ var authMethods = (client , baseUrl ) => ({
2839
2846
  };
2840
2847
 
2841
2848
  if (tenantId) {
2849
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2842
2850
  body.tenant_id = tenantId;
2843
2851
  }
2844
2852
 
2853
+ if (domainName) {
2854
+ body.domain_name = domainName;
2855
+ }
2856
+
2845
2857
  const headers = {
2846
2858
  'Content-Type': 'application/json',
2847
2859
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4268,6 +4280,7 @@ global.wazoClientId = global.wazoClientId || {};
4268
4280
  global.wazoClientToken = global.wazoClientToken || {};
4269
4281
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4270
4282
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4283
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4271
4284
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4272
4285
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4273
4286
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5327,6 +5340,7 @@ class ApiClient {
5327
5340
 
5328
5341
 
5329
5342
 
5343
+
5330
5344
 
5331
5345
 
5332
5346
 
@@ -5368,6 +5382,7 @@ class ApiClient {
5368
5382
  refreshToken: this.refreshToken,
5369
5383
  refreshBackend: this.refreshBackend,
5370
5384
  refreshTenantId: this.refreshTenantId,
5385
+ refreshDomainName: this.refreshDomainName,
5371
5386
  refreshExpiration: this.refreshExpiration,
5372
5387
  isMobile: this.isMobile,
5373
5388
  });
@@ -5383,6 +5398,7 @@ class ApiClient {
5383
5398
  this.refreshExpiration,
5384
5399
  this.isMobile,
5385
5400
  this.refreshTenantId,
5401
+ this.refreshDomainName,
5386
5402
  );
5387
5403
 
5388
5404
  logger$1.info('token refreshed', { token: session.token });
@@ -5436,9 +5452,14 @@ class ApiClient {
5436
5452
  }
5437
5453
 
5438
5454
  setRefreshTenantId(tenantId ) {
5455
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5439
5456
  this.refreshTenantId = tenantId;
5440
5457
  }
5441
5458
 
5459
+ setRefreshDomainName(domainName ) {
5460
+ this.refreshDomainName = domainName;
5461
+ }
5462
+
5442
5463
  setIsMobile(isMobile ) {
5443
5464
  this.isMobile = isMobile;
5444
5465
  }
@@ -6397,9 +6418,11 @@ class WebRTCClient extends Emitter {
6397
6418
  const videoTracks = localStream.getVideoTracks();
6398
6419
 
6399
6420
  // Remove video senders
6400
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
6401
- videoSender.replaceTrack(null);
6402
- });
6421
+ if (pc.getSenders) {
6422
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
6423
+ videoSender.replaceTrack(null);
6424
+ });
6425
+ }
6403
6426
 
6404
6427
  videoTracks.forEach(videoTrack => {
6405
6428
  videoTrack.enabled = false;
@@ -6632,7 +6655,8 @@ class WebRTCClient extends Emitter {
6632
6655
  const constraints = { audio: { deviceId: { exact: deviceId } } };
6633
6656
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
6634
6657
  const audioTrack = stream.getAudioTracks()[0];
6635
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6658
+ const sender = pc && pc.getSenders
6659
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6636
6660
 
6637
6661
  if (sender) {
6638
6662
  if (sender.track) {
@@ -6695,10 +6719,11 @@ class WebRTCClient extends Emitter {
6695
6719
  // $FlowFixMe
6696
6720
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
6697
6721
  const videoTrack = stream.getVideoTracks()[0];
6698
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
6722
+ let sender = pc && pc.getSenders
6723
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
6699
6724
  let wasTrackEnabled = false;
6700
6725
  if (!sender) {
6701
- sender = pc && pc.getSenders().find(s => !s.track);
6726
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
6702
6727
  }
6703
6728
 
6704
6729
  if (sender) {
package/lib/api/auth.js CHANGED
@@ -975,6 +975,7 @@ var auth = (client , baseUrl ) => ({
975
975
 
976
976
 
977
977
 
978
+
978
979
  ) {
979
980
  const body = {
980
981
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -995,9 +996,14 @@ var auth = (client , baseUrl ) => ({
995
996
  }
996
997
 
997
998
  if (params.tenantId) {
999
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
998
1000
  body.tenant_id = params.tenantId;
999
1001
  }
1000
1002
 
1003
+ if (params.domainName) {
1004
+ body.domain_name = params.domainName;
1005
+ }
1006
+
1001
1007
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
1002
1008
  },
1003
1009
 
@@ -1010,6 +1016,7 @@ var auth = (client , baseUrl ) => ({
1010
1016
  expiration ,
1011
1017
  isMobile = false,
1012
1018
  tenantId ,
1019
+ domainName ,
1013
1020
  ) => {
1014
1021
  const body = {
1015
1022
  backend: backend || DEFAULT_BACKEND_USER,
@@ -1019,9 +1026,14 @@ var auth = (client , baseUrl ) => ({
1019
1026
  };
1020
1027
 
1021
1028
  if (tenantId) {
1029
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
1022
1030
  body.tenant_id = tenantId;
1023
1031
  }
1024
1032
 
1033
+ if (domainName) {
1034
+ body.domain_name = domainName;
1035
+ }
1036
+
1025
1037
  const headers = {
1026
1038
  'Content-Type': 'application/json',
1027
1039
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),