@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
@@ -2255,6 +2255,7 @@ var authMethods = (client , baseUrl ) => ({
2255
2255
 
2256
2256
 
2257
2257
 
2258
+
2258
2259
  ) {
2259
2260
  const body = {
2260
2261
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2275,9 +2276,14 @@ var authMethods = (client , baseUrl ) => ({
2275
2276
  }
2276
2277
 
2277
2278
  if (params.tenantId) {
2279
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2278
2280
  body.tenant_id = params.tenantId;
2279
2281
  }
2280
2282
 
2283
+ if (params.domainName) {
2284
+ body.domain_name = params.domainName;
2285
+ }
2286
+
2281
2287
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2282
2288
  },
2283
2289
 
@@ -2290,6 +2296,7 @@ var authMethods = (client , baseUrl ) => ({
2290
2296
  expiration ,
2291
2297
  isMobile = false,
2292
2298
  tenantId ,
2299
+ domainName ,
2293
2300
  ) => {
2294
2301
  const body = {
2295
2302
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2299,9 +2306,14 @@ var authMethods = (client , baseUrl ) => ({
2299
2306
  };
2300
2307
 
2301
2308
  if (tenantId) {
2309
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2302
2310
  body.tenant_id = tenantId;
2303
2311
  }
2304
2312
 
2313
+ if (domainName) {
2314
+ body.domain_name = domainName;
2315
+ }
2316
+
2305
2317
  const headers = {
2306
2318
  'Content-Type': 'application/json',
2307
2319
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2671,6 +2683,70 @@ class ExternalApp {
2671
2683
 
2672
2684
  //
2673
2685
 
2686
+ class MeetingAuthorization {
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+ constructor({
2694
+ meetingUuid,
2695
+ uuid,
2696
+ userUuid,
2697
+ userName,
2698
+ } = {}) {
2699
+ this.meetingUuid = meetingUuid;
2700
+ this.uuid = uuid;
2701
+ this.userUuid = userUuid;
2702
+ this.userName = userName;
2703
+ }
2704
+
2705
+ setStatus(status ) {
2706
+ this.status = status;
2707
+ }
2708
+
2709
+ getStatus() {
2710
+ return this.status;
2711
+ }
2712
+
2713
+ static parse(plain ) {
2714
+ const {
2715
+ meeting_uuid: meetingUuid,
2716
+ uuid,
2717
+ guest_uuid: userUuid,
2718
+ guest_name: userName,
2719
+ } = plain;
2720
+
2721
+ return new MeetingAuthorization({
2722
+ meetingUuid,
2723
+ uuid,
2724
+ userUuid,
2725
+ userName,
2726
+ });
2727
+ }
2728
+
2729
+ static parseMany(items ) {
2730
+ if (!items) {
2731
+ return [];
2732
+ }
2733
+ return items.map(MeetingAuthorization.parse);
2734
+ }
2735
+ }
2736
+
2737
+ //
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2674
2750
 
2675
2751
 
2676
2752
 
@@ -2681,6 +2757,7 @@ class ExternalApp {
2681
2757
 
2682
2758
 
2683
2759
 
2760
+
2684
2761
 
2685
2762
 
2686
2763
  class Meeting {
@@ -2695,6 +2772,8 @@ class Meeting {
2695
2772
 
2696
2773
 
2697
2774
 
2775
+
2776
+
2698
2777
 
2699
2778
  static parse(plain ) {
2700
2779
  return new Meeting({
@@ -2707,6 +2786,7 @@ class Meeting {
2707
2786
  extension: plain.exten,
2708
2787
  persistent: plain.persistent,
2709
2788
  creationTime: moment(plain.creation_time).toDate(),
2789
+ requireAuthorization: plain.require_authorization,
2710
2790
  });
2711
2791
  }
2712
2792
 
@@ -2731,6 +2811,7 @@ class Meeting {
2731
2811
  extension,
2732
2812
  persistent,
2733
2813
  creationTime,
2814
+ requireAuthorization,
2734
2815
  } = {}) {
2735
2816
  this.guestSipAuthorization = guestSipAuthorization;
2736
2817
  this.uri = uri;
@@ -2741,6 +2822,7 @@ class Meeting {
2741
2822
  this.extension = extension;
2742
2823
  this.persistent = persistent;
2743
2824
  this.creationTime = creationTime;
2825
+ this.requireAuthorization = requireAuthorization;
2744
2826
 
2745
2827
  // Useful to compare instead of instanceof with minified code
2746
2828
  this.type = 'Meeting';
@@ -2751,8 +2833,32 @@ class Meeting {
2751
2833
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2752
2834
  return { username, secret };
2753
2835
  }
2836
+
2754
2837
  }
2755
2838
 
2839
+ //
2840
+
2841
+ const camelToUnderscore = (key ) => {
2842
+ if (typeof key !== 'string') {
2843
+ throw new Error('Input is not a string');
2844
+ }
2845
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2846
+ };
2847
+
2848
+ //
2849
+
2850
+ const convertKeysFromCamelToUnderscore = (args ) => {
2851
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2852
+ throw new Error('Input is not an object');
2853
+ }
2854
+
2855
+ return Object.keys(args).reduce((acc, key) => {
2856
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2857
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2858
+ return acc;
2859
+ }, {});
2860
+ };
2861
+
2756
2862
  /* */
2757
2863
 
2758
2864
  var confdMethods = (client , baseUrl ) => ({
@@ -2821,8 +2927,18 @@ var confdMethods = (client , baseUrl ) => ({
2821
2927
  getMyMeetings: () =>
2822
2928
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2823
2929
 
2824
- createMyMeeting: (name , persistent ) =>
2825
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2930
+ createMyMeeting: (args ) =>
2931
+ client
2932
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2933
+ .then(Meeting.parse),
2934
+
2935
+ updateMyMeeting: (meetingUuid , data ) =>
2936
+ client.put(
2937
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2938
+ convertKeysFromCamelToUnderscore(data),
2939
+ null,
2940
+ ApiRequester.successResponseParser,
2941
+ ),
2826
2942
 
2827
2943
  deleteMyMeeting: (meetingUuid ) =>
2828
2944
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2830,8 +2946,36 @@ var confdMethods = (client , baseUrl ) => ({
2830
2946
  getMeeting: (meetingUuid ) =>
2831
2947
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2832
2948
 
2949
+ meetingAuthorizations: (meetingUuid ) =>
2950
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2951
+
2952
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2953
+ client.put(
2954
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2955
+ {},
2956
+ null,
2957
+ ApiRequester.successResponseParser,
2958
+ ),
2959
+
2960
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2961
+ client.put(
2962
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2963
+ {},
2964
+ null,
2965
+ ApiRequester.successResponseParser,
2966
+ ),
2967
+
2833
2968
  guestGetMeeting: (meetingUuid ) =>
2834
2969
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2970
+
2971
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2972
+ client
2973
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2974
+ .then(MeetingAuthorization.parse),
2975
+
2976
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2977
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2978
+
2835
2979
  });
2836
2980
 
2837
2981
  //
@@ -5056,6 +5200,14 @@ var calldMethods = (client , baseUrl ) => ({
5056
5200
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
5057
5201
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
5058
5202
 
5203
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
5204
+ client.delete(
5205
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
5206
+ null,
5207
+ null,
5208
+ ApiRequester.successResponseParser,
5209
+ ),
5210
+
5059
5211
  listTrunks: () => client.get(`${baseUrl}/trunks`),
5060
5212
 
5061
5213
  mute: (callId ) =>
@@ -5433,6 +5585,7 @@ class ApiClient {
5433
5585
 
5434
5586
 
5435
5587
 
5588
+
5436
5589
 
5437
5590
 
5438
5591
 
@@ -5474,6 +5627,7 @@ class ApiClient {
5474
5627
  refreshToken: this.refreshToken,
5475
5628
  refreshBackend: this.refreshBackend,
5476
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5477
5631
  refreshExpiration: this.refreshExpiration,
5478
5632
  isMobile: this.isMobile,
5479
5633
  });
@@ -5489,6 +5643,7 @@ class ApiClient {
5489
5643
  this.refreshExpiration,
5490
5644
  this.isMobile,
5491
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5492
5647
  );
5493
5648
 
5494
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5542,9 +5697,14 @@ class ApiClient {
5542
5697
  }
5543
5698
 
5544
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5545
5701
  this.refreshTenantId = tenantId;
5546
5702
  }
5547
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5548
5708
  setIsMobile(isMobile ) {
5549
5709
  this.isMobile = isMobile;
5550
5710
  }
@@ -5569,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5569
5729
  global.wazoClientToken = global.wazoClientToken || {};
5570
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5571
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5572
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5573
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5574
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5593,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5593
5754
  };
5594
5755
 
5595
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5596
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5597
5759
  };
5598
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5599
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5600
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5601
5767
  };
@@ -5614,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5614
5780
 
5615
5781
  const fillClient = (apiClient ) => {
5616
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5617
5784
 
5618
5785
  // try with null server when dealing with non-related server info
5619
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5622,8 +5789,12 @@ const fillClient = (apiClient ) => {
5622
5789
 
5623
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5624
5791
 
5625
- apiClient.setRefreshTenantId(
5626
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5792
+ if (tenantId) {
5793
+ apiClient.setRefreshTenantId(tenantId);
5794
+ }
5795
+
5796
+ apiClient.setRefreshDomainName(
5797
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5627
5798
  );
5628
5799
 
5629
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5665,6 +5836,7 @@ var getApiClient = (forServer = null) => {
5665
5836
  class InvalidSubscription extends Error {}
5666
5837
  class InvalidAuthorization extends Error {}
5667
5838
  class NoTenantIdError extends Error {}
5839
+ class NoDomainNameError extends Error {}
5668
5840
 
5669
5841
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5670
5842
 
@@ -5728,9 +5900,24 @@ class Auth {
5728
5900
  setFetchOptions(options);
5729
5901
  }
5730
5902
 
5731
- async logIn(username , password , backend , tenantId ) {
5732
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5733
- throw new NoTenantIdError('No tenant id');
5903
+ async logIn(username , password , backend , extra ) {
5904
+ let tenantId = null;
5905
+ let domainName = null;
5906
+ if (typeof extra === 'string') {
5907
+ tenantId = extra;
5908
+ }
5909
+ if (extra && typeof extra === 'object') {
5910
+ domainName = extra.domainName;
5911
+ }
5912
+
5913
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
5914
+ if (!tenantId) {
5915
+ throw new NoTenantIdError('No tenant id');
5916
+ }
5917
+
5918
+ if (!domainName) {
5919
+ throw new NoDomainNameError('No domain name');
5920
+ }
5734
5921
  }
5735
5922
 
5736
5923
  this.authenticated = false;
@@ -5740,6 +5927,7 @@ class Auth {
5740
5927
  password,
5741
5928
  backend,
5742
5929
  tenantId,
5930
+ domainName,
5743
5931
  expiration: this.expiration,
5744
5932
  mobile: this.mobile,
5745
5933
  });
@@ -5748,7 +5936,13 @@ class Auth {
5748
5936
  getApiClient().setRefreshBackend(backend);
5749
5937
  }
5750
5938
 
5751
- getApiClient().setRefreshTenantId(tenantId);
5939
+ if (tenantId) {
5940
+ getApiClient().setRefreshTenantId(tenantId);
5941
+ }
5942
+
5943
+ if (domainName) {
5944
+ getApiClient().setRefreshDomainName(domainName);
5945
+ }
5752
5946
 
5753
5947
  return this._onAuthenticated(rawSession);
5754
5948
  }
@@ -5847,11 +6041,18 @@ class Auth {
5847
6041
  }
5848
6042
 
5849
6043
  setRefreshTenantId(refreshTenantId ) {
6044
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
5850
6045
  setRefreshTenantId(refreshTenantId);
5851
6046
 
5852
6047
  getApiClient().setRefreshTenantId(refreshTenantId);
5853
6048
  }
5854
6049
 
6050
+ setRefreshDomainName(domainName ) {
6051
+ setRefreshDomainName(domainName);
6052
+
6053
+ getApiClient().setRefreshDomainName(domainName);
6054
+ }
6055
+
5855
6056
  forceRefreshToken() {
5856
6057
  getApiClient().forceRefreshToken();
5857
6058
  }
@@ -7814,7 +8015,7 @@ class WebRTCClient extends Emitter {
7814
8015
  });
7815
8016
  }
7816
8017
 
7817
- changeAudioInputDevice(id , session , force ) {
8018
+ async changeAudioInputDevice(id , session , force ) {
7818
8019
  const currentId = this.getAudioDeviceId();
7819
8020
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7820
8021
 
@@ -7822,33 +8023,50 @@ class WebRTCClient extends Emitter {
7822
8023
  return null;
7823
8024
  }
7824
8025
 
8026
+ // in order to handle an audio track change for default devices
8027
+ // we need the actual id of the device (not 'default')
8028
+ let deviceId = id;
8029
+ if (id === 'default' && navigator.mediaDevices) {
8030
+ const devices = await navigator.mediaDevices.enumerateDevices();
8031
+ const defaultDevice = devices.find(device => device.deviceId === 'default');
8032
+ if (defaultDevice) {
8033
+ const deviceLabel = defaultDevice.label.replace('Default - ', '');
8034
+ const targetDevice = devices.find(device => device.label === deviceLabel);
8035
+ if (targetDevice) {
8036
+ deviceId = targetDevice.deviceId;
8037
+ if (!force && deviceId === currentId) {
8038
+ return null;
8039
+ }
8040
+ }
8041
+ }
8042
+ }
8043
+
7825
8044
  // let's update the local audio value
7826
8045
  if (this.audio) {
7827
8046
  this.audio = {
7828
8047
  deviceId: {
7829
- exact: id,
8048
+ exact: deviceId,
7830
8049
  },
7831
8050
  };
7832
8051
  }
7833
8052
 
7834
- if (session) {
8053
+ if (session && navigator.mediaDevices) {
7835
8054
  const sdh = session.sessionDescriptionHandler;
7836
8055
  const pc = sdh.peerConnection;
7837
8056
 
7838
- // $FlowFixMe
7839
- return navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: id } } }).then(async stream => {
7840
- const audioTrack = stream.getAudioTracks()[0];
7841
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
8057
+ const constraints = { audio: { deviceId: { exact: deviceId } } };
8058
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
8059
+ const audioTrack = stream.getAudioTracks()[0];
8060
+ const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7842
8061
 
7843
- if (sender) {
7844
- if (sender.track) {
7845
- audioTrack.enabled = sender.track.enabled;
7846
- }
7847
- sender.replaceTrack(audioTrack);
8062
+ if (sender) {
8063
+ if (sender.track) {
8064
+ audioTrack.enabled = sender.track.enabled;
7848
8065
  }
8066
+ sender.replaceTrack(audioTrack);
8067
+ }
7849
8068
 
7850
- return stream;
7851
- });
8069
+ return stream;
7852
8070
  }
7853
8071
  }
7854
8072
 
@@ -7868,14 +8086,14 @@ class WebRTCClient extends Emitter {
7868
8086
  return null;
7869
8087
  }
7870
8088
 
7871
- // let's update the local video value
7872
- if (this.video) {
7873
- this.video = {
7874
- deviceId: {
7875
- exact: id,
7876
- },
7877
- };
7878
- }
8089
+ // let's make sure we don't lose other video constraints settings -- width, height, frameRate...
8090
+ const videoObject = typeof this.video === 'object' ? this.video : {};
8091
+ this.video = {
8092
+ ...videoObject,
8093
+ deviceId: {
8094
+ exact: id,
8095
+ },
8096
+ };
7879
8097
  }
7880
8098
 
7881
8099
  changeSessionVideoInputDevice(id , session ) {
@@ -9477,9 +9695,7 @@ class WebRTCPhone extends Emitter {
9477
9695
 
9478
9696
  try {
9479
9697
  if (this.currentScreenShare.stream) {
9480
- this.currentScreenShare.stream.getTracks()
9481
- .filter(track => track.kind === 'video')
9482
- .forEach(track => track.stop());
9698
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
9483
9699
  }
9484
9700
 
9485
9701
  if (restoreLocalStream) {
@@ -11270,6 +11486,7 @@ const AGENT_UNPAUSED = 'agent_unpaused';
11270
11486
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
11271
11487
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
11272
11488
  const MEETING_USER_PROGRESS = 'meeting_user_progress';
11489
+ const MEETING_USER_GUEST_AUTHORIZATION_CREATED = 'meeting_user_guest_authorization_created';
11273
11490
 
11274
11491
  const BLACKLIST_EVENTS = [
11275
11492
  CHAT_MESSAGE_SENT,
@@ -11621,6 +11838,7 @@ WebSocketClient.eventLists = [
11621
11838
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11622
11839
  CONFERENCE_ADHOC_DELETED,
11623
11840
  MEETING_USER_PROGRESS,
11841
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11624
11842
  ];
11625
11843
 
11626
11844
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11692,6 +11910,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11692
11910
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11693
11911
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11694
11912
  MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11913
+ MEETING_USER_GUEST_AUTHORIZATION_CREATED: MEETING_USER_GUEST_AUTHORIZATION_CREATED,
11695
11914
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11696
11915
  'default': WebSocketClient
11697
11916
  });
@@ -11789,7 +12008,7 @@ class SipRoom extends Room {
11789
12008
  logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11790
12009
 
11791
12010
  if (!room) {
11792
- await Wazo.Phone.connect();
12011
+ await Wazo.Phone.connect({ media: constraints });
11793
12012
 
11794
12013
  const withCamera = constraints && !!constraints.video;
11795
12014
 
@@ -12987,6 +13206,7 @@ class Softphone {
12987
13206
  wrapUpDuration,
12988
13207
  enableAgent = true,
12989
13208
  tenantId,
13209
+ domainName,
12990
13210
  debug = false,
12991
13211
  } = {}) {
12992
13212
  this.url = url || 'https://softphone.wazo.io';
@@ -13011,8 +13231,12 @@ class Softphone {
13011
13231
  config.port = port;
13012
13232
  }
13013
13233
  if (tenantId) {
13234
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
13014
13235
  config.tenantId = tenantId;
13015
13236
  }
13237
+ if (domainName) {
13238
+ config.domainName = domainName;
13239
+ }
13016
13240
  if (wrapUpDuration) {
13017
13241
  config.wrapUpDuration = wrapUpDuration;
13018
13242
  }
@@ -13333,6 +13557,7 @@ const Wazo = {
13333
13557
  CanceledCallError,
13334
13558
  SFUNotAvailableError,
13335
13559
  NoTenantIdError,
13560
+ NoDomainNameError,
13336
13561
  };
13337
13562
 
13338
13563
  if (window) {
@@ -13476,7 +13701,7 @@ class Room extends Emitter {
13476
13701
  logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
13477
13702
 
13478
13703
  if (!room) {
13479
- await Wazo.Phone.connect();
13704
+ await Wazo.Phone.connect({ media: constraints });
13480
13705
 
13481
13706
  const withCamera = constraints && !!constraints.video;
13482
13707
 
@@ -13921,7 +14146,7 @@ class Room extends Emitter {
13921
14146
  const participant = this._getParticipantFromCallId(status.callId);
13922
14147
 
13923
14148
  if (participant) {
13924
- // we're received, so no need to broadcast, hence the input false arg
14149
+ // we're receiving, so no need to broadcast
13925
14150
  participant.updateStatus(status, false);
13926
14151
  }
13927
14152
  break;
@@ -14195,6 +14420,7 @@ class Participant extends Emitter {
14195
14420
 
14196
14421
 
14197
14422
 
14423
+
14198
14424
 
14199
14425
 
14200
14426
 
@@ -14212,6 +14438,7 @@ class Participant extends Emitter {
14212
14438
 
14213
14439
 
14214
14440
 
14441
+
14215
14442
 
14216
14443
  /**
14217
14444
  * @param room Room The room where the participant is
@@ -14235,6 +14462,7 @@ class Participant extends Emitter {
14235
14462
  this.screensharing = false;
14236
14463
  this.isOnHold = false;
14237
14464
  this.extra = extra;
14465
+ this.banned = false;
14238
14466
 
14239
14467
  this.ON_UPDATED = 'participant/ON_UPDATED';
14240
14468
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -14251,6 +14479,7 @@ class Participant extends Emitter {
14251
14479
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
14252
14480
  this.ON_HOLD = 'participant/ON_HOLD';
14253
14481
  this.ON_RESUME = 'participant/ON_RESUME';
14482
+ this.ON_BAN = 'participant/ON_BAN';
14254
14483
  }
14255
14484
 
14256
14485
  triggerEvent(name , ...args ) {
@@ -14291,6 +14520,10 @@ class Participant extends Emitter {
14291
14520
  status.extra = this.extra;
14292
14521
  break;
14293
14522
  }
14523
+ case this.ON_BAN: {
14524
+ status.banned = true;
14525
+ break;
14526
+ }
14294
14527
  }
14295
14528
 
14296
14529
  if (broadcast) {
@@ -14393,6 +14626,11 @@ class Participant extends Emitter {
14393
14626
  this.triggerUpdate(this.ON_RESUME, broadcast);
14394
14627
  }
14395
14628
 
14629
+ onBan(broadcast = true) {
14630
+ this.banned = true;
14631
+ this.triggerUpdate(this.ON_BAN, broadcast);
14632
+ }
14633
+
14396
14634
  getStatus() {
14397
14635
  return {
14398
14636
  callId: this.callId,
@@ -14439,6 +14677,10 @@ class Participant extends Emitter {
14439
14677
  }
14440
14678
  }
14441
14679
 
14680
+ if (status.banned) {
14681
+ this.onBan(false);
14682
+ }
14683
+
14442
14684
  // Poor man's object comparison
14443
14685
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
14444
14686
  this.extra = { ...this.extra, ...status.extra };
@@ -14466,6 +14708,28 @@ class Participant extends Emitter {
14466
14708
  this.streams = streams;
14467
14709
  this.videoStreams = streams;
14468
14710
  }
14711
+
14712
+ async ban(apiRequestDelay = null) {
14713
+ const { meetingUuid } = this.room;
14714
+ if (!meetingUuid) {
14715
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
14716
+ }
14717
+
14718
+ // this notifies all that someone is being banned
14719
+ this.onBan(true);
14720
+
14721
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
14722
+ if (apiRequestDelay) {
14723
+ await this.delay(apiRequestDelay);
14724
+ }
14725
+
14726
+ // proceed with the actual kick
14727
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
14728
+ }
14729
+
14730
+ async delay(ms ) {
14731
+ return new Promise(resolve => setTimeout(resolve, ms));
14732
+ }
14469
14733
  }
14470
14734
 
14471
14735
  export default Participant;