@wazo/sdk 0.37.40 → 0.37.43
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 +18 -11
- package/esm/index.js +89 -29
- 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 +89 -29
- package/esm/simple/Configuration.js +89 -29
- package/esm/simple/Directory.js +54 -23
- package/esm/simple/Phone.js +89 -29
- package/esm/simple/Websocket.js +13 -8
- package/esm/simple/index.js +89 -29
- package/esm/simple/room/LocalParticipant.js +89 -29
- package/esm/simple/room/Participant.js +89 -29
- package/esm/simple/room/RemoteParticipant.js +89 -29
- package/esm/simple/room/Room.js +89 -29
- package/esm/simple/room/SipRoom.js +89 -29
- package/esm/simple/room/Stream.js +89 -29
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +89 -29
- package/esm/simple/utils.js +89 -29
- 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 +18 -11
- package/lib/index.js +89 -29
- 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 +89 -29
- package/lib/simple/Configuration.js +89 -29
- package/lib/simple/Directory.js +54 -23
- package/lib/simple/Phone.js +89 -29
- package/lib/simple/Websocket.js +13 -8
- package/lib/simple/index.js +89 -29
- package/lib/simple/room/LocalParticipant.js +89 -29
- package/lib/simple/room/Participant.js +89 -29
- package/lib/simple/room/RemoteParticipant.js +89 -29
- package/lib/simple/room/Room.js +89 -29
- package/lib/simple/room/SipRoom.js +89 -29
- package/lib/simple/room/Stream.js +89 -29
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +89 -29
- package/lib/simple/utils.js +89 -29
- 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/domain/Phone/WebRTCPhone.js +4 -4
- 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/web-rtc-client.js +4 -2
- package/src/websocket-client.js +1 -1
|
@@ -2859,13 +2859,9 @@ class IssueReporter {
|
|
|
2859
2859
|
|
|
2860
2860
|
setTimeout(() => {
|
|
2861
2861
|
if (isArray) {
|
|
2862
|
-
payload = payload.map(message =>
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
});
|
|
2866
|
-
} else {
|
|
2867
|
-
// $FlowFixMe
|
|
2868
|
-
payload._retry = retry + 1;
|
|
2862
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
2863
|
+
} else if (payload && typeof payload === 'object') {
|
|
2864
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
2869
2865
|
}
|
|
2870
2866
|
|
|
2871
2867
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -2873,6 +2869,15 @@ class IssueReporter {
|
|
|
2873
2869
|
});
|
|
2874
2870
|
}
|
|
2875
2871
|
|
|
2872
|
+
_writeRetryCount(message , count ) {
|
|
2873
|
+
if (message && typeof message === 'object') {
|
|
2874
|
+
// $FlowFixMe
|
|
2875
|
+
message._retry = count;
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
return message;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2876
2881
|
_isLevelAbove(level1 , level2 ) {
|
|
2877
2882
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
2878
2883
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -3214,9 +3219,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
3214
3219
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
3215
3220
|
refresh_token: refreshToken,
|
|
3216
3221
|
client_id: client.clientId,
|
|
3217
|
-
tenant_id: tenantId,
|
|
3218
3222
|
};
|
|
3219
3223
|
|
|
3224
|
+
if (tenantId) {
|
|
3225
|
+
body.tenant_id = tenantId;
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3220
3228
|
const headers = {
|
|
3221
3229
|
'Content-Type': 'application/json',
|
|
3222
3230
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4988,6 +4996,7 @@ class ApiClient {
|
|
|
4988
4996
|
|
|
4989
4997
|
|
|
4990
4998
|
|
|
4999
|
+
|
|
4991
5000
|
|
|
4992
5001
|
|
|
4993
5002
|
|
|
@@ -5040,23 +5049,31 @@ class ApiClient {
|
|
|
5040
5049
|
return null;
|
|
5041
5050
|
}
|
|
5042
5051
|
|
|
5043
|
-
|
|
5044
|
-
this.refreshToken
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
+
try {
|
|
5053
|
+
const session = await this.auth.refreshToken(
|
|
5054
|
+
this.refreshToken,
|
|
5055
|
+
this.refreshBackend,
|
|
5056
|
+
this.refreshExpiration,
|
|
5057
|
+
this.isMobile,
|
|
5058
|
+
this.refreshTenantId,
|
|
5059
|
+
);
|
|
5060
|
+
|
|
5061
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5062
|
+
|
|
5063
|
+
if (this.onRefreshToken) {
|
|
5064
|
+
this.onRefreshToken(session.token, session);
|
|
5065
|
+
}
|
|
5052
5066
|
|
|
5053
|
-
|
|
5054
|
-
this.onRefreshToken(session.token, session);
|
|
5055
|
-
}
|
|
5067
|
+
this.setToken(session.token);
|
|
5056
5068
|
|
|
5057
|
-
|
|
5069
|
+
return session.token;
|
|
5070
|
+
} catch (error) {
|
|
5071
|
+
logger$1.error('token refresh, error', error);
|
|
5058
5072
|
|
|
5059
|
-
|
|
5073
|
+
if (this.onRefreshTokenError) {
|
|
5074
|
+
this.onRefreshTokenError(error);
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5060
5077
|
}
|
|
5061
5078
|
|
|
5062
5079
|
setToken(token ) {
|
|
@@ -5079,6 +5096,10 @@ class ApiClient {
|
|
|
5079
5096
|
this.onRefreshToken = onRefreshToken;
|
|
5080
5097
|
}
|
|
5081
5098
|
|
|
5099
|
+
setOnRefreshTokenError(callback ) {
|
|
5100
|
+
this.onRefreshTokenError = callback;
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5082
5103
|
setRefreshExpiration(refreshExpiration ) {
|
|
5083
5104
|
this.refreshExpiration = refreshExpiration;
|
|
5084
5105
|
}
|
|
@@ -5114,7 +5135,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5114
5135
|
global.wazoClientId = global.wazoClientId || {};
|
|
5115
5136
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5116
5137
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5138
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5117
5139
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5140
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5118
5141
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5119
5142
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5120
5143
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5130,12 +5153,20 @@ const fillClient = (apiClient ) => {
|
|
|
5130
5153
|
|
|
5131
5154
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5132
5155
|
|
|
5156
|
+
apiClient.setRefreshTenantId(
|
|
5157
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5158
|
+
);
|
|
5159
|
+
|
|
5133
5160
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5134
5161
|
|
|
5135
5162
|
apiClient.setOnRefreshToken(
|
|
5136
5163
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5137
5164
|
);
|
|
5138
5165
|
|
|
5166
|
+
apiClient.setOnRefreshTokenError(
|
|
5167
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5168
|
+
);
|
|
5169
|
+
|
|
5139
5170
|
apiClient.setRefreshExpiration(
|
|
5140
5171
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5141
5172
|
);
|
|
@@ -5149,7 +5180,7 @@ const fillClient = (apiClient ) => {
|
|
|
5149
5180
|
return apiClient;
|
|
5150
5181
|
};
|
|
5151
5182
|
|
|
5152
|
-
var getApiClient = (forServer
|
|
5183
|
+
var getApiClient = (forServer = null) => {
|
|
5153
5184
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5154
5185
|
if (server in global.wazoClients) {
|
|
5155
5186
|
return fillClient(global.wazoClients[server]);
|
|
@@ -811,13 +811,9 @@ class IssueReporter {
|
|
|
811
811
|
|
|
812
812
|
setTimeout(() => {
|
|
813
813
|
if (isArray) {
|
|
814
|
-
payload = payload.map(message =>
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
});
|
|
818
|
-
} else {
|
|
819
|
-
// $FlowFixMe
|
|
820
|
-
payload._retry = retry + 1;
|
|
814
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
815
|
+
} else if (payload && typeof payload === 'object') {
|
|
816
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
821
817
|
}
|
|
822
818
|
|
|
823
819
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -825,6 +821,15 @@ class IssueReporter {
|
|
|
825
821
|
});
|
|
826
822
|
}
|
|
827
823
|
|
|
824
|
+
_writeRetryCount(message , count ) {
|
|
825
|
+
if (message && typeof message === 'object') {
|
|
826
|
+
// $FlowFixMe
|
|
827
|
+
message._retry = count;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
return message;
|
|
831
|
+
}
|
|
832
|
+
|
|
828
833
|
_isLevelAbove(level1 , level2 ) {
|
|
829
834
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
830
835
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -897,7 +902,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
897
902
|
global.wazoClientId = global.wazoClientId || {};
|
|
898
903
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
899
904
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
905
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
900
906
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
907
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
901
908
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
902
909
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
903
910
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -1447,7 +1454,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1447
1454
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
1448
1455
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
1449
1456
|
// We have to downgrade to audio.
|
|
1450
|
-
const screenshareStopped = this.currentScreenShare.
|
|
1457
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
1451
1458
|
const constraints = { audio: false, video: screenshareStopped };
|
|
1452
1459
|
|
|
1453
1460
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -1891,7 +1898,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1891
1898
|
|
|
1892
1899
|
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1893
1900
|
|
|
1894
|
-
// Stop
|
|
1901
|
+
// Stop screenshare if needed
|
|
1895
1902
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
1896
1903
|
this.lastScreenShare = this.currentScreenShare;
|
|
1897
1904
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -2467,7 +2474,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2467
2474
|
});
|
|
2468
2475
|
|
|
2469
2476
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2470
|
-
logger.
|
|
2477
|
+
logger.info('WebRTC client disconnected');
|
|
2471
2478
|
|
|
2472
2479
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2473
2480
|
|
|
@@ -2653,7 +2660,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2653
2660
|
endTime: fromSession ? fromSession.endTime : null,
|
|
2654
2661
|
answered: state === sessionState.SessionState.Established,
|
|
2655
2662
|
paused: this.client.isCallHeld(sipSession),
|
|
2656
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
2663
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
2657
2664
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
2658
2665
|
number,
|
|
2659
2666
|
ringing: false,
|
package/lib/index.js
CHANGED
|
@@ -427,13 +427,9 @@ class IssueReporter {
|
|
|
427
427
|
|
|
428
428
|
setTimeout(() => {
|
|
429
429
|
if (isArray) {
|
|
430
|
-
payload = payload.map(message =>
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
});
|
|
434
|
-
} else {
|
|
435
|
-
// $FlowFixMe
|
|
436
|
-
payload._retry = retry + 1;
|
|
430
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
431
|
+
} else if (payload && typeof payload === 'object') {
|
|
432
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
437
433
|
}
|
|
438
434
|
|
|
439
435
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -441,6 +437,15 @@ class IssueReporter {
|
|
|
441
437
|
});
|
|
442
438
|
}
|
|
443
439
|
|
|
440
|
+
_writeRetryCount(message , count ) {
|
|
441
|
+
if (message && typeof message === 'object') {
|
|
442
|
+
// $FlowFixMe
|
|
443
|
+
message._retry = count;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return message;
|
|
447
|
+
}
|
|
448
|
+
|
|
444
449
|
_isLevelAbove(level1 , level2 ) {
|
|
445
450
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
446
451
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2277,9 +2282,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2277
2282
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2278
2283
|
refresh_token: refreshToken,
|
|
2279
2284
|
client_id: client.clientId,
|
|
2280
|
-
tenant_id: tenantId,
|
|
2281
2285
|
};
|
|
2282
2286
|
|
|
2287
|
+
if (tenantId) {
|
|
2288
|
+
body.tenant_id = tenantId;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2283
2291
|
const headers = {
|
|
2284
2292
|
'Content-Type': 'application/json',
|
|
2285
2293
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3987,7 +3995,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3987
3995
|
global.wazoClientId = global.wazoClientId || {};
|
|
3988
3996
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3989
3997
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3998
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3990
3999
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4000
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3991
4001
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3992
4002
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3993
4003
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4009,10 +4019,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4009
4019
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
4010
4020
|
};
|
|
4011
4021
|
|
|
4022
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4023
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4024
|
+
};
|
|
4025
|
+
|
|
4012
4026
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4013
4027
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4014
4028
|
};
|
|
4015
4029
|
|
|
4030
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4031
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4032
|
+
};
|
|
4033
|
+
|
|
4016
4034
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4017
4035
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4018
4036
|
};
|
|
@@ -4031,12 +4049,20 @@ const fillClient = (apiClient ) => {
|
|
|
4031
4049
|
|
|
4032
4050
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4033
4051
|
|
|
4052
|
+
apiClient.setRefreshTenantId(
|
|
4053
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4054
|
+
);
|
|
4055
|
+
|
|
4034
4056
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4035
4057
|
|
|
4036
4058
|
apiClient.setOnRefreshToken(
|
|
4037
4059
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4038
4060
|
);
|
|
4039
4061
|
|
|
4062
|
+
apiClient.setOnRefreshTokenError(
|
|
4063
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4064
|
+
);
|
|
4065
|
+
|
|
4040
4066
|
apiClient.setRefreshExpiration(
|
|
4041
4067
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4042
4068
|
);
|
|
@@ -4050,7 +4076,7 @@ const fillClient = (apiClient ) => {
|
|
|
4050
4076
|
return apiClient;
|
|
4051
4077
|
};
|
|
4052
4078
|
|
|
4053
|
-
var getApiClient = (forServer
|
|
4079
|
+
var getApiClient = (forServer = null) => {
|
|
4054
4080
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4055
4081
|
if (server in global.wazoClients) {
|
|
4056
4082
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5510,6 +5536,7 @@ class ApiClient {
|
|
|
5510
5536
|
|
|
5511
5537
|
|
|
5512
5538
|
|
|
5539
|
+
|
|
5513
5540
|
|
|
5514
5541
|
|
|
5515
5542
|
|
|
@@ -5562,23 +5589,31 @@ class ApiClient {
|
|
|
5562
5589
|
return null;
|
|
5563
5590
|
}
|
|
5564
5591
|
|
|
5565
|
-
|
|
5566
|
-
this.refreshToken
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5592
|
+
try {
|
|
5593
|
+
const session = await this.auth.refreshToken(
|
|
5594
|
+
this.refreshToken,
|
|
5595
|
+
this.refreshBackend,
|
|
5596
|
+
this.refreshExpiration,
|
|
5597
|
+
this.isMobile,
|
|
5598
|
+
this.refreshTenantId,
|
|
5599
|
+
);
|
|
5572
5600
|
|
|
5573
|
-
|
|
5601
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5574
5602
|
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5603
|
+
if (this.onRefreshToken) {
|
|
5604
|
+
this.onRefreshToken(session.token, session);
|
|
5605
|
+
}
|
|
5578
5606
|
|
|
5579
|
-
|
|
5607
|
+
this.setToken(session.token);
|
|
5608
|
+
|
|
5609
|
+
return session.token;
|
|
5610
|
+
} catch (error) {
|
|
5611
|
+
logger$a.error('token refresh, error', error);
|
|
5580
5612
|
|
|
5581
|
-
|
|
5613
|
+
if (this.onRefreshTokenError) {
|
|
5614
|
+
this.onRefreshTokenError(error);
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5582
5617
|
}
|
|
5583
5618
|
|
|
5584
5619
|
setToken(token ) {
|
|
@@ -5601,6 +5636,10 @@ class ApiClient {
|
|
|
5601
5636
|
this.onRefreshToken = onRefreshToken;
|
|
5602
5637
|
}
|
|
5603
5638
|
|
|
5639
|
+
setOnRefreshTokenError(callback ) {
|
|
5640
|
+
this.onRefreshTokenError = callback;
|
|
5641
|
+
}
|
|
5642
|
+
|
|
5604
5643
|
setRefreshExpiration(refreshExpiration ) {
|
|
5605
5644
|
this.refreshExpiration = refreshExpiration;
|
|
5606
5645
|
}
|
|
@@ -6973,8 +7012,10 @@ class WebRTCClient extends Emitter {
|
|
|
6973
7012
|
conference: isConference,
|
|
6974
7013
|
};
|
|
6975
7014
|
|
|
6976
|
-
// Avoid sdh to
|
|
6977
|
-
session.sessionDescriptionHandler
|
|
7015
|
+
// Avoid sdh to create a new stream
|
|
7016
|
+
if (session.sessionDescriptionHandler) {
|
|
7017
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7018
|
+
}
|
|
6978
7019
|
|
|
6979
7020
|
// Send re-INVITE
|
|
6980
7021
|
return session.invite(options);
|
|
@@ -8763,7 +8804,7 @@ class WebSocketClient extends Emitter {
|
|
|
8763
8804
|
this.close();
|
|
8764
8805
|
}
|
|
8765
8806
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
8766
|
-
logger$8.
|
|
8807
|
+
logger$8.info('Wazo WS url computed to reconnect', { url });
|
|
8767
8808
|
|
|
8768
8809
|
return url;
|
|
8769
8810
|
}
|
|
@@ -9846,7 +9887,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9846
9887
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9847
9888
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9848
9889
|
// We have to downgrade to audio.
|
|
9849
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9890
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9850
9891
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9851
9892
|
|
|
9852
9893
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -10290,7 +10331,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10290
10331
|
|
|
10291
10332
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
10292
10333
|
|
|
10293
|
-
// Stop
|
|
10334
|
+
// Stop screenshare if needed
|
|
10294
10335
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
10295
10336
|
this.lastScreenShare = this.currentScreenShare;
|
|
10296
10337
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10866,7 +10907,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10866
10907
|
});
|
|
10867
10908
|
|
|
10868
10909
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10869
|
-
logger$7.
|
|
10910
|
+
logger$7.info('WebRTC client disconnected');
|
|
10870
10911
|
|
|
10871
10912
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10872
10913
|
|
|
@@ -11052,7 +11093,7 @@ class WebRTCPhone extends Emitter {
|
|
|
11052
11093
|
endTime: fromSession ? fromSession.endTime : null,
|
|
11053
11094
|
answered: state === sessionState.SessionState.Established,
|
|
11054
11095
|
paused: this.client.isCallHeld(sipSession),
|
|
11055
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
11096
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
11056
11097
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
11057
11098
|
number,
|
|
11058
11099
|
ringing: false,
|
|
@@ -11732,6 +11773,7 @@ class Auth {
|
|
|
11732
11773
|
|
|
11733
11774
|
|
|
11734
11775
|
|
|
11776
|
+
|
|
11735
11777
|
|
|
11736
11778
|
|
|
11737
11779
|
|
|
@@ -11769,6 +11811,14 @@ class Auth {
|
|
|
11769
11811
|
this.onRefreshTokenCallback(token, session);
|
|
11770
11812
|
}
|
|
11771
11813
|
});
|
|
11814
|
+
|
|
11815
|
+
setOnRefreshTokenError(error => {
|
|
11816
|
+
logger$5.error('on refresh token error', error);
|
|
11817
|
+
|
|
11818
|
+
if (this.onRefreshTokenCallbackError) {
|
|
11819
|
+
this.onRefreshTokenCallbackError(error);
|
|
11820
|
+
}
|
|
11821
|
+
});
|
|
11772
11822
|
}
|
|
11773
11823
|
|
|
11774
11824
|
setFetchOptions(options ) {
|
|
@@ -11857,6 +11907,10 @@ class Auth {
|
|
|
11857
11907
|
this.onRefreshTokenCallback = callback;
|
|
11858
11908
|
}
|
|
11859
11909
|
|
|
11910
|
+
setOnRefreshTokenError(callback ) {
|
|
11911
|
+
this.onRefreshTokenCallbackError = callback;
|
|
11912
|
+
}
|
|
11913
|
+
|
|
11860
11914
|
checkAuthorizations(session , authorizationName ) {
|
|
11861
11915
|
if (!authorizationName) {
|
|
11862
11916
|
return;
|
|
@@ -11889,6 +11943,12 @@ class Auth {
|
|
|
11889
11943
|
setRefreshToken(refreshToken);
|
|
11890
11944
|
}
|
|
11891
11945
|
|
|
11946
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
11947
|
+
setRefreshTenantId(refreshTenantId);
|
|
11948
|
+
|
|
11949
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
11950
|
+
}
|
|
11951
|
+
|
|
11892
11952
|
forceRefreshToken() {
|
|
11893
11953
|
getApiClient().forceRefreshToken();
|
|
11894
11954
|
}
|
|
@@ -373,13 +373,9 @@ class IssueReporter {
|
|
|
373
373
|
|
|
374
374
|
setTimeout(() => {
|
|
375
375
|
if (isArray) {
|
|
376
|
-
payload = payload.map(message =>
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
});
|
|
380
|
-
} else {
|
|
381
|
-
// $FlowFixMe
|
|
382
|
-
payload._retry = retry + 1;
|
|
376
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
377
|
+
} else if (payload && typeof payload === 'object') {
|
|
378
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
383
379
|
}
|
|
384
380
|
|
|
385
381
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -387,6 +383,15 @@ class IssueReporter {
|
|
|
387
383
|
});
|
|
388
384
|
}
|
|
389
385
|
|
|
386
|
+
_writeRetryCount(message , count ) {
|
|
387
|
+
if (message && typeof message === 'object') {
|
|
388
|
+
// $FlowFixMe
|
|
389
|
+
message._retry = count;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return message;
|
|
393
|
+
}
|
|
394
|
+
|
|
390
395
|
_isLevelAbove(level1 , level2 ) {
|
|
391
396
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
392
397
|
const index2 = LOG_LEVELS.indexOf(level2);
|
package/lib/service/CallApi.js
CHANGED
|
@@ -2436,13 +2436,9 @@ class IssueReporter {
|
|
|
2436
2436
|
|
|
2437
2437
|
setTimeout(() => {
|
|
2438
2438
|
if (isArray) {
|
|
2439
|
-
payload = payload.map(message =>
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
});
|
|
2443
|
-
} else {
|
|
2444
|
-
// $FlowFixMe
|
|
2445
|
-
payload._retry = retry + 1;
|
|
2439
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
2440
|
+
} else if (payload && typeof payload === 'object') {
|
|
2441
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
2446
2442
|
}
|
|
2447
2443
|
|
|
2448
2444
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -2450,6 +2446,15 @@ class IssueReporter {
|
|
|
2450
2446
|
});
|
|
2451
2447
|
}
|
|
2452
2448
|
|
|
2449
|
+
_writeRetryCount(message , count ) {
|
|
2450
|
+
if (message && typeof message === 'object') {
|
|
2451
|
+
// $FlowFixMe
|
|
2452
|
+
message._retry = count;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
return message;
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2453
2458
|
_isLevelAbove(level1 , level2 ) {
|
|
2454
2459
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
2455
2460
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2791,9 +2796,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2791
2796
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2792
2797
|
refresh_token: refreshToken,
|
|
2793
2798
|
client_id: client.clientId,
|
|
2794
|
-
tenant_id: tenantId,
|
|
2795
2799
|
};
|
|
2796
2800
|
|
|
2801
|
+
if (tenantId) {
|
|
2802
|
+
body.tenant_id = tenantId;
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2797
2805
|
const headers = {
|
|
2798
2806
|
'Content-Type': 'application/json',
|
|
2799
2807
|
...(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]);
|