@wazo/sdk 0.38.9 → 0.38.12

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 (78) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +21 -0
  3. package/esm/__tests__/web-rtc-client.test.js +32 -7
  4. package/esm/api/auth.js +12 -0
  5. package/esm/api/ctid-ng.js +1 -0
  6. package/esm/api-client.js +21 -0
  7. package/esm/checker/Checker.js +32 -7
  8. package/esm/checker/checks/aor.js +21 -0
  9. package/esm/checker/checks/api.js +21 -0
  10. package/esm/checker/checks/index.js +32 -7
  11. package/esm/checker/checks/webrtc-transport.js +32 -7
  12. package/esm/checker/checks/webrtc.js +32 -7
  13. package/esm/domain/AdHocAPIConference.js +28 -2
  14. package/esm/domain/Features.js +28 -2
  15. package/esm/domain/Phone/CTIPhone.js +28 -2
  16. package/esm/domain/Phone/WebRTCPhone.js +3 -2
  17. package/esm/index.js +86 -15
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +87 -16
  21. package/esm/simple/Configuration.js +86 -15
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +86 -15
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +86 -15
  26. package/esm/simple/room/LocalParticipant.js +86 -15
  27. package/esm/simple/room/Participant.js +86 -15
  28. package/esm/simple/room/RemoteParticipant.js +86 -15
  29. package/esm/simple/room/Room.js +86 -15
  30. package/esm/simple/room/SipRoom.js +86 -15
  31. package/esm/simple/room/Stream.js +86 -15
  32. package/esm/simple/room/__tests__/Participant.test.js +86 -15
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -15
  34. package/esm/simple/utils.js +86 -15
  35. package/esm/web-rtc-client.js +32 -7
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +32 -7
  38. package/lib/api/auth.js +12 -0
  39. package/lib/api/ctid-ng.js +1 -0
  40. package/lib/api-client.js +21 -0
  41. package/lib/checker/Checker.js +32 -7
  42. package/lib/checker/checks/aor.js +21 -0
  43. package/lib/checker/checks/api.js +21 -0
  44. package/lib/checker/checks/index.js +32 -7
  45. package/lib/checker/checks/webrtc-transport.js +32 -7
  46. package/lib/checker/checks/webrtc.js +32 -7
  47. package/lib/domain/AdHocAPIConference.js +28 -2
  48. package/lib/domain/Features.js +28 -2
  49. package/lib/domain/Phone/CTIPhone.js +28 -2
  50. package/lib/domain/Phone/WebRTCPhone.js +3 -2
  51. package/lib/index.js +86 -15
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +87 -15
  55. package/lib/simple/Configuration.js +86 -15
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +86 -15
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +86 -15
  60. package/lib/simple/room/LocalParticipant.js +86 -15
  61. package/lib/simple/room/Participant.js +86 -15
  62. package/lib/simple/room/RemoteParticipant.js +86 -15
  63. package/lib/simple/room/Room.js +86 -15
  64. package/lib/simple/room/SipRoom.js +86 -15
  65. package/lib/simple/room/Stream.js +86 -15
  66. package/lib/simple/room/__tests__/Participant.test.js +86 -15
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -15
  68. package/lib/simple/utils.js +86 -15
  69. package/lib/web-rtc-client.js +32 -7
  70. package/package.json +2 -2
  71. package/src/api/auth.js +12 -0
  72. package/src/api-client.js +8 -0
  73. package/src/domain/Phone/WebRTCPhone.js +2 -2
  74. package/src/service/getApiClient.js +13 -2
  75. package/src/simple/Auth.js +35 -4
  76. package/src/simple/Softphone.js +5 -0
  77. package/src/simple/index.js +2 -1
  78. package/src/web-rtc-client.js +11 -7
@@ -2430,6 +2430,7 @@ var authMethods = (client , baseUrl ) => ({
2430
2430
 
2431
2431
 
2432
2432
 
2433
+
2433
2434
  ) {
2434
2435
  const body = {
2435
2436
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2450,9 +2451,14 @@ var authMethods = (client , baseUrl ) => ({
2450
2451
  }
2451
2452
 
2452
2453
  if (params.tenantId) {
2454
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2453
2455
  body.tenant_id = params.tenantId;
2454
2456
  }
2455
2457
 
2458
+ if (params.domainName) {
2459
+ body.domain_name = params.domainName;
2460
+ }
2461
+
2456
2462
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2457
2463
  },
2458
2464
 
@@ -2465,6 +2471,7 @@ var authMethods = (client , baseUrl ) => ({
2465
2471
  expiration ,
2466
2472
  isMobile = false,
2467
2473
  tenantId ,
2474
+ domainName ,
2468
2475
  ) => {
2469
2476
  const body = {
2470
2477
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2474,9 +2481,14 @@ var authMethods = (client , baseUrl ) => ({
2474
2481
  };
2475
2482
 
2476
2483
  if (tenantId) {
2484
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2477
2485
  body.tenant_id = tenantId;
2478
2486
  }
2479
2487
 
2488
+ if (domainName) {
2489
+ body.domain_name = domainName;
2490
+ }
2491
+
2480
2492
  const headers = {
2481
2493
  'Content-Type': 'application/json',
2482
2494
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4730,6 +4742,7 @@ class ApiClient {
4730
4742
 
4731
4743
 
4732
4744
 
4745
+
4733
4746
 
4734
4747
 
4735
4748
 
@@ -4771,6 +4784,7 @@ class ApiClient {
4771
4784
  refreshToken: this.refreshToken,
4772
4785
  refreshBackend: this.refreshBackend,
4773
4786
  refreshTenantId: this.refreshTenantId,
4787
+ refreshDomainName: this.refreshDomainName,
4774
4788
  refreshExpiration: this.refreshExpiration,
4775
4789
  isMobile: this.isMobile,
4776
4790
  });
@@ -4786,6 +4800,7 @@ class ApiClient {
4786
4800
  this.refreshExpiration,
4787
4801
  this.isMobile,
4788
4802
  this.refreshTenantId,
4803
+ this.refreshDomainName,
4789
4804
  );
4790
4805
 
4791
4806
  logger.info('token refreshed', { token: session.token });
@@ -4839,9 +4854,14 @@ class ApiClient {
4839
4854
  }
4840
4855
 
4841
4856
  setRefreshTenantId(tenantId ) {
4857
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4842
4858
  this.refreshTenantId = tenantId;
4843
4859
  }
4844
4860
 
4861
+ setRefreshDomainName(domainName ) {
4862
+ this.refreshDomainName = domainName;
4863
+ }
4864
+
4845
4865
  setIsMobile(isMobile ) {
4846
4866
  this.isMobile = isMobile;
4847
4867
  }
@@ -4866,6 +4886,7 @@ global.wazoClientId = global.wazoClientId || {};
4866
4886
  global.wazoClientToken = global.wazoClientToken || {};
4867
4887
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4868
4888
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4889
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4869
4890
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4870
4891
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4871
4892
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4875,6 +4896,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
4875
4896
 
4876
4897
  const fillClient = (apiClient ) => {
4877
4898
  const { server, token, clientId } = apiClient.client;
4899
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4878
4900
 
4879
4901
  // try with null server when dealing with non-related server info
4880
4902
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4883,8 +4905,12 @@ const fillClient = (apiClient ) => {
4883
4905
 
4884
4906
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4885
4907
 
4886
- apiClient.setRefreshTenantId(
4887
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4908
+ if (tenantId) {
4909
+ apiClient.setRefreshTenantId(tenantId);
4910
+ }
4911
+
4912
+ apiClient.setRefreshDomainName(
4913
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4888
4914
  );
4889
4915
 
4890
4916
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -2217,6 +2217,7 @@ var authMethods = (client , baseUrl ) => ({
2217
2217
 
2218
2218
 
2219
2219
 
2220
+
2220
2221
  ) {
2221
2222
  const body = {
2222
2223
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2237,9 +2238,14 @@ var authMethods = (client , baseUrl ) => ({
2237
2238
  }
2238
2239
 
2239
2240
  if (params.tenantId) {
2241
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2240
2242
  body.tenant_id = params.tenantId;
2241
2243
  }
2242
2244
 
2245
+ if (params.domainName) {
2246
+ body.domain_name = params.domainName;
2247
+ }
2248
+
2243
2249
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2244
2250
  },
2245
2251
 
@@ -2252,6 +2258,7 @@ var authMethods = (client , baseUrl ) => ({
2252
2258
  expiration ,
2253
2259
  isMobile = false,
2254
2260
  tenantId ,
2261
+ domainName ,
2255
2262
  ) => {
2256
2263
  const body = {
2257
2264
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2261,9 +2268,14 @@ var authMethods = (client , baseUrl ) => ({
2261
2268
  };
2262
2269
 
2263
2270
  if (tenantId) {
2271
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2264
2272
  body.tenant_id = tenantId;
2265
2273
  }
2266
2274
 
2275
+ if (domainName) {
2276
+ body.domain_name = domainName;
2277
+ }
2278
+
2267
2279
  const headers = {
2268
2280
  'Content-Type': 'application/json',
2269
2281
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4732,6 +4744,7 @@ class ApiClient {
4732
4744
 
4733
4745
 
4734
4746
 
4747
+
4735
4748
 
4736
4749
 
4737
4750
 
@@ -4773,6 +4786,7 @@ class ApiClient {
4773
4786
  refreshToken: this.refreshToken,
4774
4787
  refreshBackend: this.refreshBackend,
4775
4788
  refreshTenantId: this.refreshTenantId,
4789
+ refreshDomainName: this.refreshDomainName,
4776
4790
  refreshExpiration: this.refreshExpiration,
4777
4791
  isMobile: this.isMobile,
4778
4792
  });
@@ -4788,6 +4802,7 @@ class ApiClient {
4788
4802
  this.refreshExpiration,
4789
4803
  this.isMobile,
4790
4804
  this.refreshTenantId,
4805
+ this.refreshDomainName,
4791
4806
  );
4792
4807
 
4793
4808
  logger.info('token refreshed', { token: session.token });
@@ -4841,9 +4856,14 @@ class ApiClient {
4841
4856
  }
4842
4857
 
4843
4858
  setRefreshTenantId(tenantId ) {
4859
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4844
4860
  this.refreshTenantId = tenantId;
4845
4861
  }
4846
4862
 
4863
+ setRefreshDomainName(domainName ) {
4864
+ this.refreshDomainName = domainName;
4865
+ }
4866
+
4847
4867
  setIsMobile(isMobile ) {
4848
4868
  this.isMobile = isMobile;
4849
4869
  }
@@ -4868,6 +4888,7 @@ global.wazoClientId = global.wazoClientId || {};
4868
4888
  global.wazoClientToken = global.wazoClientToken || {};
4869
4889
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4870
4890
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4891
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4871
4892
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4872
4893
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4873
4894
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4877,6 +4898,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
4877
4898
 
4878
4899
  const fillClient = (apiClient ) => {
4879
4900
  const { server, token, clientId } = apiClient.client;
4901
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4880
4902
 
4881
4903
  // try with null server when dealing with non-related server info
4882
4904
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4885,8 +4907,12 @@ const fillClient = (apiClient ) => {
4885
4907
 
4886
4908
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4887
4909
 
4888
- apiClient.setRefreshTenantId(
4889
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4910
+ if (tenantId) {
4911
+ apiClient.setRefreshTenantId(tenantId);
4912
+ }
4913
+
4914
+ apiClient.setRefreshDomainName(
4915
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4890
4916
  );
4891
4917
 
4892
4918
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -3184,6 +3184,7 @@ var authMethods = (client , baseUrl ) => ({
3184
3184
 
3185
3185
 
3186
3186
 
3187
+
3187
3188
  ) {
3188
3189
  const body = {
3189
3190
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -3204,9 +3205,14 @@ var authMethods = (client , baseUrl ) => ({
3204
3205
  }
3205
3206
 
3206
3207
  if (params.tenantId) {
3208
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
3207
3209
  body.tenant_id = params.tenantId;
3208
3210
  }
3209
3211
 
3212
+ if (params.domainName) {
3213
+ body.domain_name = params.domainName;
3214
+ }
3215
+
3210
3216
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
3211
3217
  },
3212
3218
 
@@ -3219,6 +3225,7 @@ var authMethods = (client , baseUrl ) => ({
3219
3225
  expiration ,
3220
3226
  isMobile = false,
3221
3227
  tenantId ,
3228
+ domainName ,
3222
3229
  ) => {
3223
3230
  const body = {
3224
3231
  backend: backend || DEFAULT_BACKEND_USER,
@@ -3228,9 +3235,14 @@ var authMethods = (client , baseUrl ) => ({
3228
3235
  };
3229
3236
 
3230
3237
  if (tenantId) {
3238
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
3231
3239
  body.tenant_id = tenantId;
3232
3240
  }
3233
3241
 
3242
+ if (domainName) {
3243
+ body.domain_name = domainName;
3244
+ }
3245
+
3234
3246
  const headers = {
3235
3247
  'Content-Type': 'application/json',
3236
3248
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5146,6 +5158,7 @@ class ApiClient {
5146
5158
 
5147
5159
 
5148
5160
 
5161
+
5149
5162
 
5150
5163
 
5151
5164
 
@@ -5187,6 +5200,7 @@ class ApiClient {
5187
5200
  refreshToken: this.refreshToken,
5188
5201
  refreshBackend: this.refreshBackend,
5189
5202
  refreshTenantId: this.refreshTenantId,
5203
+ refreshDomainName: this.refreshDomainName,
5190
5204
  refreshExpiration: this.refreshExpiration,
5191
5205
  isMobile: this.isMobile,
5192
5206
  });
@@ -5202,6 +5216,7 @@ class ApiClient {
5202
5216
  this.refreshExpiration,
5203
5217
  this.isMobile,
5204
5218
  this.refreshTenantId,
5219
+ this.refreshDomainName,
5205
5220
  );
5206
5221
 
5207
5222
  logger$1.info('token refreshed', { token: session.token });
@@ -5255,9 +5270,14 @@ class ApiClient {
5255
5270
  }
5256
5271
 
5257
5272
  setRefreshTenantId(tenantId ) {
5273
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5258
5274
  this.refreshTenantId = tenantId;
5259
5275
  }
5260
5276
 
5277
+ setRefreshDomainName(domainName ) {
5278
+ this.refreshDomainName = domainName;
5279
+ }
5280
+
5261
5281
  setIsMobile(isMobile ) {
5262
5282
  this.isMobile = isMobile;
5263
5283
  }
@@ -5282,6 +5302,7 @@ global.wazoClientId = global.wazoClientId || {};
5282
5302
  global.wazoClientToken = global.wazoClientToken || {};
5283
5303
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5284
5304
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5305
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5285
5306
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5286
5307
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5287
5308
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5291,6 +5312,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
5291
5312
 
5292
5313
  const fillClient = (apiClient ) => {
5293
5314
  const { server, token, clientId } = apiClient.client;
5315
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5294
5316
 
5295
5317
  // try with null server when dealing with non-related server info
5296
5318
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5299,8 +5321,12 @@ const fillClient = (apiClient ) => {
5299
5321
 
5300
5322
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5301
5323
 
5302
- apiClient.setRefreshTenantId(
5303
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5324
+ if (tenantId) {
5325
+ apiClient.setRefreshTenantId(tenantId);
5326
+ }
5327
+
5328
+ apiClient.setRefreshDomainName(
5329
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5304
5330
  );
5305
5331
 
5306
5332
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -903,6 +903,7 @@ global.wazoClientId = global.wazoClientId || {};
903
903
  global.wazoClientToken = global.wazoClientToken || {};
904
904
  global.wazoRefreshToken = global.wazoRefreshToken || {};
905
905
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
906
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
906
907
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
907
908
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
908
909
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -1404,7 +1405,7 @@ class WebRTCPhone extends Emitter {
1404
1405
  const screenTrack = screenShareStream.getVideoTracks()[0];
1405
1406
  const sipSession = this.currentSipSession;
1406
1407
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
1407
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1408
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1408
1409
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
1409
1410
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
1410
1411
  const hadVideo = !!videoTrack;
@@ -1486,7 +1487,7 @@ class WebRTCPhone extends Emitter {
1486
1487
  const screenTrack = screenStream.getVideoTracks()[0];
1487
1488
  const sipSessionId = this.getSipSessionId(sipSession);
1488
1489
  const pc = this.client.getPeerConnection(sipSessionId);
1489
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1490
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1490
1491
 
1491
1492
  logger.info('WebRTC phone - on screensharing', {
1492
1493
  hadVideo,
package/lib/index.js CHANGED
@@ -2241,6 +2241,7 @@ var authMethods = (client , baseUrl ) => ({
2241
2241
 
2242
2242
 
2243
2243
 
2244
+
2244
2245
  ) {
2245
2246
  const body = {
2246
2247
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2261,9 +2262,14 @@ var authMethods = (client , baseUrl ) => ({
2261
2262
  }
2262
2263
 
2263
2264
  if (params.tenantId) {
2265
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2264
2266
  body.tenant_id = params.tenantId;
2265
2267
  }
2266
2268
 
2269
+ if (params.domainName) {
2270
+ body.domain_name = params.domainName;
2271
+ }
2272
+
2267
2273
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2268
2274
  },
2269
2275
 
@@ -2276,6 +2282,7 @@ var authMethods = (client , baseUrl ) => ({
2276
2282
  expiration ,
2277
2283
  isMobile = false,
2278
2284
  tenantId ,
2285
+ domainName ,
2279
2286
  ) => {
2280
2287
  const body = {
2281
2288
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2285,9 +2292,14 @@ var authMethods = (client , baseUrl ) => ({
2285
2292
  };
2286
2293
 
2287
2294
  if (tenantId) {
2295
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2288
2296
  body.tenant_id = tenantId;
2289
2297
  }
2290
2298
 
2299
+ if (domainName) {
2300
+ body.domain_name = domainName;
2301
+ }
2302
+
2291
2303
  const headers = {
2292
2304
  'Content-Type': 'application/json',
2293
2305
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4134,6 +4146,7 @@ global.wazoClientId = global.wazoClientId || {};
4134
4146
  global.wazoClientToken = global.wazoClientToken || {};
4135
4147
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4136
4148
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4149
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4137
4150
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4138
4151
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4139
4152
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4158,9 +4171,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
4158
4171
  };
4159
4172
 
4160
4173
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
4174
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
4161
4175
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
4162
4176
  };
4163
4177
 
4178
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
4179
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
4180
+ };
4181
+
4164
4182
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
4165
4183
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
4166
4184
  };
@@ -4179,6 +4197,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
4179
4197
 
4180
4198
  const fillClient = (apiClient ) => {
4181
4199
  const { server, token, clientId } = apiClient.client;
4200
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4182
4201
 
4183
4202
  // try with null server when dealing with non-related server info
4184
4203
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4187,8 +4206,12 @@ const fillClient = (apiClient ) => {
4187
4206
 
4188
4207
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4189
4208
 
4190
- apiClient.setRefreshTenantId(
4191
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4209
+ if (tenantId) {
4210
+ apiClient.setRefreshTenantId(tenantId);
4211
+ }
4212
+
4213
+ apiClient.setRefreshDomainName(
4214
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4192
4215
  );
4193
4216
 
4194
4217
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5686,6 +5709,7 @@ class ApiClient {
5686
5709
 
5687
5710
 
5688
5711
 
5712
+
5689
5713
 
5690
5714
 
5691
5715
 
@@ -5727,6 +5751,7 @@ class ApiClient {
5727
5751
  refreshToken: this.refreshToken,
5728
5752
  refreshBackend: this.refreshBackend,
5729
5753
  refreshTenantId: this.refreshTenantId,
5754
+ refreshDomainName: this.refreshDomainName,
5730
5755
  refreshExpiration: this.refreshExpiration,
5731
5756
  isMobile: this.isMobile,
5732
5757
  });
@@ -5742,6 +5767,7 @@ class ApiClient {
5742
5767
  this.refreshExpiration,
5743
5768
  this.isMobile,
5744
5769
  this.refreshTenantId,
5770
+ this.refreshDomainName,
5745
5771
  );
5746
5772
 
5747
5773
  logger$a.info('token refreshed', { token: session.token });
@@ -5795,9 +5821,14 @@ class ApiClient {
5795
5821
  }
5796
5822
 
5797
5823
  setRefreshTenantId(tenantId ) {
5824
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5798
5825
  this.refreshTenantId = tenantId;
5799
5826
  }
5800
5827
 
5828
+ setRefreshDomainName(domainName ) {
5829
+ this.refreshDomainName = domainName;
5830
+ }
5831
+
5801
5832
  setIsMobile(isMobile ) {
5802
5833
  this.isMobile = isMobile;
5803
5834
  }
@@ -7252,7 +7283,7 @@ class WebRTCClient extends Emitter {
7252
7283
 
7253
7284
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
7254
7285
  } else {
7255
- videoSender = pc.getSenders().find(sender => sender.track === null);
7286
+ videoSender = pc && pc.getSenders && pc.getSenders().find(sender => sender.track === null);
7256
7287
  }
7257
7288
 
7258
7289
  if (!videoSender) {
@@ -7293,9 +7324,11 @@ class WebRTCClient extends Emitter {
7293
7324
  const videoTracks = localStream.getVideoTracks();
7294
7325
 
7295
7326
  // Remove video senders
7296
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7297
- videoSender.replaceTrack(null);
7298
- });
7327
+ if (pc.getSenders) {
7328
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7329
+ videoSender.replaceTrack(null);
7330
+ });
7331
+ }
7299
7332
 
7300
7333
  videoTracks.forEach(videoTrack => {
7301
7334
  videoTrack.enabled = false;
@@ -7528,7 +7561,8 @@ class WebRTCClient extends Emitter {
7528
7561
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7529
7562
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7530
7563
  const audioTrack = stream.getAudioTracks()[0];
7531
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7564
+ const sender = pc && pc.getSenders
7565
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7532
7566
 
7533
7567
  if (sender) {
7534
7568
  if (sender.track) {
@@ -7591,10 +7625,11 @@ class WebRTCClient extends Emitter {
7591
7625
  // $FlowFixMe
7592
7626
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
7593
7627
  const videoTrack = stream.getVideoTracks()[0];
7594
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7628
+ let sender = pc && pc.getSenders
7629
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7595
7630
  let wasTrackEnabled = false;
7596
7631
  if (!sender) {
7597
- sender = pc && pc.getSenders().find(s => !s.track);
7632
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
7598
7633
  }
7599
7634
 
7600
7635
  if (sender) {
@@ -10032,7 +10067,7 @@ class WebRTCPhone extends Emitter {
10032
10067
  const screenTrack = screenShareStream.getVideoTracks()[0];
10033
10068
  const sipSession = this.currentSipSession;
10034
10069
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
10035
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10070
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10036
10071
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
10037
10072
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
10038
10073
  const hadVideo = !!videoTrack;
@@ -10114,7 +10149,7 @@ class WebRTCPhone extends Emitter {
10114
10149
  const screenTrack = screenStream.getVideoTracks()[0];
10115
10150
  const sipSessionId = this.getSipSessionId(sipSession);
10116
10151
  const pc = this.client.getPeerConnection(sipSessionId);
10117
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10152
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10118
10153
 
10119
10154
  logger$7.info('WebRTC phone - on screensharing', {
10120
10155
  hadVideo,
@@ -11955,6 +11990,7 @@ const getCallableNumber = (number , country ) => {
11955
11990
  class InvalidSubscription extends Error {}
11956
11991
  class InvalidAuthorization extends Error {}
11957
11992
  class NoTenantIdError extends Error {}
11993
+ class NoDomainNameError extends Error {}
11958
11994
 
11959
11995
  const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11960
11996
 
@@ -12018,9 +12054,24 @@ class Auth {
12018
12054
  setFetchOptions(options);
12019
12055
  }
12020
12056
 
12021
- async logIn(username , password , backend , tenantId ) {
12022
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
12023
- throw new NoTenantIdError('No tenant id');
12057
+ async logIn(username , password , backend , extra ) {
12058
+ let tenantId = null;
12059
+ let domainName = null;
12060
+ if (typeof extra === 'string') {
12061
+ tenantId = extra;
12062
+ }
12063
+ if (extra && typeof extra === 'object') {
12064
+ domainName = extra.domainName;
12065
+ }
12066
+
12067
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
12068
+ if (!tenantId) {
12069
+ throw new NoTenantIdError('No tenant id');
12070
+ }
12071
+
12072
+ if (!domainName) {
12073
+ throw new NoDomainNameError('No domain name');
12074
+ }
12024
12075
  }
12025
12076
 
12026
12077
  this.authenticated = false;
@@ -12030,6 +12081,7 @@ class Auth {
12030
12081
  password,
12031
12082
  backend,
12032
12083
  tenantId,
12084
+ domainName,
12033
12085
  expiration: this.expiration,
12034
12086
  mobile: this.mobile,
12035
12087
  });
@@ -12038,7 +12090,13 @@ class Auth {
12038
12090
  getApiClient().setRefreshBackend(backend);
12039
12091
  }
12040
12092
 
12041
- getApiClient().setRefreshTenantId(tenantId);
12093
+ if (tenantId) {
12094
+ getApiClient().setRefreshTenantId(tenantId);
12095
+ }
12096
+
12097
+ if (domainName) {
12098
+ getApiClient().setRefreshDomainName(domainName);
12099
+ }
12042
12100
 
12043
12101
  return this._onAuthenticated(rawSession);
12044
12102
  }
@@ -12137,11 +12195,18 @@ class Auth {
12137
12195
  }
12138
12196
 
12139
12197
  setRefreshTenantId(refreshTenantId ) {
12198
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
12140
12199
  setRefreshTenantId(refreshTenantId);
12141
12200
 
12142
12201
  getApiClient().setRefreshTenantId(refreshTenantId);
12143
12202
  }
12144
12203
 
12204
+ setRefreshDomainName(domainName ) {
12205
+ setRefreshDomainName(domainName);
12206
+
12207
+ getApiClient().setRefreshDomainName(domainName);
12208
+ }
12209
+
12145
12210
  forceRefreshToken() {
12146
12211
  getApiClient().forceRefreshToken();
12147
12212
  }
@@ -14459,6 +14524,7 @@ class Softphone {
14459
14524
  wrapUpDuration,
14460
14525
  enableAgent = true,
14461
14526
  tenantId,
14527
+ domainName,
14462
14528
  debug = false,
14463
14529
  } = {}) {
14464
14530
  this.url = url || 'https://softphone.wazo.io';
@@ -14483,8 +14549,12 @@ class Softphone {
14483
14549
  config.port = port;
14484
14550
  }
14485
14551
  if (tenantId) {
14552
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14486
14553
  config.tenantId = tenantId;
14487
14554
  }
14555
+ if (domainName) {
14556
+ config.domainName = domainName;
14557
+ }
14488
14558
  if (wrapUpDuration) {
14489
14559
  config.wrapUpDuration = wrapUpDuration;
14490
14560
  }
@@ -14805,6 +14875,7 @@ const Wazo = {
14805
14875
  CanceledCallError,
14806
14876
  SFUNotAvailableError,
14807
14877
  NoTenantIdError,
14878
+ NoDomainNameError,
14808
14879
  };
14809
14880
 
14810
14881
  if (window) {