@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
@@ -2838,6 +2838,7 @@ var authMethods = (client , baseUrl ) => ({
2838
2838
 
2839
2839
 
2840
2840
 
2841
+
2841
2842
  ) {
2842
2843
  const body = {
2843
2844
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2858,9 +2859,14 @@ var authMethods = (client , baseUrl ) => ({
2858
2859
  }
2859
2860
 
2860
2861
  if (params.tenantId) {
2862
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2861
2863
  body.tenant_id = params.tenantId;
2862
2864
  }
2863
2865
 
2866
+ if (params.domainName) {
2867
+ body.domain_name = params.domainName;
2868
+ }
2869
+
2864
2870
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2865
2871
  },
2866
2872
 
@@ -2873,6 +2879,7 @@ var authMethods = (client , baseUrl ) => ({
2873
2879
  expiration ,
2874
2880
  isMobile = false,
2875
2881
  tenantId ,
2882
+ domainName ,
2876
2883
  ) => {
2877
2884
  const body = {
2878
2885
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2882,9 +2889,14 @@ var authMethods = (client , baseUrl ) => ({
2882
2889
  };
2883
2890
 
2884
2891
  if (tenantId) {
2892
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2885
2893
  body.tenant_id = tenantId;
2886
2894
  }
2887
2895
 
2896
+ if (domainName) {
2897
+ body.domain_name = domainName;
2898
+ }
2899
+
2888
2900
  const headers = {
2889
2901
  'Content-Type': 'application/json',
2890
2902
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -3254,6 +3266,70 @@ class ExternalApp {
3254
3266
 
3255
3267
  //
3256
3268
 
3269
+ class MeetingAuthorization {
3270
+
3271
+
3272
+
3273
+
3274
+
3275
+
3276
+ constructor({
3277
+ meetingUuid,
3278
+ uuid,
3279
+ userUuid,
3280
+ userName,
3281
+ } = {}) {
3282
+ this.meetingUuid = meetingUuid;
3283
+ this.uuid = uuid;
3284
+ this.userUuid = userUuid;
3285
+ this.userName = userName;
3286
+ }
3287
+
3288
+ setStatus(status ) {
3289
+ this.status = status;
3290
+ }
3291
+
3292
+ getStatus() {
3293
+ return this.status;
3294
+ }
3295
+
3296
+ static parse(plain ) {
3297
+ const {
3298
+ meeting_uuid: meetingUuid,
3299
+ uuid,
3300
+ guest_uuid: userUuid,
3301
+ guest_name: userName,
3302
+ } = plain;
3303
+
3304
+ return new MeetingAuthorization({
3305
+ meetingUuid,
3306
+ uuid,
3307
+ userUuid,
3308
+ userName,
3309
+ });
3310
+ }
3311
+
3312
+ static parseMany(items ) {
3313
+ if (!items) {
3314
+ return [];
3315
+ }
3316
+ return items.map(MeetingAuthorization.parse);
3317
+ }
3318
+ }
3319
+
3320
+ //
3321
+
3322
+
3323
+
3324
+
3325
+
3326
+
3327
+
3328
+
3329
+
3330
+
3331
+
3332
+
3257
3333
 
3258
3334
 
3259
3335
 
@@ -3264,6 +3340,7 @@ class ExternalApp {
3264
3340
 
3265
3341
 
3266
3342
 
3343
+
3267
3344
 
3268
3345
 
3269
3346
  class Meeting {
@@ -3278,6 +3355,8 @@ class Meeting {
3278
3355
 
3279
3356
 
3280
3357
 
3358
+
3359
+
3281
3360
 
3282
3361
  static parse(plain ) {
3283
3362
  return new Meeting({
@@ -3290,6 +3369,7 @@ class Meeting {
3290
3369
  extension: plain.exten,
3291
3370
  persistent: plain.persistent,
3292
3371
  creationTime: moment(plain.creation_time).toDate(),
3372
+ requireAuthorization: plain.require_authorization,
3293
3373
  });
3294
3374
  }
3295
3375
 
@@ -3314,6 +3394,7 @@ class Meeting {
3314
3394
  extension,
3315
3395
  persistent,
3316
3396
  creationTime,
3397
+ requireAuthorization,
3317
3398
  } = {}) {
3318
3399
  this.guestSipAuthorization = guestSipAuthorization;
3319
3400
  this.uri = uri;
@@ -3324,6 +3405,7 @@ class Meeting {
3324
3405
  this.extension = extension;
3325
3406
  this.persistent = persistent;
3326
3407
  this.creationTime = creationTime;
3408
+ this.requireAuthorization = requireAuthorization;
3327
3409
 
3328
3410
  // Useful to compare instead of instanceof with minified code
3329
3411
  this.type = 'Meeting';
@@ -3334,8 +3416,32 @@ class Meeting {
3334
3416
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
3335
3417
  return { username, secret };
3336
3418
  }
3419
+
3337
3420
  }
3338
3421
 
3422
+ //
3423
+
3424
+ const camelToUnderscore = (key ) => {
3425
+ if (typeof key !== 'string') {
3426
+ throw new Error('Input is not a string');
3427
+ }
3428
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3429
+ };
3430
+
3431
+ //
3432
+
3433
+ const convertKeysFromCamelToUnderscore = (args ) => {
3434
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3435
+ throw new Error('Input is not an object');
3436
+ }
3437
+
3438
+ return Object.keys(args).reduce((acc, key) => {
3439
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3440
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3441
+ return acc;
3442
+ }, {});
3443
+ };
3444
+
3339
3445
  /* */
3340
3446
 
3341
3447
  var confdMethods = (client , baseUrl ) => ({
@@ -3404,8 +3510,18 @@ var confdMethods = (client , baseUrl ) => ({
3404
3510
  getMyMeetings: () =>
3405
3511
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3406
3512
 
3407
- createMyMeeting: (name , persistent ) =>
3408
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3513
+ createMyMeeting: (args ) =>
3514
+ client
3515
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3516
+ .then(Meeting.parse),
3517
+
3518
+ updateMyMeeting: (meetingUuid , data ) =>
3519
+ client.put(
3520
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3521
+ convertKeysFromCamelToUnderscore(data),
3522
+ null,
3523
+ ApiRequester.successResponseParser,
3524
+ ),
3409
3525
 
3410
3526
  deleteMyMeeting: (meetingUuid ) =>
3411
3527
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3413,8 +3529,36 @@ var confdMethods = (client , baseUrl ) => ({
3413
3529
  getMeeting: (meetingUuid ) =>
3414
3530
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3415
3531
 
3532
+ meetingAuthorizations: (meetingUuid ) =>
3533
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3534
+
3535
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3536
+ client.put(
3537
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3538
+ {},
3539
+ null,
3540
+ ApiRequester.successResponseParser,
3541
+ ),
3542
+
3543
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3544
+ client.put(
3545
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3546
+ {},
3547
+ null,
3548
+ ApiRequester.successResponseParser,
3549
+ ),
3550
+
3416
3551
  guestGetMeeting: (meetingUuid ) =>
3417
3552
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3553
+
3554
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3555
+ client
3556
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3557
+ .then(MeetingAuthorization.parse),
3558
+
3559
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3560
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3561
+
3418
3562
  });
3419
3563
 
3420
3564
  //
@@ -5056,6 +5200,14 @@ var calldMethods = (client , baseUrl ) => ({
5056
5200
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5057
5201
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5058
5202
 
5203
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5204
+ client.delete(
5205
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5206
+ null,
5207
+ null,
5208
+ ApiRequester.successResponseParser,
5209
+ ),
5210
+
5059
5211
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5060
5212
 
5061
5213
  mute: (callId ) =>
@@ -5433,6 +5585,7 @@ class ApiClient {
5433
5585
 
5434
5586
 
5435
5587
 
5588
+
5436
5589
 
5437
5590
 
5438
5591
 
@@ -5474,6 +5627,7 @@ class ApiClient {
5474
5627
  refreshToken: this.refreshToken,
5475
5628
  refreshBackend: this.refreshBackend,
5476
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5477
5631
  refreshExpiration: this.refreshExpiration,
5478
5632
  isMobile: this.isMobile,
5479
5633
  });
@@ -5489,6 +5643,7 @@ class ApiClient {
5489
5643
  this.refreshExpiration,
5490
5644
  this.isMobile,
5491
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5492
5647
  );
5493
5648
 
5494
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5542,9 +5697,14 @@ class ApiClient {
5542
5697
  }
5543
5698
 
5544
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5545
5701
  this.refreshTenantId = tenantId;
5546
5702
  }
5547
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5548
5708
  setIsMobile(isMobile ) {
5549
5709
  this.isMobile = isMobile;
5550
5710
  }
@@ -5569,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5569
5729
  global.wazoClientToken = global.wazoClientToken || {};
5570
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5571
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5572
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5573
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5574
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5593,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5593
5754
  };
5594
5755
 
5595
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5596
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5597
5759
  };
5598
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5599
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5600
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5601
5767
  };
@@ -5614,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5614
5780
 
5615
5781
  const fillClient = (apiClient ) => {
5616
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5617
5784
 
5618
5785
  // try with null server when dealing with non-related server info
5619
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5622,8 +5789,12 @@ const fillClient = (apiClient ) => {
5622
5789
 
5623
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5624
5791
 
5625
- apiClient.setRefreshTenantId(
5626
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5792
+ if (tenantId) {
5793
+ apiClient.setRefreshTenantId(tenantId);
5794
+ }
5795
+
5796
+ apiClient.setRefreshDomainName(
5797
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5627
5798
  );
5628
5799
 
5629
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -7513,7 +7684,7 @@ class WebRTCClient extends Emitter {
7513
7684
  });
7514
7685
  }
7515
7686
 
7516
- changeAudioInputDevice(id , session , force ) {
7687
+ async changeAudioInputDevice(id , session , force ) {
7517
7688
  const currentId = this.getAudioDeviceId();
7518
7689
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7519
7690
 
@@ -7521,33 +7692,50 @@ class WebRTCClient extends Emitter {
7521
7692
  return null;
7522
7693
  }
7523
7694
 
7695
+ // in order to handle an audio track change for default devices
7696
+ // we need the actual id of the device (not 'default')
7697
+ let deviceId = id;
7698
+ if (id === 'default' && navigator.mediaDevices) {
7699
+ const devices = await navigator.mediaDevices.enumerateDevices();
7700
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7701
+ if (defaultDevice) {
7702
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7703
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7704
+ if (targetDevice) {
7705
+ deviceId = targetDevice.deviceId;
7706
+ if (!force && deviceId === currentId) {
7707
+ return null;
7708
+ }
7709
+ }
7710
+ }
7711
+ }
7712
+
7524
7713
  // let's update the local audio value
7525
7714
  if (this.audio) {
7526
7715
  this.audio = {
7527
7716
  deviceId: {
7528
- exact: id,
7717
+ exact: deviceId,
7529
7718
  },
7530
7719
  };
7531
7720
  }
7532
7721
 
7533
- if (session) {
7722
+ if (session && navigator.mediaDevices) {
7534
7723
  const sdh = session.sessionDescriptionHandler;
7535
7724
  const pc = sdh.peerConnection;
7536
7725
 
7537
- // $FlowFixMe
7538
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7539
- const audioTrack = stream.getAudioTracks()[0];
7540
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7726
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7727
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7728
+ const audioTrack = stream.getAudioTracks()[0];
7729
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7541
7730
 
7542
- if (sender) {
7543
- if (sender.track) {
7544
- audioTrack.enabled = sender.track.enabled;
7545
- }
7546
- sender.replaceTrack(audioTrack);
7731
+ if (sender) {
7732
+ if (sender.track) {
7733
+ audioTrack.enabled = sender.track.enabled;
7547
7734
  }
7735
+ sender.replaceTrack(audioTrack);
7736
+ }
7548
7737
 
7549
- return stream;
7550
- });
7738
+ return stream;
7551
7739
  }
7552
7740
  }
7553
7741
 
@@ -7567,14 +7755,14 @@ class WebRTCClient extends Emitter {
7567
7755
  return null;
7568
7756
  }
7569
7757
 
7570
- // let's update the local video value
7571
- if (this.video) {
7572
- this.video = {
7573
- deviceId: {
7574
- exact: id,
7575
- },
7576
- };
7577
- }
7758
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7759
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7760
+ this.video = {
7761
+ ...videoObject,
7762
+ deviceId: {
7763
+ exact: id,
7764
+ },
7765
+ };
7578
7766
  }
7579
7767
 
7580
7768
  changeSessionVideoInputDevice(id , session ) {
@@ -9176,9 +9364,7 @@ class WebRTCPhone extends Emitter {
9176
9364
 
9177
9365
  try {
9178
9366
  if (this.currentScreenShare.stream) {
9179
- this.currentScreenShare.stream.getTracks()
9180
- .filter(track => track.kind === 'video')
9181
- .forEach(track => track.stop());
9367
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9182
9368
  }
9183
9369
 
9184
9370
  if (restoreLocalStream) {
@@ -10467,6 +10653,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10467
10653
  class InvalidSubscription extends Error {}
10468
10654
  class InvalidAuthorization extends Error {}
10469
10655
  class NoTenantIdError extends Error {}
10656
+ class NoDomainNameError extends Error {}
10470
10657
 
10471
10658
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10472
10659
 
@@ -10530,9 +10717,24 @@ class Auth {
10530
10717
  setFetchOptions(options);
10531
10718
  }
10532
10719
 
10533
- async logIn(username , password , backend , tenantId ) {
10534
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
10535
- throw new NoTenantIdError('No tenant id');
10720
+ async logIn(username , password , backend , extra ) {
10721
+ let tenantId = null;
10722
+ let domainName = null;
10723
+ if (typeof extra === 'string') {
10724
+ tenantId = extra;
10725
+ }
10726
+ if (extra && typeof extra === 'object') {
10727
+ domainName = extra.domainName;
10728
+ }
10729
+
10730
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
10731
+ if (!tenantId) {
10732
+ throw new NoTenantIdError('No tenant id');
10733
+ }
10734
+
10735
+ if (!domainName) {
10736
+ throw new NoDomainNameError('No domain name');
10737
+ }
10536
10738
  }
10537
10739
 
10538
10740
  this.authenticated = false;
@@ -10542,6 +10744,7 @@ class Auth {
10542
10744
  password,
10543
10745
  backend,
10544
10746
  tenantId,
10747
+ domainName,
10545
10748
  expiration: this.expiration,
10546
10749
  mobile: this.mobile,
10547
10750
  });
@@ -10550,7 +10753,13 @@ class Auth {
10550
10753
  getApiClient().setRefreshBackend(backend);
10551
10754
  }
10552
10755
 
10553
- getApiClient().setRefreshTenantId(tenantId);
10756
+ if (tenantId) {
10757
+ getApiClient().setRefreshTenantId(tenantId);
10758
+ }
10759
+
10760
+ if (domainName) {
10761
+ getApiClient().setRefreshDomainName(domainName);
10762
+ }
10554
10763
 
10555
10764
  return this._onAuthenticated(rawSession);
10556
10765
  }
@@ -10649,11 +10858,18 @@ class Auth {
10649
10858
  }
10650
10859
 
10651
10860
  setRefreshTenantId(refreshTenantId ) {
10861
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
10652
10862
  setRefreshTenantId(refreshTenantId);
10653
10863
 
10654
10864
  getApiClient().setRefreshTenantId(refreshTenantId);
10655
10865
  }
10656
10866
 
10867
+ setRefreshDomainName(domainName ) {
10868
+ setRefreshDomainName(domainName);
10869
+
10870
+ getApiClient().setRefreshDomainName(domainName);
10871
+ }
10872
+
10657
10873
  forceRefreshToken() {
10658
10874
  getApiClient().forceRefreshToken();
10659
10875
  }
@@ -10852,6 +11068,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10852
11068
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10853
11069
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10854
11070
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11071
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10855
11072
 
10856
11073
  const BLACKLIST_EVENTS = [
10857
11074
  CHAT_MESSAGE_SENT,
@@ -11203,6 +11420,7 @@ WebSocketClient.eventLists = [
11203
11420
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11204
11421
  CONFERENCE_ADHOC_DELETED,
11205
11422
  MEETING_USER_PROGRESS,
11423
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11206
11424
  ];
11207
11425
 
11208
11426
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11274,6 +11492,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11274
11492
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11275
11493
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11276
11494
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11495
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11277
11496
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11278
11497
  'default': WebSocketClient
11279
11498
  });
@@ -11378,6 +11597,7 @@ class Participant extends Emitter {
11378
11597
 
11379
11598
 
11380
11599
 
11600
+
11381
11601
 
11382
11602
 
11383
11603
 
@@ -11395,6 +11615,7 @@ class Participant extends Emitter {
11395
11615
 
11396
11616
 
11397
11617
 
11618
+
11398
11619
 
11399
11620
  /**
11400
11621
  * @param room Room The room where the participant is
@@ -11418,6 +11639,7 @@ class Participant extends Emitter {
11418
11639
  this.screensharing = false;
11419
11640
  this.isOnHold = false;
11420
11641
  this.extra = extra;
11642
+ this.banned = false;
11421
11643
 
11422
11644
  this.ON_UPDATED = 'participant/ON_UPDATED';
11423
11645
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11434,6 +11656,7 @@ class Participant extends Emitter {
11434
11656
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11435
11657
  this.ON_HOLD = 'participant/ON_HOLD';
11436
11658
  this.ON_RESUME = 'participant/ON_RESUME';
11659
+ this.ON_BAN = 'participant/ON_BAN';
11437
11660
  }
11438
11661
 
11439
11662
  triggerEvent(name , ...args ) {
@@ -11474,6 +11697,10 @@ class Participant extends Emitter {
11474
11697
  status.extra = this.extra;
11475
11698
  break;
11476
11699
  }
11700
+ case this.ON_BAN: {
11701
+ status.banned = true;
11702
+ break;
11703
+ }
11477
11704
  }
11478
11705
 
11479
11706
  if (broadcast) {
@@ -11576,6 +11803,11 @@ class Participant extends Emitter {
11576
11803
  this.triggerUpdate(this.ON_RESUME, broadcast);
11577
11804
  }
11578
11805
 
11806
+ onBan(broadcast = true) {
11807
+ this.banned = true;
11808
+ this.triggerUpdate(this.ON_BAN, broadcast);
11809
+ }
11810
+
11579
11811
  getStatus() {
11580
11812
  return {
11581
11813
  callId: this.callId,
@@ -11622,6 +11854,10 @@ class Participant extends Emitter {
11622
11854
  }
11623
11855
  }
11624
11856
 
11857
+ if (status.banned) {
11858
+ this.onBan(false);
11859
+ }
11860
+
11625
11861
  // Poor man's object comparison
11626
11862
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11627
11863
  this.extra = { ...this.extra, ...status.extra };
@@ -11649,6 +11885,28 @@ class Participant extends Emitter {
11649
11885
  this.streams = streams;
11650
11886
  this.videoStreams = streams;
11651
11887
  }
11888
+
11889
+ async ban(apiRequestDelay = null) {
11890
+ const { meetingUuid } = this.room;
11891
+ if (!meetingUuid) {
11892
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11893
+ }
11894
+
11895
+ // this notifies all that someone is being banned
11896
+ this.onBan(true);
11897
+
11898
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11899
+ if (apiRequestDelay) {
11900
+ await this.delay(apiRequestDelay);
11901
+ }
11902
+
11903
+ // proceed with the actual kick
11904
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11905
+ }
11906
+
11907
+ async delay(ms ) {
11908
+ return new Promise(resolve => setTimeout(resolve, ms));
11909
+ }
11652
11910
  }
11653
11911
 
11654
11912
  //
@@ -11801,7 +12059,7 @@ class Room$1 extends Emitter {
11801
12059
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11802
12060
 
11803
12061
  if (!room) {
11804
- await Wazo.Phone.connect();
12062
+ await Wazo.Phone.connect({ media: constraints });
11805
12063
 
11806
12064
  const withCamera = constraints && !!constraints.video;
11807
12065
 
@@ -12246,7 +12504,7 @@ class Room$1 extends Emitter {
12246
12504
  const participant = this._getParticipantFromCallId(status.callId);
12247
12505
 
12248
12506
  if (participant) {
12249
- // we're received, so no need to broadcast, hence the input false arg
12507
+ // we're receiving, so no need to broadcast
12250
12508
  participant.updateStatus(status, false);
12251
12509
  }
12252
12510
  break;
@@ -12513,7 +12771,7 @@ class SipRoom extends Room$1 {
12513
12771
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12514
12772
 
12515
12773
  if (!room) {
12516
- await Wazo.Phone.connect();
12774
+ await Wazo.Phone.connect({ media: constraints });
12517
12775
 
12518
12776
  const withCamera = constraints && !!constraints.video;
12519
12777
 
@@ -13703,6 +13961,7 @@ class Softphone {
13703
13961
  wrapUpDuration,
13704
13962
  enableAgent = true,
13705
13963
  tenantId,
13964
+ domainName,
13706
13965
  debug = false,
13707
13966
  } = {}) {
13708
13967
  this.url = url || 'https://softphone.wazo.io';
@@ -13727,8 +13986,12 @@ class Softphone {
13727
13986
  config.port = port;
13728
13987
  }
13729
13988
  if (tenantId) {
13989
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13730
13990
  config.tenantId = tenantId;
13731
13991
  }
13992
+ if (domainName) {
13993
+ config.domainName = domainName;
13994
+ }
13732
13995
  if (wrapUpDuration) {
13733
13996
  config.wrapUpDuration = wrapUpDuration;
13734
13997
  }
@@ -14049,6 +14312,7 @@ const Wazo = {
14049
14312
  CanceledCallError,
14050
14313
  SFUNotAvailableError,
14051
14314
  NoTenantIdError,
14315
+ NoDomainNameError,
14052
14316
  };
14053
14317
 
14054
14318
  if (window) {