@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
@@ -2229,6 +2229,7 @@ var authMethods = (client , baseUrl ) => ({
2229
2229
 
2230
2230
 
2231
2231
 
2232
+
2232
2233
  ) {
2233
2234
  const body = {
2234
2235
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2249,9 +2250,14 @@ var authMethods = (client , baseUrl ) => ({
2249
2250
  }
2250
2251
 
2251
2252
  if (params.tenantId) {
2253
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2252
2254
  body.tenant_id = params.tenantId;
2253
2255
  }
2254
2256
 
2257
+ if (params.domainName) {
2258
+ body.domain_name = params.domainName;
2259
+ }
2260
+
2255
2261
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2256
2262
  },
2257
2263
 
@@ -2264,6 +2270,7 @@ var authMethods = (client , baseUrl ) => ({
2264
2270
  expiration ,
2265
2271
  isMobile = false,
2266
2272
  tenantId ,
2273
+ domainName ,
2267
2274
  ) => {
2268
2275
  const body = {
2269
2276
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2273,9 +2280,14 @@ var authMethods = (client , baseUrl ) => ({
2273
2280
  };
2274
2281
 
2275
2282
  if (tenantId) {
2283
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2276
2284
  body.tenant_id = tenantId;
2277
2285
  }
2278
2286
 
2287
+ if (domainName) {
2288
+ body.domain_name = domainName;
2289
+ }
2290
+
2279
2291
  const headers = {
2280
2292
  'Content-Type': 'application/json',
2281
2293
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2645,6 +2657,70 @@ class ExternalApp {
2645
2657
 
2646
2658
  //
2647
2659
 
2660
+ class MeetingAuthorization {
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+ constructor({
2668
+ meetingUuid,
2669
+ uuid,
2670
+ userUuid,
2671
+ userName,
2672
+ } = {}) {
2673
+ this.meetingUuid = meetingUuid;
2674
+ this.uuid = uuid;
2675
+ this.userUuid = userUuid;
2676
+ this.userName = userName;
2677
+ }
2678
+
2679
+ setStatus(status ) {
2680
+ this.status = status;
2681
+ }
2682
+
2683
+ getStatus() {
2684
+ return this.status;
2685
+ }
2686
+
2687
+ static parse(plain ) {
2688
+ const {
2689
+ meeting_uuid: meetingUuid,
2690
+ uuid,
2691
+ guest_uuid: userUuid,
2692
+ guest_name: userName,
2693
+ } = plain;
2694
+
2695
+ return new MeetingAuthorization({
2696
+ meetingUuid,
2697
+ uuid,
2698
+ userUuid,
2699
+ userName,
2700
+ });
2701
+ }
2702
+
2703
+ static parseMany(items ) {
2704
+ if (!items) {
2705
+ return [];
2706
+ }
2707
+ return items.map(MeetingAuthorization.parse);
2708
+ }
2709
+ }
2710
+
2711
+ //
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2648
2724
 
2649
2725
 
2650
2726
 
@@ -2655,6 +2731,7 @@ class ExternalApp {
2655
2731
 
2656
2732
 
2657
2733
 
2734
+
2658
2735
 
2659
2736
 
2660
2737
  class Meeting {
@@ -2669,6 +2746,8 @@ class Meeting {
2669
2746
 
2670
2747
 
2671
2748
 
2749
+
2750
+
2672
2751
 
2673
2752
  static parse(plain ) {
2674
2753
  return new Meeting({
@@ -2681,6 +2760,7 @@ class Meeting {
2681
2760
  extension: plain.exten,
2682
2761
  persistent: plain.persistent,
2683
2762
  creationTime: moment(plain.creation_time).toDate(),
2763
+ requireAuthorization: plain.require_authorization,
2684
2764
  });
2685
2765
  }
2686
2766
 
@@ -2705,6 +2785,7 @@ class Meeting {
2705
2785
  extension,
2706
2786
  persistent,
2707
2787
  creationTime,
2788
+ requireAuthorization,
2708
2789
  } = {}) {
2709
2790
  this.guestSipAuthorization = guestSipAuthorization;
2710
2791
  this.uri = uri;
@@ -2715,6 +2796,7 @@ class Meeting {
2715
2796
  this.extension = extension;
2716
2797
  this.persistent = persistent;
2717
2798
  this.creationTime = creationTime;
2799
+ this.requireAuthorization = requireAuthorization;
2718
2800
 
2719
2801
  // Useful to compare instead of instanceof with minified code
2720
2802
  this.type = 'Meeting';
@@ -2725,8 +2807,32 @@ class Meeting {
2725
2807
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2726
2808
  return { username, secret };
2727
2809
  }
2810
+
2728
2811
  }
2729
2812
 
2813
+ //
2814
+
2815
+ const camelToUnderscore = (key ) => {
2816
+ if (typeof key !== 'string') {
2817
+ throw new Error('Input is not a string');
2818
+ }
2819
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2820
+ };
2821
+
2822
+ //
2823
+
2824
+ const convertKeysFromCamelToUnderscore = (args ) => {
2825
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2826
+ throw new Error('Input is not an object');
2827
+ }
2828
+
2829
+ return Object.keys(args).reduce((acc, key) => {
2830
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2831
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2832
+ return acc;
2833
+ }, {});
2834
+ };
2835
+
2730
2836
  /* */
2731
2837
 
2732
2838
  var confdMethods = (client , baseUrl ) => ({
@@ -2795,8 +2901,18 @@ var confdMethods = (client , baseUrl ) => ({
2795
2901
  getMyMeetings: () =>
2796
2902
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2797
2903
 
2798
- createMyMeeting: (name , persistent ) =>
2799
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2904
+ createMyMeeting: (args ) =>
2905
+ client
2906
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2907
+ .then(Meeting.parse),
2908
+
2909
+ updateMyMeeting: (meetingUuid , data ) =>
2910
+ client.put(
2911
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2912
+ convertKeysFromCamelToUnderscore(data),
2913
+ null,
2914
+ ApiRequester.successResponseParser,
2915
+ ),
2800
2916
 
2801
2917
  deleteMyMeeting: (meetingUuid ) =>
2802
2918
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2804,8 +2920,36 @@ var confdMethods = (client , baseUrl ) => ({
2804
2920
  getMeeting: (meetingUuid ) =>
2805
2921
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2806
2922
 
2923
+ meetingAuthorizations: (meetingUuid ) =>
2924
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2925
+
2926
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2927
+ client.put(
2928
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2929
+ {},
2930
+ null,
2931
+ ApiRequester.successResponseParser,
2932
+ ),
2933
+
2934
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2935
+ client.put(
2936
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2937
+ {},
2938
+ null,
2939
+ ApiRequester.successResponseParser,
2940
+ ),
2941
+
2807
2942
  guestGetMeeting: (meetingUuid ) =>
2808
2943
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2944
+
2945
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2946
+ client
2947
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2948
+ .then(MeetingAuthorization.parse),
2949
+
2950
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2951
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2952
+
2809
2953
  });
2810
2954
 
2811
2955
  //
@@ -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
  });
@@ -11796,6 +12015,7 @@ class Participant extends Emitter {
11796
12015
 
11797
12016
 
11798
12017
 
12018
+
11799
12019
 
11800
12020
 
11801
12021
 
@@ -11813,6 +12033,7 @@ class Participant extends Emitter {
11813
12033
 
11814
12034
 
11815
12035
 
12036
+
11816
12037
 
11817
12038
  /**
11818
12039
  * @param room Room The room where the participant is
@@ -11836,6 +12057,7 @@ class Participant extends Emitter {
11836
12057
  this.screensharing = false;
11837
12058
  this.isOnHold = false;
11838
12059
  this.extra = extra;
12060
+ this.banned = false;
11839
12061
 
11840
12062
  this.ON_UPDATED = 'participant/ON_UPDATED';
11841
12063
  this.ON_START_TALKING = 'participant/ON_START_TALKING';
@@ -11852,6 +12074,7 @@ class Participant extends Emitter {
11852
12074
  this.ON_EXTRA_CHANGE = 'participant/ON_EXTRA_CHANGE';
11853
12075
  this.ON_HOLD = 'participant/ON_HOLD';
11854
12076
  this.ON_RESUME = 'participant/ON_RESUME';
12077
+ this.ON_BAN = 'participant/ON_BAN';
11855
12078
  }
11856
12079
 
11857
12080
  triggerEvent(name , ...args ) {
@@ -11892,6 +12115,10 @@ class Participant extends Emitter {
11892
12115
  status.extra = this.extra;
11893
12116
  break;
11894
12117
  }
12118
+ case this.ON_BAN: {
12119
+ status.banned = true;
12120
+ break;
12121
+ }
11895
12122
  }
11896
12123
 
11897
12124
  if (broadcast) {
@@ -11994,6 +12221,11 @@ class Participant extends Emitter {
11994
12221
  this.triggerUpdate(this.ON_RESUME, broadcast);
11995
12222
  }
11996
12223
 
12224
+ onBan(broadcast = true) {
12225
+ this.banned = true;
12226
+ this.triggerUpdate(this.ON_BAN, broadcast);
12227
+ }
12228
+
11997
12229
  getStatus() {
11998
12230
  return {
11999
12231
  callId: this.callId,
@@ -12040,6 +12272,10 @@ class Participant extends Emitter {
12040
12272
  }
12041
12273
  }
12042
12274
 
12275
+ if (status.banned) {
12276
+ this.onBan(false);
12277
+ }
12278
+
12043
12279
  // Poor man's object comparison
12044
12280
  if (typeof status.extra !== 'undefined' && JSON.stringify(this.extra) !== JSON.stringify(status.extra)) {
12045
12281
  this.extra = { ...this.extra, ...status.extra };
@@ -12067,6 +12303,28 @@ class Participant extends Emitter {
12067
12303
  this.streams = streams;
12068
12304
  this.videoStreams = streams;
12069
12305
  }
12306
+
12307
+ async ban(apiRequestDelay = null) {
12308
+ const { meetingUuid } = this.room;
12309
+ if (!meetingUuid) {
12310
+ throw new Error('Attempting to ban a participant without a `meetingUuid`');
12311
+ }
12312
+
12313
+ // this notifies all that someone is being banned
12314
+ this.onBan(true);
12315
+
12316
+ // this allows to delay the actual ban, in order for the banned participant as well as others to react to the situation
12317
+ if (apiRequestDelay) {
12318
+ await this.delay(apiRequestDelay);
12319
+ }
12320
+
12321
+ // proceed with the actual kick
12322
+ return getApiClient().calld.banMeetingParticipant(meetingUuid, this.callId);
12323
+ }
12324
+
12325
+ async delay(ms ) {
12326
+ return new Promise(resolve => setTimeout(resolve, ms));
12327
+ }
12070
12328
  }
12071
12329
 
12072
12330
  //
@@ -12219,7 +12477,7 @@ class Room$1 extends Emitter {
12219
12477
  logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
12220
12478
 
12221
12479
  if (!room) {
12222
- await Wazo.Phone.connect();
12480
+ await Wazo.Phone.connect({ media: constraints });
12223
12481
 
12224
12482
  const withCamera = constraints && !!constraints.video;
12225
12483
 
@@ -12664,7 +12922,7 @@ class Room$1 extends Emitter {
12664
12922
  const participant = this._getParticipantFromCallId(status.callId);
12665
12923
 
12666
12924
  if (participant) {
12667
- // we're received, so no need to broadcast, hence the input false arg
12925
+ // we're receiving, so no need to broadcast
12668
12926
  participant.updateStatus(status, false);
12669
12927
  }
12670
12928
  break;
@@ -12931,7 +13189,7 @@ class SipRoom extends Room$1 {
12931
13189
  logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
12932
13190
 
12933
13191
  if (!room) {
12934
- await Wazo.Phone.connect();
13192
+ await Wazo.Phone.connect({ media: constraints });
12935
13193
 
12936
13194
  const withCamera = constraints && !!constraints.video;
12937
13195
 
@@ -14055,6 +14313,7 @@ class Softphone {
14055
14313
  wrapUpDuration,
14056
14314
  enableAgent = true,
14057
14315
  tenantId,
14316
+ domainName,
14058
14317
  debug = false,
14059
14318
  } = {}) {
14060
14319
  this.url = url || 'https://softphone.wazo.io';
@@ -14079,8 +14338,12 @@ class Softphone {
14079
14338
  config.port = port;
14080
14339
  }
14081
14340
  if (tenantId) {
14341
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14082
14342
  config.tenantId = tenantId;
14083
14343
  }
14344
+ if (domainName) {
14345
+ config.domainName = domainName;
14346
+ }
14084
14347
  if (wrapUpDuration) {
14085
14348
  config.wrapUpDuration = wrapUpDuration;
14086
14349
  }
@@ -14401,6 +14664,7 @@ const Wazo = {
14401
14664
  CanceledCallError,
14402
14665
  SFUNotAvailableError,
14403
14666
  NoTenantIdError,
14667
+ NoDomainNameError,
14404
14668
  };
14405
14669
 
14406
14670
  if (window) {