@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
|
@@ -2793,9 +2793,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2793
2793
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2794
2794
|
refresh_token: refreshToken,
|
|
2795
2795
|
client_id: client.clientId,
|
|
2796
|
-
tenant_id: tenantId,
|
|
2797
2796
|
};
|
|
2798
2797
|
|
|
2798
|
+
if (tenantId) {
|
|
2799
|
+
body.tenant_id = tenantId;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2799
2802
|
const headers = {
|
|
2800
2803
|
'Content-Type': 'application/json',
|
|
2801
2804
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4083,7 +4086,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4083
4086
|
global.wazoClientId = global.wazoClientId || {};
|
|
4084
4087
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4085
4088
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4089
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4086
4090
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4091
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4087
4092
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4088
4093
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4089
4094
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5129,6 +5134,7 @@ class ApiClient {
|
|
|
5129
5134
|
|
|
5130
5135
|
|
|
5131
5136
|
|
|
5137
|
+
|
|
5132
5138
|
|
|
5133
5139
|
|
|
5134
5140
|
|
|
@@ -5181,23 +5187,31 @@ class ApiClient {
|
|
|
5181
5187
|
return null;
|
|
5182
5188
|
}
|
|
5183
5189
|
|
|
5184
|
-
|
|
5185
|
-
this.refreshToken
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5190
|
+
try {
|
|
5191
|
+
const session = await this.auth.refreshToken(
|
|
5192
|
+
this.refreshToken,
|
|
5193
|
+
this.refreshBackend,
|
|
5194
|
+
this.refreshExpiration,
|
|
5195
|
+
this.isMobile,
|
|
5196
|
+
this.refreshTenantId,
|
|
5197
|
+
);
|
|
5198
|
+
|
|
5199
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5200
|
+
|
|
5201
|
+
if (this.onRefreshToken) {
|
|
5202
|
+
this.onRefreshToken(session.token, session);
|
|
5203
|
+
}
|
|
5191
5204
|
|
|
5192
|
-
|
|
5205
|
+
this.setToken(session.token);
|
|
5193
5206
|
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
this.setToken(session.token);
|
|
5207
|
+
return session.token;
|
|
5208
|
+
} catch (error) {
|
|
5209
|
+
logger$1.error('token refresh, error', error);
|
|
5199
5210
|
|
|
5200
|
-
|
|
5211
|
+
if (this.onRefreshTokenError) {
|
|
5212
|
+
this.onRefreshTokenError(error);
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5201
5215
|
}
|
|
5202
5216
|
|
|
5203
5217
|
setToken(token ) {
|
|
@@ -5220,6 +5234,10 @@ class ApiClient {
|
|
|
5220
5234
|
this.onRefreshToken = onRefreshToken;
|
|
5221
5235
|
}
|
|
5222
5236
|
|
|
5237
|
+
setOnRefreshTokenError(callback ) {
|
|
5238
|
+
this.onRefreshTokenError = callback;
|
|
5239
|
+
}
|
|
5240
|
+
|
|
5223
5241
|
setRefreshExpiration(refreshExpiration ) {
|
|
5224
5242
|
this.refreshExpiration = refreshExpiration;
|
|
5225
5243
|
}
|
|
@@ -2793,9 +2793,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2793
2793
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2794
2794
|
refresh_token: refreshToken,
|
|
2795
2795
|
client_id: client.clientId,
|
|
2796
|
-
tenant_id: tenantId,
|
|
2797
2796
|
};
|
|
2798
2797
|
|
|
2798
|
+
if (tenantId) {
|
|
2799
|
+
body.tenant_id = tenantId;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2799
2802
|
const headers = {
|
|
2800
2803
|
'Content-Type': 'application/json',
|
|
2801
2804
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4083,7 +4086,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4083
4086
|
global.wazoClientId = global.wazoClientId || {};
|
|
4084
4087
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4085
4088
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4089
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4086
4090
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4091
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4087
4092
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4088
4093
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4089
4094
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5129,6 +5134,7 @@ class ApiClient {
|
|
|
5129
5134
|
|
|
5130
5135
|
|
|
5131
5136
|
|
|
5137
|
+
|
|
5132
5138
|
|
|
5133
5139
|
|
|
5134
5140
|
|
|
@@ -5181,23 +5187,31 @@ class ApiClient {
|
|
|
5181
5187
|
return null;
|
|
5182
5188
|
}
|
|
5183
5189
|
|
|
5184
|
-
|
|
5185
|
-
this.refreshToken
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5190
|
+
try {
|
|
5191
|
+
const session = await this.auth.refreshToken(
|
|
5192
|
+
this.refreshToken,
|
|
5193
|
+
this.refreshBackend,
|
|
5194
|
+
this.refreshExpiration,
|
|
5195
|
+
this.isMobile,
|
|
5196
|
+
this.refreshTenantId,
|
|
5197
|
+
);
|
|
5198
|
+
|
|
5199
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5200
|
+
|
|
5201
|
+
if (this.onRefreshToken) {
|
|
5202
|
+
this.onRefreshToken(session.token, session);
|
|
5203
|
+
}
|
|
5191
5204
|
|
|
5192
|
-
|
|
5205
|
+
this.setToken(session.token);
|
|
5193
5206
|
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
this.setToken(session.token);
|
|
5207
|
+
return session.token;
|
|
5208
|
+
} catch (error) {
|
|
5209
|
+
logger$1.error('token refresh, error', error);
|
|
5199
5210
|
|
|
5200
|
-
|
|
5211
|
+
if (this.onRefreshTokenError) {
|
|
5212
|
+
this.onRefreshTokenError(error);
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5201
5215
|
}
|
|
5202
5216
|
|
|
5203
5217
|
setToken(token ) {
|
|
@@ -5220,6 +5234,10 @@ class ApiClient {
|
|
|
5220
5234
|
this.onRefreshToken = onRefreshToken;
|
|
5221
5235
|
}
|
|
5222
5236
|
|
|
5237
|
+
setOnRefreshTokenError(callback ) {
|
|
5238
|
+
this.onRefreshTokenError = callback;
|
|
5239
|
+
}
|
|
5240
|
+
|
|
5223
5241
|
setRefreshExpiration(refreshExpiration ) {
|
|
5224
5242
|
this.refreshExpiration = refreshExpiration;
|
|
5225
5243
|
}
|
|
@@ -2454,9 +2454,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2454
2454
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2455
2455
|
refresh_token: refreshToken,
|
|
2456
2456
|
client_id: client.clientId,
|
|
2457
|
-
tenant_id: tenantId,
|
|
2458
2457
|
};
|
|
2459
2458
|
|
|
2459
|
+
if (tenantId) {
|
|
2460
|
+
body.tenant_id = tenantId;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2460
2463
|
const headers = {
|
|
2461
2464
|
'Content-Type': 'application/json',
|
|
2462
2465
|
...(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/domain/Features.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]);
|
|
@@ -3205,9 +3205,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
3205
3205
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
3206
3206
|
refresh_token: refreshToken,
|
|
3207
3207
|
client_id: client.clientId,
|
|
3208
|
-
tenant_id: tenantId,
|
|
3209
3208
|
};
|
|
3210
3209
|
|
|
3210
|
+
if (tenantId) {
|
|
3211
|
+
body.tenant_id = tenantId;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3211
3214
|
const headers = {
|
|
3212
3215
|
'Content-Type': 'application/json',
|
|
3213
3216
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4979,6 +4982,7 @@ class ApiClient {
|
|
|
4979
4982
|
|
|
4980
4983
|
|
|
4981
4984
|
|
|
4985
|
+
|
|
4982
4986
|
|
|
4983
4987
|
|
|
4984
4988
|
|
|
@@ -5031,23 +5035,31 @@ class ApiClient {
|
|
|
5031
5035
|
return null;
|
|
5032
5036
|
}
|
|
5033
5037
|
|
|
5034
|
-
|
|
5035
|
-
this.refreshToken
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5038
|
+
try {
|
|
5039
|
+
const session = await this.auth.refreshToken(
|
|
5040
|
+
this.refreshToken,
|
|
5041
|
+
this.refreshBackend,
|
|
5042
|
+
this.refreshExpiration,
|
|
5043
|
+
this.isMobile,
|
|
5044
|
+
this.refreshTenantId,
|
|
5045
|
+
);
|
|
5046
|
+
|
|
5047
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5048
|
+
|
|
5049
|
+
if (this.onRefreshToken) {
|
|
5050
|
+
this.onRefreshToken(session.token, session);
|
|
5051
|
+
}
|
|
5043
5052
|
|
|
5044
|
-
|
|
5045
|
-
this.onRefreshToken(session.token, session);
|
|
5046
|
-
}
|
|
5053
|
+
this.setToken(session.token);
|
|
5047
5054
|
|
|
5048
|
-
|
|
5055
|
+
return session.token;
|
|
5056
|
+
} catch (error) {
|
|
5057
|
+
logger$1.error('token refresh, error', error);
|
|
5049
5058
|
|
|
5050
|
-
|
|
5059
|
+
if (this.onRefreshTokenError) {
|
|
5060
|
+
this.onRefreshTokenError(error);
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5051
5063
|
}
|
|
5052
5064
|
|
|
5053
5065
|
setToken(token ) {
|
|
@@ -5070,6 +5082,10 @@ class ApiClient {
|
|
|
5070
5082
|
this.onRefreshToken = onRefreshToken;
|
|
5071
5083
|
}
|
|
5072
5084
|
|
|
5085
|
+
setOnRefreshTokenError(callback ) {
|
|
5086
|
+
this.onRefreshTokenError = callback;
|
|
5087
|
+
}
|
|
5088
|
+
|
|
5073
5089
|
setRefreshExpiration(refreshExpiration ) {
|
|
5074
5090
|
this.refreshExpiration = refreshExpiration;
|
|
5075
5091
|
}
|
|
@@ -5105,7 +5121,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5105
5121
|
global.wazoClientId = global.wazoClientId || {};
|
|
5106
5122
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5107
5123
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5124
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5108
5125
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5126
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5109
5127
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5110
5128
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5111
5129
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5121,12 +5139,20 @@ const fillClient = (apiClient ) => {
|
|
|
5121
5139
|
|
|
5122
5140
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5123
5141
|
|
|
5142
|
+
apiClient.setRefreshTenantId(
|
|
5143
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5144
|
+
);
|
|
5145
|
+
|
|
5124
5146
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5125
5147
|
|
|
5126
5148
|
apiClient.setOnRefreshToken(
|
|
5127
5149
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5128
5150
|
);
|
|
5129
5151
|
|
|
5152
|
+
apiClient.setOnRefreshTokenError(
|
|
5153
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5154
|
+
);
|
|
5155
|
+
|
|
5130
5156
|
apiClient.setRefreshExpiration(
|
|
5131
5157
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5132
5158
|
);
|
|
@@ -5140,7 +5166,7 @@ const fillClient = (apiClient ) => {
|
|
|
5140
5166
|
return apiClient;
|
|
5141
5167
|
};
|
|
5142
5168
|
|
|
5143
|
-
var getApiClient = (forServer
|
|
5169
|
+
var getApiClient = (forServer = null) => {
|
|
5144
5170
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5145
5171
|
if (server in global.wazoClients) {
|
|
5146
5172
|
return fillClient(global.wazoClients[server]);
|
|
@@ -888,7 +888,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
888
888
|
global.wazoClientId = global.wazoClientId || {};
|
|
889
889
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
890
890
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
891
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
891
892
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
893
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
892
894
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
893
895
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
894
896
|
global.wazoIsMobile = global.wazoIsMobile || {};
|