@wazo/sdk 0.37.39 → 0.37.42
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.
- package/README.md +2 -1
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +33 -15
- package/esm/__tests__/web-rtc-client.test.js +39 -18
- package/esm/api/auth.js +4 -1
- package/esm/api/ctid-ng.js +2 -0
- package/esm/api-client.js +33 -15
- package/esm/checker/Checker.js +39 -18
- package/esm/checker/checks/aor.js +33 -15
- package/esm/checker/checks/api.js +33 -15
- package/esm/checker/checks/index.js +39 -18
- package/esm/checker/checks/webrtc-transport.js +39 -18
- package/esm/checker/checks/webrtc.js +39 -18
- package/esm/domain/AdHocAPIConference.js +42 -16
- package/esm/domain/Features.js +42 -16
- package/esm/domain/Phone/CTIPhone.js +42 -16
- package/esm/domain/Phone/WebRTCPhone.js +5 -3
- package/esm/index.js +77 -21
- package/esm/service/CallApi.js +42 -16
- package/esm/service/getApiClient.js +51 -17
- package/esm/simple/Auth.js +77 -21
- package/esm/simple/Configuration.js +77 -21
- package/esm/simple/Directory.js +42 -16
- package/esm/simple/Phone.js +77 -21
- package/esm/simple/index.js +77 -21
- package/esm/simple/room/LocalParticipant.js +77 -21
- package/esm/simple/room/Participant.js +77 -21
- package/esm/simple/room/RemoteParticipant.js +77 -21
- package/esm/simple/room/Room.js +77 -21
- package/esm/simple/room/SipRoom.js +77 -21
- package/esm/simple/room/Stream.js +77 -21
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/esm/simple/utils.js +77 -21
- package/esm/web-rtc-client.js +39 -18
- package/lib/__tests__/api-client.test.js +33 -15
- package/lib/__tests__/web-rtc-client.test.js +39 -18
- package/lib/api/auth.js +4 -1
- package/lib/api/ctid-ng.js +2 -0
- package/lib/api-client.js +33 -15
- package/lib/checker/Checker.js +39 -18
- package/lib/checker/checks/aor.js +33 -15
- package/lib/checker/checks/api.js +33 -15
- package/lib/checker/checks/index.js +39 -18
- package/lib/checker/checks/webrtc-transport.js +39 -18
- package/lib/checker/checks/webrtc.js +39 -18
- package/lib/domain/AdHocAPIConference.js +42 -16
- package/lib/domain/Features.js +42 -16
- package/lib/domain/Phone/CTIPhone.js +42 -16
- package/lib/domain/Phone/WebRTCPhone.js +5 -3
- package/lib/index.js +77 -21
- package/lib/service/CallApi.js +42 -16
- package/lib/service/getApiClient.js +52 -16
- package/lib/simple/Auth.js +77 -21
- package/lib/simple/Configuration.js +77 -21
- package/lib/simple/Directory.js +42 -16
- package/lib/simple/Phone.js +77 -21
- package/lib/simple/index.js +77 -21
- package/lib/simple/room/LocalParticipant.js +77 -21
- package/lib/simple/room/Participant.js +77 -21
- package/lib/simple/room/RemoteParticipant.js +77 -21
- package/lib/simple/room/Room.js +77 -21
- package/lib/simple/room/SipRoom.js +77 -21
- package/lib/simple/room/Stream.js +77 -21
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/lib/simple/utils.js +77 -21
- package/lib/web-rtc-client.js +39 -18
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/domain/Phone/WebRTCPhone.js +3 -3
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
- package/src/web-rtc-client.js +7 -4
|
@@ -2275,9 +2275,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2275
2275
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2276
2276
|
refresh_token: refreshToken,
|
|
2277
2277
|
client_id: client.clientId,
|
|
2278
|
-
tenant_id: tenantId,
|
|
2279
2278
|
};
|
|
2280
2279
|
|
|
2280
|
+
if (tenantId) {
|
|
2281
|
+
body.tenant_id = tenantId;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2281
2284
|
const headers = {
|
|
2282
2285
|
'Content-Type': 'application/json',
|
|
2283
2286
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5425,6 +5428,7 @@ class ApiClient {
|
|
|
5425
5428
|
|
|
5426
5429
|
|
|
5427
5430
|
|
|
5431
|
+
|
|
5428
5432
|
|
|
5429
5433
|
|
|
5430
5434
|
|
|
@@ -5477,23 +5481,31 @@ class ApiClient {
|
|
|
5477
5481
|
return null;
|
|
5478
5482
|
}
|
|
5479
5483
|
|
|
5480
|
-
|
|
5481
|
-
this.refreshToken
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5484
|
+
try {
|
|
5485
|
+
const session = await this.auth.refreshToken(
|
|
5486
|
+
this.refreshToken,
|
|
5487
|
+
this.refreshBackend,
|
|
5488
|
+
this.refreshExpiration,
|
|
5489
|
+
this.isMobile,
|
|
5490
|
+
this.refreshTenantId,
|
|
5491
|
+
);
|
|
5487
5492
|
|
|
5488
|
-
|
|
5493
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5489
5494
|
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5495
|
+
if (this.onRefreshToken) {
|
|
5496
|
+
this.onRefreshToken(session.token, session);
|
|
5497
|
+
}
|
|
5493
5498
|
|
|
5494
|
-
|
|
5499
|
+
this.setToken(session.token);
|
|
5500
|
+
|
|
5501
|
+
return session.token;
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
logger$a.error('token refresh, error', error);
|
|
5495
5504
|
|
|
5496
|
-
|
|
5505
|
+
if (this.onRefreshTokenError) {
|
|
5506
|
+
this.onRefreshTokenError(error);
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5497
5509
|
}
|
|
5498
5510
|
|
|
5499
5511
|
setToken(token ) {
|
|
@@ -5516,6 +5528,10 @@ class ApiClient {
|
|
|
5516
5528
|
this.onRefreshToken = onRefreshToken;
|
|
5517
5529
|
}
|
|
5518
5530
|
|
|
5531
|
+
setOnRefreshTokenError(callback ) {
|
|
5532
|
+
this.onRefreshTokenError = callback;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5519
5535
|
setRefreshExpiration(refreshExpiration ) {
|
|
5520
5536
|
this.refreshExpiration = refreshExpiration;
|
|
5521
5537
|
}
|
|
@@ -5551,7 +5567,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5551
5567
|
global.wazoClientId = global.wazoClientId || {};
|
|
5552
5568
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5553
5569
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5570
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5554
5571
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5572
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5555
5573
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5556
5574
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5557
5575
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5573,10 +5591,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5573
5591
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5574
5592
|
};
|
|
5575
5593
|
|
|
5594
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5595
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5596
|
+
};
|
|
5597
|
+
|
|
5576
5598
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5577
5599
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5578
5600
|
};
|
|
5579
5601
|
|
|
5602
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5603
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5580
5606
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5581
5607
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5582
5608
|
};
|
|
@@ -5595,12 +5621,20 @@ const fillClient = (apiClient ) => {
|
|
|
5595
5621
|
|
|
5596
5622
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5597
5623
|
|
|
5624
|
+
apiClient.setRefreshTenantId(
|
|
5625
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5626
|
+
);
|
|
5627
|
+
|
|
5598
5628
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5599
5629
|
|
|
5600
5630
|
apiClient.setOnRefreshToken(
|
|
5601
5631
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5602
5632
|
);
|
|
5603
5633
|
|
|
5634
|
+
apiClient.setOnRefreshTokenError(
|
|
5635
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5636
|
+
);
|
|
5637
|
+
|
|
5604
5638
|
apiClient.setRefreshExpiration(
|
|
5605
5639
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5606
5640
|
);
|
|
@@ -5614,7 +5648,7 @@ const fillClient = (apiClient ) => {
|
|
|
5614
5648
|
return apiClient;
|
|
5615
5649
|
};
|
|
5616
5650
|
|
|
5617
|
-
var getApiClient = (forServer
|
|
5651
|
+
var getApiClient = (forServer = null) => {
|
|
5618
5652
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5619
5653
|
if (server in global.wazoClients) {
|
|
5620
5654
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5641,6 +5675,7 @@ class Auth {
|
|
|
5641
5675
|
|
|
5642
5676
|
|
|
5643
5677
|
|
|
5678
|
+
|
|
5644
5679
|
|
|
5645
5680
|
|
|
5646
5681
|
|
|
@@ -5678,6 +5713,14 @@ class Auth {
|
|
|
5678
5713
|
this.onRefreshTokenCallback(token, session);
|
|
5679
5714
|
}
|
|
5680
5715
|
});
|
|
5716
|
+
|
|
5717
|
+
setOnRefreshTokenError(error => {
|
|
5718
|
+
logger$9.error('on refresh token error', error);
|
|
5719
|
+
|
|
5720
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5721
|
+
this.onRefreshTokenCallbackError(error);
|
|
5722
|
+
}
|
|
5723
|
+
});
|
|
5681
5724
|
}
|
|
5682
5725
|
|
|
5683
5726
|
setFetchOptions(options ) {
|
|
@@ -5766,6 +5809,10 @@ class Auth {
|
|
|
5766
5809
|
this.onRefreshTokenCallback = callback;
|
|
5767
5810
|
}
|
|
5768
5811
|
|
|
5812
|
+
setOnRefreshTokenError(callback ) {
|
|
5813
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5769
5816
|
checkAuthorizations(session , authorizationName ) {
|
|
5770
5817
|
if (!authorizationName) {
|
|
5771
5818
|
return;
|
|
@@ -5798,6 +5845,12 @@ class Auth {
|
|
|
5798
5845
|
setRefreshToken(refreshToken);
|
|
5799
5846
|
}
|
|
5800
5847
|
|
|
5848
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5849
|
+
setRefreshTenantId(refreshTenantId);
|
|
5850
|
+
|
|
5851
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5852
|
+
}
|
|
5853
|
+
|
|
5801
5854
|
forceRefreshToken() {
|
|
5802
5855
|
getApiClient().forceRefreshToken();
|
|
5803
5856
|
}
|
|
@@ -8745,11 +8798,14 @@ class WebRTCClient extends Emitter {
|
|
|
8745
8798
|
}
|
|
8746
8799
|
|
|
8747
8800
|
async _disconnectTransport(force = false) {
|
|
8748
|
-
if (force) {
|
|
8801
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8749
8802
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8750
8803
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8751
|
-
|
|
8752
|
-
this.userAgent.transport._ws
|
|
8804
|
+
|
|
8805
|
+
if (this.userAgent.transport._ws) {
|
|
8806
|
+
this.userAgent.transport._ws.close(1000);
|
|
8807
|
+
}
|
|
8808
|
+
|
|
8753
8809
|
return;
|
|
8754
8810
|
}
|
|
8755
8811
|
|
|
@@ -9401,7 +9457,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9401
9457
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9402
9458
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9403
9459
|
// We have to downgrade to audio.
|
|
9404
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9460
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9405
9461
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9406
9462
|
|
|
9407
9463
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9845,7 +9901,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9845
9901
|
|
|
9846
9902
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9847
9903
|
|
|
9848
|
-
// Stop
|
|
9904
|
+
// Stop screenshare if needed
|
|
9849
9905
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9850
9906
|
this.lastScreenShare = this.currentScreenShare;
|
|
9851
9907
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10607,7 +10663,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10607
10663
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10608
10664
|
answered: state === sessionState.SessionState.Established,
|
|
10609
10665
|
paused: this.client.isCallHeld(sipSession),
|
|
10610
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10666
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10611
10667
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10612
10668
|
number,
|
|
10613
10669
|
ringing: false,
|
package/lib/simple/room/Room.js
CHANGED
|
@@ -2277,9 +2277,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2277
2277
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2278
2278
|
refresh_token: refreshToken,
|
|
2279
2279
|
client_id: client.clientId,
|
|
2280
|
-
tenant_id: tenantId,
|
|
2281
2280
|
};
|
|
2282
2281
|
|
|
2282
|
+
if (tenantId) {
|
|
2283
|
+
body.tenant_id = tenantId;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2283
2286
|
const headers = {
|
|
2284
2287
|
'Content-Type': 'application/json',
|
|
2285
2288
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5427,6 +5430,7 @@ class ApiClient {
|
|
|
5427
5430
|
|
|
5428
5431
|
|
|
5429
5432
|
|
|
5433
|
+
|
|
5430
5434
|
|
|
5431
5435
|
|
|
5432
5436
|
|
|
@@ -5479,23 +5483,31 @@ class ApiClient {
|
|
|
5479
5483
|
return null;
|
|
5480
5484
|
}
|
|
5481
5485
|
|
|
5482
|
-
|
|
5483
|
-
this.refreshToken
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5486
|
+
try {
|
|
5487
|
+
const session = await this.auth.refreshToken(
|
|
5488
|
+
this.refreshToken,
|
|
5489
|
+
this.refreshBackend,
|
|
5490
|
+
this.refreshExpiration,
|
|
5491
|
+
this.isMobile,
|
|
5492
|
+
this.refreshTenantId,
|
|
5493
|
+
);
|
|
5489
5494
|
|
|
5490
|
-
|
|
5495
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5491
5496
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5497
|
+
if (this.onRefreshToken) {
|
|
5498
|
+
this.onRefreshToken(session.token, session);
|
|
5499
|
+
}
|
|
5495
5500
|
|
|
5496
|
-
|
|
5501
|
+
this.setToken(session.token);
|
|
5502
|
+
|
|
5503
|
+
return session.token;
|
|
5504
|
+
} catch (error) {
|
|
5505
|
+
logger$a.error('token refresh, error', error);
|
|
5497
5506
|
|
|
5498
|
-
|
|
5507
|
+
if (this.onRefreshTokenError) {
|
|
5508
|
+
this.onRefreshTokenError(error);
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5499
5511
|
}
|
|
5500
5512
|
|
|
5501
5513
|
setToken(token ) {
|
|
@@ -5518,6 +5530,10 @@ class ApiClient {
|
|
|
5518
5530
|
this.onRefreshToken = onRefreshToken;
|
|
5519
5531
|
}
|
|
5520
5532
|
|
|
5533
|
+
setOnRefreshTokenError(callback ) {
|
|
5534
|
+
this.onRefreshTokenError = callback;
|
|
5535
|
+
}
|
|
5536
|
+
|
|
5521
5537
|
setRefreshExpiration(refreshExpiration ) {
|
|
5522
5538
|
this.refreshExpiration = refreshExpiration;
|
|
5523
5539
|
}
|
|
@@ -5553,7 +5569,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5553
5569
|
global.wazoClientId = global.wazoClientId || {};
|
|
5554
5570
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5555
5571
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5572
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5556
5573
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5574
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5557
5575
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5558
5576
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5559
5577
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5575,10 +5593,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5575
5593
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5576
5594
|
};
|
|
5577
5595
|
|
|
5596
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5597
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5598
|
+
};
|
|
5599
|
+
|
|
5578
5600
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5579
5601
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5580
5602
|
};
|
|
5581
5603
|
|
|
5604
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5605
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5606
|
+
};
|
|
5607
|
+
|
|
5582
5608
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5583
5609
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5584
5610
|
};
|
|
@@ -5597,12 +5623,20 @@ const fillClient = (apiClient ) => {
|
|
|
5597
5623
|
|
|
5598
5624
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5599
5625
|
|
|
5626
|
+
apiClient.setRefreshTenantId(
|
|
5627
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5628
|
+
);
|
|
5629
|
+
|
|
5600
5630
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5601
5631
|
|
|
5602
5632
|
apiClient.setOnRefreshToken(
|
|
5603
5633
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5604
5634
|
);
|
|
5605
5635
|
|
|
5636
|
+
apiClient.setOnRefreshTokenError(
|
|
5637
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5638
|
+
);
|
|
5639
|
+
|
|
5606
5640
|
apiClient.setRefreshExpiration(
|
|
5607
5641
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5608
5642
|
);
|
|
@@ -5616,7 +5650,7 @@ const fillClient = (apiClient ) => {
|
|
|
5616
5650
|
return apiClient;
|
|
5617
5651
|
};
|
|
5618
5652
|
|
|
5619
|
-
var getApiClient = (forServer
|
|
5653
|
+
var getApiClient = (forServer = null) => {
|
|
5620
5654
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5621
5655
|
if (server in global.wazoClients) {
|
|
5622
5656
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5643,6 +5677,7 @@ class Auth {
|
|
|
5643
5677
|
|
|
5644
5678
|
|
|
5645
5679
|
|
|
5680
|
+
|
|
5646
5681
|
|
|
5647
5682
|
|
|
5648
5683
|
|
|
@@ -5680,6 +5715,14 @@ class Auth {
|
|
|
5680
5715
|
this.onRefreshTokenCallback(token, session);
|
|
5681
5716
|
}
|
|
5682
5717
|
});
|
|
5718
|
+
|
|
5719
|
+
setOnRefreshTokenError(error => {
|
|
5720
|
+
logger$9.error('on refresh token error', error);
|
|
5721
|
+
|
|
5722
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5723
|
+
this.onRefreshTokenCallbackError(error);
|
|
5724
|
+
}
|
|
5725
|
+
});
|
|
5683
5726
|
}
|
|
5684
5727
|
|
|
5685
5728
|
setFetchOptions(options ) {
|
|
@@ -5768,6 +5811,10 @@ class Auth {
|
|
|
5768
5811
|
this.onRefreshTokenCallback = callback;
|
|
5769
5812
|
}
|
|
5770
5813
|
|
|
5814
|
+
setOnRefreshTokenError(callback ) {
|
|
5815
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5816
|
+
}
|
|
5817
|
+
|
|
5771
5818
|
checkAuthorizations(session , authorizationName ) {
|
|
5772
5819
|
if (!authorizationName) {
|
|
5773
5820
|
return;
|
|
@@ -5800,6 +5847,12 @@ class Auth {
|
|
|
5800
5847
|
setRefreshToken(refreshToken);
|
|
5801
5848
|
}
|
|
5802
5849
|
|
|
5850
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5851
|
+
setRefreshTenantId(refreshTenantId);
|
|
5852
|
+
|
|
5853
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5854
|
+
}
|
|
5855
|
+
|
|
5803
5856
|
forceRefreshToken() {
|
|
5804
5857
|
getApiClient().forceRefreshToken();
|
|
5805
5858
|
}
|
|
@@ -8747,11 +8800,14 @@ class WebRTCClient extends Emitter {
|
|
|
8747
8800
|
}
|
|
8748
8801
|
|
|
8749
8802
|
async _disconnectTransport(force = false) {
|
|
8750
|
-
if (force) {
|
|
8803
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8751
8804
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8752
8805
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8753
|
-
|
|
8754
|
-
this.userAgent.transport._ws
|
|
8806
|
+
|
|
8807
|
+
if (this.userAgent.transport._ws) {
|
|
8808
|
+
this.userAgent.transport._ws.close(1000);
|
|
8809
|
+
}
|
|
8810
|
+
|
|
8755
8811
|
return;
|
|
8756
8812
|
}
|
|
8757
8813
|
|
|
@@ -9403,7 +9459,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9403
9459
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9404
9460
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9405
9461
|
// We have to downgrade to audio.
|
|
9406
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9462
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9407
9463
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9408
9464
|
|
|
9409
9465
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9847,7 +9903,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9847
9903
|
|
|
9848
9904
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9849
9905
|
|
|
9850
|
-
// Stop
|
|
9906
|
+
// Stop screenshare if needed
|
|
9851
9907
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9852
9908
|
this.lastScreenShare = this.currentScreenShare;
|
|
9853
9909
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10609,7 +10665,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10609
10665
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10610
10666
|
answered: state === sessionState.SessionState.Established,
|
|
10611
10667
|
paused: this.client.isCallHeld(sipSession),
|
|
10612
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10668
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10613
10669
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10614
10670
|
number,
|
|
10615
10671
|
ringing: false,
|
|
@@ -2275,9 +2275,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2275
2275
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2276
2276
|
refresh_token: refreshToken,
|
|
2277
2277
|
client_id: client.clientId,
|
|
2278
|
-
tenant_id: tenantId,
|
|
2279
2278
|
};
|
|
2280
2279
|
|
|
2280
|
+
if (tenantId) {
|
|
2281
|
+
body.tenant_id = tenantId;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2281
2284
|
const headers = {
|
|
2282
2285
|
'Content-Type': 'application/json',
|
|
2283
2286
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5425,6 +5428,7 @@ class ApiClient {
|
|
|
5425
5428
|
|
|
5426
5429
|
|
|
5427
5430
|
|
|
5431
|
+
|
|
5428
5432
|
|
|
5429
5433
|
|
|
5430
5434
|
|
|
@@ -5477,23 +5481,31 @@ class ApiClient {
|
|
|
5477
5481
|
return null;
|
|
5478
5482
|
}
|
|
5479
5483
|
|
|
5480
|
-
|
|
5481
|
-
this.refreshToken
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5484
|
+
try {
|
|
5485
|
+
const session = await this.auth.refreshToken(
|
|
5486
|
+
this.refreshToken,
|
|
5487
|
+
this.refreshBackend,
|
|
5488
|
+
this.refreshExpiration,
|
|
5489
|
+
this.isMobile,
|
|
5490
|
+
this.refreshTenantId,
|
|
5491
|
+
);
|
|
5487
5492
|
|
|
5488
|
-
|
|
5493
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5489
5494
|
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5495
|
+
if (this.onRefreshToken) {
|
|
5496
|
+
this.onRefreshToken(session.token, session);
|
|
5497
|
+
}
|
|
5493
5498
|
|
|
5494
|
-
|
|
5499
|
+
this.setToken(session.token);
|
|
5500
|
+
|
|
5501
|
+
return session.token;
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
logger$a.error('token refresh, error', error);
|
|
5495
5504
|
|
|
5496
|
-
|
|
5505
|
+
if (this.onRefreshTokenError) {
|
|
5506
|
+
this.onRefreshTokenError(error);
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5497
5509
|
}
|
|
5498
5510
|
|
|
5499
5511
|
setToken(token ) {
|
|
@@ -5516,6 +5528,10 @@ class ApiClient {
|
|
|
5516
5528
|
this.onRefreshToken = onRefreshToken;
|
|
5517
5529
|
}
|
|
5518
5530
|
|
|
5531
|
+
setOnRefreshTokenError(callback ) {
|
|
5532
|
+
this.onRefreshTokenError = callback;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5519
5535
|
setRefreshExpiration(refreshExpiration ) {
|
|
5520
5536
|
this.refreshExpiration = refreshExpiration;
|
|
5521
5537
|
}
|
|
@@ -5551,7 +5567,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5551
5567
|
global.wazoClientId = global.wazoClientId || {};
|
|
5552
5568
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5553
5569
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5570
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5554
5571
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5572
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5555
5573
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5556
5574
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5557
5575
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5573,10 +5591,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5573
5591
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5574
5592
|
};
|
|
5575
5593
|
|
|
5594
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5595
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5596
|
+
};
|
|
5597
|
+
|
|
5576
5598
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5577
5599
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5578
5600
|
};
|
|
5579
5601
|
|
|
5602
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5603
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5580
5606
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5581
5607
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5582
5608
|
};
|
|
@@ -5595,12 +5621,20 @@ const fillClient = (apiClient ) => {
|
|
|
5595
5621
|
|
|
5596
5622
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5597
5623
|
|
|
5624
|
+
apiClient.setRefreshTenantId(
|
|
5625
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5626
|
+
);
|
|
5627
|
+
|
|
5598
5628
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5599
5629
|
|
|
5600
5630
|
apiClient.setOnRefreshToken(
|
|
5601
5631
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5602
5632
|
);
|
|
5603
5633
|
|
|
5634
|
+
apiClient.setOnRefreshTokenError(
|
|
5635
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5636
|
+
);
|
|
5637
|
+
|
|
5604
5638
|
apiClient.setRefreshExpiration(
|
|
5605
5639
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5606
5640
|
);
|
|
@@ -5614,7 +5648,7 @@ const fillClient = (apiClient ) => {
|
|
|
5614
5648
|
return apiClient;
|
|
5615
5649
|
};
|
|
5616
5650
|
|
|
5617
|
-
var getApiClient = (forServer
|
|
5651
|
+
var getApiClient = (forServer = null) => {
|
|
5618
5652
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5619
5653
|
if (server in global.wazoClients) {
|
|
5620
5654
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5641,6 +5675,7 @@ class Auth {
|
|
|
5641
5675
|
|
|
5642
5676
|
|
|
5643
5677
|
|
|
5678
|
+
|
|
5644
5679
|
|
|
5645
5680
|
|
|
5646
5681
|
|
|
@@ -5678,6 +5713,14 @@ class Auth {
|
|
|
5678
5713
|
this.onRefreshTokenCallback(token, session);
|
|
5679
5714
|
}
|
|
5680
5715
|
});
|
|
5716
|
+
|
|
5717
|
+
setOnRefreshTokenError(error => {
|
|
5718
|
+
logger$9.error('on refresh token error', error);
|
|
5719
|
+
|
|
5720
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5721
|
+
this.onRefreshTokenCallbackError(error);
|
|
5722
|
+
}
|
|
5723
|
+
});
|
|
5681
5724
|
}
|
|
5682
5725
|
|
|
5683
5726
|
setFetchOptions(options ) {
|
|
@@ -5766,6 +5809,10 @@ class Auth {
|
|
|
5766
5809
|
this.onRefreshTokenCallback = callback;
|
|
5767
5810
|
}
|
|
5768
5811
|
|
|
5812
|
+
setOnRefreshTokenError(callback ) {
|
|
5813
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5769
5816
|
checkAuthorizations(session , authorizationName ) {
|
|
5770
5817
|
if (!authorizationName) {
|
|
5771
5818
|
return;
|
|
@@ -5798,6 +5845,12 @@ class Auth {
|
|
|
5798
5845
|
setRefreshToken(refreshToken);
|
|
5799
5846
|
}
|
|
5800
5847
|
|
|
5848
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5849
|
+
setRefreshTenantId(refreshTenantId);
|
|
5850
|
+
|
|
5851
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5852
|
+
}
|
|
5853
|
+
|
|
5801
5854
|
forceRefreshToken() {
|
|
5802
5855
|
getApiClient().forceRefreshToken();
|
|
5803
5856
|
}
|
|
@@ -8745,11 +8798,14 @@ class WebRTCClient extends Emitter {
|
|
|
8745
8798
|
}
|
|
8746
8799
|
|
|
8747
8800
|
async _disconnectTransport(force = false) {
|
|
8748
|
-
if (force) {
|
|
8801
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8749
8802
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8750
8803
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8751
|
-
|
|
8752
|
-
this.userAgent.transport._ws
|
|
8804
|
+
|
|
8805
|
+
if (this.userAgent.transport._ws) {
|
|
8806
|
+
this.userAgent.transport._ws.close(1000);
|
|
8807
|
+
}
|
|
8808
|
+
|
|
8753
8809
|
return;
|
|
8754
8810
|
}
|
|
8755
8811
|
|
|
@@ -9401,7 +9457,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9401
9457
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9402
9458
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9403
9459
|
// We have to downgrade to audio.
|
|
9404
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9460
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9405
9461
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9406
9462
|
|
|
9407
9463
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9845,7 +9901,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9845
9901
|
|
|
9846
9902
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9847
9903
|
|
|
9848
|
-
// Stop
|
|
9904
|
+
// Stop screenshare if needed
|
|
9849
9905
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9850
9906
|
this.lastScreenShare = this.currentScreenShare;
|
|
9851
9907
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10607,7 +10663,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10607
10663
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10608
10664
|
answered: state === sessionState.SessionState.Established,
|
|
10609
10665
|
paused: this.client.isCallHeld(sipSession),
|
|
10610
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10666
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10611
10667
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10612
10668
|
number,
|
|
10613
10669
|
ringing: false,
|