@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
@@ -2265,6 +2265,7 @@ var authMethods = (client , baseUrl ) => ({
2265
2265
 
2266
2266
 
2267
2267
 
2268
+
2268
2269
  ) {
2269
2270
  const body = {
2270
2271
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2286,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2286
  }
2286
2287
 
2287
2288
  if (params.tenantId) {
2289
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2288
2290
  body.tenant_id = params.tenantId;
2289
2291
  }
2290
2292
 
2293
+ if (params.domainName) {
2294
+ body.domain_name = params.domainName;
2295
+ }
2296
+
2291
2297
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2292
2298
  },
2293
2299
 
@@ -2300,6 +2306,7 @@ var authMethods = (client , baseUrl ) => ({
2300
2306
  expiration ,
2301
2307
  isMobile = false,
2302
2308
  tenantId ,
2309
+ domainName ,
2303
2310
  ) => {
2304
2311
  const body = {
2305
2312
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2309,9 +2316,14 @@ var authMethods = (client , baseUrl ) => ({
2309
2316
  };
2310
2317
 
2311
2318
  if (tenantId) {
2319
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2312
2320
  body.tenant_id = tenantId;
2313
2321
  }
2314
2322
 
2323
+ if (domainName) {
2324
+ body.domain_name = domainName;
2325
+ }
2326
+
2315
2327
  const headers = {
2316
2328
  'Content-Type': 'application/json',
2317
2329
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2681,6 +2693,70 @@ class ExternalApp {
2681
2693
 
2682
2694
  //
2683
2695
 
2696
+ class MeetingAuthorization {
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+ constructor({
2704
+ meetingUuid,
2705
+ uuid,
2706
+ userUuid,
2707
+ userName,
2708
+ } = {}) {
2709
+ this.meetingUuid = meetingUuid;
2710
+ this.uuid = uuid;
2711
+ this.userUuid = userUuid;
2712
+ this.userName = userName;
2713
+ }
2714
+
2715
+ setStatus(status ) {
2716
+ this.status = status;
2717
+ }
2718
+
2719
+ getStatus() {
2720
+ return this.status;
2721
+ }
2722
+
2723
+ static parse(plain ) {
2724
+ const {
2725
+ meeting_uuid: meetingUuid,
2726
+ uuid,
2727
+ guest_uuid: userUuid,
2728
+ guest_name: userName,
2729
+ } = plain;
2730
+
2731
+ return new MeetingAuthorization({
2732
+ meetingUuid,
2733
+ uuid,
2734
+ userUuid,
2735
+ userName,
2736
+ });
2737
+ }
2738
+
2739
+ static parseMany(items ) {
2740
+ if (!items) {
2741
+ return [];
2742
+ }
2743
+ return items.map(MeetingAuthorization.parse);
2744
+ }
2745
+ }
2746
+
2747
+ //
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2684
2760
 
2685
2761
 
2686
2762
 
@@ -2691,6 +2767,7 @@ class ExternalApp {
2691
2767
 
2692
2768
 
2693
2769
 
2770
+
2694
2771
 
2695
2772
 
2696
2773
  class Meeting {
@@ -2705,6 +2782,8 @@ class Meeting {
2705
2782
 
2706
2783
 
2707
2784
 
2785
+
2786
+
2708
2787
 
2709
2788
  static parse(plain ) {
2710
2789
  return new Meeting({
@@ -2717,6 +2796,7 @@ class Meeting {
2717
2796
  extension: plain.exten,
2718
2797
  persistent: plain.persistent,
2719
2798
  creationTime: moment__default['default'](plain.creation_time).toDate(),
2799
+ requireAuthorization: plain.require_authorization,
2720
2800
  });
2721
2801
  }
2722
2802
 
@@ -2741,6 +2821,7 @@ class Meeting {
2741
2821
  extension,
2742
2822
  persistent,
2743
2823
  creationTime,
2824
+ requireAuthorization,
2744
2825
  } = {}) {
2745
2826
  this.guestSipAuthorization = guestSipAuthorization;
2746
2827
  this.uri = uri;
@@ -2751,6 +2832,7 @@ class Meeting {
2751
2832
  this.extension = extension;
2752
2833
  this.persistent = persistent;
2753
2834
  this.creationTime = creationTime;
2835
+ this.requireAuthorization = requireAuthorization;
2754
2836
 
2755
2837
  // Useful to compare instead of instanceof with minified code
2756
2838
  this.type = 'Meeting';
@@ -2761,8 +2843,32 @@ class Meeting {
2761
2843
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2762
2844
  return { username, secret };
2763
2845
  }
2846
+
2764
2847
  }
2765
2848
 
2849
+ //
2850
+
2851
+ const camelToUnderscore = (key ) => {
2852
+ if (typeof key !== 'string') {
2853
+ throw new Error('Input is not a string');
2854
+ }
2855
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2856
+ };
2857
+
2858
+ //
2859
+
2860
+ const convertKeysFromCamelToUnderscore = (args ) => {
2861
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2862
+ throw new Error('Input is not an object');
2863
+ }
2864
+
2865
+ return Object.keys(args).reduce((acc, key) => {
2866
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2867
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2868
+ return acc;
2869
+ }, {});
2870
+ };
2871
+
2766
2872
  /* */
2767
2873
 
2768
2874
  var confdMethods = (client , baseUrl ) => ({
@@ -2831,8 +2937,18 @@ var confdMethods = (client , baseUrl ) => ({
2831
2937
  getMyMeetings: () =>
2832
2938
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2833
2939
 
2834
- createMyMeeting: (name , persistent ) =>
2835
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2940
+ createMyMeeting: (args ) =>
2941
+ client
2942
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2943
+ .then(Meeting.parse),
2944
+
2945
+ updateMyMeeting: (meetingUuid , data ) =>
2946
+ client.put(
2947
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2948
+ convertKeysFromCamelToUnderscore(data),
2949
+ null,
2950
+ ApiRequester.successResponseParser,
2951
+ ),
2836
2952
 
2837
2953
  deleteMyMeeting: (meetingUuid ) =>
2838
2954
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2840,8 +2956,36 @@ var confdMethods = (client , baseUrl ) => ({
2840
2956
  getMeeting: (meetingUuid ) =>
2841
2957
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2842
2958
 
2959
+ meetingAuthorizations: (meetingUuid ) =>
2960
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2961
+
2962
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2963
+ client.put(
2964
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2965
+ {},
2966
+ null,
2967
+ ApiRequester.successResponseParser,
2968
+ ),
2969
+
2970
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2971
+ client.put(
2972
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2973
+ {},
2974
+ null,
2975
+ ApiRequester.successResponseParser,
2976
+ ),
2977
+
2843
2978
  guestGetMeeting: (meetingUuid ) =>
2844
2979
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2980
+
2981
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2982
+ client
2983
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2984
+ .then(MeetingAuthorization.parse),
2985
+
2986
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2987
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2988
+
2845
2989
  });
2846
2990
 
2847
2991
  //
@@ -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
 
@@ -12997,6 +13216,7 @@ class Softphone {
12997
13216
  wrapUpDuration,
12998
13217
  enableAgent = true,
12999
13218
  tenantId,
13219
+ domainName,
13000
13220
  debug = false,
13001
13221
  } = {}) {
13002
13222
  this.url = url || 'https://softphone.wazo.io';
@@ -13021,8 +13241,12 @@ class Softphone {
13021
13241
  config.port = port;
13022
13242
  }
13023
13243
  if (tenantId) {
13244
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13024
13245
  config.tenantId = tenantId;
13025
13246
  }
13247
+ if (domainName) {
13248
+ config.domainName = domainName;
13249
+ }
13026
13250
  if (wrapUpDuration) {
13027
13251
  config.wrapUpDuration = wrapUpDuration;
13028
13252
  }
@@ -13343,6 +13567,7 @@ const Wazo = {
13343
13567
  CanceledCallError,
13344
13568
  SFUNotAvailableError,
13345
13569
  NoTenantIdError,
13570
+ NoDomainNameError,
13346
13571
  };
13347
13572
 
13348
13573
  if (window) {
@@ -13486,7 +13711,7 @@ class Room extends Emitter {
13486
13711
  logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
13487
13712
 
13488
13713
  if (!room) {
13489
- await Wazo.Phone.connect();
13714
+ await Wazo.Phone.connect({ media: constraints });
13490
13715
 
13491
13716
  const withCamera = constraints && !!constraints.video;
13492
13717
 
@@ -13931,7 +14156,7 @@ class Room extends Emitter {
13931
14156
  const participant = this._getParticipantFromCallId(status.callId);
13932
14157
 
13933
14158
  if (participant) {
13934
- // we're received, so no need to broadcast, hence the input false arg
14159
+ // we're receiving, so no need to broadcast
13935
14160
  participant.updateStatus(status, false);
13936
14161
  }
13937
14162
  break;
@@ -14205,6 +14430,7 @@ class Participant extends Emitter {
14205
14430
 
14206
14431
 
14207
14432
 
14433
+
14208
14434
 
14209
14435
 
14210
14436
 
@@ -14222,6 +14448,7 @@ class Participant extends Emitter {
14222
14448
 
14223
14449
 
14224
14450
 
14451
+
14225
14452
 
14226
14453
  /**
14227
14454
  * @param room Room The room where the participant is
@@ -14245,6 +14472,7 @@ class Participant extends Emitter {
14245
14472
  this.screensharing = false;
14246
14473
  this.isOnHold = false;
14247
14474
  this.extra = extra;
14475
+ this.banned = false;
14248
14476
 
14249
14477
  this.ON_UPDATED = 'participant/ON_UPDATED';
14250
14478
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -14261,6 +14489,7 @@ class Participant extends Emitter {
14261
14489
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
14262
14490
  this.ON_HOLD = 'participant/ON_HOLD';
14263
14491
  this.ON_RESUME = 'participant/ON_RESUME';
14492
+ this.ON_BAN = 'participant/ON_BAN';
14264
14493
  }
14265
14494
 
14266
14495
  triggerEvent(name , ...args ) {
@@ -14301,6 +14530,10 @@ class Participant extends Emitter {
14301
14530
  status.extra = this.extra;
14302
14531
  break;
14303
14532
  }
14533
+ case this.ON_BAN: {
14534
+ status.banned = true;
14535
+ break;
14536
+ }
14304
14537
  }
14305
14538
 
14306
14539
  if (broadcast) {
@@ -14403,6 +14636,11 @@ class Participant extends Emitter {
14403
14636
  this.triggerUpdate(this.ON_RESUME, broadcast);
14404
14637
  }
14405
14638
 
14639
+ onBan(broadcast = true) {
14640
+ this.banned = true;
14641
+ this.triggerUpdate(this.ON_BAN, broadcast);
14642
+ }
14643
+
14406
14644
  getStatus() {
14407
14645
  return {
14408
14646
  callId: this.callId,
@@ -14449,6 +14687,10 @@ class Participant extends Emitter {
14449
14687
  }
14450
14688
  }
14451
14689
 
14690
+ if (status.banned) {
14691
+ this.onBan(false);
14692
+ }
14693
+
14452
14694
  // Poor man's object comparison
14453
14695
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
14454
14696
  this.extra = { ...this.extra, ...status.extra };
@@ -14476,6 +14718,28 @@ class Participant extends Emitter {
14476
14718
  this.streams = streams;
14477
14719
  this.videoStreams = streams;
14478
14720
  }
14721
+
14722
+ async ban(apiRequestDelay = null) {
14723
+ const { meetingUuid } = this.room;
14724
+ if (!meetingUuid) {
14725
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
14726
+ }
14727
+
14728
+ // this notifies all that someone is being banned
14729
+ this.onBan(true);
14730
+
14731
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
14732
+ if (apiRequestDelay) {
14733
+ await this.delay(apiRequestDelay);
14734
+ }
14735
+
14736
+ // proceed with the actual kick
14737
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
14738
+ }
14739
+
14740
+ async delay(ms ) {
14741
+ return new Promise(resolve => setTimeout(resolve, ms));
14742
+ }
14479
14743
  }
14480
14744
 
14481
14745
  module.exports = Participant;