@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
@@ -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
  //
@@ -3057,6 +3189,7 @@ const RECORD_STATE_ACTIVE = 'active';
3057
3189
 
3058
3190
 
3059
3191
 
3192
+
3060
3193
 
3061
3194
 
3062
3195
 
@@ -3067,6 +3200,7 @@ const RECORD_STATE_ACTIVE = 'active';
3067
3200
 
3068
3201
 
3069
3202
 
3203
+
3070
3204
 
3071
3205
 
3072
3206
 
@@ -3095,6 +3229,7 @@ class Call {
3095
3229
 
3096
3230
 
3097
3231
 
3232
+
3098
3233
 
3099
3234
 
3100
3235
 
@@ -3119,6 +3254,7 @@ class Call {
3119
3254
  calleeNumber: plain.peer_caller_id_number,
3120
3255
  dialedExtension: plain.dialed_extension,
3121
3256
  isCaller: plain.is_caller,
3257
+ isVideo: plain.is_video,
3122
3258
  muted: plain.muted,
3123
3259
  onHold: plain.on_hold,
3124
3260
  status: plain.status,
@@ -3142,6 +3278,7 @@ class Call {
3142
3278
  calleeNumber,
3143
3279
  dialedExtension,
3144
3280
  isCaller,
3281
+ isVideo,
3145
3282
  lineId,
3146
3283
  muted,
3147
3284
  onHold,
@@ -3165,6 +3302,7 @@ class Call {
3165
3302
  this.startingTime = startingTime;
3166
3303
  this.talkingToIds = talkingToIds || [];
3167
3304
  this.recording = recording;
3305
+ this.isVideo = !!isVideo;
3168
3306
 
3169
3307
  // Useful to compare instead of instanceof with minified code
3170
3308
  this.type = 'Call';
@@ -4207,6 +4345,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4345
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4346
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
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
+
4210
4356
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4357
 
4212
4358
  mute: (callId ) =>