@wazo/sdk 0.38.9 → 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 (76) 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 +21 -0
  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 +21 -0
  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 +21 -0
  11. package/esm/checker/checks/webrtc-transport.js +21 -0
  12. package/esm/checker/checks/webrtc.js +21 -0
  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 +1 -0
  17. package/esm/index.js +73 -6
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +74 -7
  21. package/esm/simple/Configuration.js +73 -6
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +73 -6
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +73 -6
  26. package/esm/simple/room/LocalParticipant.js +73 -6
  27. package/esm/simple/room/Participant.js +73 -6
  28. package/esm/simple/room/RemoteParticipant.js +73 -6
  29. package/esm/simple/room/Room.js +73 -6
  30. package/esm/simple/room/SipRoom.js +73 -6
  31. package/esm/simple/room/Stream.js +73 -6
  32. package/esm/simple/room/__tests__/Participant.test.js +73 -6
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +73 -6
  34. package/esm/simple/utils.js +73 -6
  35. package/esm/web-rtc-client.js +21 -0
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +21 -0
  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 +21 -0
  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 +21 -0
  45. package/lib/checker/checks/webrtc-transport.js +21 -0
  46. package/lib/checker/checks/webrtc.js +21 -0
  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 +1 -0
  51. package/lib/index.js +73 -6
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +74 -6
  55. package/lib/simple/Configuration.js +73 -6
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +73 -6
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +73 -6
  60. package/lib/simple/room/LocalParticipant.js +73 -6
  61. package/lib/simple/room/Participant.js +73 -6
  62. package/lib/simple/room/RemoteParticipant.js +73 -6
  63. package/lib/simple/room/Room.js +73 -6
  64. package/lib/simple/room/SipRoom.js +73 -6
  65. package/lib/simple/room/Stream.js +73 -6
  66. package/lib/simple/room/__tests__/Participant.test.js +73 -6
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +73 -6
  68. package/lib/simple/utils.js +73 -6
  69. package/lib/web-rtc-client.js +21 -0
  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/service/getApiClient.js +13 -2
  74. package/src/simple/Auth.js +35 -4
  75. package/src/simple/Softphone.js +5 -0
  76. package/src/simple/index.js +2 -1
@@ -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' } : {}),
@@ -5573,6 +5585,7 @@ class ApiClient {
5573
5585
 
5574
5586
 
5575
5587
 
5588
+
5576
5589
 
5577
5590
 
5578
5591
 
@@ -5614,6 +5627,7 @@ class ApiClient {
5614
5627
  refreshToken: this.refreshToken,
5615
5628
  refreshBackend: this.refreshBackend,
5616
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5617
5631
  refreshExpiration: this.refreshExpiration,
5618
5632
  isMobile: this.isMobile,
5619
5633
  });
@@ -5629,6 +5643,7 @@ class ApiClient {
5629
5643
  this.refreshExpiration,
5630
5644
  this.isMobile,
5631
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5632
5647
  );
5633
5648
 
5634
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5682,9 +5697,14 @@ class ApiClient {
5682
5697
  }
5683
5698
 
5684
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5685
5701
  this.refreshTenantId = tenantId;
5686
5702
  }
5687
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5688
5708
  setIsMobile(isMobile ) {
5689
5709
  this.isMobile = isMobile;
5690
5710
  }
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5709
5729
  global.wazoClientToken = global.wazoClientToken || {};
5710
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5711
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5712
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5713
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5714
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5733
5754
  };
5734
5755
 
5735
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5736
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5737
5759
  };
5738
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5739
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5740
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5741
5767
  };
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5754
5780
 
5755
5781
  const fillClient = (apiClient ) => {
5756
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5757
5784
 
5758
5785
  // try with null server when dealing with non-related server info
5759
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
5762
5789
 
5763
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5764
5791
 
5765
- apiClient.setRefreshTenantId(
5766
- 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,
5767
5798
  );
5768
5799
 
5769
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -14009,6 +14040,7 @@ class Softphone {
14009
14040
  wrapUpDuration,
14010
14041
  enableAgent = true,
14011
14042
  tenantId,
14043
+ domainName,
14012
14044
  debug = false,
14013
14045
  } = {}) {
14014
14046
  this.url = url || 'https://softphone.wazo.io';
@@ -14033,8 +14065,12 @@ class Softphone {
14033
14065
  config.port = port;
14034
14066
  }
14035
14067
  if (tenantId) {
14068
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14036
14069
  config.tenantId = tenantId;
14037
14070
  }
14071
+ if (domainName) {
14072
+ config.domainName = domainName;
14073
+ }
14038
14074
  if (wrapUpDuration) {
14039
14075
  config.wrapUpDuration = wrapUpDuration;
14040
14076
  }
@@ -14355,6 +14391,7 @@ const Wazo = {
14355
14391
  CanceledCallError,
14356
14392
  SFUNotAvailableError,
14357
14393
  NoTenantIdError,
14394
+ NoDomainNameError,
14358
14395
  };
14359
14396
 
14360
14397
  if (window) {
@@ -14369,6 +14406,7 @@ if (global) {
14369
14406
  class InvalidSubscription extends Error {}
14370
14407
  class InvalidAuthorization extends Error {}
14371
14408
  class NoTenantIdError extends Error {}
14409
+ class NoDomainNameError extends Error {}
14372
14410
 
14373
14411
  const logger = IssueReporter$1.loggerFor('simple-auth');
14374
14412
 
@@ -14432,9 +14470,24 @@ class Auth {
14432
14470
  setFetchOptions(options);
14433
14471
  }
14434
14472
 
14435
- async logIn(username , password , backend , tenantId ) {
14436
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14437
- throw new NoTenantIdError('No tenant id');
14473
+ async logIn(username , password , backend , extra ) {
14474
+ let tenantId = null;
14475
+ let domainName = null;
14476
+ if (typeof extra === 'string') {
14477
+ tenantId = extra;
14478
+ }
14479
+ if (extra && typeof extra === 'object') {
14480
+ domainName = extra.domainName;
14481
+ }
14482
+
14483
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14484
+ if (!tenantId) {
14485
+ throw new NoTenantIdError('No tenant id');
14486
+ }
14487
+
14488
+ if (!domainName) {
14489
+ throw new NoDomainNameError('No domain name');
14490
+ }
14438
14491
  }
14439
14492
 
14440
14493
  this.authenticated = false;
@@ -14444,6 +14497,7 @@ class Auth {
14444
14497
  password,
14445
14498
  backend,
14446
14499
  tenantId,
14500
+ domainName,
14447
14501
  expiration: this.expiration,
14448
14502
  mobile: this.mobile,
14449
14503
  });
@@ -14452,7 +14506,13 @@ class Auth {
14452
14506
  getApiClient().setRefreshBackend(backend);
14453
14507
  }
14454
14508
 
14455
- getApiClient().setRefreshTenantId(tenantId);
14509
+ if (tenantId) {
14510
+ getApiClient().setRefreshTenantId(tenantId);
14511
+ }
14512
+
14513
+ if (domainName) {
14514
+ getApiClient().setRefreshDomainName(domainName);
14515
+ }
14456
14516
 
14457
14517
  return this._onAuthenticated(rawSession);
14458
14518
  }
@@ -14551,11 +14611,18 @@ class Auth {
14551
14611
  }
14552
14612
 
14553
14613
  setRefreshTenantId(refreshTenantId ) {
14614
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14554
14615
  setRefreshTenantId(refreshTenantId);
14555
14616
 
14556
14617
  getApiClient().setRefreshTenantId(refreshTenantId);
14557
14618
  }
14558
14619
 
14620
+ setRefreshDomainName(domainName ) {
14621
+ setRefreshDomainName(domainName);
14622
+
14623
+ getApiClient().setRefreshDomainName(domainName);
14624
+ }
14625
+
14559
14626
  forceRefreshToken() {
14560
14627
  getApiClient().forceRefreshToken();
14561
14628
  }
@@ -14666,4 +14733,4 @@ if (!global.wazoAuthInstance) {
14666
14733
  var Auth$1 = global.wazoAuthInstance;
14667
14734
 
14668
14735
  export default Auth$1;
14669
- export { InvalidAuthorization, InvalidSubscription, NoTenantIdError };
14736
+ export { InvalidAuthorization, InvalidSubscription, NoDomainNameError, NoTenantIdError };
@@ -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' } : {}),
@@ -5573,6 +5585,7 @@ class ApiClient {
5573
5585
 
5574
5586
 
5575
5587
 
5588
+
5576
5589
 
5577
5590
 
5578
5591
 
@@ -5614,6 +5627,7 @@ class ApiClient {
5614
5627
  refreshToken: this.refreshToken,
5615
5628
  refreshBackend: this.refreshBackend,
5616
5629
  refreshTenantId: this.refreshTenantId,
5630
+ refreshDomainName: this.refreshDomainName,
5617
5631
  refreshExpiration: this.refreshExpiration,
5618
5632
  isMobile: this.isMobile,
5619
5633
  });
@@ -5629,6 +5643,7 @@ class ApiClient {
5629
5643
  this.refreshExpiration,
5630
5644
  this.isMobile,
5631
5645
  this.refreshTenantId,
5646
+ this.refreshDomainName,
5632
5647
  );
5633
5648
 
5634
5649
  logger$a.info('token refreshed', { token: session.token });
@@ -5682,9 +5697,14 @@ class ApiClient {
5682
5697
  }
5683
5698
 
5684
5699
  setRefreshTenantId(tenantId ) {
5700
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5685
5701
  this.refreshTenantId = tenantId;
5686
5702
  }
5687
5703
 
5704
+ setRefreshDomainName(domainName ) {
5705
+ this.refreshDomainName = domainName;
5706
+ }
5707
+
5688
5708
  setIsMobile(isMobile ) {
5689
5709
  this.isMobile = isMobile;
5690
5710
  }
@@ -5709,6 +5729,7 @@ global.wazoClientId = global.wazoClientId || {};
5709
5729
  global.wazoClientToken = global.wazoClientToken || {};
5710
5730
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5711
5731
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5732
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5712
5733
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5713
5734
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5714
5735
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5733,9 +5754,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5733
5754
  };
5734
5755
 
5735
5756
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5757
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
5736
5758
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
5737
5759
  };
5738
5760
 
5761
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
5762
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
5763
+ };
5764
+
5739
5765
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5740
5766
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5741
5767
  };
@@ -5754,6 +5780,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
5754
5780
 
5755
5781
  const fillClient = (apiClient ) => {
5756
5782
  const { server, token, clientId } = apiClient.client;
5783
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5757
5784
 
5758
5785
  // try with null server when dealing with non-related server info
5759
5786
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5762,8 +5789,12 @@ const fillClient = (apiClient ) => {
5762
5789
 
5763
5790
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5764
5791
 
5765
- apiClient.setRefreshTenantId(
5766
- 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,
5767
5798
  );
5768
5799
 
5769
5800
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -13992,6 +14023,7 @@ class Softphone {
13992
14023
  wrapUpDuration,
13993
14024
  enableAgent = true,
13994
14025
  tenantId,
14026
+ domainName,
13995
14027
  debug = false,
13996
14028
  } = {}) {
13997
14029
  this.url = url || 'https://softphone.wazo.io';
@@ -14016,8 +14048,12 @@ class Softphone {
14016
14048
  config.port = port;
14017
14049
  }
14018
14050
  if (tenantId) {
14051
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14019
14052
  config.tenantId = tenantId;
14020
14053
  }
14054
+ if (domainName) {
14055
+ config.domainName = domainName;
14056
+ }
14021
14057
  if (wrapUpDuration) {
14022
14058
  config.wrapUpDuration = wrapUpDuration;
14023
14059
  }
@@ -14338,6 +14374,7 @@ const Wazo = {
14338
14374
  CanceledCallError,
14339
14375
  SFUNotAvailableError,
14340
14376
  NoTenantIdError,
14377
+ NoDomainNameError,
14341
14378
  };
14342
14379
 
14343
14380
  if (window) {
@@ -14352,6 +14389,7 @@ if (global) {
14352
14389
  class InvalidSubscription extends Error {}
14353
14390
  class InvalidAuthorization extends Error {}
14354
14391
  class NoTenantIdError extends Error {}
14392
+ class NoDomainNameError extends Error {}
14355
14393
 
14356
14394
  const logger = IssueReporter$1.loggerFor('simple-auth');
14357
14395
 
@@ -14415,9 +14453,24 @@ class Auth {
14415
14453
  setFetchOptions(options);
14416
14454
  }
14417
14455
 
14418
- async logIn(username , password , backend , tenantId ) {
14419
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
14420
- throw new NoTenantIdError('No tenant id');
14456
+ async logIn(username , password , backend , extra ) {
14457
+ let tenantId = null;
14458
+ let domainName = null;
14459
+ if (typeof extra === 'string') {
14460
+ tenantId = extra;
14461
+ }
14462
+ if (extra && typeof extra === 'object') {
14463
+ domainName = extra.domainName;
14464
+ }
14465
+
14466
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
14467
+ if (!tenantId) {
14468
+ throw new NoTenantIdError('No tenant id');
14469
+ }
14470
+
14471
+ if (!domainName) {
14472
+ throw new NoDomainNameError('No domain name');
14473
+ }
14421
14474
  }
14422
14475
 
14423
14476
  this.authenticated = false;
@@ -14427,6 +14480,7 @@ class Auth {
14427
14480
  password,
14428
14481
  backend,
14429
14482
  tenantId,
14483
+ domainName,
14430
14484
  expiration: this.expiration,
14431
14485
  mobile: this.mobile,
14432
14486
  });
@@ -14435,7 +14489,13 @@ class Auth {
14435
14489
  getApiClient().setRefreshBackend(backend);
14436
14490
  }
14437
14491
 
14438
- getApiClient().setRefreshTenantId(tenantId);
14492
+ if (tenantId) {
14493
+ getApiClient().setRefreshTenantId(tenantId);
14494
+ }
14495
+
14496
+ if (domainName) {
14497
+ getApiClient().setRefreshDomainName(domainName);
14498
+ }
14439
14499
 
14440
14500
  return this._onAuthenticated(rawSession);
14441
14501
  }
@@ -14534,11 +14594,18 @@ class Auth {
14534
14594
  }
14535
14595
 
14536
14596
  setRefreshTenantId(refreshTenantId ) {
14597
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
14537
14598
  setRefreshTenantId(refreshTenantId);
14538
14599
 
14539
14600
  getApiClient().setRefreshTenantId(refreshTenantId);
14540
14601
  }
14541
14602
 
14603
+ setRefreshDomainName(domainName ) {
14604
+ setRefreshDomainName(domainName);
14605
+
14606
+ getApiClient().setRefreshDomainName(domainName);
14607
+ }
14608
+
14542
14609
  forceRefreshToken() {
14543
14610
  getApiClient().forceRefreshToken();
14544
14611
  }
@@ -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' } : {}),
@@ -4724,6 +4736,7 @@ class ApiClient {
4724
4736
 
4725
4737
 
4726
4738
 
4739
+
4727
4740
 
4728
4741
 
4729
4742
 
@@ -4765,6 +4778,7 @@ class ApiClient {
4765
4778
  refreshToken: this.refreshToken,
4766
4779
  refreshBackend: this.refreshBackend,
4767
4780
  refreshTenantId: this.refreshTenantId,
4781
+ refreshDomainName: this.refreshDomainName,
4768
4782
  refreshExpiration: this.refreshExpiration,
4769
4783
  isMobile: this.isMobile,
4770
4784
  });
@@ -4780,6 +4794,7 @@ class ApiClient {
4780
4794
  this.refreshExpiration,
4781
4795
  this.isMobile,
4782
4796
  this.refreshTenantId,
4797
+ this.refreshDomainName,
4783
4798
  );
4784
4799
 
4785
4800
  logger.info('token refreshed', { token: session.token });
@@ -4833,9 +4848,14 @@ class ApiClient {
4833
4848
  }
4834
4849
 
4835
4850
  setRefreshTenantId(tenantId ) {
4851
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
4836
4852
  this.refreshTenantId = tenantId;
4837
4853
  }
4838
4854
 
4855
+ setRefreshDomainName(domainName ) {
4856
+ this.refreshDomainName = domainName;
4857
+ }
4858
+
4839
4859
  setIsMobile(isMobile ) {
4840
4860
  this.isMobile = isMobile;
4841
4861
  }
@@ -4860,6 +4880,7 @@ global.wazoClientId = global.wazoClientId || {};
4860
4880
  global.wazoClientToken = global.wazoClientToken || {};
4861
4881
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4862
4882
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4883
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4863
4884
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4864
4885
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4865
4886
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4869,6 +4890,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
4869
4890
 
4870
4891
  const fillClient = (apiClient ) => {
4871
4892
  const { server, token, clientId } = apiClient.client;
4893
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4872
4894
 
4873
4895
  // try with null server when dealing with non-related server info
4874
4896
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4877,8 +4899,12 @@ const fillClient = (apiClient ) => {
4877
4899
 
4878
4900
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4879
4901
 
4880
- apiClient.setRefreshTenantId(
4881
- 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,
4882
4908
  );
4883
4909
 
4884
4910
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);