@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
@@ -2241,6 +2241,7 @@ var authMethods = (client , baseUrl ) => ({
2241
2241
 
2242
2242
 
2243
2243
 
2244
+
2244
2245
  ) {
2245
2246
  const body = {
2246
2247
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2261,9 +2262,14 @@ var authMethods = (client , baseUrl ) => ({
2261
2262
  }
2262
2263
 
2263
2264
  if (params.tenantId) {
2265
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2264
2266
  body.tenant_id = params.tenantId;
2265
2267
  }
2266
2268
 
2269
+ if (params.domainName) {
2270
+ body.domain_name = params.domainName;
2271
+ }
2272
+
2267
2273
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2268
2274
  },
2269
2275
 
@@ -2276,6 +2282,7 @@ var authMethods = (client , baseUrl ) => ({
2276
2282
  expiration ,
2277
2283
  isMobile = false,
2278
2284
  tenantId ,
2285
+ domainName ,
2279
2286
  ) => {
2280
2287
  const body = {
2281
2288
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2292,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2292
  };
2286
2293
 
2287
2294
  if (tenantId) {
2295
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2288
2296
  body.tenant_id = tenantId;
2289
2297
  }
2290
2298
 
2299
+ if (domainName) {
2300
+ body.domain_name = domainName;
2301
+ }
2302
+
2291
2303
  const headers = {
2292
2304
  'Content-Type': 'application/json',
2293
2305
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2657,6 +2669,70 @@ class ExternalApp {
2657
2669
 
2658
2670
  //
2659
2671
 
2672
+ class MeetingAuthorization {
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+ constructor({
2680
+ meetingUuid,
2681
+ uuid,
2682
+ userUuid,
2683
+ userName,
2684
+ } = {}) {
2685
+ this.meetingUuid = meetingUuid;
2686
+ this.uuid = uuid;
2687
+ this.userUuid = userUuid;
2688
+ this.userName = userName;
2689
+ }
2690
+
2691
+ setStatus(status ) {
2692
+ this.status = status;
2693
+ }
2694
+
2695
+ getStatus() {
2696
+ return this.status;
2697
+ }
2698
+
2699
+ static parse(plain ) {
2700
+ const {
2701
+ meeting_uuid: meetingUuid,
2702
+ uuid,
2703
+ guest_uuid: userUuid,
2704
+ guest_name: userName,
2705
+ } = plain;
2706
+
2707
+ return new MeetingAuthorization({
2708
+ meetingUuid,
2709
+ uuid,
2710
+ userUuid,
2711
+ userName,
2712
+ });
2713
+ }
2714
+
2715
+ static parseMany(items ) {
2716
+ if (!items) {
2717
+ return [];
2718
+ }
2719
+ return items.map(MeetingAuthorization.parse);
2720
+ }
2721
+ }
2722
+
2723
+ //
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2660
2736
 
2661
2737
 
2662
2738
 
@@ -2667,6 +2743,7 @@ class ExternalApp {
2667
2743
 
2668
2744
 
2669
2745
 
2746
+
2670
2747
 
2671
2748
 
2672
2749
  class Meeting {
@@ -2681,6 +2758,8 @@ class Meeting {
2681
2758
 
2682
2759
 
2683
2760
 
2761
+
2762
+
2684
2763
 
2685
2764
  static parse(plain ) {
2686
2765
  return new Meeting({
@@ -2693,6 +2772,7 @@ class Meeting {
2693
2772
  extension: plain.exten,
2694
2773
  persistent: plain.persistent,
2695
2774
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2775
+ requireAuthorization: plain.require_authorization,
2696
2776
  });
2697
2777
  }
2698
2778
 
@@ -2717,6 +2797,7 @@ class Meeting {
2717
2797
  extension,
2718
2798
  persistent,
2719
2799
  creationTime,
2800
+ requireAuthorization,
2720
2801
  } = {}) {
2721
2802
  this.guestSipAuthorization = guestSipAuthorization;
2722
2803
  this.uri = uri;
@@ -2727,6 +2808,7 @@ class Meeting {
2727
2808
  this.extension = extension;
2728
2809
  this.persistent = persistent;
2729
2810
  this.creationTime = creationTime;
2811
+ this.requireAuthorization = requireAuthorization;
2730
2812
 
2731
2813
  // Useful to compare instead of instanceof with minified code
2732
2814
  this.type = 'Meeting';
@@ -2737,8 +2819,32 @@ class Meeting {
2737
2819
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2738
2820
  return { username, secret };
2739
2821
  }
2822
+
2740
2823
  }
2741
2824
 
2825
+ //
2826
+
2827
+ const camelToUnderscore = (key ) => {
2828
+ if (typeof key !== 'string') {
2829
+ throw new Error('Input is not a string');
2830
+ }
2831
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2832
+ };
2833
+
2834
+ //
2835
+
2836
+ const convertKeysFromCamelToUnderscore = (args ) => {
2837
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2838
+ throw new Error('Input is not an object');
2839
+ }
2840
+
2841
+ return Object.keys(args).reduce((acc, key) => {
2842
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2843
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2844
+ return acc;
2845
+ }, {});
2846
+ };
2847
+
2742
2848
  /* */
2743
2849
 
2744
2850
  var confdMethods = (client , baseUrl ) => ({
@@ -2807,8 +2913,18 @@ var confdMethods = (client , baseUrl ) => ({
2807
2913
  getMyMeetings: () =>
2808
2914
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2809
2915
 
2810
- createMyMeeting: (name , persistent ) =>
2811
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2916
+ createMyMeeting: (args ) =>
2917
+ client
2918
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2919
+ .then(Meeting.parse),
2920
+
2921
+ updateMyMeeting: (meetingUuid , data ) =>
2922
+ client.put(
2923
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2924
+ convertKeysFromCamelToUnderscore(data),
2925
+ null,
2926
+ ApiRequester.successResponseParser,
2927
+ ),
2812
2928
 
2813
2929
  deleteMyMeeting: (meetingUuid ) =>
2814
2930
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2816,8 +2932,36 @@ var confdMethods = (client , baseUrl ) => ({
2816
2932
  getMeeting: (meetingUuid ) =>
2817
2933
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2818
2934
 
2935
+ meetingAuthorizations: (meetingUuid ) =>
2936
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2937
+
2938
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2939
+ client.put(
2940
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2941
+ {},
2942
+ null,
2943
+ ApiRequester.successResponseParser,
2944
+ ),
2945
+
2946
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2947
+ client.put(
2948
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2949
+ {},
2950
+ null,
2951
+ ApiRequester.successResponseParser,
2952
+ ),
2953
+
2819
2954
  guestGetMeeting: (meetingUuid ) =>
2820
2955
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2956
+
2957
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2958
+ client
2959
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2960
+ .then(MeetingAuthorization.parse),
2961
+
2962
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2963
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2964
+
2821
2965
  });
2822
2966
 
2823
2967
  //
@@ -5068,6 +5212,14 @@ var calldMethods = (client , baseUrl ) => ({
5068
5212
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5069
5213
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5070
5214
 
5215
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5216
+ client.delete(
5217
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5218
+ null,
5219
+ null,
5220
+ ApiRequester.successResponseParser,
5221
+ ),
5222
+
5071
5223
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5072
5224
 
5073
5225
  mute: (callId ) =>
@@ -5445,6 +5597,7 @@ class ApiClient {
5445
5597
 
5446
5598
 
5447
5599
 
5600
+
5448
5601
 
5449
5602
 
5450
5603
 
@@ -5486,6 +5639,7 @@ class ApiClient {
5486
5639
  refreshToken: this.refreshToken,
5487
5640
  refreshBackend: this.refreshBackend,
5488
5641
  refreshTenantId: this.refreshTenantId,
5642
+ refreshDomainName: this.refreshDomainName,
5489
5643
  refreshExpiration: this.refreshExpiration,
5490
5644
  isMobile: this.isMobile,
5491
5645
  });
@@ -5501,6 +5655,7 @@ class ApiClient {
5501
5655
  this.refreshExpiration,
5502
5656
  this.isMobile,
5503
5657
  this.refreshTenantId,
5658
+ this.refreshDomainName,
5504
5659
  );
5505
5660
 
5506
5661
  logger$a.info('token refreshed', { token: session.token });
@@ -5554,9 +5709,14 @@ class ApiClient {
5554
5709
  }
5555
5710
 
5556
5711
  setRefreshTenantId(tenantId ) {
5712
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5557
5713
  this.refreshTenantId = tenantId;
5558
5714
  }
5559
5715
 
5716
+ setRefreshDomainName(domainName ) {
5717
+ this.refreshDomainName = domainName;
5718
+ }
5719
+
5560
5720
  setIsMobile(isMobile ) {
5561
5721
  this.isMobile = isMobile;
5562
5722
  }
@@ -5581,6 +5741,7 @@ global.wazoClientId = global.wazoClientId || {};
5581
5741
  global.wazoClientToken = global.wazoClientToken || {};
5582
5742
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5583
5743
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5744
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5584
5745
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5585
5746
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5586
5747
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5605,9 +5766,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5605
5766
  };
5606
5767
 
5607
5768
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5769
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5608
5770
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5609
5771
  };
5610
5772
 
5773
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5774
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5775
+ };
5776
+
5611
5777
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5612
5778
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5613
5779
  };
@@ -5626,6 +5792,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5626
5792
 
5627
5793
  const fillClient = (apiClient ) => {
5628
5794
  const { server, token, clientId } = apiClient.client;
5795
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5629
5796
 
5630
5797
  // try with null server when dealing with non-related server info
5631
5798
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5634,8 +5801,12 @@ const fillClient = (apiClient ) => {
5634
5801
 
5635
5802
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5636
5803
 
5637
- apiClient.setRefreshTenantId(
5638
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5804
+ if (tenantId) {
5805
+ apiClient.setRefreshTenantId(tenantId);
5806
+ }
5807
+
5808
+ apiClient.setRefreshDomainName(
5809
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5639
5810
  );
5640
5811
 
5641
5812
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7525,7 +7696,7 @@ class WebRTCClient extends Emitter {
7525
7696
  });
7526
7697
  }
7527
7698
 
7528
- changeAudioInputDevice(id , session , force ) {
7699
+ async changeAudioInputDevice(id , session , force ) {
7529
7700
  const currentId = this.getAudioDeviceId();
7530
7701
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7531
7702
 
@@ -7533,33 +7704,50 @@ class WebRTCClient extends Emitter {
7533
7704
  return null;
7534
7705
  }
7535
7706
 
7707
+ // in order to handle an audio track change for default devices
7708
+ // we need the actual id of the device (not 'default')
7709
+ let deviceId = id;
7710
+ if (id === 'default' && navigator.mediaDevices) {
7711
+ const devices = await navigator.mediaDevices.enumerateDevices();
7712
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7713
+ if (defaultDevice) {
7714
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7715
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7716
+ if (targetDevice) {
7717
+ deviceId = targetDevice.deviceId;
7718
+ if (!force && deviceId === currentId) {
7719
+ return null;
7720
+ }
7721
+ }
7722
+ }
7723
+ }
7724
+
7536
7725
  // let's update the local audio value
7537
7726
  if (this.audio) {
7538
7727
  this.audio = {
7539
7728
  deviceId: {
7540
- exact: id,
7729
+ exact: deviceId,
7541
7730
  },
7542
7731
  };
7543
7732
  }
7544
7733
 
7545
- if (session) {
7734
+ if (session && navigator.mediaDevices) {
7546
7735
  const sdh = session.sessionDescriptionHandler;
7547
7736
  const pc = sdh.peerConnection;
7548
7737
 
7549
- // $FlowFixMe
7550
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7551
- const audioTrack = stream.getAudioTracks()[0];
7552
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7738
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7739
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7740
+ const audioTrack = stream.getAudioTracks()[0];
7741
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7553
7742
 
7554
- if (sender) {
7555
- if (sender.track) {
7556
- audioTrack.enabled = sender.track.enabled;
7557
- }
7558
- sender.replaceTrack(audioTrack);
7743
+ if (sender) {
7744
+ if (sender.track) {
7745
+ audioTrack.enabled = sender.track.enabled;
7559
7746
  }
7747
+ sender.replaceTrack(audioTrack);
7748
+ }
7560
7749
 
7561
- return stream;
7562
- });
7750
+ return stream;
7563
7751
  }
7564
7752
  }
7565
7753
 
@@ -7579,14 +7767,14 @@ class WebRTCClient extends Emitter {
7579
7767
  return null;
7580
7768
  }
7581
7769
 
7582
- // let's update the local video value
7583
- if (this.video) {
7584
- this.video = {
7585
- deviceId: {
7586
- exact: id,
7587
- },
7588
- };
7589
- }
7770
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7771
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7772
+ this.video = {
7773
+ ...videoObject,
7774
+ deviceId: {
7775
+ exact: id,
7776
+ },
7777
+ };
7590
7778
  }
7591
7779
 
7592
7780
  changeSessionVideoInputDevice(id , session ) {
@@ -9188,9 +9376,7 @@ class WebRTCPhone extends Emitter {
9188
9376
 
9189
9377
  try {
9190
9378
  if (this.currentScreenShare.stream) {
9191
- this.currentScreenShare.stream.getTracks()
9192
- .filter(track => track.kind === 'video')
9193
- .forEach(track => track.stop());
9379
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9194
9380
  }
9195
9381
 
9196
9382
  if (restoreLocalStream) {
@@ -10981,6 +11167,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10981
11167
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10982
11168
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10983
11169
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11170
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10984
11171
 
10985
11172
  const BLACKLIST_EVENTS = [
10986
11173
  CHAT_MESSAGE_SENT,
@@ -11332,6 +11519,7 @@ WebSocketClient.eventLists = [
11332
11519
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11333
11520
  CONFERENCE_ADHOC_DELETED,
11334
11521
  MEETING_USER_PROGRESS,
11522
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11335
11523
  ];
11336
11524
 
11337
11525
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11403,6 +11591,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11403
11591
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11404
11592
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11405
11593
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11594
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11406
11595
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11407
11596
  'default': WebSocketClient
11408
11597
  });
@@ -11507,6 +11696,7 @@ class Participant extends Emitter {
11507
11696
 
11508
11697
 
11509
11698
 
11699
+
11510
11700
 
11511
11701
 
11512
11702
 
@@ -11524,6 +11714,7 @@ class Participant extends Emitter {
11524
11714
 
11525
11715
 
11526
11716
 
11717
+
11527
11718
 
11528
11719
  /**
11529
11720
  * @param room Room The room where the participant is
@@ -11547,6 +11738,7 @@ class Participant extends Emitter {
11547
11738
  this.screensharing = false;
11548
11739
  this.isOnHold = false;
11549
11740
  this.extra = extra;
11741
+ this.banned = false;
11550
11742
 
11551
11743
  this.ON_UPDATED = 'participant/ON_UPDATED';
11552
11744
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11563,6 +11755,7 @@ class Participant extends Emitter {
11563
11755
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11564
11756
  this.ON_HOLD = 'participant/ON_HOLD';
11565
11757
  this.ON_RESUME = 'participant/ON_RESUME';
11758
+ this.ON_BAN = 'participant/ON_BAN';
11566
11759
  }
11567
11760
 
11568
11761
  triggerEvent(name , ...args ) {
@@ -11603,6 +11796,10 @@ class Participant extends Emitter {
11603
11796
  status.extra = this.extra;
11604
11797
  break;
11605
11798
  }
11799
+ case this.ON_BAN: {
11800
+ status.banned = true;
11801
+ break;
11802
+ }
11606
11803
  }
11607
11804
 
11608
11805
  if (broadcast) {
@@ -11705,6 +11902,11 @@ class Participant extends Emitter {
11705
11902
  this.triggerUpdate(this.ON_RESUME, broadcast);
11706
11903
  }
11707
11904
 
11905
+ onBan(broadcast = true) {
11906
+ this.banned = true;
11907
+ this.triggerUpdate(this.ON_BAN, broadcast);
11908
+ }
11909
+
11708
11910
  getStatus() {
11709
11911
  return {
11710
11912
  callId: this.callId,
@@ -11751,6 +11953,10 @@ class Participant extends Emitter {
11751
11953
  }
11752
11954
  }
11753
11955
 
11956
+ if (status.banned) {
11957
+ this.onBan(false);
11958
+ }
11959
+
11754
11960
  // Poor man's object comparison
11755
11961
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11756
11962
  this.extra = { ...this.extra, ...status.extra };
@@ -11778,6 +11984,28 @@ class Participant extends Emitter {
11778
11984
  this.streams = streams;
11779
11985
  this.videoStreams = streams;
11780
11986
  }
11987
+
11988
+ async ban(apiRequestDelay = null) {
11989
+ const { meetingUuid } = this.room;
11990
+ if (!meetingUuid) {
11991
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11992
+ }
11993
+
11994
+ // this notifies all that someone is being banned
11995
+ this.onBan(true);
11996
+
11997
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11998
+ if (apiRequestDelay) {
11999
+ await this.delay(apiRequestDelay);
12000
+ }
12001
+
12002
+ // proceed with the actual kick
12003
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12004
+ }
12005
+
12006
+ async delay(ms ) {
12007
+ return new Promise(resolve => setTimeout(resolve, ms));
12008
+ }
11781
12009
  }
11782
12010
 
11783
12011
  //
@@ -11930,7 +12158,7 @@ class Room$1 extends Emitter {
11930
12158
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11931
12159
 
11932
12160
  if (!room) {
11933
- await Wazo.Phone.connect();
12161
+ await Wazo.Phone.connect({ media: constraints });
11934
12162
 
11935
12163
  const withCamera = constraints && !!constraints.video;
11936
12164
 
@@ -12375,7 +12603,7 @@ class Room$1 extends Emitter {
12375
12603
  const participant = this._getParticipantFromCallId(status.callId);
12376
12604
 
12377
12605
  if (participant) {
12378
- // we're received, so no need to broadcast, hence the input false arg
12606
+ // we're receiving, so no need to broadcast
12379
12607
  participant.updateStatus(status, false);
12380
12608
  }
12381
12609
  break;
@@ -12642,7 +12870,7 @@ class SipRoom extends Room$1 {
12642
12870
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12643
12871
 
12644
12872
  if (!room) {
12645
- await Wazo.Phone.connect();
12873
+ await Wazo.Phone.connect({ media: constraints });
12646
12874
 
12647
12875
  const withCamera = constraints && !!constraints.video;
12648
12876
 
@@ -13824,6 +14052,7 @@ class Softphone {
13824
14052
  wrapUpDuration,
13825
14053
  enableAgent = true,
13826
14054
  tenantId,
14055
+ domainName,
13827
14056
  debug = false,
13828
14057
  } = {}) {
13829
14058
  this.url = url || 'https://softphone.wazo.io';
@@ -13848,8 +14077,12 @@ class Softphone {
13848
14077
  config.port = port;
13849
14078
  }
13850
14079
  if (tenantId) {
14080
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13851
14081
  config.tenantId = tenantId;
13852
14082
  }
14083
+ if (domainName) {
14084
+ config.domainName = domainName;
14085
+ }
13853
14086
  if (wrapUpDuration) {
13854
14087
  config.wrapUpDuration = wrapUpDuration;
13855
14088
  }
@@ -14170,6 +14403,7 @@ const Wazo = {
14170
14403
  CanceledCallError,
14171
14404
  SFUNotAvailableError,
14172
14405
  NoTenantIdError,
14406
+ NoDomainNameError,
14173
14407
  };
14174
14408
 
14175
14409
  if (window) {
@@ -14184,6 +14418,7 @@ if (global) {
14184
14418
  class InvalidSubscription extends Error {}
14185
14419
  class InvalidAuthorization extends Error {}
14186
14420
  class NoTenantIdError extends Error {}
14421
+ class NoDomainNameError extends Error {}
14187
14422
 
14188
14423
  const logger = IssueReporter$1.loggerFor('simple-auth');
14189
14424
 
@@ -14247,9 +14482,24 @@ class Auth {
14247
14482
  setFetchOptions(options);
14248
14483
  }
14249
14484
 
14250
- async logIn(username , password , backend , tenantId ) {
14251
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14252
- throw new NoTenantIdError('No tenant id');
14485
+ async logIn(username , password , backend , extra ) {
14486
+ let tenantId = null;
14487
+ let domainName = null;
14488
+ if (typeof extra === 'string') {
14489
+ tenantId = extra;
14490
+ }
14491
+ if (extra && typeof extra === 'object') {
14492
+ domainName = extra.domainName;
14493
+ }
14494
+
14495
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14496
+ if (!tenantId) {
14497
+ throw new NoTenantIdError('No tenant id');
14498
+ }
14499
+
14500
+ if (!domainName) {
14501
+ throw new NoDomainNameError('No domain name');
14502
+ }
14253
14503
  }
14254
14504
 
14255
14505
  this.authenticated = false;
@@ -14259,6 +14509,7 @@ class Auth {
14259
14509
  password,
14260
14510
  backend,
14261
14511
  tenantId,
14512
+ domainName,
14262
14513
  expiration: this.expiration,
14263
14514
  mobile: this.mobile,
14264
14515
  });
@@ -14267,7 +14518,13 @@ class Auth {
14267
14518
  getApiClient().setRefreshBackend(backend);
14268
14519
  }
14269
14520
 
14270
- getApiClient().setRefreshTenantId(tenantId);
14521
+ if (tenantId) {
14522
+ getApiClient().setRefreshTenantId(tenantId);
14523
+ }
14524
+
14525
+ if (domainName) {
14526
+ getApiClient().setRefreshDomainName(domainName);
14527
+ }
14271
14528
 
14272
14529
  return this._onAuthenticated(rawSession);
14273
14530
  }
@@ -14366,11 +14623,18 @@ class Auth {
14366
14623
  }
14367
14624
 
14368
14625
  setRefreshTenantId(refreshTenantId ) {
14626
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14369
14627
  setRefreshTenantId(refreshTenantId);
14370
14628
 
14371
14629
  getApiClient().setRefreshTenantId(refreshTenantId);
14372
14630
  }
14373
14631
 
14632
+ setRefreshDomainName(domainName ) {
14633
+ setRefreshDomainName(domainName);
14634
+
14635
+ getApiClient().setRefreshDomainName(domainName);
14636
+ }
14637
+
14374
14638
  forceRefreshToken() {
14375
14639
  getApiClient().forceRefreshToken();
14376
14640
  }
@@ -14482,5 +14746,6 @@ var Auth$1 = global.wazoAuthInstance;
14482
14746
 
14483
14747
  exports.InvalidAuthorization = InvalidAuthorization;
14484
14748
  exports.InvalidSubscription = InvalidSubscription;
14749
+ exports.NoDomainNameError = NoDomainNameError;
14485
14750
  exports.NoTenantIdError = NoTenantIdError;
14486
14751
  exports.default = Auth$1;