@wazo/sdk 0.37.40 → 0.37.43

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 (109) hide show
  1. package/dist/wazo-sdk.js +3 -3
  2. package/esm/__tests__/api-client.test.js +45 -22
  3. package/esm/__tests__/web-rtc-client.test.js +49 -24
  4. package/esm/api/agentd.js +12 -7
  5. package/esm/api/amid.js +12 -7
  6. package/esm/api/application.js +12 -7
  7. package/esm/api/auth.js +16 -8
  8. package/esm/api/call-logd.js +12 -7
  9. package/esm/api/calld.js +12 -7
  10. package/esm/api/chatd.js +12 -7
  11. package/esm/api/confd.js +12 -7
  12. package/esm/api/ctid-ng.js +14 -7
  13. package/esm/api/dird.js +12 -7
  14. package/esm/api/webhookd.js +12 -7
  15. package/esm/api-client.js +45 -22
  16. package/esm/checker/Checker.js +50 -25
  17. package/esm/checker/checks/aor.js +45 -22
  18. package/esm/checker/checks/api.js +45 -22
  19. package/esm/checker/checks/index.js +50 -25
  20. package/esm/checker/checks/wazo-websocket.js +13 -8
  21. package/esm/checker/checks/webrtc-transport.js +49 -24
  22. package/esm/checker/checks/webrtc.js +49 -24
  23. package/esm/domain/AdHocAPIConference.js +54 -23
  24. package/esm/domain/Features.js +54 -23
  25. package/esm/domain/Phone/CTIPhone.js +54 -23
  26. package/esm/domain/Phone/WebRTCPhone.js +18 -11
  27. package/esm/index.js +89 -29
  28. package/esm/lib/WazoSessionDescriptionHandler.js +12 -7
  29. package/esm/service/CallApi.js +54 -23
  30. package/esm/service/IssueReporter.js +12 -7
  31. package/esm/service/__tests__/IssueReporter.test.js +18 -7
  32. package/esm/service/getApiClient.js +63 -24
  33. package/esm/simple/Auth.js +89 -29
  34. package/esm/simple/Configuration.js +89 -29
  35. package/esm/simple/Directory.js +54 -23
  36. package/esm/simple/Phone.js +89 -29
  37. package/esm/simple/Websocket.js +13 -8
  38. package/esm/simple/index.js +89 -29
  39. package/esm/simple/room/LocalParticipant.js +89 -29
  40. package/esm/simple/room/Participant.js +89 -29
  41. package/esm/simple/room/RemoteParticipant.js +89 -29
  42. package/esm/simple/room/Room.js +89 -29
  43. package/esm/simple/room/SipRoom.js +89 -29
  44. package/esm/simple/room/Stream.js +89 -29
  45. package/esm/simple/room/__tests__/RemoteParticipant.test.js +89 -29
  46. package/esm/simple/utils.js +89 -29
  47. package/esm/utils/__tests__/api-requester.test.js +12 -7
  48. package/esm/utils/api-requester.js +12 -7
  49. package/esm/web-rtc-client.js +49 -24
  50. package/esm/websocket-client.js +13 -8
  51. package/lib/__tests__/api-client.test.js +45 -22
  52. package/lib/__tests__/web-rtc-client.test.js +49 -24
  53. package/lib/api/agentd.js +12 -7
  54. package/lib/api/amid.js +12 -7
  55. package/lib/api/application.js +12 -7
  56. package/lib/api/auth.js +16 -8
  57. package/lib/api/call-logd.js +12 -7
  58. package/lib/api/calld.js +12 -7
  59. package/lib/api/chatd.js +12 -7
  60. package/lib/api/confd.js +12 -7
  61. package/lib/api/ctid-ng.js +14 -7
  62. package/lib/api/dird.js +12 -7
  63. package/lib/api/webhookd.js +12 -7
  64. package/lib/api-client.js +45 -22
  65. package/lib/checker/Checker.js +50 -25
  66. package/lib/checker/checks/aor.js +45 -22
  67. package/lib/checker/checks/api.js +45 -22
  68. package/lib/checker/checks/index.js +50 -25
  69. package/lib/checker/checks/wazo-websocket.js +13 -8
  70. package/lib/checker/checks/webrtc-transport.js +49 -24
  71. package/lib/checker/checks/webrtc.js +49 -24
  72. package/lib/domain/AdHocAPIConference.js +54 -23
  73. package/lib/domain/Features.js +54 -23
  74. package/lib/domain/Phone/CTIPhone.js +54 -23
  75. package/lib/domain/Phone/WebRTCPhone.js +18 -11
  76. package/lib/index.js +89 -29
  77. package/lib/lib/WazoSessionDescriptionHandler.js +12 -7
  78. package/lib/service/CallApi.js +54 -23
  79. package/lib/service/IssueReporter.js +12 -7
  80. package/lib/service/__tests__/IssueReporter.test.js +18 -7
  81. package/lib/service/getApiClient.js +64 -23
  82. package/lib/simple/Auth.js +89 -29
  83. package/lib/simple/Configuration.js +89 -29
  84. package/lib/simple/Directory.js +54 -23
  85. package/lib/simple/Phone.js +89 -29
  86. package/lib/simple/Websocket.js +13 -8
  87. package/lib/simple/index.js +89 -29
  88. package/lib/simple/room/LocalParticipant.js +89 -29
  89. package/lib/simple/room/Participant.js +89 -29
  90. package/lib/simple/room/RemoteParticipant.js +89 -29
  91. package/lib/simple/room/Room.js +89 -29
  92. package/lib/simple/room/SipRoom.js +89 -29
  93. package/lib/simple/room/Stream.js +89 -29
  94. package/lib/simple/room/__tests__/RemoteParticipant.test.js +89 -29
  95. package/lib/simple/utils.js +89 -29
  96. package/lib/utils/__tests__/api-requester.test.js +12 -7
  97. package/lib/utils/api-requester.js +12 -7
  98. package/lib/web-rtc-client.js +49 -24
  99. package/lib/websocket-client.js +13 -8
  100. package/package.json +1 -1
  101. package/src/api/auth.js +4 -1
  102. package/src/api-client.js +26 -13
  103. package/src/domain/Phone/WebRTCPhone.js +4 -4
  104. package/src/service/IssueReporter.js +12 -7
  105. package/src/service/__tests__/IssueReporter.test.js +6 -0
  106. package/src/service/getApiClient.js +19 -1
  107. package/src/simple/Auth.js +21 -0
  108. package/src/web-rtc-client.js +4 -2
  109. package/src/websocket-client.js +1 -1
@@ -427,13 +427,9 @@ class IssueReporter {
427
427
 
428
428
  setTimeout(() => {
429
429
  if (isArray) {
430
- payload = payload.map(message => {
431
- message._retry = retry + 1;
432
- return message;
433
- });
434
- } else {
435
- // $FlowFixMe
436
- payload._retry = retry + 1;
430
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
431
+ } else if (payload && typeof payload === 'object') {
432
+ payload = this._writeRetryCount(payload, retry + 1);
437
433
  }
438
434
 
439
435
  this._sendDebugToGrafana(payload, retry + 1);
@@ -441,6 +437,15 @@ class IssueReporter {
441
437
  });
442
438
  }
443
439
 
440
+ _writeRetryCount(message , count ) {
441
+ if (message && typeof message === 'object') {
442
+ // $FlowFixMe
443
+ message._retry = count;
444
+ }
445
+
446
+ return message;
447
+ }
448
+
444
449
  _isLevelAbove(level1 , level2 ) {
445
450
  const index1 = LOG_LEVELS.indexOf(level1);
446
451
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -2277,9 +2282,12 @@ var authMethods = (client , baseUrl ) => ({
2277
2282
  expiration: expiration || DETAULT_EXPIRATION,
2278
2283
  refresh_token: refreshToken,
2279
2284
  client_id: client.clientId,
2280
- tenant_id: tenantId,
2281
2285
  };
2282
2286
 
2287
+ if (tenantId) {
2288
+ body.tenant_id = tenantId;
2289
+ }
2290
+
2283
2291
  const headers = {
2284
2292
  'Content-Type': 'application/json',
2285
2293
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5427,6 +5435,7 @@ class ApiClient {
5427
5435
 
5428
5436
 
5429
5437
 
5438
+
5430
5439
 
5431
5440
 
5432
5441
 
@@ -5479,23 +5488,31 @@ class ApiClient {
5479
5488
  return null;
5480
5489
  }
5481
5490
 
5482
- const session = await this.auth.refreshToken(
5483
- this.refreshToken,
5484
- this.refreshBackend,
5485
- this.refreshExpiration,
5486
- this.isMobile,
5487
- this.refreshTenantId,
5488
- );
5491
+ try {
5492
+ const session = await this.auth.refreshToken(
5493
+ this.refreshToken,
5494
+ this.refreshBackend,
5495
+ this.refreshExpiration,
5496
+ this.isMobile,
5497
+ this.refreshTenantId,
5498
+ );
5489
5499
 
5490
- logger$a.info('token refreshed', { token: session.token });
5500
+ logger$a.info('token refreshed', { token: session.token });
5491
5501
 
5492
- if (this.onRefreshToken) {
5493
- this.onRefreshToken(session.token, session);
5494
- }
5502
+ if (this.onRefreshToken) {
5503
+ this.onRefreshToken(session.token, session);
5504
+ }
5495
5505
 
5496
- this.setToken(session.token);
5506
+ this.setToken(session.token);
5497
5507
 
5498
- return session.token;
5508
+ return session.token;
5509
+ } catch (error) {
5510
+ logger$a.error('token refresh, error', error);
5511
+
5512
+ if (this.onRefreshTokenError) {
5513
+ this.onRefreshTokenError(error);
5514
+ }
5515
+ }
5499
5516
  }
5500
5517
 
5501
5518
  setToken(token ) {
@@ -5518,6 +5535,10 @@ class ApiClient {
5518
5535
  this.onRefreshToken = onRefreshToken;
5519
5536
  }
5520
5537
 
5538
+ setOnRefreshTokenError(callback ) {
5539
+ this.onRefreshTokenError = callback;
5540
+ }
5541
+
5521
5542
  setRefreshExpiration(refreshExpiration ) {
5522
5543
  this.refreshExpiration = refreshExpiration;
5523
5544
  }
@@ -5553,7 +5574,9 @@ global.wazoClients = global.wazoClients || {};
5553
5574
  global.wazoClientId = global.wazoClientId || {};
5554
5575
  global.wazoClientToken = global.wazoClientToken || {};
5555
5576
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5577
+ global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5556
5578
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5579
+ global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5557
5580
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
5558
5581
  global.wazoRefreshBackend = global.wazoRefreshBackend || {};
5559
5582
  global.wazoIsMobile = global.wazoIsMobile || {};
@@ -5575,10 +5598,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5575
5598
  global.wazoRefreshToken[forServer] = newRefreshToken;
5576
5599
  };
5577
5600
 
5601
+ const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5602
+ global.wazoRefreshTenantId[forServer] = refreshTenantId;
5603
+ };
5604
+
5578
5605
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5579
5606
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5580
5607
  };
5581
5608
 
5609
+ const setOnRefreshTokenError = (callback , forServer = null) => {
5610
+ global.wazoOnRefreshTokenError[forServer] = callback;
5611
+ };
5612
+
5582
5613
  const setRefreshExpiration = (refreshExpiration , forServer = null) => {
5583
5614
  global.wazoRefreshExpiration[forServer] = refreshExpiration;
5584
5615
  };
@@ -5597,12 +5628,20 @@ const fillClient = (apiClient ) => {
5597
5628
 
5598
5629
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5599
5630
 
5631
+ apiClient.setRefreshTenantId(
5632
+ global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5633
+ );
5634
+
5600
5635
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
5601
5636
 
5602
5637
  apiClient.setOnRefreshToken(
5603
5638
  global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
5604
5639
  );
5605
5640
 
5641
+ apiClient.setOnRefreshTokenError(
5642
+ global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
5643
+ );
5644
+
5606
5645
  apiClient.setRefreshExpiration(
5607
5646
  global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
5608
5647
  );
@@ -5616,7 +5655,7 @@ const fillClient = (apiClient ) => {
5616
5655
  return apiClient;
5617
5656
  };
5618
5657
 
5619
- var getApiClient = (forServer ) => {
5658
+ var getApiClient = (forServer = null) => {
5620
5659
  const server = forServer || global.wazoCurrentServer || '';
5621
5660
  if (server in global.wazoClients) {
5622
5661
  return fillClient(global.wazoClients[server]);
@@ -5643,6 +5682,7 @@ class Auth {
5643
5682
 
5644
5683
 
5645
5684
 
5685
+
5646
5686
 
5647
5687
 
5648
5688
 
@@ -5680,6 +5720,14 @@ class Auth {
5680
5720
  this.onRefreshTokenCallback(token, session);
5681
5721
  }
5682
5722
  });
5723
+
5724
+ setOnRefreshTokenError(error => {
5725
+ logger$9.error('on refresh token error', error);
5726
+
5727
+ if (this.onRefreshTokenCallbackError) {
5728
+ this.onRefreshTokenCallbackError(error);
5729
+ }
5730
+ });
5683
5731
  }
5684
5732
 
5685
5733
  setFetchOptions(options ) {
@@ -5768,6 +5816,10 @@ class Auth {
5768
5816
  this.onRefreshTokenCallback = callback;
5769
5817
  }
5770
5818
 
5819
+ setOnRefreshTokenError(callback ) {
5820
+ this.onRefreshTokenCallbackError = callback;
5821
+ }
5822
+
5771
5823
  checkAuthorizations(session , authorizationName ) {
5772
5824
  if (!authorizationName) {
5773
5825
  return;
@@ -5800,6 +5852,12 @@ class Auth {
5800
5852
  setRefreshToken(refreshToken);
5801
5853
  }
5802
5854
 
5855
+ setRefreshTenantId(refreshTenantId ) {
5856
+ setRefreshTenantId(refreshTenantId);
5857
+
5858
+ getApiClient().setRefreshTenantId(refreshTenantId);
5859
+ }
5860
+
5803
5861
  forceRefreshToken() {
5804
5862
  getApiClient().forceRefreshToken();
5805
5863
  }
@@ -7434,8 +7492,10 @@ class WebRTCClient extends Emitter {
7434
7492
  conference: isConference,
7435
7493
  };
7436
7494
 
7437
- // Avoid sdh to created a new stream
7438
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7495
+ // Avoid sdh to create a new stream
7496
+ if (session.sessionDescriptionHandler) {
7497
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7498
+ }
7439
7499
 
7440
7500
  // Send re-INVITE
7441
7501
  return session.invite(options);
@@ -9406,7 +9466,7 @@ class WebRTCPhone extends Emitter {
9406
9466
  // When stopping screenshare and we had video before that, we have to re-upgrade
9407
9467
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9408
9468
  // We have to downgrade to audio.
9409
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9469
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9410
9470
  const constraints = { audio: false, video: screenshareStopped };
9411
9471
 
9412
9472
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9850,7 +9910,7 @@ class WebRTCPhone extends Emitter {
9850
9910
 
9851
9911
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9852
9912
 
9853
- // Stop screenshre if needed
9913
+ // Stop screenshare if needed
9854
9914
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9855
9915
  this.lastScreenShare = this.currentScreenShare;
9856
9916
  await this.stopScreenSharing(false, callSession);
@@ -10426,7 +10486,7 @@ class WebRTCPhone extends Emitter {
10426
10486
  });
10427
10487
 
10428
10488
  this.client.on(this.client.DISCONNECTED, () => {
10429
- logger$7.warn('WebRTC client disconnected');
10489
+ logger$7.info('WebRTC client disconnected');
10430
10490
 
10431
10491
  this.eventEmitter.emit(ON_UNREGISTERED);
10432
10492
 
@@ -10612,7 +10672,7 @@ class WebRTCPhone extends Emitter {
10612
10672
  endTime: fromSession ? fromSession.endTime : null,
10613
10673
  answered: state === sessionState.SessionState.Established,
10614
10674
  paused: this.client.isCallHeld(sipSession),
10615
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10675
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10616
10676
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10617
10677
  number,
10618
10678
  ringing: false,
@@ -11446,7 +11506,7 @@ class WebSocketClient extends Emitter {
11446
11506
  this.close();
11447
11507
  }
11448
11508
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11449
- logger$5.log('Wazo WS url computed to reconnect', { url });
11509
+ logger$5.info('Wazo WS url computed to reconnect', { url });
11450
11510
 
11451
11511
  return url;
11452
11512
  }
@@ -690,13 +690,9 @@ class IssueReporter {
690
690
 
691
691
  setTimeout(() => {
692
692
  if (isArray) {
693
- payload = payload.map(message => {
694
- message._retry = retry + 1;
695
- return message;
696
- });
697
- } else {
698
- // $FlowFixMe
699
- payload._retry = retry + 1;
693
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
694
+ } else if (payload && typeof payload === 'object') {
695
+ payload = this._writeRetryCount(payload, retry + 1);
700
696
  }
701
697
 
702
698
  this._sendDebugToGrafana(payload, retry + 1);
@@ -704,6 +700,15 @@ class IssueReporter {
704
700
  });
705
701
  }
706
702
 
703
+ _writeRetryCount(message , count ) {
704
+ if (message && typeof message === 'object') {
705
+ // $FlowFixMe
706
+ message._retry = count;
707
+ }
708
+
709
+ return message;
710
+ }
711
+
707
712
  _isLevelAbove(level1 , level2 ) {
708
713
  const index1 = LOG_LEVELS.indexOf(level1);
709
714
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -2275,9 +2280,12 @@ var authMethods = (client , baseUrl ) => ({
2275
2280
  expiration: expiration || DETAULT_EXPIRATION,
2276
2281
  refresh_token: refreshToken,
2277
2282
  client_id: client.clientId,
2278
- tenant_id: tenantId,
2279
2283
  };
2280
2284
 
2285
+ if (tenantId) {
2286
+ body.tenant_id = tenantId;
2287
+ }
2288
+
2281
2289
  const headers = {
2282
2290
  'Content-Type': 'application/json',
2283
2291
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5425,6 +5433,7 @@ class ApiClient {
5425
5433
 
5426
5434
 
5427
5435
 
5436
+
5428
5437
 
5429
5438
 
5430
5439
 
@@ -5477,23 +5486,31 @@ class ApiClient {
5477
5486
  return null;
5478
5487
  }
5479
5488
 
5480
- const session = await this.auth.refreshToken(
5481
- this.refreshToken,
5482
- this.refreshBackend,
5483
- this.refreshExpiration,
5484
- this.isMobile,
5485
- this.refreshTenantId,
5486
- );
5489
+ try {
5490
+ const session = await this.auth.refreshToken(
5491
+ this.refreshToken,
5492
+ this.refreshBackend,
5493
+ this.refreshExpiration,
5494
+ this.isMobile,
5495
+ this.refreshTenantId,
5496
+ );
5487
5497
 
5488
- logger$a.info('token refreshed', { token: session.token });
5498
+ logger$a.info('token refreshed', { token: session.token });
5489
5499
 
5490
- if (this.onRefreshToken) {
5491
- this.onRefreshToken(session.token, session);
5492
- }
5500
+ if (this.onRefreshToken) {
5501
+ this.onRefreshToken(session.token, session);
5502
+ }
5493
5503
 
5494
- this.setToken(session.token);
5504
+ this.setToken(session.token);
5495
5505
 
5496
- return session.token;
5506
+ return session.token;
5507
+ } catch (error) {
5508
+ logger$a.error('token refresh, error', error);
5509
+
5510
+ if (this.onRefreshTokenError) {
5511
+ this.onRefreshTokenError(error);
5512
+ }
5513
+ }
5497
5514
  }
5498
5515
 
5499
5516
  setToken(token ) {
@@ -5516,6 +5533,10 @@ class ApiClient {
5516
5533
  this.onRefreshToken = onRefreshToken;
5517
5534
  }
5518
5535
 
5536
+ setOnRefreshTokenError(callback ) {
5537
+ this.onRefreshTokenError = callback;
5538
+ }
5539
+
5519
5540
  setRefreshExpiration(refreshExpiration ) {
5520
5541
  this.refreshExpiration = refreshExpiration;
5521
5542
  }
@@ -5551,7 +5572,9 @@ global.wazoClients = global.wazoClients || {};
5551
5572
  global.wazoClientId = global.wazoClientId || {};
5552
5573
  global.wazoClientToken = global.wazoClientToken || {};
5553
5574
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5575
+ global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5554
5576
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5577
+ global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5555
5578
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
5556
5579
  global.wazoRefreshBackend = global.wazoRefreshBackend || {};
5557
5580
  global.wazoIsMobile = global.wazoIsMobile || {};
@@ -5573,10 +5596,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5573
5596
  global.wazoRefreshToken[forServer] = newRefreshToken;
5574
5597
  };
5575
5598
 
5599
+ const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5600
+ global.wazoRefreshTenantId[forServer] = refreshTenantId;
5601
+ };
5602
+
5576
5603
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5577
5604
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5578
5605
  };
5579
5606
 
5607
+ const setOnRefreshTokenError = (callback , forServer = null) => {
5608
+ global.wazoOnRefreshTokenError[forServer] = callback;
5609
+ };
5610
+
5580
5611
  const setRefreshExpiration = (refreshExpiration , forServer = null) => {
5581
5612
  global.wazoRefreshExpiration[forServer] = refreshExpiration;
5582
5613
  };
@@ -5595,12 +5626,20 @@ const fillClient = (apiClient ) => {
5595
5626
 
5596
5627
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5597
5628
 
5629
+ apiClient.setRefreshTenantId(
5630
+ global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5631
+ );
5632
+
5598
5633
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
5599
5634
 
5600
5635
  apiClient.setOnRefreshToken(
5601
5636
  global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
5602
5637
  );
5603
5638
 
5639
+ apiClient.setOnRefreshTokenError(
5640
+ global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
5641
+ );
5642
+
5604
5643
  apiClient.setRefreshExpiration(
5605
5644
  global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
5606
5645
  );
@@ -5614,7 +5653,7 @@ const fillClient = (apiClient ) => {
5614
5653
  return apiClient;
5615
5654
  };
5616
5655
 
5617
- var getApiClient = (forServer ) => {
5656
+ var getApiClient = (forServer = null) => {
5618
5657
  const server = forServer || global.wazoCurrentServer || '';
5619
5658
  if (server in global.wazoClients) {
5620
5659
  return fillClient(global.wazoClients[server]);
@@ -5641,6 +5680,7 @@ class Auth {
5641
5680
 
5642
5681
 
5643
5682
 
5683
+
5644
5684
 
5645
5685
 
5646
5686
 
@@ -5678,6 +5718,14 @@ class Auth {
5678
5718
  this.onRefreshTokenCallback(token, session);
5679
5719
  }
5680
5720
  });
5721
+
5722
+ setOnRefreshTokenError(error => {
5723
+ logger$9.error('on refresh token error', error);
5724
+
5725
+ if (this.onRefreshTokenCallbackError) {
5726
+ this.onRefreshTokenCallbackError(error);
5727
+ }
5728
+ });
5681
5729
  }
5682
5730
 
5683
5731
  setFetchOptions(options ) {
@@ -5766,6 +5814,10 @@ class Auth {
5766
5814
  this.onRefreshTokenCallback = callback;
5767
5815
  }
5768
5816
 
5817
+ setOnRefreshTokenError(callback ) {
5818
+ this.onRefreshTokenCallbackError = callback;
5819
+ }
5820
+
5769
5821
  checkAuthorizations(session , authorizationName ) {
5770
5822
  if (!authorizationName) {
5771
5823
  return;
@@ -5798,6 +5850,12 @@ class Auth {
5798
5850
  setRefreshToken(refreshToken);
5799
5851
  }
5800
5852
 
5853
+ setRefreshTenantId(refreshTenantId ) {
5854
+ setRefreshTenantId(refreshTenantId);
5855
+
5856
+ getApiClient().setRefreshTenantId(refreshTenantId);
5857
+ }
5858
+
5801
5859
  forceRefreshToken() {
5802
5860
  getApiClient().forceRefreshToken();
5803
5861
  }
@@ -7432,8 +7490,10 @@ class WebRTCClient extends Emitter {
7432
7490
  conference: isConference,
7433
7491
  };
7434
7492
 
7435
- // Avoid sdh to created a new stream
7436
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7493
+ // Avoid sdh to create a new stream
7494
+ if (session.sessionDescriptionHandler) {
7495
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7496
+ }
7437
7497
 
7438
7498
  // Send re-INVITE
7439
7499
  return session.invite(options);
@@ -9404,7 +9464,7 @@ class WebRTCPhone extends Emitter {
9404
9464
  // When stopping screenshare and we had video before that, we have to re-upgrade
9405
9465
  // When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
9406
9466
  // We have to downgrade to audio.
9407
- const screenshareStopped = this.currentScreenShare.sender && this.currentScreenShare.hadVideo;
9467
+ const screenshareStopped = this.currentScreenShare.hadVideo;
9408
9468
  const constraints = { audio: false, video: screenshareStopped };
9409
9469
 
9410
9470
  // We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
@@ -9848,7 +9908,7 @@ class WebRTCPhone extends Emitter {
9848
9908
 
9849
9909
  logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9850
9910
 
9851
- // Stop screenshre if needed
9911
+ // Stop screenshare if needed
9852
9912
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
9853
9913
  this.lastScreenShare = this.currentScreenShare;
9854
9914
  await this.stopScreenSharing(false, callSession);
@@ -10424,7 +10484,7 @@ class WebRTCPhone extends Emitter {
10424
10484
  });
10425
10485
 
10426
10486
  this.client.on(this.client.DISCONNECTED, () => {
10427
- logger$7.warn('WebRTC client disconnected');
10487
+ logger$7.info('WebRTC client disconnected');
10428
10488
 
10429
10489
  this.eventEmitter.emit(ON_UNREGISTERED);
10430
10490
 
@@ -10610,7 +10670,7 @@ class WebRTCPhone extends Emitter {
10610
10670
  endTime: fromSession ? fromSession.endTime : null,
10611
10671
  answered: state === sessionState.SessionState.Established,
10612
10672
  paused: this.client.isCallHeld(sipSession),
10613
- isCaller: 'incoming' in extra ? !extra.incoming : false,
10673
+ isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
10614
10674
  cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
10615
10675
  number,
10616
10676
  ringing: false,
@@ -11444,7 +11504,7 @@ class WebSocketClient extends Emitter {
11444
11504
  this.close();
11445
11505
  }
11446
11506
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11447
- logger$5.log('Wazo WS url computed to reconnect', { url });
11507
+ logger$5.info('Wazo WS url computed to reconnect', { url });
11448
11508
 
11449
11509
  return url;
11450
11510
  }