@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
@@ -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
  //
@@ -4230,6 +4362,14 @@ var calldMethods = (client , baseUrl ) => ({
4230
4362
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4231
4363
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4232
4364
 
4365
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4366
+ client.delete(
4367
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4368
+ null,
4369
+ null,
4370
+ ApiRequester.successResponseParser,
4371
+ ),
4372
+
4233
4373
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4234
4374
 
4235
4375
  mute: (callId ) =>
@@ -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
  //
@@ -4230,6 +4362,14 @@ var calldMethods = (client , baseUrl ) => ({
4230
4362
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4231
4363
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4232
4364
 
4365
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4366
+ client.delete(
4367
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4368
+ null,
4369
+ null,
4370
+ ApiRequester.successResponseParser,
4371
+ ),
4372
+
4233
4373
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4234
4374
 
4235
4375
  mute: (callId ) =>