@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
@@ -2848,6 +2848,7 @@ var authMethods = (client , baseUrl ) => ({
2848
2848
 
2849
2849
 
2850
2850
 
2851
+
2851
2852
  ) {
2852
2853
  const body = {
2853
2854
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2868,9 +2869,14 @@ var authMethods = (client , baseUrl ) => ({
2868
2869
  }
2869
2870
 
2870
2871
  if (params.tenantId) {
2872
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2871
2873
  body.tenant_id = params.tenantId;
2872
2874
  }
2873
2875
 
2876
+ if (params.domainName) {
2877
+ body.domain_name = params.domainName;
2878
+ }
2879
+
2874
2880
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2875
2881
  },
2876
2882
 
@@ -2883,6 +2889,7 @@ var authMethods = (client , baseUrl ) => ({
2883
2889
  expiration ,
2884
2890
  isMobile = false,
2885
2891
  tenantId ,
2892
+ domainName ,
2886
2893
  ) => {
2887
2894
  const body = {
2888
2895
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2892,9 +2899,14 @@ var authMethods = (client , baseUrl ) => ({
2892
2899
  };
2893
2900
 
2894
2901
  if (tenantId) {
2902
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2895
2903
  body.tenant_id = tenantId;
2896
2904
  }
2897
2905
 
2906
+ if (domainName) {
2907
+ body.domain_name = domainName;
2908
+ }
2909
+
2898
2910
  const headers = {
2899
2911
  'Content-Type': 'application/json',
2900
2912
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -3264,6 +3276,70 @@ class ExternalApp {
3264
3276
 
3265
3277
  //
3266
3278
 
3279
+ class MeetingAuthorization {
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+ constructor({
3287
+ meetingUuid,
3288
+ uuid,
3289
+ userUuid,
3290
+ userName,
3291
+ } = {}) {
3292
+ this.meetingUuid = meetingUuid;
3293
+ this.uuid = uuid;
3294
+ this.userUuid = userUuid;
3295
+ this.userName = userName;
3296
+ }
3297
+
3298
+ setStatus(status ) {
3299
+ this.status = status;
3300
+ }
3301
+
3302
+ getStatus() {
3303
+ return this.status;
3304
+ }
3305
+
3306
+ static parse(plain ) {
3307
+ const {
3308
+ meeting_uuid: meetingUuid,
3309
+ uuid,
3310
+ guest_uuid: userUuid,
3311
+ guest_name: userName,
3312
+ } = plain;
3313
+
3314
+ return new MeetingAuthorization({
3315
+ meetingUuid,
3316
+ uuid,
3317
+ userUuid,
3318
+ userName,
3319
+ });
3320
+ }
3321
+
3322
+ static parseMany(items ) {
3323
+ if (!items) {
3324
+ return [];
3325
+ }
3326
+ return items.map(MeetingAuthorization.parse);
3327
+ }
3328
+ }
3329
+
3330
+ //
3331
+
3332
+
3333
+
3334
+
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3267
3343
 
3268
3344
 
3269
3345
 
@@ -3274,6 +3350,7 @@ class ExternalApp {
3274
3350
 
3275
3351
 
3276
3352
 
3353
+
3277
3354
 
3278
3355
 
3279
3356
  class Meeting {
@@ -3288,6 +3365,8 @@ class Meeting {
3288
3365
 
3289
3366
 
3290
3367
 
3368
+
3369
+
3291
3370
 
3292
3371
  static parse(plain ) {
3293
3372
  return new Meeting({
@@ -3300,6 +3379,7 @@ class Meeting {
3300
3379
  extension: plain.exten,
3301
3380
  persistent: plain.persistent,
3302
3381
  creationTime: moment__default['default'](plain.creation_time).toDate(),
3382
+ requireAuthorization: plain.require_authorization,
3303
3383
  });
3304
3384
  }
3305
3385
 
@@ -3324,6 +3404,7 @@ class Meeting {
3324
3404
  extension,
3325
3405
  persistent,
3326
3406
  creationTime,
3407
+ requireAuthorization,
3327
3408
  } = {}) {
3328
3409
  this.guestSipAuthorization = guestSipAuthorization;
3329
3410
  this.uri = uri;
@@ -3334,6 +3415,7 @@ class Meeting {
3334
3415
  this.extension = extension;
3335
3416
  this.persistent = persistent;
3336
3417
  this.creationTime = creationTime;
3418
+ this.requireAuthorization = requireAuthorization;
3337
3419
 
3338
3420
  // Useful to compare instead of instanceof with minified code
3339
3421
  this.type = 'Meeting';
@@ -3344,8 +3426,32 @@ class Meeting {
3344
3426
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3345
3427
  return { username, secret };
3346
3428
  }
3429
+
3347
3430
  }
3348
3431
 
3432
+ //
3433
+
3434
+ const camelToUnderscore = (key ) => {
3435
+ if (typeof key !== 'string') {
3436
+ throw new Error('Input is not a string');
3437
+ }
3438
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3439
+ };
3440
+
3441
+ //
3442
+
3443
+ const convertKeysFromCamelToUnderscore = (args ) => {
3444
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3445
+ throw new Error('Input is not an object');
3446
+ }
3447
+
3448
+ return Object.keys(args).reduce((acc, key) => {
3449
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3450
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3451
+ return acc;
3452
+ }, {});
3453
+ };
3454
+
3349
3455
  /* */
3350
3456
 
3351
3457
  var confdMethods = (client , baseUrl ) => ({
@@ -3414,8 +3520,18 @@ var confdMethods = (client , baseUrl ) => ({
3414
3520
  getMyMeetings: () =>
3415
3521
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3416
3522
 
3417
- createMyMeeting: (name , persistent ) =>
3418
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3523
+ createMyMeeting: (args ) =>
3524
+ client
3525
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3526
+ .then(Meeting.parse),
3527
+
3528
+ updateMyMeeting: (meetingUuid , data ) =>
3529
+ client.put(
3530
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3531
+ convertKeysFromCamelToUnderscore(data),
3532
+ null,
3533
+ ApiRequester.successResponseParser,
3534
+ ),
3419
3535
 
3420
3536
  deleteMyMeeting: (meetingUuid ) =>
3421
3537
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3423,8 +3539,36 @@ var confdMethods = (client , baseUrl ) => ({
3423
3539
  getMeeting: (meetingUuid ) =>
3424
3540
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3425
3541
 
3542
+ meetingAuthorizations: (meetingUuid ) =>
3543
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3544
+
3545
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3546
+ client.put(
3547
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3548
+ {},
3549
+ null,
3550
+ ApiRequester.successResponseParser,
3551
+ ),
3552
+
3553
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3554
+ client.put(
3555
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3556
+ {},
3557
+ null,
3558
+ ApiRequester.successResponseParser,
3559
+ ),
3560
+
3426
3561
  guestGetMeeting: (meetingUuid ) =>
3427
3562
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3563
+
3564
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3565
+ client
3566
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3567
+ .then(MeetingAuthorization.parse),
3568
+
3569
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3570
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3571
+
3428
3572
  });
3429
3573
 
3430
3574
  //
@@ -5066,6 +5210,14 @@ var calldMethods = (client , baseUrl ) => ({
5066
5210
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5067
5211
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5068
5212
 
5213
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5214
+ client.delete(
5215
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5216
+ null,
5217
+ null,
5218
+ ApiRequester.successResponseParser,
5219
+ ),
5220
+
5069
5221
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5070
5222
 
5071
5223
  mute: (callId ) =>
@@ -5443,6 +5595,7 @@ class ApiClient {
5443
5595
 
5444
5596
 
5445
5597
 
5598
+
5446
5599
 
5447
5600
 
5448
5601
 
@@ -5484,6 +5637,7 @@ class ApiClient {
5484
5637
  refreshToken: this.refreshToken,
5485
5638
  refreshBackend: this.refreshBackend,
5486
5639
  refreshTenantId: this.refreshTenantId,
5640
+ refreshDomainName: this.refreshDomainName,
5487
5641
  refreshExpiration: this.refreshExpiration,
5488
5642
  isMobile: this.isMobile,
5489
5643
  });
@@ -5499,6 +5653,7 @@ class ApiClient {
5499
5653
  this.refreshExpiration,
5500
5654
  this.isMobile,
5501
5655
  this.refreshTenantId,
5656
+ this.refreshDomainName,
5502
5657
  );
5503
5658
 
5504
5659
  logger$a.info('token refreshed', { token: session.token });
@@ -5552,9 +5707,14 @@ class ApiClient {
5552
5707
  }
5553
5708
 
5554
5709
  setRefreshTenantId(tenantId ) {
5710
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5555
5711
  this.refreshTenantId = tenantId;
5556
5712
  }
5557
5713
 
5714
+ setRefreshDomainName(domainName ) {
5715
+ this.refreshDomainName = domainName;
5716
+ }
5717
+
5558
5718
  setIsMobile(isMobile ) {
5559
5719
  this.isMobile = isMobile;
5560
5720
  }
@@ -5579,6 +5739,7 @@ global.wazoClientId = global.wazoClientId || {};
5579
5739
  global.wazoClientToken = global.wazoClientToken || {};
5580
5740
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5581
5741
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5742
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5582
5743
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5583
5744
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5584
5745
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5603,9 +5764,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5603
5764
  };
5604
5765
 
5605
5766
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5767
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5606
5768
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5607
5769
  };
5608
5770
 
5771
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5772
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5773
+ };
5774
+
5609
5775
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5610
5776
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5611
5777
  };
@@ -5624,6 +5790,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5624
5790
 
5625
5791
  const fillClient = (apiClient ) => {
5626
5792
  const { server, token, clientId } = apiClient.client;
5793
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5627
5794
 
5628
5795
  // try with null server when dealing with non-related server info
5629
5796
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5632,8 +5799,12 @@ const fillClient = (apiClient ) => {
5632
5799
 
5633
5800
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5634
5801
 
5635
- apiClient.setRefreshTenantId(
5636
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5802
+ if (tenantId) {
5803
+ apiClient.setRefreshTenantId(tenantId);
5804
+ }
5805
+
5806
+ apiClient.setRefreshDomainName(
5807
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5637
5808
  );
5638
5809
 
5639
5810
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7523,7 +7694,7 @@ class WebRTCClient extends Emitter {
7523
7694
  });
7524
7695
  }
7525
7696
 
7526
- changeAudioInputDevice(id , session , force ) {
7697
+ async changeAudioInputDevice(id , session , force ) {
7527
7698
  const currentId = this.getAudioDeviceId();
7528
7699
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7529
7700
 
@@ -7531,33 +7702,50 @@ class WebRTCClient extends Emitter {
7531
7702
  return null;
7532
7703
  }
7533
7704
 
7705
+ // in order to handle an audio track change for default devices
7706
+ // we need the actual id of the device (not 'default')
7707
+ let deviceId = id;
7708
+ if (id === 'default' && navigator.mediaDevices) {
7709
+ const devices = await navigator.mediaDevices.enumerateDevices();
7710
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7711
+ if (defaultDevice) {
7712
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7713
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7714
+ if (targetDevice) {
7715
+ deviceId = targetDevice.deviceId;
7716
+ if (!force && deviceId === currentId) {
7717
+ return null;
7718
+ }
7719
+ }
7720
+ }
7721
+ }
7722
+
7534
7723
  // let's update the local audio value
7535
7724
  if (this.audio) {
7536
7725
  this.audio = {
7537
7726
  deviceId: {
7538
- exact: id,
7727
+ exact: deviceId,
7539
7728
  },
7540
7729
  };
7541
7730
  }
7542
7731
 
7543
- if (session) {
7732
+ if (session && navigator.mediaDevices) {
7544
7733
  const sdh = session.sessionDescriptionHandler;
7545
7734
  const pc = sdh.peerConnection;
7546
7735
 
7547
- // $FlowFixMe
7548
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7549
- const audioTrack = stream.getAudioTracks()[0];
7550
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7736
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7737
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7738
+ const audioTrack = stream.getAudioTracks()[0];
7739
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7551
7740
 
7552
- if (sender) {
7553
- if (sender.track) {
7554
- audioTrack.enabled = sender.track.enabled;
7555
- }
7556
- sender.replaceTrack(audioTrack);
7741
+ if (sender) {
7742
+ if (sender.track) {
7743
+ audioTrack.enabled = sender.track.enabled;
7557
7744
  }
7745
+ sender.replaceTrack(audioTrack);
7746
+ }
7558
7747
 
7559
- return stream;
7560
- });
7748
+ return stream;
7561
7749
  }
7562
7750
  }
7563
7751
 
@@ -7577,14 +7765,14 @@ class WebRTCClient extends Emitter {
7577
7765
  return null;
7578
7766
  }
7579
7767
 
7580
- // let's update the local video value
7581
- if (this.video) {
7582
- this.video = {
7583
- deviceId: {
7584
- exact: id,
7585
- },
7586
- };
7587
- }
7768
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7769
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7770
+ this.video = {
7771
+ ...videoObject,
7772
+ deviceId: {
7773
+ exact: id,
7774
+ },
7775
+ };
7588
7776
  }
7589
7777
 
7590
7778
  changeSessionVideoInputDevice(id , session ) {
@@ -9186,9 +9374,7 @@ class WebRTCPhone extends Emitter {
9186
9374
 
9187
9375
  try {
9188
9376
  if (this.currentScreenShare.stream) {
9189
- this.currentScreenShare.stream.getTracks()
9190
- .filter(track => track.kind === 'video')
9191
- .forEach(track => track.stop());
9377
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9192
9378
  }
9193
9379
 
9194
9380
  if (restoreLocalStream) {
@@ -10477,6 +10663,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10477
10663
  class InvalidSubscription extends Error {}
10478
10664
  class InvalidAuthorization extends Error {}
10479
10665
  class NoTenantIdError extends Error {}
10666
+ class NoDomainNameError extends Error {}
10480
10667
 
10481
10668
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10482
10669
 
@@ -10540,9 +10727,24 @@ class Auth {
10540
10727
  setFetchOptions(options);
10541
10728
  }
10542
10729
 
10543
- async logIn(username , password , backend , tenantId ) {
10544
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
10545
- throw new NoTenantIdError('No tenant id');
10730
+ async logIn(username , password , backend , extra ) {
10731
+ let tenantId = null;
10732
+ let domainName = null;
10733
+ if (typeof extra === 'string') {
10734
+ tenantId = extra;
10735
+ }
10736
+ if (extra && typeof extra === 'object') {
10737
+ domainName = extra.domainName;
10738
+ }
10739
+
10740
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
10741
+ if (!tenantId) {
10742
+ throw new NoTenantIdError('No tenant id');
10743
+ }
10744
+
10745
+ if (!domainName) {
10746
+ throw new NoDomainNameError('No domain name');
10747
+ }
10546
10748
  }
10547
10749
 
10548
10750
  this.authenticated = false;
@@ -10552,6 +10754,7 @@ class Auth {
10552
10754
  password,
10553
10755
  backend,
10554
10756
  tenantId,
10757
+ domainName,
10555
10758
  expiration: this.expiration,
10556
10759
  mobile: this.mobile,
10557
10760
  });
@@ -10560,7 +10763,13 @@ class Auth {
10560
10763
  getApiClient().setRefreshBackend(backend);
10561
10764
  }
10562
10765
 
10563
- getApiClient().setRefreshTenantId(tenantId);
10766
+ if (tenantId) {
10767
+ getApiClient().setRefreshTenantId(tenantId);
10768
+ }
10769
+
10770
+ if (domainName) {
10771
+ getApiClient().setRefreshDomainName(domainName);
10772
+ }
10564
10773
 
10565
10774
  return this._onAuthenticated(rawSession);
10566
10775
  }
@@ -10659,11 +10868,18 @@ class Auth {
10659
10868
  }
10660
10869
 
10661
10870
  setRefreshTenantId(refreshTenantId ) {
10871
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
10662
10872
  setRefreshTenantId(refreshTenantId);
10663
10873
 
10664
10874
  getApiClient().setRefreshTenantId(refreshTenantId);
10665
10875
  }
10666
10876
 
10877
+ setRefreshDomainName(domainName ) {
10878
+ setRefreshDomainName(domainName);
10879
+
10880
+ getApiClient().setRefreshDomainName(domainName);
10881
+ }
10882
+
10667
10883
  forceRefreshToken() {
10668
10884
  getApiClient().forceRefreshToken();
10669
10885
  }
@@ -10862,6 +11078,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10862
11078
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10863
11079
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10864
11080
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11081
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10865
11082
 
10866
11083
  const BLACKLIST_EVENTS = [
10867
11084
  CHAT_MESSAGE_SENT,
@@ -11213,6 +11430,7 @@ WebSocketClient.eventLists = [
11213
11430
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11214
11431
  CONFERENCE_ADHOC_DELETED,
11215
11432
  MEETING_USER_PROGRESS,
11433
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11216
11434
  ];
11217
11435
 
11218
11436
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11284,6 +11502,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11284
11502
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11285
11503
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11286
11504
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11505
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11287
11506
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11288
11507
  'default': WebSocketClient
11289
11508
  });
@@ -11388,6 +11607,7 @@ class Participant extends Emitter {
11388
11607
 
11389
11608
 
11390
11609
 
11610
+
11391
11611
 
11392
11612
 
11393
11613
 
@@ -11405,6 +11625,7 @@ class Participant extends Emitter {
11405
11625
 
11406
11626
 
11407
11627
 
11628
+
11408
11629
 
11409
11630
  /**
11410
11631
  * @param room Room The room where the participant is
@@ -11428,6 +11649,7 @@ class Participant extends Emitter {
11428
11649
  this.screensharing = false;
11429
11650
  this.isOnHold = false;
11430
11651
  this.extra = extra;
11652
+ this.banned = false;
11431
11653
 
11432
11654
  this.ON_UPDATED = 'participant/ON_UPDATED';
11433
11655
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11444,6 +11666,7 @@ class Participant extends Emitter {
11444
11666
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11445
11667
  this.ON_HOLD = 'participant/ON_HOLD';
11446
11668
  this.ON_RESUME = 'participant/ON_RESUME';
11669
+ this.ON_BAN = 'participant/ON_BAN';
11447
11670
  }
11448
11671
 
11449
11672
  triggerEvent(name , ...args ) {
@@ -11484,6 +11707,10 @@ class Participant extends Emitter {
11484
11707
  status.extra = this.extra;
11485
11708
  break;
11486
11709
  }
11710
+ case this.ON_BAN: {
11711
+ status.banned = true;
11712
+ break;
11713
+ }
11487
11714
  }
11488
11715
 
11489
11716
  if (broadcast) {
@@ -11586,6 +11813,11 @@ class Participant extends Emitter {
11586
11813
  this.triggerUpdate(this.ON_RESUME, broadcast);
11587
11814
  }
11588
11815
 
11816
+ onBan(broadcast = true) {
11817
+ this.banned = true;
11818
+ this.triggerUpdate(this.ON_BAN, broadcast);
11819
+ }
11820
+
11589
11821
  getStatus() {
11590
11822
  return {
11591
11823
  callId: this.callId,
@@ -11632,6 +11864,10 @@ class Participant extends Emitter {
11632
11864
  }
11633
11865
  }
11634
11866
 
11867
+ if (status.banned) {
11868
+ this.onBan(false);
11869
+ }
11870
+
11635
11871
  // Poor man's object comparison
11636
11872
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11637
11873
  this.extra = { ...this.extra, ...status.extra };
@@ -11659,6 +11895,28 @@ class Participant extends Emitter {
11659
11895
  this.streams = streams;
11660
11896
  this.videoStreams = streams;
11661
11897
  }
11898
+
11899
+ async ban(apiRequestDelay = null) {
11900
+ const { meetingUuid } = this.room;
11901
+ if (!meetingUuid) {
11902
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11903
+ }
11904
+
11905
+ // this notifies all that someone is being banned
11906
+ this.onBan(true);
11907
+
11908
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11909
+ if (apiRequestDelay) {
11910
+ await this.delay(apiRequestDelay);
11911
+ }
11912
+
11913
+ // proceed with the actual kick
11914
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11915
+ }
11916
+
11917
+ async delay(ms ) {
11918
+ return new Promise(resolve => setTimeout(resolve, ms));
11919
+ }
11662
11920
  }
11663
11921
 
11664
11922
  //
@@ -11811,7 +12069,7 @@ class Room$1 extends Emitter {
11811
12069
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11812
12070
 
11813
12071
  if (!room) {
11814
- await Wazo.Phone.connect();
12072
+ await Wazo.Phone.connect({ media: constraints });
11815
12073
 
11816
12074
  const withCamera = constraints && !!constraints.video;
11817
12075
 
@@ -12256,7 +12514,7 @@ class Room$1 extends Emitter {
12256
12514
  const participant = this._getParticipantFromCallId(status.callId);
12257
12515
 
12258
12516
  if (participant) {
12259
- // we're received, so no need to broadcast, hence the input false arg
12517
+ // we're receiving, so no need to broadcast
12260
12518
  participant.updateStatus(status, false);
12261
12519
  }
12262
12520
  break;
@@ -12523,7 +12781,7 @@ class SipRoom extends Room$1 {
12523
12781
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12524
12782
 
12525
12783
  if (!room) {
12526
- await Wazo.Phone.connect();
12784
+ await Wazo.Phone.connect({ media: constraints });
12527
12785
 
12528
12786
  const withCamera = constraints && !!constraints.video;
12529
12787
 
@@ -13713,6 +13971,7 @@ class Softphone {
13713
13971
  wrapUpDuration,
13714
13972
  enableAgent = true,
13715
13973
  tenantId,
13974
+ domainName,
13716
13975
  debug = false,
13717
13976
  } = {}) {
13718
13977
  this.url = url || 'https://softphone.wazo.io';
@@ -13737,8 +13996,12 @@ class Softphone {
13737
13996
  config.port = port;
13738
13997
  }
13739
13998
  if (tenantId) {
13999
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13740
14000
  config.tenantId = tenantId;
13741
14001
  }
14002
+ if (domainName) {
14003
+ config.domainName = domainName;
14004
+ }
13742
14005
  if (wrapUpDuration) {
13743
14006
  config.wrapUpDuration = wrapUpDuration;
13744
14007
  }
@@ -14059,6 +14322,7 @@ const Wazo = {
14059
14322
  CanceledCallError,
14060
14323
  SFUNotAvailableError,
14061
14324
  NoTenantIdError,
14325
+ NoDomainNameError,
14062
14326
  };
14063
14327
 
14064
14328
  if (window) {