@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
@@ -2655,6 +2655,70 @@ class ExternalApp {
2655
2655
 
2656
2656
  //
2657
2657
 
2658
+ class MeetingAuthorization {
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+ constructor({
2666
+ meetingUuid,
2667
+ uuid,
2668
+ userUuid,
2669
+ userName,
2670
+ } = {}) {
2671
+ this.meetingUuid = meetingUuid;
2672
+ this.uuid = uuid;
2673
+ this.userUuid = userUuid;
2674
+ this.userName = userName;
2675
+ }
2676
+
2677
+ setStatus(status ) {
2678
+ this.status = status;
2679
+ }
2680
+
2681
+ getStatus() {
2682
+ return this.status;
2683
+ }
2684
+
2685
+ static parse(plain ) {
2686
+ const {
2687
+ meeting_uuid: meetingUuid,
2688
+ uuid,
2689
+ guest_uuid: userUuid,
2690
+ guest_name: userName,
2691
+ } = plain;
2692
+
2693
+ return new MeetingAuthorization({
2694
+ meetingUuid,
2695
+ uuid,
2696
+ userUuid,
2697
+ userName,
2698
+ });
2699
+ }
2700
+
2701
+ static parseMany(items ) {
2702
+ if (!items) {
2703
+ return [];
2704
+ }
2705
+ return items.map(MeetingAuthorization.parse);
2706
+ }
2707
+ }
2708
+
2709
+ //
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2658
2722
 
2659
2723
 
2660
2724
 
@@ -2665,6 +2729,7 @@ class ExternalApp {
2665
2729
 
2666
2730
 
2667
2731
 
2732
+
2668
2733
 
2669
2734
 
2670
2735
  class Meeting {
@@ -2679,6 +2744,8 @@ class Meeting {
2679
2744
 
2680
2745
 
2681
2746
 
2747
+
2748
+
2682
2749
 
2683
2750
  static parse(plain ) {
2684
2751
  return new Meeting({
@@ -2691,6 +2758,7 @@ class Meeting {
2691
2758
  extension: plain.exten,
2692
2759
  persistent: plain.persistent,
2693
2760
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2761
+ requireAuthorization: plain.require_authorization,
2694
2762
  });
2695
2763
  }
2696
2764
 
@@ -2715,6 +2783,7 @@ class Meeting {
2715
2783
  extension,
2716
2784
  persistent,
2717
2785
  creationTime,
2786
+ requireAuthorization,
2718
2787
  } = {}) {
2719
2788
  this.guestSipAuthorization = guestSipAuthorization;
2720
2789
  this.uri = uri;
@@ -2725,6 +2794,7 @@ class Meeting {
2725
2794
  this.extension = extension;
2726
2795
  this.persistent = persistent;
2727
2796
  this.creationTime = creationTime;
2797
+ this.requireAuthorization = requireAuthorization;
2728
2798
 
2729
2799
  // Useful to compare instead of instanceof with minified code
2730
2800
  this.type = 'Meeting';
@@ -2735,8 +2805,32 @@ class Meeting {
2735
2805
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2736
2806
  return { username, secret };
2737
2807
  }
2808
+
2738
2809
  }
2739
2810
 
2811
+ //
2812
+
2813
+ const camelToUnderscore = (key ) => {
2814
+ if (typeof key !== 'string') {
2815
+ throw new Error('Input is not a string');
2816
+ }
2817
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2818
+ };
2819
+
2820
+ //
2821
+
2822
+ const convertKeysFromCamelToUnderscore = (args ) => {
2823
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2824
+ throw new Error('Input is not an object');
2825
+ }
2826
+
2827
+ return Object.keys(args).reduce((acc, key) => {
2828
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2829
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2830
+ return acc;
2831
+ }, {});
2832
+ };
2833
+
2740
2834
  /* */
2741
2835
 
2742
2836
  var confdMethods = (client , baseUrl ) => ({
@@ -2805,8 +2899,18 @@ var confdMethods = (client , baseUrl ) => ({
2805
2899
  getMyMeetings: () =>
2806
2900
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2807
2901
 
2808
- createMyMeeting: (name , persistent ) =>
2809
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2902
+ createMyMeeting: (args ) =>
2903
+ client
2904
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2905
+ .then(Meeting.parse),
2906
+
2907
+ updateMyMeeting: (meetingUuid , data ) =>
2908
+ client.put(
2909
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2910
+ convertKeysFromCamelToUnderscore(data),
2911
+ null,
2912
+ ApiRequester.successResponseParser,
2913
+ ),
2810
2914
 
2811
2915
  deleteMyMeeting: (meetingUuid ) =>
2812
2916
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2814,8 +2918,36 @@ var confdMethods = (client , baseUrl ) => ({
2814
2918
  getMeeting: (meetingUuid ) =>
2815
2919
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2816
2920
 
2921
+ meetingAuthorizations: (meetingUuid ) =>
2922
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2923
+
2924
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2925
+ client.put(
2926
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2927
+ {},
2928
+ null,
2929
+ ApiRequester.successResponseParser,
2930
+ ),
2931
+
2932
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2933
+ client.put(
2934
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2935
+ {},
2936
+ null,
2937
+ ApiRequester.successResponseParser,
2938
+ ),
2939
+
2817
2940
  guestGetMeeting: (meetingUuid ) =>
2818
2941
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2942
+
2943
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2944
+ client
2945
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2946
+ .then(MeetingAuthorization.parse),
2947
+
2948
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2949
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2950
+
2819
2951
  });
2820
2952
 
2821
2953
  //
@@ -5066,6 +5198,14 @@ var calldMethods = (client , baseUrl ) => ({
5066
5198
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5067
5199
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5068
5200
 
5201
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5202
+ client.delete(
5203
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5204
+ null,
5205
+ null,
5206
+ ApiRequester.successResponseParser,
5207
+ ),
5208
+
5069
5209
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5070
5210
 
5071
5211
  mute: (callId ) =>
@@ -7523,7 +7663,7 @@ class WebRTCClient extends Emitter {
7523
7663
  });
7524
7664
  }
7525
7665
 
7526
- changeAudioInputDevice(id , session , force ) {
7666
+ async changeAudioInputDevice(id , session , force ) {
7527
7667
  const currentId = this.getAudioDeviceId();
7528
7668
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7529
7669
 
@@ -7531,33 +7671,50 @@ class WebRTCClient extends Emitter {
7531
7671
  return null;
7532
7672
  }
7533
7673
 
7674
+ // in order to handle an audio track change for default devices
7675
+ // we need the actual id of the device (not 'default')
7676
+ let deviceId = id;
7677
+ if (id === 'default' && navigator.mediaDevices) {
7678
+ const devices = await navigator.mediaDevices.enumerateDevices();
7679
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7680
+ if (defaultDevice) {
7681
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7682
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7683
+ if (targetDevice) {
7684
+ deviceId = targetDevice.deviceId;
7685
+ if (!force && deviceId === currentId) {
7686
+ return null;
7687
+ }
7688
+ }
7689
+ }
7690
+ }
7691
+
7534
7692
  // let's update the local audio value
7535
7693
  if (this.audio) {
7536
7694
  this.audio = {
7537
7695
  deviceId: {
7538
- exact: id,
7696
+ exact: deviceId,
7539
7697
  },
7540
7698
  };
7541
7699
  }
7542
7700
 
7543
- if (session) {
7701
+ if (session && navigator.mediaDevices) {
7544
7702
  const sdh = session.sessionDescriptionHandler;
7545
7703
  const pc = sdh.peerConnection;
7546
7704
 
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);
7705
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7706
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7707
+ const audioTrack = stream.getAudioTracks()[0];
7708
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7551
7709
 
7552
- if (sender) {
7553
- if (sender.track) {
7554
- audioTrack.enabled = sender.track.enabled;
7555
- }
7556
- sender.replaceTrack(audioTrack);
7710
+ if (sender) {
7711
+ if (sender.track) {
7712
+ audioTrack.enabled = sender.track.enabled;
7557
7713
  }
7714
+ sender.replaceTrack(audioTrack);
7715
+ }
7558
7716
 
7559
- return stream;
7560
- });
7717
+ return stream;
7561
7718
  }
7562
7719
  }
7563
7720
 
@@ -7577,14 +7734,14 @@ class WebRTCClient extends Emitter {
7577
7734
  return null;
7578
7735
  }
7579
7736
 
7580
- // let's update the local video value
7581
- if (this.video) {
7582
- this.video = {
7583
- deviceId: {
7584
- exact: id,
7585
- },
7586
- };
7587
- }
7737
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7738
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7739
+ this.video = {
7740
+ ...videoObject,
7741
+ deviceId: {
7742
+ exact: id,
7743
+ },
7744
+ };
7588
7745
  }
7589
7746
 
7590
7747
  changeSessionVideoInputDevice(id , session ) {
@@ -10979,6 +11136,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10979
11136
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10980
11137
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10981
11138
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11139
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10982
11140
 
10983
11141
  const BLACKLIST_EVENTS = [
10984
11142
  CHAT_MESSAGE_SENT,
@@ -11330,6 +11488,7 @@ WebSocketClient.eventLists = [
11330
11488
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11331
11489
  CONFERENCE_ADHOC_DELETED,
11332
11490
  MEETING_USER_PROGRESS,
11491
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11333
11492
  ];
11334
11493
 
11335
11494
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11401,6 +11560,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11401
11560
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11402
11561
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11403
11562
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11563
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11404
11564
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11405
11565
  'default': WebSocketClient
11406
11566
  });
@@ -11505,6 +11665,7 @@ class Participant extends Emitter {
11505
11665
 
11506
11666
 
11507
11667
 
11668
+
11508
11669
 
11509
11670
 
11510
11671
 
@@ -11522,6 +11683,7 @@ class Participant extends Emitter {
11522
11683
 
11523
11684
 
11524
11685
 
11686
+
11525
11687
 
11526
11688
  /**
11527
11689
  * @param room Room The room where the participant is
@@ -11545,6 +11707,7 @@ class Participant extends Emitter {
11545
11707
  this.screensharing = false;
11546
11708
  this.isOnHold = false;
11547
11709
  this.extra = extra;
11710
+ this.banned = false;
11548
11711
 
11549
11712
  this.ON_UPDATED = 'participant/ON_UPDATED';
11550
11713
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11561,6 +11724,7 @@ class Participant extends Emitter {
11561
11724
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11562
11725
  this.ON_HOLD = 'participant/ON_HOLD';
11563
11726
  this.ON_RESUME = 'participant/ON_RESUME';
11727
+ this.ON_BAN = 'participant/ON_BAN';
11564
11728
  }
11565
11729
 
11566
11730
  triggerEvent(name , ...args ) {
@@ -11601,6 +11765,10 @@ class Participant extends Emitter {
11601
11765
  status.extra = this.extra;
11602
11766
  break;
11603
11767
  }
11768
+ case this.ON_BAN: {
11769
+ status.banned = true;
11770
+ break;
11771
+ }
11604
11772
  }
11605
11773
 
11606
11774
  if (broadcast) {
@@ -11703,6 +11871,11 @@ class Participant extends Emitter {
11703
11871
  this.triggerUpdate(this.ON_RESUME, broadcast);
11704
11872
  }
11705
11873
 
11874
+ onBan(broadcast = true) {
11875
+ this.banned = true;
11876
+ this.triggerUpdate(this.ON_BAN, broadcast);
11877
+ }
11878
+
11706
11879
  getStatus() {
11707
11880
  return {
11708
11881
  callId: this.callId,
@@ -11749,6 +11922,10 @@ class Participant extends Emitter {
11749
11922
  }
11750
11923
  }
11751
11924
 
11925
+ if (status.banned) {
11926
+ this.onBan(false);
11927
+ }
11928
+
11752
11929
  // Poor man's object comparison
11753
11930
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11754
11931
  this.extra = { ...this.extra, ...status.extra };
@@ -11776,6 +11953,28 @@ class Participant extends Emitter {
11776
11953
  this.streams = streams;
11777
11954
  this.videoStreams = streams;
11778
11955
  }
11956
+
11957
+ async ban(apiRequestDelay = null) {
11958
+ const { meetingUuid } = this.room;
11959
+ if (!meetingUuid) {
11960
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11961
+ }
11962
+
11963
+ // this notifies all that someone is being banned
11964
+ this.onBan(true);
11965
+
11966
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11967
+ if (apiRequestDelay) {
11968
+ await this.delay(apiRequestDelay);
11969
+ }
11970
+
11971
+ // proceed with the actual kick
11972
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11973
+ }
11974
+
11975
+ async delay(ms ) {
11976
+ return new Promise(resolve => setTimeout(resolve, ms));
11977
+ }
11779
11978
  }
11780
11979
 
11781
11980
  //
@@ -11928,7 +12127,7 @@ class Room$1 extends Emitter {
11928
12127
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11929
12128
 
11930
12129
  if (!room) {
11931
- await Wazo.Phone.connect();
12130
+ await Wazo.Phone.connect({ media: constraints });
11932
12131
 
11933
12132
  const withCamera = constraints && !!constraints.video;
11934
12133
 
@@ -12373,7 +12572,7 @@ class Room$1 extends Emitter {
12373
12572
  const participant = this._getParticipantFromCallId(status.callId);
12374
12573
 
12375
12574
  if (participant) {
12376
- // we're received, so no need to broadcast, hence the input false arg
12575
+ // we're receiving, so no need to broadcast
12377
12576
  participant.updateStatus(status, false);
12378
12577
  }
12379
12578
  break;
@@ -12640,7 +12839,7 @@ class SipRoom extends Room$1 {
12640
12839
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12641
12840
 
12642
12841
  if (!room) {
12643
- await Wazo.Phone.connect();
12842
+ await Wazo.Phone.connect({ media: constraints });
12644
12843
 
12645
12844
  const withCamera = constraints && !!constraints.video;
12646
12845
 
@@ -2631,6 +2631,70 @@ class ExternalApp {
2631
2631
 
2632
2632
  //
2633
2633
 
2634
+ class MeetingAuthorization {
2635
+
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+ constructor({
2642
+ meetingUuid,
2643
+ uuid,
2644
+ userUuid,
2645
+ userName,
2646
+ } = {}) {
2647
+ this.meetingUuid = meetingUuid;
2648
+ this.uuid = uuid;
2649
+ this.userUuid = userUuid;
2650
+ this.userName = userName;
2651
+ }
2652
+
2653
+ setStatus(status ) {
2654
+ this.status = status;
2655
+ }
2656
+
2657
+ getStatus() {
2658
+ return this.status;
2659
+ }
2660
+
2661
+ static parse(plain ) {
2662
+ const {
2663
+ meeting_uuid: meetingUuid,
2664
+ uuid,
2665
+ guest_uuid: userUuid,
2666
+ guest_name: userName,
2667
+ } = plain;
2668
+
2669
+ return new MeetingAuthorization({
2670
+ meetingUuid,
2671
+ uuid,
2672
+ userUuid,
2673
+ userName,
2674
+ });
2675
+ }
2676
+
2677
+ static parseMany(items ) {
2678
+ if (!items) {
2679
+ return [];
2680
+ }
2681
+ return items.map(MeetingAuthorization.parse);
2682
+ }
2683
+ }
2684
+
2685
+ //
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2634
2698
 
2635
2699
 
2636
2700
 
@@ -2641,6 +2705,7 @@ class ExternalApp {
2641
2705
 
2642
2706
 
2643
2707
 
2708
+
2644
2709
 
2645
2710
 
2646
2711
  class Meeting {
@@ -2655,6 +2720,8 @@ class Meeting {
2655
2720
 
2656
2721
 
2657
2722
 
2723
+
2724
+
2658
2725
 
2659
2726
  static parse(plain ) {
2660
2727
  return new Meeting({
@@ -2667,6 +2734,7 @@ class Meeting {
2667
2734
  extension: plain.exten,
2668
2735
  persistent: plain.persistent,
2669
2736
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2737
+ requireAuthorization: plain.require_authorization,
2670
2738
  });
2671
2739
  }
2672
2740
 
@@ -2691,6 +2759,7 @@ class Meeting {
2691
2759
  extension,
2692
2760
  persistent,
2693
2761
  creationTime,
2762
+ requireAuthorization,
2694
2763
  } = {}) {
2695
2764
  this.guestSipAuthorization = guestSipAuthorization;
2696
2765
  this.uri = uri;
@@ -2701,6 +2770,7 @@ class Meeting {
2701
2770
  this.extension = extension;
2702
2771
  this.persistent = persistent;
2703
2772
  this.creationTime = creationTime;
2773
+ this.requireAuthorization = requireAuthorization;
2704
2774
 
2705
2775
  // Useful to compare instead of instanceof with minified code
2706
2776
  this.type = 'Meeting';
@@ -2711,8 +2781,32 @@ class Meeting {
2711
2781
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2712
2782
  return { username, secret };
2713
2783
  }
2784
+
2714
2785
  }
2715
2786
 
2787
+ //
2788
+
2789
+ const camelToUnderscore = (key ) => {
2790
+ if (typeof key !== 'string') {
2791
+ throw new Error('Input is not a string');
2792
+ }
2793
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2794
+ };
2795
+
2796
+ //
2797
+
2798
+ const convertKeysFromCamelToUnderscore = (args ) => {
2799
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2800
+ throw new Error('Input is not an object');
2801
+ }
2802
+
2803
+ return Object.keys(args).reduce((acc, key) => {
2804
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2805
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2806
+ return acc;
2807
+ }, {});
2808
+ };
2809
+
2716
2810
  /* */
2717
2811
 
2718
2812
  var confdMethods = (client , baseUrl ) => ({
@@ -2781,8 +2875,18 @@ var confdMethods = (client , baseUrl ) => ({
2781
2875
  getMyMeetings: () =>
2782
2876
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2783
2877
 
2784
- createMyMeeting: (name , persistent ) =>
2785
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2878
+ createMyMeeting: (args ) =>
2879
+ client
2880
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2881
+ .then(Meeting.parse),
2882
+
2883
+ updateMyMeeting: (meetingUuid , data ) =>
2884
+ client.put(
2885
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2886
+ convertKeysFromCamelToUnderscore(data),
2887
+ null,
2888
+ ApiRequester.successResponseParser,
2889
+ ),
2786
2890
 
2787
2891
  deleteMyMeeting: (meetingUuid ) =>
2788
2892
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2790,8 +2894,36 @@ var confdMethods = (client , baseUrl ) => ({
2790
2894
  getMeeting: (meetingUuid ) =>
2791
2895
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2792
2896
 
2897
+ meetingAuthorizations: (meetingUuid ) =>
2898
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2899
+
2900
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2901
+ client.put(
2902
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2903
+ {},
2904
+ null,
2905
+ ApiRequester.successResponseParser,
2906
+ ),
2907
+
2908
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2909
+ client.put(
2910
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2911
+ {},
2912
+ null,
2913
+ ApiRequester.successResponseParser,
2914
+ ),
2915
+
2793
2916
  guestGetMeeting: (meetingUuid ) =>
2794
2917
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2918
+
2919
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2920
+ client
2921
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2922
+ .then(MeetingAuthorization.parse),
2923
+
2924
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2925
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2926
+
2795
2927
  });
2796
2928
 
2797
2929
  //
@@ -4213,6 +4345,14 @@ var calldMethods = (client , baseUrl ) => ({
4213
4345
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4214
4346
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4215
4347
 
4348
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4349
+ client.delete(
4350
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4351
+ null,
4352
+ null,
4353
+ ApiRequester.successResponseParser,
4354
+ ),
4355
+
4216
4356
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4217
4357
 
4218
4358
  mute: (callId ) =>