@wazo/sdk 0.38.8 → 0.38.11

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 +31 -6
  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 +31 -6
  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 +31 -6
  11. package/esm/checker/checks/webrtc-transport.js +31 -6
  12. package/esm/checker/checks/webrtc.js +31 -6
  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 +4 -5
  17. package/esm/index.js +86 -17
  18. package/esm/service/CallApi.js +28 -2
  19. package/esm/service/getApiClient.js +34 -3
  20. package/esm/simple/Auth.js +87 -18
  21. package/esm/simple/Configuration.js +86 -17
  22. package/esm/simple/Directory.js +28 -2
  23. package/esm/simple/Phone.js +86 -17
  24. package/esm/simple/Softphone.js +5 -0
  25. package/esm/simple/index.js +86 -17
  26. package/esm/simple/room/LocalParticipant.js +86 -17
  27. package/esm/simple/room/Participant.js +86 -17
  28. package/esm/simple/room/RemoteParticipant.js +86 -17
  29. package/esm/simple/room/Room.js +86 -17
  30. package/esm/simple/room/SipRoom.js +86 -17
  31. package/esm/simple/room/Stream.js +86 -17
  32. package/esm/simple/room/__tests__/Participant.test.js +86 -17
  33. package/esm/simple/room/__tests__/RemoteParticipant.test.js +86 -17
  34. package/esm/simple/utils.js +86 -17
  35. package/esm/web-rtc-client.js +31 -6
  36. package/lib/__tests__/api-client.test.js +21 -0
  37. package/lib/__tests__/web-rtc-client.test.js +31 -6
  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 +31 -6
  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 +31 -6
  45. package/lib/checker/checks/webrtc-transport.js +31 -6
  46. package/lib/checker/checks/webrtc.js +31 -6
  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 +4 -5
  51. package/lib/index.js +86 -17
  52. package/lib/service/CallApi.js +28 -2
  53. package/lib/service/getApiClient.js +34 -2
  54. package/lib/simple/Auth.js +87 -17
  55. package/lib/simple/Configuration.js +86 -17
  56. package/lib/simple/Directory.js +28 -2
  57. package/lib/simple/Phone.js +86 -17
  58. package/lib/simple/Softphone.js +5 -0
  59. package/lib/simple/index.js +86 -17
  60. package/lib/simple/room/LocalParticipant.js +86 -17
  61. package/lib/simple/room/Participant.js +86 -17
  62. package/lib/simple/room/RemoteParticipant.js +86 -17
  63. package/lib/simple/room/Room.js +86 -17
  64. package/lib/simple/room/SipRoom.js +86 -17
  65. package/lib/simple/room/Stream.js +86 -17
  66. package/lib/simple/room/__tests__/Participant.test.js +86 -17
  67. package/lib/simple/room/__tests__/RemoteParticipant.test.js +86 -17
  68. package/lib/simple/utils.js +86 -17
  69. package/lib/web-rtc-client.js +31 -6
  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 +3 -5
  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 +10 -6
@@ -3175,6 +3175,7 @@ var authMethods = (client , baseUrl ) => ({
3175
3175
 
3176
3176
 
3177
3177
 
3178
+
3178
3179
  ) {
3179
3180
  const body = {
3180
3181
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -3195,9 +3196,14 @@ var authMethods = (client , baseUrl ) => ({
3195
3196
  }
3196
3197
 
3197
3198
  if (params.tenantId) {
3199
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
3198
3200
  body.tenant_id = params.tenantId;
3199
3201
  }
3200
3202
 
3203
+ if (params.domainName) {
3204
+ body.domain_name = params.domainName;
3205
+ }
3206
+
3201
3207
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
3202
3208
  },
3203
3209
 
@@ -3210,6 +3216,7 @@ var authMethods = (client , baseUrl ) => ({
3210
3216
  expiration ,
3211
3217
  isMobile = false,
3212
3218
  tenantId ,
3219
+ domainName ,
3213
3220
  ) => {
3214
3221
  const body = {
3215
3222
  backend: backend || DEFAULT_BACKEND_USER,
@@ -3219,9 +3226,14 @@ var authMethods = (client , baseUrl ) => ({
3219
3226
  };
3220
3227
 
3221
3228
  if (tenantId) {
3229
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
3222
3230
  body.tenant_id = tenantId;
3223
3231
  }
3224
3232
 
3233
+ if (domainName) {
3234
+ body.domain_name = domainName;
3235
+ }
3236
+
3225
3237
  const headers = {
3226
3238
  'Content-Type': 'application/json',
3227
3239
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5137,6 +5149,7 @@ class ApiClient {
5137
5149
 
5138
5150
 
5139
5151
 
5152
+
5140
5153
 
5141
5154
 
5142
5155
 
@@ -5178,6 +5191,7 @@ class ApiClient {
5178
5191
  refreshToken: this.refreshToken,
5179
5192
  refreshBackend: this.refreshBackend,
5180
5193
  refreshTenantId: this.refreshTenantId,
5194
+ refreshDomainName: this.refreshDomainName,
5181
5195
  refreshExpiration: this.refreshExpiration,
5182
5196
  isMobile: this.isMobile,
5183
5197
  });
@@ -5193,6 +5207,7 @@ class ApiClient {
5193
5207
  this.refreshExpiration,
5194
5208
  this.isMobile,
5195
5209
  this.refreshTenantId,
5210
+ this.refreshDomainName,
5196
5211
  );
5197
5212
 
5198
5213
  logger$1.info('token refreshed', { token: session.token });
@@ -5246,9 +5261,14 @@ class ApiClient {
5246
5261
  }
5247
5262
 
5248
5263
  setRefreshTenantId(tenantId ) {
5264
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5249
5265
  this.refreshTenantId = tenantId;
5250
5266
  }
5251
5267
 
5268
+ setRefreshDomainName(domainName ) {
5269
+ this.refreshDomainName = domainName;
5270
+ }
5271
+
5252
5272
  setIsMobile(isMobile ) {
5253
5273
  this.isMobile = isMobile;
5254
5274
  }
@@ -5273,6 +5293,7 @@ global.wazoClientId = global.wazoClientId || {};
5273
5293
  global.wazoClientToken = global.wazoClientToken || {};
5274
5294
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5275
5295
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5296
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
5276
5297
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5277
5298
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5278
5299
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -5282,6 +5303,7 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
5282
5303
 
5283
5304
  const fillClient = (apiClient ) => {
5284
5305
  const { server, token, clientId } = apiClient.client;
5306
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
5285
5307
 
5286
5308
  // try with null server when dealing with non-related server info
5287
5309
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -5290,8 +5312,12 @@ const fillClient = (apiClient ) => {
5290
5312
 
5291
5313
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5292
5314
 
5293
- apiClient.setRefreshTenantId(
5294
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5315
+ if (tenantId) {
5316
+ apiClient.setRefreshTenantId(tenantId);
5317
+ }
5318
+
5319
+ apiClient.setRefreshDomainName(
5320
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
5295
5321
  );
5296
5322
 
5297
5323
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -894,6 +894,7 @@ global.wazoClientId = global.wazoClientId || {};
894
894
  global.wazoClientToken = global.wazoClientToken || {};
895
895
  global.wazoRefreshToken = global.wazoRefreshToken || {};
896
896
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
897
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
897
898
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
898
899
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
899
900
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -1395,7 +1396,7 @@ class WebRTCPhone extends Emitter {
1395
1396
  const screenTrack = screenShareStream.getVideoTracks()[0];
1396
1397
  const sipSession = this.currentSipSession;
1397
1398
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
1398
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1399
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1399
1400
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
1400
1401
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
1401
1402
  const hadVideo = !!videoTrack;
@@ -1433,9 +1434,7 @@ class WebRTCPhone extends Emitter {
1433
1434
 
1434
1435
  try {
1435
1436
  if (this.currentScreenShare.stream) {
1436
- this.currentScreenShare.stream.getTracks()
1437
- .filter(track => track.kind === 'video')
1438
- .forEach(track => track.stop());
1437
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
1439
1438
  }
1440
1439
 
1441
1440
  if (restoreLocalStream) {
@@ -1479,7 +1478,7 @@ class WebRTCPhone extends Emitter {
1479
1478
  const screenTrack = screenStream.getVideoTracks()[0];
1480
1479
  const sipSessionId = this.getSipSessionId(sipSession);
1481
1480
  const pc = this.client.getPeerConnection(sipSessionId);
1482
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1481
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1483
1482
 
1484
1483
  logger.info('WebRTC phone - on screensharing', {
1485
1484
  hadVideo,
package/esm/index.js CHANGED
@@ -2230,6 +2230,7 @@ var authMethods = (client , baseUrl ) => ({
2230
2230
 
2231
2231
 
2232
2232
 
2233
+
2233
2234
  ) {
2234
2235
  const body = {
2235
2236
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2250,9 +2251,14 @@ var authMethods = (client , baseUrl ) => ({
2250
2251
  }
2251
2252
 
2252
2253
  if (params.tenantId) {
2254
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2253
2255
  body.tenant_id = params.tenantId;
2254
2256
  }
2255
2257
 
2258
+ if (params.domainName) {
2259
+ body.domain_name = params.domainName;
2260
+ }
2261
+
2256
2262
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2257
2263
  },
2258
2264
 
@@ -2265,6 +2271,7 @@ var authMethods = (client , baseUrl ) => ({
2265
2271
  expiration ,
2266
2272
  isMobile = false,
2267
2273
  tenantId ,
2274
+ domainName ,
2268
2275
  ) => {
2269
2276
  const body = {
2270
2277
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2274,9 +2281,14 @@ var authMethods = (client , baseUrl ) => ({
2274
2281
  };
2275
2282
 
2276
2283
  if (tenantId) {
2284
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2277
2285
  body.tenant_id = tenantId;
2278
2286
  }
2279
2287
 
2288
+ if (domainName) {
2289
+ body.domain_name = domainName;
2290
+ }
2291
+
2280
2292
  const headers = {
2281
2293
  'Content-Type': 'application/json',
2282
2294
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -4123,6 +4135,7 @@ global.wazoClientId = global.wazoClientId || {};
4123
4135
  global.wazoClientToken = global.wazoClientToken || {};
4124
4136
  global.wazoRefreshToken = global.wazoRefreshToken || {};
4125
4137
  global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
4138
+ global.wazoRefreshDomainName = global.wazoRefreshDomainName || {};
4126
4139
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
4127
4140
  global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
4128
4141
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
@@ -4147,9 +4160,14 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
4147
4160
  };
4148
4161
 
4149
4162
  const setRefreshTenantId = (refreshTenantId , forServer = null) => {
4163
+ console.warn('Use of `setRefreshTenantId` is deprecated, please use `setRefreshDomainName` instead');
4150
4164
  global.wazoRefreshTenantId[forServer] = refreshTenantId;
4151
4165
  };
4152
4166
 
4167
+ const setRefreshDomainName = (refreshDomainName , forServer = null) => {
4168
+ global.wazoRefreshDomainName[forServer] = refreshDomainName;
4169
+ };
4170
+
4153
4171
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
4154
4172
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
4155
4173
  };
@@ -4168,6 +4186,7 @@ const setFetchOptions = (fetchOptions , forServer = null) => {
4168
4186
 
4169
4187
  const fillClient = (apiClient ) => {
4170
4188
  const { server, token, clientId } = apiClient.client;
4189
+ const tenantId = global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId;
4171
4190
 
4172
4191
  // try with null server when dealing with non-related server info
4173
4192
  apiClient.setToken(global.wazoClientToken[server] || global.wazoClientToken[null] || token);
@@ -4176,8 +4195,12 @@ const fillClient = (apiClient ) => {
4176
4195
 
4177
4196
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
4178
4197
 
4179
- apiClient.setRefreshTenantId(
4180
- global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
4198
+ if (tenantId) {
4199
+ apiClient.setRefreshTenantId(tenantId);
4200
+ }
4201
+
4202
+ apiClient.setRefreshDomainName(
4203
+ global.wazoRefreshDomainName[server] || global.wazoRefreshDomainName[null] || apiClient.refreshDomainName,
4181
4204
  );
4182
4205
 
4183
4206
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
@@ -5675,6 +5698,7 @@ class ApiClient {
5675
5698
 
5676
5699
 
5677
5700
 
5701
+
5678
5702
 
5679
5703
 
5680
5704
 
@@ -5716,6 +5740,7 @@ class ApiClient {
5716
5740
  refreshToken: this.refreshToken,
5717
5741
  refreshBackend: this.refreshBackend,
5718
5742
  refreshTenantId: this.refreshTenantId,
5743
+ refreshDomainName: this.refreshDomainName,
5719
5744
  refreshExpiration: this.refreshExpiration,
5720
5745
  isMobile: this.isMobile,
5721
5746
  });
@@ -5731,6 +5756,7 @@ class ApiClient {
5731
5756
  this.refreshExpiration,
5732
5757
  this.isMobile,
5733
5758
  this.refreshTenantId,
5759
+ this.refreshDomainName,
5734
5760
  );
5735
5761
 
5736
5762
  logger$a.info('token refreshed', { token: session.token });
@@ -5784,9 +5810,14 @@ class ApiClient {
5784
5810
  }
5785
5811
 
5786
5812
  setRefreshTenantId(tenantId ) {
5813
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead');
5787
5814
  this.refreshTenantId = tenantId;
5788
5815
  }
5789
5816
 
5817
+ setRefreshDomainName(domainName ) {
5818
+ this.refreshDomainName = domainName;
5819
+ }
5820
+
5790
5821
  setIsMobile(isMobile ) {
5791
5822
  this.isMobile = isMobile;
5792
5823
  }
@@ -7282,9 +7313,11 @@ class WebRTCClient extends Emitter {
7282
7313
  const videoTracks = localStream.getVideoTracks();
7283
7314
 
7284
7315
  // Remove video senders
7285
- pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7286
- videoSender.replaceTrack(null);
7287
- });
7316
+ if (pc.getSenders) {
7317
+ pc.getSenders().filter(sender => sender.track && sender.track.kind === 'video').forEach(videoSender => {
7318
+ videoSender.replaceTrack(null);
7319
+ });
7320
+ }
7288
7321
 
7289
7322
  videoTracks.forEach(videoTrack => {
7290
7323
  videoTrack.enabled = false;
@@ -7517,7 +7550,8 @@ class WebRTCClient extends Emitter {
7517
7550
  const constraints = { audio: { deviceId: { exact: deviceId } } };
7518
7551
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
7519
7552
  const audioTrack = stream.getAudioTracks()[0];
7520
- const sender = pc && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7553
+ const sender = pc && pc.getSenders
7554
+ && pc.getSenders().find(s => audioTrack && s && s.track && s.track.kind === audioTrack.kind);
7521
7555
 
7522
7556
  if (sender) {
7523
7557
  if (sender.track) {
@@ -7580,10 +7614,11 @@ class WebRTCClient extends Emitter {
7580
7614
  // $FlowFixMe
7581
7615
  return navigator.mediaDevices.getUserMedia(constraints).then(async stream => {
7582
7616
  const videoTrack = stream.getVideoTracks()[0];
7583
- let sender = pc && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7617
+ let sender = pc && pc.getSenders
7618
+ && pc.getSenders().find(s => videoTrack && s && s.track && s.track.kind === videoTrack.kind);
7584
7619
  let wasTrackEnabled = false;
7585
7620
  if (!sender) {
7586
- sender = pc && pc.getSenders().find(s => !s.track);
7621
+ sender = pc && pc.getSenders && pc.getSenders().find(s => !s.track);
7587
7622
  }
7588
7623
 
7589
7624
  if (sender) {
@@ -10021,7 +10056,7 @@ class WebRTCPhone extends Emitter {
10021
10056
  const screenTrack = screenShareStream.getVideoTracks()[0];
10022
10057
  const sipSession = this.currentSipSession;
10023
10058
  const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
10024
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10059
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10025
10060
  const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
10026
10061
  const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
10027
10062
  const hadVideo = !!videoTrack;
@@ -10059,9 +10094,7 @@ class WebRTCPhone extends Emitter {
10059
10094
 
10060
10095
  try {
10061
10096
  if (this.currentScreenShare.stream) {
10062
- this.currentScreenShare.stream.getTracks()
10063
- .filter(track => track.kind === 'video')
10064
- .forEach(track => track.stop());
10097
+ this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
10065
10098
  }
10066
10099
 
10067
10100
  if (restoreLocalStream) {
@@ -10105,7 +10138,7 @@ class WebRTCPhone extends Emitter {
10105
10138
  const screenTrack = screenStream.getVideoTracks()[0];
10106
10139
  const sipSessionId = this.getSipSessionId(sipSession);
10107
10140
  const pc = this.client.getPeerConnection(sipSessionId);
10108
- const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10141
+ const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
10109
10142
 
10110
10143
  logger$7.info('WebRTC phone - on screensharing', {
10111
10144
  hadVideo,
@@ -11946,6 +11979,7 @@ const getCallableNumber = (number , country ) => {
11946
11979
  class InvalidSubscription extends Error {}
11947
11980
  class InvalidAuthorization extends Error {}
11948
11981
  class NoTenantIdError extends Error {}
11982
+ class NoDomainNameError extends Error {}
11949
11983
 
11950
11984
  const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11951
11985
 
@@ -12009,9 +12043,24 @@ class Auth {
12009
12043
  setFetchOptions(options);
12010
12044
  }
12011
12045
 
12012
- async logIn(username , password , backend , tenantId ) {
12013
- if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
12014
- throw new NoTenantIdError('No tenant id');
12046
+ async logIn(username , password , backend , extra ) {
12047
+ let tenantId = null;
12048
+ let domainName = null;
12049
+ if (typeof extra === 'string') {
12050
+ tenantId = extra;
12051
+ }
12052
+ if (extra && typeof extra === 'object') {
12053
+ domainName = extra.domainName;
12054
+ }
12055
+
12056
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId && !domainName) {
12057
+ if (!tenantId) {
12058
+ throw new NoTenantIdError('No tenant id');
12059
+ }
12060
+
12061
+ if (!domainName) {
12062
+ throw new NoDomainNameError('No domain name');
12063
+ }
12015
12064
  }
12016
12065
 
12017
12066
  this.authenticated = false;
@@ -12021,6 +12070,7 @@ class Auth {
12021
12070
  password,
12022
12071
  backend,
12023
12072
  tenantId,
12073
+ domainName,
12024
12074
  expiration: this.expiration,
12025
12075
  mobile: this.mobile,
12026
12076
  });
@@ -12029,7 +12079,13 @@ class Auth {
12029
12079
  getApiClient().setRefreshBackend(backend);
12030
12080
  }
12031
12081
 
12032
- getApiClient().setRefreshTenantId(tenantId);
12082
+ if (tenantId) {
12083
+ getApiClient().setRefreshTenantId(tenantId);
12084
+ }
12085
+
12086
+ if (domainName) {
12087
+ getApiClient().setRefreshDomainName(domainName);
12088
+ }
12033
12089
 
12034
12090
  return this._onAuthenticated(rawSession);
12035
12091
  }
@@ -12128,11 +12184,18 @@ class Auth {
12128
12184
  }
12129
12185
 
12130
12186
  setRefreshTenantId(refreshTenantId ) {
12187
+ console.warn('Use of `setRefreshTenantId` is deprecated, use `setRefreshDomainName` instead.');
12131
12188
  setRefreshTenantId(refreshTenantId);
12132
12189
 
12133
12190
  getApiClient().setRefreshTenantId(refreshTenantId);
12134
12191
  }
12135
12192
 
12193
+ setRefreshDomainName(domainName ) {
12194
+ setRefreshDomainName(domainName);
12195
+
12196
+ getApiClient().setRefreshDomainName(domainName);
12197
+ }
12198
+
12136
12199
  forceRefreshToken() {
12137
12200
  getApiClient().forceRefreshToken();
12138
12201
  }
@@ -14450,6 +14513,7 @@ class Softphone {
14450
14513
  wrapUpDuration,
14451
14514
  enableAgent = true,
14452
14515
  tenantId,
14516
+ domainName,
14453
14517
  debug = false,
14454
14518
  } = {}) {
14455
14519
  this.url = url || 'https://softphone.wazo.io';
@@ -14474,8 +14538,12 @@ class Softphone {
14474
14538
  config.port = port;
14475
14539
  }
14476
14540
  if (tenantId) {
14541
+ console.warn('Use of `tenantId` is deprecated when calling `Softphone.init()`, use `domainName` instead');
14477
14542
  config.tenantId = tenantId;
14478
14543
  }
14544
+ if (domainName) {
14545
+ config.domainName = domainName;
14546
+ }
14479
14547
  if (wrapUpDuration) {
14480
14548
  config.wrapUpDuration = wrapUpDuration;
14481
14549
  }
@@ -14796,6 +14864,7 @@ const Wazo = {
14796
14864
  CanceledCallError,
14797
14865
  SFUNotAvailableError,
14798
14866
  NoTenantIdError,
14867
+ NoDomainNameError,
14799
14868
  };
14800
14869
 
14801
14870
  if (window) {
@@ -2755,6 +2755,7 @@ var authMethods = (client , baseUrl ) => ({
2755
2755
 
2756
2756
 
2757
2757
 
2758
+
2758
2759
  ) {
2759
2760
  const body = {
2760
2761
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2775,9 +2776,14 @@ var authMethods = (client , baseUrl ) => ({
2775
2776
  }
2776
2777
 
2777
2778
  if (params.tenantId) {
2779
+ console.warn('Use of `tenantId` is deprecated when calling logIn() method, use `domainName` instead.');
2778
2780
  body.tenant_id = params.tenantId;
2779
2781
  }
2780
2782
 
2783
+ if (params.domainName) {
2784
+ body.domain_name = params.domainName;
2785
+ }
2786
+
2781
2787
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2782
2788
  },
2783
2789
 
@@ -2790,6 +2796,7 @@ var authMethods = (client , baseUrl ) => ({
2790
2796
  expiration ,
2791
2797
  isMobile = false,
2792
2798
  tenantId ,
2799
+ domainName ,
2793
2800
  ) => {
2794
2801
  const body = {
2795
2802
  backend: backend || DEFAULT_BACKEND_USER,
@@ -2799,9 +2806,14 @@ var authMethods = (client , baseUrl ) => ({
2799
2806
  };
2800
2807
 
2801
2808
  if (tenantId) {
2809
+ console.warn('Use of `tenantId` is deprecated when calling refreshToken() method, use `domainName` instead.');
2802
2810
  body.tenant_id = tenantId;
2803
2811
  }
2804
2812
 
2813
+ if (domainName) {
2814
+ body.domain_name = domainName;
2815
+ }
2816
+
2805
2817
  const headers = {
2806
2818
  'Content-Type': 'application/json',
2807
2819
  ...(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);