@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
  });
@@ -11801,7 +12020,7 @@ class SipRoom extends Room {
11801
12020
  logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11802
12021
 
11803
12022
  if (!room) {
11804
- await Wazo.Phone.connect();
12023
+ await Wazo.Phone.connect({ media: constraints });
11805
12024
 
11806
12025
  const withCamera = constraints && !!constraints.video;
11807
12026
 
@@ -11947,6 +12166,7 @@ class Participant extends Emitter {
11947
12166
 
11948
12167
 
11949
12168
 
12169
+
11950
12170
 
11951
12171
 
11952
12172
 
@@ -11964,6 +12184,7 @@ class Participant extends Emitter {
11964
12184
 
11965
12185
 
11966
12186
 
12187
+
11967
12188
 
11968
12189
  /**
11969
12190
  * @param room Room The room where the participant is
@@ -11987,6 +12208,7 @@ class Participant extends Emitter {
11987
12208
  this.screensharing = false;
11988
12209
  this.isOnHold = false;
11989
12210
  this.extra = extra;
12211
+ this.banned = false;
11990
12212
 
11991
12213
  this.ON_UPDATED = 'participant/ON_UPDATED';
11992
12214
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -12003,6 +12225,7 @@ class Participant extends Emitter {
12003
12225
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
12004
12226
  this.ON_HOLD = 'participant/ON_HOLD';
12005
12227
  this.ON_RESUME = 'participant/ON_RESUME';
12228
+ this.ON_BAN = 'participant/ON_BAN';
12006
12229
  }
12007
12230
 
12008
12231
  triggerEvent(name , ...args ) {
@@ -12043,6 +12266,10 @@ class Participant extends Emitter {
12043
12266
  status.extra = this.extra;
12044
12267
  break;
12045
12268
  }
12269
+ case this.ON_BAN: {
12270
+ status.banned = true;
12271
+ break;
12272
+ }
12046
12273
  }
12047
12274
 
12048
12275
  if (broadcast) {
@@ -12145,6 +12372,11 @@ class Participant extends Emitter {
12145
12372
  this.triggerUpdate(this.ON_RESUME, broadcast);
12146
12373
  }
12147
12374
 
12375
+ onBan(broadcast = true) {
12376
+ this.banned = true;
12377
+ this.triggerUpdate(this.ON_BAN, broadcast);
12378
+ }
12379
+
12148
12380
  getStatus() {
12149
12381
  return {
12150
12382
  callId: this.callId,
@@ -12191,6 +12423,10 @@ class Participant extends Emitter {
12191
12423
  }
12192
12424
  }
12193
12425
 
12426
+ if (status.banned) {
12427
+ this.onBan(false);
12428
+ }
12429
+
12194
12430
  // Poor man's object comparison
12195
12431
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
12196
12432
  this.extra = { ...this.extra, ...status.extra };
@@ -12218,6 +12454,28 @@ class Participant extends Emitter {
12218
12454
  this.streams = streams;
12219
12455
  this.videoStreams = streams;
12220
12456
  }
12457
+
12458
+ async ban(apiRequestDelay = null) {
12459
+ const { meetingUuid } = this.room;
12460
+ if (!meetingUuid) {
12461
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
12462
+ }
12463
+
12464
+ // this notifies all that someone is being banned
12465
+ this.onBan(true);
12466
+
12467
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
12468
+ if (apiRequestDelay) {
12469
+ await this.delay(apiRequestDelay);
12470
+ }
12471
+
12472
+ // proceed with the actual kick
12473
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12474
+ }
12475
+
12476
+ async delay(ms ) {
12477
+ return new Promise(resolve => setTimeout(resolve, ms));
12478
+ }
12221
12479
  }
12222
12480
 
12223
12481
  //
@@ -13289,6 +13547,7 @@ class Softphone {
13289
13547
  wrapUpDuration,
13290
13548
  enableAgent = true,
13291
13549
  tenantId,
13550
+ domainName,
13292
13551
  debug = false,
13293
13552
  } = {}) {
13294
13553
  this.url = url || 'https://softphone.wazo.io';
@@ -13313,8 +13572,12 @@ class Softphone {
13313
13572
  config.port = port;
13314
13573
  }
13315
13574
  if (tenantId) {
13575
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13316
13576
  config.tenantId = tenantId;
13317
13577
  }
13578
+ if (domainName) {
13579
+ config.domainName = domainName;
13580
+ }
13318
13581
  if (wrapUpDuration) {
13319
13582
  config.wrapUpDuration = wrapUpDuration;
13320
13583
  }
@@ -13635,6 +13898,7 @@ const Wazo = {
13635
13898
  CanceledCallError,
13636
13899
  SFUNotAvailableError,
13637
13900
  NoTenantIdError,
13901
+ NoDomainNameError,
13638
13902
  };
13639
13903
 
13640
13904
  if (window) {
@@ -13778,7 +14042,7 @@ class Room extends Emitter {
13778
14042
  logger.info('connecting to room', { extension, audioOnly, room: !!room });
13779
14043
 
13780
14044
  if (!room) {
13781
- await Wazo.Phone.connect();
14045
+ await Wazo.Phone.connect({ media: constraints });
13782
14046
 
13783
14047
  const withCamera = constraints && !!constraints.video;
13784
14048
 
@@ -14223,7 +14487,7 @@ class Room extends Emitter {
14223
14487
  const participant = this._getParticipantFromCallId(status.callId);
14224
14488
 
14225
14489
  if (participant) {
14226
- // we're received, so no need to broadcast, hence the input false arg
14490
+ // we're receiving, so no need to broadcast
14227
14491
  participant.updateStatus(status, false);
14228
14492
  }
14229
14493
  break;