@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
@@ -2645,6 +2645,70 @@ class ExternalApp {
2645
2645
 
2646
2646
  //
2647
2647
 
2648
+ class MeetingAuthorization {
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+ constructor({
2656
+ meetingUuid,
2657
+ uuid,
2658
+ userUuid,
2659
+ userName,
2660
+ } = {}) {
2661
+ this.meetingUuid = meetingUuid;
2662
+ this.uuid = uuid;
2663
+ this.userUuid = userUuid;
2664
+ this.userName = userName;
2665
+ }
2666
+
2667
+ setStatus(status ) {
2668
+ this.status = status;
2669
+ }
2670
+
2671
+ getStatus() {
2672
+ return this.status;
2673
+ }
2674
+
2675
+ static parse(plain ) {
2676
+ const {
2677
+ meeting_uuid: meetingUuid,
2678
+ uuid,
2679
+ guest_uuid: userUuid,
2680
+ guest_name: userName,
2681
+ } = plain;
2682
+
2683
+ return new MeetingAuthorization({
2684
+ meetingUuid,
2685
+ uuid,
2686
+ userUuid,
2687
+ userName,
2688
+ });
2689
+ }
2690
+
2691
+ static parseMany(items ) {
2692
+ if (!items) {
2693
+ return [];
2694
+ }
2695
+ return items.map(MeetingAuthorization.parse);
2696
+ }
2697
+ }
2698
+
2699
+ //
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+
2648
2712
 
2649
2713
 
2650
2714
 
@@ -2655,6 +2719,7 @@ class ExternalApp {
2655
2719
 
2656
2720
 
2657
2721
 
2722
+
2658
2723
 
2659
2724
 
2660
2725
  class Meeting {
@@ -2669,6 +2734,8 @@ class Meeting {
2669
2734
 
2670
2735
 
2671
2736
 
2737
+
2738
+
2672
2739
 
2673
2740
  static parse(plain ) {
2674
2741
  return new Meeting({
@@ -2681,6 +2748,7 @@ class Meeting {
2681
2748
  extension: plain.exten,
2682
2749
  persistent: plain.persistent,
2683
2750
  creationTime: moment(plain.creation_time).toDate(),
2751
+ requireAuthorization: plain.require_authorization,
2684
2752
  });
2685
2753
  }
2686
2754
 
@@ -2705,6 +2773,7 @@ class Meeting {
2705
2773
  extension,
2706
2774
  persistent,
2707
2775
  creationTime,
2776
+ requireAuthorization,
2708
2777
  } = {}) {
2709
2778
  this.guestSipAuthorization = guestSipAuthorization;
2710
2779
  this.uri = uri;
@@ -2715,6 +2784,7 @@ class Meeting {
2715
2784
  this.extension = extension;
2716
2785
  this.persistent = persistent;
2717
2786
  this.creationTime = creationTime;
2787
+ this.requireAuthorization = requireAuthorization;
2718
2788
 
2719
2789
  // Useful to compare instead of instanceof with minified code
2720
2790
  this.type = 'Meeting';
@@ -2725,8 +2795,32 @@ class Meeting {
2725
2795
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2726
2796
  return { username, secret };
2727
2797
  }
2798
+
2728
2799
  }
2729
2800
 
2801
+ //
2802
+
2803
+ const camelToUnderscore = (key ) => {
2804
+ if (typeof key !== 'string') {
2805
+ throw new Error('Input is not a string');
2806
+ }
2807
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2808
+ };
2809
+
2810
+ //
2811
+
2812
+ const convertKeysFromCamelToUnderscore = (args ) => {
2813
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2814
+ throw new Error('Input is not an object');
2815
+ }
2816
+
2817
+ return Object.keys(args).reduce((acc, key) => {
2818
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2819
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2820
+ return acc;
2821
+ }, {});
2822
+ };
2823
+
2730
2824
  /* */
2731
2825
 
2732
2826
  var confdMethods = (client , baseUrl ) => ({
@@ -2795,8 +2889,18 @@ var confdMethods = (client , baseUrl ) => ({
2795
2889
  getMyMeetings: () =>
2796
2890
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2797
2891
 
2798
- createMyMeeting: (name , persistent ) =>
2799
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2892
+ createMyMeeting: (args ) =>
2893
+ client
2894
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2895
+ .then(Meeting.parse),
2896
+
2897
+ updateMyMeeting: (meetingUuid , data ) =>
2898
+ client.put(
2899
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2900
+ convertKeysFromCamelToUnderscore(data),
2901
+ null,
2902
+ ApiRequester.successResponseParser,
2903
+ ),
2800
2904
 
2801
2905
  deleteMyMeeting: (meetingUuid ) =>
2802
2906
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2804,8 +2908,36 @@ var confdMethods = (client , baseUrl ) => ({
2804
2908
  getMeeting: (meetingUuid ) =>
2805
2909
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2806
2910
 
2911
+ meetingAuthorizations: (meetingUuid ) =>
2912
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2913
+
2914
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2915
+ client.put(
2916
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2917
+ {},
2918
+ null,
2919
+ ApiRequester.successResponseParser,
2920
+ ),
2921
+
2922
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2923
+ client.put(
2924
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2925
+ {},
2926
+ null,
2927
+ ApiRequester.successResponseParser,
2928
+ ),
2929
+
2807
2930
  guestGetMeeting: (meetingUuid ) =>
2808
2931
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2932
+
2933
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2934
+ client
2935
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2936
+ .then(MeetingAuthorization.parse),
2937
+
2938
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2939
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2940
+
2809
2941
  });
2810
2942
 
2811
2943
  //
@@ -5056,6 +5188,14 @@ var calldMethods = (client , baseUrl ) => ({
5056
5188
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5057
5189
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5058
5190
 
5191
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5192
+ client.delete(
5193
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5194
+ null,
5195
+ null,
5196
+ ApiRequester.successResponseParser,
5197
+ ),
5198
+
5059
5199
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5060
5200
 
5061
5201
  mute: (callId ) =>
@@ -7513,7 +7653,7 @@ class WebRTCClient extends Emitter {
7513
7653
  });
7514
7654
  }
7515
7655
 
7516
- changeAudioInputDevice(id , session , force ) {
7656
+ async changeAudioInputDevice(id , session , force ) {
7517
7657
  const currentId = this.getAudioDeviceId();
7518
7658
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7519
7659
 
@@ -7521,33 +7661,50 @@ class WebRTCClient extends Emitter {
7521
7661
  return null;
7522
7662
  }
7523
7663
 
7664
+ // in order to handle an audio track change for default devices
7665
+ // we need the actual id of the device (not 'default')
7666
+ let deviceId = id;
7667
+ if (id === 'default' && navigator.mediaDevices) {
7668
+ const devices = await navigator.mediaDevices.enumerateDevices();
7669
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7670
+ if (defaultDevice) {
7671
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7672
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7673
+ if (targetDevice) {
7674
+ deviceId = targetDevice.deviceId;
7675
+ if (!force && deviceId === currentId) {
7676
+ return null;
7677
+ }
7678
+ }
7679
+ }
7680
+ }
7681
+
7524
7682
  // let's update the local audio value
7525
7683
  if (this.audio) {
7526
7684
  this.audio = {
7527
7685
  deviceId: {
7528
- exact: id,
7686
+ exact: deviceId,
7529
7687
  },
7530
7688
  };
7531
7689
  }
7532
7690
 
7533
- if (session) {
7691
+ if (session && navigator.mediaDevices) {
7534
7692
  const sdh = session.sessionDescriptionHandler;
7535
7693
  const pc = sdh.peerConnection;
7536
7694
 
7537
- // $FlowFixMe
7538
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7539
- const audioTrack = stream.getAudioTracks()[0];
7540
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7695
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7696
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7697
+ const audioTrack = stream.getAudioTracks()[0];
7698
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7541
7699
 
7542
- if (sender) {
7543
- if (sender.track) {
7544
- audioTrack.enabled = sender.track.enabled;
7545
- }
7546
- sender.replaceTrack(audioTrack);
7700
+ if (sender) {
7701
+ if (sender.track) {
7702
+ audioTrack.enabled = sender.track.enabled;
7547
7703
  }
7704
+ sender.replaceTrack(audioTrack);
7705
+ }
7548
7706
 
7549
- return stream;
7550
- });
7707
+ return stream;
7551
7708
  }
7552
7709
  }
7553
7710
 
@@ -7567,14 +7724,14 @@ class WebRTCClient extends Emitter {
7567
7724
  return null;
7568
7725
  }
7569
7726
 
7570
- // let's update the local video value
7571
- if (this.video) {
7572
- this.video = {
7573
- deviceId: {
7574
- exact: id,
7575
- },
7576
- };
7577
- }
7727
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7728
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7729
+ this.video = {
7730
+ ...videoObject,
7731
+ deviceId: {
7732
+ exact: id,
7733
+ },
7734
+ };
7578
7735
  }
7579
7736
 
7580
7737
  changeSessionVideoInputDevice(id , session ) {
@@ -10969,6 +11126,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10969
11126
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10970
11127
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10971
11128
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11129
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10972
11130
 
10973
11131
  const BLACKLIST_EVENTS = [
10974
11132
  CHAT_MESSAGE_SENT,
@@ -11320,6 +11478,7 @@ WebSocketClient.eventLists = [
11320
11478
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11321
11479
  CONFERENCE_ADHOC_DELETED,
11322
11480
  MEETING_USER_PROGRESS,
11481
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11323
11482
  ];
11324
11483
 
11325
11484
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11391,6 +11550,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11391
11550
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11392
11551
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11393
11552
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11553
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11394
11554
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11395
11555
  'default': WebSocketClient
11396
11556
  });
@@ -11495,6 +11655,7 @@ class Participant extends Emitter {
11495
11655
 
11496
11656
 
11497
11657
 
11658
+
11498
11659
 
11499
11660
 
11500
11661
 
@@ -11512,6 +11673,7 @@ class Participant extends Emitter {
11512
11673
 
11513
11674
 
11514
11675
 
11676
+
11515
11677
 
11516
11678
  /**
11517
11679
  * @param room Room The room where the participant is
@@ -11535,6 +11697,7 @@ class Participant extends Emitter {
11535
11697
  this.screensharing = false;
11536
11698
  this.isOnHold = false;
11537
11699
  this.extra = extra;
11700
+ this.banned = false;
11538
11701
 
11539
11702
  this.ON_UPDATED = 'participant/ON_UPDATED';
11540
11703
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11551,6 +11714,7 @@ class Participant extends Emitter {
11551
11714
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11552
11715
  this.ON_HOLD = 'participant/ON_HOLD';
11553
11716
  this.ON_RESUME = 'participant/ON_RESUME';
11717
+ this.ON_BAN = 'participant/ON_BAN';
11554
11718
  }
11555
11719
 
11556
11720
  triggerEvent(name , ...args ) {
@@ -11591,6 +11755,10 @@ class Participant extends Emitter {
11591
11755
  status.extra = this.extra;
11592
11756
  break;
11593
11757
  }
11758
+ case this.ON_BAN: {
11759
+ status.banned = true;
11760
+ break;
11761
+ }
11594
11762
  }
11595
11763
 
11596
11764
  if (broadcast) {
@@ -11693,6 +11861,11 @@ class Participant extends Emitter {
11693
11861
  this.triggerUpdate(this.ON_RESUME, broadcast);
11694
11862
  }
11695
11863
 
11864
+ onBan(broadcast = true) {
11865
+ this.banned = true;
11866
+ this.triggerUpdate(this.ON_BAN, broadcast);
11867
+ }
11868
+
11696
11869
  getStatus() {
11697
11870
  return {
11698
11871
  callId: this.callId,
@@ -11739,6 +11912,10 @@ class Participant extends Emitter {
11739
11912
  }
11740
11913
  }
11741
11914
 
11915
+ if (status.banned) {
11916
+ this.onBan(false);
11917
+ }
11918
+
11742
11919
  // Poor man's object comparison
11743
11920
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11744
11921
  this.extra = { ...this.extra, ...status.extra };
@@ -11766,6 +11943,28 @@ class Participant extends Emitter {
11766
11943
  this.streams = streams;
11767
11944
  this.videoStreams = streams;
11768
11945
  }
11946
+
11947
+ async ban(apiRequestDelay = null) {
11948
+ const { meetingUuid } = this.room;
11949
+ if (!meetingUuid) {
11950
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11951
+ }
11952
+
11953
+ // this notifies all that someone is being banned
11954
+ this.onBan(true);
11955
+
11956
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11957
+ if (apiRequestDelay) {
11958
+ await this.delay(apiRequestDelay);
11959
+ }
11960
+
11961
+ // proceed with the actual kick
11962
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11963
+ }
11964
+
11965
+ async delay(ms ) {
11966
+ return new Promise(resolve => setTimeout(resolve, ms));
11967
+ }
11769
11968
  }
11770
11969
 
11771
11970
  //
@@ -11918,7 +12117,7 @@ class Room$1 extends Emitter {
11918
12117
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11919
12118
 
11920
12119
  if (!room) {
11921
- await Wazo.Phone.connect();
12120
+ await Wazo.Phone.connect({ media: constraints });
11922
12121
 
11923
12122
  const withCamera = constraints && !!constraints.video;
11924
12123
 
@@ -12363,7 +12562,7 @@ class Room$1 extends Emitter {
12363
12562
  const participant = this._getParticipantFromCallId(status.callId);
12364
12563
 
12365
12564
  if (participant) {
12366
- // we're received, so no need to broadcast, hence the input false arg
12565
+ // we're receiving, so no need to broadcast
12367
12566
  participant.updateStatus(status, false);
12368
12567
  }
12369
12568
  break;
@@ -12630,7 +12829,7 @@ class SipRoom extends Room$1 {
12630
12829
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12631
12830
 
12632
12831
  if (!room) {
12633
- await Wazo.Phone.connect();
12832
+ await Wazo.Phone.connect({ media: constraints });
12634
12833
 
12635
12834
  const withCamera = constraints && !!constraints.video;
12636
12835
 
@@ -2625,6 +2625,70 @@ class ExternalApp {
2625
2625
 
2626
2626
  //
2627
2627
 
2628
+ class MeetingAuthorization {
2629
+
2630
+
2631
+
2632
+
2633
+
2634
+
2635
+ constructor({
2636
+ meetingUuid,
2637
+ uuid,
2638
+ userUuid,
2639
+ userName,
2640
+ } = {}) {
2641
+ this.meetingUuid = meetingUuid;
2642
+ this.uuid = uuid;
2643
+ this.userUuid = userUuid;
2644
+ this.userName = userName;
2645
+ }
2646
+
2647
+ setStatus(status ) {
2648
+ this.status = status;
2649
+ }
2650
+
2651
+ getStatus() {
2652
+ return this.status;
2653
+ }
2654
+
2655
+ static parse(plain ) {
2656
+ const {
2657
+ meeting_uuid: meetingUuid,
2658
+ uuid,
2659
+ guest_uuid: userUuid,
2660
+ guest_name: userName,
2661
+ } = plain;
2662
+
2663
+ return new MeetingAuthorization({
2664
+ meetingUuid,
2665
+ uuid,
2666
+ userUuid,
2667
+ userName,
2668
+ });
2669
+ }
2670
+
2671
+ static parseMany(items ) {
2672
+ if (!items) {
2673
+ return [];
2674
+ }
2675
+ return items.map(MeetingAuthorization.parse);
2676
+ }
2677
+ }
2678
+
2679
+ //
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2628
2692
 
2629
2693
 
2630
2694
 
@@ -2635,6 +2699,7 @@ class ExternalApp {
2635
2699
 
2636
2700
 
2637
2701
 
2702
+
2638
2703
 
2639
2704
 
2640
2705
  class Meeting {
@@ -2649,6 +2714,8 @@ class Meeting {
2649
2714
 
2650
2715
 
2651
2716
 
2717
+
2718
+
2652
2719
 
2653
2720
  static parse(plain ) {
2654
2721
  return new Meeting({
@@ -2661,6 +2728,7 @@ class Meeting {
2661
2728
  extension: plain.exten,
2662
2729
  persistent: plain.persistent,
2663
2730
  creationTime: moment(plain.creation_time).toDate(),
2731
+ requireAuthorization: plain.require_authorization,
2664
2732
  });
2665
2733
  }
2666
2734
 
@@ -2685,6 +2753,7 @@ class Meeting {
2685
2753
  extension,
2686
2754
  persistent,
2687
2755
  creationTime,
2756
+ requireAuthorization,
2688
2757
  } = {}) {
2689
2758
  this.guestSipAuthorization = guestSipAuthorization;
2690
2759
  this.uri = uri;
@@ -2695,6 +2764,7 @@ class Meeting {
2695
2764
  this.extension = extension;
2696
2765
  this.persistent = persistent;
2697
2766
  this.creationTime = creationTime;
2767
+ this.requireAuthorization = requireAuthorization;
2698
2768
 
2699
2769
  // Useful to compare instead of instanceof with minified code
2700
2770
  this.type = 'Meeting';
@@ -2705,8 +2775,32 @@ class Meeting {
2705
2775
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2706
2776
  return { username, secret };
2707
2777
  }
2778
+
2708
2779
  }
2709
2780
 
2781
+ //
2782
+
2783
+ const camelToUnderscore = (key ) => {
2784
+ if (typeof key !== 'string') {
2785
+ throw new Error('Input is not a string');
2786
+ }
2787
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2788
+ };
2789
+
2790
+ //
2791
+
2792
+ const convertKeysFromCamelToUnderscore = (args ) => {
2793
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2794
+ throw new Error('Input is not an object');
2795
+ }
2796
+
2797
+ return Object.keys(args).reduce((acc, key) => {
2798
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2799
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2800
+ return acc;
2801
+ }, {});
2802
+ };
2803
+
2710
2804
  /* */
2711
2805
 
2712
2806
  var confdMethods = (client , baseUrl ) => ({
@@ -2775,8 +2869,18 @@ var confdMethods = (client , baseUrl ) => ({
2775
2869
  getMyMeetings: () =>
2776
2870
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2777
2871
 
2778
- createMyMeeting: (name , persistent ) =>
2779
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2872
+ createMyMeeting: (args ) =>
2873
+ client
2874
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2875
+ .then(Meeting.parse),
2876
+
2877
+ updateMyMeeting: (meetingUuid , data ) =>
2878
+ client.put(
2879
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2880
+ convertKeysFromCamelToUnderscore(data),
2881
+ null,
2882
+ ApiRequester.successResponseParser,
2883
+ ),
2780
2884
 
2781
2885
  deleteMyMeeting: (meetingUuid ) =>
2782
2886
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2784,8 +2888,36 @@ var confdMethods = (client , baseUrl ) => ({
2784
2888
  getMeeting: (meetingUuid ) =>
2785
2889
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2786
2890
 
2891
+ meetingAuthorizations: (meetingUuid ) =>
2892
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2893
+
2894
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2895
+ client.put(
2896
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2897
+ {},
2898
+ null,
2899
+ ApiRequester.successResponseParser,
2900
+ ),
2901
+
2902
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2903
+ client.put(
2904
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2905
+ {},
2906
+ null,
2907
+ ApiRequester.successResponseParser,
2908
+ ),
2909
+
2787
2910
  guestGetMeeting: (meetingUuid ) =>
2788
2911
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2912
+
2913
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2914
+ client
2915
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2916
+ .then(MeetingAuthorization.parse),
2917
+
2918
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2919
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2920
+
2789
2921
  });
2790
2922
 
2791
2923
  //
@@ -4207,6 +4339,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4339
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4340
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
4341
 
4342
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4343
+ client.delete(
4344
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4345
+ null,
4346
+ null,
4347
+ ApiRequester.successResponseParser,
4348
+ ),
4349
+
4210
4350
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4351
 
4212
4352
  mute: (callId ) =>