@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
|
@@ -2460,9 +2460,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2460
2460
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2461
2461
|
refresh_token: refreshToken,
|
|
2462
2462
|
client_id: client.clientId,
|
|
2463
|
-
tenant_id: tenantId,
|
|
2464
2463
|
};
|
|
2465
2464
|
|
|
2465
|
+
if (tenantId) {
|
|
2466
|
+
body.tenant_id = tenantId;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2466
2469
|
const headers = {
|
|
2467
2470
|
'Content-Type': 'application/json',
|
|
2468
2471
|
...(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/domain/Features.js
CHANGED
|
@@ -2253,9 +2253,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2253
2253
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2254
2254
|
refresh_token: refreshToken,
|
|
2255
2255
|
client_id: client.clientId,
|
|
2256
|
-
tenant_id: tenantId,
|
|
2257
2256
|
};
|
|
2258
2257
|
|
|
2258
|
+
if (tenantId) {
|
|
2259
|
+
body.tenant_id = tenantId;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2259
2262
|
const headers = {
|
|
2260
2263
|
'Content-Type': 'application/json',
|
|
2261
2264
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4574,6 +4577,7 @@ class ApiClient {
|
|
|
4574
4577
|
|
|
4575
4578
|
|
|
4576
4579
|
|
|
4580
|
+
|
|
4577
4581
|
|
|
4578
4582
|
|
|
4579
4583
|
|
|
@@ -4626,23 +4630,31 @@ class ApiClient {
|
|
|
4626
4630
|
return null;
|
|
4627
4631
|
}
|
|
4628
4632
|
|
|
4629
|
-
|
|
4630
|
-
this.refreshToken
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4633
|
+
try {
|
|
4634
|
+
const session = await this.auth.refreshToken(
|
|
4635
|
+
this.refreshToken,
|
|
4636
|
+
this.refreshBackend,
|
|
4637
|
+
this.refreshExpiration,
|
|
4638
|
+
this.isMobile,
|
|
4639
|
+
this.refreshTenantId,
|
|
4640
|
+
);
|
|
4641
|
+
|
|
4642
|
+
logger.info('token refreshed', { token: session.token });
|
|
4643
|
+
|
|
4644
|
+
if (this.onRefreshToken) {
|
|
4645
|
+
this.onRefreshToken(session.token, session);
|
|
4646
|
+
}
|
|
4638
4647
|
|
|
4639
|
-
|
|
4640
|
-
this.onRefreshToken(session.token, session);
|
|
4641
|
-
}
|
|
4648
|
+
this.setToken(session.token);
|
|
4642
4649
|
|
|
4643
|
-
|
|
4650
|
+
return session.token;
|
|
4651
|
+
} catch (error) {
|
|
4652
|
+
logger.error('token refresh, error', error);
|
|
4644
4653
|
|
|
4645
|
-
|
|
4654
|
+
if (this.onRefreshTokenError) {
|
|
4655
|
+
this.onRefreshTokenError(error);
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4646
4658
|
}
|
|
4647
4659
|
|
|
4648
4660
|
setToken(token ) {
|
|
@@ -4665,6 +4677,10 @@ class ApiClient {
|
|
|
4665
4677
|
this.onRefreshToken = onRefreshToken;
|
|
4666
4678
|
}
|
|
4667
4679
|
|
|
4680
|
+
setOnRefreshTokenError(callback ) {
|
|
4681
|
+
this.onRefreshTokenError = callback;
|
|
4682
|
+
}
|
|
4683
|
+
|
|
4668
4684
|
setRefreshExpiration(refreshExpiration ) {
|
|
4669
4685
|
this.refreshExpiration = refreshExpiration;
|
|
4670
4686
|
}
|
|
@@ -4700,7 +4716,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4700
4716
|
global.wazoClientId = global.wazoClientId || {};
|
|
4701
4717
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4702
4718
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4719
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4703
4720
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4721
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4704
4722
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4705
4723
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4706
4724
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4716,12 +4734,20 @@ const fillClient = (apiClient ) => {
|
|
|
4716
4734
|
|
|
4717
4735
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4718
4736
|
|
|
4737
|
+
apiClient.setRefreshTenantId(
|
|
4738
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4739
|
+
);
|
|
4740
|
+
|
|
4719
4741
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4720
4742
|
|
|
4721
4743
|
apiClient.setOnRefreshToken(
|
|
4722
4744
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4723
4745
|
);
|
|
4724
4746
|
|
|
4747
|
+
apiClient.setOnRefreshTokenError(
|
|
4748
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4749
|
+
);
|
|
4750
|
+
|
|
4725
4751
|
apiClient.setRefreshExpiration(
|
|
4726
4752
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4727
4753
|
);
|
|
@@ -4735,7 +4761,7 @@ const fillClient = (apiClient ) => {
|
|
|
4735
4761
|
return apiClient;
|
|
4736
4762
|
};
|
|
4737
4763
|
|
|
4738
|
-
var getApiClient = (forServer
|
|
4764
|
+
var getApiClient = (forServer = null) => {
|
|
4739
4765
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4740
4766
|
if (server in global.wazoClients) {
|
|
4741
4767
|
return fillClient(global.wazoClients[server]);
|
|
@@ -3214,9 +3214,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
3214
3214
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
3215
3215
|
refresh_token: refreshToken,
|
|
3216
3216
|
client_id: client.clientId,
|
|
3217
|
-
tenant_id: tenantId,
|
|
3218
3217
|
};
|
|
3219
3218
|
|
|
3219
|
+
if (tenantId) {
|
|
3220
|
+
body.tenant_id = tenantId;
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3220
3223
|
const headers = {
|
|
3221
3224
|
'Content-Type': 'application/json',
|
|
3222
3225
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4988,6 +4991,7 @@ class ApiClient {
|
|
|
4988
4991
|
|
|
4989
4992
|
|
|
4990
4993
|
|
|
4994
|
+
|
|
4991
4995
|
|
|
4992
4996
|
|
|
4993
4997
|
|
|
@@ -5040,23 +5044,31 @@ class ApiClient {
|
|
|
5040
5044
|
return null;
|
|
5041
5045
|
}
|
|
5042
5046
|
|
|
5043
|
-
|
|
5044
|
-
this.refreshToken
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5047
|
+
try {
|
|
5048
|
+
const session = await this.auth.refreshToken(
|
|
5049
|
+
this.refreshToken,
|
|
5050
|
+
this.refreshBackend,
|
|
5051
|
+
this.refreshExpiration,
|
|
5052
|
+
this.isMobile,
|
|
5053
|
+
this.refreshTenantId,
|
|
5054
|
+
);
|
|
5055
|
+
|
|
5056
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5057
|
+
|
|
5058
|
+
if (this.onRefreshToken) {
|
|
5059
|
+
this.onRefreshToken(session.token, session);
|
|
5060
|
+
}
|
|
5052
5061
|
|
|
5053
|
-
|
|
5054
|
-
this.onRefreshToken(session.token, session);
|
|
5055
|
-
}
|
|
5062
|
+
this.setToken(session.token);
|
|
5056
5063
|
|
|
5057
|
-
|
|
5064
|
+
return session.token;
|
|
5065
|
+
} catch (error) {
|
|
5066
|
+
logger$1.error('token refresh, error', error);
|
|
5058
5067
|
|
|
5059
|
-
|
|
5068
|
+
if (this.onRefreshTokenError) {
|
|
5069
|
+
this.onRefreshTokenError(error);
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5060
5072
|
}
|
|
5061
5073
|
|
|
5062
5074
|
setToken(token ) {
|
|
@@ -5079,6 +5091,10 @@ class ApiClient {
|
|
|
5079
5091
|
this.onRefreshToken = onRefreshToken;
|
|
5080
5092
|
}
|
|
5081
5093
|
|
|
5094
|
+
setOnRefreshTokenError(callback ) {
|
|
5095
|
+
this.onRefreshTokenError = callback;
|
|
5096
|
+
}
|
|
5097
|
+
|
|
5082
5098
|
setRefreshExpiration(refreshExpiration ) {
|
|
5083
5099
|
this.refreshExpiration = refreshExpiration;
|
|
5084
5100
|
}
|
|
@@ -5114,7 +5130,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5114
5130
|
global.wazoClientId = global.wazoClientId || {};
|
|
5115
5131
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5116
5132
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5133
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5117
5134
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5135
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5118
5136
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5119
5137
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5120
5138
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5130,12 +5148,20 @@ const fillClient = (apiClient ) => {
|
|
|
5130
5148
|
|
|
5131
5149
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5132
5150
|
|
|
5151
|
+
apiClient.setRefreshTenantId(
|
|
5152
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5153
|
+
);
|
|
5154
|
+
|
|
5133
5155
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5134
5156
|
|
|
5135
5157
|
apiClient.setOnRefreshToken(
|
|
5136
5158
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5137
5159
|
);
|
|
5138
5160
|
|
|
5161
|
+
apiClient.setOnRefreshTokenError(
|
|
5162
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5163
|
+
);
|
|
5164
|
+
|
|
5139
5165
|
apiClient.setRefreshExpiration(
|
|
5140
5166
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5141
5167
|
);
|
|
@@ -5149,7 +5175,7 @@ const fillClient = (apiClient ) => {
|
|
|
5149
5175
|
return apiClient;
|
|
5150
5176
|
};
|
|
5151
5177
|
|
|
5152
|
-
var getApiClient = (forServer
|
|
5178
|
+
var getApiClient = (forServer = null) => {
|
|
5153
5179
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5154
5180
|
if (server in global.wazoClients) {
|
|
5155
5181
|
return fillClient(global.wazoClients[server]);
|
|
@@ -897,7 +897,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
897
897
|
global.wazoClientId = global.wazoClientId || {};
|
|
898
898
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
899
899
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
900
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
900
901
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
902
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
901
903
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
902
904
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
903
905
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
package/lib/index.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' } : {}),
|
|
@@ -3987,7 +3990,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3987
3990
|
global.wazoClientId = global.wazoClientId || {};
|
|
3988
3991
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3989
3992
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3993
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3990
3994
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3995
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3991
3996
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3992
3997
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3993
3998
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4009,10 +4014,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4009
4014
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
4010
4015
|
};
|
|
4011
4016
|
|
|
4017
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4018
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4019
|
+
};
|
|
4020
|
+
|
|
4012
4021
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4013
4022
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4014
4023
|
};
|
|
4015
4024
|
|
|
4025
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4026
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4027
|
+
};
|
|
4028
|
+
|
|
4016
4029
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4017
4030
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4018
4031
|
};
|
|
@@ -4031,12 +4044,20 @@ const fillClient = (apiClient ) => {
|
|
|
4031
4044
|
|
|
4032
4045
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4033
4046
|
|
|
4047
|
+
apiClient.setRefreshTenantId(
|
|
4048
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4049
|
+
);
|
|
4050
|
+
|
|
4034
4051
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4035
4052
|
|
|
4036
4053
|
apiClient.setOnRefreshToken(
|
|
4037
4054
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4038
4055
|
);
|
|
4039
4056
|
|
|
4057
|
+
apiClient.setOnRefreshTokenError(
|
|
4058
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4059
|
+
);
|
|
4060
|
+
|
|
4040
4061
|
apiClient.setRefreshExpiration(
|
|
4041
4062
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4042
4063
|
);
|
|
@@ -4050,7 +4071,7 @@ const fillClient = (apiClient ) => {
|
|
|
4050
4071
|
return apiClient;
|
|
4051
4072
|
};
|
|
4052
4073
|
|
|
4053
|
-
var getApiClient = (forServer
|
|
4074
|
+
var getApiClient = (forServer = null) => {
|
|
4054
4075
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4055
4076
|
if (server in global.wazoClients) {
|
|
4056
4077
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5510,6 +5531,7 @@ class ApiClient {
|
|
|
5510
5531
|
|
|
5511
5532
|
|
|
5512
5533
|
|
|
5534
|
+
|
|
5513
5535
|
|
|
5514
5536
|
|
|
5515
5537
|
|
|
@@ -5562,23 +5584,31 @@ class ApiClient {
|
|
|
5562
5584
|
return null;
|
|
5563
5585
|
}
|
|
5564
5586
|
|
|
5565
|
-
|
|
5566
|
-
this.refreshToken
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5587
|
+
try {
|
|
5588
|
+
const session = await this.auth.refreshToken(
|
|
5589
|
+
this.refreshToken,
|
|
5590
|
+
this.refreshBackend,
|
|
5591
|
+
this.refreshExpiration,
|
|
5592
|
+
this.isMobile,
|
|
5593
|
+
this.refreshTenantId,
|
|
5594
|
+
);
|
|
5572
5595
|
|
|
5573
|
-
|
|
5596
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5574
5597
|
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5598
|
+
if (this.onRefreshToken) {
|
|
5599
|
+
this.onRefreshToken(session.token, session);
|
|
5600
|
+
}
|
|
5578
5601
|
|
|
5579
|
-
|
|
5602
|
+
this.setToken(session.token);
|
|
5580
5603
|
|
|
5581
|
-
|
|
5604
|
+
return session.token;
|
|
5605
|
+
} catch (error) {
|
|
5606
|
+
logger$a.error('token refresh, error', error);
|
|
5607
|
+
|
|
5608
|
+
if (this.onRefreshTokenError) {
|
|
5609
|
+
this.onRefreshTokenError(error);
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5582
5612
|
}
|
|
5583
5613
|
|
|
5584
5614
|
setToken(token ) {
|
|
@@ -5601,6 +5631,10 @@ class ApiClient {
|
|
|
5601
5631
|
this.onRefreshToken = onRefreshToken;
|
|
5602
5632
|
}
|
|
5603
5633
|
|
|
5634
|
+
setOnRefreshTokenError(callback ) {
|
|
5635
|
+
this.onRefreshTokenError = callback;
|
|
5636
|
+
}
|
|
5637
|
+
|
|
5604
5638
|
setRefreshExpiration(refreshExpiration ) {
|
|
5605
5639
|
this.refreshExpiration = refreshExpiration;
|
|
5606
5640
|
}
|
|
@@ -11732,6 +11766,7 @@ class Auth {
|
|
|
11732
11766
|
|
|
11733
11767
|
|
|
11734
11768
|
|
|
11769
|
+
|
|
11735
11770
|
|
|
11736
11771
|
|
|
11737
11772
|
|
|
@@ -11769,6 +11804,14 @@ class Auth {
|
|
|
11769
11804
|
this.onRefreshTokenCallback(token, session);
|
|
11770
11805
|
}
|
|
11771
11806
|
});
|
|
11807
|
+
|
|
11808
|
+
setOnRefreshTokenError(error => {
|
|
11809
|
+
logger$5.error('on refresh token error', error);
|
|
11810
|
+
|
|
11811
|
+
if (this.onRefreshTokenCallbackError) {
|
|
11812
|
+
this.onRefreshTokenCallbackError(error);
|
|
11813
|
+
}
|
|
11814
|
+
});
|
|
11772
11815
|
}
|
|
11773
11816
|
|
|
11774
11817
|
setFetchOptions(options ) {
|
|
@@ -11857,6 +11900,10 @@ class Auth {
|
|
|
11857
11900
|
this.onRefreshTokenCallback = callback;
|
|
11858
11901
|
}
|
|
11859
11902
|
|
|
11903
|
+
setOnRefreshTokenError(callback ) {
|
|
11904
|
+
this.onRefreshTokenCallbackError = callback;
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11860
11907
|
checkAuthorizations(session , authorizationName ) {
|
|
11861
11908
|
if (!authorizationName) {
|
|
11862
11909
|
return;
|
|
@@ -11889,6 +11936,12 @@ class Auth {
|
|
|
11889
11936
|
setRefreshToken(refreshToken);
|
|
11890
11937
|
}
|
|
11891
11938
|
|
|
11939
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
11940
|
+
setRefreshTenantId(refreshTenantId);
|
|
11941
|
+
|
|
11942
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
11943
|
+
}
|
|
11944
|
+
|
|
11892
11945
|
forceRefreshToken() {
|
|
11893
11946
|
getApiClient().forceRefreshToken();
|
|
11894
11947
|
}
|
package/lib/service/CallApi.js
CHANGED
|
@@ -2791,9 +2791,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2791
2791
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2792
2792
|
refresh_token: refreshToken,
|
|
2793
2793
|
client_id: client.clientId,
|
|
2794
|
-
tenant_id: tenantId,
|
|
2795
2794
|
};
|
|
2796
2795
|
|
|
2796
|
+
if (tenantId) {
|
|
2797
|
+
body.tenant_id = tenantId;
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2797
2800
|
const headers = {
|
|
2798
2801
|
'Content-Type': 'application/json',
|
|
2799
2802
|
...(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]);
|