@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/lib/index.js CHANGED
@@ -2241,6 +2241,7 @@ var authMethods = (client , baseUrl ) => ({
2241
2241
 
2242
2242
 
2243
2243
 
2244
+
2244
2245
  ) {
2245
2246
  const body = {
2246
2247
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2261,9 +2262,14 @@ var authMethods = (client , baseUrl ) => ({
2261
2262
  }
2262
2263
 
2263
2264
  if (params.tenantId) {
2265
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2264
2266
  body.tenant_id = params.tenantId;
2265
2267
  }
2266
2268
 
2269
+ if (params.domainName) {
2270
+ body.domain_name = params.domainName;
2271
+ }
2272
+
2267
2273
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2268
2274
  },
2269
2275
 
@@ -2276,6 +2282,7 @@ var authMethods = (client , baseUrl ) => ({
2276
2282
  expiration ,
2277
2283
  isMobile = false,
2278
2284
  tenantId ,
2285
+ domainName ,
2279
2286
  ) => {
2280
2287
  const body = {
2281
2288
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2292,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2292
  };
2286
2293
 
2287
2294
  if (tenantId) {
2295
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2288
2296
  body.tenant_id = tenantId;
2289
2297
  }
2290
2298
 
2299
+ if (domainName) {
2300
+ body.domain_name = domainName;
2301
+ }
2302
+
2291
2303
  const headers = {
2292
2304
  'Content-Type': 'application/json',
2293
2305
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2657,6 +2669,70 @@ class ExternalApp {
2657
2669
 
2658
2670
  //
2659
2671
 
2672
+ class MeetingAuthorization {
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+ constructor({
2680
+ meetingUuid,
2681
+ uuid,
2682
+ userUuid,
2683
+ userName,
2684
+ } = {}) {
2685
+ this.meetingUuid = meetingUuid;
2686
+ this.uuid = uuid;
2687
+ this.userUuid = userUuid;
2688
+ this.userName = userName;
2689
+ }
2690
+
2691
+ setStatus(status ) {
2692
+ this.status = status;
2693
+ }
2694
+
2695
+ getStatus() {
2696
+ return this.status;
2697
+ }
2698
+
2699
+ static parse(plain ) {
2700
+ const {
2701
+ meeting_uuid: meetingUuid,
2702
+ uuid,
2703
+ guest_uuid: userUuid,
2704
+ guest_name: userName,
2705
+ } = plain;
2706
+
2707
+ return new MeetingAuthorization({
2708
+ meetingUuid,
2709
+ uuid,
2710
+ userUuid,
2711
+ userName,
2712
+ });
2713
+ }
2714
+
2715
+ static parseMany(items ) {
2716
+ if (!items) {
2717
+ return [];
2718
+ }
2719
+ return items.map(MeetingAuthorization.parse);
2720
+ }
2721
+ }
2722
+
2723
+ //
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2660
2736
 
2661
2737
 
2662
2738
 
@@ -2667,6 +2743,7 @@ class ExternalApp {
2667
2743
 
2668
2744
 
2669
2745
 
2746
+
2670
2747
 
2671
2748
 
2672
2749
  class Meeting {
@@ -2681,6 +2758,8 @@ class Meeting {
2681
2758
 
2682
2759
 
2683
2760
 
2761
+
2762
+
2684
2763
 
2685
2764
  static parse(plain ) {
2686
2765
  return new Meeting({
@@ -2693,6 +2772,7 @@ class Meeting {
2693
2772
  extension: plain.exten,
2694
2773
  persistent: plain.persistent,
2695
2774
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2775
+ requireAuthorization: plain.require_authorization,
2696
2776
  });
2697
2777
  }
2698
2778
 
@@ -2717,6 +2797,7 @@ class Meeting {
2717
2797
  extension,
2718
2798
  persistent,
2719
2799
  creationTime,
2800
+ requireAuthorization,
2720
2801
  } = {}) {
2721
2802
  this.guestSipAuthorization = guestSipAuthorization;
2722
2803
  this.uri = uri;
@@ -2727,6 +2808,7 @@ class Meeting {
2727
2808
  this.extension = extension;
2728
2809
  this.persistent = persistent;
2729
2810
  this.creationTime = creationTime;
2811
+ this.requireAuthorization = requireAuthorization;
2730
2812
 
2731
2813
  // Useful to compare instead of instanceof with minified code
2732
2814
  this.type = 'Meeting';
@@ -2737,8 +2819,32 @@ class Meeting {
2737
2819
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2738
2820
  return { username, secret };
2739
2821
  }
2822
+
2740
2823
  }
2741
2824
 
2825
+ //
2826
+
2827
+ const camelToUnderscore = (key ) => {
2828
+ if (typeof key !== 'string') {
2829
+ throw new Error('Input is not a string');
2830
+ }
2831
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2832
+ };
2833
+
2834
+ //
2835
+
2836
+ const convertKeysFromCamelToUnderscore = (args ) => {
2837
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2838
+ throw new Error('Input is not an object');
2839
+ }
2840
+
2841
+ return Object.keys(args).reduce((acc, key) => {
2842
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2843
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2844
+ return acc;
2845
+ }, {});
2846
+ };
2847
+
2742
2848
  /* */
2743
2849
 
2744
2850
  var confdMethods = (client , baseUrl ) => ({
@@ -2807,8 +2913,18 @@ var confdMethods = (client , baseUrl ) => ({
2807
2913
  getMyMeetings: () =>
2808
2914
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2809
2915
 
2810
- createMyMeeting: (name , persistent ) =>
2811
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2916
+ createMyMeeting: (args ) =>
2917
+ client
2918
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2919
+ .then(Meeting.parse),
2920
+
2921
+ updateMyMeeting: (meetingUuid , data ) =>
2922
+ client.put(
2923
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2924
+ convertKeysFromCamelToUnderscore(data),
2925
+ null,
2926
+ ApiRequester.successResponseParser,
2927
+ ),
2812
2928
 
2813
2929
  deleteMyMeeting: (meetingUuid ) =>
2814
2930
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2816,8 +2932,36 @@ var confdMethods = (client , baseUrl ) => ({
2816
2932
  getMeeting: (meetingUuid ) =>
2817
2933
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2818
2934
 
2935
+ meetingAuthorizations: (meetingUuid ) =>
2936
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2937
+
2938
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2939
+ client.put(
2940
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2941
+ {},
2942
+ null,
2943
+ ApiRequester.successResponseParser,
2944
+ ),
2945
+
2946
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2947
+ client.put(
2948
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2949
+ {},
2950
+ null,
2951
+ ApiRequester.successResponseParser,
2952
+ ),
2953
+
2819
2954
  guestGetMeeting: (meetingUuid ) =>
2820
2955
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2956
+
2957
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2958
+ client
2959
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2960
+ .then(MeetingAuthorization.parse),
2961
+
2962
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2963
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2964
+
2821
2965
  });
2822
2966
 
2823
2967
  //
@@ -4002,6 +4146,7 @@ global.wazoClientId = global.wazoClientId || {};
4002
4146
  global.wazoClientToken = global.wazoClientToken || {};
4003
4147
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4004
4148
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4149
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4005
4150
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4006
4151
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4007
4152
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4026,9 +4171,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
4026
4171
  };
4027
4172
 
4028
4173
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
4174
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
4029
4175
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
4030
4176
  };
4031
4177
 
4178
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
4179
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
4180
+ };
4181
+
4032
4182
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
4033
4183
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
4034
4184
  };
@@ -4047,6 +4197,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
4047
4197
 
4048
4198
  const fillClient = (apiClient ) => {
4049
4199
  const { server, token, clientId } = apiClient.client;
4200
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4050
4201
 
4051
4202
  // try with null server when dealing with non-related server info
4052
4203
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4055,8 +4206,12 @@ const fillClient = (apiClient ) => {
4055
4206
 
4056
4207
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4057
4208
 
4058
- apiClient.setRefreshTenantId(
4059
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4209
+ if (tenantId) {
4210
+ apiClient.setRefreshTenantId(tenantId);
4211
+ }
4212
+
4213
+ apiClient.setRefreshDomainName(
4214
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4060
4215
  );
4061
4216
 
4062
4217
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5169,6 +5324,14 @@ var calldMethods = (client , baseUrl ) => ({
5169
5324
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5170
5325
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5171
5326
 
5327
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5328
+ client.delete(
5329
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5330
+ null,
5331
+ null,
5332
+ ApiRequester.successResponseParser,
5333
+ ),
5334
+
5172
5335
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5173
5336
 
5174
5337
  mute: (callId ) =>
@@ -5546,6 +5709,7 @@ class ApiClient {
5546
5709
 
5547
5710
 
5548
5711
 
5712
+
5549
5713
 
5550
5714
 
5551
5715
 
@@ -5587,6 +5751,7 @@ class ApiClient {
5587
5751
  refreshToken: this.refreshToken,
5588
5752
  refreshBackend: this.refreshBackend,
5589
5753
  refreshTenantId: this.refreshTenantId,
5754
+ refreshDomainName: this.refreshDomainName,
5590
5755
  refreshExpiration: this.refreshExpiration,
5591
5756
  isMobile: this.isMobile,
5592
5757
  });
@@ -5602,6 +5767,7 @@ class ApiClient {
5602
5767
  this.refreshExpiration,
5603
5768
  this.isMobile,
5604
5769
  this.refreshTenantId,
5770
+ this.refreshDomainName,
5605
5771
  );
5606
5772
 
5607
5773
  logger$a.info('token refreshed', { token: session.token });
@@ -5655,9 +5821,14 @@ class ApiClient {
5655
5821
  }
5656
5822
 
5657
5823
  setRefreshTenantId(tenantId ) {
5824
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5658
5825
  this.refreshTenantId = tenantId;
5659
5826
  }
5660
5827
 
5828
+ setRefreshDomainName(domainName ) {
5829
+ this.refreshDomainName = domainName;
5830
+ }
5831
+
5661
5832
  setIsMobile(isMobile ) {
5662
5833
  this.isMobile = isMobile;
5663
5834
  }
@@ -7346,7 +7517,7 @@ class WebRTCClient extends Emitter {
7346
7517
  });
7347
7518
  }
7348
7519
 
7349
- changeAudioInputDevice(id , session , force ) {
7520
+ async changeAudioInputDevice(id , session , force ) {
7350
7521
  const currentId = this.getAudioDeviceId();
7351
7522
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7352
7523
 
@@ -7354,33 +7525,50 @@ class WebRTCClient extends Emitter {
7354
7525
  return null;
7355
7526
  }
7356
7527
 
7528
+ // in order to handle an audio track change for default devices
7529
+ // we need the actual id of the device (not 'default')
7530
+ let deviceId = id;
7531
+ if (id === 'default' && navigator.mediaDevices) {
7532
+ const devices = await navigator.mediaDevices.enumerateDevices();
7533
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
7534
+ if (defaultDevice) {
7535
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
7536
+ const targetDevice = devices.find(device => device.label === deviceLabel);
7537
+ if (targetDevice) {
7538
+ deviceId = targetDevice.deviceId;
7539
+ if (!force && deviceId === currentId) {
7540
+ return null;
7541
+ }
7542
+ }
7543
+ }
7544
+ }
7545
+
7357
7546
  // let's update the local audio value
7358
7547
  if (this.audio) {
7359
7548
  this.audio = {
7360
7549
  deviceId: {
7361
- exact: id,
7550
+ exact: deviceId,
7362
7551
  },
7363
7552
  };
7364
7553
  }
7365
7554
 
7366
- if (session) {
7555
+ if (session && navigator.mediaDevices) {
7367
7556
  const sdh = session.sessionDescriptionHandler;
7368
7557
  const pc = sdh.peerConnection;
7369
7558
 
7370
- // $FlowFixMe
7371
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7372
- const audioTrack = stream.getAudioTracks()[0];
7373
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7559
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
7560
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
7561
+ const audioTrack = stream.getAudioTracks()[0];
7562
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7374
7563
 
7375
- if (sender) {
7376
- if (sender.track) {
7377
- audioTrack.enabled = sender.track.enabled;
7378
- }
7379
- sender.replaceTrack(audioTrack);
7564
+ if (sender) {
7565
+ if (sender.track) {
7566
+ audioTrack.enabled = sender.track.enabled;
7380
7567
  }
7568
+ sender.replaceTrack(audioTrack);
7569
+ }
7381
7570
 
7382
- return stream;
7383
- });
7571
+ return stream;
7384
7572
  }
7385
7573
  }
7386
7574
 
@@ -7400,14 +7588,14 @@ class WebRTCClient extends Emitter {
7400
7588
  return null;
7401
7589
  }
7402
7590
 
7403
- // let's update the local video value
7404
- if (this.video) {
7405
- this.video = {
7406
- deviceId: {
7407
- exact: id,
7408
- },
7409
- };
7410
- }
7591
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
7592
+ const videoObject = typeof this.video === 'object' ? this.video : {};
7593
+ this.video = {
7594
+ ...videoObject,
7595
+ deviceId: {
7596
+ exact: id,
7597
+ },
7598
+ };
7411
7599
  }
7412
7600
 
7413
7601
  changeSessionVideoInputDevice(id , session ) {
@@ -8580,6 +8768,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
8580
8768
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
8581
8769
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
8582
8770
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
8771
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
8583
8772
 
8584
8773
  const BLACKLIST_EVENTS = [
8585
8774
  CHAT_MESSAGE_SENT,
@@ -8931,6 +9120,7 @@ WebSocketClient.eventLists = [
8931
9120
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8932
9121
  CONFERENCE_ADHOC_DELETED,
8933
9122
  MEETING_USER_PROGRESS,
9123
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
8934
9124
  ];
8935
9125
 
8936
9126
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -9002,6 +9192,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
9002
9192
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
9003
9193
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
9004
9194
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
9195
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
9005
9196
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
9006
9197
  'default': WebSocketClient
9007
9198
  });
@@ -9910,9 +10101,7 @@ class WebRTCPhone extends Emitter {
9910
10101
 
9911
10102
  try {
9912
10103
  if (this.currentScreenShare.stream) {
9913
- this.currentScreenShare.stream.getTracks()
9914
- .filter(track => track.kind === 'video')
9915
- .forEach(track => track.stop());
10104
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9916
10105
  }
9917
10106
 
9918
10107
  if (restoreLocalStream) {
@@ -11797,6 +11986,7 @@ const getCallableNumber = (number , country ) => {
11797
11986
  class InvalidSubscription extends Error {}
11798
11987
  class InvalidAuthorization extends Error {}
11799
11988
  class NoTenantIdError extends Error {}
11989
+ class NoDomainNameError extends Error {}
11800
11990
 
11801
11991
  const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11802
11992
 
@@ -11860,9 +12050,24 @@ class Auth {
11860
12050
  setFetchOptions(options);
11861
12051
  }
11862
12052
 
11863
- async logIn(username , password , backend , tenantId ) {
11864
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
11865
- throw new NoTenantIdError('No tenant id');
12053
+ async logIn(username , password , backend , extra ) {
12054
+ let tenantId = null;
12055
+ let domainName = null;
12056
+ if (typeof extra === 'string') {
12057
+ tenantId = extra;
12058
+ }
12059
+ if (extra && typeof extra === 'object') {
12060
+ domainName = extra.domainName;
12061
+ }
12062
+
12063
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
12064
+ if (!tenantId) {
12065
+ throw new NoTenantIdError('No tenant id');
12066
+ }
12067
+
12068
+ if (!domainName) {
12069
+ throw new NoDomainNameError('No domain name');
12070
+ }
11866
12071
  }
11867
12072
 
11868
12073
  this.authenticated = false;
@@ -11872,6 +12077,7 @@ class Auth {
11872
12077
  password,
11873
12078
  backend,
11874
12079
  tenantId,
12080
+ domainName,
11875
12081
  expiration: this.expiration,
11876
12082
  mobile: this.mobile,
11877
12083
  });
@@ -11880,7 +12086,13 @@ class Auth {
11880
12086
  getApiClient().setRefreshBackend(backend);
11881
12087
  }
11882
12088
 
11883
- getApiClient().setRefreshTenantId(tenantId);
12089
+ if (tenantId) {
12090
+ getApiClient().setRefreshTenantId(tenantId);
12091
+ }
12092
+
12093
+ if (domainName) {
12094
+ getApiClient().setRefreshDomainName(domainName);
12095
+ }
11884
12096
 
11885
12097
  return this._onAuthenticated(rawSession);
11886
12098
  }
@@ -11979,11 +12191,18 @@ class Auth {
11979
12191
  }
11980
12192
 
11981
12193
  setRefreshTenantId(refreshTenantId ) {
12194
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
11982
12195
  setRefreshTenantId(refreshTenantId);
11983
12196
 
11984
12197
  getApiClient().setRefreshTenantId(refreshTenantId);
11985
12198
  }
11986
12199
 
12200
+ setRefreshDomainName(domainName ) {
12201
+ setRefreshDomainName(domainName);
12202
+
12203
+ getApiClient().setRefreshDomainName(domainName);
12204
+ }
12205
+
11987
12206
  forceRefreshToken() {
11988
12207
  getApiClient().forceRefreshToken();
11989
12208
  }
@@ -12782,6 +13001,7 @@ class Participant extends Emitter {
12782
13001
 
12783
13002
 
12784
13003
 
13004
+
12785
13005
 
12786
13006
 
12787
13007
 
@@ -12799,6 +13019,7 @@ class Participant extends Emitter {
12799
13019
 
12800
13020
 
12801
13021
 
13022
+
12802
13023
 
12803
13024
  /**
12804
13025
  * @param room Room The room where the participant is
@@ -12822,6 +13043,7 @@ class Participant extends Emitter {
12822
13043
  this.screensharing = false;
12823
13044
  this.isOnHold = false;
12824
13045
  this.extra = extra;
13046
+ this.banned = false;
12825
13047
 
12826
13048
  this.ON_UPDATED = 'participant/ON_UPDATED';
12827
13049
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -12838,6 +13060,7 @@ class Participant extends Emitter {
12838
13060
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
12839
13061
  this.ON_HOLD = 'participant/ON_HOLD';
12840
13062
  this.ON_RESUME = 'participant/ON_RESUME';
13063
+ this.ON_BAN = 'participant/ON_BAN';
12841
13064
  }
12842
13065
 
12843
13066
  triggerEvent(name , ...args ) {
@@ -12878,6 +13101,10 @@ class Participant extends Emitter {
12878
13101
  status.extra = this.extra;
12879
13102
  break;
12880
13103
  }
13104
+ case this.ON_BAN: {
13105
+ status.banned = true;
13106
+ break;
13107
+ }
12881
13108
  }
12882
13109
 
12883
13110
  if (broadcast) {
@@ -12980,6 +13207,11 @@ class Participant extends Emitter {
12980
13207
  this.triggerUpdate(this.ON_RESUME, broadcast);
12981
13208
  }
12982
13209
 
13210
+ onBan(broadcast = true) {
13211
+ this.banned = true;
13212
+ this.triggerUpdate(this.ON_BAN, broadcast);
13213
+ }
13214
+
12983
13215
  getStatus() {
12984
13216
  return {
12985
13217
  callId: this.callId,
@@ -13026,6 +13258,10 @@ class Participant extends Emitter {
13026
13258
  }
13027
13259
  }
13028
13260
 
13261
+ if (status.banned) {
13262
+ this.onBan(false);
13263
+ }
13264
+
13029
13265
  // Poor man's object comparison
13030
13266
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
13031
13267
  this.extra = { ...this.extra, ...status.extra };
@@ -13053,6 +13289,28 @@ class Participant extends Emitter {
13053
13289
  this.streams = streams;
13054
13290
  this.videoStreams = streams;
13055
13291
  }
13292
+
13293
+ async ban(apiRequestDelay = null) {
13294
+ const { meetingUuid } = this.room;
13295
+ if (!meetingUuid) {
13296
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
13297
+ }
13298
+
13299
+ // this notifies all that someone is being banned
13300
+ this.onBan(true);
13301
+
13302
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
13303
+ if (apiRequestDelay) {
13304
+ await this.delay(apiRequestDelay);
13305
+ }
13306
+
13307
+ // proceed with the actual kick
13308
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
13309
+ }
13310
+
13311
+ async delay(ms ) {
13312
+ return new Promise(resolve => setTimeout(resolve, ms));
13313
+ }
13056
13314
  }
13057
13315
 
13058
13316
  //
@@ -13205,7 +13463,7 @@ class Room extends Emitter {
13205
13463
  logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
13206
13464
 
13207
13465
  if (!room) {
13208
- await Wazo.Phone.connect();
13466
+ await Wazo.Phone.connect({ media: constraints });
13209
13467
 
13210
13468
  const withCamera = constraints && !!constraints.video;
13211
13469
 
@@ -13650,7 +13908,7 @@ class Room extends Emitter {
13650
13908
  const participant = this._getParticipantFromCallId(status.callId);
13651
13909
 
13652
13910
  if (participant) {
13653
- // we're received, so no need to broadcast, hence the input false arg
13911
+ // we're receiving, so no need to broadcast
13654
13912
  participant.updateStatus(status, false);
13655
13913
  }
13656
13914
  break;
@@ -13917,7 +14175,7 @@ class SipRoom extends Room {
13917
14175
  logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
13918
14176
 
13919
14177
  if (!room) {
13920
- await Wazo.Phone.connect();
14178
+ await Wazo.Phone.connect({ media: constraints });
13921
14179
 
13922
14180
  const withCamera = constraints && !!constraints.video;
13923
14181
 
@@ -14262,6 +14520,7 @@ class Softphone {
14262
14520
  wrapUpDuration,
14263
14521
  enableAgent = true,
14264
14522
  tenantId,
14523
+ domainName,
14265
14524
  debug = false,
14266
14525
  } = {}) {
14267
14526
  this.url = url || 'https://softphone.wazo.io';
@@ -14286,8 +14545,12 @@ class Softphone {
14286
14545
  config.port = port;
14287
14546
  }
14288
14547
  if (tenantId) {
14548
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14289
14549
  config.tenantId = tenantId;
14290
14550
  }
14551
+ if (domainName) {
14552
+ config.domainName = domainName;
14553
+ }
14291
14554
  if (wrapUpDuration) {
14292
14555
  config.wrapUpDuration = wrapUpDuration;
14293
14556
  }
@@ -14608,6 +14871,7 @@ const Wazo = {
14608
14871
  CanceledCallError,
14609
14872
  SFUNotAvailableError,
14610
14873
  NoTenantIdError,
14874
+ NoDomainNameError,
14611
14875
  };
14612
14876
 
14613
14877
  if (window) {