@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
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
2229
2229
 
2230
2230
 
2231
2231
 
2232
+
2232
2233
  ) {
2233
2234
  const body = {
2234
2235
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
2249
2250
  }
2250
2251
 
2251
2252
  if (params.tenantId) {
2253
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2252
2254
  body.tenant_id = params.tenantId;
2253
2255
  }
2254
2256
 
2257
+ if (params.domainName) {
2258
+ body.domain_name = params.domainName;
2259
+ }
2260
+
2255
2261
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2256
2262
  },
2257
2263
 
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
2264
2270
  expiration ,
2265
2271
  isMobile = false,
2266
2272
  tenantId ,
2273
+ domainName ,
2267
2274
  ) => {
2268
2275
  const body = {
2269
2276
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
2273
2280
  };
2274
2281
 
2275
2282
  if (tenantId) {
2283
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2276
2284
  body.tenant_id = tenantId;
2277
2285
  }
2278
2286
 
2287
+ if (domainName) {
2288
+ body.domain_name = domainName;
2289
+ }
2290
+
2279
2291
  const headers = {
2280
2292
  'Content-Type': 'application/json',
2281
2293
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2645,6 +2657,70 @@ class ExternalApp {
2645
2657
 
2646
2658
  //
2647
2659
 
2660
+ class MeetingAuthorization {
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+ constructor({
2668
+ meetingUuid,
2669
+ uuid,
2670
+ userUuid,
2671
+ userName,
2672
+ } = {}) {
2673
+ this.meetingUuid = meetingUuid;
2674
+ this.uuid = uuid;
2675
+ this.userUuid = userUuid;
2676
+ this.userName = userName;
2677
+ }
2678
+
2679
+ setStatus(status ) {
2680
+ this.status = status;
2681
+ }
2682
+
2683
+ getStatus() {
2684
+ return this.status;
2685
+ }
2686
+
2687
+ static parse(plain ) {
2688
+ const {
2689
+ meeting_uuid: meetingUuid,
2690
+ uuid,
2691
+ guest_uuid: userUuid,
2692
+ guest_name: userName,
2693
+ } = plain;
2694
+
2695
+ return new MeetingAuthorization({
2696
+ meetingUuid,
2697
+ uuid,
2698
+ userUuid,
2699
+ userName,
2700
+ });
2701
+ }
2702
+
2703
+ static parseMany(items ) {
2704
+ if (!items) {
2705
+ return [];
2706
+ }
2707
+ return items.map(MeetingAuthorization.parse);
2708
+ }
2709
+ }
2710
+
2711
+ //
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2648
2724
 
2649
2725
 
2650
2726
 
@@ -2655,6 +2731,7 @@ class ExternalApp {
2655
2731
 
2656
2732
 
2657
2733
 
2734
+
2658
2735
 
2659
2736
 
2660
2737
  class Meeting {
@@ -2669,6 +2746,8 @@ class Meeting {
2669
2746
 
2670
2747
 
2671
2748
 
2749
+
2750
+
2672
2751
 
2673
2752
  static parse(plain ) {
2674
2753
  return new Meeting({
@@ -2681,6 +2760,7 @@ class Meeting {
2681
2760
  extension: plain.exten,
2682
2761
  persistent: plain.persistent,
2683
2762
  creationTime: moment(plain.creation_time).toDate(),
2763
+ requireAuthorization: plain.require_authorization,
2684
2764
  });
2685
2765
  }
2686
2766
 
@@ -2705,6 +2785,7 @@ class Meeting {
2705
2785
  extension,
2706
2786
  persistent,
2707
2787
  creationTime,
2788
+ requireAuthorization,
2708
2789
  } = {}) {
2709
2790
  this.guestSipAuthorization = guestSipAuthorization;
2710
2791
  this.uri = uri;
@@ -2715,6 +2796,7 @@ class Meeting {
2715
2796
  this.extension = extension;
2716
2797
  this.persistent = persistent;
2717
2798
  this.creationTime = creationTime;
2799
+ this.requireAuthorization = requireAuthorization;
2718
2800
 
2719
2801
  // Useful to compare instead of instanceof with minified code
2720
2802
  this.type = 'Meeting';
@@ -2725,8 +2807,32 @@ class Meeting {
2725
2807
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2726
2808
  return { username, secret };
2727
2809
  }
2810
+
2728
2811
  }
2729
2812
 
2813
+ //
2814
+
2815
+ const camelToUnderscore = (key ) => {
2816
+ if (typeof key !== 'string') {
2817
+ throw new Error('Input is not a string');
2818
+ }
2819
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2820
+ };
2821
+
2822
+ //
2823
+
2824
+ const convertKeysFromCamelToUnderscore = (args ) => {
2825
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2826
+ throw new Error('Input is not an object');
2827
+ }
2828
+
2829
+ return Object.keys(args).reduce((acc, key) => {
2830
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2831
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2832
+ return acc;
2833
+ }, {});
2834
+ };
2835
+
2730
2836
  /* */
2731
2837
 
2732
2838
  var confdMethods = (client , baseUrl ) => ({
@@ -2795,8 +2901,18 @@ var confdMethods = (client , baseUrl ) => ({
2795
2901
  getMyMeetings: () =>
2796
2902
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2797
2903
 
2798
- createMyMeeting: (name , persistent ) =>
2799
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2904
+ createMyMeeting: (args ) =>
2905
+ client
2906
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2907
+ .then(Meeting.parse),
2908
+
2909
+ updateMyMeeting: (meetingUuid , data ) =>
2910
+ client.put(
2911
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2912
+ convertKeysFromCamelToUnderscore(data),
2913
+ null,
2914
+ ApiRequester.successResponseParser,
2915
+ ),
2800
2916
 
2801
2917
  deleteMyMeeting: (meetingUuid ) =>
2802
2918
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2804,8 +2920,36 @@ var confdMethods = (client , baseUrl ) => ({
2804
2920
  getMeeting: (meetingUuid ) =>
2805
2921
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2806
2922
 
2923
+ meetingAuthorizations: (meetingUuid ) =>
2924
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2925
+
2926
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2927
+ client.put(
2928
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2929
+ {},
2930
+ null,
2931
+ ApiRequester.successResponseParser,
2932
+ ),
2933
+
2934
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2935
+ client.put(
2936
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2937
+ {},
2938
+ null,
2939
+ ApiRequester.successResponseParser,
2940
+ ),
2941
+
2807
2942
  guestGetMeeting: (meetingUuid ) =>
2808
2943
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2944
+
2945
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2946
+ client
2947
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2948
+ .then(MeetingAuthorization.parse),
2949
+
2950
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2951
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2952
+
2809
2953
  });
2810
2954
 
2811
2955
  //
@@ -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) {
@@ -10969,6 +11155,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
10969
11155
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10970
11156
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10971
11157
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11158
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
10972
11159
 
10973
11160
  const BLACKLIST_EVENTS = [
10974
11161
  CHAT_MESSAGE_SENT,
@@ -11320,6 +11507,7 @@ WebSocketClient.eventLists = [
11320
11507
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11321
11508
  CONFERENCE_ADHOC_DELETED,
11322
11509
  MEETING_USER_PROGRESS,
11510
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11323
11511
  ];
11324
11512
 
11325
11513
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11391,6 +11579,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11391
11579
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11392
11580
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11393
11581
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11582
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11394
11583
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11395
11584
  'default': WebSocketClient
11396
11585
  });
@@ -11495,6 +11684,7 @@ class Participant extends Emitter {
11495
11684
 
11496
11685
 
11497
11686
 
11687
+
11498
11688
 
11499
11689
 
11500
11690
 
@@ -11512,6 +11702,7 @@ class Participant extends Emitter {
11512
11702
 
11513
11703
 
11514
11704
 
11705
+
11515
11706
 
11516
11707
  /**
11517
11708
  * @param room Room The room where the participant is
@@ -11535,6 +11726,7 @@ class Participant extends Emitter {
11535
11726
  this.screensharing = false;
11536
11727
  this.isOnHold = false;
11537
11728
  this.extra = extra;
11729
+ this.banned = false;
11538
11730
 
11539
11731
  this.ON_UPDATED = 'participant/ON_UPDATED';
11540
11732
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11551,6 +11743,7 @@ class Participant extends Emitter {
11551
11743
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11552
11744
  this.ON_HOLD = 'participant/ON_HOLD';
11553
11745
  this.ON_RESUME = 'participant/ON_RESUME';
11746
+ this.ON_BAN = 'participant/ON_BAN';
11554
11747
  }
11555
11748
 
11556
11749
  triggerEvent(name , ...args ) {
@@ -11591,6 +11784,10 @@ class Participant extends Emitter {
11591
11784
  status.extra = this.extra;
11592
11785
  break;
11593
11786
  }
11787
+ case this.ON_BAN: {
11788
+ status.banned = true;
11789
+ break;
11790
+ }
11594
11791
  }
11595
11792
 
11596
11793
  if (broadcast) {
@@ -11693,6 +11890,11 @@ class Participant extends Emitter {
11693
11890
  this.triggerUpdate(this.ON_RESUME, broadcast);
11694
11891
  }
11695
11892
 
11893
+ onBan(broadcast = true) {
11894
+ this.banned = true;
11895
+ this.triggerUpdate(this.ON_BAN, broadcast);
11896
+ }
11897
+
11696
11898
  getStatus() {
11697
11899
  return {
11698
11900
  callId: this.callId,
@@ -11739,6 +11941,10 @@ class Participant extends Emitter {
11739
11941
  }
11740
11942
  }
11741
11943
 
11944
+ if (status.banned) {
11945
+ this.onBan(false);
11946
+ }
11947
+
11742
11948
  // Poor man's object comparison
11743
11949
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
11744
11950
  this.extra = { ...this.extra, ...status.extra };
@@ -11766,6 +11972,28 @@ class Participant extends Emitter {
11766
11972
  this.streams = streams;
11767
11973
  this.videoStreams = streams;
11768
11974
  }
11975
+
11976
+ async ban(apiRequestDelay = null) {
11977
+ const { meetingUuid } = this.room;
11978
+ if (!meetingUuid) {
11979
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
11980
+ }
11981
+
11982
+ // this notifies all that someone is being banned
11983
+ this.onBan(true);
11984
+
11985
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
11986
+ if (apiRequestDelay) {
11987
+ await this.delay(apiRequestDelay);
11988
+ }
11989
+
11990
+ // proceed with the actual kick
11991
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
11992
+ }
11993
+
11994
+ async delay(ms ) {
11995
+ return new Promise(resolve => setTimeout(resolve, ms));
11996
+ }
11769
11997
  }
11770
11998
 
11771
11999
  //
@@ -11918,7 +12146,7 @@ class Room$1 extends Emitter {
11918
12146
  logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11919
12147
 
11920
12148
  if (!room) {
11921
- await Wazo.Phone.connect();
12149
+ await Wazo.Phone.connect({ media: constraints });
11922
12150
 
11923
12151
  const withCamera = constraints && !!constraints.video;
11924
12152
 
@@ -12363,7 +12591,7 @@ class Room$1 extends Emitter {
12363
12591
  const participant = this._getParticipantFromCallId(status.callId);
12364
12592
 
12365
12593
  if (participant) {
12366
- // we're received, so no need to broadcast, hence the input false arg
12594
+ // we're receiving, so no need to broadcast
12367
12595
  participant.updateStatus(status, false);
12368
12596
  }
12369
12597
  break;
@@ -12630,7 +12858,7 @@ class SipRoom extends Room$1 {
12630
12858
  logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12631
12859
 
12632
12860
  if (!room) {
12633
- await Wazo.Phone.connect();
12861
+ await Wazo.Phone.connect({ media: constraints });
12634
12862
 
12635
12863
  const withCamera = constraints && !!constraints.video;
12636
12864
 
@@ -13795,6 +14023,7 @@ class Softphone {
13795
14023
  wrapUpDuration,
13796
14024
  enableAgent = true,
13797
14025
  tenantId,
14026
+ domainName,
13798
14027
  debug = false,
13799
14028
  } = {}) {
13800
14029
  this.url = url || 'https://softphone.wazo.io';
@@ -13819,8 +14048,12 @@ class Softphone {
13819
14048
  config.port = port;
13820
14049
  }
13821
14050
  if (tenantId) {
14051
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13822
14052
  config.tenantId = tenantId;
13823
14053
  }
14054
+ if (domainName) {
14055
+ config.domainName = domainName;
14056
+ }
13824
14057
  if (wrapUpDuration) {
13825
14058
  config.wrapUpDuration = wrapUpDuration;
13826
14059
  }
@@ -14141,6 +14374,7 @@ const Wazo = {
14141
14374
  CanceledCallError,
14142
14375
  SFUNotAvailableError,
14143
14376
  NoTenantIdError,
14377
+ NoDomainNameError,
14144
14378
  };
14145
14379
 
14146
14380
  if (window) {
@@ -14155,6 +14389,7 @@ if (global) {
14155
14389
  class InvalidSubscription extends Error {}
14156
14390
  class InvalidAuthorization extends Error {}
14157
14391
  class NoTenantIdError extends Error {}
14392
+ class NoDomainNameError extends Error {}
14158
14393
 
14159
14394
  const logger = IssueReporter$1.loggerFor('simple-auth');
14160
14395
 
@@ -14218,9 +14453,24 @@ class Auth {
14218
14453
  setFetchOptions(options);
14219
14454
  }
14220
14455
 
14221
- async logIn(username , password , backend , tenantId ) {
14222
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14223
- throw new NoTenantIdError('No tenant id');
14456
+ async logIn(username , password , backend , extra ) {
14457
+ let tenantId = null;
14458
+ let domainName = null;
14459
+ if (typeof extra === 'string') {
14460
+ tenantId = extra;
14461
+ }
14462
+ if (extra && typeof extra === 'object') {
14463
+ domainName = extra.domainName;
14464
+ }
14465
+
14466
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14467
+ if (!tenantId) {
14468
+ throw new NoTenantIdError('No tenant id');
14469
+ }
14470
+
14471
+ if (!domainName) {
14472
+ throw new NoDomainNameError('No domain name');
14473
+ }
14224
14474
  }
14225
14475
 
14226
14476
  this.authenticated = false;
@@ -14230,6 +14480,7 @@ class Auth {
14230
14480
  password,
14231
14481
  backend,
14232
14482
  tenantId,
14483
+ domainName,
14233
14484
  expiration: this.expiration,
14234
14485
  mobile: this.mobile,
14235
14486
  });
@@ -14238,7 +14489,13 @@ class Auth {
14238
14489
  getApiClient().setRefreshBackend(backend);
14239
14490
  }
14240
14491
 
14241
- getApiClient().setRefreshTenantId(tenantId);
14492
+ if (tenantId) {
14493
+ getApiClient().setRefreshTenantId(tenantId);
14494
+ }
14495
+
14496
+ if (domainName) {
14497
+ getApiClient().setRefreshDomainName(domainName);
14498
+ }
14242
14499
 
14243
14500
  return this._onAuthenticated(rawSession);
14244
14501
  }
@@ -14337,11 +14594,18 @@ class Auth {
14337
14594
  }
14338
14595
 
14339
14596
  setRefreshTenantId(refreshTenantId ) {
14597
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14340
14598
  setRefreshTenantId(refreshTenantId);
14341
14599
 
14342
14600
  getApiClient().setRefreshTenantId(refreshTenantId);
14343
14601
  }
14344
14602
 
14603
+ setRefreshDomainName(domainName ) {
14604
+ setRefreshDomainName(domainName);
14605
+
14606
+ getApiClient().setRefreshDomainName(domainName);
14607
+ }
14608
+
14345
14609
  forceRefreshToken() {
14346
14610
  getApiClient().forceRefreshToken();
14347
14611
  }