@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
@@ -2239,6 +2239,7 @@ var authMethods = (client , baseUrl ) => ({
2239
2239
 
2240
2240
 
2241
2241
 
2242
+
2242
2243
  ) {
2243
2244
  const body = {
2244
2245
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2259,9 +2260,14 @@ var authMethods = (client , baseUrl ) => ({
2259
2260
  }
2260
2261
 
2261
2262
  if (params.tenantId) {
2263
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2262
2264
  body.tenant_id = params.tenantId;
2263
2265
  }
2264
2266
 
2267
+ if (params.domainName) {
2268
+ body.domain_name = params.domainName;
2269
+ }
2270
+
2265
2271
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2266
2272
  },
2267
2273
 
@@ -2274,6 +2280,7 @@ var authMethods = (client , baseUrl ) => ({
2274
2280
  expiration ,
2275
2281
  isMobile = false,
2276
2282
  tenantId ,
2283
+ domainName ,
2277
2284
  ) => {
2278
2285
  const body = {
2279
2286
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2283,9 +2290,14 @@ var authMethods = (client , baseUrl ) => ({
2283
2290
  };
2284
2291
 
2285
2292
  if (tenantId) {
2293
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2286
2294
  body.tenant_id = tenantId;
2287
2295
  }
2288
2296
 
2297
+ if (domainName) {
2298
+ body.domain_name = domainName;
2299
+ }
2300
+
2289
2301
  const headers = {
2290
2302
  'Content-Type': 'application/json',
2291
2303
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2655,6 +2667,70 @@ class ExternalApp {
2655
2667
 
2656
2668
  //
2657
2669
 
2670
+ class MeetingAuthorization {
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+ constructor({
2678
+ meetingUuid,
2679
+ uuid,
2680
+ userUuid,
2681
+ userName,
2682
+ } = {}) {
2683
+ this.meetingUuid = meetingUuid;
2684
+ this.uuid = uuid;
2685
+ this.userUuid = userUuid;
2686
+ this.userName = userName;
2687
+ }
2688
+
2689
+ setStatus(status ) {
2690
+ this.status = status;
2691
+ }
2692
+
2693
+ getStatus() {
2694
+ return this.status;
2695
+ }
2696
+
2697
+ static parse(plain ) {
2698
+ const {
2699
+ meeting_uuid: meetingUuid,
2700
+ uuid,
2701
+ guest_uuid: userUuid,
2702
+ guest_name: userName,
2703
+ } = plain;
2704
+
2705
+ return new MeetingAuthorization({
2706
+ meetingUuid,
2707
+ uuid,
2708
+ userUuid,
2709
+ userName,
2710
+ });
2711
+ }
2712
+
2713
+ static parseMany(items ) {
2714
+ if (!items) {
2715
+ return [];
2716
+ }
2717
+ return items.map(MeetingAuthorization.parse);
2718
+ }
2719
+ }
2720
+
2721
+ //
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2658
2734
 
2659
2735
 
2660
2736
 
@@ -2665,6 +2741,7 @@ class ExternalApp {
2665
2741
 
2666
2742
 
2667
2743
 
2744
+
2668
2745
 
2669
2746
 
2670
2747
  class Meeting {
@@ -2679,6 +2756,8 @@ class Meeting {
2679
2756
 
2680
2757
 
2681
2758
 
2759
+
2760
+
2682
2761
 
2683
2762
  static parse(plain ) {
2684
2763
  return new Meeting({
@@ -2691,6 +2770,7 @@ class Meeting {
2691
2770
  extension: plain.exten,
2692
2771
  persistent: plain.persistent,
2693
2772
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2773
+ requireAuthorization: plain.require_authorization,
2694
2774
  });
2695
2775
  }
2696
2776
 
@@ -2715,6 +2795,7 @@ class Meeting {
2715
2795
  extension,
2716
2796
  persistent,
2717
2797
  creationTime,
2798
+ requireAuthorization,
2718
2799
  } = {}) {
2719
2800
  this.guestSipAuthorization = guestSipAuthorization;
2720
2801
  this.uri = uri;
@@ -2725,6 +2806,7 @@ class Meeting {
2725
2806
  this.extension = extension;
2726
2807
  this.persistent = persistent;
2727
2808
  this.creationTime = creationTime;
2809
+ this.requireAuthorization = requireAuthorization;
2728
2810
 
2729
2811
  // Useful to compare instead of instanceof with minified code
2730
2812
  this.type = 'Meeting';
@@ -2735,8 +2817,32 @@ class Meeting {
2735
2817
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2736
2818
  return { username, secret };
2737
2819
  }
2820
+
2738
2821
  }
2739
2822
 
2823
+ //
2824
+
2825
+ const camelToUnderscore = (key ) => {
2826
+ if (typeof key !== 'string') {
2827
+ throw new Error('Input is not a string');
2828
+ }
2829
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2830
+ };
2831
+
2832
+ //
2833
+
2834
+ const convertKeysFromCamelToUnderscore = (args ) => {
2835
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2836
+ throw new Error('Input is not an object');
2837
+ }
2838
+
2839
+ return Object.keys(args).reduce((acc, key) => {
2840
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2841
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2842
+ return acc;
2843
+ }, {});
2844
+ };
2845
+
2740
2846
  /* */
2741
2847
 
2742
2848
  var confdMethods = (client , baseUrl ) => ({
@@ -2805,8 +2911,18 @@ var confdMethods = (client , baseUrl ) => ({
2805
2911
  getMyMeetings: () =>
2806
2912
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2807
2913
 
2808
- createMyMeeting: (name , persistent ) =>
2809
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2914
+ createMyMeeting: (args ) =>
2915
+ client
2916
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2917
+ .then(Meeting.parse),
2918
+
2919
+ updateMyMeeting: (meetingUuid , data ) =>
2920
+ client.put(
2921
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2922
+ convertKeysFromCamelToUnderscore(data),
2923
+ null,
2924
+ ApiRequester.successResponseParser,
2925
+ ),
2810
2926
 
2811
2927
  deleteMyMeeting: (meetingUuid ) =>
2812
2928
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2814,8 +2930,36 @@ var confdMethods = (client , baseUrl ) => ({
2814
2930
  getMeeting: (meetingUuid ) =>
2815
2931
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2816
2932
 
2933
+ meetingAuthorizations: (meetingUuid ) =>
2934
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2935
+
2936
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2937
+ client.put(
2938
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2939
+ {},
2940
+ null,
2941
+ ApiRequester.successResponseParser,
2942
+ ),
2943
+
2944
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2945
+ client.put(
2946
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2947
+ {},
2948
+ null,
2949
+ ApiRequester.successResponseParser,
2950
+ ),
2951
+
2817
2952
  guestGetMeeting: (meetingUuid ) =>
2818
2953
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2954
+
2955
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2956
+ client
2957
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2958
+ .then(MeetingAuthorization.parse),
2959
+
2960
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2961
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2962
+
2819
2963
  });
2820
2964
 
2821
2965
  //
@@ -5066,6 +5210,14 @@ var calldMethods = (client , baseUrl ) => ({
5066
5210
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5067
5211
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5068
5212
 
5213
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5214
+ client.delete(
5215
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5216
+ null,
5217
+ null,
5218
+ ApiRequester.successResponseParser,
5219
+ ),
5220
+
5069
5221
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5070
5222
 
5071
5223
  mute: (callId ) =>
@@ -5443,6 +5595,7 @@ class ApiClient {
5443
5595
 
5444
5596
 
5445
5597
 
5598
+
5446
5599
 
5447
5600
 
5448
5601
 
@@ -5484,6 +5637,7 @@ class ApiClient {
5484
5637
  refreshToken: this.refreshToken,
5485
5638
  refreshBackend: this.refreshBackend,
5486
5639
  refreshTenantId: this.refreshTenantId,
5640
+ refreshDomainName: this.refreshDomainName,
5487
5641
  refreshExpiration: this.refreshExpiration,
5488
5642
  isMobile: this.isMobile,
5489
5643
  });
@@ -5499,6 +5653,7 @@ class ApiClient {
5499
5653
  this.refreshExpiration,
5500
5654
  this.isMobile,
5501
5655
  this.refreshTenantId,
5656
+ this.refreshDomainName,
5502
5657
  );
5503
5658
 
5504
5659
  logger$a.info('token refreshed', { token: session.token });
@@ -5552,9 +5707,14 @@ class ApiClient {
5552
5707
  }
5553
5708
 
5554
5709
  setRefreshTenantId(tenantId ) {
5710
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5555
5711
  this.refreshTenantId = tenantId;
5556
5712
  }
5557
5713
 
5714
+ setRefreshDomainName(domainName ) {
5715
+ this.refreshDomainName = domainName;
5716
+ }
5717
+
5558
5718
  setIsMobile(isMobile ) {
5559
5719
  this.isMobile = isMobile;
5560
5720
  }
@@ -5579,6 +5739,7 @@ global.wazoClientId = global.wazoClientId || {};
5579
5739
  global.wazoClientToken = global.wazoClientToken || {};
5580
5740
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5581
5741
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5742
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5582
5743
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5583
5744
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5584
5745
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5603,9 +5764,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5603
5764
  };
5604
5765
 
5605
5766
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5767
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5606
5768
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5607
5769
  };
5608
5770
 
5771
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5772
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5773
+ };
5774
+
5609
5775
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5610
5776
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5611
5777
  };
@@ -5624,6 +5790,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5624
5790
 
5625
5791
  const fillClient = (apiClient ) => {
5626
5792
  const { server, token, clientId } = apiClient.client;
5793
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5627
5794
 
5628
5795
  // try with null server when dealing with non-related server info
5629
5796
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5632,8 +5799,12 @@ const fillClient = (apiClient ) => {
5632
5799
 
5633
5800
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5634
5801
 
5635
- apiClient.setRefreshTenantId(
5636
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5802
+ if (tenantId) {
5803
+ apiClient.setRefreshTenantId(tenantId);
5804
+ }
5805
+
5806
+ apiClient.setRefreshDomainName(
5807
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5637
5808
  );
5638
5809
 
5639
5810
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5675,6 +5846,7 @@ var getApiClient = (forServer = null) => {
5675
5846
  class InvalidSubscription extends Error {}
5676
5847
  class InvalidAuthorization extends Error {}
5677
5848
  class NoTenantIdError extends Error {}
5849
+ class NoDomainNameError extends Error {}
5678
5850
 
5679
5851
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5680
5852
 
@@ -5738,9 +5910,24 @@ class Auth {
5738
5910
  setFetchOptions(options);
5739
5911
  }
5740
5912
 
5741
- async logIn(username , password , backend , tenantId ) {
5742
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5743
- throw new NoTenantIdError('No tenant id');
5913
+ async logIn(username , password , backend , extra ) {
5914
+ let tenantId = null;
5915
+ let domainName = null;
5916
+ if (typeof extra === 'string') {
5917
+ tenantId = extra;
5918
+ }
5919
+ if (extra && typeof extra === 'object') {
5920
+ domainName = extra.domainName;
5921
+ }
5922
+
5923
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5924
+ if (!tenantId) {
5925
+ throw new NoTenantIdError('No tenant id');
5926
+ }
5927
+
5928
+ if (!domainName) {
5929
+ throw new NoDomainNameError('No domain name');
5930
+ }
5744
5931
  }
5745
5932
 
5746
5933
  this.authenticated = false;
@@ -5750,6 +5937,7 @@ class Auth {
5750
5937
  password,
5751
5938
  backend,
5752
5939
  tenantId,
5940
+ domainName,
5753
5941
  expiration: this.expiration,
5754
5942
  mobile: this.mobile,
5755
5943
  });
@@ -5758,7 +5946,13 @@ class Auth {
5758
5946
  getApiClient().setRefreshBackend(backend);
5759
5947
  }
5760
5948
 
5761
- getApiClient().setRefreshTenantId(tenantId);
5949
+ if (tenantId) {
5950
+ getApiClient().setRefreshTenantId(tenantId);
5951
+ }
5952
+
5953
+ if (domainName) {
5954
+ getApiClient().setRefreshDomainName(domainName);
5955
+ }
5762
5956
 
5763
5957
  return this._onAuthenticated(rawSession);
5764
5958
  }
@@ -5857,11 +6051,18 @@ class Auth {
5857
6051
  }
5858
6052
 
5859
6053
  setRefreshTenantId(refreshTenantId ) {
6054
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
5860
6055
  setRefreshTenantId(refreshTenantId);
5861
6056
 
5862
6057
  getApiClient().setRefreshTenantId(refreshTenantId);
5863
6058
  }
5864
6059
 
6060
+ setRefreshDomainName(domainName ) {
6061
+ setRefreshDomainName(domainName);
6062
+
6063
+ getApiClient().setRefreshDomainName(domainName);
6064
+ }
6065
+
5865
6066
  forceRefreshToken() {
5866
6067
  getApiClient().forceRefreshToken();
5867
6068
  }
@@ -7824,7 +8025,7 @@ class WebRTCClient extends Emitter {
7824
8025
  });
7825
8026
  }
7826
8027
 
7827
- changeAudioInputDevice(id , session , force ) {
8028
+ async changeAudioInputDevice(id , session , force ) {
7828
8029
  const currentId = this.getAudioDeviceId();
7829
8030
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7830
8031
 
@@ -7832,33 +8033,50 @@ class WebRTCClient extends Emitter {
7832
8033
  return null;
7833
8034
  }
7834
8035
 
8036
+ // in order to handle an audio track change for default devices
8037
+ // we need the actual id of the device (not 'default')
8038
+ let deviceId = id;
8039
+ if (id === 'default' && navigator.mediaDevices) {
8040
+ const devices = await navigator.mediaDevices.enumerateDevices();
8041
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
8042
+ if (defaultDevice) {
8043
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
8044
+ const targetDevice = devices.find(device => device.label === deviceLabel);
8045
+ if (targetDevice) {
8046
+ deviceId = targetDevice.deviceId;
8047
+ if (!force && deviceId === currentId) {
8048
+ return null;
8049
+ }
8050
+ }
8051
+ }
8052
+ }
8053
+
7835
8054
  // let's update the local audio value
7836
8055
  if (this.audio) {
7837
8056
  this.audio = {
7838
8057
  deviceId: {
7839
- exact: id,
8058
+ exact: deviceId,
7840
8059
  },
7841
8060
  };
7842
8061
  }
7843
8062
 
7844
- if (session) {
8063
+ if (session && navigator.mediaDevices) {
7845
8064
  const sdh = session.sessionDescriptionHandler;
7846
8065
  const pc = sdh.peerConnection;
7847
8066
 
7848
- // $FlowFixMe
7849
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7850
- const audioTrack = stream.getAudioTracks()[0];
7851
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8067
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
8068
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
8069
+ const audioTrack = stream.getAudioTracks()[0];
8070
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7852
8071
 
7853
- if (sender) {
7854
- if (sender.track) {
7855
- audioTrack.enabled = sender.track.enabled;
7856
- }
7857
- sender.replaceTrack(audioTrack);
8072
+ if (sender) {
8073
+ if (sender.track) {
8074
+ audioTrack.enabled = sender.track.enabled;
7858
8075
  }
8076
+ sender.replaceTrack(audioTrack);
8077
+ }
7859
8078
 
7860
- return stream;
7861
- });
8079
+ return stream;
7862
8080
  }
7863
8081
  }
7864
8082
 
@@ -7878,14 +8096,14 @@ class WebRTCClient extends Emitter {
7878
8096
  return null;
7879
8097
  }
7880
8098
 
7881
- // let's update the local video value
7882
- if (this.video) {
7883
- this.video = {
7884
- deviceId: {
7885
- exact: id,
7886
- },
7887
- };
7888
- }
8099
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
8100
+ const videoObject = typeof this.video === 'object' ? this.video : {};
8101
+ this.video = {
8102
+ ...videoObject,
8103
+ deviceId: {
8104
+ exact: id,
8105
+ },
8106
+ };
7889
8107
  }
7890
8108
 
7891
8109
  changeSessionVideoInputDevice(id , session ) {
@@ -9487,9 +9705,7 @@ class WebRTCPhone extends Emitter {
9487
9705
 
9488
9706
  try {
9489
9707
  if (this.currentScreenShare.stream) {
9490
- this.currentScreenShare.stream.getTracks()
9491
- .filter(track => track.kind === 'video')
9492
- .forEach(track => track.stop());
9708
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9493
9709
  }
9494
9710
 
9495
9711
  if (restoreLocalStream) {
@@ -11280,6 +11496,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
11280
11496
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
11281
11497
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
11282
11498
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11499
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
11283
11500
 
11284
11501
  const BLACKLIST_EVENTS = [
11285
11502
  CHAT_MESSAGE_SENT,
@@ -11631,6 +11848,7 @@ WebSocketClient.eventLists = [
11631
11848
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11632
11849
  CONFERENCE_ADHOC_DELETED,
11633
11850
  MEETING_USER_PROGRESS,
11851
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11634
11852
  ];
11635
11853
 
11636
11854
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11702,6 +11920,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11702
11920
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11703
11921
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11704
11922
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11923
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11705
11924
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11706
11925
  'default': WebSocketClient
11707
11926
  });
@@ -11799,7 +12018,7 @@ class SipRoom extends Room {
11799
12018
  logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11800
12019
 
11801
12020
  if (!room) {
11802
- await Wazo.Phone.connect();
12021
+ await Wazo.Phone.connect({ media: constraints });
11803
12022
 
11804
12023
  const withCamera = constraints && !!constraints.video;
11805
12024
 
@@ -11945,6 +12164,7 @@ class Participant extends Emitter {
11945
12164
 
11946
12165
 
11947
12166
 
12167
+
11948
12168
 
11949
12169
 
11950
12170
 
@@ -11962,6 +12182,7 @@ class Participant extends Emitter {
11962
12182
 
11963
12183
 
11964
12184
 
12185
+
11965
12186
 
11966
12187
  /**
11967
12188
  * @param room Room The room where the participant is
@@ -11985,6 +12206,7 @@ class Participant extends Emitter {
11985
12206
  this.screensharing = false;
11986
12207
  this.isOnHold = false;
11987
12208
  this.extra = extra;
12209
+ this.banned = false;
11988
12210
 
11989
12211
  this.ON_UPDATED = 'participant/ON_UPDATED';
11990
12212
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -12001,6 +12223,7 @@ class Participant extends Emitter {
12001
12223
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
12002
12224
  this.ON_HOLD = 'participant/ON_HOLD';
12003
12225
  this.ON_RESUME = 'participant/ON_RESUME';
12226
+ this.ON_BAN = 'participant/ON_BAN';
12004
12227
  }
12005
12228
 
12006
12229
  triggerEvent(name , ...args ) {
@@ -12041,6 +12264,10 @@ class Participant extends Emitter {
12041
12264
  status.extra = this.extra;
12042
12265
  break;
12043
12266
  }
12267
+ case this.ON_BAN: {
12268
+ status.banned = true;
12269
+ break;
12270
+ }
12044
12271
  }
12045
12272
 
12046
12273
  if (broadcast) {
@@ -12143,6 +12370,11 @@ class Participant extends Emitter {
12143
12370
  this.triggerUpdate(this.ON_RESUME, broadcast);
12144
12371
  }
12145
12372
 
12373
+ onBan(broadcast = true) {
12374
+ this.banned = true;
12375
+ this.triggerUpdate(this.ON_BAN, broadcast);
12376
+ }
12377
+
12146
12378
  getStatus() {
12147
12379
  return {
12148
12380
  callId: this.callId,
@@ -12189,6 +12421,10 @@ class Participant extends Emitter {
12189
12421
  }
12190
12422
  }
12191
12423
 
12424
+ if (status.banned) {
12425
+ this.onBan(false);
12426
+ }
12427
+
12192
12428
  // Poor man's object comparison
12193
12429
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
12194
12430
  this.extra = { ...this.extra, ...status.extra };
@@ -12216,6 +12452,28 @@ class Participant extends Emitter {
12216
12452
  this.streams = streams;
12217
12453
  this.videoStreams = streams;
12218
12454
  }
12455
+
12456
+ async ban(apiRequestDelay = null) {
12457
+ const { meetingUuid } = this.room;
12458
+ if (!meetingUuid) {
12459
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
12460
+ }
12461
+
12462
+ // this notifies all that someone is being banned
12463
+ this.onBan(true);
12464
+
12465
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
12466
+ if (apiRequestDelay) {
12467
+ await this.delay(apiRequestDelay);
12468
+ }
12469
+
12470
+ // proceed with the actual kick
12471
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12472
+ }
12473
+
12474
+ async delay(ms ) {
12475
+ return new Promise(resolve => setTimeout(resolve, ms));
12476
+ }
12219
12477
  }
12220
12478
 
12221
12479
  //
@@ -13276,6 +13534,7 @@ class Softphone {
13276
13534
  wrapUpDuration,
13277
13535
  enableAgent = true,
13278
13536
  tenantId,
13537
+ domainName,
13279
13538
  debug = false,
13280
13539
  } = {}) {
13281
13540
  this.url = url || 'https://softphone.wazo.io';
@@ -13300,8 +13559,12 @@ class Softphone {
13300
13559
  config.port = port;
13301
13560
  }
13302
13561
  if (tenantId) {
13562
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13303
13563
  config.tenantId = tenantId;
13304
13564
  }
13565
+ if (domainName) {
13566
+ config.domainName = domainName;
13567
+ }
13305
13568
  if (wrapUpDuration) {
13306
13569
  config.wrapUpDuration = wrapUpDuration;
13307
13570
  }
@@ -13622,6 +13885,7 @@ const Wazo = {
13622
13885
  CanceledCallError,
13623
13886
  SFUNotAvailableError,
13624
13887
  NoTenantIdError,
13888
+ NoDomainNameError,
13625
13889
  };
13626
13890
 
13627
13891
  if (window) {
@@ -13765,7 +14029,7 @@ class Room extends Emitter {
13765
14029
  logger.info('connecting to room', { extension, audioOnly, room: !!room });
13766
14030
 
13767
14031
  if (!room) {
13768
- await Wazo.Phone.connect();
14032
+ await Wazo.Phone.connect({ media: constraints });
13769
14033
 
13770
14034
  const withCamera = constraints && !!constraints.video;
13771
14035
 
@@ -14210,7 +14474,7 @@ class Room extends Emitter {
14210
14474
  const participant = this._getParticipantFromCallId(status.callId);
14211
14475
 
14212
14476
  if (participant) {
14213
- // we're received, so no need to broadcast, hence the input false arg
14477
+ // we're receiving, so no need to broadcast
14214
14478
  participant.updateStatus(status, false);
14215
14479
  }
14216
14480
  break;