@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
  });
@@ -11806,6 +12025,7 @@ class Participant extends Emitter {
11806
12025
 
11807
12026
 
11808
12027
 
12028
+
11809
12029
 
11810
12030
 
11811
12031
 
@@ -11823,6 +12043,7 @@ class Participant extends Emitter {
11823
12043
 
11824
12044
 
11825
12045
 
12046
+
11826
12047
 
11827
12048
  /**
11828
12049
  * @param room Room The room where the participant is
@@ -11846,6 +12067,7 @@ class Participant extends Emitter {
11846
12067
  this.screensharing = false;
11847
12068
  this.isOnHold = false;
11848
12069
  this.extra = extra;
12070
+ this.banned = false;
11849
12071
 
11850
12072
  this.ON_UPDATED = 'participant/ON_UPDATED';
11851
12073
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11862,6 +12084,7 @@ class Participant extends Emitter {
11862
12084
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11863
12085
  this.ON_HOLD = 'participant/ON_HOLD';
11864
12086
  this.ON_RESUME = 'participant/ON_RESUME';
12087
+ this.ON_BAN = 'participant/ON_BAN';
11865
12088
  }
11866
12089
 
11867
12090
  triggerEvent(name , ...args ) {
@@ -11902,6 +12125,10 @@ class Participant extends Emitter {
11902
12125
  status.extra = this.extra;
11903
12126
  break;
11904
12127
  }
12128
+ case this.ON_BAN: {
12129
+ status.banned = true;
12130
+ break;
12131
+ }
11905
12132
  }
11906
12133
 
11907
12134
  if (broadcast) {
@@ -12004,6 +12231,11 @@ class Participant extends Emitter {
12004
12231
  this.triggerUpdate(this.ON_RESUME, broadcast);
12005
12232
  }
12006
12233
 
12234
+ onBan(broadcast = true) {
12235
+ this.banned = true;
12236
+ this.triggerUpdate(this.ON_BAN, broadcast);
12237
+ }
12238
+
12007
12239
  getStatus() {
12008
12240
  return {
12009
12241
  callId: this.callId,
@@ -12050,6 +12282,10 @@ class Participant extends Emitter {
12050
12282
  }
12051
12283
  }
12052
12284
 
12285
+ if (status.banned) {
12286
+ this.onBan(false);
12287
+ }
12288
+
12053
12289
  // Poor man's object comparison
12054
12290
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
12055
12291
  this.extra = { ...this.extra, ...status.extra };
@@ -12077,6 +12313,28 @@ class Participant extends Emitter {
12077
12313
  this.streams = streams;
12078
12314
  this.videoStreams = streams;
12079
12315
  }
12316
+
12317
+ async ban(apiRequestDelay = null) {
12318
+ const { meetingUuid } = this.room;
12319
+ if (!meetingUuid) {
12320
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
12321
+ }
12322
+
12323
+ // this notifies all that someone is being banned
12324
+ this.onBan(true);
12325
+
12326
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
12327
+ if (apiRequestDelay) {
12328
+ await this.delay(apiRequestDelay);
12329
+ }
12330
+
12331
+ // proceed with the actual kick
12332
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12333
+ }
12334
+
12335
+ async delay(ms ) {
12336
+ return new Promise(resolve => setTimeout(resolve, ms));
12337
+ }
12080
12338
  }
12081
12339
 
12082
12340
  //
@@ -12229,7 +12487,7 @@ class Room$1 extends Emitter {
12229
12487
  logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
12230
12488
 
12231
12489
  if (!room) {
12232
- await Wazo.Phone.connect();
12490
+ await Wazo.Phone.connect({ media: constraints });
12233
12491
 
12234
12492
  const withCamera = constraints && !!constraints.video;
12235
12493
 
@@ -12674,7 +12932,7 @@ class Room$1 extends Emitter {
12674
12932
  const participant = this._getParticipantFromCallId(status.callId);
12675
12933
 
12676
12934
  if (participant) {
12677
- // we're received, so no need to broadcast, hence the input false arg
12935
+ // we're receiving, so no need to broadcast
12678
12936
  participant.updateStatus(status, false);
12679
12937
  }
12680
12938
  break;
@@ -12941,7 +13199,7 @@ class SipRoom extends Room$1 {
12941
13199
  logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
12942
13200
 
12943
13201
  if (!room) {
12944
- await Wazo.Phone.connect();
13202
+ await Wazo.Phone.connect({ media: constraints });
12945
13203
 
12946
13204
  const withCamera = constraints && !!constraints.video;
12947
13205
 
@@ -14065,6 +14323,7 @@ class Softphone {
14065
14323
  wrapUpDuration,
14066
14324
  enableAgent = true,
14067
14325
  tenantId,
14326
+ domainName,
14068
14327
  debug = false,
14069
14328
  } = {}) {
14070
14329
  this.url = url || 'https://softphone.wazo.io';
@@ -14089,8 +14348,12 @@ class Softphone {
14089
14348
  config.port = port;
14090
14349
  }
14091
14350
  if (tenantId) {
14351
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14092
14352
  config.tenantId = tenantId;
14093
14353
  }
14354
+ if (domainName) {
14355
+ config.domainName = domainName;
14356
+ }
14094
14357
  if (wrapUpDuration) {
14095
14358
  config.wrapUpDuration = wrapUpDuration;
14096
14359
  }
@@ -14411,6 +14674,7 @@ const Wazo = {
14411
14674
  CanceledCallError,
14412
14675
  SFUNotAvailableError,
14413
14676
  NoTenantIdError,
14677
+ NoDomainNameError,
14414
14678
  };
14415
14679
 
14416
14680
  if (window) {