@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
|
@@ -2850,13 +2850,9 @@ class IssueReporter {
|
|
|
2850
2850
|
|
|
2851
2851
|
setTimeout(() => {
|
|
2852
2852
|
if (isArray) {
|
|
2853
|
-
payload = payload.map(message =>
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
});
|
|
2857
|
-
} else {
|
|
2858
|
-
// $FlowFixMe
|
|
2859
|
-
payload._retry = retry + 1;
|
|
2853
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
2854
|
+
} else if (payload && typeof payload === 'object') {
|
|
2855
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
2860
2856
|
}
|
|
2861
2857
|
|
|
2862
2858
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -2864,6 +2860,15 @@ class IssueReporter {
|
|
|
2864
2860
|
});
|
|
2865
2861
|
}
|
|
2866
2862
|
|
|
2863
|
+
_writeRetryCount(message , count ) {
|
|
2864
|
+
if (message && typeof message === 'object') {
|
|
2865
|
+
// $FlowFixMe
|
|
2866
|
+
message._retry = count;
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
return message;
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2867
2872
|
_isLevelAbove(level1 , level2 ) {
|
|
2868
2873
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
2869
2874
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -3205,9 +3210,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
3205
3210
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
3206
3211
|
refresh_token: refreshToken,
|
|
3207
3212
|
client_id: client.clientId,
|
|
3208
|
-
tenant_id: tenantId,
|
|
3209
3213
|
};
|
|
3210
3214
|
|
|
3215
|
+
if (tenantId) {
|
|
3216
|
+
body.tenant_id = tenantId;
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3211
3219
|
const headers = {
|
|
3212
3220
|
'Content-Type': 'application/json',
|
|
3213
3221
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4979,6 +4987,7 @@ class ApiClient {
|
|
|
4979
4987
|
|
|
4980
4988
|
|
|
4981
4989
|
|
|
4990
|
+
|
|
4982
4991
|
|
|
4983
4992
|
|
|
4984
4993
|
|
|
@@ -5031,23 +5040,31 @@ class ApiClient {
|
|
|
5031
5040
|
return null;
|
|
5032
5041
|
}
|
|
5033
5042
|
|
|
5034
|
-
|
|
5035
|
-
this.refreshToken
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
+
try {
|
|
5044
|
+
const session = await this.auth.refreshToken(
|
|
5045
|
+
this.refreshToken,
|
|
5046
|
+
this.refreshBackend,
|
|
5047
|
+
this.refreshExpiration,
|
|
5048
|
+
this.isMobile,
|
|
5049
|
+
this.refreshTenantId,
|
|
5050
|
+
);
|
|
5051
|
+
|
|
5052
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5053
|
+
|
|
5054
|
+
if (this.onRefreshToken) {
|
|
5055
|
+
this.onRefreshToken(session.token, session);
|
|
5056
|
+
}
|
|
5043
5057
|
|
|
5044
|
-
|
|
5045
|
-
this.onRefreshToken(session.token, session);
|
|
5046
|
-
}
|
|
5058
|
+
this.setToken(session.token);
|
|
5047
5059
|
|
|
5048
|
-
|
|
5060
|
+
return session.token;
|
|
5061
|
+
} catch (error) {
|
|
5062
|
+
logger$1.error('token refresh, error', error);
|
|
5049
5063
|
|
|
5050
|
-
|
|
5064
|
+
if (this.onRefreshTokenError) {
|
|
5065
|
+
this.onRefreshTokenError(error);
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5051
5068
|
}
|
|
5052
5069
|
|
|
5053
5070
|
setToken(token ) {
|
|
@@ -5070,6 +5087,10 @@ class ApiClient {
|
|
|
5070
5087
|
this.onRefreshToken = onRefreshToken;
|
|
5071
5088
|
}
|
|
5072
5089
|
|
|
5090
|
+
setOnRefreshTokenError(callback ) {
|
|
5091
|
+
this.onRefreshTokenError = callback;
|
|
5092
|
+
}
|
|
5093
|
+
|
|
5073
5094
|
setRefreshExpiration(refreshExpiration ) {
|
|
5074
5095
|
this.refreshExpiration = refreshExpiration;
|
|
5075
5096
|
}
|
|
@@ -5105,7 +5126,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5105
5126
|
global.wazoClientId = global.wazoClientId || {};
|
|
5106
5127
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5107
5128
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5129
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5108
5130
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5131
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5109
5132
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5110
5133
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5111
5134
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5121,12 +5144,20 @@ const fillClient = (apiClient ) => {
|
|
|
5121
5144
|
|
|
5122
5145
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5123
5146
|
|
|
5147
|
+
apiClient.setRefreshTenantId(
|
|
5148
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5149
|
+
);
|
|
5150
|
+
|
|
5124
5151
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5125
5152
|
|
|
5126
5153
|
apiClient.setOnRefreshToken(
|
|
5127
5154
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5128
5155
|
);
|
|
5129
5156
|
|
|
5157
|
+
apiClient.setOnRefreshTokenError(
|
|
5158
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5159
|
+
);
|
|
5160
|
+
|
|
5130
5161
|
apiClient.setRefreshExpiration(
|
|
5131
5162
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5132
5163
|
);
|
|
@@ -5140,7 +5171,7 @@ const fillClient = (apiClient ) => {
|
|
|
5140
5171
|
return apiClient;
|
|
5141
5172
|
};
|
|
5142
5173
|
|
|
5143
|
-
var getApiClient = (forServer
|
|
5174
|
+
var getApiClient = (forServer = null) => {
|
|
5144
5175
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5145
5176
|
if (server in global.wazoClients) {
|
|
5146
5177
|
return fillClient(global.wazoClients[server]);
|
|
@@ -802,13 +802,9 @@ class IssueReporter {
|
|
|
802
802
|
|
|
803
803
|
setTimeout(() => {
|
|
804
804
|
if (isArray) {
|
|
805
|
-
payload = payload.map(message =>
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
});
|
|
809
|
-
} else {
|
|
810
|
-
// $FlowFixMe
|
|
811
|
-
payload._retry = retry + 1;
|
|
805
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
806
|
+
} else if (payload && typeof payload === 'object') {
|
|
807
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
812
808
|
}
|
|
813
809
|
|
|
814
810
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -816,6 +812,15 @@ class IssueReporter {
|
|
|
816
812
|
});
|
|
817
813
|
}
|
|
818
814
|
|
|
815
|
+
_writeRetryCount(message , count ) {
|
|
816
|
+
if (message && typeof message === 'object') {
|
|
817
|
+
// $FlowFixMe
|
|
818
|
+
message._retry = count;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
return message;
|
|
822
|
+
}
|
|
823
|
+
|
|
819
824
|
_isLevelAbove(level1 , level2 ) {
|
|
820
825
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
821
826
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -888,7 +893,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
888
893
|
global.wazoClientId = global.wazoClientId || {};
|
|
889
894
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
890
895
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
896
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
891
897
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
898
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
892
899
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
893
900
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
894
901
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -1438,7 +1445,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1438
1445
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
1439
1446
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
1440
1447
|
// We have to downgrade to audio.
|
|
1441
|
-
const screenshareStopped = this.currentScreenShare.
|
|
1448
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
1442
1449
|
const constraints = { audio: false, video: screenshareStopped };
|
|
1443
1450
|
|
|
1444
1451
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -1882,7 +1889,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1882
1889
|
|
|
1883
1890
|
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1884
1891
|
|
|
1885
|
-
// Stop
|
|
1892
|
+
// Stop screenshare if needed
|
|
1886
1893
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
1887
1894
|
this.lastScreenShare = this.currentScreenShare;
|
|
1888
1895
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -2458,7 +2465,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2458
2465
|
});
|
|
2459
2466
|
|
|
2460
2467
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2461
|
-
logger.
|
|
2468
|
+
logger.info('WebRTC client disconnected');
|
|
2462
2469
|
|
|
2463
2470
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2464
2471
|
|
|
@@ -2644,7 +2651,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2644
2651
|
endTime: fromSession ? fromSession.endTime : null,
|
|
2645
2652
|
answered: state === SessionState.Established,
|
|
2646
2653
|
paused: this.client.isCallHeld(sipSession),
|
|
2647
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
2654
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
2648
2655
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
2649
2656
|
number,
|
|
2650
2657
|
ringing: false,
|
package/esm/index.js
CHANGED
|
@@ -416,13 +416,9 @@ class IssueReporter {
|
|
|
416
416
|
|
|
417
417
|
setTimeout(() => {
|
|
418
418
|
if (isArray) {
|
|
419
|
-
payload = payload.map(message =>
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
});
|
|
423
|
-
} else {
|
|
424
|
-
// $FlowFixMe
|
|
425
|
-
payload._retry = retry + 1;
|
|
419
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
420
|
+
} else if (payload && typeof payload === 'object') {
|
|
421
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
426
422
|
}
|
|
427
423
|
|
|
428
424
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -430,6 +426,15 @@ class IssueReporter {
|
|
|
430
426
|
});
|
|
431
427
|
}
|
|
432
428
|
|
|
429
|
+
_writeRetryCount(message , count ) {
|
|
430
|
+
if (message && typeof message === 'object') {
|
|
431
|
+
// $FlowFixMe
|
|
432
|
+
message._retry = count;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return message;
|
|
436
|
+
}
|
|
437
|
+
|
|
433
438
|
_isLevelAbove(level1 , level2 ) {
|
|
434
439
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
435
440
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2266,9 +2271,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2266
2271
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2267
2272
|
refresh_token: refreshToken,
|
|
2268
2273
|
client_id: client.clientId,
|
|
2269
|
-
tenant_id: tenantId,
|
|
2270
2274
|
};
|
|
2271
2275
|
|
|
2276
|
+
if (tenantId) {
|
|
2277
|
+
body.tenant_id = tenantId;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2272
2280
|
const headers = {
|
|
2273
2281
|
'Content-Type': 'application/json',
|
|
2274
2282
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3976,7 +3984,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3976
3984
|
global.wazoClientId = global.wazoClientId || {};
|
|
3977
3985
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3978
3986
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3987
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3979
3988
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3989
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3980
3990
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3981
3991
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3982
3992
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -3998,10 +4008,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
3998
4008
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
3999
4009
|
};
|
|
4000
4010
|
|
|
4011
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4012
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4013
|
+
};
|
|
4014
|
+
|
|
4001
4015
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4002
4016
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4003
4017
|
};
|
|
4004
4018
|
|
|
4019
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4020
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4021
|
+
};
|
|
4022
|
+
|
|
4005
4023
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4006
4024
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4007
4025
|
};
|
|
@@ -4020,12 +4038,20 @@ const fillClient = (apiClient ) => {
|
|
|
4020
4038
|
|
|
4021
4039
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4022
4040
|
|
|
4041
|
+
apiClient.setRefreshTenantId(
|
|
4042
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4043
|
+
);
|
|
4044
|
+
|
|
4023
4045
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4024
4046
|
|
|
4025
4047
|
apiClient.setOnRefreshToken(
|
|
4026
4048
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4027
4049
|
);
|
|
4028
4050
|
|
|
4051
|
+
apiClient.setOnRefreshTokenError(
|
|
4052
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4053
|
+
);
|
|
4054
|
+
|
|
4029
4055
|
apiClient.setRefreshExpiration(
|
|
4030
4056
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4031
4057
|
);
|
|
@@ -4039,7 +4065,7 @@ const fillClient = (apiClient ) => {
|
|
|
4039
4065
|
return apiClient;
|
|
4040
4066
|
};
|
|
4041
4067
|
|
|
4042
|
-
var getApiClient = (forServer
|
|
4068
|
+
var getApiClient = (forServer = null) => {
|
|
4043
4069
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4044
4070
|
if (server in global.wazoClients) {
|
|
4045
4071
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5499,6 +5525,7 @@ class ApiClient {
|
|
|
5499
5525
|
|
|
5500
5526
|
|
|
5501
5527
|
|
|
5528
|
+
|
|
5502
5529
|
|
|
5503
5530
|
|
|
5504
5531
|
|
|
@@ -5551,23 +5578,31 @@ class ApiClient {
|
|
|
5551
5578
|
return null;
|
|
5552
5579
|
}
|
|
5553
5580
|
|
|
5554
|
-
|
|
5555
|
-
this.refreshToken
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5581
|
+
try {
|
|
5582
|
+
const session = await this.auth.refreshToken(
|
|
5583
|
+
this.refreshToken,
|
|
5584
|
+
this.refreshBackend,
|
|
5585
|
+
this.refreshExpiration,
|
|
5586
|
+
this.isMobile,
|
|
5587
|
+
this.refreshTenantId,
|
|
5588
|
+
);
|
|
5561
5589
|
|
|
5562
|
-
|
|
5590
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5563
5591
|
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5592
|
+
if (this.onRefreshToken) {
|
|
5593
|
+
this.onRefreshToken(session.token, session);
|
|
5594
|
+
}
|
|
5567
5595
|
|
|
5568
|
-
|
|
5596
|
+
this.setToken(session.token);
|
|
5597
|
+
|
|
5598
|
+
return session.token;
|
|
5599
|
+
} catch (error) {
|
|
5600
|
+
logger$a.error('token refresh, error', error);
|
|
5569
5601
|
|
|
5570
|
-
|
|
5602
|
+
if (this.onRefreshTokenError) {
|
|
5603
|
+
this.onRefreshTokenError(error);
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5571
5606
|
}
|
|
5572
5607
|
|
|
5573
5608
|
setToken(token ) {
|
|
@@ -5590,6 +5625,10 @@ class ApiClient {
|
|
|
5590
5625
|
this.onRefreshToken = onRefreshToken;
|
|
5591
5626
|
}
|
|
5592
5627
|
|
|
5628
|
+
setOnRefreshTokenError(callback ) {
|
|
5629
|
+
this.onRefreshTokenError = callback;
|
|
5630
|
+
}
|
|
5631
|
+
|
|
5593
5632
|
setRefreshExpiration(refreshExpiration ) {
|
|
5594
5633
|
this.refreshExpiration = refreshExpiration;
|
|
5595
5634
|
}
|
|
@@ -6962,8 +7001,10 @@ class WebRTCClient extends Emitter {
|
|
|
6962
7001
|
conference: isConference,
|
|
6963
7002
|
};
|
|
6964
7003
|
|
|
6965
|
-
// Avoid sdh to
|
|
6966
|
-
session.sessionDescriptionHandler
|
|
7004
|
+
// Avoid sdh to create a new stream
|
|
7005
|
+
if (session.sessionDescriptionHandler) {
|
|
7006
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7007
|
+
}
|
|
6967
7008
|
|
|
6968
7009
|
// Send re-INVITE
|
|
6969
7010
|
return session.invite(options);
|
|
@@ -8752,7 +8793,7 @@ class WebSocketClient extends Emitter {
|
|
|
8752
8793
|
this.close();
|
|
8753
8794
|
}
|
|
8754
8795
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
8755
|
-
logger$8.
|
|
8796
|
+
logger$8.info('Wazo WS url computed to reconnect', { url });
|
|
8756
8797
|
|
|
8757
8798
|
return url;
|
|
8758
8799
|
}
|
|
@@ -9835,7 +9876,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9835
9876
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9836
9877
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9837
9878
|
// We have to downgrade to audio.
|
|
9838
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9879
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9839
9880
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9840
9881
|
|
|
9841
9882
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -10279,7 +10320,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10279
10320
|
|
|
10280
10321
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
10281
10322
|
|
|
10282
|
-
// Stop
|
|
10323
|
+
// Stop screenshare if needed
|
|
10283
10324
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
10284
10325
|
this.lastScreenShare = this.currentScreenShare;
|
|
10285
10326
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10855,7 +10896,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10855
10896
|
});
|
|
10856
10897
|
|
|
10857
10898
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10858
|
-
logger$7.
|
|
10899
|
+
logger$7.info('WebRTC client disconnected');
|
|
10859
10900
|
|
|
10860
10901
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10861
10902
|
|
|
@@ -11041,7 +11082,7 @@ class WebRTCPhone extends Emitter {
|
|
|
11041
11082
|
endTime: fromSession ? fromSession.endTime : null,
|
|
11042
11083
|
answered: state === SessionState.Established,
|
|
11043
11084
|
paused: this.client.isCallHeld(sipSession),
|
|
11044
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
11085
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
11045
11086
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
11046
11087
|
number,
|
|
11047
11088
|
ringing: false,
|
|
@@ -11721,6 +11762,7 @@ class Auth {
|
|
|
11721
11762
|
|
|
11722
11763
|
|
|
11723
11764
|
|
|
11765
|
+
|
|
11724
11766
|
|
|
11725
11767
|
|
|
11726
11768
|
|
|
@@ -11758,6 +11800,14 @@ class Auth {
|
|
|
11758
11800
|
this.onRefreshTokenCallback(token, session);
|
|
11759
11801
|
}
|
|
11760
11802
|
});
|
|
11803
|
+
|
|
11804
|
+
setOnRefreshTokenError(error => {
|
|
11805
|
+
logger$5.error('on refresh token error', error);
|
|
11806
|
+
|
|
11807
|
+
if (this.onRefreshTokenCallbackError) {
|
|
11808
|
+
this.onRefreshTokenCallbackError(error);
|
|
11809
|
+
}
|
|
11810
|
+
});
|
|
11761
11811
|
}
|
|
11762
11812
|
|
|
11763
11813
|
setFetchOptions(options ) {
|
|
@@ -11846,6 +11896,10 @@ class Auth {
|
|
|
11846
11896
|
this.onRefreshTokenCallback = callback;
|
|
11847
11897
|
}
|
|
11848
11898
|
|
|
11899
|
+
setOnRefreshTokenError(callback ) {
|
|
11900
|
+
this.onRefreshTokenCallbackError = callback;
|
|
11901
|
+
}
|
|
11902
|
+
|
|
11849
11903
|
checkAuthorizations(session , authorizationName ) {
|
|
11850
11904
|
if (!authorizationName) {
|
|
11851
11905
|
return;
|
|
@@ -11878,6 +11932,12 @@ class Auth {
|
|
|
11878
11932
|
setRefreshToken(refreshToken);
|
|
11879
11933
|
}
|
|
11880
11934
|
|
|
11935
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
11936
|
+
setRefreshTenantId(refreshTenantId);
|
|
11937
|
+
|
|
11938
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
11939
|
+
}
|
|
11940
|
+
|
|
11881
11941
|
forceRefreshToken() {
|
|
11882
11942
|
getApiClient().forceRefreshToken();
|
|
11883
11943
|
}
|
|
@@ -363,13 +363,9 @@ class IssueReporter {
|
|
|
363
363
|
|
|
364
364
|
setTimeout(() => {
|
|
365
365
|
if (isArray) {
|
|
366
|
-
payload = payload.map(message =>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
});
|
|
370
|
-
} else {
|
|
371
|
-
// $FlowFixMe
|
|
372
|
-
payload._retry = retry + 1;
|
|
366
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
367
|
+
} else if (payload && typeof payload === 'object') {
|
|
368
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
373
369
|
}
|
|
374
370
|
|
|
375
371
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -377,6 +373,15 @@ class IssueReporter {
|
|
|
377
373
|
});
|
|
378
374
|
}
|
|
379
375
|
|
|
376
|
+
_writeRetryCount(message , count ) {
|
|
377
|
+
if (message && typeof message === 'object') {
|
|
378
|
+
// $FlowFixMe
|
|
379
|
+
message._retry = count;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return message;
|
|
383
|
+
}
|
|
384
|
+
|
|
380
385
|
_isLevelAbove(level1 , level2 ) {
|
|
381
386
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
382
387
|
const index2 = LOG_LEVELS.indexOf(level2);
|
package/esm/service/CallApi.js
CHANGED
|
@@ -2430,13 +2430,9 @@ class IssueReporter {
|
|
|
2430
2430
|
|
|
2431
2431
|
setTimeout(() => {
|
|
2432
2432
|
if (isArray) {
|
|
2433
|
-
payload = payload.map(message =>
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
});
|
|
2437
|
-
} else {
|
|
2438
|
-
// $FlowFixMe
|
|
2439
|
-
payload._retry = retry + 1;
|
|
2433
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
2434
|
+
} else if (payload && typeof payload === 'object') {
|
|
2435
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
2440
2436
|
}
|
|
2441
2437
|
|
|
2442
2438
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -2444,6 +2440,15 @@ class IssueReporter {
|
|
|
2444
2440
|
});
|
|
2445
2441
|
}
|
|
2446
2442
|
|
|
2443
|
+
_writeRetryCount(message , count ) {
|
|
2444
|
+
if (message && typeof message === 'object') {
|
|
2445
|
+
// $FlowFixMe
|
|
2446
|
+
message._retry = count;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
return message;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2447
2452
|
_isLevelAbove(level1 , level2 ) {
|
|
2448
2453
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
2449
2454
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2785,9 +2790,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2785
2790
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2786
2791
|
refresh_token: refreshToken,
|
|
2787
2792
|
client_id: client.clientId,
|
|
2788
|
-
tenant_id: tenantId,
|
|
2789
2793
|
};
|
|
2790
2794
|
|
|
2795
|
+
if (tenantId) {
|
|
2796
|
+
body.tenant_id = tenantId;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2791
2799
|
const headers = {
|
|
2792
2800
|
'Content-Type': 'application/json',
|
|
2793
2801
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4566,6 +4574,7 @@ class ApiClient {
|
|
|
4566
4574
|
|
|
4567
4575
|
|
|
4568
4576
|
|
|
4577
|
+
|
|
4569
4578
|
|
|
4570
4579
|
|
|
4571
4580
|
|
|
@@ -4618,23 +4627,31 @@ class ApiClient {
|
|
|
4618
4627
|
return null;
|
|
4619
4628
|
}
|
|
4620
4629
|
|
|
4621
|
-
|
|
4622
|
-
this.refreshToken
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
+
try {
|
|
4631
|
+
const session = await this.auth.refreshToken(
|
|
4632
|
+
this.refreshToken,
|
|
4633
|
+
this.refreshBackend,
|
|
4634
|
+
this.refreshExpiration,
|
|
4635
|
+
this.isMobile,
|
|
4636
|
+
this.refreshTenantId,
|
|
4637
|
+
);
|
|
4638
|
+
|
|
4639
|
+
logger.info('token refreshed', { token: session.token });
|
|
4640
|
+
|
|
4641
|
+
if (this.onRefreshToken) {
|
|
4642
|
+
this.onRefreshToken(session.token, session);
|
|
4643
|
+
}
|
|
4630
4644
|
|
|
4631
|
-
|
|
4632
|
-
this.onRefreshToken(session.token, session);
|
|
4633
|
-
}
|
|
4645
|
+
this.setToken(session.token);
|
|
4634
4646
|
|
|
4635
|
-
|
|
4647
|
+
return session.token;
|
|
4648
|
+
} catch (error) {
|
|
4649
|
+
logger.error('token refresh, error', error);
|
|
4636
4650
|
|
|
4637
|
-
|
|
4651
|
+
if (this.onRefreshTokenError) {
|
|
4652
|
+
this.onRefreshTokenError(error);
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4638
4655
|
}
|
|
4639
4656
|
|
|
4640
4657
|
setToken(token ) {
|
|
@@ -4657,6 +4674,10 @@ class ApiClient {
|
|
|
4657
4674
|
this.onRefreshToken = onRefreshToken;
|
|
4658
4675
|
}
|
|
4659
4676
|
|
|
4677
|
+
setOnRefreshTokenError(callback ) {
|
|
4678
|
+
this.onRefreshTokenError = callback;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4660
4681
|
setRefreshExpiration(refreshExpiration ) {
|
|
4661
4682
|
this.refreshExpiration = refreshExpiration;
|
|
4662
4683
|
}
|
|
@@ -4692,7 +4713,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4692
4713
|
global.wazoClientId = global.wazoClientId || {};
|
|
4693
4714
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4694
4715
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4716
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4695
4717
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4718
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4696
4719
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4697
4720
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4698
4721
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4708,12 +4731,20 @@ const fillClient = (apiClient ) => {
|
|
|
4708
4731
|
|
|
4709
4732
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4710
4733
|
|
|
4734
|
+
apiClient.setRefreshTenantId(
|
|
4735
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4736
|
+
);
|
|
4737
|
+
|
|
4711
4738
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4712
4739
|
|
|
4713
4740
|
apiClient.setOnRefreshToken(
|
|
4714
4741
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4715
4742
|
);
|
|
4716
4743
|
|
|
4744
|
+
apiClient.setOnRefreshTokenError(
|
|
4745
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4746
|
+
);
|
|
4747
|
+
|
|
4717
4748
|
apiClient.setRefreshExpiration(
|
|
4718
4749
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4719
4750
|
);
|
|
@@ -4727,7 +4758,7 @@ const fillClient = (apiClient ) => {
|
|
|
4727
4758
|
return apiClient;
|
|
4728
4759
|
};
|
|
4729
4760
|
|
|
4730
|
-
var getApiClient = (forServer
|
|
4761
|
+
var getApiClient = (forServer = null) => {
|
|
4731
4762
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4732
4763
|
if (server in global.wazoClients) {
|
|
4733
4764
|
return fillClient(global.wazoClients[server]);
|