@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
@@ -2424,6 +2424,7 @@ var authMethods = (client , baseUrl ) => ({
2424
2424
 
2425
2425
 
2426
2426
 
2427
+
2427
2428
  ) {
2428
2429
  const body = {
2429
2430
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2444,9 +2445,14 @@ var authMethods = (client , baseUrl ) => ({
2444
2445
  }
2445
2446
 
2446
2447
  if (params.tenantId) {
2448
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2447
2449
  body.tenant_id = params.tenantId;
2448
2450
  }
2449
2451
 
2452
+ if (params.domainName) {
2453
+ body.domain_name = params.domainName;
2454
+ }
2455
+
2450
2456
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2451
2457
  },
2452
2458
 
@@ -2459,6 +2465,7 @@ var authMethods = (client , baseUrl ) => ({
2459
2465
  expiration ,
2460
2466
  isMobile = false,
2461
2467
  tenantId ,
2468
+ domainName ,
2462
2469
  ) => {
2463
2470
  const body = {
2464
2471
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2468,9 +2475,14 @@ var authMethods = (client , baseUrl ) => ({
2468
2475
  };
2469
2476
 
2470
2477
  if (tenantId) {
2478
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2471
2479
  body.tenant_id = tenantId;
2472
2480
  }
2473
2481
 
2482
+ if (domainName) {
2483
+ body.domain_name = domainName;
2484
+ }
2485
+
2474
2486
  const headers = {
2475
2487
  'Content-Type': 'application/json',
2476
2488
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2840,6 +2852,70 @@ class ExternalApp {
2840
2852
 
2841
2853
  //
2842
2854
 
2855
+ class MeetingAuthorization {
2856
+
2857
+
2858
+
2859
+
2860
+
2861
+
2862
+ constructor({
2863
+ meetingUuid,
2864
+ uuid,
2865
+ userUuid,
2866
+ userName,
2867
+ } = {}) {
2868
+ this.meetingUuid = meetingUuid;
2869
+ this.uuid = uuid;
2870
+ this.userUuid = userUuid;
2871
+ this.userName = userName;
2872
+ }
2873
+
2874
+ setStatus(status ) {
2875
+ this.status = status;
2876
+ }
2877
+
2878
+ getStatus() {
2879
+ return this.status;
2880
+ }
2881
+
2882
+ static parse(plain ) {
2883
+ const {
2884
+ meeting_uuid: meetingUuid,
2885
+ uuid,
2886
+ guest_uuid: userUuid,
2887
+ guest_name: userName,
2888
+ } = plain;
2889
+
2890
+ return new MeetingAuthorization({
2891
+ meetingUuid,
2892
+ uuid,
2893
+ userUuid,
2894
+ userName,
2895
+ });
2896
+ }
2897
+
2898
+ static parseMany(items ) {
2899
+ if (!items) {
2900
+ return [];
2901
+ }
2902
+ return items.map(MeetingAuthorization.parse);
2903
+ }
2904
+ }
2905
+
2906
+ //
2907
+
2908
+
2909
+
2910
+
2911
+
2912
+
2913
+
2914
+
2915
+
2916
+
2917
+
2918
+
2843
2919
 
2844
2920
 
2845
2921
 
@@ -2850,6 +2926,7 @@ class ExternalApp {
2850
2926
 
2851
2927
 
2852
2928
 
2929
+
2853
2930
 
2854
2931
 
2855
2932
  class Meeting {
@@ -2864,6 +2941,8 @@ class Meeting {
2864
2941
 
2865
2942
 
2866
2943
 
2944
+
2945
+
2867
2946
 
2868
2947
  static parse(plain ) {
2869
2948
  return new Meeting({
@@ -2876,6 +2955,7 @@ class Meeting {
2876
2955
  extension: plain.exten,
2877
2956
  persistent: plain.persistent,
2878
2957
  creationTime: moment(plain.creation_time).toDate(),
2958
+ requireAuthorization: plain.require_authorization,
2879
2959
  });
2880
2960
  }
2881
2961
 
@@ -2900,6 +2980,7 @@ class Meeting {
2900
2980
  extension,
2901
2981
  persistent,
2902
2982
  creationTime,
2983
+ requireAuthorization,
2903
2984
  } = {}) {
2904
2985
  this.guestSipAuthorization = guestSipAuthorization;
2905
2986
  this.uri = uri;
@@ -2910,6 +2991,7 @@ class Meeting {
2910
2991
  this.extension = extension;
2911
2992
  this.persistent = persistent;
2912
2993
  this.creationTime = creationTime;
2994
+ this.requireAuthorization = requireAuthorization;
2913
2995
 
2914
2996
  // Useful to compare instead of instanceof with minified code
2915
2997
  this.type = 'Meeting';
@@ -2920,8 +3002,32 @@ class Meeting {
2920
3002
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2921
3003
  return { username, secret };
2922
3004
  }
3005
+
2923
3006
  }
2924
3007
 
3008
+ //
3009
+
3010
+ const camelToUnderscore = (key ) => {
3011
+ if (typeof key !== 'string') {
3012
+ throw new Error('Input is not a string');
3013
+ }
3014
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
3015
+ };
3016
+
3017
+ //
3018
+
3019
+ const convertKeysFromCamelToUnderscore = (args ) => {
3020
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
3021
+ throw new Error('Input is not an object');
3022
+ }
3023
+
3024
+ return Object.keys(args).reduce((acc, key) => {
3025
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
3026
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
3027
+ return acc;
3028
+ }, {});
3029
+ };
3030
+
2925
3031
  /* */
2926
3032
 
2927
3033
  var confdMethods = (client , baseUrl ) => ({
@@ -2990,8 +3096,18 @@ var confdMethods = (client , baseUrl ) => ({
2990
3096
  getMyMeetings: () =>
2991
3097
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2992
3098
 
2993
- createMyMeeting: (name , persistent ) =>
2994
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3099
+ createMyMeeting: (args ) =>
3100
+ client
3101
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
3102
+ .then(Meeting.parse),
3103
+
3104
+ updateMyMeeting: (meetingUuid , data ) =>
3105
+ client.put(
3106
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
3107
+ convertKeysFromCamelToUnderscore(data),
3108
+ null,
3109
+ ApiRequester.successResponseParser,
3110
+ ),
2995
3111
 
2996
3112
  deleteMyMeeting: (meetingUuid ) =>
2997
3113
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2999,8 +3115,36 @@ var confdMethods = (client , baseUrl ) => ({
2999
3115
  getMeeting: (meetingUuid ) =>
3000
3116
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3001
3117
 
3118
+ meetingAuthorizations: (meetingUuid ) =>
3119
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
3120
+
3121
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
3122
+ client.put(
3123
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
3124
+ {},
3125
+ null,
3126
+ ApiRequester.successResponseParser,
3127
+ ),
3128
+
3129
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
3130
+ client.put(
3131
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
3132
+ {},
3133
+ null,
3134
+ ApiRequester.successResponseParser,
3135
+ ),
3136
+
3002
3137
  guestGetMeeting: (meetingUuid ) =>
3003
3138
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3139
+
3140
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
3141
+ client
3142
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
3143
+ .then(MeetingAuthorization.parse),
3144
+
3145
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
3146
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
3147
+
3004
3148
  });
3005
3149
 
3006
3150
  //
@@ -4207,6 +4351,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4351
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4352
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
4353
 
4354
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4355
+ client.delete(
4356
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4357
+ null,
4358
+ null,
4359
+ ApiRequester.successResponseParser,
4360
+ ),
4361
+
4210
4362
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4363
 
4212
4364
  mute: (callId ) =>
@@ -4584,6 +4736,7 @@ class ApiClient {
4584
4736
 
4585
4737
 
4586
4738
 
4739
+
4587
4740
 
4588
4741
 
4589
4742
 
@@ -4625,6 +4778,7 @@ class ApiClient {
4625
4778
  refreshToken: this.refreshToken,
4626
4779
  refreshBackend: this.refreshBackend,
4627
4780
  refreshTenantId: this.refreshTenantId,
4781
+ refreshDomainName: this.refreshDomainName,
4628
4782
  refreshExpiration: this.refreshExpiration,
4629
4783
  isMobile: this.isMobile,
4630
4784
  });
@@ -4640,6 +4794,7 @@ class ApiClient {
4640
4794
  this.refreshExpiration,
4641
4795
  this.isMobile,
4642
4796
  this.refreshTenantId,
4797
+ this.refreshDomainName,
4643
4798
  );
4644
4799
 
4645
4800
  logger.info('token refreshed', { token: session.token });
@@ -4693,9 +4848,14 @@ class ApiClient {
4693
4848
  }
4694
4849
 
4695
4850
  setRefreshTenantId(tenantId ) {
4851
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4696
4852
  this.refreshTenantId = tenantId;
4697
4853
  }
4698
4854
 
4855
+ setRefreshDomainName(domainName ) {
4856
+ this.refreshDomainName = domainName;
4857
+ }
4858
+
4699
4859
  setIsMobile(isMobile ) {
4700
4860
  this.isMobile = isMobile;
4701
4861
  }
@@ -4720,6 +4880,7 @@ global.wazoClientId = global.wazoClientId || {};
4720
4880
  global.wazoClientToken = global.wazoClientToken || {};
4721
4881
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4722
4882
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4883
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4723
4884
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4724
4885
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4725
4886
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4729,6 +4890,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
4729
4890
 
4730
4891
  const fillClient = (apiClient ) => {
4731
4892
  const { server, token, clientId } = apiClient.client;
4893
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4732
4894
 
4733
4895
  // try with null server when dealing with non-related server info
4734
4896
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4737,8 +4899,12 @@ const fillClient = (apiClient ) => {
4737
4899
 
4738
4900
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4739
4901
 
4740
- apiClient.setRefreshTenantId(
4741
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4902
+ if (tenantId) {
4903
+ apiClient.setRefreshTenantId(tenantId);
4904
+ }
4905
+
4906
+ apiClient.setRefreshDomainName(
4907
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4742
4908
  );
4743
4909
 
4744
4910
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -2209,6 +2209,7 @@ var authMethods = (client , baseUrl ) => ({
2209
2209
 
2210
2210
 
2211
2211
 
2212
+
2212
2213
  ) {
2213
2214
  const body = {
2214
2215
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2229,9 +2230,14 @@ var authMethods = (client , baseUrl ) => ({
2229
2230
  }
2230
2231
 
2231
2232
  if (params.tenantId) {
2233
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2232
2234
  body.tenant_id = params.tenantId;
2233
2235
  }
2234
2236
 
2237
+ if (params.domainName) {
2238
+ body.domain_name = params.domainName;
2239
+ }
2240
+
2235
2241
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2236
2242
  },
2237
2243
 
@@ -2244,6 +2250,7 @@ var authMethods = (client , baseUrl ) => ({
2244
2250
  expiration ,
2245
2251
  isMobile = false,
2246
2252
  tenantId ,
2253
+ domainName ,
2247
2254
  ) => {
2248
2255
  const body = {
2249
2256
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2253,9 +2260,14 @@ var authMethods = (client , baseUrl ) => ({
2253
2260
  };
2254
2261
 
2255
2262
  if (tenantId) {
2263
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2256
2264
  body.tenant_id = tenantId;
2257
2265
  }
2258
2266
 
2267
+ if (domainName) {
2268
+ body.domain_name = domainName;
2269
+ }
2270
+
2259
2271
  const headers = {
2260
2272
  'Content-Type': 'application/json',
2261
2273
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -2625,6 +2637,70 @@ class ExternalApp {
2625
2637
 
2626
2638
  //
2627
2639
 
2640
+ class MeetingAuthorization {
2641
+
2642
+
2643
+
2644
+
2645
+
2646
+
2647
+ constructor({
2648
+ meetingUuid,
2649
+ uuid,
2650
+ userUuid,
2651
+ userName,
2652
+ } = {}) {
2653
+ this.meetingUuid = meetingUuid;
2654
+ this.uuid = uuid;
2655
+ this.userUuid = userUuid;
2656
+ this.userName = userName;
2657
+ }
2658
+
2659
+ setStatus(status ) {
2660
+ this.status = status;
2661
+ }
2662
+
2663
+ getStatus() {
2664
+ return this.status;
2665
+ }
2666
+
2667
+ static parse(plain ) {
2668
+ const {
2669
+ meeting_uuid: meetingUuid,
2670
+ uuid,
2671
+ guest_uuid: userUuid,
2672
+ guest_name: userName,
2673
+ } = plain;
2674
+
2675
+ return new MeetingAuthorization({
2676
+ meetingUuid,
2677
+ uuid,
2678
+ userUuid,
2679
+ userName,
2680
+ });
2681
+ }
2682
+
2683
+ static parseMany(items ) {
2684
+ if (!items) {
2685
+ return [];
2686
+ }
2687
+ return items.map(MeetingAuthorization.parse);
2688
+ }
2689
+ }
2690
+
2691
+ //
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2628
2704
 
2629
2705
 
2630
2706
 
@@ -2635,6 +2711,7 @@ class ExternalApp {
2635
2711
 
2636
2712
 
2637
2713
 
2714
+
2638
2715
 
2639
2716
 
2640
2717
  class Meeting {
@@ -2649,6 +2726,8 @@ class Meeting {
2649
2726
 
2650
2727
 
2651
2728
 
2729
+
2730
+
2652
2731
 
2653
2732
  static parse(plain ) {
2654
2733
  return new Meeting({
@@ -2661,6 +2740,7 @@ class Meeting {
2661
2740
  extension: plain.exten,
2662
2741
  persistent: plain.persistent,
2663
2742
  creationTime: moment(plain.creation_time).toDate(),
2743
+ requireAuthorization: plain.require_authorization,
2664
2744
  });
2665
2745
  }
2666
2746
 
@@ -2685,6 +2765,7 @@ class Meeting {
2685
2765
  extension,
2686
2766
  persistent,
2687
2767
  creationTime,
2768
+ requireAuthorization,
2688
2769
  } = {}) {
2689
2770
  this.guestSipAuthorization = guestSipAuthorization;
2690
2771
  this.uri = uri;
@@ -2695,6 +2776,7 @@ class Meeting {
2695
2776
  this.extension = extension;
2696
2777
  this.persistent = persistent;
2697
2778
  this.creationTime = creationTime;
2779
+ this.requireAuthorization = requireAuthorization;
2698
2780
 
2699
2781
  // Useful to compare instead of instanceof with minified code
2700
2782
  this.type = 'Meeting';
@@ -2705,8 +2787,32 @@ class Meeting {
2705
2787
  const [username, secret] = atob(this.guestSipAuthorization).split(':');
2706
2788
  return { username, secret };
2707
2789
  }
2790
+
2708
2791
  }
2709
2792
 
2793
+ //
2794
+
2795
+ const camelToUnderscore = (key ) => {
2796
+ if (typeof key !== 'string') {
2797
+ throw new Error('Input is not a string');
2798
+ }
2799
+ return key.charAt(0).toLowerCase() + key.substring(1).replace(/([A-Z])/g, '_$1').toLowerCase();
2800
+ };
2801
+
2802
+ //
2803
+
2804
+ const convertKeysFromCamelToUnderscore = (args ) => {
2805
+ if (!args || typeof args !== 'object' || Array.isArray(args)) {
2806
+ throw new Error('Input is not an object');
2807
+ }
2808
+
2809
+ return Object.keys(args).reduce((acc, key) => {
2810
+ acc[camelToUnderscore(key)] = typeof args[key] === 'object' && !Array.isArray(args[key])
2811
+ ? convertKeysFromCamelToUnderscore(args[key]) : args[key];
2812
+ return acc;
2813
+ }, {});
2814
+ };
2815
+
2710
2816
  /* */
2711
2817
 
2712
2818
  var confdMethods = (client , baseUrl ) => ({
@@ -2775,8 +2881,18 @@ var confdMethods = (client , baseUrl ) => ({
2775
2881
  getMyMeetings: () =>
2776
2882
  client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2777
2883
 
2778
- createMyMeeting: (name , persistent ) =>
2779
- client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2884
+ createMyMeeting: (args ) =>
2885
+ client
2886
+ .post(`${baseUrl}/users/me/meetings`, convertKeysFromCamelToUnderscore(args))
2887
+ .then(Meeting.parse),
2888
+
2889
+ updateMyMeeting: (meetingUuid , data ) =>
2890
+ client.put(
2891
+ `${baseUrl}/users/me/meetings/${meetingUuid}`,
2892
+ convertKeysFromCamelToUnderscore(data),
2893
+ null,
2894
+ ApiRequester.successResponseParser,
2895
+ ),
2780
2896
 
2781
2897
  deleteMyMeeting: (meetingUuid ) =>
2782
2898
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2784,8 +2900,36 @@ var confdMethods = (client , baseUrl ) => ({
2784
2900
  getMeeting: (meetingUuid ) =>
2785
2901
  client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2786
2902
 
2903
+ meetingAuthorizations: (meetingUuid ) =>
2904
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/authorizations`, null).then(MeetingAuthorization.parseMany),
2905
+
2906
+ meetingAuthorizationReject: (meetingUuid , authorizationUuid ) =>
2907
+ client.put(
2908
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/reject`,
2909
+ {},
2910
+ null,
2911
+ ApiRequester.successResponseParser,
2912
+ ),
2913
+
2914
+ meetingAuthorizationAccept: (meetingUuid , authorizationUuid ) =>
2915
+ client.put(
2916
+ `${baseUrl}/users/me/meetings/${meetingUuid}/authorizations/${authorizationUuid}/accept`,
2917
+ {},
2918
+ null,
2919
+ ApiRequester.successResponseParser,
2920
+ ),
2921
+
2787
2922
  guestGetMeeting: (meetingUuid ) =>
2788
2923
  client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2924
+
2925
+ guestAuthorizationRequest: (userUuid , meetingUuid , username ) =>
2926
+ client
2927
+ .post(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations`, { guest_name: username })
2928
+ .then(MeetingAuthorization.parse),
2929
+
2930
+ guestAuthorizationCheck: (userUuid , meetingUuid , authorizationUuid ) =>
2931
+ client.get(`${baseUrl}/guests/${userUuid}/meetings/${meetingUuid}/authorizations/${authorizationUuid}`, null),
2932
+
2789
2933
  });
2790
2934
 
2791
2935
  //
@@ -4207,6 +4351,14 @@ var calldMethods = (client , baseUrl ) => ({
4207
4351
  getMeetingParticipantsAsUser: async (meetingUuid ) =>
4208
4352
  client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4209
4353
 
4354
+ banMeetingParticipant: (meetingUuid , participantUuid ) =>
4355
+ client.delete(
4356
+ `${baseUrl}/users/me/meetings/${meetingUuid}/participants/${participantUuid}`,
4357
+ null,
4358
+ null,
4359
+ ApiRequester.successResponseParser,
4360
+ ),
4361
+
4210
4362
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4211
4363
 
4212
4364
  mute: (callId ) =>
@@ -4584,6 +4736,7 @@ class ApiClient {
4584
4736
 
4585
4737
 
4586
4738
 
4739
+
4587
4740
 
4588
4741
 
4589
4742
 
@@ -4625,6 +4778,7 @@ class ApiClient {
4625
4778
  refreshToken: this.refreshToken,
4626
4779
  refreshBackend: this.refreshBackend,
4627
4780
  refreshTenantId: this.refreshTenantId,
4781
+ refreshDomainName: this.refreshDomainName,
4628
4782
  refreshExpiration: this.refreshExpiration,
4629
4783
  isMobile: this.isMobile,
4630
4784
  });
@@ -4640,6 +4794,7 @@ class ApiClient {
4640
4794
  this.refreshExpiration,
4641
4795
  this.isMobile,
4642
4796
  this.refreshTenantId,
4797
+ this.refreshDomainName,
4643
4798
  );
4644
4799
 
4645
4800
  logger.info('token refreshed', { token: session.token });
@@ -4693,9 +4848,14 @@ class ApiClient {
4693
4848
  }
4694
4849
 
4695
4850
  setRefreshTenantId(tenantId ) {
4851
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4696
4852
  this.refreshTenantId = tenantId;
4697
4853
  }
4698
4854
 
4855
+ setRefreshDomainName(domainName ) {
4856
+ this.refreshDomainName = domainName;
4857
+ }
4858
+
4699
4859
  setIsMobile(isMobile ) {
4700
4860
  this.isMobile = isMobile;
4701
4861
  }
@@ -4720,6 +4880,7 @@ global.wazoClientId = global.wazoClientId || {};
4720
4880
  global.wazoClientToken = global.wazoClientToken || {};
4721
4881
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4722
4882
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4883
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4723
4884
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4724
4885
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4725
4886
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4729,6 +4890,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
4729
4890
 
4730
4891
  const fillClient = (apiClient ) => {
4731
4892
  const { server, token, clientId } = apiClient.client;
4893
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4732
4894
 
4733
4895
  // try with null server when dealing with non-related server info
4734
4896
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4737,8 +4899,12 @@ const fillClient = (apiClient ) => {
4737
4899
 
4738
4900
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4739
4901
 
4740
- apiClient.setRefreshTenantId(
4741
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4902
+ if (tenantId) {
4903
+ apiClient.setRefreshTenantId(tenantId);
4904
+ }
4905
+
4906
+ apiClient.setRefreshDomainName(
4907
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4742
4908
  );
4743
4909
 
4744
4910
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);