@wazo/sdk 0.38.5 → 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 (135) hide show
  1. package/README.md +1 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +148 -2
  4. package/esm/__tests__/web-rtc-client.test.js +303 -26
  5. package/esm/api/calld.js +14 -0
  6. package/esm/api/confd.js +134 -2
  7. package/esm/api/ctid-ng.js +6 -0
  8. package/esm/api-client.js +148 -2
  9. package/esm/checker/Checker.js +212 -26
  10. package/esm/checker/checks/aor.js +148 -2
  11. package/esm/checker/checks/api.js +148 -2
  12. package/esm/checker/checks/index.js +212 -26
  13. package/esm/checker/checks/wazo-websocket.js +2 -0
  14. package/esm/checker/checks/webrtc-transport.js +210 -26
  15. package/esm/checker/checks/webrtc.js +210 -26
  16. package/esm/domain/AdHocAPIConference.js +148 -2
  17. package/esm/domain/Call.js +6 -0
  18. package/esm/domain/CallSession.js +1 -1
  19. package/esm/domain/Features.js +148 -2
  20. package/esm/domain/Meeting.js +18 -0
  21. package/esm/domain/MeetingAuthorization.js +70 -0
  22. package/esm/domain/Phone/CTIPhone.js +149 -3
  23. package/esm/domain/Phone/WebRTCPhone.js +3 -3
  24. package/esm/domain/__tests__/Call.test.js +6 -0
  25. package/esm/domain/__tests__/CallSession.test.js +1 -1
  26. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -1
  27. package/esm/domain/__tests__/Meeting.test.js +87 -1
  28. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  29. package/esm/domain/__tests__/Room.test.js +1 -1
  30. package/esm/index.js +258 -32
  31. package/esm/lib/WazoSessionDescriptionHandler.js +22 -1
  32. package/esm/service/CallApi.js +148 -2
  33. package/esm/service/getApiClient.js +148 -2
  34. package/esm/simple/Auth.js +258 -32
  35. package/esm/simple/Configuration.js +258 -32
  36. package/esm/simple/Directory.js +148 -2
  37. package/esm/simple/Phone.js +258 -32
  38. package/esm/simple/Websocket.js +3 -0
  39. package/esm/simple/index.js +258 -32
  40. package/esm/simple/room/LocalParticipant.js +258 -32
  41. package/esm/simple/room/Participant.js +258 -32
  42. package/esm/simple/room/RemoteParticipant.js +258 -32
  43. package/esm/simple/room/Room.js +258 -32
  44. package/esm/simple/room/SipRoom.js +258 -32
  45. package/esm/simple/room/Stream.js +258 -32
  46. package/esm/simple/room/__tests__/Participant.test.js +14747 -0
  47. package/esm/simple/room/__tests__/RemoteParticipant.test.js +258 -32
  48. package/esm/simple/utils.js +258 -32
  49. package/esm/utils/__tests__/object.test.js +57 -0
  50. package/esm/utils/__tests__/sdp.test.js +50 -0
  51. package/esm/utils/__tests__/string.test.js +30 -0
  52. package/esm/utils/object.js +24 -0
  53. package/esm/utils/sdp.js +19 -1
  54. package/esm/utils/string.js +10 -0
  55. package/esm/web-rtc-client.js +210 -26
  56. package/esm/websocket-client.js +3 -1
  57. package/lib/__tests__/api-client.test.js +148 -2
  58. package/lib/__tests__/web-rtc-client.test.js +303 -26
  59. package/lib/api/calld.js +14 -0
  60. package/lib/api/confd.js +134 -2
  61. package/lib/api/ctid-ng.js +6 -0
  62. package/lib/api-client.js +148 -2
  63. package/lib/checker/Checker.js +212 -26
  64. package/lib/checker/checks/aor.js +148 -2
  65. package/lib/checker/checks/api.js +148 -2
  66. package/lib/checker/checks/index.js +212 -26
  67. package/lib/checker/checks/wazo-websocket.js +2 -0
  68. package/lib/checker/checks/webrtc-transport.js +210 -26
  69. package/lib/checker/checks/webrtc.js +210 -26
  70. package/lib/domain/AdHocAPIConference.js +148 -2
  71. package/lib/domain/Call.js +6 -0
  72. package/lib/domain/CallSession.js +1 -1
  73. package/lib/domain/Features.js +148 -2
  74. package/lib/domain/Meeting.js +18 -0
  75. package/lib/domain/MeetingAuthorization.js +79 -0
  76. package/lib/domain/Phone/CTIPhone.js +149 -3
  77. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  78. package/lib/domain/__tests__/Call.test.js +6 -0
  79. package/lib/domain/__tests__/CallSession.test.js +1 -1
  80. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -1
  81. package/lib/domain/__tests__/Meeting.test.js +87 -1
  82. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  83. package/lib/domain/__tests__/Room.test.js +1 -1
  84. package/lib/index.js +258 -32
  85. package/lib/lib/WazoSessionDescriptionHandler.js +22 -1
  86. package/lib/service/CallApi.js +148 -2
  87. package/lib/service/getApiClient.js +148 -2
  88. package/lib/simple/Auth.js +258 -32
  89. package/lib/simple/Configuration.js +258 -32
  90. package/lib/simple/Directory.js +148 -2
  91. package/lib/simple/Phone.js +258 -32
  92. package/lib/simple/Websocket.js +3 -0
  93. package/lib/simple/index.js +258 -32
  94. package/lib/simple/room/LocalParticipant.js +258 -32
  95. package/lib/simple/room/Participant.js +258 -32
  96. package/lib/simple/room/RemoteParticipant.js +258 -32
  97. package/lib/simple/room/Room.js +258 -32
  98. package/lib/simple/room/SipRoom.js +258 -32
  99. package/lib/simple/room/Stream.js +258 -32
  100. package/lib/simple/room/__tests__/Participant.test.js +14757 -0
  101. package/lib/simple/room/__tests__/RemoteParticipant.test.js +258 -32
  102. package/lib/simple/utils.js +258 -32
  103. package/lib/utils/__tests__/object.test.js +59 -0
  104. package/lib/utils/__tests__/sdp.test.js +50 -0
  105. package/lib/utils/__tests__/string.test.js +32 -0
  106. package/lib/utils/object.js +28 -0
  107. package/lib/utils/sdp.js +19 -0
  108. package/lib/utils/string.js +14 -0
  109. package/lib/web-rtc-client.js +210 -26
  110. package/lib/websocket-client.js +3 -0
  111. package/package.json +2 -2
  112. package/src/__tests__/web-rtc-client.test.js +93 -0
  113. package/src/api/calld.js +8 -0
  114. package/src/api/confd.js +43 -2
  115. package/src/domain/Call.js +6 -0
  116. package/src/domain/CallSession.js +1 -1
  117. package/src/domain/Meeting.js +20 -0
  118. package/src/domain/MeetingAuthorization.js +67 -0
  119. package/src/domain/Phone/WebRTCPhone.js +2 -2
  120. package/src/domain/__tests__/Meeting.test.js +70 -1
  121. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  122. package/src/lib/WazoSessionDescriptionHandler.js +5 -2
  123. package/src/simple/room/Participant.js +40 -0
  124. package/src/simple/room/Room.js +2 -2
  125. package/src/simple/room/SipRoom.js +1 -1
  126. package/src/simple/room/__tests__/Participant.test.js +81 -0
  127. package/src/types/WebSocketMessage.js +7 -1
  128. package/src/utils/__tests__/object.test.js +35 -0
  129. package/src/utils/__tests__/sdp.test.js +33 -1
  130. package/src/utils/__tests__/string.test.js +23 -0
  131. package/src/utils/object.js +15 -0
  132. package/src/utils/sdp.js +18 -0
  133. package/src/utils/string.js +8 -0
  134. package/src/web-rtc-client.js +40 -23
  135. package/src/websocket-client.js +2 -0
@@ -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
  //
@@ -3051,6 +3183,7 @@ const RECORD_STATE_ACTIVE = 'active';
3051
3183
 
3052
3184
 
3053
3185
 
3186
+
3054
3187
 
3055
3188
 
3056
3189
 
@@ -3061,6 +3194,7 @@ const RECORD_STATE_ACTIVE = 'active';
3061
3194
 
3062
3195
 
3063
3196
 
3197
+
3064
3198
 
3065
3199
 
3066
3200
 
@@ -3089,6 +3223,7 @@ class Call {
3089
3223
 
3090
3224
 
3091
3225
 
3226
+
3092
3227
 
3093
3228
 
3094
3229
 
@@ -3113,6 +3248,7 @@ class Call {
3113
3248
  calleeNumber: plain.peer_caller_id_number,
3114
3249
  dialedExtension: plain.dialed_extension,
3115
3250
  isCaller: plain.is_caller,
3251
+ isVideo: plain.is_video,
3116
3252
  muted: plain.muted,
3117
3253
  onHold: plain.on_hold,
3118
3254
  status: plain.status,
@@ -3136,6 +3272,7 @@ class Call {
3136
3272
  calleeNumber,
3137
3273
  dialedExtension,
3138
3274
  isCaller,
3275
+ isVideo,
3139
3276
  lineId,
3140
3277
  muted,
3141
3278
  onHold,
@@ -3159,6 +3296,7 @@ class Call {
3159
3296
  this.startingTime = startingTime;
3160
3297
  this.talkingToIds = talkingToIds || [];
3161
3298
  this.recording = recording;
3299
+ this.isVideo = !!isVideo;
3162
3300
 
3163
3301
  // Useful to compare instead of instanceof with minified code
3164
3302
  this.type = 'Call';
@@ -4218,6 +4356,14 @@ var calldMethods = (client , baseUrl ) => ({
4218
4356
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4219
4357
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4220
4358
 
4359
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4360
+ client.delete(
4361
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4362
+ null,
4363
+ null,
4364
+ ApiRequester.successResponseParser,
4365
+ ),
4366
+
4221
4367
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4222
4368
 
4223
4369
  mute: (callId ) =>