@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
@@ -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
  //
@@ -5068,6 +5212,14 @@ var calldMethods = (client , baseUrl ) => ({
5068
5212
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5069
5213
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5070
5214
 
5215
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5216
+ client.delete(
5217
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5218
+ null,
5219
+ null,
5220
+ ApiRequester.successResponseParser,
5221
+ ),
5222
+
5071
5223
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5072
5224
 
5073
5225
  mute: (callId ) =>
@@ -5445,6 +5597,7 @@ class ApiClient {
5445
5597
 
5446
5598
 
5447
5599
 
5600
+
5448
5601
 
5449
5602
 
5450
5603
 
@@ -5486,6 +5639,7 @@ class ApiClient {
5486
5639
  refreshToken: this.refreshToken,
5487
5640
  refreshBackend: this.refreshBackend,
5488
5641
  refreshTenantId: this.refreshTenantId,
5642
+ refreshDomainName: this.refreshDomainName,
5489
5643
  refreshExpiration: this.refreshExpiration,
5490
5644
  isMobile: this.isMobile,
5491
5645
  });
@@ -5501,6 +5655,7 @@ class ApiClient {
5501
5655
  this.refreshExpiration,
5502
5656
  this.isMobile,
5503
5657
  this.refreshTenantId,
5658
+ this.refreshDomainName,
5504
5659
  );
5505
5660
 
5506
5661
  logger$a.info('token refreshed', { token: session.token });
@@ -5554,9 +5709,14 @@ class ApiClient {
5554
5709
  }
5555
5710
 
5556
5711
  setRefreshTenantId(tenantId ) {
5712
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5557
5713
  this.refreshTenantId = tenantId;
5558
5714
  }
5559
5715
 
5716
+ setRefreshDomainName(domainName ) {
5717
+ this.refreshDomainName = domainName;
5718
+ }
5719
+
5560
5720
  setIsMobile(isMobile ) {
5561
5721
  this.isMobile = isMobile;
5562
5722
  }
@@ -5581,6 +5741,7 @@ global.wazoClientId = global.wazoClientId || {};
5581
5741
  global.wazoClientToken = global.wazoClientToken || {};
5582
5742
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5583
5743
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5744
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5584
5745
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5585
5746
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5586
5747
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5605,9 +5766,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5605
5766
  };
5606
5767
 
5607
5768
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5769
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5608
5770
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5609
5771
  };
5610
5772
 
5773
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5774
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5775
+ };
5776
+
5611
5777
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5612
5778
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5613
5779
  };
@@ -5626,6 +5792,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5626
5792
 
5627
5793
  const fillClient = (apiClient ) => {
5628
5794
  const { server, token, clientId } = apiClient.client;
5795
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5629
5796
 
5630
5797
  // try with null server when dealing with non-related server info
5631
5798
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5634,8 +5801,12 @@ const fillClient = (apiClient ) => {
5634
5801
 
5635
5802
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5636
5803
 
5637
- apiClient.setRefreshTenantId(
5638
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5804
+ if (tenantId) {
5805
+ apiClient.setRefreshTenantId(tenantId);
5806
+ }
5807
+
5808
+ apiClient.setRefreshDomainName(
5809
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5639
5810
  );
5640
5811
 
5641
5812
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5677,6 +5848,7 @@ var getApiClient = (forServer = null) => {
5677
5848
  class InvalidSubscription extends Error {}
5678
5849
  class InvalidAuthorization extends Error {}
5679
5850
  class NoTenantIdError extends Error {}
5851
+ class NoDomainNameError extends Error {}
5680
5852
 
5681
5853
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5682
5854
 
@@ -5740,9 +5912,24 @@ class Auth {
5740
5912
  setFetchOptions(options);
5741
5913
  }
5742
5914
 
5743
- async logIn(username , password , backend , tenantId ) {
5744
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5745
- throw new NoTenantIdError('No tenant id');
5915
+ async logIn(username , password , backend , extra ) {
5916
+ let tenantId = null;
5917
+ let domainName = null;
5918
+ if (typeof extra === 'string') {
5919
+ tenantId = extra;
5920
+ }
5921
+ if (extra && typeof extra === 'object') {
5922
+ domainName = extra.domainName;
5923
+ }
5924
+
5925
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5926
+ if (!tenantId) {
5927
+ throw new NoTenantIdError('No tenant id');
5928
+ }
5929
+
5930
+ if (!domainName) {
5931
+ throw new NoDomainNameError('No domain name');
5932
+ }
5746
5933
  }
5747
5934
 
5748
5935
  this.authenticated = false;
@@ -5752,6 +5939,7 @@ class Auth {
5752
5939
  password,
5753
5940
  backend,
5754
5941
  tenantId,
5942
+ domainName,
5755
5943
  expiration: this.expiration,
5756
5944
  mobile: this.mobile,
5757
5945
  });
@@ -5760,7 +5948,13 @@ class Auth {
5760
5948
  getApiClient().setRefreshBackend(backend);
5761
5949
  }
5762
5950
 
5763
- getApiClient().setRefreshTenantId(tenantId);
5951
+ if (tenantId) {
5952
+ getApiClient().setRefreshTenantId(tenantId);
5953
+ }
5954
+
5955
+ if (domainName) {
5956
+ getApiClient().setRefreshDomainName(domainName);
5957
+ }
5764
5958
 
5765
5959
  return this._onAuthenticated(rawSession);
5766
5960
  }
@@ -5859,11 +6053,18 @@ class Auth {
5859
6053
  }
5860
6054
 
5861
6055
  setRefreshTenantId(refreshTenantId ) {
6056
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
5862
6057
  setRefreshTenantId(refreshTenantId);
5863
6058
 
5864
6059
  getApiClient().setRefreshTenantId(refreshTenantId);
5865
6060
  }
5866
6061
 
6062
+ setRefreshDomainName(domainName ) {
6063
+ setRefreshDomainName(domainName);
6064
+
6065
+ getApiClient().setRefreshDomainName(domainName);
6066
+ }
6067
+
5867
6068
  forceRefreshToken() {
5868
6069
  getApiClient().forceRefreshToken();
5869
6070
  }
@@ -7826,7 +8027,7 @@ class WebRTCClient extends Emitter {
7826
8027
  });
7827
8028
  }
7828
8029
 
7829
- changeAudioInputDevice(id , session , force ) {
8030
+ async changeAudioInputDevice(id , session , force ) {
7830
8031
  const currentId = this.getAudioDeviceId();
7831
8032
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7832
8033
 
@@ -7834,33 +8035,50 @@ class WebRTCClient extends Emitter {
7834
8035
  return null;
7835
8036
  }
7836
8037
 
8038
+ // in order to handle an audio track change for default devices
8039
+ // we need the actual id of the device (not 'default')
8040
+ let deviceId = id;
8041
+ if (id === 'default' && navigator.mediaDevices) {
8042
+ const devices = await navigator.mediaDevices.enumerateDevices();
8043
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
8044
+ if (defaultDevice) {
8045
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
8046
+ const targetDevice = devices.find(device => device.label === deviceLabel);
8047
+ if (targetDevice) {
8048
+ deviceId = targetDevice.deviceId;
8049
+ if (!force && deviceId === currentId) {
8050
+ return null;
8051
+ }
8052
+ }
8053
+ }
8054
+ }
8055
+
7837
8056
  // let's update the local audio value
7838
8057
  if (this.audio) {
7839
8058
  this.audio = {
7840
8059
  deviceId: {
7841
- exact: id,
8060
+ exact: deviceId,
7842
8061
  },
7843
8062
  };
7844
8063
  }
7845
8064
 
7846
- if (session) {
8065
+ if (session && navigator.mediaDevices) {
7847
8066
  const sdh = session.sessionDescriptionHandler;
7848
8067
  const pc = sdh.peerConnection;
7849
8068
 
7850
- // $FlowFixMe
7851
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7852
- const audioTrack = stream.getAudioTracks()[0];
7853
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8069
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
8070
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
8071
+ const audioTrack = stream.getAudioTracks()[0];
8072
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7854
8073
 
7855
- if (sender) {
7856
- if (sender.track) {
7857
- audioTrack.enabled = sender.track.enabled;
7858
- }
7859
- sender.replaceTrack(audioTrack);
8074
+ if (sender) {
8075
+ if (sender.track) {
8076
+ audioTrack.enabled = sender.track.enabled;
7860
8077
  }
8078
+ sender.replaceTrack(audioTrack);
8079
+ }
7861
8080
 
7862
- return stream;
7863
- });
8081
+ return stream;
7864
8082
  }
7865
8083
  }
7866
8084
 
@@ -7880,14 +8098,14 @@ class WebRTCClient extends Emitter {
7880
8098
  return null;
7881
8099
  }
7882
8100
 
7883
- // let's update the local video value
7884
- if (this.video) {
7885
- this.video = {
7886
- deviceId: {
7887
- exact: id,
7888
- },
7889
- };
7890
- }
8101
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
8102
+ const videoObject = typeof this.video === 'object' ? this.video : {};
8103
+ this.video = {
8104
+ ...videoObject,
8105
+ deviceId: {
8106
+ exact: id,
8107
+ },
8108
+ };
7891
8109
  }
7892
8110
 
7893
8111
  changeSessionVideoInputDevice(id , session ) {
@@ -9489,9 +9707,7 @@ class WebRTCPhone extends Emitter {
9489
9707
 
9490
9708
  try {
9491
9709
  if (this.currentScreenShare.stream) {
9492
- this.currentScreenShare.stream.getTracks()
9493
- .filter(track => track.kind === 'video')
9494
- .forEach(track => track.stop());
9710
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9495
9711
  }
9496
9712
 
9497
9713
  if (restoreLocalStream) {
@@ -11282,6 +11498,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
11282
11498
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
11283
11499
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
11284
11500
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11501
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
11285
11502
 
11286
11503
  const BLACKLIST_EVENTS = [
11287
11504
  CHAT_MESSAGE_SENT,
@@ -11633,6 +11850,7 @@ WebSocketClient.eventLists = [
11633
11850
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11634
11851
  CONFERENCE_ADHOC_DELETED,
11635
11852
  MEETING_USER_PROGRESS,
11853
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11636
11854
  ];
11637
11855
 
11638
11856
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11704,6 +11922,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11704
11922
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11705
11923
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11706
11924
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11925
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11707
11926
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11708
11927
  'default': WebSocketClient
11709
11928
  });
@@ -11808,6 +12027,7 @@ class Participant extends Emitter {
11808
12027
 
11809
12028
 
11810
12029
 
12030
+
11811
12031
 
11812
12032
 
11813
12033
 
@@ -11825,6 +12045,7 @@ class Participant extends Emitter {
11825
12045
 
11826
12046
 
11827
12047
 
12048
+
11828
12049
 
11829
12050
  /**
11830
12051
  * @param room Room The room where the participant is
@@ -11848,6 +12069,7 @@ class Participant extends Emitter {
11848
12069
  this.screensharing = false;
11849
12070
  this.isOnHold = false;
11850
12071
  this.extra = extra;
12072
+ this.banned = false;
11851
12073
 
11852
12074
  this.ON_UPDATED = 'participant/ON_UPDATED';
11853
12075
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11864,6 +12086,7 @@ class Participant extends Emitter {
11864
12086
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11865
12087
  this.ON_HOLD = 'participant/ON_HOLD';
11866
12088
  this.ON_RESUME = 'participant/ON_RESUME';
12089
+ this.ON_BAN = 'participant/ON_BAN';
11867
12090
  }
11868
12091
 
11869
12092
  triggerEvent(name , ...args ) {
@@ -11904,6 +12127,10 @@ class Participant extends Emitter {
11904
12127
  status.extra = this.extra;
11905
12128
  break;
11906
12129
  }
12130
+ case this.ON_BAN: {
12131
+ status.banned = true;
12132
+ break;
12133
+ }
11907
12134
  }
11908
12135
 
11909
12136
  if (broadcast) {
@@ -12006,6 +12233,11 @@ class Participant extends Emitter {
12006
12233
  this.triggerUpdate(this.ON_RESUME, broadcast);
12007
12234
  }
12008
12235
 
12236
+ onBan(broadcast = true) {
12237
+ this.banned = true;
12238
+ this.triggerUpdate(this.ON_BAN, broadcast);
12239
+ }
12240
+
12009
12241
  getStatus() {
12010
12242
  return {
12011
12243
  callId: this.callId,
@@ -12052,6 +12284,10 @@ class Participant extends Emitter {
12052
12284
  }
12053
12285
  }
12054
12286
 
12287
+ if (status.banned) {
12288
+ this.onBan(false);
12289
+ }
12290
+
12055
12291
  // Poor man's object comparison
12056
12292
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
12057
12293
  this.extra = { ...this.extra, ...status.extra };
@@ -12079,6 +12315,28 @@ class Participant extends Emitter {
12079
12315
  this.streams = streams;
12080
12316
  this.videoStreams = streams;
12081
12317
  }
12318
+
12319
+ async ban(apiRequestDelay = null) {
12320
+ const { meetingUuid } = this.room;
12321
+ if (!meetingUuid) {
12322
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
12323
+ }
12324
+
12325
+ // this notifies all that someone is being banned
12326
+ this.onBan(true);
12327
+
12328
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
12329
+ if (apiRequestDelay) {
12330
+ await this.delay(apiRequestDelay);
12331
+ }
12332
+
12333
+ // proceed with the actual kick
12334
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12335
+ }
12336
+
12337
+ async delay(ms ) {
12338
+ return new Promise(resolve => setTimeout(resolve, ms));
12339
+ }
12082
12340
  }
12083
12341
 
12084
12342
  //
@@ -12231,7 +12489,7 @@ class Room$1 extends Emitter {
12231
12489
  logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
12232
12490
 
12233
12491
  if (!room) {
12234
- await Wazo.Phone.connect();
12492
+ await Wazo.Phone.connect({ media: constraints });
12235
12493
 
12236
12494
  const withCamera = constraints && !!constraints.video;
12237
12495
 
@@ -12676,7 +12934,7 @@ class Room$1 extends Emitter {
12676
12934
  const participant = this._getParticipantFromCallId(status.callId);
12677
12935
 
12678
12936
  if (participant) {
12679
- // we're received, so no need to broadcast, hence the input false arg
12937
+ // we're receiving, so no need to broadcast
12680
12938
  participant.updateStatus(status, false);
12681
12939
  }
12682
12940
  break;
@@ -12943,7 +13201,7 @@ class SipRoom extends Room$1 {
12943
13201
  logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
12944
13202
 
12945
13203
  if (!room) {
12946
- await Wazo.Phone.connect();
13204
+ await Wazo.Phone.connect({ media: constraints });
12947
13205
 
12948
13206
  const withCamera = constraints && !!constraints.video;
12949
13207
 
@@ -14109,6 +14367,7 @@ class Softphone {
14109
14367
  wrapUpDuration,
14110
14368
  enableAgent = true,
14111
14369
  tenantId,
14370
+ domainName,
14112
14371
  debug = false,
14113
14372
  } = {}) {
14114
14373
  this.url = url || 'https://softphone.wazo.io';
@@ -14133,8 +14392,12 @@ class Softphone {
14133
14392
  config.port = port;
14134
14393
  }
14135
14394
  if (tenantId) {
14395
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14136
14396
  config.tenantId = tenantId;
14137
14397
  }
14398
+ if (domainName) {
14399
+ config.domainName = domainName;
14400
+ }
14138
14401
  if (wrapUpDuration) {
14139
14402
  config.wrapUpDuration = wrapUpDuration;
14140
14403
  }
@@ -14455,6 +14718,7 @@ const Wazo = {
14455
14718
  CanceledCallError,
14456
14719
  SFUNotAvailableError,
14457
14720
  NoTenantIdError,
14721
+ NoDomainNameError,
14458
14722
  };
14459
14723
 
14460
14724
  if (window) {