@wazo/sdk 0.38.6 → 0.38.9

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 (118) 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 +249 -28
  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 +205 -25
  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 +205 -25
  11. package/esm/checker/checks/wazo-websocket.js +2 -0
  12. package/esm/checker/checks/webrtc-transport.js +203 -25
  13. package/esm/checker/checks/webrtc.js +203 -25
  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/Phone/WebRTCPhone.js +1 -3
  20. package/esm/domain/__tests__/Meeting.test.js +87 -1
  21. package/esm/domain/__tests__/MeetingAuthorization.test.js +109 -0
  22. package/esm/index.js +249 -31
  23. package/esm/lib/WazoSessionDescriptionHandler.js +22 -1
  24. package/esm/service/CallApi.js +142 -2
  25. package/esm/service/getApiClient.js +142 -2
  26. package/esm/simple/Auth.js +249 -31
  27. package/esm/simple/Configuration.js +249 -31
  28. package/esm/simple/Directory.js +142 -2
  29. package/esm/simple/Phone.js +249 -31
  30. package/esm/simple/Websocket.js +3 -0
  31. package/esm/simple/index.js +249 -31
  32. package/esm/simple/room/LocalParticipant.js +249 -31
  33. package/esm/simple/room/Participant.js +249 -31
  34. package/esm/simple/room/RemoteParticipant.js +249 -31
  35. package/esm/simple/room/Room.js +249 -31
  36. package/esm/simple/room/SipRoom.js +249 -31
  37. package/esm/simple/room/Stream.js +249 -31
  38. package/esm/simple/room/__tests__/Participant.test.js +14745 -0
  39. package/esm/simple/room/__tests__/RemoteParticipant.test.js +249 -31
  40. package/esm/simple/utils.js +249 -31
  41. package/esm/utils/__tests__/object.test.js +57 -0
  42. package/esm/utils/__tests__/sdp.test.js +50 -0
  43. package/esm/utils/__tests__/string.test.js +30 -0
  44. package/esm/utils/object.js +24 -0
  45. package/esm/utils/sdp.js +19 -1
  46. package/esm/utils/string.js +10 -0
  47. package/esm/web-rtc-client.js +203 -25
  48. package/esm/websocket-client.js +3 -1
  49. package/lib/__tests__/api-client.test.js +142 -2
  50. package/lib/__tests__/web-rtc-client.test.js +249 -28
  51. package/lib/api/calld.js +8 -0
  52. package/lib/api/confd.js +134 -2
  53. package/lib/api-client.js +142 -2
  54. package/lib/checker/Checker.js +205 -25
  55. package/lib/checker/checks/aor.js +142 -2
  56. package/lib/checker/checks/api.js +142 -2
  57. package/lib/checker/checks/index.js +205 -25
  58. package/lib/checker/checks/wazo-websocket.js +2 -0
  59. package/lib/checker/checks/webrtc-transport.js +203 -25
  60. package/lib/checker/checks/webrtc.js +203 -25
  61. package/lib/domain/AdHocAPIConference.js +142 -2
  62. package/lib/domain/Features.js +142 -2
  63. package/lib/domain/Meeting.js +18 -0
  64. package/lib/domain/MeetingAuthorization.js +79 -0
  65. package/lib/domain/Phone/CTIPhone.js +142 -2
  66. package/lib/domain/Phone/WebRTCPhone.js +1 -3
  67. package/lib/domain/__tests__/Meeting.test.js +87 -1
  68. package/lib/domain/__tests__/MeetingAuthorization.test.js +111 -0
  69. package/lib/index.js +249 -31
  70. package/lib/lib/WazoSessionDescriptionHandler.js +22 -1
  71. package/lib/service/CallApi.js +142 -2
  72. package/lib/service/getApiClient.js +142 -2
  73. package/lib/simple/Auth.js +249 -31
  74. package/lib/simple/Configuration.js +249 -31
  75. package/lib/simple/Directory.js +142 -2
  76. package/lib/simple/Phone.js +249 -31
  77. package/lib/simple/Websocket.js +3 -0
  78. package/lib/simple/index.js +249 -31
  79. package/lib/simple/room/LocalParticipant.js +249 -31
  80. package/lib/simple/room/Participant.js +249 -31
  81. package/lib/simple/room/RemoteParticipant.js +249 -31
  82. package/lib/simple/room/Room.js +249 -31
  83. package/lib/simple/room/SipRoom.js +249 -31
  84. package/lib/simple/room/Stream.js +249 -31
  85. package/lib/simple/room/__tests__/Participant.test.js +14755 -0
  86. package/lib/simple/room/__tests__/RemoteParticipant.test.js +249 -31
  87. package/lib/simple/utils.js +249 -31
  88. package/lib/utils/__tests__/object.test.js +59 -0
  89. package/lib/utils/__tests__/sdp.test.js +50 -0
  90. package/lib/utils/__tests__/string.test.js +32 -0
  91. package/lib/utils/object.js +28 -0
  92. package/lib/utils/sdp.js +19 -0
  93. package/lib/utils/string.js +14 -0
  94. package/lib/web-rtc-client.js +203 -25
  95. package/lib/websocket-client.js +3 -0
  96. package/package.json +2 -2
  97. package/src/__tests__/web-rtc-client.test.js +46 -3
  98. package/src/api/calld.js +8 -0
  99. package/src/api/confd.js +43 -2
  100. package/src/domain/Meeting.js +20 -0
  101. package/src/domain/MeetingAuthorization.js +67 -0
  102. package/src/domain/Phone/WebRTCPhone.js +1 -3
  103. package/src/domain/__tests__/Meeting.test.js +70 -1
  104. package/src/domain/__tests__/MeetingAuthorization.test.js +58 -0
  105. package/src/lib/WazoSessionDescriptionHandler.js +5 -2
  106. package/src/simple/room/Participant.js +40 -0
  107. package/src/simple/room/Room.js +2 -2
  108. package/src/simple/room/SipRoom.js +1 -1
  109. package/src/simple/room/__tests__/Participant.test.js +81 -0
  110. package/src/types/WebSocketMessage.js +7 -1
  111. package/src/utils/__tests__/object.test.js +35 -0
  112. package/src/utils/__tests__/sdp.test.js +33 -1
  113. package/src/utils/__tests__/string.test.js +23 -0
  114. package/src/utils/object.js +15 -0
  115. package/src/utils/sdp.js +18 -0
  116. package/src/utils/string.js +8 -0
  117. package/src/web-rtc-client.js +39 -22
  118. 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
  //
@@ -4780,6 +4933,14 @@ var calldMethods = (client , baseUrl ) => ({
4780
4933
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4781
4934
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4782
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
+
4783
4944
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4784
4945
 
4785
4946
  mute: (callId ) =>
@@ -6420,7 +6581,7 @@ class WebRTCClient extends Emitter {
6420
6581
  });
6421
6582
  }
6422
6583
 
6423
- changeAudioInputDevice(id , session , force ) {
6584
+ async changeAudioInputDevice(id , session , force ) {
6424
6585
  const currentId = this.getAudioDeviceId();
6425
6586
  logger.info('setting audio input device', { id, currentId, session: !!session });
6426
6587
 
@@ -6428,33 +6589,50 @@ class WebRTCClient extends Emitter {
6428
6589
  return null;
6429
6590
  }
6430
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
+
6431
6610
  // let's update the local audio value
6432
6611
  if (this.audio) {
6433
6612
  this.audio = {
6434
6613
  deviceId: {
6435
- exact: id,
6614
+ exact: deviceId,
6436
6615
  },
6437
6616
  };
6438
6617
  }
6439
6618
 
6440
- if (session) {
6619
+ if (session && navigator.mediaDevices) {
6441
6620
  const sdh = session.sessionDescriptionHandler;
6442
6621
  const pc = sdh.peerConnection;
6443
6622
 
6444
- // $FlowFixMe
6445
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
6446
- const audioTrack = stream.getAudioTracks()[0];
6447
- 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);
6448
6627
 
6449
- if (sender) {
6450
- if (sender.track) {
6451
- audioTrack.enabled = sender.track.enabled;
6452
- }
6453
- sender.replaceTrack(audioTrack);
6628
+ if (sender) {
6629
+ if (sender.track) {
6630
+ audioTrack.enabled = sender.track.enabled;
6454
6631
  }
6632
+ sender.replaceTrack(audioTrack);
6633
+ }
6455
6634
 
6456
- return stream;
6457
- });
6635
+ return stream;
6458
6636
  }
6459
6637
  }
6460
6638
 
@@ -6474,14 +6652,14 @@ class WebRTCClient extends Emitter {
6474
6652
  return null;
6475
6653
  }
6476
6654
 
6477
- // let's update the local video value
6478
- if (this.video) {
6479
- this.video = {
6480
- deviceId: {
6481
- exact: id,
6482
- },
6483
- };
6484
- }
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
+ };
6485
6663
  }
6486
6664
 
6487
6665
  changeSessionVideoInputDevice(id , session ) {
@@ -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
  //
@@ -4780,6 +4933,14 @@ var calldMethods = (client , baseUrl ) => ({
4780
4933
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4781
4934
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4782
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
+
4783
4944
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4784
4945
 
4785
4946
  mute: (callId ) =>
@@ -6420,7 +6581,7 @@ class WebRTCClient extends Emitter {
6420
6581
  });
6421
6582
  }
6422
6583
 
6423
- changeAudioInputDevice(id , session , force ) {
6584
+ async changeAudioInputDevice(id , session , force ) {
6424
6585
  const currentId = this.getAudioDeviceId();
6425
6586
  logger.info('setting audio input device', { id, currentId, session: !!session });
6426
6587
 
@@ -6428,33 +6589,50 @@ class WebRTCClient extends Emitter {
6428
6589
  return null;
6429
6590
  }
6430
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
+
6431
6610
  // let's update the local audio value
6432
6611
  if (this.audio) {
6433
6612
  this.audio = {
6434
6613
  deviceId: {
6435
- exact: id,
6614
+ exact: deviceId,
6436
6615
  },
6437
6616
  };
6438
6617
  }
6439
6618
 
6440
- if (session) {
6619
+ if (session && navigator.mediaDevices) {
6441
6620
  const sdh = session.sessionDescriptionHandler;
6442
6621
  const pc = sdh.peerConnection;
6443
6622
 
6444
- // $FlowFixMe
6445
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
6446
- const audioTrack = stream.getAudioTracks()[0];
6447
- 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);
6448
6627
 
6449
- if (sender) {
6450
- if (sender.track) {
6451
- audioTrack.enabled = sender.track.enabled;
6452
- }
6453
- sender.replaceTrack(audioTrack);
6628
+ if (sender) {
6629
+ if (sender.track) {
6630
+ audioTrack.enabled = sender.track.enabled;
6454
6631
  }
6632
+ sender.replaceTrack(audioTrack);
6633
+ }
6455
6634
 
6456
- return stream;
6457
- });
6635
+ return stream;
6458
6636
  }
6459
6637
  }
6460
6638
 
@@ -6474,14 +6652,14 @@ class WebRTCClient extends Emitter {
6474
6652
  return null;
6475
6653
  }
6476
6654
 
6477
- // let's update the local video value
6478
- if (this.video) {
6479
- this.video = {
6480
- deviceId: {
6481
- exact: id,
6482
- },
6483
- };
6484
- }
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
+ };
6485
6663
  }
6486
6664
 
6487
6665
  changeSessionVideoInputDevice(id , session ) {