@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]);
|
|
@@ -8463,11 +8497,14 @@ class WebRTCClient extends Emitter {
|
|
|
8463
8497
|
}
|
|
8464
8498
|
|
|
8465
8499
|
async _disconnectTransport(force = false) {
|
|
8466
|
-
if (force) {
|
|
8500
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8467
8501
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8468
8502
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8469
|
-
|
|
8470
|
-
this.userAgent.transport._ws
|
|
8503
|
+
|
|
8504
|
+
if (this.userAgent.transport._ws) {
|
|
8505
|
+
this.userAgent.transport._ws.close(1000);
|
|
8506
|
+
}
|
|
8507
|
+
|
|
8471
8508
|
return;
|
|
8472
8509
|
}
|
|
8473
8510
|
|
|
@@ -9119,7 +9156,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9119
9156
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9120
9157
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9121
9158
|
// We have to downgrade to audio.
|
|
9122
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9159
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9123
9160
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9124
9161
|
|
|
9125
9162
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9563,7 +9600,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9563
9600
|
|
|
9564
9601
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9565
9602
|
|
|
9566
|
-
// Stop
|
|
9603
|
+
// Stop screenshare if needed
|
|
9567
9604
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9568
9605
|
this.lastScreenShare = this.currentScreenShare;
|
|
9569
9606
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10325,7 +10362,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10325
10362
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10326
10363
|
answered: state === sessionState.SessionState.Established,
|
|
10327
10364
|
paused: this.client.isCallHeld(sipSession),
|
|
10328
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10365
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10329
10366
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10330
10367
|
number,
|
|
10331
10368
|
ringing: false,
|
|
@@ -13708,6 +13745,7 @@ class Auth {
|
|
|
13708
13745
|
|
|
13709
13746
|
|
|
13710
13747
|
|
|
13748
|
+
|
|
13711
13749
|
|
|
13712
13750
|
|
|
13713
13751
|
|
|
@@ -13745,6 +13783,14 @@ class Auth {
|
|
|
13745
13783
|
this.onRefreshTokenCallback(token, session);
|
|
13746
13784
|
}
|
|
13747
13785
|
});
|
|
13786
|
+
|
|
13787
|
+
setOnRefreshTokenError(error => {
|
|
13788
|
+
logger.error('on refresh token error', error);
|
|
13789
|
+
|
|
13790
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13791
|
+
this.onRefreshTokenCallbackError(error);
|
|
13792
|
+
}
|
|
13793
|
+
});
|
|
13748
13794
|
}
|
|
13749
13795
|
|
|
13750
13796
|
setFetchOptions(options ) {
|
|
@@ -13833,6 +13879,10 @@ class Auth {
|
|
|
13833
13879
|
this.onRefreshTokenCallback = callback;
|
|
13834
13880
|
}
|
|
13835
13881
|
|
|
13882
|
+
setOnRefreshTokenError(callback ) {
|
|
13883
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13884
|
+
}
|
|
13885
|
+
|
|
13836
13886
|
checkAuthorizations(session , authorizationName ) {
|
|
13837
13887
|
if (!authorizationName) {
|
|
13838
13888
|
return;
|
|
@@ -13865,6 +13915,12 @@ class Auth {
|
|
|
13865
13915
|
setRefreshToken(refreshToken);
|
|
13866
13916
|
}
|
|
13867
13917
|
|
|
13918
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13919
|
+
setRefreshTenantId(refreshTenantId);
|
|
13920
|
+
|
|
13921
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13922
|
+
}
|
|
13923
|
+
|
|
13868
13924
|
forceRefreshToken() {
|
|
13869
13925
|
getApiClient().forceRefreshToken();
|
|
13870
13926
|
}
|
package/lib/simple/Directory.js
CHANGED
|
@@ -2251,9 +2251,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2251
2251
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2252
2252
|
refresh_token: refreshToken,
|
|
2253
2253
|
client_id: client.clientId,
|
|
2254
|
-
tenant_id: tenantId,
|
|
2255
2254
|
};
|
|
2256
2255
|
|
|
2256
|
+
if (tenantId) {
|
|
2257
|
+
body.tenant_id = tenantId;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2257
2260
|
const headers = {
|
|
2258
2261
|
'Content-Type': 'application/json',
|
|
2259
2262
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4572,6 +4575,7 @@ class ApiClient {
|
|
|
4572
4575
|
|
|
4573
4576
|
|
|
4574
4577
|
|
|
4578
|
+
|
|
4575
4579
|
|
|
4576
4580
|
|
|
4577
4581
|
|
|
@@ -4624,23 +4628,31 @@ class ApiClient {
|
|
|
4624
4628
|
return null;
|
|
4625
4629
|
}
|
|
4626
4630
|
|
|
4627
|
-
|
|
4628
|
-
this.refreshToken
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4631
|
+
try {
|
|
4632
|
+
const session = await this.auth.refreshToken(
|
|
4633
|
+
this.refreshToken,
|
|
4634
|
+
this.refreshBackend,
|
|
4635
|
+
this.refreshExpiration,
|
|
4636
|
+
this.isMobile,
|
|
4637
|
+
this.refreshTenantId,
|
|
4638
|
+
);
|
|
4639
|
+
|
|
4640
|
+
logger.info('token refreshed', { token: session.token });
|
|
4641
|
+
|
|
4642
|
+
if (this.onRefreshToken) {
|
|
4643
|
+
this.onRefreshToken(session.token, session);
|
|
4644
|
+
}
|
|
4636
4645
|
|
|
4637
|
-
|
|
4638
|
-
this.onRefreshToken(session.token, session);
|
|
4639
|
-
}
|
|
4646
|
+
this.setToken(session.token);
|
|
4640
4647
|
|
|
4641
|
-
|
|
4648
|
+
return session.token;
|
|
4649
|
+
} catch (error) {
|
|
4650
|
+
logger.error('token refresh, error', error);
|
|
4642
4651
|
|
|
4643
|
-
|
|
4652
|
+
if (this.onRefreshTokenError) {
|
|
4653
|
+
this.onRefreshTokenError(error);
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4644
4656
|
}
|
|
4645
4657
|
|
|
4646
4658
|
setToken(token ) {
|
|
@@ -4663,6 +4675,10 @@ class ApiClient {
|
|
|
4663
4675
|
this.onRefreshToken = onRefreshToken;
|
|
4664
4676
|
}
|
|
4665
4677
|
|
|
4678
|
+
setOnRefreshTokenError(callback ) {
|
|
4679
|
+
this.onRefreshTokenError = callback;
|
|
4680
|
+
}
|
|
4681
|
+
|
|
4666
4682
|
setRefreshExpiration(refreshExpiration ) {
|
|
4667
4683
|
this.refreshExpiration = refreshExpiration;
|
|
4668
4684
|
}
|
|
@@ -4698,7 +4714,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4698
4714
|
global.wazoClientId = global.wazoClientId || {};
|
|
4699
4715
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4700
4716
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4717
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4701
4718
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4719
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4702
4720
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4703
4721
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4704
4722
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4714,12 +4732,20 @@ const fillClient = (apiClient ) => {
|
|
|
4714
4732
|
|
|
4715
4733
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4716
4734
|
|
|
4735
|
+
apiClient.setRefreshTenantId(
|
|
4736
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4737
|
+
);
|
|
4738
|
+
|
|
4717
4739
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4718
4740
|
|
|
4719
4741
|
apiClient.setOnRefreshToken(
|
|
4720
4742
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4721
4743
|
);
|
|
4722
4744
|
|
|
4745
|
+
apiClient.setOnRefreshTokenError(
|
|
4746
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4747
|
+
);
|
|
4748
|
+
|
|
4723
4749
|
apiClient.setRefreshExpiration(
|
|
4724
4750
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4725
4751
|
);
|
|
@@ -4733,7 +4759,7 @@ const fillClient = (apiClient ) => {
|
|
|
4733
4759
|
return apiClient;
|
|
4734
4760
|
};
|
|
4735
4761
|
|
|
4736
|
-
var getApiClient = (forServer
|
|
4762
|
+
var getApiClient = (forServer = null) => {
|
|
4737
4763
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4738
4764
|
if (server in global.wazoClients) {
|
|
4739
4765
|
return fillClient(global.wazoClients[server]);
|
package/lib/simple/Phone.js
CHANGED
|
@@ -2878,9 +2878,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2878
2878
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2879
2879
|
refresh_token: refreshToken,
|
|
2880
2880
|
client_id: client.clientId,
|
|
2881
|
-
tenant_id: tenantId,
|
|
2882
2881
|
};
|
|
2883
2882
|
|
|
2883
|
+
if (tenantId) {
|
|
2884
|
+
body.tenant_id = tenantId;
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2884
2887
|
const headers = {
|
|
2885
2888
|
'Content-Type': 'application/json',
|
|
2886
2889
|
...(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]);
|
|
@@ -8463,11 +8497,14 @@ class WebRTCClient extends Emitter {
|
|
|
8463
8497
|
}
|
|
8464
8498
|
|
|
8465
8499
|
async _disconnectTransport(force = false) {
|
|
8466
|
-
if (force) {
|
|
8500
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8467
8501
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8468
8502
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8469
|
-
|
|
8470
|
-
this.userAgent.transport._ws
|
|
8503
|
+
|
|
8504
|
+
if (this.userAgent.transport._ws) {
|
|
8505
|
+
this.userAgent.transport._ws.close(1000);
|
|
8506
|
+
}
|
|
8507
|
+
|
|
8471
8508
|
return;
|
|
8472
8509
|
}
|
|
8473
8510
|
|
|
@@ -9119,7 +9156,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9119
9156
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9120
9157
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9121
9158
|
// We have to downgrade to audio.
|
|
9122
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9159
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9123
9160
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9124
9161
|
|
|
9125
9162
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9563,7 +9600,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9563
9600
|
|
|
9564
9601
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9565
9602
|
|
|
9566
|
-
// Stop
|
|
9603
|
+
// Stop screenshare if needed
|
|
9567
9604
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9568
9605
|
this.lastScreenShare = this.currentScreenShare;
|
|
9569
9606
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10325,7 +10362,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10325
10362
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10326
10363
|
answered: state === sessionState.SessionState.Established,
|
|
10327
10364
|
paused: this.client.isCallHeld(sipSession),
|
|
10328
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10365
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10329
10366
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10330
10367
|
number,
|
|
10331
10368
|
ringing: false,
|
|
@@ -10409,6 +10446,7 @@ class Auth {
|
|
|
10409
10446
|
|
|
10410
10447
|
|
|
10411
10448
|
|
|
10449
|
+
|
|
10412
10450
|
|
|
10413
10451
|
|
|
10414
10452
|
|
|
@@ -10446,6 +10484,14 @@ class Auth {
|
|
|
10446
10484
|
this.onRefreshTokenCallback(token, session);
|
|
10447
10485
|
}
|
|
10448
10486
|
});
|
|
10487
|
+
|
|
10488
|
+
setOnRefreshTokenError(error => {
|
|
10489
|
+
logger$7.error('on refresh token error', error);
|
|
10490
|
+
|
|
10491
|
+
if (this.onRefreshTokenCallbackError) {
|
|
10492
|
+
this.onRefreshTokenCallbackError(error);
|
|
10493
|
+
}
|
|
10494
|
+
});
|
|
10449
10495
|
}
|
|
10450
10496
|
|
|
10451
10497
|
setFetchOptions(options ) {
|
|
@@ -10534,6 +10580,10 @@ class Auth {
|
|
|
10534
10580
|
this.onRefreshTokenCallback = callback;
|
|
10535
10581
|
}
|
|
10536
10582
|
|
|
10583
|
+
setOnRefreshTokenError(callback ) {
|
|
10584
|
+
this.onRefreshTokenCallbackError = callback;
|
|
10585
|
+
}
|
|
10586
|
+
|
|
10537
10587
|
checkAuthorizations(session , authorizationName ) {
|
|
10538
10588
|
if (!authorizationName) {
|
|
10539
10589
|
return;
|
|
@@ -10566,6 +10616,12 @@ class Auth {
|
|
|
10566
10616
|
setRefreshToken(refreshToken);
|
|
10567
10617
|
}
|
|
10568
10618
|
|
|
10619
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
10620
|
+
setRefreshTenantId(refreshTenantId);
|
|
10621
|
+
|
|
10622
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
10623
|
+
}
|
|
10624
|
+
|
|
10569
10625
|
forceRefreshToken() {
|
|
10570
10626
|
getApiClient().forceRefreshToken();
|
|
10571
10627
|
}
|