@wazo/sdk 0.37.41 → 0.38.0
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 +3 -3
- package/esm/__tests__/api-client.test.js +45 -22
- package/esm/__tests__/web-rtc-client.test.js +49 -24
- package/esm/api/agentd.js +12 -7
- package/esm/api/amid.js +12 -7
- package/esm/api/application.js +12 -7
- package/esm/api/auth.js +16 -8
- package/esm/api/call-logd.js +12 -7
- package/esm/api/calld.js +12 -7
- package/esm/api/chatd.js +12 -7
- package/esm/api/confd.js +12 -7
- package/esm/api/ctid-ng.js +14 -7
- package/esm/api/dird.js +12 -7
- package/esm/api/webhookd.js +12 -7
- package/esm/api-client.js +45 -22
- package/esm/checker/Checker.js +50 -25
- package/esm/checker/checks/aor.js +45 -22
- package/esm/checker/checks/api.js +45 -22
- package/esm/checker/checks/index.js +50 -25
- package/esm/checker/checks/wazo-websocket.js +13 -8
- package/esm/checker/checks/webrtc-transport.js +49 -24
- package/esm/checker/checks/webrtc.js +49 -24
- package/esm/domain/AdHocAPIConference.js +54 -23
- package/esm/domain/Features.js +54 -23
- package/esm/domain/Phone/CTIPhone.js +54 -23
- package/esm/domain/Phone/WebRTCPhone.js +14 -7
- package/esm/index.js +233 -25
- package/esm/lib/WazoSessionDescriptionHandler.js +12 -7
- package/esm/service/CallApi.js +54 -23
- package/esm/service/IssueReporter.js +12 -7
- package/esm/service/__tests__/IssueReporter.test.js +18 -7
- package/esm/service/getApiClient.js +63 -24
- package/esm/simple/Auth.js +233 -25
- package/esm/simple/Configuration.js +233 -25
- package/esm/simple/Directory.js +54 -23
- package/esm/simple/Phone.js +233 -25
- package/esm/simple/Softphone.js +148 -0
- package/esm/simple/Websocket.js +13 -8
- package/esm/simple/index.js +233 -25
- package/esm/simple/room/LocalParticipant.js +233 -25
- package/esm/simple/room/Participant.js +233 -25
- package/esm/simple/room/RemoteParticipant.js +233 -25
- package/esm/simple/room/Room.js +233 -25
- package/esm/simple/room/SipRoom.js +233 -25
- package/esm/simple/room/Stream.js +233 -25
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/esm/simple/utils.js +233 -25
- package/esm/utils/__tests__/api-requester.test.js +12 -7
- package/esm/utils/api-requester.js +12 -7
- package/esm/web-rtc-client.js +49 -24
- package/esm/websocket-client.js +13 -8
- package/lib/__tests__/api-client.test.js +45 -22
- package/lib/__tests__/web-rtc-client.test.js +49 -24
- package/lib/api/agentd.js +12 -7
- package/lib/api/amid.js +12 -7
- package/lib/api/application.js +12 -7
- package/lib/api/auth.js +16 -8
- package/lib/api/call-logd.js +12 -7
- package/lib/api/calld.js +12 -7
- package/lib/api/chatd.js +12 -7
- package/lib/api/confd.js +12 -7
- package/lib/api/ctid-ng.js +14 -7
- package/lib/api/dird.js +12 -7
- package/lib/api/webhookd.js +12 -7
- package/lib/api-client.js +45 -22
- package/lib/checker/Checker.js +50 -25
- package/lib/checker/checks/aor.js +45 -22
- package/lib/checker/checks/api.js +45 -22
- package/lib/checker/checks/index.js +50 -25
- package/lib/checker/checks/wazo-websocket.js +13 -8
- package/lib/checker/checks/webrtc-transport.js +49 -24
- package/lib/checker/checks/webrtc.js +49 -24
- package/lib/domain/AdHocAPIConference.js +54 -23
- package/lib/domain/Features.js +54 -23
- package/lib/domain/Phone/CTIPhone.js +54 -23
- package/lib/domain/Phone/WebRTCPhone.js +14 -7
- package/lib/index.js +233 -25
- package/lib/lib/WazoSessionDescriptionHandler.js +12 -7
- package/lib/service/CallApi.js +54 -23
- package/lib/service/IssueReporter.js +12 -7
- package/lib/service/__tests__/IssueReporter.test.js +18 -7
- package/lib/service/getApiClient.js +64 -23
- package/lib/simple/Auth.js +233 -25
- package/lib/simple/Configuration.js +233 -25
- package/lib/simple/Directory.js +54 -23
- package/lib/simple/Phone.js +233 -25
- package/lib/simple/Softphone.js +150 -0
- package/lib/simple/Websocket.js +13 -8
- package/lib/simple/index.js +233 -25
- package/lib/simple/room/LocalParticipant.js +233 -25
- package/lib/simple/room/Participant.js +233 -25
- package/lib/simple/room/RemoteParticipant.js +233 -25
- package/lib/simple/room/Room.js +233 -25
- package/lib/simple/room/SipRoom.js +233 -25
- package/lib/simple/room/Stream.js +233 -25
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/lib/simple/utils.js +233 -25
- package/lib/utils/__tests__/api-requester.test.js +12 -7
- package/lib/utils/api-requester.js +12 -7
- package/lib/web-rtc-client.js +49 -24
- package/lib/websocket-client.js +13 -8
- package/package.json +1 -1
- package/src/api/auth.js +4 -1
- package/src/api-client.js +26 -13
- package/src/service/IssueReporter.js +12 -7
- package/src/service/__tests__/IssueReporter.test.js +6 -0
- package/src/service/getApiClient.js +19 -1
- package/src/simple/Auth.js +21 -0
- package/src/simple/Softphone.js +148 -0
- package/src/simple/index.js +2 -0
- package/src/web-rtc-client.js +4 -2
- package/src/websocket-client.js +1 -1
|
@@ -687,13 +687,9 @@ class IssueReporter {
|
|
|
687
687
|
|
|
688
688
|
setTimeout(() => {
|
|
689
689
|
if (isArray) {
|
|
690
|
-
payload = payload.map(message =>
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
});
|
|
694
|
-
} else {
|
|
695
|
-
// $FlowFixMe
|
|
696
|
-
payload._retry = retry + 1;
|
|
690
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
691
|
+
} else if (payload && typeof payload === 'object') {
|
|
692
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
697
693
|
}
|
|
698
694
|
|
|
699
695
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -701,6 +697,15 @@ class IssueReporter {
|
|
|
701
697
|
});
|
|
702
698
|
}
|
|
703
699
|
|
|
700
|
+
_writeRetryCount(message , count ) {
|
|
701
|
+
if (message && typeof message === 'object') {
|
|
702
|
+
// $FlowFixMe
|
|
703
|
+
message._retry = count;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return message;
|
|
707
|
+
}
|
|
708
|
+
|
|
704
709
|
_isLevelAbove(level1 , level2 ) {
|
|
705
710
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
706
711
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2802,9 +2807,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2802
2807
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2803
2808
|
refresh_token: refreshToken,
|
|
2804
2809
|
client_id: client.clientId,
|
|
2805
|
-
tenant_id: tenantId,
|
|
2806
2810
|
};
|
|
2807
2811
|
|
|
2812
|
+
if (tenantId) {
|
|
2813
|
+
body.tenant_id = tenantId;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2808
2816
|
const headers = {
|
|
2809
2817
|
'Content-Type': 'application/json',
|
|
2810
2818
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4092,7 +4100,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4092
4100
|
global.wazoClientId = global.wazoClientId || {};
|
|
4093
4101
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4094
4102
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4103
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4095
4104
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4105
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4096
4106
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4097
4107
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4098
4108
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5138,6 +5148,7 @@ class ApiClient {
|
|
|
5138
5148
|
|
|
5139
5149
|
|
|
5140
5150
|
|
|
5151
|
+
|
|
5141
5152
|
|
|
5142
5153
|
|
|
5143
5154
|
|
|
@@ -5190,23 +5201,31 @@ class ApiClient {
|
|
|
5190
5201
|
return null;
|
|
5191
5202
|
}
|
|
5192
5203
|
|
|
5193
|
-
|
|
5194
|
-
this.refreshToken
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5204
|
+
try {
|
|
5205
|
+
const session = await this.auth.refreshToken(
|
|
5206
|
+
this.refreshToken,
|
|
5207
|
+
this.refreshBackend,
|
|
5208
|
+
this.refreshExpiration,
|
|
5209
|
+
this.isMobile,
|
|
5210
|
+
this.refreshTenantId,
|
|
5211
|
+
);
|
|
5212
|
+
|
|
5213
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5214
|
+
|
|
5215
|
+
if (this.onRefreshToken) {
|
|
5216
|
+
this.onRefreshToken(session.token, session);
|
|
5217
|
+
}
|
|
5202
5218
|
|
|
5203
|
-
|
|
5204
|
-
this.onRefreshToken(session.token, session);
|
|
5205
|
-
}
|
|
5219
|
+
this.setToken(session.token);
|
|
5206
5220
|
|
|
5207
|
-
|
|
5221
|
+
return session.token;
|
|
5222
|
+
} catch (error) {
|
|
5223
|
+
logger$1.error('token refresh, error', error);
|
|
5208
5224
|
|
|
5209
|
-
|
|
5225
|
+
if (this.onRefreshTokenError) {
|
|
5226
|
+
this.onRefreshTokenError(error);
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5210
5229
|
}
|
|
5211
5230
|
|
|
5212
5231
|
setToken(token ) {
|
|
@@ -5229,6 +5248,10 @@ class ApiClient {
|
|
|
5229
5248
|
this.onRefreshToken = onRefreshToken;
|
|
5230
5249
|
}
|
|
5231
5250
|
|
|
5251
|
+
setOnRefreshTokenError(callback ) {
|
|
5252
|
+
this.onRefreshTokenError = callback;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5232
5255
|
setRefreshExpiration(refreshExpiration ) {
|
|
5233
5256
|
this.refreshExpiration = refreshExpiration;
|
|
5234
5257
|
}
|
|
@@ -6093,8 +6116,10 @@ class WebRTCClient extends Emitter {
|
|
|
6093
6116
|
conference: isConference,
|
|
6094
6117
|
};
|
|
6095
6118
|
|
|
6096
|
-
// Avoid sdh to
|
|
6097
|
-
session.sessionDescriptionHandler
|
|
6119
|
+
// Avoid sdh to create a new stream
|
|
6120
|
+
if (session.sessionDescriptionHandler) {
|
|
6121
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6122
|
+
}
|
|
6098
6123
|
|
|
6099
6124
|
// Send re-INVITE
|
|
6100
6125
|
return session.invite(options);
|
|
@@ -687,13 +687,9 @@ class IssueReporter {
|
|
|
687
687
|
|
|
688
688
|
setTimeout(() => {
|
|
689
689
|
if (isArray) {
|
|
690
|
-
payload = payload.map(message =>
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
});
|
|
694
|
-
} else {
|
|
695
|
-
// $FlowFixMe
|
|
696
|
-
payload._retry = retry + 1;
|
|
690
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
691
|
+
} else if (payload && typeof payload === 'object') {
|
|
692
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
697
693
|
}
|
|
698
694
|
|
|
699
695
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -701,6 +697,15 @@ class IssueReporter {
|
|
|
701
697
|
});
|
|
702
698
|
}
|
|
703
699
|
|
|
700
|
+
_writeRetryCount(message , count ) {
|
|
701
|
+
if (message && typeof message === 'object') {
|
|
702
|
+
// $FlowFixMe
|
|
703
|
+
message._retry = count;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return message;
|
|
707
|
+
}
|
|
708
|
+
|
|
704
709
|
_isLevelAbove(level1 , level2 ) {
|
|
705
710
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
706
711
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2802,9 +2807,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2802
2807
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2803
2808
|
refresh_token: refreshToken,
|
|
2804
2809
|
client_id: client.clientId,
|
|
2805
|
-
tenant_id: tenantId,
|
|
2806
2810
|
};
|
|
2807
2811
|
|
|
2812
|
+
if (tenantId) {
|
|
2813
|
+
body.tenant_id = tenantId;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2808
2816
|
const headers = {
|
|
2809
2817
|
'Content-Type': 'application/json',
|
|
2810
2818
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4092,7 +4100,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4092
4100
|
global.wazoClientId = global.wazoClientId || {};
|
|
4093
4101
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4094
4102
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4103
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4095
4104
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4105
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4096
4106
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4097
4107
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4098
4108
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5138,6 +5148,7 @@ class ApiClient {
|
|
|
5138
5148
|
|
|
5139
5149
|
|
|
5140
5150
|
|
|
5151
|
+
|
|
5141
5152
|
|
|
5142
5153
|
|
|
5143
5154
|
|
|
@@ -5190,23 +5201,31 @@ class ApiClient {
|
|
|
5190
5201
|
return null;
|
|
5191
5202
|
}
|
|
5192
5203
|
|
|
5193
|
-
|
|
5194
|
-
this.refreshToken
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5204
|
+
try {
|
|
5205
|
+
const session = await this.auth.refreshToken(
|
|
5206
|
+
this.refreshToken,
|
|
5207
|
+
this.refreshBackend,
|
|
5208
|
+
this.refreshExpiration,
|
|
5209
|
+
this.isMobile,
|
|
5210
|
+
this.refreshTenantId,
|
|
5211
|
+
);
|
|
5212
|
+
|
|
5213
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5214
|
+
|
|
5215
|
+
if (this.onRefreshToken) {
|
|
5216
|
+
this.onRefreshToken(session.token, session);
|
|
5217
|
+
}
|
|
5202
5218
|
|
|
5203
|
-
|
|
5204
|
-
this.onRefreshToken(session.token, session);
|
|
5205
|
-
}
|
|
5219
|
+
this.setToken(session.token);
|
|
5206
5220
|
|
|
5207
|
-
|
|
5221
|
+
return session.token;
|
|
5222
|
+
} catch (error) {
|
|
5223
|
+
logger$1.error('token refresh, error', error);
|
|
5208
5224
|
|
|
5209
|
-
|
|
5225
|
+
if (this.onRefreshTokenError) {
|
|
5226
|
+
this.onRefreshTokenError(error);
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5210
5229
|
}
|
|
5211
5230
|
|
|
5212
5231
|
setToken(token ) {
|
|
@@ -5229,6 +5248,10 @@ class ApiClient {
|
|
|
5229
5248
|
this.onRefreshToken = onRefreshToken;
|
|
5230
5249
|
}
|
|
5231
5250
|
|
|
5251
|
+
setOnRefreshTokenError(callback ) {
|
|
5252
|
+
this.onRefreshTokenError = callback;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5232
5255
|
setRefreshExpiration(refreshExpiration ) {
|
|
5233
5256
|
this.refreshExpiration = refreshExpiration;
|
|
5234
5257
|
}
|
|
@@ -6093,8 +6116,10 @@ class WebRTCClient extends Emitter {
|
|
|
6093
6116
|
conference: isConference,
|
|
6094
6117
|
};
|
|
6095
6118
|
|
|
6096
|
-
// Avoid sdh to
|
|
6097
|
-
session.sessionDescriptionHandler
|
|
6119
|
+
// Avoid sdh to create a new stream
|
|
6120
|
+
if (session.sessionDescriptionHandler) {
|
|
6121
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6122
|
+
}
|
|
6098
6123
|
|
|
6099
6124
|
// Send re-INVITE
|
|
6100
6125
|
return session.invite(options);
|
|
@@ -622,13 +622,9 @@ class IssueReporter {
|
|
|
622
622
|
|
|
623
623
|
setTimeout(() => {
|
|
624
624
|
if (isArray) {
|
|
625
|
-
payload = payload.map(message =>
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
});
|
|
629
|
-
} else {
|
|
630
|
-
// $FlowFixMe
|
|
631
|
-
payload._retry = retry + 1;
|
|
625
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
626
|
+
} else if (payload && typeof payload === 'object') {
|
|
627
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
632
628
|
}
|
|
633
629
|
|
|
634
630
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -636,6 +632,15 @@ class IssueReporter {
|
|
|
636
632
|
});
|
|
637
633
|
}
|
|
638
634
|
|
|
635
|
+
_writeRetryCount(message , count ) {
|
|
636
|
+
if (message && typeof message === 'object') {
|
|
637
|
+
// $FlowFixMe
|
|
638
|
+
message._retry = count;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return message;
|
|
642
|
+
}
|
|
643
|
+
|
|
639
644
|
_isLevelAbove(level1 , level2 ) {
|
|
640
645
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
641
646
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2460,9 +2465,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2460
2465
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2461
2466
|
refresh_token: refreshToken,
|
|
2462
2467
|
client_id: client.clientId,
|
|
2463
|
-
tenant_id: tenantId,
|
|
2464
2468
|
};
|
|
2465
2469
|
|
|
2470
|
+
if (tenantId) {
|
|
2471
|
+
body.tenant_id = tenantId;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2466
2474
|
const headers = {
|
|
2467
2475
|
'Content-Type': 'application/json',
|
|
2468
2476
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4572,6 +4580,7 @@ class ApiClient {
|
|
|
4572
4580
|
|
|
4573
4581
|
|
|
4574
4582
|
|
|
4583
|
+
|
|
4575
4584
|
|
|
4576
4585
|
|
|
4577
4586
|
|
|
@@ -4624,23 +4633,31 @@ class ApiClient {
|
|
|
4624
4633
|
return null;
|
|
4625
4634
|
}
|
|
4626
4635
|
|
|
4627
|
-
|
|
4628
|
-
this.refreshToken
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
+
try {
|
|
4637
|
+
const session = await this.auth.refreshToken(
|
|
4638
|
+
this.refreshToken,
|
|
4639
|
+
this.refreshBackend,
|
|
4640
|
+
this.refreshExpiration,
|
|
4641
|
+
this.isMobile,
|
|
4642
|
+
this.refreshTenantId,
|
|
4643
|
+
);
|
|
4644
|
+
|
|
4645
|
+
logger.info('token refreshed', { token: session.token });
|
|
4646
|
+
|
|
4647
|
+
if (this.onRefreshToken) {
|
|
4648
|
+
this.onRefreshToken(session.token, session);
|
|
4649
|
+
}
|
|
4636
4650
|
|
|
4637
|
-
|
|
4638
|
-
this.onRefreshToken(session.token, session);
|
|
4639
|
-
}
|
|
4651
|
+
this.setToken(session.token);
|
|
4640
4652
|
|
|
4641
|
-
|
|
4653
|
+
return session.token;
|
|
4654
|
+
} catch (error) {
|
|
4655
|
+
logger.error('token refresh, error', error);
|
|
4642
4656
|
|
|
4643
|
-
|
|
4657
|
+
if (this.onRefreshTokenError) {
|
|
4658
|
+
this.onRefreshTokenError(error);
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4644
4661
|
}
|
|
4645
4662
|
|
|
4646
4663
|
setToken(token ) {
|
|
@@ -4663,6 +4680,10 @@ class ApiClient {
|
|
|
4663
4680
|
this.onRefreshToken = onRefreshToken;
|
|
4664
4681
|
}
|
|
4665
4682
|
|
|
4683
|
+
setOnRefreshTokenError(callback ) {
|
|
4684
|
+
this.onRefreshTokenError = callback;
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4666
4687
|
setRefreshExpiration(refreshExpiration ) {
|
|
4667
4688
|
this.refreshExpiration = refreshExpiration;
|
|
4668
4689
|
}
|
|
@@ -4698,7 +4719,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4698
4719
|
global.wazoClientId = global.wazoClientId || {};
|
|
4699
4720
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4700
4721
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4722
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4701
4723
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4724
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4702
4725
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4703
4726
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4704
4727
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4714,12 +4737,20 @@ const fillClient = (apiClient ) => {
|
|
|
4714
4737
|
|
|
4715
4738
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4716
4739
|
|
|
4740
|
+
apiClient.setRefreshTenantId(
|
|
4741
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4742
|
+
);
|
|
4743
|
+
|
|
4717
4744
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4718
4745
|
|
|
4719
4746
|
apiClient.setOnRefreshToken(
|
|
4720
4747
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4721
4748
|
);
|
|
4722
4749
|
|
|
4750
|
+
apiClient.setOnRefreshTokenError(
|
|
4751
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4752
|
+
);
|
|
4753
|
+
|
|
4723
4754
|
apiClient.setRefreshExpiration(
|
|
4724
4755
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4725
4756
|
);
|
|
@@ -4733,7 +4764,7 @@ const fillClient = (apiClient ) => {
|
|
|
4733
4764
|
return apiClient;
|
|
4734
4765
|
};
|
|
4735
4766
|
|
|
4736
|
-
var getApiClient = (forServer
|
|
4767
|
+
var getApiClient = (forServer = null) => {
|
|
4737
4768
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4738
4769
|
if (server in global.wazoClients) {
|
|
4739
4770
|
return fillClient(global.wazoClients[server]);
|
package/lib/domain/Features.js
CHANGED
|
@@ -404,13 +404,9 @@ class IssueReporter {
|
|
|
404
404
|
|
|
405
405
|
setTimeout(() => {
|
|
406
406
|
if (isArray) {
|
|
407
|
-
payload = payload.map(message =>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
411
|
-
} else {
|
|
412
|
-
// $FlowFixMe
|
|
413
|
-
payload._retry = retry + 1;
|
|
407
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
408
|
+
} else if (payload && typeof payload === 'object') {
|
|
409
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
414
410
|
}
|
|
415
411
|
|
|
416
412
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -418,6 +414,15 @@ class IssueReporter {
|
|
|
418
414
|
});
|
|
419
415
|
}
|
|
420
416
|
|
|
417
|
+
_writeRetryCount(message , count ) {
|
|
418
|
+
if (message && typeof message === 'object') {
|
|
419
|
+
// $FlowFixMe
|
|
420
|
+
message._retry = count;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return message;
|
|
424
|
+
}
|
|
425
|
+
|
|
421
426
|
_isLevelAbove(level1 , level2 ) {
|
|
422
427
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
423
428
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2253,9 +2258,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2253
2258
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2254
2259
|
refresh_token: refreshToken,
|
|
2255
2260
|
client_id: client.clientId,
|
|
2256
|
-
tenant_id: tenantId,
|
|
2257
2261
|
};
|
|
2258
2262
|
|
|
2263
|
+
if (tenantId) {
|
|
2264
|
+
body.tenant_id = tenantId;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2259
2267
|
const headers = {
|
|
2260
2268
|
'Content-Type': 'application/json',
|
|
2261
2269
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4574,6 +4582,7 @@ class ApiClient {
|
|
|
4574
4582
|
|
|
4575
4583
|
|
|
4576
4584
|
|
|
4585
|
+
|
|
4577
4586
|
|
|
4578
4587
|
|
|
4579
4588
|
|
|
@@ -4626,23 +4635,31 @@ class ApiClient {
|
|
|
4626
4635
|
return null;
|
|
4627
4636
|
}
|
|
4628
4637
|
|
|
4629
|
-
|
|
4630
|
-
this.refreshToken
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
+
try {
|
|
4639
|
+
const session = await this.auth.refreshToken(
|
|
4640
|
+
this.refreshToken,
|
|
4641
|
+
this.refreshBackend,
|
|
4642
|
+
this.refreshExpiration,
|
|
4643
|
+
this.isMobile,
|
|
4644
|
+
this.refreshTenantId,
|
|
4645
|
+
);
|
|
4646
|
+
|
|
4647
|
+
logger.info('token refreshed', { token: session.token });
|
|
4648
|
+
|
|
4649
|
+
if (this.onRefreshToken) {
|
|
4650
|
+
this.onRefreshToken(session.token, session);
|
|
4651
|
+
}
|
|
4638
4652
|
|
|
4639
|
-
|
|
4640
|
-
this.onRefreshToken(session.token, session);
|
|
4641
|
-
}
|
|
4653
|
+
this.setToken(session.token);
|
|
4642
4654
|
|
|
4643
|
-
|
|
4655
|
+
return session.token;
|
|
4656
|
+
} catch (error) {
|
|
4657
|
+
logger.error('token refresh, error', error);
|
|
4644
4658
|
|
|
4645
|
-
|
|
4659
|
+
if (this.onRefreshTokenError) {
|
|
4660
|
+
this.onRefreshTokenError(error);
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4646
4663
|
}
|
|
4647
4664
|
|
|
4648
4665
|
setToken(token ) {
|
|
@@ -4665,6 +4682,10 @@ class ApiClient {
|
|
|
4665
4682
|
this.onRefreshToken = onRefreshToken;
|
|
4666
4683
|
}
|
|
4667
4684
|
|
|
4685
|
+
setOnRefreshTokenError(callback ) {
|
|
4686
|
+
this.onRefreshTokenError = callback;
|
|
4687
|
+
}
|
|
4688
|
+
|
|
4668
4689
|
setRefreshExpiration(refreshExpiration ) {
|
|
4669
4690
|
this.refreshExpiration = refreshExpiration;
|
|
4670
4691
|
}
|
|
@@ -4700,7 +4721,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4700
4721
|
global.wazoClientId = global.wazoClientId || {};
|
|
4701
4722
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4702
4723
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4724
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4703
4725
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4726
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4704
4727
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4705
4728
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4706
4729
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4716,12 +4739,20 @@ const fillClient = (apiClient ) => {
|
|
|
4716
4739
|
|
|
4717
4740
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4718
4741
|
|
|
4742
|
+
apiClient.setRefreshTenantId(
|
|
4743
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4744
|
+
);
|
|
4745
|
+
|
|
4719
4746
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4720
4747
|
|
|
4721
4748
|
apiClient.setOnRefreshToken(
|
|
4722
4749
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4723
4750
|
);
|
|
4724
4751
|
|
|
4752
|
+
apiClient.setOnRefreshTokenError(
|
|
4753
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4754
|
+
);
|
|
4755
|
+
|
|
4725
4756
|
apiClient.setRefreshExpiration(
|
|
4726
4757
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4727
4758
|
);
|
|
@@ -4735,7 +4766,7 @@ const fillClient = (apiClient ) => {
|
|
|
4735
4766
|
return apiClient;
|
|
4736
4767
|
};
|
|
4737
4768
|
|
|
4738
|
-
var getApiClient = (forServer
|
|
4769
|
+
var getApiClient = (forServer = null) => {
|
|
4739
4770
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4740
4771
|
if (server in global.wazoClients) {
|
|
4741
4772
|
return fillClient(global.wazoClients[server]);
|