@wazo/sdk 0.37.39 → 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/README.md +2 -1
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +33 -15
- package/esm/__tests__/web-rtc-client.test.js +39 -18
- 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 +39 -18
- package/esm/checker/checks/aor.js +33 -15
- package/esm/checker/checks/api.js +33 -15
- package/esm/checker/checks/index.js +39 -18
- package/esm/checker/checks/webrtc-transport.js +39 -18
- package/esm/checker/checks/webrtc.js +39 -18
- 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 +5 -3
- package/esm/index.js +77 -21
- package/esm/service/CallApi.js +42 -16
- package/esm/service/getApiClient.js +51 -17
- package/esm/simple/Auth.js +77 -21
- package/esm/simple/Configuration.js +77 -21
- package/esm/simple/Directory.js +42 -16
- package/esm/simple/Phone.js +77 -21
- package/esm/simple/index.js +77 -21
- package/esm/simple/room/LocalParticipant.js +77 -21
- package/esm/simple/room/Participant.js +77 -21
- package/esm/simple/room/RemoteParticipant.js +77 -21
- package/esm/simple/room/Room.js +77 -21
- package/esm/simple/room/SipRoom.js +77 -21
- package/esm/simple/room/Stream.js +77 -21
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/esm/simple/utils.js +77 -21
- package/esm/web-rtc-client.js +39 -18
- package/lib/__tests__/api-client.test.js +33 -15
- package/lib/__tests__/web-rtc-client.test.js +39 -18
- 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 +39 -18
- package/lib/checker/checks/aor.js +33 -15
- package/lib/checker/checks/api.js +33 -15
- package/lib/checker/checks/index.js +39 -18
- package/lib/checker/checks/webrtc-transport.js +39 -18
- package/lib/checker/checks/webrtc.js +39 -18
- 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 +5 -3
- package/lib/index.js +77 -21
- package/lib/service/CallApi.js +42 -16
- package/lib/service/getApiClient.js +52 -16
- package/lib/simple/Auth.js +77 -21
- package/lib/simple/Configuration.js +77 -21
- package/lib/simple/Directory.js +42 -16
- package/lib/simple/Phone.js +77 -21
- package/lib/simple/index.js +77 -21
- package/lib/simple/room/LocalParticipant.js +77 -21
- package/lib/simple/room/Participant.js +77 -21
- package/lib/simple/room/RemoteParticipant.js +77 -21
- package/lib/simple/room/Room.js +77 -21
- package/lib/simple/room/SipRoom.js +77 -21
- package/lib/simple/room/Stream.js +77 -21
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +77 -21
- package/lib/simple/utils.js +77 -21
- package/lib/web-rtc-client.js +39 -18
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/domain/Phone/WebRTCPhone.js +3 -3
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
- package/src/web-rtc-client.js +7 -4
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]);
|
|
@@ -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 || {};
|
|
@@ -4722,10 +4740,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4722
4740
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
4723
4741
|
};
|
|
4724
4742
|
|
|
4743
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4744
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4745
|
+
};
|
|
4746
|
+
|
|
4725
4747
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4726
4748
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4727
4749
|
};
|
|
4728
4750
|
|
|
4751
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4752
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4753
|
+
};
|
|
4754
|
+
|
|
4729
4755
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4730
4756
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4731
4757
|
};
|
|
@@ -4752,12 +4778,20 @@ const fillClient = (apiClient ) => {
|
|
|
4752
4778
|
|
|
4753
4779
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4754
4780
|
|
|
4781
|
+
apiClient.setRefreshTenantId(
|
|
4782
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4783
|
+
);
|
|
4784
|
+
|
|
4755
4785
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4756
4786
|
|
|
4757
4787
|
apiClient.setOnRefreshToken(
|
|
4758
4788
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4759
4789
|
);
|
|
4760
4790
|
|
|
4791
|
+
apiClient.setOnRefreshTokenError(
|
|
4792
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4793
|
+
);
|
|
4794
|
+
|
|
4761
4795
|
apiClient.setRefreshExpiration(
|
|
4762
4796
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4763
4797
|
);
|
|
@@ -4771,7 +4805,7 @@ const fillClient = (apiClient ) => {
|
|
|
4771
4805
|
return apiClient;
|
|
4772
4806
|
};
|
|
4773
4807
|
|
|
4774
|
-
var getApiClient = (forServer
|
|
4808
|
+
var getApiClient = (forServer = null) => {
|
|
4775
4809
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4776
4810
|
if (server in global.wazoClients) {
|
|
4777
4811
|
return fillClient(global.wazoClients[server]);
|
|
@@ -4789,6 +4823,8 @@ exports.setCurrentServer = setCurrentServer;
|
|
|
4789
4823
|
exports.setFetchOptions = setFetchOptions;
|
|
4790
4824
|
exports.setIsMobile = setIsMobile;
|
|
4791
4825
|
exports.setOnRefreshToken = setOnRefreshToken;
|
|
4826
|
+
exports.setOnRefreshTokenError = setOnRefreshTokenError;
|
|
4792
4827
|
exports.setRefreshBackend = setRefreshBackend;
|
|
4793
4828
|
exports.setRefreshExpiration = setRefreshExpiration;
|
|
4829
|
+
exports.setRefreshTenantId = setRefreshTenantId;
|
|
4794
4830
|
exports.setRefreshToken = setRefreshToken;
|
package/lib/simple/Auth.js
CHANGED
|
@@ -2277,9 +2277,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2277
2277
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2278
2278
|
refresh_token: refreshToken,
|
|
2279
2279
|
client_id: client.clientId,
|
|
2280
|
-
tenant_id: tenantId,
|
|
2281
2280
|
};
|
|
2282
2281
|
|
|
2282
|
+
if (tenantId) {
|
|
2283
|
+
body.tenant_id = tenantId;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2283
2286
|
const headers = {
|
|
2284
2287
|
'Content-Type': 'application/json',
|
|
2285
2288
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5427,6 +5430,7 @@ class ApiClient {
|
|
|
5427
5430
|
|
|
5428
5431
|
|
|
5429
5432
|
|
|
5433
|
+
|
|
5430
5434
|
|
|
5431
5435
|
|
|
5432
5436
|
|
|
@@ -5479,23 +5483,31 @@ class ApiClient {
|
|
|
5479
5483
|
return null;
|
|
5480
5484
|
}
|
|
5481
5485
|
|
|
5482
|
-
|
|
5483
|
-
this.refreshToken
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5486
|
+
try {
|
|
5487
|
+
const session = await this.auth.refreshToken(
|
|
5488
|
+
this.refreshToken,
|
|
5489
|
+
this.refreshBackend,
|
|
5490
|
+
this.refreshExpiration,
|
|
5491
|
+
this.isMobile,
|
|
5492
|
+
this.refreshTenantId,
|
|
5493
|
+
);
|
|
5489
5494
|
|
|
5490
|
-
|
|
5495
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5491
5496
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5497
|
+
if (this.onRefreshToken) {
|
|
5498
|
+
this.onRefreshToken(session.token, session);
|
|
5499
|
+
}
|
|
5495
5500
|
|
|
5496
|
-
|
|
5501
|
+
this.setToken(session.token);
|
|
5502
|
+
|
|
5503
|
+
return session.token;
|
|
5504
|
+
} catch (error) {
|
|
5505
|
+
logger$a.error('token refresh, error', error);
|
|
5497
5506
|
|
|
5498
|
-
|
|
5507
|
+
if (this.onRefreshTokenError) {
|
|
5508
|
+
this.onRefreshTokenError(error);
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5499
5511
|
}
|
|
5500
5512
|
|
|
5501
5513
|
setToken(token ) {
|
|
@@ -5518,6 +5530,10 @@ class ApiClient {
|
|
|
5518
5530
|
this.onRefreshToken = onRefreshToken;
|
|
5519
5531
|
}
|
|
5520
5532
|
|
|
5533
|
+
setOnRefreshTokenError(callback ) {
|
|
5534
|
+
this.onRefreshTokenError = callback;
|
|
5535
|
+
}
|
|
5536
|
+
|
|
5521
5537
|
setRefreshExpiration(refreshExpiration ) {
|
|
5522
5538
|
this.refreshExpiration = refreshExpiration;
|
|
5523
5539
|
}
|
|
@@ -5553,7 +5569,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5553
5569
|
global.wazoClientId = global.wazoClientId || {};
|
|
5554
5570
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5555
5571
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5572
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5556
5573
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5574
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5557
5575
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5558
5576
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5559
5577
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5575,10 +5593,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5575
5593
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5576
5594
|
};
|
|
5577
5595
|
|
|
5596
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5597
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5598
|
+
};
|
|
5599
|
+
|
|
5578
5600
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5579
5601
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5580
5602
|
};
|
|
5581
5603
|
|
|
5604
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5605
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5606
|
+
};
|
|
5607
|
+
|
|
5582
5608
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5583
5609
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5584
5610
|
};
|
|
@@ -5597,12 +5623,20 @@ const fillClient = (apiClient ) => {
|
|
|
5597
5623
|
|
|
5598
5624
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5599
5625
|
|
|
5626
|
+
apiClient.setRefreshTenantId(
|
|
5627
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5628
|
+
);
|
|
5629
|
+
|
|
5600
5630
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5601
5631
|
|
|
5602
5632
|
apiClient.setOnRefreshToken(
|
|
5603
5633
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5604
5634
|
);
|
|
5605
5635
|
|
|
5636
|
+
apiClient.setOnRefreshTokenError(
|
|
5637
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5638
|
+
);
|
|
5639
|
+
|
|
5606
5640
|
apiClient.setRefreshExpiration(
|
|
5607
5641
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5608
5642
|
);
|
|
@@ -5616,7 +5650,7 @@ const fillClient = (apiClient ) => {
|
|
|
5616
5650
|
return apiClient;
|
|
5617
5651
|
};
|
|
5618
5652
|
|
|
5619
|
-
var getApiClient = (forServer
|
|
5653
|
+
var getApiClient = (forServer = null) => {
|
|
5620
5654
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5621
5655
|
if (server in global.wazoClients) {
|
|
5622
5656
|
return fillClient(global.wazoClients[server]);
|
|
@@ -8465,11 +8499,14 @@ class WebRTCClient extends Emitter {
|
|
|
8465
8499
|
}
|
|
8466
8500
|
|
|
8467
8501
|
async _disconnectTransport(force = false) {
|
|
8468
|
-
if (force) {
|
|
8502
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
8469
8503
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
8470
8504
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
8471
|
-
|
|
8472
|
-
this.userAgent.transport._ws
|
|
8505
|
+
|
|
8506
|
+
if (this.userAgent.transport._ws) {
|
|
8507
|
+
this.userAgent.transport._ws.close(1000);
|
|
8508
|
+
}
|
|
8509
|
+
|
|
8473
8510
|
return;
|
|
8474
8511
|
}
|
|
8475
8512
|
|
|
@@ -9121,7 +9158,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9121
9158
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9122
9159
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9123
9160
|
// We have to downgrade to audio.
|
|
9124
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9161
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9125
9162
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9126
9163
|
|
|
9127
9164
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9565,7 +9602,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9565
9602
|
|
|
9566
9603
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9567
9604
|
|
|
9568
|
-
// Stop
|
|
9605
|
+
// Stop screenshare if needed
|
|
9569
9606
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9570
9607
|
this.lastScreenShare = this.currentScreenShare;
|
|
9571
9608
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10327,7 +10364,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10327
10364
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10328
10365
|
answered: state === sessionState.SessionState.Established,
|
|
10329
10366
|
paused: this.client.isCallHeld(sipSession),
|
|
10330
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10367
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10331
10368
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10332
10369
|
number,
|
|
10333
10370
|
ringing: false,
|
|
@@ -13727,6 +13764,7 @@ class Auth {
|
|
|
13727
13764
|
|
|
13728
13765
|
|
|
13729
13766
|
|
|
13767
|
+
|
|
13730
13768
|
|
|
13731
13769
|
|
|
13732
13770
|
|
|
@@ -13764,6 +13802,14 @@ class Auth {
|
|
|
13764
13802
|
this.onRefreshTokenCallback(token, session);
|
|
13765
13803
|
}
|
|
13766
13804
|
});
|
|
13805
|
+
|
|
13806
|
+
setOnRefreshTokenError(error => {
|
|
13807
|
+
logger.error('on refresh token error', error);
|
|
13808
|
+
|
|
13809
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13810
|
+
this.onRefreshTokenCallbackError(error);
|
|
13811
|
+
}
|
|
13812
|
+
});
|
|
13767
13813
|
}
|
|
13768
13814
|
|
|
13769
13815
|
setFetchOptions(options ) {
|
|
@@ -13852,6 +13898,10 @@ class Auth {
|
|
|
13852
13898
|
this.onRefreshTokenCallback = callback;
|
|
13853
13899
|
}
|
|
13854
13900
|
|
|
13901
|
+
setOnRefreshTokenError(callback ) {
|
|
13902
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13903
|
+
}
|
|
13904
|
+
|
|
13855
13905
|
checkAuthorizations(session , authorizationName ) {
|
|
13856
13906
|
if (!authorizationName) {
|
|
13857
13907
|
return;
|
|
@@ -13884,6 +13934,12 @@ class Auth {
|
|
|
13884
13934
|
setRefreshToken(refreshToken);
|
|
13885
13935
|
}
|
|
13886
13936
|
|
|
13937
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13938
|
+
setRefreshTenantId(refreshTenantId);
|
|
13939
|
+
|
|
13940
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13941
|
+
}
|
|
13942
|
+
|
|
13887
13943
|
forceRefreshToken() {
|
|
13888
13944
|
getApiClient().forceRefreshToken();
|
|
13889
13945
|
}
|