@wazo/sdk 0.38.7 → 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 (106) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +142 -2
  3. package/esm/__tests__/web-rtc-client.test.js +227 -27
  4. package/esm/api/calld.js +8 -0
  5. package/esm/api/confd.js +134 -2
  6. package/esm/api-client.js +142 -2
  7. package/esm/checker/Checker.js +183 -24
  8. package/esm/checker/checks/aor.js +142 -2
  9. package/esm/checker/checks/api.js +142 -2
  10. package/esm/checker/checks/index.js +183 -24
  11. package/esm/checker/checks/wazo-websocket.js +2 -0
  12. package/esm/checker/checks/webrtc-transport.js +181 -24
  13. package/esm/checker/checks/webrtc.js +181 -24
  14. package/esm/domain/AdHocAPIConference.js +142 -2
  15. package/esm/domain/Features.js +142 -2
  16. package/esm/domain/Meeting.js +18 -0
  17. package/esm/domain/MeetingAuthorization.js +70 -0
  18. package/esm/domain/Phone/CTIPhone.js +142 -2
  19. package/esm/domain/__tests__/Meeting.test.js +87 -1
  20. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  21. package/esm/index.js +226 -27
  22. package/esm/service/CallApi.js +142 -2
  23. package/esm/service/getApiClient.js +142 -2
  24. package/esm/simple/Auth.js +226 -27
  25. package/esm/simple/Configuration.js +226 -27
  26. package/esm/simple/Directory.js +142 -2
  27. package/esm/simple/Phone.js +226 -27
  28. package/esm/simple/Websocket.js +3 -0
  29. package/esm/simple/index.js +226 -27
  30. package/esm/simple/room/LocalParticipant.js +226 -27
  31. package/esm/simple/room/Participant.js +226 -27
  32. package/esm/simple/room/RemoteParticipant.js +226 -27
  33. package/esm/simple/room/Room.js +226 -27
  34. package/esm/simple/room/SipRoom.js +226 -27
  35. package/esm/simple/room/Stream.js +226 -27
  36. package/esm/simple/room/__tests__/Participant.test.js +14747 -0
  37. package/esm/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  38. package/esm/simple/utils.js +226 -27
  39. package/esm/utils/__tests__/object.test.js +57 -0
  40. package/esm/utils/__tests__/string.test.js +30 -0
  41. package/esm/utils/object.js +24 -0
  42. package/esm/utils/string.js +10 -0
  43. package/esm/web-rtc-client.js +181 -24
  44. package/esm/websocket-client.js +3 -1
  45. package/lib/__tests__/api-client.test.js +142 -2
  46. package/lib/__tests__/web-rtc-client.test.js +227 -27
  47. package/lib/api/calld.js +8 -0
  48. package/lib/api/confd.js +134 -2
  49. package/lib/api-client.js +142 -2
  50. package/lib/checker/Checker.js +183 -24
  51. package/lib/checker/checks/aor.js +142 -2
  52. package/lib/checker/checks/api.js +142 -2
  53. package/lib/checker/checks/index.js +183 -24
  54. package/lib/checker/checks/wazo-websocket.js +2 -0
  55. package/lib/checker/checks/webrtc-transport.js +181 -24
  56. package/lib/checker/checks/webrtc.js +181 -24
  57. package/lib/domain/AdHocAPIConference.js +142 -2
  58. package/lib/domain/Features.js +142 -2
  59. package/lib/domain/Meeting.js +18 -0
  60. package/lib/domain/MeetingAuthorization.js +79 -0
  61. package/lib/domain/Phone/CTIPhone.js +142 -2
  62. package/lib/domain/__tests__/Meeting.test.js +87 -1
  63. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  64. package/lib/index.js +226 -27
  65. package/lib/service/CallApi.js +142 -2
  66. package/lib/service/getApiClient.js +142 -2
  67. package/lib/simple/Auth.js +226 -27
  68. package/lib/simple/Configuration.js +226 -27
  69. package/lib/simple/Directory.js +142 -2
  70. package/lib/simple/Phone.js +226 -27
  71. package/lib/simple/Websocket.js +3 -0
  72. package/lib/simple/index.js +226 -27
  73. package/lib/simple/room/LocalParticipant.js +226 -27
  74. package/lib/simple/room/Participant.js +226 -27
  75. package/lib/simple/room/RemoteParticipant.js +226 -27
  76. package/lib/simple/room/Room.js +226 -27
  77. package/lib/simple/room/SipRoom.js +226 -27
  78. package/lib/simple/room/Stream.js +226 -27
  79. package/lib/simple/room/__tests__/Participant.test.js +14757 -0
  80. package/lib/simple/room/__tests__/RemoteParticipant.test.js +226 -27
  81. package/lib/simple/utils.js +226 -27
  82. package/lib/utils/__tests__/object.test.js +59 -0
  83. package/lib/utils/__tests__/string.test.js +32 -0
  84. package/lib/utils/object.js +28 -0
  85. package/lib/utils/string.js +14 -0
  86. package/lib/web-rtc-client.js +181 -24
  87. package/lib/websocket-client.js +3 -0
  88. package/package.json +2 -2
  89. package/src/__tests__/web-rtc-client.test.js +46 -3
  90. package/src/api/calld.js +8 -0
  91. package/src/api/confd.js +43 -2
  92. package/src/domain/Meeting.js +20 -0
  93. package/src/domain/MeetingAuthorization.js +67 -0
  94. package/src/domain/__tests__/Meeting.test.js +70 -1
  95. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  96. package/src/simple/room/Participant.js +40 -0
  97. package/src/simple/room/Room.js +2 -2
  98. package/src/simple/room/SipRoom.js +1 -1
  99. package/src/simple/room/__tests__/Participant.test.js +81 -0
  100. package/src/types/WebSocketMessage.js +7 -1
  101. package/src/utils/__tests__/object.test.js +35 -0
  102. package/src/utils/__tests__/string.test.js +23 -0
  103. package/src/utils/object.js +15 -0
  104. package/src/utils/string.js +8 -0
  105. package/src/web-rtc-client.js +39 -22
  106. package/src/websocket-client.js +2 -0
@@ -3202,6 +3202,70 @@ class ExternalApp {
3202
3202
 
3203
3203
  //
3204
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
+
3205
3269
 
3206
3270
 
3207
3271
 
@@ -3212,6 +3276,7 @@ class ExternalApp {
3212
3276
 
3213
3277
 
3214
3278
 
3279
+
3215
3280
 
3216
3281
 
3217
3282
  class Meeting {
@@ -3226,6 +3291,8 @@ class Meeting {
3226
3291
 
3227
3292
 
3228
3293
 
3294
+
3295
+
3229
3296
 
3230
3297
  static parse(plain ) {
3231
3298
  return new Meeting({
@@ -3238,6 +3305,7 @@ class Meeting {
3238
3305
  extension: plain.exten,
3239
3306
  persistent: plain.persistent,
3240
3307
  creationTime: moment(plain.creation_time).toDate(),
3308
+ requireAuthorization: plain.require_authorization,
3241
3309
  });
3242
3310
  }
3243
3311
 
@@ -3262,6 +3330,7 @@ class Meeting {
3262
3330
  extension,
3263
3331
  persistent,
3264
3332
  creationTime,
3333
+ requireAuthorization,
3265
3334
  } = {}) {
3266
3335
  this.guestSipAuthorization = guestSipAuthorization;
3267
3336
  this.uri = uri;
@@ -3272,6 +3341,7 @@ class Meeting {
3272
3341
  this.extension = extension;
3273
3342
  this.persistent = persistent;
3274
3343
  this.creationTime = creationTime;
3344
+ this.requireAuthorization = requireAuthorization;
3275
3345
 
3276
3346
  // Useful to compare instead of instanceof with minified code
3277
3347
  this.type = 'Meeting';
@@ -3282,8 +3352,32 @@ class Meeting {
3282
3352
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3283
3353
  return { username, secret };
3284
3354
  }
3355
+
3285
3356
  }
3286
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
+
3287
3381
  /* */
3288
3382
 
3289
3383
  var confdMethods = (client , baseUrl ) => ({
@@ -3352,8 +3446,18 @@ var confdMethods = (client , baseUrl ) => ({
3352
3446
  getMyMeetings: () =>
3353
3447
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3354
3448
 
3355
- createMyMeeting: (name , persistent ) =>
3356
- 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
+ ),
3357
3461
 
3358
3462
  deleteMyMeeting: (meetingUuid ) =>
3359
3463
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3361,8 +3465,36 @@ var confdMethods = (client , baseUrl ) => ({
3361
3465
  getMeeting: (meetingUuid ) =>
3362
3466
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3363
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
+
3364
3487
  guestGetMeeting: (meetingUuid ) =>
3365
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
+
3366
3498
  });
3367
3499
 
3368
3500
  //
@@ -4801,6 +4933,14 @@ var calldMethods = (client , baseUrl ) => ({
4801
4933
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4802
4934
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4803
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
+
4804
4944
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4805
4945
 
4806
4946
  mute: (callId ) =>
@@ -6441,7 +6581,7 @@ class WebRTCClient extends Emitter {
6441
6581
  });
6442
6582
  }
6443
6583
 
6444
- changeAudioInputDevice(id , session , force ) {
6584
+ async changeAudioInputDevice(id , session , force ) {
6445
6585
  const currentId = this.getAudioDeviceId();
6446
6586
  logger.info('setting audio input device', { id, currentId, session: !!session });
6447
6587
 
@@ -6449,33 +6589,50 @@ class WebRTCClient extends Emitter {
6449
6589
  return null;
6450
6590
  }
6451
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
+
6452
6610
  // let's update the local audio value
6453
6611
  if (this.audio) {
6454
6612
  this.audio = {
6455
6613
  deviceId: {
6456
- exact: id,
6614
+ exact: deviceId,
6457
6615
  },
6458
6616
  };
6459
6617
  }
6460
6618
 
6461
- if (session) {
6619
+ if (session && navigator.mediaDevices) {
6462
6620
  const sdh = session.sessionDescriptionHandler;
6463
6621
  const pc = sdh.peerConnection;
6464
6622
 
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);
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);
6469
6627
 
6470
- if (sender) {
6471
- if (sender.track) {
6472
- audioTrack.enabled = sender.track.enabled;
6473
- }
6474
- sender.replaceTrack(audioTrack);
6628
+ if (sender) {
6629
+ if (sender.track) {
6630
+ audioTrack.enabled = sender.track.enabled;
6475
6631
  }
6632
+ sender.replaceTrack(audioTrack);
6633
+ }
6476
6634
 
6477
- return stream;
6478
- });
6635
+ return stream;
6479
6636
  }
6480
6637
  }
6481
6638
 
@@ -6495,14 +6652,14 @@ class WebRTCClient extends Emitter {
6495
6652
  return null;
6496
6653
  }
6497
6654
 
6498
- // let's update the local video value
6499
- if (this.video) {
6500
- this.video = {
6501
- deviceId: {
6502
- exact: id,
6503
- },
6504
- };
6505
- }
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
+ };
6506
6663
  }
6507
6664
 
6508
6665
  changeSessionVideoInputDevice(id , session ) {
@@ -3202,6 +3202,70 @@ class ExternalApp {
3202
3202
 
3203
3203
  //
3204
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
+
3205
3269
 
3206
3270
 
3207
3271
 
@@ -3212,6 +3276,7 @@ class ExternalApp {
3212
3276
 
3213
3277
 
3214
3278
 
3279
+
3215
3280
 
3216
3281
 
3217
3282
  class Meeting {
@@ -3226,6 +3291,8 @@ class Meeting {
3226
3291
 
3227
3292
 
3228
3293
 
3294
+
3295
+
3229
3296
 
3230
3297
  static parse(plain ) {
3231
3298
  return new Meeting({
@@ -3238,6 +3305,7 @@ class Meeting {
3238
3305
  extension: plain.exten,
3239
3306
  persistent: plain.persistent,
3240
3307
  creationTime: moment(plain.creation_time).toDate(),
3308
+ requireAuthorization: plain.require_authorization,
3241
3309
  });
3242
3310
  }
3243
3311
 
@@ -3262,6 +3330,7 @@ class Meeting {
3262
3330
  extension,
3263
3331
  persistent,
3264
3332
  creationTime,
3333
+ requireAuthorization,
3265
3334
  } = {}) {
3266
3335
  this.guestSipAuthorization = guestSipAuthorization;
3267
3336
  this.uri = uri;
@@ -3272,6 +3341,7 @@ class Meeting {
3272
3341
  this.extension = extension;
3273
3342
  this.persistent = persistent;
3274
3343
  this.creationTime = creationTime;
3344
+ this.requireAuthorization = requireAuthorization;
3275
3345
 
3276
3346
  // Useful to compare instead of instanceof with minified code
3277
3347
  this.type = 'Meeting';
@@ -3282,8 +3352,32 @@ class Meeting {
3282
3352
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3283
3353
  return { username, secret };
3284
3354
  }
3355
+
3285
3356
  }
3286
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
+
3287
3381
  /* */
3288
3382
 
3289
3383
  var confdMethods = (client , baseUrl ) => ({
@@ -3352,8 +3446,18 @@ var confdMethods = (client , baseUrl ) => ({
3352
3446
  getMyMeetings: () =>
3353
3447
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3354
3448
 
3355
- createMyMeeting: (name , persistent ) =>
3356
- 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
+ ),
3357
3461
 
3358
3462
  deleteMyMeeting: (meetingUuid ) =>
3359
3463
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3361,8 +3465,36 @@ var confdMethods = (client , baseUrl ) => ({
3361
3465
  getMeeting: (meetingUuid ) =>
3362
3466
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3363
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
+
3364
3487
  guestGetMeeting: (meetingUuid ) =>
3365
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
+
3366
3498
  });
3367
3499
 
3368
3500
  //
@@ -4801,6 +4933,14 @@ var calldMethods = (client , baseUrl ) => ({
4801
4933
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4802
4934
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4803
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
+
4804
4944
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4805
4945
 
4806
4946
  mute: (callId ) =>
@@ -6441,7 +6581,7 @@ class WebRTCClient extends Emitter {
6441
6581
  });
6442
6582
  }
6443
6583
 
6444
- changeAudioInputDevice(id , session , force ) {
6584
+ async changeAudioInputDevice(id , session , force ) {
6445
6585
  const currentId = this.getAudioDeviceId();
6446
6586
  logger.info('setting audio input device', { id, currentId, session: !!session });
6447
6587
 
@@ -6449,33 +6589,50 @@ class WebRTCClient extends Emitter {
6449
6589
  return null;
6450
6590
  }
6451
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
+
6452
6610
  // let's update the local audio value
6453
6611
  if (this.audio) {
6454
6612
  this.audio = {
6455
6613
  deviceId: {
6456
- exact: id,
6614
+ exact: deviceId,
6457
6615
  },
6458
6616
  };
6459
6617
  }
6460
6618
 
6461
- if (session) {
6619
+ if (session && navigator.mediaDevices) {
6462
6620
  const sdh = session.sessionDescriptionHandler;
6463
6621
  const pc = sdh.peerConnection;
6464
6622
 
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);
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);
6469
6627
 
6470
- if (sender) {
6471
- if (sender.track) {
6472
- audioTrack.enabled = sender.track.enabled;
6473
- }
6474
- sender.replaceTrack(audioTrack);
6628
+ if (sender) {
6629
+ if (sender.track) {
6630
+ audioTrack.enabled = sender.track.enabled;
6475
6631
  }
6632
+ sender.replaceTrack(audioTrack);
6633
+ }
6476
6634
 
6477
- return stream;
6478
- });
6635
+ return stream;
6479
6636
  }
6480
6637
  }
6481
6638
 
@@ -6495,14 +6652,14 @@ class WebRTCClient extends Emitter {
6495
6652
  return null;
6496
6653
  }
6497
6654
 
6498
- // let's update the local video value
6499
- if (this.video) {
6500
- this.video = {
6501
- deviceId: {
6502
- exact: id,
6503
- },
6504
- };
6505
- }
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
+ };
6506
6663
  }
6507
6664
 
6508
6665
  changeSessionVideoInputDevice(id , session ) {