@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/checker/Checker.js
CHANGED
|
@@ -2273,9 +2273,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2273
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2274
2274
|
refresh_token: refreshToken,
|
|
2275
2275
|
client_id: client.clientId,
|
|
2276
|
-
tenant_id: tenantId,
|
|
2277
2276
|
};
|
|
2278
2277
|
|
|
2278
|
+
if (tenantId) {
|
|
2279
|
+
body.tenant_id = tenantId;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2279
2282
|
const headers = {
|
|
2280
2283
|
'Content-Type': 'application/json',
|
|
2281
2284
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3589,7 +3592,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3589
3592
|
global.wazoClientId = global.wazoClientId || {};
|
|
3590
3593
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3591
3594
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3595
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3592
3596
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3597
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3593
3598
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3594
3599
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3595
3600
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4635,6 +4640,7 @@ class ApiClient {
|
|
|
4635
4640
|
|
|
4636
4641
|
|
|
4637
4642
|
|
|
4643
|
+
|
|
4638
4644
|
|
|
4639
4645
|
|
|
4640
4646
|
|
|
@@ -4687,23 +4693,31 @@ class ApiClient {
|
|
|
4687
4693
|
return null;
|
|
4688
4694
|
}
|
|
4689
4695
|
|
|
4690
|
-
|
|
4691
|
-
this.refreshToken
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4696
|
+
try {
|
|
4697
|
+
const session = await this.auth.refreshToken(
|
|
4698
|
+
this.refreshToken,
|
|
4699
|
+
this.refreshBackend,
|
|
4700
|
+
this.refreshExpiration,
|
|
4701
|
+
this.isMobile,
|
|
4702
|
+
this.refreshTenantId,
|
|
4703
|
+
);
|
|
4704
|
+
|
|
4705
|
+
logger$3.info('token refreshed', { token: session.token });
|
|
4706
|
+
|
|
4707
|
+
if (this.onRefreshToken) {
|
|
4708
|
+
this.onRefreshToken(session.token, session);
|
|
4709
|
+
}
|
|
4699
4710
|
|
|
4700
|
-
|
|
4701
|
-
this.onRefreshToken(session.token, session);
|
|
4702
|
-
}
|
|
4711
|
+
this.setToken(session.token);
|
|
4703
4712
|
|
|
4704
|
-
|
|
4713
|
+
return session.token;
|
|
4714
|
+
} catch (error) {
|
|
4715
|
+
logger$3.error('token refresh, error', error);
|
|
4705
4716
|
|
|
4706
|
-
|
|
4717
|
+
if (this.onRefreshTokenError) {
|
|
4718
|
+
this.onRefreshTokenError(error);
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4707
4721
|
}
|
|
4708
4722
|
|
|
4709
4723
|
setToken(token ) {
|
|
@@ -4726,6 +4740,10 @@ class ApiClient {
|
|
|
4726
4740
|
this.onRefreshToken = onRefreshToken;
|
|
4727
4741
|
}
|
|
4728
4742
|
|
|
4743
|
+
setOnRefreshTokenError(callback ) {
|
|
4744
|
+
this.onRefreshTokenError = callback;
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4729
4747
|
setRefreshExpiration(refreshExpiration ) {
|
|
4730
4748
|
this.refreshExpiration = refreshExpiration;
|
|
4731
4749
|
}
|
|
@@ -7992,11 +8010,14 @@ class WebRTCClient extends Emitter {
|
|
|
7992
8010
|
}
|
|
7993
8011
|
|
|
7994
8012
|
async _disconnectTransport(force = false) {
|
|
7995
|
-
if (force) {
|
|
8013
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
7996
8014
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
7997
8015
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
7998
|
-
|
|
7999
|
-
this.userAgent.transport._ws
|
|
8016
|
+
|
|
8017
|
+
if (this.userAgent.transport._ws) {
|
|
8018
|
+
this.userAgent.transport._ws.close(1000);
|
|
8019
|
+
}
|
|
8020
|
+
|
|
8000
8021
|
return;
|
|
8001
8022
|
}
|
|
8002
8023
|
|
|
@@ -2251,9 +2251,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2251
2251
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2252
2252
|
refresh_token: refreshToken,
|
|
2253
2253
|
client_id: client.clientId,
|
|
2254
|
-
tenant_id: tenantId,
|
|
2255
2254
|
};
|
|
2256
2255
|
|
|
2256
|
+
if (tenantId) {
|
|
2257
|
+
body.tenant_id = tenantId;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2257
2260
|
const headers = {
|
|
2258
2261
|
'Content-Type': 'application/json',
|
|
2259
2262
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3541,7 +3544,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3541
3544
|
global.wazoClientId = global.wazoClientId || {};
|
|
3542
3545
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3543
3546
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3547
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3544
3548
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3549
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3545
3550
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3546
3551
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3547
3552
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4587,6 +4592,7 @@ class ApiClient {
|
|
|
4587
4592
|
|
|
4588
4593
|
|
|
4589
4594
|
|
|
4595
|
+
|
|
4590
4596
|
|
|
4591
4597
|
|
|
4592
4598
|
|
|
@@ -4639,23 +4645,31 @@ class ApiClient {
|
|
|
4639
4645
|
return null;
|
|
4640
4646
|
}
|
|
4641
4647
|
|
|
4642
|
-
|
|
4643
|
-
this.refreshToken
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4648
|
+
try {
|
|
4649
|
+
const session = await this.auth.refreshToken(
|
|
4650
|
+
this.refreshToken,
|
|
4651
|
+
this.refreshBackend,
|
|
4652
|
+
this.refreshExpiration,
|
|
4653
|
+
this.isMobile,
|
|
4654
|
+
this.refreshTenantId,
|
|
4655
|
+
);
|
|
4656
|
+
|
|
4657
|
+
logger.info('token refreshed', { token: session.token });
|
|
4658
|
+
|
|
4659
|
+
if (this.onRefreshToken) {
|
|
4660
|
+
this.onRefreshToken(session.token, session);
|
|
4661
|
+
}
|
|
4651
4662
|
|
|
4652
|
-
|
|
4653
|
-
this.onRefreshToken(session.token, session);
|
|
4654
|
-
}
|
|
4663
|
+
this.setToken(session.token);
|
|
4655
4664
|
|
|
4656
|
-
|
|
4665
|
+
return session.token;
|
|
4666
|
+
} catch (error) {
|
|
4667
|
+
logger.error('token refresh, error', error);
|
|
4657
4668
|
|
|
4658
|
-
|
|
4669
|
+
if (this.onRefreshTokenError) {
|
|
4670
|
+
this.onRefreshTokenError(error);
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4659
4673
|
}
|
|
4660
4674
|
|
|
4661
4675
|
setToken(token ) {
|
|
@@ -4678,6 +4692,10 @@ class ApiClient {
|
|
|
4678
4692
|
this.onRefreshToken = onRefreshToken;
|
|
4679
4693
|
}
|
|
4680
4694
|
|
|
4695
|
+
setOnRefreshTokenError(callback ) {
|
|
4696
|
+
this.onRefreshTokenError = callback;
|
|
4697
|
+
}
|
|
4698
|
+
|
|
4681
4699
|
setRefreshExpiration(refreshExpiration ) {
|
|
4682
4700
|
this.refreshExpiration = refreshExpiration;
|
|
4683
4701
|
}
|
|
@@ -2251,9 +2251,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2251
2251
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2252
2252
|
refresh_token: refreshToken,
|
|
2253
2253
|
client_id: client.clientId,
|
|
2254
|
-
tenant_id: tenantId,
|
|
2255
2254
|
};
|
|
2256
2255
|
|
|
2256
|
+
if (tenantId) {
|
|
2257
|
+
body.tenant_id = tenantId;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2257
2260
|
const headers = {
|
|
2258
2261
|
'Content-Type': 'application/json',
|
|
2259
2262
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3541,7 +3544,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3541
3544
|
global.wazoClientId = global.wazoClientId || {};
|
|
3542
3545
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3543
3546
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3547
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3544
3548
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3549
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3545
3550
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3546
3551
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3547
3552
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4587,6 +4592,7 @@ class ApiClient {
|
|
|
4587
4592
|
|
|
4588
4593
|
|
|
4589
4594
|
|
|
4595
|
+
|
|
4590
4596
|
|
|
4591
4597
|
|
|
4592
4598
|
|
|
@@ -4639,23 +4645,31 @@ class ApiClient {
|
|
|
4639
4645
|
return null;
|
|
4640
4646
|
}
|
|
4641
4647
|
|
|
4642
|
-
|
|
4643
|
-
this.refreshToken
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4648
|
+
try {
|
|
4649
|
+
const session = await this.auth.refreshToken(
|
|
4650
|
+
this.refreshToken,
|
|
4651
|
+
this.refreshBackend,
|
|
4652
|
+
this.refreshExpiration,
|
|
4653
|
+
this.isMobile,
|
|
4654
|
+
this.refreshTenantId,
|
|
4655
|
+
);
|
|
4656
|
+
|
|
4657
|
+
logger.info('token refreshed', { token: session.token });
|
|
4658
|
+
|
|
4659
|
+
if (this.onRefreshToken) {
|
|
4660
|
+
this.onRefreshToken(session.token, session);
|
|
4661
|
+
}
|
|
4651
4662
|
|
|
4652
|
-
|
|
4653
|
-
this.onRefreshToken(session.token, session);
|
|
4654
|
-
}
|
|
4663
|
+
this.setToken(session.token);
|
|
4655
4664
|
|
|
4656
|
-
|
|
4665
|
+
return session.token;
|
|
4666
|
+
} catch (error) {
|
|
4667
|
+
logger.error('token refresh, error', error);
|
|
4657
4668
|
|
|
4658
|
-
|
|
4669
|
+
if (this.onRefreshTokenError) {
|
|
4670
|
+
this.onRefreshTokenError(error);
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4659
4673
|
}
|
|
4660
4674
|
|
|
4661
4675
|
setToken(token ) {
|
|
@@ -4678,6 +4692,10 @@ class ApiClient {
|
|
|
4678
4692
|
this.onRefreshToken = onRefreshToken;
|
|
4679
4693
|
}
|
|
4680
4694
|
|
|
4695
|
+
setOnRefreshTokenError(callback ) {
|
|
4696
|
+
this.onRefreshTokenError = callback;
|
|
4697
|
+
}
|
|
4698
|
+
|
|
4681
4699
|
setRefreshExpiration(refreshExpiration ) {
|
|
4682
4700
|
this.refreshExpiration = refreshExpiration;
|
|
4683
4701
|
}
|
|
@@ -2273,9 +2273,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2273
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2274
2274
|
refresh_token: refreshToken,
|
|
2275
2275
|
client_id: client.clientId,
|
|
2276
|
-
tenant_id: tenantId,
|
|
2277
2276
|
};
|
|
2278
2277
|
|
|
2278
|
+
if (tenantId) {
|
|
2279
|
+
body.tenant_id = tenantId;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2279
2282
|
const headers = {
|
|
2280
2283
|
'Content-Type': 'application/json',
|
|
2281
2284
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3589,7 +3592,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3589
3592
|
global.wazoClientId = global.wazoClientId || {};
|
|
3590
3593
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3591
3594
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3595
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3592
3596
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3597
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3593
3598
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3594
3599
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3595
3600
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4635,6 +4640,7 @@ class ApiClient {
|
|
|
4635
4640
|
|
|
4636
4641
|
|
|
4637
4642
|
|
|
4643
|
+
|
|
4638
4644
|
|
|
4639
4645
|
|
|
4640
4646
|
|
|
@@ -4687,23 +4693,31 @@ class ApiClient {
|
|
|
4687
4693
|
return null;
|
|
4688
4694
|
}
|
|
4689
4695
|
|
|
4690
|
-
|
|
4691
|
-
this.refreshToken
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4696
|
+
try {
|
|
4697
|
+
const session = await this.auth.refreshToken(
|
|
4698
|
+
this.refreshToken,
|
|
4699
|
+
this.refreshBackend,
|
|
4700
|
+
this.refreshExpiration,
|
|
4701
|
+
this.isMobile,
|
|
4702
|
+
this.refreshTenantId,
|
|
4703
|
+
);
|
|
4704
|
+
|
|
4705
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
4706
|
+
|
|
4707
|
+
if (this.onRefreshToken) {
|
|
4708
|
+
this.onRefreshToken(session.token, session);
|
|
4709
|
+
}
|
|
4699
4710
|
|
|
4700
|
-
|
|
4701
|
-
this.onRefreshToken(session.token, session);
|
|
4702
|
-
}
|
|
4711
|
+
this.setToken(session.token);
|
|
4703
4712
|
|
|
4704
|
-
|
|
4713
|
+
return session.token;
|
|
4714
|
+
} catch (error) {
|
|
4715
|
+
logger$2.error('token refresh, error', error);
|
|
4705
4716
|
|
|
4706
|
-
|
|
4717
|
+
if (this.onRefreshTokenError) {
|
|
4718
|
+
this.onRefreshTokenError(error);
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4707
4721
|
}
|
|
4708
4722
|
|
|
4709
4723
|
setToken(token ) {
|
|
@@ -4726,6 +4740,10 @@ class ApiClient {
|
|
|
4726
4740
|
this.onRefreshToken = onRefreshToken;
|
|
4727
4741
|
}
|
|
4728
4742
|
|
|
4743
|
+
setOnRefreshTokenError(callback ) {
|
|
4744
|
+
this.onRefreshTokenError = callback;
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4729
4747
|
setRefreshExpiration(refreshExpiration ) {
|
|
4730
4748
|
this.refreshExpiration = refreshExpiration;
|
|
4731
4749
|
}
|
|
@@ -7992,11 +8010,14 @@ class WebRTCClient extends Emitter {
|
|
|
7992
8010
|
}
|
|
7993
8011
|
|
|
7994
8012
|
async _disconnectTransport(force = false) {
|
|
7995
|
-
if (force) {
|
|
8013
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
7996
8014
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
7997
8015
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
7998
|
-
|
|
7999
|
-
this.userAgent.transport._ws
|
|
8016
|
+
|
|
8017
|
+
if (this.userAgent.transport._ws) {
|
|
8018
|
+
this.userAgent.transport._ws.close(1000);
|
|
8019
|
+
}
|
|
8020
|
+
|
|
8000
8021
|
return;
|
|
8001
8022
|
}
|
|
8002
8023
|
|
|
@@ -2802,9 +2802,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2802
2802
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2803
2803
|
refresh_token: refreshToken,
|
|
2804
2804
|
client_id: client.clientId,
|
|
2805
|
-
tenant_id: tenantId,
|
|
2806
2805
|
};
|
|
2807
2806
|
|
|
2807
|
+
if (tenantId) {
|
|
2808
|
+
body.tenant_id = tenantId;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2808
2811
|
const headers = {
|
|
2809
2812
|
'Content-Type': 'application/json',
|
|
2810
2813
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4092,7 +4095,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4092
4095
|
global.wazoClientId = global.wazoClientId || {};
|
|
4093
4096
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4094
4097
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4098
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4095
4099
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4100
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4096
4101
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4097
4102
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4098
4103
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5138,6 +5143,7 @@ class ApiClient {
|
|
|
5138
5143
|
|
|
5139
5144
|
|
|
5140
5145
|
|
|
5146
|
+
|
|
5141
5147
|
|
|
5142
5148
|
|
|
5143
5149
|
|
|
@@ -5190,23 +5196,31 @@ class ApiClient {
|
|
|
5190
5196
|
return null;
|
|
5191
5197
|
}
|
|
5192
5198
|
|
|
5193
|
-
|
|
5194
|
-
this.refreshToken
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5199
|
+
try {
|
|
5200
|
+
const session = await this.auth.refreshToken(
|
|
5201
|
+
this.refreshToken,
|
|
5202
|
+
this.refreshBackend,
|
|
5203
|
+
this.refreshExpiration,
|
|
5204
|
+
this.isMobile,
|
|
5205
|
+
this.refreshTenantId,
|
|
5206
|
+
);
|
|
5207
|
+
|
|
5208
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5209
|
+
|
|
5210
|
+
if (this.onRefreshToken) {
|
|
5211
|
+
this.onRefreshToken(session.token, session);
|
|
5212
|
+
}
|
|
5202
5213
|
|
|
5203
|
-
|
|
5204
|
-
this.onRefreshToken(session.token, session);
|
|
5205
|
-
}
|
|
5214
|
+
this.setToken(session.token);
|
|
5206
5215
|
|
|
5207
|
-
|
|
5216
|
+
return session.token;
|
|
5217
|
+
} catch (error) {
|
|
5218
|
+
logger$1.error('token refresh, error', error);
|
|
5208
5219
|
|
|
5209
|
-
|
|
5220
|
+
if (this.onRefreshTokenError) {
|
|
5221
|
+
this.onRefreshTokenError(error);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5210
5224
|
}
|
|
5211
5225
|
|
|
5212
5226
|
setToken(token ) {
|
|
@@ -5229,6 +5243,10 @@ class ApiClient {
|
|
|
5229
5243
|
this.onRefreshToken = onRefreshToken;
|
|
5230
5244
|
}
|
|
5231
5245
|
|
|
5246
|
+
setOnRefreshTokenError(callback ) {
|
|
5247
|
+
this.onRefreshTokenError = callback;
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5232
5250
|
setRefreshExpiration(refreshExpiration ) {
|
|
5233
5251
|
this.refreshExpiration = refreshExpiration;
|
|
5234
5252
|
}
|
|
@@ -7406,11 +7424,14 @@ class WebRTCClient extends Emitter {
|
|
|
7406
7424
|
}
|
|
7407
7425
|
|
|
7408
7426
|
async _disconnectTransport(force = false) {
|
|
7409
|
-
if (force) {
|
|
7427
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
7410
7428
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
7411
7429
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
7412
|
-
|
|
7413
|
-
this.userAgent.transport._ws
|
|
7430
|
+
|
|
7431
|
+
if (this.userAgent.transport._ws) {
|
|
7432
|
+
this.userAgent.transport._ws.close(1000);
|
|
7433
|
+
}
|
|
7434
|
+
|
|
7414
7435
|
return;
|
|
7415
7436
|
}
|
|
7416
7437
|
|
|
@@ -2802,9 +2802,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2802
2802
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2803
2803
|
refresh_token: refreshToken,
|
|
2804
2804
|
client_id: client.clientId,
|
|
2805
|
-
tenant_id: tenantId,
|
|
2806
2805
|
};
|
|
2807
2806
|
|
|
2807
|
+
if (tenantId) {
|
|
2808
|
+
body.tenant_id = tenantId;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2808
2811
|
const headers = {
|
|
2809
2812
|
'Content-Type': 'application/json',
|
|
2810
2813
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4092,7 +4095,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4092
4095
|
global.wazoClientId = global.wazoClientId || {};
|
|
4093
4096
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4094
4097
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4098
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4095
4099
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4100
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4096
4101
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4097
4102
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4098
4103
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5138,6 +5143,7 @@ class ApiClient {
|
|
|
5138
5143
|
|
|
5139
5144
|
|
|
5140
5145
|
|
|
5146
|
+
|
|
5141
5147
|
|
|
5142
5148
|
|
|
5143
5149
|
|
|
@@ -5190,23 +5196,31 @@ class ApiClient {
|
|
|
5190
5196
|
return null;
|
|
5191
5197
|
}
|
|
5192
5198
|
|
|
5193
|
-
|
|
5194
|
-
this.refreshToken
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5199
|
+
try {
|
|
5200
|
+
const session = await this.auth.refreshToken(
|
|
5201
|
+
this.refreshToken,
|
|
5202
|
+
this.refreshBackend,
|
|
5203
|
+
this.refreshExpiration,
|
|
5204
|
+
this.isMobile,
|
|
5205
|
+
this.refreshTenantId,
|
|
5206
|
+
);
|
|
5207
|
+
|
|
5208
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5209
|
+
|
|
5210
|
+
if (this.onRefreshToken) {
|
|
5211
|
+
this.onRefreshToken(session.token, session);
|
|
5212
|
+
}
|
|
5202
5213
|
|
|
5203
|
-
|
|
5204
|
-
this.onRefreshToken(session.token, session);
|
|
5205
|
-
}
|
|
5214
|
+
this.setToken(session.token);
|
|
5206
5215
|
|
|
5207
|
-
|
|
5216
|
+
return session.token;
|
|
5217
|
+
} catch (error) {
|
|
5218
|
+
logger$1.error('token refresh, error', error);
|
|
5208
5219
|
|
|
5209
|
-
|
|
5220
|
+
if (this.onRefreshTokenError) {
|
|
5221
|
+
this.onRefreshTokenError(error);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5210
5224
|
}
|
|
5211
5225
|
|
|
5212
5226
|
setToken(token ) {
|
|
@@ -5229,6 +5243,10 @@ class ApiClient {
|
|
|
5229
5243
|
this.onRefreshToken = onRefreshToken;
|
|
5230
5244
|
}
|
|
5231
5245
|
|
|
5246
|
+
setOnRefreshTokenError(callback ) {
|
|
5247
|
+
this.onRefreshTokenError = callback;
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5232
5250
|
setRefreshExpiration(refreshExpiration ) {
|
|
5233
5251
|
this.refreshExpiration = refreshExpiration;
|
|
5234
5252
|
}
|
|
@@ -7406,11 +7424,14 @@ class WebRTCClient extends Emitter {
|
|
|
7406
7424
|
}
|
|
7407
7425
|
|
|
7408
7426
|
async _disconnectTransport(force = false) {
|
|
7409
|
-
if (force) {
|
|
7427
|
+
if (force && this.userAgent && this.userAgent.transport) {
|
|
7410
7428
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
7411
7429
|
this.userAgent.transport.disconnectResolve = () => {};
|
|
7412
|
-
|
|
7413
|
-
this.userAgent.transport._ws
|
|
7430
|
+
|
|
7431
|
+
if (this.userAgent.transport._ws) {
|
|
7432
|
+
this.userAgent.transport._ws.close(1000);
|
|
7433
|
+
}
|
|
7434
|
+
|
|
7414
7435
|
return;
|
|
7415
7436
|
}
|
|
7416
7437
|
|