@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
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);
|
|
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]);
|
|
@@ -10412,6 +10446,7 @@ class Auth {
|
|
|
10412
10446
|
|
|
10413
10447
|
|
|
10414
10448
|
|
|
10449
|
+
|
|
10415
10450
|
|
|
10416
10451
|
|
|
10417
10452
|
|
|
@@ -10449,6 +10484,14 @@ class Auth {
|
|
|
10449
10484
|
this.onRefreshTokenCallback(token, session);
|
|
10450
10485
|
}
|
|
10451
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
|
+
});
|
|
10452
10495
|
}
|
|
10453
10496
|
|
|
10454
10497
|
setFetchOptions(options ) {
|
|
@@ -10537,6 +10580,10 @@ class Auth {
|
|
|
10537
10580
|
this.onRefreshTokenCallback = callback;
|
|
10538
10581
|
}
|
|
10539
10582
|
|
|
10583
|
+
setOnRefreshTokenError(callback ) {
|
|
10584
|
+
this.onRefreshTokenCallbackError = callback;
|
|
10585
|
+
}
|
|
10586
|
+
|
|
10540
10587
|
checkAuthorizations(session , authorizationName ) {
|
|
10541
10588
|
if (!authorizationName) {
|
|
10542
10589
|
return;
|
|
@@ -10569,6 +10616,12 @@ class Auth {
|
|
|
10569
10616
|
setRefreshToken(refreshToken);
|
|
10570
10617
|
}
|
|
10571
10618
|
|
|
10619
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
10620
|
+
setRefreshTenantId(refreshTenantId);
|
|
10621
|
+
|
|
10622
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
10623
|
+
}
|
|
10624
|
+
|
|
10572
10625
|
forceRefreshToken() {
|
|
10573
10626
|
getApiClient().forceRefreshToken();
|
|
10574
10627
|
}
|
package/lib/simple/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|
}
|