@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
@@ -2633,6 +2633,70 @@ class ExternalApp {
2633
2633
 
2634
2634
  //
2635
2635
 
2636
+ class MeetingAuthorization {
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+
2643
+ constructor({
2644
+ meetingUuid,
2645
+ uuid,
2646
+ userUuid,
2647
+ userName,
2648
+ } = {}) {
2649
+ this.meetingUuid = meetingUuid;
2650
+ this.uuid = uuid;
2651
+ this.userUuid = userUuid;
2652
+ this.userName = userName;
2653
+ }
2654
+
2655
+ setStatus(status ) {
2656
+ this.status = status;
2657
+ }
2658
+
2659
+ getStatus() {
2660
+ return this.status;
2661
+ }
2662
+
2663
+ static parse(plain ) {
2664
+ const {
2665
+ meeting_uuid: meetingUuid,
2666
+ uuid,
2667
+ guest_uuid: userUuid,
2668
+ guest_name: userName,
2669
+ } = plain;
2670
+
2671
+ return new MeetingAuthorization({
2672
+ meetingUuid,
2673
+ uuid,
2674
+ userUuid,
2675
+ userName,
2676
+ });
2677
+ }
2678
+
2679
+ static parseMany(items ) {
2680
+ if (!items) {
2681
+ return [];
2682
+ }
2683
+ return items.map(MeetingAuthorization.parse);
2684
+ }
2685
+ }
2686
+
2687
+ //
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2636
2700
 
2637
2701
 
2638
2702
 
@@ -2643,6 +2707,7 @@ class ExternalApp {
2643
2707
 
2644
2708
 
2645
2709
 
2710
+
2646
2711
 
2647
2712
 
2648
2713
  class Meeting {
@@ -2657,6 +2722,8 @@ class Meeting {
2657
2722
 
2658
2723
 
2659
2724
 
2725
+
2726
+
2660
2727
 
2661
2728
  static parse(plain ) {
2662
2729
  return new Meeting({
@@ -2669,6 +2736,7 @@ class Meeting {
2669
2736
  extension: plain.exten,
2670
2737
  persistent: plain.persistent,
2671
2738
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2739
+ requireAuthorization: plain.require_authorization,
2672
2740
  });
2673
2741
  }
2674
2742
 
@@ -2693,6 +2761,7 @@ class Meeting {
2693
2761
  extension,
2694
2762
  persistent,
2695
2763
  creationTime,
2764
+ requireAuthorization,
2696
2765
  } = {}) {
2697
2766
  this.guestSipAuthorization = guestSipAuthorization;
2698
2767
  this.uri = uri;
@@ -2703,6 +2772,7 @@ class Meeting {
2703
2772
  this.extension = extension;
2704
2773
  this.persistent = persistent;
2705
2774
  this.creationTime = creationTime;
2775
+ this.requireAuthorization = requireAuthorization;
2706
2776
 
2707
2777
  // Useful to compare instead of instanceof with minified code
2708
2778
  this.type = 'Meeting';
@@ -2713,8 +2783,32 @@ class Meeting {
2713
2783
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2714
2784
  return { username, secret };
2715
2785
  }
2786
+
2716
2787
  }
2717
2788
 
2789
+ //
2790
+
2791
+ const camelToUnderscore = (key ) => {
2792
+ if (typeof key !== 'string') {
2793
+ throw new Error('Input is not a string');
2794
+ }
2795
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2796
+ };
2797
+
2798
+ //
2799
+
2800
+ const convertKeysFromCamelToUnderscore = (args ) => {
2801
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2802
+ throw new Error('Input is not an object');
2803
+ }
2804
+
2805
+ return Object.keys(args).reduce((acc, key) => {
2806
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2807
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2808
+ return acc;
2809
+ }, {});
2810
+ };
2811
+
2718
2812
  /* */
2719
2813
 
2720
2814
  var confdMethods = (client , baseUrl ) => ({
@@ -2783,8 +2877,18 @@ var confdMethods = (client , baseUrl ) => ({
2783
2877
  getMyMeetings: () =>
2784
2878
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2785
2879
 
2786
- createMyMeeting: (name , persistent ) =>
2787
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2880
+ createMyMeeting: (args ) =>
2881
+ client
2882
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2883
+ .then(Meeting.parse),
2884
+
2885
+ updateMyMeeting: (meetingUuid , data ) =>
2886
+ client.put(
2887
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2888
+ convertKeysFromCamelToUnderscore(data),
2889
+ null,
2890
+ ApiRequester.successResponseParser,
2891
+ ),
2788
2892
 
2789
2893
  deleteMyMeeting: (meetingUuid ) =>
2790
2894
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2792,8 +2896,36 @@ var confdMethods = (client , baseUrl ) => ({
2792
2896
  getMeeting: (meetingUuid ) =>
2793
2897
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2794
2898
 
2899
+ meetingAuthorizations: (meetingUuid ) =>
2900
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2901
+
2902
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2903
+ client.put(
2904
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2905
+ {},
2906
+ null,
2907
+ ApiRequester.successResponseParser,
2908
+ ),
2909
+
2910
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2911
+ client.put(
2912
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2913
+ {},
2914
+ null,
2915
+ ApiRequester.successResponseParser,
2916
+ ),
2917
+
2795
2918
  guestGetMeeting: (meetingUuid ) =>
2796
2919
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2920
+
2921
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2922
+ client
2923
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2924
+ .then(MeetingAuthorization.parse),
2925
+
2926
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2927
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2928
+
2797
2929
  });
2798
2930
 
2799
2931
  //
@@ -3059,6 +3191,7 @@ const RECORD_STATE_ACTIVE = 'active';
3059
3191
 
3060
3192
 
3061
3193
 
3194
+
3062
3195
 
3063
3196
 
3064
3197
 
@@ -3069,6 +3202,7 @@ const RECORD_STATE_ACTIVE = 'active';
3069
3202
 
3070
3203
 
3071
3204
 
3205
+
3072
3206
 
3073
3207
 
3074
3208
 
@@ -3097,6 +3231,7 @@ class Call {
3097
3231
 
3098
3232
 
3099
3233
 
3234
+
3100
3235
 
3101
3236
 
3102
3237
 
@@ -3121,6 +3256,7 @@ class Call {
3121
3256
  calleeNumber: plain.peer_caller_id_number,
3122
3257
  dialedExtension: plain.dialed_extension,
3123
3258
  isCaller: plain.is_caller,
3259
+ isVideo: plain.is_video,
3124
3260
  muted: plain.muted,
3125
3261
  onHold: plain.on_hold,
3126
3262
  status: plain.status,
@@ -3144,6 +3280,7 @@ class Call {
3144
3280
  calleeNumber,
3145
3281
  dialedExtension,
3146
3282
  isCaller,
3283
+ isVideo,
3147
3284
  lineId,
3148
3285
  muted,
3149
3286
  onHold,
@@ -3167,6 +3304,7 @@ class Call {
3167
3304
  this.startingTime = startingTime;
3168
3305
  this.talkingToIds = talkingToIds || [];
3169
3306
  this.recording = recording;
3307
+ this.isVideo = !!isVideo;
3170
3308
 
3171
3309
  // Useful to compare instead of instanceof with minified code
3172
3310
  this.type = 'Call';
@@ -4209,6 +4347,14 @@ var calldMethods = (client , baseUrl ) => ({
4209
4347
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4210
4348
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4211
4349
 
4350
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4351
+ client.delete(
4352
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4353
+ null,
4354
+ null,
4355
+ ApiRequester.successResponseParser,
4356
+ ),
4357
+
4212
4358
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4213
4359
 
4214
4360
  mute: (callId ) =>
@@ -19,6 +19,17 @@ var newFrom = (instance , ToClass ) => {
19
19
 
20
20
  //
21
21
 
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
22
33
 
23
34
 
24
35
 
@@ -29,6 +40,7 @@ var newFrom = (instance , ToClass ) => {
29
40
 
30
41
 
31
42
 
43
+
32
44
 
33
45
 
34
46
  class Meeting {
@@ -43,6 +55,8 @@ class Meeting {
43
55
 
44
56
 
45
57
 
58
+
59
+
46
60
 
47
61
  static parse(plain ) {
48
62
  return new Meeting({
@@ -55,6 +69,7 @@ class Meeting {
55
69
  extension: plain.exten,
56
70
  persistent: plain.persistent,
57
71
  creationTime: moment__default['default'](plain.creation_time).toDate(),
72
+ requireAuthorization: plain.require_authorization,
58
73
  });
59
74
  }
60
75
 
@@ -79,6 +94,7 @@ class Meeting {
79
94
  extension,
80
95
  persistent,
81
96
  creationTime,
97
+ requireAuthorization,
82
98
  } = {}) {
83
99
  this.guestSipAuthorization = guestSipAuthorization;
84
100
  this.uri = uri;
@@ -89,6 +105,7 @@ class Meeting {
89
105
  this.extension = extension;
90
106
  this.persistent = persistent;
91
107
  this.creationTime = creationTime;
108
+ this.requireAuthorization = requireAuthorization;
92
109
 
93
110
  // Useful to compare instead of instanceof with minified code
94
111
  this.type = 'Meeting';
@@ -99,6 +116,7 @@ class Meeting {
99
116
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
100
117
  return { username, secret };
101
118
  }
119
+
102
120
  }
103
121
 
104
122
  module.exports = Meeting;
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ //
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ const PENDING = 'pending';
16
+ const ACCEPTED = 'accepted';
17
+ const REJECTED = 'rejected';
18
+ const POST_PROCESSING = 'post_processing';
19
+ const POST_PROCESSED_SUCCESS = 'post_processed_success';
20
+ const POST_PROCESSED_ERROR = 'post_processed_error';
21
+
22
+ class MeetingAuthorization {
23
+
24
+
25
+
26
+
27
+
28
+
29
+ constructor({
30
+ meetingUuid,
31
+ uuid,
32
+ userUuid,
33
+ userName,
34
+ } = {}) {
35
+ this.meetingUuid = meetingUuid;
36
+ this.uuid = uuid;
37
+ this.userUuid = userUuid;
38
+ this.userName = userName;
39
+ }
40
+
41
+ setStatus(status ) {
42
+ this.status = status;
43
+ }
44
+
45
+ getStatus() {
46
+ return this.status;
47
+ }
48
+
49
+ static parse(plain ) {
50
+ const {
51
+ meeting_uuid: meetingUuid,
52
+ uuid,
53
+ guest_uuid: userUuid,
54
+ guest_name: userName,
55
+ } = plain;
56
+
57
+ return new MeetingAuthorization({
58
+ meetingUuid,
59
+ uuid,
60
+ userUuid,
61
+ userName,
62
+ });
63
+ }
64
+
65
+ static parseMany(items ) {
66
+ if (!items) {
67
+ return [];
68
+ }
69
+ return items.map(MeetingAuthorization.parse);
70
+ }
71
+ }
72
+
73
+ exports.ACCEPTED = ACCEPTED;
74
+ exports.PENDING = PENDING;
75
+ exports.POST_PROCESSED_ERROR = POST_PROCESSED_ERROR;
76
+ exports.POST_PROCESSED_SUCCESS = POST_PROCESSED_SUCCESS;
77
+ exports.POST_PROCESSING = POST_PROCESSING;
78
+ exports.REJECTED = REJECTED;
79
+ exports.default = MeetingAuthorization;
@@ -1522,6 +1522,7 @@ const RECORD_STATE_ACTIVE = 'active';
1522
1522
 
1523
1523
 
1524
1524
 
1525
+
1525
1526
 
1526
1527
 
1527
1528
 
@@ -1532,6 +1533,7 @@ const RECORD_STATE_ACTIVE = 'active';
1532
1533
 
1533
1534
 
1534
1535
 
1536
+
1535
1537
 
1536
1538
 
1537
1539
 
@@ -1560,6 +1562,7 @@ class Call {
1560
1562
 
1561
1563
 
1562
1564
 
1565
+
1563
1566
 
1564
1567
 
1565
1568
 
@@ -1584,6 +1587,7 @@ class Call {
1584
1587
  calleeNumber: plain.peer_caller_id_number,
1585
1588
  dialedExtension: plain.dialed_extension,
1586
1589
  isCaller: plain.is_caller,
1590
+ isVideo: plain.is_video,
1587
1591
  muted: plain.muted,
1588
1592
  onHold: plain.on_hold,
1589
1593
  status: plain.status,
@@ -1607,6 +1611,7 @@ class Call {
1607
1611
  calleeNumber,
1608
1612
  dialedExtension,
1609
1613
  isCaller,
1614
+ isVideo,
1610
1615
  lineId,
1611
1616
  muted,
1612
1617
  onHold,
@@ -1630,6 +1635,7 @@ class Call {
1630
1635
  this.startingTime = startingTime;
1631
1636
  this.talkingToIds = talkingToIds || [];
1632
1637
  this.recording = recording;
1638
+ this.isVideo = !!isVideo;
1633
1639
 
1634
1640
  // Useful to compare instead of instanceof with minified code
1635
1641
  this.type = 'Call';
@@ -2103,7 +2109,7 @@ class CallSession {
2103
2109
  ringing: call.isRinging(),
2104
2110
  answered: call.isUp(),
2105
2111
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
2106
- cameraEnabled: false,
2112
+ cameraEnabled: call.isVideo,
2107
2113
  dialedExtension: call.dialedExtension,
2108
2114
  call,
2109
2115
  conference: false, // @FIXME?
@@ -3594,6 +3600,70 @@ class ExternalApp {
3594
3600
 
3595
3601
  //
3596
3602
 
3603
+ class MeetingAuthorization {
3604
+
3605
+
3606
+
3607
+
3608
+
3609
+
3610
+ constructor({
3611
+ meetingUuid,
3612
+ uuid,
3613
+ userUuid,
3614
+ userName,
3615
+ } = {}) {
3616
+ this.meetingUuid = meetingUuid;
3617
+ this.uuid = uuid;
3618
+ this.userUuid = userUuid;
3619
+ this.userName = userName;
3620
+ }
3621
+
3622
+ setStatus(status ) {
3623
+ this.status = status;
3624
+ }
3625
+
3626
+ getStatus() {
3627
+ return this.status;
3628
+ }
3629
+
3630
+ static parse(plain ) {
3631
+ const {
3632
+ meeting_uuid: meetingUuid,
3633
+ uuid,
3634
+ guest_uuid: userUuid,
3635
+ guest_name: userName,
3636
+ } = plain;
3637
+
3638
+ return new MeetingAuthorization({
3639
+ meetingUuid,
3640
+ uuid,
3641
+ userUuid,
3642
+ userName,
3643
+ });
3644
+ }
3645
+
3646
+ static parseMany(items ) {
3647
+ if (!items) {
3648
+ return [];
3649
+ }
3650
+ return items.map(MeetingAuthorization.parse);
3651
+ }
3652
+ }
3653
+
3654
+ //
3655
+
3656
+
3657
+
3658
+
3659
+
3660
+
3661
+
3662
+
3663
+
3664
+
3665
+
3666
+
3597
3667
 
3598
3668
 
3599
3669
 
@@ -3604,6 +3674,7 @@ class ExternalApp {
3604
3674
 
3605
3675
 
3606
3676
 
3677
+
3607
3678
 
3608
3679
 
3609
3680
  class Meeting {
@@ -3618,6 +3689,8 @@ class Meeting {
3618
3689
 
3619
3690
 
3620
3691
 
3692
+
3693
+
3621
3694
 
3622
3695
  static parse(plain ) {
3623
3696
  return new Meeting({
@@ -3630,6 +3703,7 @@ class Meeting {
3630
3703
  extension: plain.exten,
3631
3704
  persistent: plain.persistent,
3632
3705
  creationTime: moment__default['default'](plain.creation_time).toDate(),
3706
+ requireAuthorization: plain.require_authorization,
3633
3707
  });
3634
3708
  }
3635
3709
 
@@ -3654,6 +3728,7 @@ class Meeting {
3654
3728
  extension,
3655
3729
  persistent,
3656
3730
  creationTime,
3731
+ requireAuthorization,
3657
3732
  } = {}) {
3658
3733
  this.guestSipAuthorization = guestSipAuthorization;
3659
3734
  this.uri = uri;
@@ -3664,6 +3739,7 @@ class Meeting {
3664
3739
  this.extension = extension;
3665
3740
  this.persistent = persistent;
3666
3741
  this.creationTime = creationTime;
3742
+ this.requireAuthorization = requireAuthorization;
3667
3743
 
3668
3744
  // Useful to compare instead of instanceof with minified code
3669
3745
  this.type = 'Meeting';
@@ -3674,8 +3750,32 @@ class Meeting {
3674
3750
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3675
3751
  return { username, secret };
3676
3752
  }
3753
+
3677
3754
  }
3678
3755
 
3756
+ //
3757
+
3758
+ const camelToUnderscore = (key ) => {
3759
+ if (typeof key !== 'string') {
3760
+ throw new Error('Input is not a string');
3761
+ }
3762
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3763
+ };
3764
+
3765
+ //
3766
+
3767
+ const convertKeysFromCamelToUnderscore = (args ) => {
3768
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3769
+ throw new Error('Input is not an object');
3770
+ }
3771
+
3772
+ return Object.keys(args).reduce((acc, key) => {
3773
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3774
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3775
+ return acc;
3776
+ }, {});
3777
+ };
3778
+
3679
3779
  /* */
3680
3780
 
3681
3781
  var confdMethods = (client , baseUrl ) => ({
@@ -3744,8 +3844,18 @@ var confdMethods = (client , baseUrl ) => ({
3744
3844
  getMyMeetings: () =>
3745
3845
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3746
3846
 
3747
- createMyMeeting: (name , persistent ) =>
3748
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3847
+ createMyMeeting: (args ) =>
3848
+ client
3849
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3850
+ .then(Meeting.parse),
3851
+
3852
+ updateMyMeeting: (meetingUuid , data ) =>
3853
+ client.put(
3854
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3855
+ convertKeysFromCamelToUnderscore(data),
3856
+ null,
3857
+ ApiRequester.successResponseParser,
3858
+ ),
3749
3859
 
3750
3860
  deleteMyMeeting: (meetingUuid ) =>
3751
3861
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3753,8 +3863,36 @@ var confdMethods = (client , baseUrl ) => ({
3753
3863
  getMeeting: (meetingUuid ) =>
3754
3864
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3755
3865
 
3866
+ meetingAuthorizations: (meetingUuid ) =>
3867
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3868
+
3869
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3870
+ client.put(
3871
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3872
+ {},
3873
+ null,
3874
+ ApiRequester.successResponseParser,
3875
+ ),
3876
+
3877
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3878
+ client.put(
3879
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3880
+ {},
3881
+ null,
3882
+ ApiRequester.successResponseParser,
3883
+ ),
3884
+
3756
3885
  guestGetMeeting: (meetingUuid ) =>
3757
3886
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3887
+
3888
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3889
+ client
3890
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3891
+ .then(MeetingAuthorization.parse),
3892
+
3893
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3894
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3895
+
3758
3896
  });
3759
3897
 
3760
3898
  //
@@ -4623,6 +4761,14 @@ var calldMethods = (client , baseUrl ) => ({
4623
4761
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4624
4762
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4625
4763
 
4764
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4765
+ client.delete(
4766
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4767
+ null,
4768
+ null,
4769
+ ApiRequester.successResponseParser,
4770
+ ),
4771
+
4626
4772
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4627
4773
 
4628
4774
  mute: (callId ) =>
@@ -445,7 +445,7 @@ class CallSession {
445
445
  ringing: call.isRinging(),
446
446
  answered: call.isUp(),
447
447
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
448
- cameraEnabled: false,
448
+ cameraEnabled: call.isVideo,
449
449
  dialedExtension: call.dialedExtension,
450
450
  call,
451
451
  conference: false, // @FIXME?
@@ -1579,10 +1579,10 @@ class WebRTCPhone extends Emitter {
1579
1579
  this.audioRingVolume = volume;
1580
1580
  }
1581
1581
 
1582
- changeAudioInputDevice(id ) {
1582
+ changeAudioInputDevice(id , force ) {
1583
1583
  logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
1584
1584
 
1585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
1585
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
1586
1586
  }
1587
1587
 
1588
1588
  changeVideoInputDevice(id ) {