@wazo/sdk 0.38.7 → 0.38.8

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 (106) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +142 -2
  3. package/esm/__tests__/web-rtc-client.test.js +227 -27
  4. package/esm/api/calld.js +8 -0
  5. package/esm/api/confd.js +134 -2
  6. package/esm/api-client.js +142 -2
  7. package/esm/checker/Checker.js +183 -24
  8. package/esm/checker/checks/aor.js +142 -2
  9. package/esm/checker/checks/api.js +142 -2
  10. package/esm/checker/checks/index.js +183 -24
  11. package/esm/checker/checks/wazo-websocket.js +2 -0
  12. package/esm/checker/checks/webrtc-transport.js +181 -24
  13. package/esm/checker/checks/webrtc.js +181 -24
  14. package/esm/domain/AdHocAPIConference.js +142 -2
  15. package/esm/domain/Features.js +142 -2
  16. package/esm/domain/Meeting.js +18 -0
  17. package/esm/domain/MeetingAuthorization.js +70 -0
  18. package/esm/domain/Phone/CTIPhone.js +142 -2
  19. package/esm/domain/__tests__/Meeting.test.js +87 -1
  20. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  21. package/esm/index.js +226 -27
  22. package/esm/service/CallApi.js +142 -2
  23. package/esm/service/getApiClient.js +142 -2
  24. package/esm/simple/Auth.js +226 -27
  25. package/esm/simple/Configuration.js +226 -27
  26. package/esm/simple/Directory.js +142 -2
  27. package/esm/simple/Phone.js +226 -27
  28. package/esm/simple/Websocket.js +3 -0
  29. package/esm/simple/index.js +226 -27
  30. package/esm/simple/room/LocalParticipant.js +226 -27
  31. package/esm/simple/room/Participant.js +226 -27
  32. package/esm/simple/room/RemoteParticipant.js +226 -27
  33. package/esm/simple/room/Room.js +226 -27
  34. package/esm/simple/room/SipRoom.js +226 -27
  35. package/esm/simple/room/Stream.js +226 -27
  36. package/esm/simple/room/__tests__/Participant.test.js +14747 -0
  37. package/esm/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  38. package/esm/simple/utils.js +226 -27
  39. package/esm/utils/__tests__/object.test.js +57 -0
  40. package/esm/utils/__tests__/string.test.js +30 -0
  41. package/esm/utils/object.js +24 -0
  42. package/esm/utils/string.js +10 -0
  43. package/esm/web-rtc-client.js +181 -24
  44. package/esm/websocket-client.js +3 -1
  45. package/lib/__tests__/api-client.test.js +142 -2
  46. package/lib/__tests__/web-rtc-client.test.js +227 -27
  47. package/lib/api/calld.js +8 -0
  48. package/lib/api/confd.js +134 -2
  49. package/lib/api-client.js +142 -2
  50. package/lib/checker/Checker.js +183 -24
  51. package/lib/checker/checks/aor.js +142 -2
  52. package/lib/checker/checks/api.js +142 -2
  53. package/lib/checker/checks/index.js +183 -24
  54. package/lib/checker/checks/wazo-websocket.js +2 -0
  55. package/lib/checker/checks/webrtc-transport.js +181 -24
  56. package/lib/checker/checks/webrtc.js +181 -24
  57. package/lib/domain/AdHocAPIConference.js +142 -2
  58. package/lib/domain/Features.js +142 -2
  59. package/lib/domain/Meeting.js +18 -0
  60. package/lib/domain/MeetingAuthorization.js +79 -0
  61. package/lib/domain/Phone/CTIPhone.js +142 -2
  62. package/lib/domain/__tests__/Meeting.test.js +87 -1
  63. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  64. package/lib/index.js +226 -27
  65. package/lib/service/CallApi.js +142 -2
  66. package/lib/service/getApiClient.js +142 -2
  67. package/lib/simple/Auth.js +226 -27
  68. package/lib/simple/Configuration.js +226 -27
  69. package/lib/simple/Directory.js +142 -2
  70. package/lib/simple/Phone.js +226 -27
  71. package/lib/simple/Websocket.js +3 -0
  72. package/lib/simple/index.js +226 -27
  73. package/lib/simple/room/LocalParticipant.js +226 -27
  74. package/lib/simple/room/Participant.js +226 -27
  75. package/lib/simple/room/RemoteParticipant.js +226 -27
  76. package/lib/simple/room/Room.js +226 -27
  77. package/lib/simple/room/SipRoom.js +226 -27
  78. package/lib/simple/room/Stream.js +226 -27
  79. package/lib/simple/room/__tests__/Participant.test.js +14757 -0
  80. package/lib/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  81. package/lib/simple/utils.js +226 -27
  82. package/lib/utils/__tests__/object.test.js +59 -0
  83. package/lib/utils/__tests__/string.test.js +32 -0
  84. package/lib/utils/object.js +28 -0
  85. package/lib/utils/string.js +14 -0
  86. package/lib/web-rtc-client.js +181 -24
  87. package/lib/websocket-client.js +3 -0
  88. package/package.json +2 -2
  89. package/src/__tests__/web-rtc-client.test.js +46 -3
  90. package/src/api/calld.js +8 -0
  91. package/src/api/confd.js +43 -2
  92. package/src/domain/Meeting.js +20 -0
  93. package/src/domain/MeetingAuthorization.js +67 -0
  94. package/src/domain/__tests__/Meeting.test.js +70 -1
  95. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  96. package/src/simple/room/Participant.js +40 -0
  97. package/src/simple/room/Room.js +2 -2
  98. package/src/simple/room/SipRoom.js +1 -1
  99. package/src/simple/room/__tests__/Participant.test.js +81 -0
  100. package/src/types/WebSocketMessage.js +7 -1
  101. package/src/utils/__tests__/object.test.js +35 -0
  102. package/src/utils/__tests__/string.test.js +23 -0
  103. package/src/utils/object.js +15 -0
  104. package/src/utils/string.js +8 -0
  105. package/src/web-rtc-client.js +39 -22
  106. package/src/websocket-client.js +2 -0
@@ -2633,6 +2633,70 @@ class ExternalApp {
2633
2633
 
2634
2634
  //
2635
2635
 
2636
+ class MeetingAuthorization {
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+
2643
+ constructor({
2644
+ meetingUuid,
2645
+ uuid,
2646
+ userUuid,
2647
+ userName,
2648
+ } = {}) {
2649
+ this.meetingUuid = meetingUuid;
2650
+ this.uuid = uuid;
2651
+ this.userUuid = userUuid;
2652
+ this.userName = userName;
2653
+ }
2654
+
2655
+ setStatus(status ) {
2656
+ this.status = status;
2657
+ }
2658
+
2659
+ getStatus() {
2660
+ return this.status;
2661
+ }
2662
+
2663
+ static parse(plain ) {
2664
+ const {
2665
+ meeting_uuid: meetingUuid,
2666
+ uuid,
2667
+ guest_uuid: userUuid,
2668
+ guest_name: userName,
2669
+ } = plain;
2670
+
2671
+ return new MeetingAuthorization({
2672
+ meetingUuid,
2673
+ uuid,
2674
+ userUuid,
2675
+ userName,
2676
+ });
2677
+ }
2678
+
2679
+ static parseMany(items ) {
2680
+ if (!items) {
2681
+ return [];
2682
+ }
2683
+ return items.map(MeetingAuthorization.parse);
2684
+ }
2685
+ }
2686
+
2687
+ //
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2636
2700
 
2637
2701
 
2638
2702
 
@@ -2643,6 +2707,7 @@ class ExternalApp {
2643
2707
 
2644
2708
 
2645
2709
 
2710
+
2646
2711
 
2647
2712
 
2648
2713
  class Meeting {
@@ -2657,6 +2722,8 @@ class Meeting {
2657
2722
 
2658
2723
 
2659
2724
 
2725
+
2726
+
2660
2727
 
2661
2728
  static parse(plain ) {
2662
2729
  return new Meeting({
@@ -2669,6 +2736,7 @@ class Meeting {
2669
2736
  extension: plain.exten,
2670
2737
  persistent: plain.persistent,
2671
2738
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2739
+ requireAuthorization: plain.require_authorization,
2672
2740
  });
2673
2741
  }
2674
2742
 
@@ -2693,6 +2761,7 @@ class Meeting {
2693
2761
  extension,
2694
2762
  persistent,
2695
2763
  creationTime,
2764
+ requireAuthorization,
2696
2765
  } = {}) {
2697
2766
  this.guestSipAuthorization = guestSipAuthorization;
2698
2767
  this.uri = uri;
@@ -2703,6 +2772,7 @@ class Meeting {
2703
2772
  this.extension = extension;
2704
2773
  this.persistent = persistent;
2705
2774
  this.creationTime = creationTime;
2775
+ this.requireAuthorization = requireAuthorization;
2706
2776
 
2707
2777
  // Useful to compare instead of instanceof with minified code
2708
2778
  this.type = 'Meeting';
@@ -2713,8 +2783,32 @@ class Meeting {
2713
2783
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2714
2784
  return { username, secret };
2715
2785
  }
2786
+
2716
2787
  }
2717
2788
 
2789
+ //
2790
+
2791
+ const camelToUnderscore = (key ) => {
2792
+ if (typeof key !== 'string') {
2793
+ throw new Error('Input is not a string');
2794
+ }
2795
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2796
+ };
2797
+
2798
+ //
2799
+
2800
+ const convertKeysFromCamelToUnderscore = (args ) => {
2801
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2802
+ throw new Error('Input is not an object');
2803
+ }
2804
+
2805
+ return Object.keys(args).reduce((acc, key) => {
2806
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2807
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2808
+ return acc;
2809
+ }, {});
2810
+ };
2811
+
2718
2812
  /* */
2719
2813
 
2720
2814
  var confdMethods = (client , baseUrl ) => ({
@@ -2783,8 +2877,18 @@ var confdMethods = (client , baseUrl ) => ({
2783
2877
  getMyMeetings: () =>
2784
2878
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2785
2879
 
2786
- createMyMeeting: (name , persistent ) =>
2787
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2880
+ createMyMeeting: (args ) =>
2881
+ client
2882
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2883
+ .then(Meeting.parse),
2884
+
2885
+ updateMyMeeting: (meetingUuid , data ) =>
2886
+ client.put(
2887
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2888
+ convertKeysFromCamelToUnderscore(data),
2889
+ null,
2890
+ ApiRequester.successResponseParser,
2891
+ ),
2788
2892
 
2789
2893
  deleteMyMeeting: (meetingUuid ) =>
2790
2894
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2792,8 +2896,36 @@ var confdMethods = (client , baseUrl ) => ({
2792
2896
  getMeeting: (meetingUuid ) =>
2793
2897
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2794
2898
 
2899
+ meetingAuthorizations: (meetingUuid ) =>
2900
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2901
+
2902
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2903
+ client.put(
2904
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2905
+ {},
2906
+ null,
2907
+ ApiRequester.successResponseParser,
2908
+ ),
2909
+
2910
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2911
+ client.put(
2912
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2913
+ {},
2914
+ null,
2915
+ ApiRequester.successResponseParser,
2916
+ ),
2917
+
2795
2918
  guestGetMeeting: (meetingUuid ) =>
2796
2919
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2920
+
2921
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2922
+ client
2923
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2924
+ .then(MeetingAuthorization.parse),
2925
+
2926
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2927
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2928
+
2797
2929
  });
2798
2930
 
2799
2931
  //
@@ -4215,6 +4347,14 @@ var calldMethods = (client , baseUrl ) => ({
4215
4347
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4216
4348
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4217
4349
 
4350
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4351
+ client.delete(
4352
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4353
+ null,
4354
+ null,
4355
+ ApiRequester.successResponseParser,
4356
+ ),
4357
+
4218
4358
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4219
4359
 
4220
4360
  mute: (callId ) =>
@@ -2657,6 +2657,70 @@ class ExternalApp {
2657
2657
 
2658
2658
  //
2659
2659
 
2660
+ class MeetingAuthorization {
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+ constructor({
2668
+ meetingUuid,
2669
+ uuid,
2670
+ userUuid,
2671
+ userName,
2672
+ } = {}) {
2673
+ this.meetingUuid = meetingUuid;
2674
+ this.uuid = uuid;
2675
+ this.userUuid = userUuid;
2676
+ this.userName = userName;
2677
+ }
2678
+
2679
+ setStatus(status ) {
2680
+ this.status = status;
2681
+ }
2682
+
2683
+ getStatus() {
2684
+ return this.status;
2685
+ }
2686
+
2687
+ static parse(plain ) {
2688
+ const {
2689
+ meeting_uuid: meetingUuid,
2690
+ uuid,
2691
+ guest_uuid: userUuid,
2692
+ guest_name: userName,
2693
+ } = plain;
2694
+
2695
+ return new MeetingAuthorization({
2696
+ meetingUuid,
2697
+ uuid,
2698
+ userUuid,
2699
+ userName,
2700
+ });
2701
+ }
2702
+
2703
+ static parseMany(items ) {
2704
+ if (!items) {
2705
+ return [];
2706
+ }
2707
+ return items.map(MeetingAuthorization.parse);
2708
+ }
2709
+ }
2710
+
2711
+ //
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2660
2724
 
2661
2725
 
2662
2726
 
@@ -2667,6 +2731,7 @@ class ExternalApp {
2667
2731
 
2668
2732
 
2669
2733
 
2734
+
2670
2735
 
2671
2736
 
2672
2737
  class Meeting {
@@ -2681,6 +2746,8 @@ class Meeting {
2681
2746
 
2682
2747
 
2683
2748
 
2749
+
2750
+
2684
2751
 
2685
2752
  static parse(plain ) {
2686
2753
  return new Meeting({
@@ -2693,6 +2760,7 @@ class Meeting {
2693
2760
  extension: plain.exten,
2694
2761
  persistent: plain.persistent,
2695
2762
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2763
+ requireAuthorization: plain.require_authorization,
2696
2764
  });
2697
2765
  }
2698
2766
 
@@ -2717,6 +2785,7 @@ class Meeting {
2717
2785
  extension,
2718
2786
  persistent,
2719
2787
  creationTime,
2788
+ requireAuthorization,
2720
2789
  } = {}) {
2721
2790
  this.guestSipAuthorization = guestSipAuthorization;
2722
2791
  this.uri = uri;
@@ -2727,6 +2796,7 @@ class Meeting {
2727
2796
  this.extension = extension;
2728
2797
  this.persistent = persistent;
2729
2798
  this.creationTime = creationTime;
2799
+ this.requireAuthorization = requireAuthorization;
2730
2800
 
2731
2801
  // Useful to compare instead of instanceof with minified code
2732
2802
  this.type = 'Meeting';
@@ -2737,8 +2807,32 @@ class Meeting {
2737
2807
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2738
2808
  return { username, secret };
2739
2809
  }
2810
+
2740
2811
  }
2741
2812
 
2813
+ //
2814
+
2815
+ const camelToUnderscore = (key ) => {
2816
+ if (typeof key !== 'string') {
2817
+ throw new Error('Input is not a string');
2818
+ }
2819
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2820
+ };
2821
+
2822
+ //
2823
+
2824
+ const convertKeysFromCamelToUnderscore = (args ) => {
2825
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2826
+ throw new Error('Input is not an object');
2827
+ }
2828
+
2829
+ return Object.keys(args).reduce((acc, key) => {
2830
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2831
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2832
+ return acc;
2833
+ }, {});
2834
+ };
2835
+
2742
2836
  /* */
2743
2837
 
2744
2838
  var confdMethods = (client , baseUrl ) => ({
@@ -2807,8 +2901,18 @@ var confdMethods = (client , baseUrl ) => ({
2807
2901
  getMyMeetings: () =>
2808
2902
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2809
2903
 
2810
- createMyMeeting: (name , persistent ) =>
2811
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2904
+ createMyMeeting: (args ) =>
2905
+ client
2906
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2907
+ .then(Meeting.parse),
2908
+
2909
+ updateMyMeeting: (meetingUuid , data ) =>
2910
+ client.put(
2911
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2912
+ convertKeysFromCamelToUnderscore(data),
2913
+ null,
2914
+ ApiRequester.successResponseParser,
2915
+ ),
2812
2916
 
2813
2917
  deleteMyMeeting: (meetingUuid ) =>
2814
2918
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2816,8 +2920,36 @@ var confdMethods = (client , baseUrl ) => ({
2816
2920
  getMeeting: (meetingUuid ) =>
2817
2921
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2818
2922
 
2923
+ meetingAuthorizations: (meetingUuid ) =>
2924
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2925
+
2926
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2927
+ client.put(
2928
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2929
+ {},
2930
+ null,
2931
+ ApiRequester.successResponseParser,
2932
+ ),
2933
+
2934
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2935
+ client.put(
2936
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2937
+ {},
2938
+ null,
2939
+ ApiRequester.successResponseParser,
2940
+ ),
2941
+
2819
2942
  guestGetMeeting: (meetingUuid ) =>
2820
2943
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2944
+
2945
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2946
+ client
2947
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2948
+ .then(MeetingAuthorization.parse),
2949
+
2950
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2951
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2952
+
2821
2953
  });
2822
2954
 
2823
2955
  //
@@ -5068,6 +5200,14 @@ var calldMethods = (client , baseUrl ) => ({
5068
5200
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5069
5201
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5070
5202
 
5203
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5204
+ client.delete(
5205
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5206
+ null,
5207
+ null,
5208
+ ApiRequester.successResponseParser,
5209
+ ),
5210
+
5071
5211
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5072
5212
 
5073
5213
  mute: (callId ) =>
@@ -7525,7 +7665,7 @@ class WebRTCClient extends Emitter {
7525
7665
  });
7526
7666
  }
7527
7667
 
7528
- changeAudioInputDevice(id , session , force ) {
7668
+ async changeAudioInputDevice(id , session , force ) {
7529
7669
  const currentId = this.getAudioDeviceId();
7530
7670
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7531
7671
 
@@ -7533,33 +7673,50 @@ class WebRTCClient extends Emitter {
7533
7673
  return null;
7534
7674
  }
7535
7675
 
7676
+ // in order to handle an audio track change for default devices
7677
+ // we need the actual id of the device (not 'default')
7678
+ let deviceId = id;
7679
+ if (id === 'default' && navigator.mediaDevices) {
7680
+ const devices = await navigator.mediaDevices.enumerateDevices();
7681
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7682
+ if (defaultDevice) {
7683
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7684
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7685
+ if (targetDevice) {
7686
+ deviceId = targetDevice.deviceId;
7687
+ if (!force && deviceId === currentId) {
7688
+ return null;
7689
+ }
7690
+ }
7691
+ }
7692
+ }
7693
+
7536
7694
  // let's update the local audio value
7537
7695
  if (this.audio) {
7538
7696
  this.audio = {
7539
7697
  deviceId: {
7540
- exact: id,
7698
+ exact: deviceId,
7541
7699
  },
7542
7700
  };
7543
7701
  }
7544
7702
 
7545
- if (session) {
7703
+ if (session && navigator.mediaDevices) {
7546
7704
  const sdh = session.sessionDescriptionHandler;
7547
7705
  const pc = sdh.peerConnection;
7548
7706
 
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);
7707
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7708
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7709
+ const audioTrack = stream.getAudioTracks()[0];
7710
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7553
7711
 
7554
- if (sender) {
7555
- if (sender.track) {
7556
- audioTrack.enabled = sender.track.enabled;
7557
- }
7558
- sender.replaceTrack(audioTrack);
7712
+ if (sender) {
7713
+ if (sender.track) {
7714
+ audioTrack.enabled = sender.track.enabled;
7559
7715
  }
7716
+ sender.replaceTrack(audioTrack);
7717
+ }
7560
7718
 
7561
- return stream;
7562
- });
7719
+ return stream;
7563
7720
  }
7564
7721
  }
7565
7722
 
@@ -7579,14 +7736,14 @@ class WebRTCClient extends Emitter {
7579
7736
  return null;
7580
7737
  }
7581
7738
 
7582
- // let's update the local video value
7583
- if (this.video) {
7584
- this.video = {
7585
- deviceId: {
7586
- exact: id,
7587
- },
7588
- };
7589
- }
7739
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7740
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7741
+ this.video = {
7742
+ ...videoObject,
7743
+ deviceId: {
7744
+ exact: id,
7745
+ },
7746
+ };
7590
7747
  }
7591
7748
 
7592
7749
  changeSessionVideoInputDevice(id , session ) {
@@ -10981,6 +11138,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10981
11138
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10982
11139
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10983
11140
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11141
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10984
11142
 
10985
11143
  const BLACKLIST_EVENTS = [
10986
11144
  CHAT_MESSAGE_SENT,
@@ -11332,6 +11490,7 @@ WebSocketClient.eventLists = [
11332
11490
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11333
11491
  CONFERENCE_ADHOC_DELETED,
11334
11492
  MEETING_USER_PROGRESS,
11493
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11335
11494
  ];
11336
11495
 
11337
11496
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11403,6 +11562,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11403
11562
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11404
11563
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11405
11564
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11565
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11406
11566
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11407
11567
  'default': WebSocketClient
11408
11568
  });
@@ -11507,6 +11667,7 @@ class Participant extends Emitter {
11507
11667
 
11508
11668
 
11509
11669
 
11670
+
11510
11671
 
11511
11672
 
11512
11673
 
@@ -11524,6 +11685,7 @@ class Participant extends Emitter {
11524
11685
 
11525
11686
 
11526
11687
 
11688
+
11527
11689
 
11528
11690
  /**
11529
11691
  * @param room Room The room where the participant is
@@ -11547,6 +11709,7 @@ class Participant extends Emitter {
11547
11709
  this.screensharing = false;
11548
11710
  this.isOnHold = false;
11549
11711
  this.extra = extra;
11712
+ this.banned = false;
11550
11713
 
11551
11714
  this.ON_UPDATED = 'participant/ON_UPDATED';
11552
11715
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11563,6 +11726,7 @@ class Participant extends Emitter {
11563
11726
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11564
11727
  this.ON_HOLD = 'participant/ON_HOLD';
11565
11728
  this.ON_RESUME = 'participant/ON_RESUME';
11729
+ this.ON_BAN = 'participant/ON_BAN';
11566
11730
  }
11567
11731
 
11568
11732
  triggerEvent(name , ...args ) {
@@ -11603,6 +11767,10 @@ class Participant extends Emitter {
11603
11767
  status.extra = this.extra;
11604
11768
  break;
11605
11769
  }
11770
+ case this.ON_BAN: {
11771
+ status.banned = true;
11772
+ break;
11773
+ }
11606
11774
  }
11607
11775
 
11608
11776
  if (broadcast) {
@@ -11705,6 +11873,11 @@ class Participant extends Emitter {
11705
11873
  this.triggerUpdate(this.ON_RESUME, broadcast);
11706
11874
  }
11707
11875
 
11876
+ onBan(broadcast = true) {
11877
+ this.banned = true;
11878
+ this.triggerUpdate(this.ON_BAN, broadcast);
11879
+ }
11880
+
11708
11881
  getStatus() {
11709
11882
  return {
11710
11883
  callId: this.callId,
@@ -11751,6 +11924,10 @@ class Participant extends Emitter {
11751
11924
  }
11752
11925
  }
11753
11926
 
11927
+ if (status.banned) {
11928
+ this.onBan(false);
11929
+ }
11930
+
11754
11931
  // Poor man's object comparison
11755
11932
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11756
11933
  this.extra = { ...this.extra, ...status.extra };
@@ -11778,6 +11955,28 @@ class Participant extends Emitter {
11778
11955
  this.streams = streams;
11779
11956
  this.videoStreams = streams;
11780
11957
  }
11958
+
11959
+ async ban(apiRequestDelay = null) {
11960
+ const { meetingUuid } = this.room;
11961
+ if (!meetingUuid) {
11962
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11963
+ }
11964
+
11965
+ // this notifies all that someone is being banned
11966
+ this.onBan(true);
11967
+
11968
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11969
+ if (apiRequestDelay) {
11970
+ await this.delay(apiRequestDelay);
11971
+ }
11972
+
11973
+ // proceed with the actual kick
11974
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11975
+ }
11976
+
11977
+ async delay(ms ) {
11978
+ return new Promise(resolve => setTimeout(resolve, ms));
11979
+ }
11781
11980
  }
11782
11981
 
11783
11982
  //
@@ -11930,7 +12129,7 @@ class Room$1 extends Emitter {
11930
12129
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11931
12130
 
11932
12131
  if (!room) {
11933
- await Wazo.Phone.connect();
12132
+ await Wazo.Phone.connect({ media: constraints });
11934
12133
 
11935
12134
  const withCamera = constraints && !!constraints.video;
11936
12135
 
@@ -12375,7 +12574,7 @@ class Room$1 extends Emitter {
12375
12574
  const participant = this._getParticipantFromCallId(status.callId);
12376
12575
 
12377
12576
  if (participant) {
12378
- // we're received, so no need to broadcast, hence the input false arg
12577
+ // we're receiving, so no need to broadcast
12379
12578
  participant.updateStatus(status, false);
12380
12579
  }
12381
12580
  break;
@@ -12642,7 +12841,7 @@ class SipRoom extends Room$1 {
12642
12841
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12643
12842
 
12644
12843
  if (!room) {
12645
- await Wazo.Phone.connect();
12844
+ await Wazo.Phone.connect({ media: constraints });
12646
12845
 
12647
12846
  const withCamera = constraints && !!constraints.video;
12648
12847