@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';
@@ -4201,6 +4339,14 @@ var calldMethods = (client , baseUrl ) => ({
4201
4339
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4202
4340
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4203
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
+
4204
4350
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4205
4351
 
4206
4352
  mute: (callId ) =>
@@ -13,6 +13,17 @@ var newFrom = (instance , ToClass ) => {
13
13
 
14
14
  //
15
15
 
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
16
27
 
17
28
 
18
29
 
@@ -23,6 +34,7 @@ var newFrom = (instance , ToClass ) => {
23
34
 
24
35
 
25
36
 
37
+
26
38
 
27
39
 
28
40
  class Meeting {
@@ -37,6 +49,8 @@ class Meeting {
37
49
 
38
50
 
39
51
 
52
+
53
+
40
54
 
41
55
  static parse(plain ) {
42
56
  return new Meeting({
@@ -49,6 +63,7 @@ class Meeting {
49
63
  extension: plain.exten,
50
64
  persistent: plain.persistent,
51
65
  creationTime: moment(plain.creation_time).toDate(),
66
+ requireAuthorization: plain.require_authorization,
52
67
  });
53
68
  }
54
69
 
@@ -73,6 +88,7 @@ class Meeting {
73
88
  extension,
74
89
  persistent,
75
90
  creationTime,
91
+ requireAuthorization,
76
92
  } = {}) {
77
93
  this.guestSipAuthorization = guestSipAuthorization;
78
94
  this.uri = uri;
@@ -83,6 +99,7 @@ class Meeting {
83
99
  this.extension = extension;
84
100
  this.persistent = persistent;
85
101
  this.creationTime = creationTime;
102
+ this.requireAuthorization = requireAuthorization;
86
103
 
87
104
  // Useful to compare instead of instanceof with minified code
88
105
  this.type = 'Meeting';
@@ -93,6 +110,7 @@ class Meeting {
93
110
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
94
111
  return { username, secret };
95
112
  }
113
+
96
114
  }
97
115
 
98
116
  export default Meeting;
@@ -0,0 +1,70 @@
1
+ //
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ const PENDING = 'pending';
12
+ const ACCEPTED = 'accepted';
13
+ const REJECTED = 'rejected';
14
+ const POST_PROCESSING = 'post_processing';
15
+ const POST_PROCESSED_SUCCESS = 'post_processed_success';
16
+ const POST_PROCESSED_ERROR = 'post_processed_error';
17
+
18
+ class MeetingAuthorization {
19
+
20
+
21
+
22
+
23
+
24
+
25
+ constructor({
26
+ meetingUuid,
27
+ uuid,
28
+ userUuid,
29
+ userName,
30
+ } = {}) {
31
+ this.meetingUuid = meetingUuid;
32
+ this.uuid = uuid;
33
+ this.userUuid = userUuid;
34
+ this.userName = userName;
35
+ }
36
+
37
+ setStatus(status ) {
38
+ this.status = status;
39
+ }
40
+
41
+ getStatus() {
42
+ return this.status;
43
+ }
44
+
45
+ static parse(plain ) {
46
+ const {
47
+ meeting_uuid: meetingUuid,
48
+ uuid,
49
+ guest_uuid: userUuid,
50
+ guest_name: userName,
51
+ } = plain;
52
+
53
+ return new MeetingAuthorization({
54
+ meetingUuid,
55
+ uuid,
56
+ userUuid,
57
+ userName,
58
+ });
59
+ }
60
+
61
+ static parseMany(items ) {
62
+ if (!items) {
63
+ return [];
64
+ }
65
+ return items.map(MeetingAuthorization.parse);
66
+ }
67
+ }
68
+
69
+ export default MeetingAuthorization;
70
+ export { ACCEPTED, PENDING, POST_PROCESSED_ERROR, POST_PROCESSED_SUCCESS, POST_PROCESSING, REJECTED };
@@ -1513,6 +1513,7 @@ const RECORD_STATE_ACTIVE = 'active';
1513
1513
 
1514
1514
 
1515
1515
 
1516
+
1516
1517
 
1517
1518
 
1518
1519
 
@@ -1523,6 +1524,7 @@ const RECORD_STATE_ACTIVE = 'active';
1523
1524
 
1524
1525
 
1525
1526
 
1527
+
1526
1528
 
1527
1529
 
1528
1530
 
@@ -1551,6 +1553,7 @@ class Call {
1551
1553
 
1552
1554
 
1553
1555
 
1556
+
1554
1557
 
1555
1558
 
1556
1559
 
@@ -1575,6 +1578,7 @@ class Call {
1575
1578
  calleeNumber: plain.peer_caller_id_number,
1576
1579
  dialedExtension: plain.dialed_extension,
1577
1580
  isCaller: plain.is_caller,
1581
+ isVideo: plain.is_video,
1578
1582
  muted: plain.muted,
1579
1583
  onHold: plain.on_hold,
1580
1584
  status: plain.status,
@@ -1598,6 +1602,7 @@ class Call {
1598
1602
  calleeNumber,
1599
1603
  dialedExtension,
1600
1604
  isCaller,
1605
+ isVideo,
1601
1606
  lineId,
1602
1607
  muted,
1603
1608
  onHold,
@@ -1621,6 +1626,7 @@ class Call {
1621
1626
  this.startingTime = startingTime;
1622
1627
  this.talkingToIds = talkingToIds || [];
1623
1628
  this.recording = recording;
1629
+ this.isVideo = !!isVideo;
1624
1630
 
1625
1631
  // Useful to compare instead of instanceof with minified code
1626
1632
  this.type = 'Call';
@@ -2094,7 +2100,7 @@ class CallSession {
2094
2100
  ringing: call.isRinging(),
2095
2101
  answered: call.isUp(),
2096
2102
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
2097
- cameraEnabled: false,
2103
+ cameraEnabled: call.isVideo,
2098
2104
  dialedExtension: call.dialedExtension,
2099
2105
  call,
2100
2106
  conference: false, // @FIXME?
@@ -3585,6 +3591,70 @@ class ExternalApp {
3585
3591
 
3586
3592
  //
3587
3593
 
3594
+ class MeetingAuthorization {
3595
+
3596
+
3597
+
3598
+
3599
+
3600
+
3601
+ constructor({
3602
+ meetingUuid,
3603
+ uuid,
3604
+ userUuid,
3605
+ userName,
3606
+ } = {}) {
3607
+ this.meetingUuid = meetingUuid;
3608
+ this.uuid = uuid;
3609
+ this.userUuid = userUuid;
3610
+ this.userName = userName;
3611
+ }
3612
+
3613
+ setStatus(status ) {
3614
+ this.status = status;
3615
+ }
3616
+
3617
+ getStatus() {
3618
+ return this.status;
3619
+ }
3620
+
3621
+ static parse(plain ) {
3622
+ const {
3623
+ meeting_uuid: meetingUuid,
3624
+ uuid,
3625
+ guest_uuid: userUuid,
3626
+ guest_name: userName,
3627
+ } = plain;
3628
+
3629
+ return new MeetingAuthorization({
3630
+ meetingUuid,
3631
+ uuid,
3632
+ userUuid,
3633
+ userName,
3634
+ });
3635
+ }
3636
+
3637
+ static parseMany(items ) {
3638
+ if (!items) {
3639
+ return [];
3640
+ }
3641
+ return items.map(MeetingAuthorization.parse);
3642
+ }
3643
+ }
3644
+
3645
+ //
3646
+
3647
+
3648
+
3649
+
3650
+
3651
+
3652
+
3653
+
3654
+
3655
+
3656
+
3657
+
3588
3658
 
3589
3659
 
3590
3660
 
@@ -3595,6 +3665,7 @@ class ExternalApp {
3595
3665
 
3596
3666
 
3597
3667
 
3668
+
3598
3669
 
3599
3670
 
3600
3671
  class Meeting {
@@ -3609,6 +3680,8 @@ class Meeting {
3609
3680
 
3610
3681
 
3611
3682
 
3683
+
3684
+
3612
3685
 
3613
3686
  static parse(plain ) {
3614
3687
  return new Meeting({
@@ -3621,6 +3694,7 @@ class Meeting {
3621
3694
  extension: plain.exten,
3622
3695
  persistent: plain.persistent,
3623
3696
  creationTime: moment(plain.creation_time).toDate(),
3697
+ requireAuthorization: plain.require_authorization,
3624
3698
  });
3625
3699
  }
3626
3700
 
@@ -3645,6 +3719,7 @@ class Meeting {
3645
3719
  extension,
3646
3720
  persistent,
3647
3721
  creationTime,
3722
+ requireAuthorization,
3648
3723
  } = {}) {
3649
3724
  this.guestSipAuthorization = guestSipAuthorization;
3650
3725
  this.uri = uri;
@@ -3655,6 +3730,7 @@ class Meeting {
3655
3730
  this.extension = extension;
3656
3731
  this.persistent = persistent;
3657
3732
  this.creationTime = creationTime;
3733
+ this.requireAuthorization = requireAuthorization;
3658
3734
 
3659
3735
  // Useful to compare instead of instanceof with minified code
3660
3736
  this.type = 'Meeting';
@@ -3665,8 +3741,32 @@ class Meeting {
3665
3741
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3666
3742
  return { username, secret };
3667
3743
  }
3744
+
3668
3745
  }
3669
3746
 
3747
+ //
3748
+
3749
+ const camelToUnderscore = (key ) => {
3750
+ if (typeof key !== 'string') {
3751
+ throw new Error('Input is not a string');
3752
+ }
3753
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3754
+ };
3755
+
3756
+ //
3757
+
3758
+ const convertKeysFromCamelToUnderscore = (args ) => {
3759
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3760
+ throw new Error('Input is not an object');
3761
+ }
3762
+
3763
+ return Object.keys(args).reduce((acc, key) => {
3764
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3765
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3766
+ return acc;
3767
+ }, {});
3768
+ };
3769
+
3670
3770
  /* */
3671
3771
 
3672
3772
  var confdMethods = (client , baseUrl ) => ({
@@ -3735,8 +3835,18 @@ var confdMethods = (client , baseUrl ) => ({
3735
3835
  getMyMeetings: () =>
3736
3836
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3737
3837
 
3738
- createMyMeeting: (name , persistent ) =>
3739
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3838
+ createMyMeeting: (args ) =>
3839
+ client
3840
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3841
+ .then(Meeting.parse),
3842
+
3843
+ updateMyMeeting: (meetingUuid , data ) =>
3844
+ client.put(
3845
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3846
+ convertKeysFromCamelToUnderscore(data),
3847
+ null,
3848
+ ApiRequester.successResponseParser,
3849
+ ),
3740
3850
 
3741
3851
  deleteMyMeeting: (meetingUuid ) =>
3742
3852
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3744,8 +3854,36 @@ var confdMethods = (client , baseUrl ) => ({
3744
3854
  getMeeting: (meetingUuid ) =>
3745
3855
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3746
3856
 
3857
+ meetingAuthorizations: (meetingUuid ) =>
3858
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3859
+
3860
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3861
+ client.put(
3862
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3863
+ {},
3864
+ null,
3865
+ ApiRequester.successResponseParser,
3866
+ ),
3867
+
3868
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3869
+ client.put(
3870
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3871
+ {},
3872
+ null,
3873
+ ApiRequester.successResponseParser,
3874
+ ),
3875
+
3747
3876
  guestGetMeeting: (meetingUuid ) =>
3748
3877
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3878
+
3879
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3880
+ client
3881
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3882
+ .then(MeetingAuthorization.parse),
3883
+
3884
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3885
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3886
+
3749
3887
  });
3750
3888
 
3751
3889
  //
@@ -4614,6 +4752,14 @@ var calldMethods = (client , baseUrl ) => ({
4614
4752
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4615
4753
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4616
4754
 
4755
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4756
+ client.delete(
4757
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4758
+ null,
4759
+ null,
4760
+ ApiRequester.successResponseParser,
4761
+ ),
4762
+
4617
4763
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4618
4764
 
4619
4765
  mute: (callId ) =>
@@ -436,7 +436,7 @@ class CallSession {
436
436
  ringing: call.isRinging(),
437
437
  answered: call.isUp(),
438
438
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
439
- cameraEnabled: false,
439
+ cameraEnabled: call.isVideo,
440
440
  dialedExtension: call.dialedExtension,
441
441
  call,
442
442
  conference: false, // @FIXME?
@@ -1570,10 +1570,10 @@ class WebRTCPhone extends Emitter {
1570
1570
  this.audioRingVolume = volume;
1571
1571
  }
1572
1572
 
1573
- changeAudioInputDevice(id ) {
1573
+ changeAudioInputDevice(id , force ) {
1574
1574
  logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
1575
1575
 
1576
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
1576
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
1577
1577
  }
1578
1578
 
1579
1579
  changeVideoInputDevice(id ) {