@wazo/sdk 0.38.7 → 0.38.10

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 (121) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +163 -2
  3. package/esm/__tests__/web-rtc-client.test.js +248 -27
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/calld.js +8 -0
  6. package/esm/api/confd.js +134 -2
  7. package/esm/api/ctid-ng.js +1 -0
  8. package/esm/api-client.js +163 -2
  9. package/esm/checker/Checker.js +204 -24
  10. package/esm/checker/checks/aor.js +163 -2
  11. package/esm/checker/checks/api.js +163 -2
  12. package/esm/checker/checks/index.js +204 -24
  13. package/esm/checker/checks/wazo-websocket.js +2 -0
  14. package/esm/checker/checks/webrtc-transport.js +202 -24
  15. package/esm/checker/checks/webrtc.js +202 -24
  16. package/esm/domain/AdHocAPIConference.js +170 -4
  17. package/esm/domain/Features.js +170 -4
  18. package/esm/domain/Meeting.js +18 -0
  19. package/esm/domain/MeetingAuthorization.js +70 -0
  20. package/esm/domain/Phone/CTIPhone.js +170 -4
  21. package/esm/domain/Phone/WebRTCPhone.js +2 -3
  22. package/esm/domain/__tests__/Meeting.test.js +87 -1
  23. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  24. package/esm/index.js +300 -36
  25. package/esm/service/CallApi.js +170 -4
  26. package/esm/service/getApiClient.js +176 -5
  27. package/esm/simple/Auth.js +301 -37
  28. package/esm/simple/Configuration.js +300 -36
  29. package/esm/simple/Directory.js +170 -4
  30. package/esm/simple/Phone.js +300 -36
  31. package/esm/simple/Softphone.js +5 -0
  32. package/esm/simple/Websocket.js +3 -0
  33. package/esm/simple/index.js +300 -36
  34. package/esm/simple/room/LocalParticipant.js +300 -36
  35. package/esm/simple/room/Participant.js +300 -36
  36. package/esm/simple/room/RemoteParticipant.js +300 -36
  37. package/esm/simple/room/Room.js +300 -36
  38. package/esm/simple/room/SipRoom.js +300 -36
  39. package/esm/simple/room/Stream.js +300 -36
  40. package/esm/simple/room/__tests__/Participant.test.js +14812 -0
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  42. package/esm/simple/utils.js +300 -36
  43. package/esm/utils/__tests__/object.test.js +57 -0
  44. package/esm/utils/__tests__/string.test.js +30 -0
  45. package/esm/utils/object.js +24 -0
  46. package/esm/utils/string.js +10 -0
  47. package/esm/web-rtc-client.js +202 -24
  48. package/esm/websocket-client.js +3 -1
  49. package/lib/__tests__/api-client.test.js +163 -2
  50. package/lib/__tests__/web-rtc-client.test.js +248 -27
  51. package/lib/api/auth.js +12 -0
  52. package/lib/api/calld.js +8 -0
  53. package/lib/api/confd.js +134 -2
  54. package/lib/api/ctid-ng.js +1 -0
  55. package/lib/api-client.js +163 -2
  56. package/lib/checker/Checker.js +204 -24
  57. package/lib/checker/checks/aor.js +163 -2
  58. package/lib/checker/checks/api.js +163 -2
  59. package/lib/checker/checks/index.js +204 -24
  60. package/lib/checker/checks/wazo-websocket.js +2 -0
  61. package/lib/checker/checks/webrtc-transport.js +202 -24
  62. package/lib/checker/checks/webrtc.js +202 -24
  63. package/lib/domain/AdHocAPIConference.js +170 -4
  64. package/lib/domain/Features.js +170 -4
  65. package/lib/domain/Meeting.js +18 -0
  66. package/lib/domain/MeetingAuthorization.js +79 -0
  67. package/lib/domain/Phone/CTIPhone.js +170 -4
  68. package/lib/domain/Phone/WebRTCPhone.js +2 -3
  69. package/lib/domain/__tests__/Meeting.test.js +87 -1
  70. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  71. package/lib/index.js +300 -36
  72. package/lib/service/CallApi.js +170 -4
  73. package/lib/service/getApiClient.js +176 -4
  74. package/lib/simple/Auth.js +301 -36
  75. package/lib/simple/Configuration.js +300 -36
  76. package/lib/simple/Directory.js +170 -4
  77. package/lib/simple/Phone.js +300 -36
  78. package/lib/simple/Softphone.js +5 -0
  79. package/lib/simple/Websocket.js +3 -0
  80. package/lib/simple/index.js +300 -36
  81. package/lib/simple/room/LocalParticipant.js +300 -36
  82. package/lib/simple/room/Participant.js +300 -36
  83. package/lib/simple/room/RemoteParticipant.js +300 -36
  84. package/lib/simple/room/Room.js +300 -36
  85. package/lib/simple/room/SipRoom.js +300 -36
  86. package/lib/simple/room/Stream.js +300 -36
  87. package/lib/simple/room/__tests__/Participant.test.js +14822 -0
  88. package/lib/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  89. package/lib/simple/utils.js +300 -36
  90. package/lib/utils/__tests__/object.test.js +59 -0
  91. package/lib/utils/__tests__/string.test.js +32 -0
  92. package/lib/utils/object.js +28 -0
  93. package/lib/utils/string.js +14 -0
  94. package/lib/web-rtc-client.js +202 -24
  95. package/lib/websocket-client.js +3 -0
  96. package/package.json +1 -1
  97. package/src/__tests__/web-rtc-client.test.js +46 -3
  98. package/src/api/auth.js +12 -0
  99. package/src/api/calld.js +8 -0
  100. package/src/api/confd.js +43 -2
  101. package/src/api-client.js +8 -0
  102. package/src/domain/Meeting.js +20 -0
  103. package/src/domain/MeetingAuthorization.js +67 -0
  104. package/src/domain/Phone/WebRTCPhone.js +1 -3
  105. package/src/domain/__tests__/Meeting.test.js +70 -1
  106. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  107. package/src/service/getApiClient.js +13 -2
  108. package/src/simple/Auth.js +35 -4
  109. package/src/simple/Softphone.js +5 -0
  110. package/src/simple/index.js +2 -1
  111. package/src/simple/room/Participant.js +40 -0
  112. package/src/simple/room/Room.js +2 -2
  113. package/src/simple/room/SipRoom.js +1 -1
  114. package/src/simple/room/__tests__/Participant.test.js +81 -0
  115. package/src/types/WebSocketMessage.js +7 -1
  116. package/src/utils/__tests__/object.test.js +35 -0
  117. package/src/utils/__tests__/string.test.js +23 -0
  118. package/src/utils/object.js +15 -0
  119. package/src/utils/string.js +8 -0
  120. package/src/web-rtc-client.js +39 -22
  121. package/src/websocket-client.js +2 -0
@@ -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' } : {}),
@@ -2655,6 +2667,70 @@ class ExternalApp {
2655
2667
 
2656
2668
  //
2657
2669
 
2670
+ class MeetingAuthorization {
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+ constructor({
2678
+ meetingUuid,
2679
+ uuid,
2680
+ userUuid,
2681
+ userName,
2682
+ } = {}) {
2683
+ this.meetingUuid = meetingUuid;
2684
+ this.uuid = uuid;
2685
+ this.userUuid = userUuid;
2686
+ this.userName = userName;
2687
+ }
2688
+
2689
+ setStatus(status ) {
2690
+ this.status = status;
2691
+ }
2692
+
2693
+ getStatus() {
2694
+ return this.status;
2695
+ }
2696
+
2697
+ static parse(plain ) {
2698
+ const {
2699
+ meeting_uuid: meetingUuid,
2700
+ uuid,
2701
+ guest_uuid: userUuid,
2702
+ guest_name: userName,
2703
+ } = plain;
2704
+
2705
+ return new MeetingAuthorization({
2706
+ meetingUuid,
2707
+ uuid,
2708
+ userUuid,
2709
+ userName,
2710
+ });
2711
+ }
2712
+
2713
+ static parseMany(items ) {
2714
+ if (!items) {
2715
+ return [];
2716
+ }
2717
+ return items.map(MeetingAuthorization.parse);
2718
+ }
2719
+ }
2720
+
2721
+ //
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2658
2734
 
2659
2735
 
2660
2736
 
@@ -2665,6 +2741,7 @@ class ExternalApp {
2665
2741
 
2666
2742
 
2667
2743
 
2744
+
2668
2745
 
2669
2746
 
2670
2747
  class Meeting {
@@ -2679,6 +2756,8 @@ class Meeting {
2679
2756
 
2680
2757
 
2681
2758
 
2759
+
2760
+
2682
2761
 
2683
2762
  static parse(plain ) {
2684
2763
  return new Meeting({
@@ -2691,6 +2770,7 @@ class Meeting {
2691
2770
  extension: plain.exten,
2692
2771
  persistent: plain.persistent,
2693
2772
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2773
+ requireAuthorization: plain.require_authorization,
2694
2774
  });
2695
2775
  }
2696
2776
 
@@ -2715,6 +2795,7 @@ class Meeting {
2715
2795
  extension,
2716
2796
  persistent,
2717
2797
  creationTime,
2798
+ requireAuthorization,
2718
2799
  } = {}) {
2719
2800
  this.guestSipAuthorization = guestSipAuthorization;
2720
2801
  this.uri = uri;
@@ -2725,6 +2806,7 @@ class Meeting {
2725
2806
  this.extension = extension;
2726
2807
  this.persistent = persistent;
2727
2808
  this.creationTime = creationTime;
2809
+ this.requireAuthorization = requireAuthorization;
2728
2810
 
2729
2811
  // Useful to compare instead of instanceof with minified code
2730
2812
  this.type = 'Meeting';
@@ -2735,8 +2817,32 @@ class Meeting {
2735
2817
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2736
2818
  return { username, secret };
2737
2819
  }
2820
+
2738
2821
  }
2739
2822
 
2823
+ //
2824
+
2825
+ const camelToUnderscore = (key ) => {
2826
+ if (typeof key !== 'string') {
2827
+ throw new Error('Input is not a string');
2828
+ }
2829
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2830
+ };
2831
+
2832
+ //
2833
+
2834
+ const convertKeysFromCamelToUnderscore = (args ) => {
2835
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2836
+ throw new Error('Input is not an object');
2837
+ }
2838
+
2839
+ return Object.keys(args).reduce((acc, key) => {
2840
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2841
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2842
+ return acc;
2843
+ }, {});
2844
+ };
2845
+
2740
2846
  /* */
2741
2847
 
2742
2848
  var confdMethods = (client , baseUrl ) => ({
@@ -2805,8 +2911,18 @@ var confdMethods = (client , baseUrl ) => ({
2805
2911
  getMyMeetings: () =>
2806
2912
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2807
2913
 
2808
- createMyMeeting: (name , persistent ) =>
2809
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2914
+ createMyMeeting: (args ) =>
2915
+ client
2916
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2917
+ .then(Meeting.parse),
2918
+
2919
+ updateMyMeeting: (meetingUuid , data ) =>
2920
+ client.put(
2921
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2922
+ convertKeysFromCamelToUnderscore(data),
2923
+ null,
2924
+ ApiRequester.successResponseParser,
2925
+ ),
2810
2926
 
2811
2927
  deleteMyMeeting: (meetingUuid ) =>
2812
2928
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2814,8 +2930,36 @@ var confdMethods = (client , baseUrl ) => ({
2814
2930
  getMeeting: (meetingUuid ) =>
2815
2931
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2816
2932
 
2933
+ meetingAuthorizations: (meetingUuid ) =>
2934
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2935
+
2936
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2937
+ client.put(
2938
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2939
+ {},
2940
+ null,
2941
+ ApiRequester.successResponseParser,
2942
+ ),
2943
+
2944
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2945
+ client.put(
2946
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2947
+ {},
2948
+ null,
2949
+ ApiRequester.successResponseParser,
2950
+ ),
2951
+
2817
2952
  guestGetMeeting: (meetingUuid ) =>
2818
2953
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2954
+
2955
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2956
+ client
2957
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2958
+ .then(MeetingAuthorization.parse),
2959
+
2960
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2961
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2962
+
2819
2963
  });
2820
2964
 
2821
2965
  //
@@ -5066,6 +5210,14 @@ var calldMethods = (client , baseUrl ) => ({
5066
5210
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5067
5211
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5068
5212
 
5213
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5214
+ client.delete(
5215
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5216
+ null,
5217
+ null,
5218
+ ApiRequester.successResponseParser,
5219
+ ),
5220
+
5069
5221
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5070
5222
 
5071
5223
  mute: (callId ) =>
@@ -5443,6 +5595,7 @@ class ApiClient {
5443
5595
 
5444
5596
 
5445
5597
 
5598
+
5446
5599
 
5447
5600
 
5448
5601
 
@@ -5484,6 +5637,7 @@ class ApiClient {
5484
5637
  refreshToken: this.refreshToken,
5485
5638
  refreshBackend: this.refreshBackend,
5486
5639
  refreshTenantId: this.refreshTenantId,
5640
+ refreshDomainName: this.refreshDomainName,
5487
5641
  refreshExpiration: this.refreshExpiration,
5488
5642
  isMobile: this.isMobile,
5489
5643
  });
@@ -5499,6 +5653,7 @@ class ApiClient {
5499
5653
  this.refreshExpiration,
5500
5654
  this.isMobile,
5501
5655
  this.refreshTenantId,
5656
+ this.refreshDomainName,
5502
5657
  );
5503
5658
 
5504
5659
  logger$a.info('token refreshed', { token: session.token });
@@ -5552,9 +5707,14 @@ class ApiClient {
5552
5707
  }
5553
5708
 
5554
5709
  setRefreshTenantId(tenantId ) {
5710
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5555
5711
  this.refreshTenantId = tenantId;
5556
5712
  }
5557
5713
 
5714
+ setRefreshDomainName(domainName ) {
5715
+ this.refreshDomainName = domainName;
5716
+ }
5717
+
5558
5718
  setIsMobile(isMobile ) {
5559
5719
  this.isMobile = isMobile;
5560
5720
  }
@@ -5579,6 +5739,7 @@ global.wazoClientId = global.wazoClientId || {};
5579
5739
  global.wazoClientToken = global.wazoClientToken || {};
5580
5740
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5581
5741
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5742
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5582
5743
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5583
5744
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5584
5745
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5603,9 +5764,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5603
5764
  };
5604
5765
 
5605
5766
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5767
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5606
5768
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5607
5769
  };
5608
5770
 
5771
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5772
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5773
+ };
5774
+
5609
5775
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5610
5776
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5611
5777
  };
@@ -5624,6 +5790,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5624
5790
 
5625
5791
  const fillClient = (apiClient ) => {
5626
5792
  const { server, token, clientId } = apiClient.client;
5793
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5627
5794
 
5628
5795
  // try with null server when dealing with non-related server info
5629
5796
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5632,8 +5799,12 @@ const fillClient = (apiClient ) => {
5632
5799
 
5633
5800
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5634
5801
 
5635
- apiClient.setRefreshTenantId(
5636
- 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,
5637
5808
  );
5638
5809
 
5639
5810
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7523,7 +7694,7 @@ class WebRTCClient extends Emitter {
7523
7694
  });
7524
7695
  }
7525
7696
 
7526
- changeAudioInputDevice(id , session , force ) {
7697
+ async changeAudioInputDevice(id , session , force ) {
7527
7698
  const currentId = this.getAudioDeviceId();
7528
7699
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7529
7700
 
@@ -7531,33 +7702,50 @@ class WebRTCClient extends Emitter {
7531
7702
  return null;
7532
7703
  }
7533
7704
 
7705
+ // in order to handle an audio track change for default devices
7706
+ // we need the actual id of the device (not 'default')
7707
+ let deviceId = id;
7708
+ if (id === 'default' && navigator.mediaDevices) {
7709
+ const devices = await navigator.mediaDevices.enumerateDevices();
7710
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7711
+ if (defaultDevice) {
7712
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7713
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7714
+ if (targetDevice) {
7715
+ deviceId = targetDevice.deviceId;
7716
+ if (!force && deviceId === currentId) {
7717
+ return null;
7718
+ }
7719
+ }
7720
+ }
7721
+ }
7722
+
7534
7723
  // let's update the local audio value
7535
7724
  if (this.audio) {
7536
7725
  this.audio = {
7537
7726
  deviceId: {
7538
- exact: id,
7727
+ exact: deviceId,
7539
7728
  },
7540
7729
  };
7541
7730
  }
7542
7731
 
7543
- if (session) {
7732
+ if (session && navigator.mediaDevices) {
7544
7733
  const sdh = session.sessionDescriptionHandler;
7545
7734
  const pc = sdh.peerConnection;
7546
7735
 
7547
- // $FlowFixMe
7548
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7549
- const audioTrack = stream.getAudioTracks()[0];
7550
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7736
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7737
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7738
+ const audioTrack = stream.getAudioTracks()[0];
7739
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7551
7740
 
7552
- if (sender) {
7553
- if (sender.track) {
7554
- audioTrack.enabled = sender.track.enabled;
7555
- }
7556
- sender.replaceTrack(audioTrack);
7741
+ if (sender) {
7742
+ if (sender.track) {
7743
+ audioTrack.enabled = sender.track.enabled;
7557
7744
  }
7745
+ sender.replaceTrack(audioTrack);
7746
+ }
7558
7747
 
7559
- return stream;
7560
- });
7748
+ return stream;
7561
7749
  }
7562
7750
  }
7563
7751
 
@@ -7577,14 +7765,14 @@ class WebRTCClient extends Emitter {
7577
7765
  return null;
7578
7766
  }
7579
7767
 
7580
- // let's update the local video value
7581
- if (this.video) {
7582
- this.video = {
7583
- deviceId: {
7584
- exact: id,
7585
- },
7586
- };
7587
- }
7768
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7769
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7770
+ this.video = {
7771
+ ...videoObject,
7772
+ deviceId: {
7773
+ exact: id,
7774
+ },
7775
+ };
7588
7776
  }
7589
7777
 
7590
7778
  changeSessionVideoInputDevice(id , session ) {
@@ -9186,9 +9374,7 @@ class WebRTCPhone extends Emitter {
9186
9374
 
9187
9375
  try {
9188
9376
  if (this.currentScreenShare.stream) {
9189
- this.currentScreenShare.stream.getTracks()
9190
- .filter(track => track.kind === 'video')
9191
- .forEach(track => track.stop());
9377
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9192
9378
  }
9193
9379
 
9194
9380
  if (restoreLocalStream) {
@@ -10979,6 +11165,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10979
11165
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10980
11166
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10981
11167
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11168
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10982
11169
 
10983
11170
  const BLACKLIST_EVENTS = [
10984
11171
  CHAT_MESSAGE_SENT,
@@ -11330,6 +11517,7 @@ WebSocketClient.eventLists = [
11330
11517
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11331
11518
  CONFERENCE_ADHOC_DELETED,
11332
11519
  MEETING_USER_PROGRESS,
11520
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11333
11521
  ];
11334
11522
 
11335
11523
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11401,6 +11589,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11401
11589
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11402
11590
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11403
11591
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11592
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11404
11593
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11405
11594
  'default': WebSocketClient
11406
11595
  });
@@ -11505,6 +11694,7 @@ class Participant extends Emitter {
11505
11694
 
11506
11695
 
11507
11696
 
11697
+
11508
11698
 
11509
11699
 
11510
11700
 
@@ -11522,6 +11712,7 @@ class Participant extends Emitter {
11522
11712
 
11523
11713
 
11524
11714
 
11715
+
11525
11716
 
11526
11717
  /**
11527
11718
  * @param room Room The room where the participant is
@@ -11545,6 +11736,7 @@ class Participant extends Emitter {
11545
11736
  this.screensharing = false;
11546
11737
  this.isOnHold = false;
11547
11738
  this.extra = extra;
11739
+ this.banned = false;
11548
11740
 
11549
11741
  this.ON_UPDATED = 'participant/ON_UPDATED';
11550
11742
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11561,6 +11753,7 @@ class Participant extends Emitter {
11561
11753
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11562
11754
  this.ON_HOLD = 'participant/ON_HOLD';
11563
11755
  this.ON_RESUME = 'participant/ON_RESUME';
11756
+ this.ON_BAN = 'participant/ON_BAN';
11564
11757
  }
11565
11758
 
11566
11759
  triggerEvent(name , ...args ) {
@@ -11601,6 +11794,10 @@ class Participant extends Emitter {
11601
11794
  status.extra = this.extra;
11602
11795
  break;
11603
11796
  }
11797
+ case this.ON_BAN: {
11798
+ status.banned = true;
11799
+ break;
11800
+ }
11604
11801
  }
11605
11802
 
11606
11803
  if (broadcast) {
@@ -11703,6 +11900,11 @@ class Participant extends Emitter {
11703
11900
  this.triggerUpdate(this.ON_RESUME, broadcast);
11704
11901
  }
11705
11902
 
11903
+ onBan(broadcast = true) {
11904
+ this.banned = true;
11905
+ this.triggerUpdate(this.ON_BAN, broadcast);
11906
+ }
11907
+
11706
11908
  getStatus() {
11707
11909
  return {
11708
11910
  callId: this.callId,
@@ -11749,6 +11951,10 @@ class Participant extends Emitter {
11749
11951
  }
11750
11952
  }
11751
11953
 
11954
+ if (status.banned) {
11955
+ this.onBan(false);
11956
+ }
11957
+
11752
11958
  // Poor man's object comparison
11753
11959
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11754
11960
  this.extra = { ...this.extra, ...status.extra };
@@ -11776,6 +11982,28 @@ class Participant extends Emitter {
11776
11982
  this.streams = streams;
11777
11983
  this.videoStreams = streams;
11778
11984
  }
11985
+
11986
+ async ban(apiRequestDelay = null) {
11987
+ const { meetingUuid } = this.room;
11988
+ if (!meetingUuid) {
11989
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11990
+ }
11991
+
11992
+ // this notifies all that someone is being banned
11993
+ this.onBan(true);
11994
+
11995
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11996
+ if (apiRequestDelay) {
11997
+ await this.delay(apiRequestDelay);
11998
+ }
11999
+
12000
+ // proceed with the actual kick
12001
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12002
+ }
12003
+
12004
+ async delay(ms ) {
12005
+ return new Promise(resolve => setTimeout(resolve, ms));
12006
+ }
11779
12007
  }
11780
12008
 
11781
12009
  //
@@ -11928,7 +12156,7 @@ class Room$1 extends Emitter {
11928
12156
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11929
12157
 
11930
12158
  if (!room) {
11931
- await Wazo.Phone.connect();
12159
+ await Wazo.Phone.connect({ media: constraints });
11932
12160
 
11933
12161
  const withCamera = constraints && !!constraints.video;
11934
12162
 
@@ -12373,7 +12601,7 @@ class Room$1 extends Emitter {
12373
12601
  const participant = this._getParticipantFromCallId(status.callId);
12374
12602
 
12375
12603
  if (participant) {
12376
- // we're received, so no need to broadcast, hence the input false arg
12604
+ // we're receiving, so no need to broadcast
12377
12605
  participant.updateStatus(status, false);
12378
12606
  }
12379
12607
  break;
@@ -12640,7 +12868,7 @@ class SipRoom extends Room$1 {
12640
12868
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12641
12869
 
12642
12870
  if (!room) {
12643
- await Wazo.Phone.connect();
12871
+ await Wazo.Phone.connect({ media: constraints });
12644
12872
 
12645
12873
  const withCamera = constraints && !!constraints.video;
12646
12874
 
@@ -13805,6 +14033,7 @@ class Softphone {
13805
14033
  wrapUpDuration,
13806
14034
  enableAgent = true,
13807
14035
  tenantId,
14036
+ domainName,
13808
14037
  debug = false,
13809
14038
  } = {}) {
13810
14039
  this.url = url || 'https://softphone.wazo.io';
@@ -13829,8 +14058,12 @@ class Softphone {
13829
14058
  config.port = port;
13830
14059
  }
13831
14060
  if (tenantId) {
14061
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13832
14062
  config.tenantId = tenantId;
13833
14063
  }
14064
+ if (domainName) {
14065
+ config.domainName = domainName;
14066
+ }
13834
14067
  if (wrapUpDuration) {
13835
14068
  config.wrapUpDuration = wrapUpDuration;
13836
14069
  }
@@ -14151,6 +14384,7 @@ const Wazo = {
14151
14384
  CanceledCallError,
14152
14385
  SFUNotAvailableError,
14153
14386
  NoTenantIdError,
14387
+ NoDomainNameError,
14154
14388
  };
14155
14389
 
14156
14390
  if (window) {
@@ -14165,6 +14399,7 @@ if (global) {
14165
14399
  class InvalidSubscription extends Error {}
14166
14400
  class InvalidAuthorization extends Error {}
14167
14401
  class NoTenantIdError extends Error {}
14402
+ class NoDomainNameError extends Error {}
14168
14403
 
14169
14404
  const logger = IssueReporter$1.loggerFor('simple-auth');
14170
14405
 
@@ -14228,9 +14463,24 @@ class Auth {
14228
14463
  setFetchOptions(options);
14229
14464
  }
14230
14465
 
14231
- async logIn(username , password , backend , tenantId ) {
14232
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14233
- throw new NoTenantIdError('No tenant id');
14466
+ async logIn(username , password , backend , extra ) {
14467
+ let tenantId = null;
14468
+ let domainName = null;
14469
+ if (typeof extra === 'string') {
14470
+ tenantId = extra;
14471
+ }
14472
+ if (extra && typeof extra === 'object') {
14473
+ domainName = extra.domainName;
14474
+ }
14475
+
14476
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14477
+ if (!tenantId) {
14478
+ throw new NoTenantIdError('No tenant id');
14479
+ }
14480
+
14481
+ if (!domainName) {
14482
+ throw new NoDomainNameError('No domain name');
14483
+ }
14234
14484
  }
14235
14485
 
14236
14486
  this.authenticated = false;
@@ -14240,6 +14490,7 @@ class Auth {
14240
14490
  password,
14241
14491
  backend,
14242
14492
  tenantId,
14493
+ domainName,
14243
14494
  expiration: this.expiration,
14244
14495
  mobile: this.mobile,
14245
14496
  });
@@ -14248,7 +14499,13 @@ class Auth {
14248
14499
  getApiClient().setRefreshBackend(backend);
14249
14500
  }
14250
14501
 
14251
- getApiClient().setRefreshTenantId(tenantId);
14502
+ if (tenantId) {
14503
+ getApiClient().setRefreshTenantId(tenantId);
14504
+ }
14505
+
14506
+ if (domainName) {
14507
+ getApiClient().setRefreshDomainName(domainName);
14508
+ }
14252
14509
 
14253
14510
  return this._onAuthenticated(rawSession);
14254
14511
  }
@@ -14347,11 +14604,18 @@ class Auth {
14347
14604
  }
14348
14605
 
14349
14606
  setRefreshTenantId(refreshTenantId ) {
14607
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14350
14608
  setRefreshTenantId(refreshTenantId);
14351
14609
 
14352
14610
  getApiClient().setRefreshTenantId(refreshTenantId);
14353
14611
  }
14354
14612
 
14613
+ setRefreshDomainName(domainName ) {
14614
+ setRefreshDomainName(domainName);
14615
+
14616
+ getApiClient().setRefreshDomainName(domainName);
14617
+ }
14618
+
14355
14619
  forceRefreshToken() {
14356
14620
  getApiClient().forceRefreshToken();
14357
14621
  }