@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
@@ -778,6 +778,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
778
778
  return fixed;
779
779
  };
780
780
 
781
+ const addIcesInAllBundles = (sdp ) => {
782
+ const parsedSdp = sdpParser.parse(sdp);
783
+
784
+ const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
785
+ if (!mediaWithCandidate) {
786
+ return sdp;
787
+ }
788
+
789
+ const { candidates } = mediaWithCandidate;
790
+
791
+ parsedSdp.media = parsedSdp.media.map(media => ({
792
+ ...media,
793
+ candidates: media.candidates || candidates,
794
+ }));
795
+
796
+ return sdpParser.write(parsedSdp);
797
+ };
798
+
781
799
  /* global RTCSessionDescriptionInit, navigator */
782
800
 
783
801
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
@@ -907,7 +925,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
907
925
 
908
926
  // Check if we got ICEs
909
927
  if (sdp.indexOf('a=candidate') !== -1) {
910
- return description;
928
+ return {
929
+ type: description.type,
930
+ sdp: addIcesInAllBundles(sdp),
931
+ };
911
932
  }
912
933
 
913
934
  wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
@@ -3181,6 +3202,70 @@ class ExternalApp {
3181
3202
 
3182
3203
  //
3183
3204
 
3205
+ class MeetingAuthorization {
3206
+
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+ constructor({
3213
+ meetingUuid,
3214
+ uuid,
3215
+ userUuid,
3216
+ userName,
3217
+ } = {}) {
3218
+ this.meetingUuid = meetingUuid;
3219
+ this.uuid = uuid;
3220
+ this.userUuid = userUuid;
3221
+ this.userName = userName;
3222
+ }
3223
+
3224
+ setStatus(status ) {
3225
+ this.status = status;
3226
+ }
3227
+
3228
+ getStatus() {
3229
+ return this.status;
3230
+ }
3231
+
3232
+ static parse(plain ) {
3233
+ const {
3234
+ meeting_uuid: meetingUuid,
3235
+ uuid,
3236
+ guest_uuid: userUuid,
3237
+ guest_name: userName,
3238
+ } = plain;
3239
+
3240
+ return new MeetingAuthorization({
3241
+ meetingUuid,
3242
+ uuid,
3243
+ userUuid,
3244
+ userName,
3245
+ });
3246
+ }
3247
+
3248
+ static parseMany(items ) {
3249
+ if (!items) {
3250
+ return [];
3251
+ }
3252
+ return items.map(MeetingAuthorization.parse);
3253
+ }
3254
+ }
3255
+
3256
+ //
3257
+
3258
+
3259
+
3260
+
3261
+
3262
+
3263
+
3264
+
3265
+
3266
+
3267
+
3268
+
3184
3269
 
3185
3270
 
3186
3271
 
@@ -3191,6 +3276,7 @@ class ExternalApp {
3191
3276
 
3192
3277
 
3193
3278
 
3279
+
3194
3280
 
3195
3281
 
3196
3282
  class Meeting {
@@ -3205,6 +3291,8 @@ class Meeting {
3205
3291
 
3206
3292
 
3207
3293
 
3294
+
3295
+
3208
3296
 
3209
3297
  static parse(plain ) {
3210
3298
  return new Meeting({
@@ -3217,6 +3305,7 @@ class Meeting {
3217
3305
  extension: plain.exten,
3218
3306
  persistent: plain.persistent,
3219
3307
  creationTime: moment(plain.creation_time).toDate(),
3308
+ requireAuthorization: plain.require_authorization,
3220
3309
  });
3221
3310
  }
3222
3311
 
@@ -3241,6 +3330,7 @@ class Meeting {
3241
3330
  extension,
3242
3331
  persistent,
3243
3332
  creationTime,
3333
+ requireAuthorization,
3244
3334
  } = {}) {
3245
3335
  this.guestSipAuthorization = guestSipAuthorization;
3246
3336
  this.uri = uri;
@@ -3251,6 +3341,7 @@ class Meeting {
3251
3341
  this.extension = extension;
3252
3342
  this.persistent = persistent;
3253
3343
  this.creationTime = creationTime;
3344
+ this.requireAuthorization = requireAuthorization;
3254
3345
 
3255
3346
  // Useful to compare instead of instanceof with minified code
3256
3347
  this.type = 'Meeting';
@@ -3261,8 +3352,32 @@ class Meeting {
3261
3352
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3262
3353
  return { username, secret };
3263
3354
  }
3355
+
3264
3356
  }
3265
3357
 
3358
+ //
3359
+
3360
+ const camelToUnderscore = (key ) => {
3361
+ if (typeof key !== 'string') {
3362
+ throw new Error('Input is not a string');
3363
+ }
3364
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3365
+ };
3366
+
3367
+ //
3368
+
3369
+ const convertKeysFromCamelToUnderscore = (args ) => {
3370
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3371
+ throw new Error('Input is not an object');
3372
+ }
3373
+
3374
+ return Object.keys(args).reduce((acc, key) => {
3375
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3376
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3377
+ return acc;
3378
+ }, {});
3379
+ };
3380
+
3266
3381
  /* */
3267
3382
 
3268
3383
  var confdMethods = (client , baseUrl ) => ({
@@ -3331,8 +3446,18 @@ var confdMethods = (client , baseUrl ) => ({
3331
3446
  getMyMeetings: () =>
3332
3447
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3333
3448
 
3334
- createMyMeeting: (name , persistent ) =>
3335
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3449
+ createMyMeeting: (args ) =>
3450
+ client
3451
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3452
+ .then(Meeting.parse),
3453
+
3454
+ updateMyMeeting: (meetingUuid , data ) =>
3455
+ client.put(
3456
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3457
+ convertKeysFromCamelToUnderscore(data),
3458
+ null,
3459
+ ApiRequester.successResponseParser,
3460
+ ),
3336
3461
 
3337
3462
  deleteMyMeeting: (meetingUuid ) =>
3338
3463
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3340,8 +3465,36 @@ var confdMethods = (client , baseUrl ) => ({
3340
3465
  getMeeting: (meetingUuid ) =>
3341
3466
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3342
3467
 
3468
+ meetingAuthorizations: (meetingUuid ) =>
3469
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3470
+
3471
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3472
+ client.put(
3473
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3474
+ {},
3475
+ null,
3476
+ ApiRequester.successResponseParser,
3477
+ ),
3478
+
3479
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3480
+ client.put(
3481
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3482
+ {},
3483
+ null,
3484
+ ApiRequester.successResponseParser,
3485
+ ),
3486
+
3343
3487
  guestGetMeeting: (meetingUuid ) =>
3344
3488
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3489
+
3490
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3491
+ client
3492
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3493
+ .then(MeetingAuthorization.parse),
3494
+
3495
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3496
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3497
+
3345
3498
  });
3346
3499
 
3347
3500
  //
@@ -3607,6 +3760,7 @@ const RECORD_STATE_ACTIVE = 'active';
3607
3760
 
3608
3761
 
3609
3762
 
3763
+
3610
3764
 
3611
3765
 
3612
3766
 
@@ -3617,6 +3771,7 @@ const RECORD_STATE_ACTIVE = 'active';
3617
3771
 
3618
3772
 
3619
3773
 
3774
+
3620
3775
 
3621
3776
 
3622
3777
 
@@ -3645,6 +3800,7 @@ class Call {
3645
3800
 
3646
3801
 
3647
3802
 
3803
+
3648
3804
 
3649
3805
 
3650
3806
 
@@ -3669,6 +3825,7 @@ class Call {
3669
3825
  calleeNumber: plain.peer_caller_id_number,
3670
3826
  dialedExtension: plain.dialed_extension,
3671
3827
  isCaller: plain.is_caller,
3828
+ isVideo: plain.is_video,
3672
3829
  muted: plain.muted,
3673
3830
  onHold: plain.on_hold,
3674
3831
  status: plain.status,
@@ -3692,6 +3849,7 @@ class Call {
3692
3849
  calleeNumber,
3693
3850
  dialedExtension,
3694
3851
  isCaller,
3852
+ isVideo,
3695
3853
  lineId,
3696
3854
  muted,
3697
3855
  onHold,
@@ -3715,6 +3873,7 @@ class Call {
3715
3873
  this.startingTime = startingTime;
3716
3874
  this.talkingToIds = talkingToIds || [];
3717
3875
  this.recording = recording;
3876
+ this.isVideo = !!isVideo;
3718
3877
 
3719
3878
  // Useful to compare instead of instanceof with minified code
3720
3879
  this.type = 'Call';
@@ -4774,6 +4933,14 @@ var calldMethods = (client , baseUrl ) => ({
4774
4933
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4775
4934
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4776
4935
 
4936
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4937
+ client.delete(
4938
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4939
+ null,
4940
+ null,
4941
+ ApiRequester.successResponseParser,
4942
+ ),
4943
+
4777
4944
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4778
4945
 
4779
4946
  mute: (callId ) =>
@@ -6414,41 +6581,58 @@ class WebRTCClient extends Emitter {
6414
6581
  });
6415
6582
  }
6416
6583
 
6417
- changeAudioInputDevice(id , session ) {
6584
+ async changeAudioInputDevice(id , session , force ) {
6418
6585
  const currentId = this.getAudioDeviceId();
6419
6586
  logger.info('setting audio input device', { id, currentId, session: !!session });
6420
6587
 
6421
- if (id === currentId) {
6588
+ if (!force && id === currentId) {
6422
6589
  return null;
6423
6590
  }
6424
6591
 
6592
+ // in order to handle an audio track change for default devices
6593
+ // we need the actual id of the device (not 'default')
6594
+ let deviceId = id;
6595
+ if (id === 'default' && navigator.mediaDevices) {
6596
+ const devices = await navigator.mediaDevices.enumerateDevices();
6597
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
6598
+ if (defaultDevice) {
6599
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
6600
+ const targetDevice = devices.find(device => device.label === deviceLabel);
6601
+ if (targetDevice) {
6602
+ deviceId = targetDevice.deviceId;
6603
+ if (!force && deviceId === currentId) {
6604
+ return null;
6605
+ }
6606
+ }
6607
+ }
6608
+ }
6609
+
6425
6610
  // let's update the local audio value
6426
6611
  if (this.audio) {
6427
6612
  this.audio = {
6428
6613
  deviceId: {
6429
- exact: id,
6614
+ exact: deviceId,
6430
6615
  },
6431
6616
  };
6432
6617
  }
6433
6618
 
6434
- if (session) {
6619
+ if (session && navigator.mediaDevices) {
6435
6620
  const sdh = session.sessionDescriptionHandler;
6436
6621
  const pc = sdh.peerConnection;
6437
6622
 
6438
- // $FlowFixMe
6439
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
6440
- const audioTrack = stream.getAudioTracks()[0];
6441
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6623
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
6624
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
6625
+ const audioTrack = stream.getAudioTracks()[0];
6626
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6442
6627
 
6443
- if (sender) {
6444
- if (sender.track) {
6445
- audioTrack.enabled = sender.track.enabled;
6446
- }
6447
- sender.replaceTrack(audioTrack);
6628
+ if (sender) {
6629
+ if (sender.track) {
6630
+ audioTrack.enabled = sender.track.enabled;
6448
6631
  }
6632
+ sender.replaceTrack(audioTrack);
6633
+ }
6449
6634
 
6450
- return stream;
6451
- });
6635
+ return stream;
6452
6636
  }
6453
6637
  }
6454
6638
 
@@ -6468,14 +6652,14 @@ class WebRTCClient extends Emitter {
6468
6652
  return null;
6469
6653
  }
6470
6654
 
6471
- // let's update the local video value
6472
- if (this.video) {
6473
- this.video = {
6474
- deviceId: {
6475
- exact: id,
6476
- },
6477
- };
6478
- }
6655
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
6656
+ const videoObject = typeof this.video === 'object' ? this.video : {};
6657
+ this.video = {
6658
+ ...videoObject,
6659
+ deviceId: {
6660
+ exact: id,
6661
+ },
6662
+ };
6479
6663
  }
6480
6664
 
6481
6665
  changeSessionVideoInputDevice(id , session ) {
@@ -7602,3 +7786,96 @@ describe('WebRTC client', () => {
7602
7786
  expect(client.isAudioMuted(oldKindUnmuted)).toBeFalsy();
7603
7787
  });
7604
7788
  });
7789
+
7790
+ describe('changeAudioInputDevice', () => {
7791
+ const defaultId = 'default';
7792
+ const deviceId = 'device1';
7793
+ const constraints = { audio: { deviceId: { exact: defaultId } }, video: null };
7794
+
7795
+ const session = {
7796
+ sessionDescriptionHandler: {
7797
+ peerConnection: {
7798
+ getSenders: () => [{ track: { kind: 'audio', enabled: true } }],
7799
+ },
7800
+ },
7801
+ };
7802
+
7803
+ const stream = {};
7804
+ const getAudioTracksMock = jest.fn(() => []);
7805
+ Object.defineProperty(stream, 'getAudioTracks', {
7806
+ value: getAudioTracksMock,
7807
+ });
7808
+
7809
+ const getUserMediaMock = jest.fn(async () => {
7810
+ return new Promise(resolve => {
7811
+ resolve(stream);
7812
+ });
7813
+ });
7814
+
7815
+ const devices = [
7816
+ { deviceId: 'default', kind: 'audioinput', label: 'Default - Fake Microphone', groupId: 'fak3Gr0up3' },
7817
+ { deviceId: 'fak3d3v1c3', kind: 'audioinput', label: 'Fake Microphone', groupId: 'fak3Gr0up3' },
7818
+ ];
7819
+ const enumerateDevicesMock = jest.fn(async () => {
7820
+ return new Promise(resolve => {
7821
+ resolve(devices);
7822
+ });
7823
+ });
7824
+
7825
+ Object.defineProperty(global.navigator, 'mediaDevices', {
7826
+ value: {
7827
+ getUserMedia: getUserMediaMock,
7828
+ enumerateDevices: enumerateDevicesMock,
7829
+ },
7830
+ });
7831
+
7832
+ it('should change the audio input track if the provided id is different', async () => {
7833
+ client.setMediaConstraints(constraints);
7834
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7835
+ const result = await client.changeAudioInputDevice(deviceId, session);
7836
+ expect(result).toBeTruthy();
7837
+ });
7838
+
7839
+ it('should NOT change the audio input track if the provided id is the same', async () => {
7840
+ client.setMediaConstraints(constraints);
7841
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7842
+ const result = await client.changeAudioInputDevice(defaultId, session);
7843
+ expect(result).toBeFalsy();
7844
+ });
7845
+
7846
+ it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
7847
+ client.setMediaConstraints(constraints);
7848
+ expect(client.getAudioDeviceId()).toBe(defaultId);
7849
+ const result = await client.changeAudioInputDevice(defaultId, session, true);
7850
+ expect(result).toBeTruthy();
7851
+ });
7852
+
7853
+ describe('setVideoInputDevice', () => {
7854
+ it('should retain its original video values', () => {
7855
+ const video = { height: { min: 480, max: 720 }, width: { min: 640, max: 1280 } };
7856
+
7857
+ client.video = video;
7858
+ client.setVideoInputDevice(deviceId);
7859
+ expect(client.video).toEqual({ ...video, deviceId: { exact: deviceId } });
7860
+ });
7861
+
7862
+ it('should set deviceId when video\'s original value is true', () => {
7863
+ client.video = true;
7864
+ client.setVideoInputDevice(deviceId);
7865
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7866
+ });
7867
+
7868
+ it('should set deviceId when video\'s original value is not set', () => {
7869
+ client.video = undefined;
7870
+ client.setVideoInputDevice(deviceId);
7871
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7872
+ });
7873
+
7874
+ it('should NOT set deviceId when its value does not change', () => {
7875
+ client.video = { deviceId: { exact: deviceId } };
7876
+ const result = client.setVideoInputDevice(deviceId);
7877
+ expect(result).toEqual(null);
7878
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7879
+ });
7880
+ });
7881
+ });
package/esm/api/calld.js CHANGED
@@ -968,6 +968,7 @@ const RECORD_STATE_ACTIVE = 'active';
968
968
 
969
969
 
970
970
 
971
+
971
972
 
972
973
 
973
974
 
@@ -978,6 +979,7 @@ const RECORD_STATE_ACTIVE = 'active';
978
979
 
979
980
 
980
981
 
982
+
981
983
 
982
984
 
983
985
 
@@ -1006,6 +1008,7 @@ class Call {
1006
1008
 
1007
1009
 
1008
1010
 
1011
+
1009
1012
 
1010
1013
 
1011
1014
 
@@ -1030,6 +1033,7 @@ class Call {
1030
1033
  calleeNumber: plain.peer_caller_id_number,
1031
1034
  dialedExtension: plain.dialed_extension,
1032
1035
  isCaller: plain.is_caller,
1036
+ isVideo: plain.is_video,
1033
1037
  muted: plain.muted,
1034
1038
  onHold: plain.on_hold,
1035
1039
  status: plain.status,
@@ -1053,6 +1057,7 @@ class Call {
1053
1057
  calleeNumber,
1054
1058
  dialedExtension,
1055
1059
  isCaller,
1060
+ isVideo,
1056
1061
  lineId,
1057
1062
  muted,
1058
1063
  onHold,
@@ -1076,6 +1081,7 @@ class Call {
1076
1081
  this.startingTime = startingTime;
1077
1082
  this.talkingToIds = talkingToIds || [];
1078
1083
  this.recording = recording;
1084
+ this.isVideo = !!isVideo;
1079
1085
 
1080
1086
  // Useful to compare instead of instanceof with minified code
1081
1087
  this.type = 'Call';
@@ -1389,6 +1395,14 @@ var calld = (client , baseUrl ) => ({
1389
1395
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
1390
1396
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
1391
1397
 
1398
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
1399
+ client.delete(
1400
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
1401
+ null,
1402
+ null,
1403
+ ApiRequester.successResponseParser,
1404
+ ),
1405
+
1392
1406
  listTrunks: () => client.get(`${baseUrl}/trunks`),
1393
1407
 
1394
1408
  mute: (callId ) =>