@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
|
@@ -2265,9 +2265,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2265
2265
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2266
2266
|
refresh_token: refreshToken,
|
|
2267
2267
|
client_id: client.clientId,
|
|
2268
|
-
tenant_id: tenantId,
|
|
2269
2268
|
};
|
|
2270
2269
|
|
|
2270
|
+
if (tenantId) {
|
|
2271
|
+
body.tenant_id = tenantId;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2271
2274
|
const headers = {
|
|
2272
2275
|
'Content-Type': 'application/json',
|
|
2273
2276
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5415,6 +5418,7 @@ class ApiClient {
|
|
|
5415
5418
|
|
|
5416
5419
|
|
|
5417
5420
|
|
|
5421
|
+
|
|
5418
5422
|
|
|
5419
5423
|
|
|
5420
5424
|
|
|
@@ -5467,23 +5471,31 @@ class ApiClient {
|
|
|
5467
5471
|
return null;
|
|
5468
5472
|
}
|
|
5469
5473
|
|
|
5470
|
-
|
|
5471
|
-
this.refreshToken
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5474
|
+
try {
|
|
5475
|
+
const session = await this.auth.refreshToken(
|
|
5476
|
+
this.refreshToken,
|
|
5477
|
+
this.refreshBackend,
|
|
5478
|
+
this.refreshExpiration,
|
|
5479
|
+
this.isMobile,
|
|
5480
|
+
this.refreshTenantId,
|
|
5481
|
+
);
|
|
5477
5482
|
|
|
5478
|
-
|
|
5483
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5479
5484
|
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5485
|
+
if (this.onRefreshToken) {
|
|
5486
|
+
this.onRefreshToken(session.token, session);
|
|
5487
|
+
}
|
|
5483
5488
|
|
|
5484
|
-
|
|
5489
|
+
this.setToken(session.token);
|
|
5485
5490
|
|
|
5486
|
-
|
|
5491
|
+
return session.token;
|
|
5492
|
+
} catch (error) {
|
|
5493
|
+
logger$a.error('token refresh, error', error);
|
|
5494
|
+
|
|
5495
|
+
if (this.onRefreshTokenError) {
|
|
5496
|
+
this.onRefreshTokenError(error);
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5487
5499
|
}
|
|
5488
5500
|
|
|
5489
5501
|
setToken(token ) {
|
|
@@ -5506,6 +5518,10 @@ class ApiClient {
|
|
|
5506
5518
|
this.onRefreshToken = onRefreshToken;
|
|
5507
5519
|
}
|
|
5508
5520
|
|
|
5521
|
+
setOnRefreshTokenError(callback ) {
|
|
5522
|
+
this.onRefreshTokenError = callback;
|
|
5523
|
+
}
|
|
5524
|
+
|
|
5509
5525
|
setRefreshExpiration(refreshExpiration ) {
|
|
5510
5526
|
this.refreshExpiration = refreshExpiration;
|
|
5511
5527
|
}
|
|
@@ -5541,7 +5557,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5541
5557
|
global.wazoClientId = global.wazoClientId || {};
|
|
5542
5558
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5543
5559
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5560
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5544
5561
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5562
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5545
5563
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5546
5564
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5547
5565
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5563,10 +5581,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5563
5581
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5564
5582
|
};
|
|
5565
5583
|
|
|
5584
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5585
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5586
|
+
};
|
|
5587
|
+
|
|
5566
5588
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5567
5589
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5568
5590
|
};
|
|
5569
5591
|
|
|
5592
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5593
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5594
|
+
};
|
|
5595
|
+
|
|
5570
5596
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5571
5597
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5572
5598
|
};
|
|
@@ -5585,12 +5611,20 @@ const fillClient = (apiClient ) => {
|
|
|
5585
5611
|
|
|
5586
5612
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5587
5613
|
|
|
5614
|
+
apiClient.setRefreshTenantId(
|
|
5615
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5616
|
+
);
|
|
5617
|
+
|
|
5588
5618
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5589
5619
|
|
|
5590
5620
|
apiClient.setOnRefreshToken(
|
|
5591
5621
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5592
5622
|
);
|
|
5593
5623
|
|
|
5624
|
+
apiClient.setOnRefreshTokenError(
|
|
5625
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5626
|
+
);
|
|
5627
|
+
|
|
5594
5628
|
apiClient.setRefreshExpiration(
|
|
5595
5629
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5596
5630
|
);
|
|
@@ -5604,7 +5638,7 @@ const fillClient = (apiClient ) => {
|
|
|
5604
5638
|
return apiClient;
|
|
5605
5639
|
};
|
|
5606
5640
|
|
|
5607
|
-
var getApiClient = (forServer
|
|
5641
|
+
var getApiClient = (forServer = null) => {
|
|
5608
5642
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5609
5643
|
if (server in global.wazoClients) {
|
|
5610
5644
|
return fillClient(global.wazoClients[server]);
|
|
@@ -13701,6 +13735,7 @@ class Auth {
|
|
|
13701
13735
|
|
|
13702
13736
|
|
|
13703
13737
|
|
|
13738
|
+
|
|
13704
13739
|
|
|
13705
13740
|
|
|
13706
13741
|
|
|
@@ -13738,6 +13773,14 @@ class Auth {
|
|
|
13738
13773
|
this.onRefreshTokenCallback(token, session);
|
|
13739
13774
|
}
|
|
13740
13775
|
});
|
|
13776
|
+
|
|
13777
|
+
setOnRefreshTokenError(error => {
|
|
13778
|
+
logger.error('on refresh token error', error);
|
|
13779
|
+
|
|
13780
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13781
|
+
this.onRefreshTokenCallbackError(error);
|
|
13782
|
+
}
|
|
13783
|
+
});
|
|
13741
13784
|
}
|
|
13742
13785
|
|
|
13743
13786
|
setFetchOptions(options ) {
|
|
@@ -13826,6 +13869,10 @@ class Auth {
|
|
|
13826
13869
|
this.onRefreshTokenCallback = callback;
|
|
13827
13870
|
}
|
|
13828
13871
|
|
|
13872
|
+
setOnRefreshTokenError(callback ) {
|
|
13873
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13874
|
+
}
|
|
13875
|
+
|
|
13829
13876
|
checkAuthorizations(session , authorizationName ) {
|
|
13830
13877
|
if (!authorizationName) {
|
|
13831
13878
|
return;
|
|
@@ -13858,6 +13905,12 @@ class Auth {
|
|
|
13858
13905
|
setRefreshToken(refreshToken);
|
|
13859
13906
|
}
|
|
13860
13907
|
|
|
13908
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13909
|
+
setRefreshTenantId(refreshTenantId);
|
|
13910
|
+
|
|
13911
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13912
|
+
}
|
|
13913
|
+
|
|
13861
13914
|
forceRefreshToken() {
|
|
13862
13915
|
getApiClient().forceRefreshToken();
|
|
13863
13916
|
}
|
package/esm/simple/Directory.js
CHANGED
|
@@ -2245,9 +2245,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2245
2245
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2246
2246
|
refresh_token: refreshToken,
|
|
2247
2247
|
client_id: client.clientId,
|
|
2248
|
-
tenant_id: tenantId,
|
|
2249
2248
|
};
|
|
2250
2249
|
|
|
2250
|
+
if (tenantId) {
|
|
2251
|
+
body.tenant_id = tenantId;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2251
2254
|
const headers = {
|
|
2252
2255
|
'Content-Type': 'application/json',
|
|
2253
2256
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4566,6 +4569,7 @@ class ApiClient {
|
|
|
4566
4569
|
|
|
4567
4570
|
|
|
4568
4571
|
|
|
4572
|
+
|
|
4569
4573
|
|
|
4570
4574
|
|
|
4571
4575
|
|
|
@@ -4618,23 +4622,31 @@ class ApiClient {
|
|
|
4618
4622
|
return null;
|
|
4619
4623
|
}
|
|
4620
4624
|
|
|
4621
|
-
|
|
4622
|
-
this.refreshToken
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4625
|
+
try {
|
|
4626
|
+
const session = await this.auth.refreshToken(
|
|
4627
|
+
this.refreshToken,
|
|
4628
|
+
this.refreshBackend,
|
|
4629
|
+
this.refreshExpiration,
|
|
4630
|
+
this.isMobile,
|
|
4631
|
+
this.refreshTenantId,
|
|
4632
|
+
);
|
|
4633
|
+
|
|
4634
|
+
logger.info('token refreshed', { token: session.token });
|
|
4635
|
+
|
|
4636
|
+
if (this.onRefreshToken) {
|
|
4637
|
+
this.onRefreshToken(session.token, session);
|
|
4638
|
+
}
|
|
4630
4639
|
|
|
4631
|
-
|
|
4632
|
-
this.onRefreshToken(session.token, session);
|
|
4633
|
-
}
|
|
4640
|
+
this.setToken(session.token);
|
|
4634
4641
|
|
|
4635
|
-
|
|
4642
|
+
return session.token;
|
|
4643
|
+
} catch (error) {
|
|
4644
|
+
logger.error('token refresh, error', error);
|
|
4636
4645
|
|
|
4637
|
-
|
|
4646
|
+
if (this.onRefreshTokenError) {
|
|
4647
|
+
this.onRefreshTokenError(error);
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4638
4650
|
}
|
|
4639
4651
|
|
|
4640
4652
|
setToken(token ) {
|
|
@@ -4657,6 +4669,10 @@ class ApiClient {
|
|
|
4657
4669
|
this.onRefreshToken = onRefreshToken;
|
|
4658
4670
|
}
|
|
4659
4671
|
|
|
4672
|
+
setOnRefreshTokenError(callback ) {
|
|
4673
|
+
this.onRefreshTokenError = callback;
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4660
4676
|
setRefreshExpiration(refreshExpiration ) {
|
|
4661
4677
|
this.refreshExpiration = refreshExpiration;
|
|
4662
4678
|
}
|
|
@@ -4692,7 +4708,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4692
4708
|
global.wazoClientId = global.wazoClientId || {};
|
|
4693
4709
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4694
4710
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4711
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4695
4712
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4713
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4696
4714
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4697
4715
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4698
4716
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4708,12 +4726,20 @@ const fillClient = (apiClient ) => {
|
|
|
4708
4726
|
|
|
4709
4727
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4710
4728
|
|
|
4729
|
+
apiClient.setRefreshTenantId(
|
|
4730
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4731
|
+
);
|
|
4732
|
+
|
|
4711
4733
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4712
4734
|
|
|
4713
4735
|
apiClient.setOnRefreshToken(
|
|
4714
4736
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4715
4737
|
);
|
|
4716
4738
|
|
|
4739
|
+
apiClient.setOnRefreshTokenError(
|
|
4740
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4741
|
+
);
|
|
4742
|
+
|
|
4717
4743
|
apiClient.setRefreshExpiration(
|
|
4718
4744
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4719
4745
|
);
|
|
@@ -4727,7 +4753,7 @@ const fillClient = (apiClient ) => {
|
|
|
4727
4753
|
return apiClient;
|
|
4728
4754
|
};
|
|
4729
4755
|
|
|
4730
|
-
var getApiClient = (forServer
|
|
4756
|
+
var getApiClient = (forServer = null) => {
|
|
4731
4757
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4732
4758
|
if (server in global.wazoClients) {
|
|
4733
4759
|
return fillClient(global.wazoClients[server]);
|
package/esm/simple/Phone.js
CHANGED
|
@@ -2868,9 +2868,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2868
2868
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2869
2869
|
refresh_token: refreshToken,
|
|
2870
2870
|
client_id: client.clientId,
|
|
2871
|
-
tenant_id: tenantId,
|
|
2872
2871
|
};
|
|
2873
2872
|
|
|
2873
|
+
if (tenantId) {
|
|
2874
|
+
body.tenant_id = tenantId;
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2874
2877
|
const headers = {
|
|
2875
2878
|
'Content-Type': 'application/json',
|
|
2876
2879
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5415,6 +5418,7 @@ class ApiClient {
|
|
|
5415
5418
|
|
|
5416
5419
|
|
|
5417
5420
|
|
|
5421
|
+
|
|
5418
5422
|
|
|
5419
5423
|
|
|
5420
5424
|
|
|
@@ -5467,23 +5471,31 @@ class ApiClient {
|
|
|
5467
5471
|
return null;
|
|
5468
5472
|
}
|
|
5469
5473
|
|
|
5470
|
-
|
|
5471
|
-
this.refreshToken
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5474
|
+
try {
|
|
5475
|
+
const session = await this.auth.refreshToken(
|
|
5476
|
+
this.refreshToken,
|
|
5477
|
+
this.refreshBackend,
|
|
5478
|
+
this.refreshExpiration,
|
|
5479
|
+
this.isMobile,
|
|
5480
|
+
this.refreshTenantId,
|
|
5481
|
+
);
|
|
5477
5482
|
|
|
5478
|
-
|
|
5483
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5479
5484
|
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5485
|
+
if (this.onRefreshToken) {
|
|
5486
|
+
this.onRefreshToken(session.token, session);
|
|
5487
|
+
}
|
|
5483
5488
|
|
|
5484
|
-
|
|
5489
|
+
this.setToken(session.token);
|
|
5485
5490
|
|
|
5486
|
-
|
|
5491
|
+
return session.token;
|
|
5492
|
+
} catch (error) {
|
|
5493
|
+
logger$a.error('token refresh, error', error);
|
|
5494
|
+
|
|
5495
|
+
if (this.onRefreshTokenError) {
|
|
5496
|
+
this.onRefreshTokenError(error);
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5487
5499
|
}
|
|
5488
5500
|
|
|
5489
5501
|
setToken(token ) {
|
|
@@ -5506,6 +5518,10 @@ class ApiClient {
|
|
|
5506
5518
|
this.onRefreshToken = onRefreshToken;
|
|
5507
5519
|
}
|
|
5508
5520
|
|
|
5521
|
+
setOnRefreshTokenError(callback ) {
|
|
5522
|
+
this.onRefreshTokenError = callback;
|
|
5523
|
+
}
|
|
5524
|
+
|
|
5509
5525
|
setRefreshExpiration(refreshExpiration ) {
|
|
5510
5526
|
this.refreshExpiration = refreshExpiration;
|
|
5511
5527
|
}
|
|
@@ -5541,7 +5557,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5541
5557
|
global.wazoClientId = global.wazoClientId || {};
|
|
5542
5558
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5543
5559
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5560
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5544
5561
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5562
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5545
5563
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5546
5564
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5547
5565
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5563,10 +5581,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5563
5581
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5564
5582
|
};
|
|
5565
5583
|
|
|
5584
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5585
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5586
|
+
};
|
|
5587
|
+
|
|
5566
5588
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5567
5589
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5568
5590
|
};
|
|
5569
5591
|
|
|
5592
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5593
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5594
|
+
};
|
|
5595
|
+
|
|
5570
5596
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5571
5597
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5572
5598
|
};
|
|
@@ -5585,12 +5611,20 @@ const fillClient = (apiClient ) => {
|
|
|
5585
5611
|
|
|
5586
5612
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5587
5613
|
|
|
5614
|
+
apiClient.setRefreshTenantId(
|
|
5615
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5616
|
+
);
|
|
5617
|
+
|
|
5588
5618
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5589
5619
|
|
|
5590
5620
|
apiClient.setOnRefreshToken(
|
|
5591
5621
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5592
5622
|
);
|
|
5593
5623
|
|
|
5624
|
+
apiClient.setOnRefreshTokenError(
|
|
5625
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5626
|
+
);
|
|
5627
|
+
|
|
5594
5628
|
apiClient.setRefreshExpiration(
|
|
5595
5629
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5596
5630
|
);
|
|
@@ -5604,7 +5638,7 @@ const fillClient = (apiClient ) => {
|
|
|
5604
5638
|
return apiClient;
|
|
5605
5639
|
};
|
|
5606
5640
|
|
|
5607
|
-
var getApiClient = (forServer
|
|
5641
|
+
var getApiClient = (forServer = null) => {
|
|
5608
5642
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5609
5643
|
if (server in global.wazoClients) {
|
|
5610
5644
|
return fillClient(global.wazoClients[server]);
|
|
@@ -10402,6 +10436,7 @@ class Auth {
|
|
|
10402
10436
|
|
|
10403
10437
|
|
|
10404
10438
|
|
|
10439
|
+
|
|
10405
10440
|
|
|
10406
10441
|
|
|
10407
10442
|
|
|
@@ -10439,6 +10474,14 @@ class Auth {
|
|
|
10439
10474
|
this.onRefreshTokenCallback(token, session);
|
|
10440
10475
|
}
|
|
10441
10476
|
});
|
|
10477
|
+
|
|
10478
|
+
setOnRefreshTokenError(error => {
|
|
10479
|
+
logger$7.error('on refresh token error', error);
|
|
10480
|
+
|
|
10481
|
+
if (this.onRefreshTokenCallbackError) {
|
|
10482
|
+
this.onRefreshTokenCallbackError(error);
|
|
10483
|
+
}
|
|
10484
|
+
});
|
|
10442
10485
|
}
|
|
10443
10486
|
|
|
10444
10487
|
setFetchOptions(options ) {
|
|
@@ -10527,6 +10570,10 @@ class Auth {
|
|
|
10527
10570
|
this.onRefreshTokenCallback = callback;
|
|
10528
10571
|
}
|
|
10529
10572
|
|
|
10573
|
+
setOnRefreshTokenError(callback ) {
|
|
10574
|
+
this.onRefreshTokenCallbackError = callback;
|
|
10575
|
+
}
|
|
10576
|
+
|
|
10530
10577
|
checkAuthorizations(session , authorizationName ) {
|
|
10531
10578
|
if (!authorizationName) {
|
|
10532
10579
|
return;
|
|
@@ -10559,6 +10606,12 @@ class Auth {
|
|
|
10559
10606
|
setRefreshToken(refreshToken);
|
|
10560
10607
|
}
|
|
10561
10608
|
|
|
10609
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
10610
|
+
setRefreshTenantId(refreshTenantId);
|
|
10611
|
+
|
|
10612
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
10613
|
+
}
|
|
10614
|
+
|
|
10562
10615
|
forceRefreshToken() {
|
|
10563
10616
|
getApiClient().forceRefreshToken();
|
|
10564
10617
|
}
|
package/esm/simple/index.js
CHANGED
|
@@ -2265,9 +2265,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2265
2265
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2266
2266
|
refresh_token: refreshToken,
|
|
2267
2267
|
client_id: client.clientId,
|
|
2268
|
-
tenant_id: tenantId,
|
|
2269
2268
|
};
|
|
2270
2269
|
|
|
2270
|
+
if (tenantId) {
|
|
2271
|
+
body.tenant_id = tenantId;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2271
2274
|
const headers = {
|
|
2272
2275
|
'Content-Type': 'application/json',
|
|
2273
2276
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5415,6 +5418,7 @@ class ApiClient {
|
|
|
5415
5418
|
|
|
5416
5419
|
|
|
5417
5420
|
|
|
5421
|
+
|
|
5418
5422
|
|
|
5419
5423
|
|
|
5420
5424
|
|
|
@@ -5467,23 +5471,31 @@ class ApiClient {
|
|
|
5467
5471
|
return null;
|
|
5468
5472
|
}
|
|
5469
5473
|
|
|
5470
|
-
|
|
5471
|
-
this.refreshToken
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5474
|
+
try {
|
|
5475
|
+
const session = await this.auth.refreshToken(
|
|
5476
|
+
this.refreshToken,
|
|
5477
|
+
this.refreshBackend,
|
|
5478
|
+
this.refreshExpiration,
|
|
5479
|
+
this.isMobile,
|
|
5480
|
+
this.refreshTenantId,
|
|
5481
|
+
);
|
|
5477
5482
|
|
|
5478
|
-
|
|
5483
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5479
5484
|
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5485
|
+
if (this.onRefreshToken) {
|
|
5486
|
+
this.onRefreshToken(session.token, session);
|
|
5487
|
+
}
|
|
5483
5488
|
|
|
5484
|
-
|
|
5489
|
+
this.setToken(session.token);
|
|
5485
5490
|
|
|
5486
|
-
|
|
5491
|
+
return session.token;
|
|
5492
|
+
} catch (error) {
|
|
5493
|
+
logger$a.error('token refresh, error', error);
|
|
5494
|
+
|
|
5495
|
+
if (this.onRefreshTokenError) {
|
|
5496
|
+
this.onRefreshTokenError(error);
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5487
5499
|
}
|
|
5488
5500
|
|
|
5489
5501
|
setToken(token ) {
|
|
@@ -5506,6 +5518,10 @@ class ApiClient {
|
|
|
5506
5518
|
this.onRefreshToken = onRefreshToken;
|
|
5507
5519
|
}
|
|
5508
5520
|
|
|
5521
|
+
setOnRefreshTokenError(callback ) {
|
|
5522
|
+
this.onRefreshTokenError = callback;
|
|
5523
|
+
}
|
|
5524
|
+
|
|
5509
5525
|
setRefreshExpiration(refreshExpiration ) {
|
|
5510
5526
|
this.refreshExpiration = refreshExpiration;
|
|
5511
5527
|
}
|
|
@@ -5541,7 +5557,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5541
5557
|
global.wazoClientId = global.wazoClientId || {};
|
|
5542
5558
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5543
5559
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5560
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5544
5561
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5562
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5545
5563
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5546
5564
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5547
5565
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5563,10 +5581,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5563
5581
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5564
5582
|
};
|
|
5565
5583
|
|
|
5584
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5585
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5586
|
+
};
|
|
5587
|
+
|
|
5566
5588
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5567
5589
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5568
5590
|
};
|
|
5569
5591
|
|
|
5592
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5593
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5594
|
+
};
|
|
5595
|
+
|
|
5570
5596
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5571
5597
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5572
5598
|
};
|
|
@@ -5585,12 +5611,20 @@ const fillClient = (apiClient ) => {
|
|
|
5585
5611
|
|
|
5586
5612
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5587
5613
|
|
|
5614
|
+
apiClient.setRefreshTenantId(
|
|
5615
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5616
|
+
);
|
|
5617
|
+
|
|
5588
5618
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5589
5619
|
|
|
5590
5620
|
apiClient.setOnRefreshToken(
|
|
5591
5621
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5592
5622
|
);
|
|
5593
5623
|
|
|
5624
|
+
apiClient.setOnRefreshTokenError(
|
|
5625
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5626
|
+
);
|
|
5627
|
+
|
|
5594
5628
|
apiClient.setRefreshExpiration(
|
|
5595
5629
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5596
5630
|
);
|
|
@@ -5604,7 +5638,7 @@ const fillClient = (apiClient ) => {
|
|
|
5604
5638
|
return apiClient;
|
|
5605
5639
|
};
|
|
5606
5640
|
|
|
5607
|
-
var getApiClient = (forServer
|
|
5641
|
+
var getApiClient = (forServer = null) => {
|
|
5608
5642
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5609
5643
|
if (server in global.wazoClients) {
|
|
5610
5644
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5631,6 +5665,7 @@ class Auth {
|
|
|
5631
5665
|
|
|
5632
5666
|
|
|
5633
5667
|
|
|
5668
|
+
|
|
5634
5669
|
|
|
5635
5670
|
|
|
5636
5671
|
|
|
@@ -5668,6 +5703,14 @@ class Auth {
|
|
|
5668
5703
|
this.onRefreshTokenCallback(token, session);
|
|
5669
5704
|
}
|
|
5670
5705
|
});
|
|
5706
|
+
|
|
5707
|
+
setOnRefreshTokenError(error => {
|
|
5708
|
+
logger$9.error('on refresh token error', error);
|
|
5709
|
+
|
|
5710
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5711
|
+
this.onRefreshTokenCallbackError(error);
|
|
5712
|
+
}
|
|
5713
|
+
});
|
|
5671
5714
|
}
|
|
5672
5715
|
|
|
5673
5716
|
setFetchOptions(options ) {
|
|
@@ -5756,6 +5799,10 @@ class Auth {
|
|
|
5756
5799
|
this.onRefreshTokenCallback = callback;
|
|
5757
5800
|
}
|
|
5758
5801
|
|
|
5802
|
+
setOnRefreshTokenError(callback ) {
|
|
5803
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5759
5806
|
checkAuthorizations(session , authorizationName ) {
|
|
5760
5807
|
if (!authorizationName) {
|
|
5761
5808
|
return;
|
|
@@ -5788,6 +5835,12 @@ class Auth {
|
|
|
5788
5835
|
setRefreshToken(refreshToken);
|
|
5789
5836
|
}
|
|
5790
5837
|
|
|
5838
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5839
|
+
setRefreshTenantId(refreshTenantId);
|
|
5840
|
+
|
|
5841
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5842
|
+
}
|
|
5843
|
+
|
|
5791
5844
|
forceRefreshToken() {
|
|
5792
5845
|
getApiClient().forceRefreshToken();
|
|
5793
5846
|
}
|