@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
package/esm/index.js CHANGED
@@ -2230,6 +2230,7 @@ var authMethods = (client , baseUrl ) => ({
2230
2230
 
2231
2231
 
2232
2232
 
2233
+
2233
2234
  ) {
2234
2235
  const body = {
2235
2236
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2250,9 +2251,14 @@ var authMethods = (client , baseUrl ) => ({
2250
2251
  }
2251
2252
 
2252
2253
  if (params.tenantId) {
2254
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2253
2255
  body.tenant_id = params.tenantId;
2254
2256
  }
2255
2257
 
2258
+ if (params.domainName) {
2259
+ body.domain_name = params.domainName;
2260
+ }
2261
+
2256
2262
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2257
2263
  },
2258
2264
 
@@ -2265,6 +2271,7 @@ var authMethods = (client , baseUrl ) => ({
2265
2271
  expiration ,
2266
2272
  isMobile = false,
2267
2273
  tenantId ,
2274
+ domainName ,
2268
2275
  ) => {
2269
2276
  const body = {
2270
2277
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2274,9 +2281,14 @@ var authMethods = (client , baseUrl ) => ({
2274
2281
  };
2275
2282
 
2276
2283
  if (tenantId) {
2284
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2277
2285
  body.tenant_id = tenantId;
2278
2286
  }
2279
2287
 
2288
+ if (domainName) {
2289
+ body.domain_name = domainName;
2290
+ }
2291
+
2280
2292
  const headers = {
2281
2293
  'Content-Type': 'application/json',
2282
2294
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2646,6 +2658,70 @@ class ExternalApp {
2646
2658
 
2647
2659
  //
2648
2660
 
2661
+ class MeetingAuthorization {
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+ constructor({
2669
+ meetingUuid,
2670
+ uuid,
2671
+ userUuid,
2672
+ userName,
2673
+ } = {}) {
2674
+ this.meetingUuid = meetingUuid;
2675
+ this.uuid = uuid;
2676
+ this.userUuid = userUuid;
2677
+ this.userName = userName;
2678
+ }
2679
+
2680
+ setStatus(status ) {
2681
+ this.status = status;
2682
+ }
2683
+
2684
+ getStatus() {
2685
+ return this.status;
2686
+ }
2687
+
2688
+ static parse(plain ) {
2689
+ const {
2690
+ meeting_uuid: meetingUuid,
2691
+ uuid,
2692
+ guest_uuid: userUuid,
2693
+ guest_name: userName,
2694
+ } = plain;
2695
+
2696
+ return new MeetingAuthorization({
2697
+ meetingUuid,
2698
+ uuid,
2699
+ userUuid,
2700
+ userName,
2701
+ });
2702
+ }
2703
+
2704
+ static parseMany(items ) {
2705
+ if (!items) {
2706
+ return [];
2707
+ }
2708
+ return items.map(MeetingAuthorization.parse);
2709
+ }
2710
+ }
2711
+
2712
+ //
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2649
2725
 
2650
2726
 
2651
2727
 
@@ -2656,6 +2732,7 @@ class ExternalApp {
2656
2732
 
2657
2733
 
2658
2734
 
2735
+
2659
2736
 
2660
2737
 
2661
2738
  class Meeting {
@@ -2670,6 +2747,8 @@ class Meeting {
2670
2747
 
2671
2748
 
2672
2749
 
2750
+
2751
+
2673
2752
 
2674
2753
  static parse(plain ) {
2675
2754
  return new Meeting({
@@ -2682,6 +2761,7 @@ class Meeting {
2682
2761
  extension: plain.exten,
2683
2762
  persistent: plain.persistent,
2684
2763
  creationTime: moment(plain.creation_time).toDate(),
2764
+ requireAuthorization: plain.require_authorization,
2685
2765
  });
2686
2766
  }
2687
2767
 
@@ -2706,6 +2786,7 @@ class Meeting {
2706
2786
  extension,
2707
2787
  persistent,
2708
2788
  creationTime,
2789
+ requireAuthorization,
2709
2790
  } = {}) {
2710
2791
  this.guestSipAuthorization = guestSipAuthorization;
2711
2792
  this.uri = uri;
@@ -2716,6 +2797,7 @@ class Meeting {
2716
2797
  this.extension = extension;
2717
2798
  this.persistent = persistent;
2718
2799
  this.creationTime = creationTime;
2800
+ this.requireAuthorization = requireAuthorization;
2719
2801
 
2720
2802
  // Useful to compare instead of instanceof with minified code
2721
2803
  this.type = 'Meeting';
@@ -2726,8 +2808,32 @@ class Meeting {
2726
2808
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2727
2809
  return { username, secret };
2728
2810
  }
2811
+
2729
2812
  }
2730
2813
 
2814
+ //
2815
+
2816
+ const camelToUnderscore = (key ) => {
2817
+ if (typeof key !== 'string') {
2818
+ throw new Error('Input is not a string');
2819
+ }
2820
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2821
+ };
2822
+
2823
+ //
2824
+
2825
+ const convertKeysFromCamelToUnderscore = (args ) => {
2826
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2827
+ throw new Error('Input is not an object');
2828
+ }
2829
+
2830
+ return Object.keys(args).reduce((acc, key) => {
2831
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2832
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2833
+ return acc;
2834
+ }, {});
2835
+ };
2836
+
2731
2837
  /* */
2732
2838
 
2733
2839
  var confdMethods = (client , baseUrl ) => ({
@@ -2796,8 +2902,18 @@ var confdMethods = (client , baseUrl ) => ({
2796
2902
  getMyMeetings: () =>
2797
2903
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2798
2904
 
2799
- createMyMeeting: (name , persistent ) =>
2800
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2905
+ createMyMeeting: (args ) =>
2906
+ client
2907
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2908
+ .then(Meeting.parse),
2909
+
2910
+ updateMyMeeting: (meetingUuid , data ) =>
2911
+ client.put(
2912
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2913
+ convertKeysFromCamelToUnderscore(data),
2914
+ null,
2915
+ ApiRequester.successResponseParser,
2916
+ ),
2801
2917
 
2802
2918
  deleteMyMeeting: (meetingUuid ) =>
2803
2919
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2805,8 +2921,36 @@ var confdMethods = (client , baseUrl ) => ({
2805
2921
  getMeeting: (meetingUuid ) =>
2806
2922
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2807
2923
 
2924
+ meetingAuthorizations: (meetingUuid ) =>
2925
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2926
+
2927
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2928
+ client.put(
2929
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2930
+ {},
2931
+ null,
2932
+ ApiRequester.successResponseParser,
2933
+ ),
2934
+
2935
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2936
+ client.put(
2937
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2938
+ {},
2939
+ null,
2940
+ ApiRequester.successResponseParser,
2941
+ ),
2942
+
2808
2943
  guestGetMeeting: (meetingUuid ) =>
2809
2944
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2945
+
2946
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2947
+ client
2948
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2949
+ .then(MeetingAuthorization.parse),
2950
+
2951
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2952
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2953
+
2810
2954
  });
2811
2955
 
2812
2956
  //
@@ -3991,6 +4135,7 @@ global.wazoClientId = global.wazoClientId || {};
3991
4135
  global.wazoClientToken = global.wazoClientToken || {};
3992
4136
  global.wazoRefreshToken = global.wazoRefreshToken || {};
3993
4137
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4138
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
3994
4139
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
3995
4140
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
3996
4141
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4015,9 +4160,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
4015
4160
  };
4016
4161
 
4017
4162
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
4163
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
4018
4164
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
4019
4165
  };
4020
4166
 
4167
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
4168
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
4169
+ };
4170
+
4021
4171
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
4022
4172
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
4023
4173
  };
@@ -4036,6 +4186,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
4036
4186
 
4037
4187
  const fillClient = (apiClient ) => {
4038
4188
  const { server, token, clientId } = apiClient.client;
4189
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4039
4190
 
4040
4191
  // try with null server when dealing with non-related server info
4041
4192
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4044,8 +4195,12 @@ const fillClient = (apiClient ) => {
4044
4195
 
4045
4196
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4046
4197
 
4047
- apiClient.setRefreshTenantId(
4048
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4198
+ if (tenantId) {
4199
+ apiClient.setRefreshTenantId(tenantId);
4200
+ }
4201
+
4202
+ apiClient.setRefreshDomainName(
4203
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4049
4204
  );
4050
4205
 
4051
4206
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5158,6 +5313,14 @@ var calldMethods = (client , baseUrl ) => ({
5158
5313
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5159
5314
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5160
5315
 
5316
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5317
+ client.delete(
5318
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5319
+ null,
5320
+ null,
5321
+ ApiRequester.successResponseParser,
5322
+ ),
5323
+
5161
5324
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5162
5325
 
5163
5326
  mute: (callId ) =>
@@ -5535,6 +5698,7 @@ class ApiClient {
5535
5698
 
5536
5699
 
5537
5700
 
5701
+
5538
5702
 
5539
5703
 
5540
5704
 
@@ -5576,6 +5740,7 @@ class ApiClient {
5576
5740
  refreshToken: this.refreshToken,
5577
5741
  refreshBackend: this.refreshBackend,
5578
5742
  refreshTenantId: this.refreshTenantId,
5743
+ refreshDomainName: this.refreshDomainName,
5579
5744
  refreshExpiration: this.refreshExpiration,
5580
5745
  isMobile: this.isMobile,
5581
5746
  });
@@ -5591,6 +5756,7 @@ class ApiClient {
5591
5756
  this.refreshExpiration,
5592
5757
  this.isMobile,
5593
5758
  this.refreshTenantId,
5759
+ this.refreshDomainName,
5594
5760
  );
5595
5761
 
5596
5762
  logger$a.info('token refreshed', { token: session.token });
@@ -5644,9 +5810,14 @@ class ApiClient {
5644
5810
  }
5645
5811
 
5646
5812
  setRefreshTenantId(tenantId ) {
5813
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5647
5814
  this.refreshTenantId = tenantId;
5648
5815
  }
5649
5816
 
5817
+ setRefreshDomainName(domainName ) {
5818
+ this.refreshDomainName = domainName;
5819
+ }
5820
+
5650
5821
  setIsMobile(isMobile ) {
5651
5822
  this.isMobile = isMobile;
5652
5823
  }
@@ -7335,7 +7506,7 @@ class WebRTCClient extends Emitter {
7335
7506
  });
7336
7507
  }
7337
7508
 
7338
- changeAudioInputDevice(id , session , force ) {
7509
+ async changeAudioInputDevice(id , session , force ) {
7339
7510
  const currentId = this.getAudioDeviceId();
7340
7511
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7341
7512
 
@@ -7343,33 +7514,50 @@ class WebRTCClient extends Emitter {
7343
7514
  return null;
7344
7515
  }
7345
7516
 
7517
+ // in order to handle an audio track change for default devices
7518
+ // we need the actual id of the device (not 'default')
7519
+ let deviceId = id;
7520
+ if (id === 'default' && navigator.mediaDevices) {
7521
+ const devices = await navigator.mediaDevices.enumerateDevices();
7522
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7523
+ if (defaultDevice) {
7524
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7525
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7526
+ if (targetDevice) {
7527
+ deviceId = targetDevice.deviceId;
7528
+ if (!force && deviceId === currentId) {
7529
+ return null;
7530
+ }
7531
+ }
7532
+ }
7533
+ }
7534
+
7346
7535
  // let's update the local audio value
7347
7536
  if (this.audio) {
7348
7537
  this.audio = {
7349
7538
  deviceId: {
7350
- exact: id,
7539
+ exact: deviceId,
7351
7540
  },
7352
7541
  };
7353
7542
  }
7354
7543
 
7355
- if (session) {
7544
+ if (session && navigator.mediaDevices) {
7356
7545
  const sdh = session.sessionDescriptionHandler;
7357
7546
  const pc = sdh.peerConnection;
7358
7547
 
7359
- // $FlowFixMe
7360
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7361
- const audioTrack = stream.getAudioTracks()[0];
7362
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7548
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7549
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7550
+ const audioTrack = stream.getAudioTracks()[0];
7551
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7363
7552
 
7364
- if (sender) {
7365
- if (sender.track) {
7366
- audioTrack.enabled = sender.track.enabled;
7367
- }
7368
- sender.replaceTrack(audioTrack);
7553
+ if (sender) {
7554
+ if (sender.track) {
7555
+ audioTrack.enabled = sender.track.enabled;
7369
7556
  }
7557
+ sender.replaceTrack(audioTrack);
7558
+ }
7370
7559
 
7371
- return stream;
7372
- });
7560
+ return stream;
7373
7561
  }
7374
7562
  }
7375
7563
 
@@ -7389,14 +7577,14 @@ class WebRTCClient extends Emitter {
7389
7577
  return null;
7390
7578
  }
7391
7579
 
7392
- // let's update the local video value
7393
- if (this.video) {
7394
- this.video = {
7395
- deviceId: {
7396
- exact: id,
7397
- },
7398
- };
7399
- }
7580
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7581
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7582
+ this.video = {
7583
+ ...videoObject,
7584
+ deviceId: {
7585
+ exact: id,
7586
+ },
7587
+ };
7400
7588
  }
7401
7589
 
7402
7590
  changeSessionVideoInputDevice(id , session ) {
@@ -8569,6 +8757,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
8569
8757
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
8570
8758
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
8571
8759
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
8760
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
8572
8761
 
8573
8762
  const BLACKLIST_EVENTS = [
8574
8763
  CHAT_MESSAGE_SENT,
@@ -8920,6 +9109,7 @@ WebSocketClient.eventLists = [
8920
9109
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8921
9110
  CONFERENCE_ADHOC_DELETED,
8922
9111
  MEETING_USER_PROGRESS,
9112
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
8923
9113
  ];
8924
9114
 
8925
9115
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -8991,6 +9181,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8991
9181
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8992
9182
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
8993
9183
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
9184
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
8994
9185
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
8995
9186
  'default': WebSocketClient
8996
9187
  });
@@ -9899,9 +10090,7 @@ class WebRTCPhone extends Emitter {
9899
10090
 
9900
10091
  try {
9901
10092
  if (this.currentScreenShare.stream) {
9902
- this.currentScreenShare.stream.getTracks()
9903
- .filter(track => track.kind === 'video')
9904
- .forEach(track => track.stop());
10093
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9905
10094
  }
9906
10095
 
9907
10096
  if (restoreLocalStream) {
@@ -11786,6 +11975,7 @@ const getCallableNumber = (number , country ) => {
11786
11975
  class InvalidSubscription extends Error {}
11787
11976
  class InvalidAuthorization extends Error {}
11788
11977
  class NoTenantIdError extends Error {}
11978
+ class NoDomainNameError extends Error {}
11789
11979
 
11790
11980
  const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11791
11981
 
@@ -11849,9 +12039,24 @@ class Auth {
11849
12039
  setFetchOptions(options);
11850
12040
  }
11851
12041
 
11852
- async logIn(username , password , backend , tenantId ) {
11853
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
11854
- throw new NoTenantIdError('No tenant id');
12042
+ async logIn(username , password , backend , extra ) {
12043
+ let tenantId = null;
12044
+ let domainName = null;
12045
+ if (typeof extra === 'string') {
12046
+ tenantId = extra;
12047
+ }
12048
+ if (extra && typeof extra === 'object') {
12049
+ domainName = extra.domainName;
12050
+ }
12051
+
12052
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
12053
+ if (!tenantId) {
12054
+ throw new NoTenantIdError('No tenant id');
12055
+ }
12056
+
12057
+ if (!domainName) {
12058
+ throw new NoDomainNameError('No domain name');
12059
+ }
11855
12060
  }
11856
12061
 
11857
12062
  this.authenticated = false;
@@ -11861,6 +12066,7 @@ class Auth {
11861
12066
  password,
11862
12067
  backend,
11863
12068
  tenantId,
12069
+ domainName,
11864
12070
  expiration: this.expiration,
11865
12071
  mobile: this.mobile,
11866
12072
  });
@@ -11869,7 +12075,13 @@ class Auth {
11869
12075
  getApiClient().setRefreshBackend(backend);
11870
12076
  }
11871
12077
 
11872
- getApiClient().setRefreshTenantId(tenantId);
12078
+ if (tenantId) {
12079
+ getApiClient().setRefreshTenantId(tenantId);
12080
+ }
12081
+
12082
+ if (domainName) {
12083
+ getApiClient().setRefreshDomainName(domainName);
12084
+ }
11873
12085
 
11874
12086
  return this._onAuthenticated(rawSession);
11875
12087
  }
@@ -11968,11 +12180,18 @@ class Auth {
11968
12180
  }
11969
12181
 
11970
12182
  setRefreshTenantId(refreshTenantId ) {
12183
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
11971
12184
  setRefreshTenantId(refreshTenantId);
11972
12185
 
11973
12186
  getApiClient().setRefreshTenantId(refreshTenantId);
11974
12187
  }
11975
12188
 
12189
+ setRefreshDomainName(domainName ) {
12190
+ setRefreshDomainName(domainName);
12191
+
12192
+ getApiClient().setRefreshDomainName(domainName);
12193
+ }
12194
+
11976
12195
  forceRefreshToken() {
11977
12196
  getApiClient().forceRefreshToken();
11978
12197
  }
@@ -12771,6 +12990,7 @@ class Participant extends Emitter {
12771
12990
 
12772
12991
 
12773
12992
 
12993
+
12774
12994
 
12775
12995
 
12776
12996
 
@@ -12788,6 +13008,7 @@ class Participant extends Emitter {
12788
13008
 
12789
13009
 
12790
13010
 
13011
+
12791
13012
 
12792
13013
  /**
12793
13014
  * @param room Room The room where the participant is
@@ -12811,6 +13032,7 @@ class Participant extends Emitter {
12811
13032
  this.screensharing = false;
12812
13033
  this.isOnHold = false;
12813
13034
  this.extra = extra;
13035
+ this.banned = false;
12814
13036
 
12815
13037
  this.ON_UPDATED = 'participant/ON_UPDATED';
12816
13038
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -12827,6 +13049,7 @@ class Participant extends Emitter {
12827
13049
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
12828
13050
  this.ON_HOLD = 'participant/ON_HOLD';
12829
13051
  this.ON_RESUME = 'participant/ON_RESUME';
13052
+ this.ON_BAN = 'participant/ON_BAN';
12830
13053
  }
12831
13054
 
12832
13055
  triggerEvent(name , ...args ) {
@@ -12867,6 +13090,10 @@ class Participant extends Emitter {
12867
13090
  status.extra = this.extra;
12868
13091
  break;
12869
13092
  }
13093
+ case this.ON_BAN: {
13094
+ status.banned = true;
13095
+ break;
13096
+ }
12870
13097
  }
12871
13098
 
12872
13099
  if (broadcast) {
@@ -12969,6 +13196,11 @@ class Participant extends Emitter {
12969
13196
  this.triggerUpdate(this.ON_RESUME, broadcast);
12970
13197
  }
12971
13198
 
13199
+ onBan(broadcast = true) {
13200
+ this.banned = true;
13201
+ this.triggerUpdate(this.ON_BAN, broadcast);
13202
+ }
13203
+
12972
13204
  getStatus() {
12973
13205
  return {
12974
13206
  callId: this.callId,
@@ -13015,6 +13247,10 @@ class Participant extends Emitter {
13015
13247
  }
13016
13248
  }
13017
13249
 
13250
+ if (status.banned) {
13251
+ this.onBan(false);
13252
+ }
13253
+
13018
13254
  // Poor man's object comparison
13019
13255
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
13020
13256
  this.extra = { ...this.extra, ...status.extra };
@@ -13042,6 +13278,28 @@ class Participant extends Emitter {
13042
13278
  this.streams = streams;
13043
13279
  this.videoStreams = streams;
13044
13280
  }
13281
+
13282
+ async ban(apiRequestDelay = null) {
13283
+ const { meetingUuid } = this.room;
13284
+ if (!meetingUuid) {
13285
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
13286
+ }
13287
+
13288
+ // this notifies all that someone is being banned
13289
+ this.onBan(true);
13290
+
13291
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
13292
+ if (apiRequestDelay) {
13293
+ await this.delay(apiRequestDelay);
13294
+ }
13295
+
13296
+ // proceed with the actual kick
13297
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
13298
+ }
13299
+
13300
+ async delay(ms ) {
13301
+ return new Promise(resolve => setTimeout(resolve, ms));
13302
+ }
13045
13303
  }
13046
13304
 
13047
13305
  //
@@ -13194,7 +13452,7 @@ class Room extends Emitter {
13194
13452
  logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
13195
13453
 
13196
13454
  if (!room) {
13197
- await Wazo.Phone.connect();
13455
+ await Wazo.Phone.connect({ media: constraints });
13198
13456
 
13199
13457
  const withCamera = constraints && !!constraints.video;
13200
13458
 
@@ -13639,7 +13897,7 @@ class Room extends Emitter {
13639
13897
  const participant = this._getParticipantFromCallId(status.callId);
13640
13898
 
13641
13899
  if (participant) {
13642
- // we're received, so no need to broadcast, hence the input false arg
13900
+ // we're receiving, so no need to broadcast
13643
13901
  participant.updateStatus(status, false);
13644
13902
  }
13645
13903
  break;
@@ -13906,7 +14164,7 @@ class SipRoom extends Room {
13906
14164
  logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
13907
14165
 
13908
14166
  if (!room) {
13909
- await Wazo.Phone.connect();
14167
+ await Wazo.Phone.connect({ media: constraints });
13910
14168
 
13911
14169
  const withCamera = constraints && !!constraints.video;
13912
14170
 
@@ -14251,6 +14509,7 @@ class Softphone {
14251
14509
  wrapUpDuration,
14252
14510
  enableAgent = true,
14253
14511
  tenantId,
14512
+ domainName,
14254
14513
  debug = false,
14255
14514
  } = {}) {
14256
14515
  this.url = url || 'https://softphone.wazo.io';
@@ -14275,8 +14534,12 @@ class Softphone {
14275
14534
  config.port = port;
14276
14535
  }
14277
14536
  if (tenantId) {
14537
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14278
14538
  config.tenantId = tenantId;
14279
14539
  }
14540
+ if (domainName) {
14541
+ config.domainName = domainName;
14542
+ }
14280
14543
  if (wrapUpDuration) {
14281
14544
  config.wrapUpDuration = wrapUpDuration;
14282
14545
  }
@@ -14597,6 +14860,7 @@ const Wazo = {
14597
14860
  CanceledCallError,
14598
14861
  SFUNotAvailableError,
14599
14862
  NoTenantIdError,
14863
+ NoDomainNameError,
14600
14864
  };
14601
14865
 
14602
14866
  if (window) {