@wazo/sdk 0.38.7 → 0.38.10

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 (121) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +163 -2
  3. package/esm/__tests__/web-rtc-client.test.js +248 -27
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/calld.js +8 -0
  6. package/esm/api/confd.js +134 -2
  7. package/esm/api/ctid-ng.js +1 -0
  8. package/esm/api-client.js +163 -2
  9. package/esm/checker/Checker.js +204 -24
  10. package/esm/checker/checks/aor.js +163 -2
  11. package/esm/checker/checks/api.js +163 -2
  12. package/esm/checker/checks/index.js +204 -24
  13. package/esm/checker/checks/wazo-websocket.js +2 -0
  14. package/esm/checker/checks/webrtc-transport.js +202 -24
  15. package/esm/checker/checks/webrtc.js +202 -24
  16. package/esm/domain/AdHocAPIConference.js +170 -4
  17. package/esm/domain/Features.js +170 -4
  18. package/esm/domain/Meeting.js +18 -0
  19. package/esm/domain/MeetingAuthorization.js +70 -0
  20. package/esm/domain/Phone/CTIPhone.js +170 -4
  21. package/esm/domain/Phone/WebRTCPhone.js +2 -3
  22. package/esm/domain/__tests__/Meeting.test.js +87 -1
  23. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  24. package/esm/index.js +300 -36
  25. package/esm/service/CallApi.js +170 -4
  26. package/esm/service/getApiClient.js +176 -5
  27. package/esm/simple/Auth.js +301 -37
  28. package/esm/simple/Configuration.js +300 -36
  29. package/esm/simple/Directory.js +170 -4
  30. package/esm/simple/Phone.js +300 -36
  31. package/esm/simple/Softphone.js +5 -0
  32. package/esm/simple/Websocket.js +3 -0
  33. package/esm/simple/index.js +300 -36
  34. package/esm/simple/room/LocalParticipant.js +300 -36
  35. package/esm/simple/room/Participant.js +300 -36
  36. package/esm/simple/room/RemoteParticipant.js +300 -36
  37. package/esm/simple/room/Room.js +300 -36
  38. package/esm/simple/room/SipRoom.js +300 -36
  39. package/esm/simple/room/Stream.js +300 -36
  40. package/esm/simple/room/__tests__/Participant.test.js +14812 -0
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  42. package/esm/simple/utils.js +300 -36
  43. package/esm/utils/__tests__/object.test.js +57 -0
  44. package/esm/utils/__tests__/string.test.js +30 -0
  45. package/esm/utils/object.js +24 -0
  46. package/esm/utils/string.js +10 -0
  47. package/esm/web-rtc-client.js +202 -24
  48. package/esm/websocket-client.js +3 -1
  49. package/lib/__tests__/api-client.test.js +163 -2
  50. package/lib/__tests__/web-rtc-client.test.js +248 -27
  51. package/lib/api/auth.js +12 -0
  52. package/lib/api/calld.js +8 -0
  53. package/lib/api/confd.js +134 -2
  54. package/lib/api/ctid-ng.js +1 -0
  55. package/lib/api-client.js +163 -2
  56. package/lib/checker/Checker.js +204 -24
  57. package/lib/checker/checks/aor.js +163 -2
  58. package/lib/checker/checks/api.js +163 -2
  59. package/lib/checker/checks/index.js +204 -24
  60. package/lib/checker/checks/wazo-websocket.js +2 -0
  61. package/lib/checker/checks/webrtc-transport.js +202 -24
  62. package/lib/checker/checks/webrtc.js +202 -24
  63. package/lib/domain/AdHocAPIConference.js +170 -4
  64. package/lib/domain/Features.js +170 -4
  65. package/lib/domain/Meeting.js +18 -0
  66. package/lib/domain/MeetingAuthorization.js +79 -0
  67. package/lib/domain/Phone/CTIPhone.js +170 -4
  68. package/lib/domain/Phone/WebRTCPhone.js +2 -3
  69. package/lib/domain/__tests__/Meeting.test.js +87 -1
  70. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  71. package/lib/index.js +300 -36
  72. package/lib/service/CallApi.js +170 -4
  73. package/lib/service/getApiClient.js +176 -4
  74. package/lib/simple/Auth.js +301 -36
  75. package/lib/simple/Configuration.js +300 -36
  76. package/lib/simple/Directory.js +170 -4
  77. package/lib/simple/Phone.js +300 -36
  78. package/lib/simple/Softphone.js +5 -0
  79. package/lib/simple/Websocket.js +3 -0
  80. package/lib/simple/index.js +300 -36
  81. package/lib/simple/room/LocalParticipant.js +300 -36
  82. package/lib/simple/room/Participant.js +300 -36
  83. package/lib/simple/room/RemoteParticipant.js +300 -36
  84. package/lib/simple/room/Room.js +300 -36
  85. package/lib/simple/room/SipRoom.js +300 -36
  86. package/lib/simple/room/Stream.js +300 -36
  87. package/lib/simple/room/__tests__/Participant.test.js +14822 -0
  88. package/lib/simple/room/__tests__/RemoteParticipant.test.js +300 -36
  89. package/lib/simple/utils.js +300 -36
  90. package/lib/utils/__tests__/object.test.js +59 -0
  91. package/lib/utils/__tests__/string.test.js +32 -0
  92. package/lib/utils/object.js +28 -0
  93. package/lib/utils/string.js +14 -0
  94. package/lib/web-rtc-client.js +202 -24
  95. package/lib/websocket-client.js +3 -0
  96. package/package.json +1 -1
  97. package/src/__tests__/web-rtc-client.test.js +46 -3
  98. package/src/api/auth.js +12 -0
  99. package/src/api/calld.js +8 -0
  100. package/src/api/confd.js +43 -2
  101. package/src/api-client.js +8 -0
  102. package/src/domain/Meeting.js +20 -0
  103. package/src/domain/MeetingAuthorization.js +67 -0
  104. package/src/domain/Phone/WebRTCPhone.js +1 -3
  105. package/src/domain/__tests__/Meeting.test.js +70 -1
  106. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  107. package/src/service/getApiClient.js +13 -2
  108. package/src/simple/Auth.js +35 -4
  109. package/src/simple/Softphone.js +5 -0
  110. package/src/simple/index.js +2 -1
  111. package/src/simple/room/Participant.js +40 -0
  112. package/src/simple/room/Room.js +2 -2
  113. package/src/simple/room/SipRoom.js +1 -1
  114. package/src/simple/room/__tests__/Participant.test.js +81 -0
  115. package/src/types/WebSocketMessage.js +7 -1
  116. package/src/utils/__tests__/object.test.js +35 -0
  117. package/src/utils/__tests__/string.test.js +23 -0
  118. package/src/utils/object.js +15 -0
  119. package/src/utils/string.js +8 -0
  120. package/src/web-rtc-client.js +39 -22
  121. package/src/websocket-client.js +2 -0
@@ -2786,6 +2786,7 @@ var authMethods = (client , baseUrl ) => ({
2786
2786
 
2787
2787
 
2788
2788
 
2789
+
2789
2790
  ) {
2790
2791
  const body = {
2791
2792
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2806,9 +2807,14 @@ var authMethods = (client , baseUrl ) => ({
2806
2807
  }
2807
2808
 
2808
2809
  if (params.tenantId) {
2810
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2809
2811
  body.tenant_id = params.tenantId;
2810
2812
  }
2811
2813
 
2814
+ if (params.domainName) {
2815
+ body.domain_name = params.domainName;
2816
+ }
2817
+
2812
2818
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2813
2819
  },
2814
2820
 
@@ -2821,6 +2827,7 @@ var authMethods = (client , baseUrl ) => ({
2821
2827
  expiration ,
2822
2828
  isMobile = false,
2823
2829
  tenantId ,
2830
+ domainName ,
2824
2831
  ) => {
2825
2832
  const body = {
2826
2833
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2830,9 +2837,14 @@ var authMethods = (client , baseUrl ) => ({
2830
2837
  };
2831
2838
 
2832
2839
  if (tenantId) {
2840
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2833
2841
  body.tenant_id = tenantId;
2834
2842
  }
2835
2843
 
2844
+ if (domainName) {
2845
+ body.domain_name = domainName;
2846
+ }
2847
+
2836
2848
  const headers = {
2837
2849
  'Content-Type': 'application/json',
2838
2850
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -3202,6 +3214,70 @@ class ExternalApp {
3202
3214
 
3203
3215
  //
3204
3216
 
3217
+ class MeetingAuthorization {
3218
+
3219
+
3220
+
3221
+
3222
+
3223
+
3224
+ constructor({
3225
+ meetingUuid,
3226
+ uuid,
3227
+ userUuid,
3228
+ userName,
3229
+ } = {}) {
3230
+ this.meetingUuid = meetingUuid;
3231
+ this.uuid = uuid;
3232
+ this.userUuid = userUuid;
3233
+ this.userName = userName;
3234
+ }
3235
+
3236
+ setStatus(status ) {
3237
+ this.status = status;
3238
+ }
3239
+
3240
+ getStatus() {
3241
+ return this.status;
3242
+ }
3243
+
3244
+ static parse(plain ) {
3245
+ const {
3246
+ meeting_uuid: meetingUuid,
3247
+ uuid,
3248
+ guest_uuid: userUuid,
3249
+ guest_name: userName,
3250
+ } = plain;
3251
+
3252
+ return new MeetingAuthorization({
3253
+ meetingUuid,
3254
+ uuid,
3255
+ userUuid,
3256
+ userName,
3257
+ });
3258
+ }
3259
+
3260
+ static parseMany(items ) {
3261
+ if (!items) {
3262
+ return [];
3263
+ }
3264
+ return items.map(MeetingAuthorization.parse);
3265
+ }
3266
+ }
3267
+
3268
+ //
3269
+
3270
+
3271
+
3272
+
3273
+
3274
+
3275
+
3276
+
3277
+
3278
+
3279
+
3280
+
3205
3281
 
3206
3282
 
3207
3283
 
@@ -3212,6 +3288,7 @@ class ExternalApp {
3212
3288
 
3213
3289
 
3214
3290
 
3291
+
3215
3292
 
3216
3293
 
3217
3294
  class Meeting {
@@ -3226,6 +3303,8 @@ class Meeting {
3226
3303
 
3227
3304
 
3228
3305
 
3306
+
3307
+
3229
3308
 
3230
3309
  static parse(plain ) {
3231
3310
  return new Meeting({
@@ -3238,6 +3317,7 @@ class Meeting {
3238
3317
  extension: plain.exten,
3239
3318
  persistent: plain.persistent,
3240
3319
  creationTime: moment(plain.creation_time).toDate(),
3320
+ requireAuthorization: plain.require_authorization,
3241
3321
  });
3242
3322
  }
3243
3323
 
@@ -3262,6 +3342,7 @@ class Meeting {
3262
3342
  extension,
3263
3343
  persistent,
3264
3344
  creationTime,
3345
+ requireAuthorization,
3265
3346
  } = {}) {
3266
3347
  this.guestSipAuthorization = guestSipAuthorization;
3267
3348
  this.uri = uri;
@@ -3272,6 +3353,7 @@ class Meeting {
3272
3353
  this.extension = extension;
3273
3354
  this.persistent = persistent;
3274
3355
  this.creationTime = creationTime;
3356
+ this.requireAuthorization = requireAuthorization;
3275
3357
 
3276
3358
  // Useful to compare instead of instanceof with minified code
3277
3359
  this.type = 'Meeting';
@@ -3282,8 +3364,32 @@ class Meeting {
3282
3364
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3283
3365
  return { username, secret };
3284
3366
  }
3367
+
3285
3368
  }
3286
3369
 
3370
+ //
3371
+
3372
+ const camelToUnderscore = (key ) => {
3373
+ if (typeof key !== 'string') {
3374
+ throw new Error('Input is not a string');
3375
+ }
3376
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3377
+ };
3378
+
3379
+ //
3380
+
3381
+ const convertKeysFromCamelToUnderscore = (args ) => {
3382
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3383
+ throw new Error('Input is not an object');
3384
+ }
3385
+
3386
+ return Object.keys(args).reduce((acc, key) => {
3387
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3388
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3389
+ return acc;
3390
+ }, {});
3391
+ };
3392
+
3287
3393
  /* */
3288
3394
 
3289
3395
  var confdMethods = (client , baseUrl ) => ({
@@ -3352,8 +3458,18 @@ var confdMethods = (client , baseUrl ) => ({
3352
3458
  getMyMeetings: () =>
3353
3459
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3354
3460
 
3355
- createMyMeeting: (name , persistent ) =>
3356
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3461
+ createMyMeeting: (args ) =>
3462
+ client
3463
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3464
+ .then(Meeting.parse),
3465
+
3466
+ updateMyMeeting: (meetingUuid , data ) =>
3467
+ client.put(
3468
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3469
+ convertKeysFromCamelToUnderscore(data),
3470
+ null,
3471
+ ApiRequester.successResponseParser,
3472
+ ),
3357
3473
 
3358
3474
  deleteMyMeeting: (meetingUuid ) =>
3359
3475
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3361,8 +3477,36 @@ var confdMethods = (client , baseUrl ) => ({
3361
3477
  getMeeting: (meetingUuid ) =>
3362
3478
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3363
3479
 
3480
+ meetingAuthorizations: (meetingUuid ) =>
3481
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3482
+
3483
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3484
+ client.put(
3485
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3486
+ {},
3487
+ null,
3488
+ ApiRequester.successResponseParser,
3489
+ ),
3490
+
3491
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3492
+ client.put(
3493
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3494
+ {},
3495
+ null,
3496
+ ApiRequester.successResponseParser,
3497
+ ),
3498
+
3364
3499
  guestGetMeeting: (meetingUuid ) =>
3365
3500
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3501
+
3502
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3503
+ client
3504
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3505
+ .then(MeetingAuthorization.parse),
3506
+
3507
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3508
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3509
+
3366
3510
  });
3367
3511
 
3368
3512
  //
@@ -4127,6 +4271,7 @@ global.wazoClientId = global.wazoClientId || {};
4127
4271
  global.wazoClientToken = global.wazoClientToken || {};
4128
4272
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4129
4273
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4274
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4130
4275
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4131
4276
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4132
4277
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4801,6 +4946,14 @@ var calldMethods = (client , baseUrl ) => ({
4801
4946
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4802
4947
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4803
4948
 
4949
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4950
+ client.delete(
4951
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4952
+ null,
4953
+ null,
4954
+ ApiRequester.successResponseParser,
4955
+ ),
4956
+
4804
4957
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4805
4958
 
4806
4959
  mute: (callId ) =>
@@ -5178,6 +5331,7 @@ class ApiClient {
5178
5331
 
5179
5332
 
5180
5333
 
5334
+
5181
5335
 
5182
5336
 
5183
5337
 
@@ -5219,6 +5373,7 @@ class ApiClient {
5219
5373
  refreshToken: this.refreshToken,
5220
5374
  refreshBackend: this.refreshBackend,
5221
5375
  refreshTenantId: this.refreshTenantId,
5376
+ refreshDomainName: this.refreshDomainName,
5222
5377
  refreshExpiration: this.refreshExpiration,
5223
5378
  isMobile: this.isMobile,
5224
5379
  });
@@ -5234,6 +5389,7 @@ class ApiClient {
5234
5389
  this.refreshExpiration,
5235
5390
  this.isMobile,
5236
5391
  this.refreshTenantId,
5392
+ this.refreshDomainName,
5237
5393
  );
5238
5394
 
5239
5395
  logger$1.info('token refreshed', { token: session.token });
@@ -5287,9 +5443,14 @@ class ApiClient {
5287
5443
  }
5288
5444
 
5289
5445
  setRefreshTenantId(tenantId ) {
5446
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5290
5447
  this.refreshTenantId = tenantId;
5291
5448
  }
5292
5449
 
5450
+ setRefreshDomainName(domainName ) {
5451
+ this.refreshDomainName = domainName;
5452
+ }
5453
+
5293
5454
  setIsMobile(isMobile ) {
5294
5455
  this.isMobile = isMobile;
5295
5456
  }
@@ -6441,7 +6602,7 @@ class WebRTCClient extends Emitter {
6441
6602
  });
6442
6603
  }
6443
6604
 
6444
- changeAudioInputDevice(id , session , force ) {
6605
+ async changeAudioInputDevice(id , session , force ) {
6445
6606
  const currentId = this.getAudioDeviceId();
6446
6607
  logger.info('setting audio input device', { id, currentId, session: !!session });
6447
6608
 
@@ -6449,33 +6610,50 @@ class WebRTCClient extends Emitter {
6449
6610
  return null;
6450
6611
  }
6451
6612
 
6613
+ // in order to handle an audio track change for default devices
6614
+ // we need the actual id of the device (not 'default')
6615
+ let deviceId = id;
6616
+ if (id === 'default' && navigator.mediaDevices) {
6617
+ const devices = await navigator.mediaDevices.enumerateDevices();
6618
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
6619
+ if (defaultDevice) {
6620
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
6621
+ const targetDevice = devices.find(device => device.label === deviceLabel);
6622
+ if (targetDevice) {
6623
+ deviceId = targetDevice.deviceId;
6624
+ if (!force && deviceId === currentId) {
6625
+ return null;
6626
+ }
6627
+ }
6628
+ }
6629
+ }
6630
+
6452
6631
  // let's update the local audio value
6453
6632
  if (this.audio) {
6454
6633
  this.audio = {
6455
6634
  deviceId: {
6456
- exact: id,
6635
+ exact: deviceId,
6457
6636
  },
6458
6637
  };
6459
6638
  }
6460
6639
 
6461
- if (session) {
6640
+ if (session && navigator.mediaDevices) {
6462
6641
  const sdh = session.sessionDescriptionHandler;
6463
6642
  const pc = sdh.peerConnection;
6464
6643
 
6465
- // $FlowFixMe
6466
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
6467
- const audioTrack = stream.getAudioTracks()[0];
6468
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6644
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
6645
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
6646
+ const audioTrack = stream.getAudioTracks()[0];
6647
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
6469
6648
 
6470
- if (sender) {
6471
- if (sender.track) {
6472
- audioTrack.enabled = sender.track.enabled;
6473
- }
6474
- sender.replaceTrack(audioTrack);
6649
+ if (sender) {
6650
+ if (sender.track) {
6651
+ audioTrack.enabled = sender.track.enabled;
6475
6652
  }
6653
+ sender.replaceTrack(audioTrack);
6654
+ }
6476
6655
 
6477
- return stream;
6478
- });
6656
+ return stream;
6479
6657
  }
6480
6658
  }
6481
6659
 
@@ -6495,14 +6673,14 @@ class WebRTCClient extends Emitter {
6495
6673
  return null;
6496
6674
  }
6497
6675
 
6498
- // let's update the local video value
6499
- if (this.video) {
6500
- this.video = {
6501
- deviceId: {
6502
- exact: id,
6503
- },
6504
- };
6505
- }
6676
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
6677
+ const videoObject = typeof this.video === 'object' ? this.video : {};
6678
+ this.video = {
6679
+ ...videoObject,
6680
+ deviceId: {
6681
+ exact: id,
6682
+ },
6683
+ };
6506
6684
  }
6507
6685
 
6508
6686
  changeSessionVideoInputDevice(id , session ) {
@@ -7655,27 +7833,70 @@ describe('changeAudioInputDevice', () => {
7655
7833
  });
7656
7834
  });
7657
7835
 
7836
+ const devices = [
7837
+ { deviceId: 'default', kind: 'audioinput', label: 'Default - Fake Microphone', groupId: 'fak3Gr0up3' },
7838
+ { deviceId: 'fak3d3v1c3', kind: 'audioinput', label: 'Fake Microphone', groupId: 'fak3Gr0up3' },
7839
+ ];
7840
+ const enumerateDevicesMock = jest.fn(async () => {
7841
+ return new Promise(resolve => {
7842
+ resolve(devices);
7843
+ });
7844
+ });
7845
+
7658
7846
  Object.defineProperty(global.navigator, 'mediaDevices', {
7659
7847
  value: {
7660
7848
  getUserMedia: getUserMediaMock,
7849
+ enumerateDevices: enumerateDevicesMock,
7661
7850
  },
7662
7851
  });
7663
7852
 
7664
7853
  it('should change the audio input track if the provided id is different', async () => {
7665
7854
  client.setMediaConstraints(constraints);
7666
7855
  expect(client.getAudioDeviceId()).toBe(defaultId);
7667
- expect(client.changeAudioInputDevice(deviceId, session)).toBeTruthy();
7856
+ const result = await client.changeAudioInputDevice(deviceId, session);
7857
+ expect(result).toBeTruthy();
7668
7858
  });
7669
7859
 
7670
7860
  it('should NOT change the audio input track if the provided id is the same', async () => {
7671
7861
  client.setMediaConstraints(constraints);
7672
7862
  expect(client.getAudioDeviceId()).toBe(defaultId);
7673
- expect(client.changeAudioInputDevice(defaultId, session)).toBeFalsy();
7863
+ const result = await client.changeAudioInputDevice(defaultId, session);
7864
+ expect(result).toBeFalsy();
7674
7865
  });
7675
7866
 
7676
7867
  it('should change the audio input track if the provided id is the same and force param is TRUE', async () => {
7677
7868
  client.setMediaConstraints(constraints);
7678
7869
  expect(client.getAudioDeviceId()).toBe(defaultId);
7679
- expect(client.changeAudioInputDevice(defaultId, session, true)).toBeTruthy();
7870
+ const result = await client.changeAudioInputDevice(defaultId, session, true);
7871
+ expect(result).toBeTruthy();
7872
+ });
7873
+
7874
+ describe('setVideoInputDevice', () => {
7875
+ it('should retain its original video values', () => {
7876
+ const video = { height: { min: 480, max: 720 }, width: { min: 640, max: 1280 } };
7877
+
7878
+ client.video = video;
7879
+ client.setVideoInputDevice(deviceId);
7880
+ expect(client.video).toEqual({ ...video, deviceId: { exact: deviceId } });
7881
+ });
7882
+
7883
+ it('should set deviceId when video\'s original value is true', () => {
7884
+ client.video = true;
7885
+ client.setVideoInputDevice(deviceId);
7886
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7887
+ });
7888
+
7889
+ it('should set deviceId when video\'s original value is not set', () => {
7890
+ client.video = undefined;
7891
+ client.setVideoInputDevice(deviceId);
7892
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7893
+ });
7894
+
7895
+ it('should NOT set deviceId when its value does not change', () => {
7896
+ client.video = { deviceId: { exact: deviceId } };
7897
+ const result = client.setVideoInputDevice(deviceId);
7898
+ expect(result).toEqual(null);
7899
+ expect(client.video).toEqual({ deviceId: { exact: deviceId } });
7900
+ });
7680
7901
  });
7681
7902
  });
package/esm/api/auth.js CHANGED
@@ -967,6 +967,7 @@ var auth = (client , baseUrl ) => ({
967
967
 
968
968
 
969
969
 
970
+
970
971
  ) {
971
972
  const body = {
972
973
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -987,9 +988,14 @@ var auth = (client , baseUrl ) => ({
987
988
  }
988
989
 
989
990
  if (params.tenantId) {
991
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
990
992
  body.tenant_id = params.tenantId;
991
993
  }
992
994
 
995
+ if (params.domainName) {
996
+ body.domain_name = params.domainName;
997
+ }
998
+
993
999
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
994
1000
  },
995
1001
 
@@ -1002,6 +1008,7 @@ var auth = (client , baseUrl ) => ({
1002
1008
  expiration ,
1003
1009
  isMobile = false,
1004
1010
  tenantId ,
1011
+ domainName ,
1005
1012
  ) => {
1006
1013
  const body = {
1007
1014
  backend: backend || DEFAULT_BACKEND_USER,
@@ -1011,9 +1018,14 @@ var auth = (client , baseUrl ) => ({
1011
1018
  };
1012
1019
 
1013
1020
  if (tenantId) {
1021
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
1014
1022
  body.tenant_id = tenantId;
1015
1023
  }
1016
1024
 
1025
+ if (domainName) {
1026
+ body.domain_name = domainName;
1027
+ }
1028
+
1017
1029
  const headers = {
1018
1030
  'Content-Type': 'application/json',
1019
1031
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
package/esm/api/calld.js CHANGED
@@ -1395,6 +1395,14 @@ var calld = (client , baseUrl ) => ({
1395
1395
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
1396
1396
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
1397
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
+
1398
1406
  listTrunks: () => client.get(`${baseUrl}/trunks`),
1399
1407
 
1400
1408
  mute: (callId ) =>