@wazo/sdk 0.37.41 → 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/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +33 -15
- package/esm/__tests__/web-rtc-client.test.js +33 -15
- 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 +33 -15
- package/esm/checker/checks/aor.js +33 -15
- package/esm/checker/checks/api.js +33 -15
- package/esm/checker/checks/index.js +33 -15
- package/esm/checker/checks/webrtc-transport.js +33 -15
- package/esm/checker/checks/webrtc.js +33 -15
- 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 +2 -0
- package/esm/index.js +68 -15
- package/esm/service/CallApi.js +42 -16
- package/esm/service/getApiClient.js +51 -17
- package/esm/simple/Auth.js +68 -15
- package/esm/simple/Configuration.js +68 -15
- package/esm/simple/Directory.js +42 -16
- package/esm/simple/Phone.js +68 -15
- package/esm/simple/index.js +68 -15
- package/esm/simple/room/LocalParticipant.js +68 -15
- package/esm/simple/room/Participant.js +68 -15
- package/esm/simple/room/RemoteParticipant.js +68 -15
- package/esm/simple/room/Room.js +68 -15
- package/esm/simple/room/SipRoom.js +68 -15
- package/esm/simple/room/Stream.js +68 -15
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +68 -15
- package/esm/simple/utils.js +68 -15
- package/esm/web-rtc-client.js +33 -15
- package/lib/__tests__/api-client.test.js +33 -15
- package/lib/__tests__/web-rtc-client.test.js +33 -15
- 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 +33 -15
- package/lib/checker/checks/aor.js +33 -15
- package/lib/checker/checks/api.js +33 -15
- package/lib/checker/checks/index.js +33 -15
- package/lib/checker/checks/webrtc-transport.js +33 -15
- package/lib/checker/checks/webrtc.js +33 -15
- 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 +2 -0
- package/lib/index.js +68 -15
- package/lib/service/CallApi.js +42 -16
- package/lib/service/getApiClient.js +52 -16
- package/lib/simple/Auth.js +68 -15
- package/lib/simple/Configuration.js +68 -15
- package/lib/simple/Directory.js +42 -16
- package/lib/simple/Phone.js +68 -15
- package/lib/simple/index.js +68 -15
- package/lib/simple/room/LocalParticipant.js +68 -15
- package/lib/simple/room/Participant.js +68 -15
- package/lib/simple/room/RemoteParticipant.js +68 -15
- package/lib/simple/room/Room.js +68 -15
- package/lib/simple/room/SipRoom.js +68 -15
- package/lib/simple/room/Stream.js +68 -15
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +68 -15
- package/lib/simple/utils.js +68 -15
- package/lib/web-rtc-client.js +33 -15
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
|
@@ -2301,9 +2301,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2301
2301
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2302
2302
|
refresh_token: refreshToken,
|
|
2303
2303
|
client_id: client.clientId,
|
|
2304
|
-
tenant_id: tenantId,
|
|
2305
2304
|
};
|
|
2306
2305
|
|
|
2306
|
+
if (tenantId) {
|
|
2307
|
+
body.tenant_id = tenantId;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2307
2310
|
const headers = {
|
|
2308
2311
|
'Content-Type': 'application/json',
|
|
2309
2312
|
...(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);
|
|
5495
5500
|
|
|
5496
|
-
|
|
5501
|
+
return session.token;
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
logger$a.error('token refresh, error', error);
|
|
5504
|
+
|
|
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
|
}
|
|
@@ -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);
|
|
5495
5500
|
|
|
5496
|
-
|
|
5501
|
+
return session.token;
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
logger$a.error('token refresh, error', error);
|
|
5504
|
+
|
|
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
|
}
|
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);
|
|
5497
5502
|
|
|
5498
|
-
|
|
5503
|
+
return session.token;
|
|
5504
|
+
} catch (error) {
|
|
5505
|
+
logger$a.error('token refresh, error', error);
|
|
5506
|
+
|
|
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
|
}
|