@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
|
@@ -1919,13 +1919,9 @@ class IssueReporter {
|
|
|
1919
1919
|
|
|
1920
1920
|
setTimeout(() => {
|
|
1921
1921
|
if (isArray) {
|
|
1922
|
-
payload = payload.map(message =>
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
});
|
|
1926
|
-
} else {
|
|
1927
|
-
// $FlowFixMe
|
|
1928
|
-
payload._retry = retry + 1;
|
|
1922
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1923
|
+
} else if (payload && typeof payload === 'object') {
|
|
1924
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1929
1925
|
}
|
|
1930
1926
|
|
|
1931
1927
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1933,6 +1929,15 @@ class IssueReporter {
|
|
|
1933
1929
|
});
|
|
1934
1930
|
}
|
|
1935
1931
|
|
|
1932
|
+
_writeRetryCount(message , count ) {
|
|
1933
|
+
if (message && typeof message === 'object') {
|
|
1934
|
+
// $FlowFixMe
|
|
1935
|
+
message._retry = count;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
return message;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1936
1941
|
_isLevelAbove(level1 , level2 ) {
|
|
1937
1942
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1938
1943
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2275,9 +2280,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2275
2280
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2276
2281
|
refresh_token: refreshToken,
|
|
2277
2282
|
client_id: client.clientId,
|
|
2278
|
-
tenant_id: tenantId,
|
|
2279
2283
|
};
|
|
2280
2284
|
|
|
2285
|
+
if (tenantId) {
|
|
2286
|
+
body.tenant_id = tenantId;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2281
2289
|
const headers = {
|
|
2282
2290
|
'Content-Type': 'application/json',
|
|
2283
2291
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5425,6 +5433,7 @@ class ApiClient {
|
|
|
5425
5433
|
|
|
5426
5434
|
|
|
5427
5435
|
|
|
5436
|
+
|
|
5428
5437
|
|
|
5429
5438
|
|
|
5430
5439
|
|
|
@@ -5477,23 +5486,31 @@ class ApiClient {
|
|
|
5477
5486
|
return null;
|
|
5478
5487
|
}
|
|
5479
5488
|
|
|
5480
|
-
|
|
5481
|
-
this.refreshToken
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5489
|
+
try {
|
|
5490
|
+
const session = await this.auth.refreshToken(
|
|
5491
|
+
this.refreshToken,
|
|
5492
|
+
this.refreshBackend,
|
|
5493
|
+
this.refreshExpiration,
|
|
5494
|
+
this.isMobile,
|
|
5495
|
+
this.refreshTenantId,
|
|
5496
|
+
);
|
|
5487
5497
|
|
|
5488
|
-
|
|
5498
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5489
5499
|
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5500
|
+
if (this.onRefreshToken) {
|
|
5501
|
+
this.onRefreshToken(session.token, session);
|
|
5502
|
+
}
|
|
5493
5503
|
|
|
5494
|
-
|
|
5504
|
+
this.setToken(session.token);
|
|
5495
5505
|
|
|
5496
|
-
|
|
5506
|
+
return session.token;
|
|
5507
|
+
} catch (error) {
|
|
5508
|
+
logger$a.error('token refresh, error', error);
|
|
5509
|
+
|
|
5510
|
+
if (this.onRefreshTokenError) {
|
|
5511
|
+
this.onRefreshTokenError(error);
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5497
5514
|
}
|
|
5498
5515
|
|
|
5499
5516
|
setToken(token ) {
|
|
@@ -5516,6 +5533,10 @@ class ApiClient {
|
|
|
5516
5533
|
this.onRefreshToken = onRefreshToken;
|
|
5517
5534
|
}
|
|
5518
5535
|
|
|
5536
|
+
setOnRefreshTokenError(callback ) {
|
|
5537
|
+
this.onRefreshTokenError = callback;
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5519
5540
|
setRefreshExpiration(refreshExpiration ) {
|
|
5520
5541
|
this.refreshExpiration = refreshExpiration;
|
|
5521
5542
|
}
|
|
@@ -5551,7 +5572,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5551
5572
|
global.wazoClientId = global.wazoClientId || {};
|
|
5552
5573
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5553
5574
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5575
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5554
5576
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5577
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5555
5578
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5556
5579
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5557
5580
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5573,10 +5596,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5573
5596
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5574
5597
|
};
|
|
5575
5598
|
|
|
5599
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5600
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5601
|
+
};
|
|
5602
|
+
|
|
5576
5603
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5577
5604
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5578
5605
|
};
|
|
5579
5606
|
|
|
5607
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5608
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5580
5611
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5581
5612
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5582
5613
|
};
|
|
@@ -5595,12 +5626,20 @@ const fillClient = (apiClient ) => {
|
|
|
5595
5626
|
|
|
5596
5627
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5597
5628
|
|
|
5629
|
+
apiClient.setRefreshTenantId(
|
|
5630
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5631
|
+
);
|
|
5632
|
+
|
|
5598
5633
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5599
5634
|
|
|
5600
5635
|
apiClient.setOnRefreshToken(
|
|
5601
5636
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5602
5637
|
);
|
|
5603
5638
|
|
|
5639
|
+
apiClient.setOnRefreshTokenError(
|
|
5640
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5641
|
+
);
|
|
5642
|
+
|
|
5604
5643
|
apiClient.setRefreshExpiration(
|
|
5605
5644
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5606
5645
|
);
|
|
@@ -5614,7 +5653,7 @@ const fillClient = (apiClient ) => {
|
|
|
5614
5653
|
return apiClient;
|
|
5615
5654
|
};
|
|
5616
5655
|
|
|
5617
|
-
var getApiClient = (forServer
|
|
5656
|
+
var getApiClient = (forServer = null) => {
|
|
5618
5657
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5619
5658
|
if (server in global.wazoClients) {
|
|
5620
5659
|
return fillClient(global.wazoClients[server]);
|
|
@@ -7150,8 +7189,10 @@ class WebRTCClient extends Emitter {
|
|
|
7150
7189
|
conference: isConference,
|
|
7151
7190
|
};
|
|
7152
7191
|
|
|
7153
|
-
// Avoid sdh to
|
|
7154
|
-
session.sessionDescriptionHandler
|
|
7192
|
+
// Avoid sdh to create a new stream
|
|
7193
|
+
if (session.sessionDescriptionHandler) {
|
|
7194
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7195
|
+
}
|
|
7155
7196
|
|
|
7156
7197
|
// Send re-INVITE
|
|
7157
7198
|
return session.invite(options);
|
|
@@ -9122,7 +9163,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9122
9163
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9123
9164
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9124
9165
|
// We have to downgrade to audio.
|
|
9125
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9166
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9126
9167
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9127
9168
|
|
|
9128
9169
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9566,7 +9607,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9566
9607
|
|
|
9567
9608
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9568
9609
|
|
|
9569
|
-
// Stop
|
|
9610
|
+
// Stop screenshare if needed
|
|
9570
9611
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9571
9612
|
this.lastScreenShare = this.currentScreenShare;
|
|
9572
9613
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10142,7 +10183,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10142
10183
|
});
|
|
10143
10184
|
|
|
10144
10185
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10145
|
-
logger$8.
|
|
10186
|
+
logger$8.info('WebRTC client disconnected');
|
|
10146
10187
|
|
|
10147
10188
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10148
10189
|
|
|
@@ -10328,7 +10369,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10328
10369
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10329
10370
|
answered: state === sessionState.SessionState.Established,
|
|
10330
10371
|
paused: this.client.isCallHeld(sipSession),
|
|
10331
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10372
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10332
10373
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10333
10374
|
number,
|
|
10334
10375
|
ringing: false,
|
|
@@ -11162,7 +11203,7 @@ class WebSocketClient extends Emitter {
|
|
|
11162
11203
|
this.close();
|
|
11163
11204
|
}
|
|
11164
11205
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11165
|
-
logger$6.
|
|
11206
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11166
11207
|
|
|
11167
11208
|
return url;
|
|
11168
11209
|
}
|
|
@@ -13711,6 +13752,7 @@ class Auth {
|
|
|
13711
13752
|
|
|
13712
13753
|
|
|
13713
13754
|
|
|
13755
|
+
|
|
13714
13756
|
|
|
13715
13757
|
|
|
13716
13758
|
|
|
@@ -13748,6 +13790,14 @@ class Auth {
|
|
|
13748
13790
|
this.onRefreshTokenCallback(token, session);
|
|
13749
13791
|
}
|
|
13750
13792
|
});
|
|
13793
|
+
|
|
13794
|
+
setOnRefreshTokenError(error => {
|
|
13795
|
+
logger.error('on refresh token error', error);
|
|
13796
|
+
|
|
13797
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13798
|
+
this.onRefreshTokenCallbackError(error);
|
|
13799
|
+
}
|
|
13800
|
+
});
|
|
13751
13801
|
}
|
|
13752
13802
|
|
|
13753
13803
|
setFetchOptions(options ) {
|
|
@@ -13836,6 +13886,10 @@ class Auth {
|
|
|
13836
13886
|
this.onRefreshTokenCallback = callback;
|
|
13837
13887
|
}
|
|
13838
13888
|
|
|
13889
|
+
setOnRefreshTokenError(callback ) {
|
|
13890
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13891
|
+
}
|
|
13892
|
+
|
|
13839
13893
|
checkAuthorizations(session , authorizationName ) {
|
|
13840
13894
|
if (!authorizationName) {
|
|
13841
13895
|
return;
|
|
@@ -13868,6 +13922,12 @@ class Auth {
|
|
|
13868
13922
|
setRefreshToken(refreshToken);
|
|
13869
13923
|
}
|
|
13870
13924
|
|
|
13925
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13926
|
+
setRefreshTenantId(refreshTenantId);
|
|
13927
|
+
|
|
13928
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13929
|
+
}
|
|
13930
|
+
|
|
13871
13931
|
forceRefreshToken() {
|
|
13872
13932
|
getApiClient().forceRefreshToken();
|
|
13873
13933
|
}
|
package/lib/simple/Directory.js
CHANGED
|
@@ -402,13 +402,9 @@ class IssueReporter {
|
|
|
402
402
|
|
|
403
403
|
setTimeout(() => {
|
|
404
404
|
if (isArray) {
|
|
405
|
-
payload = payload.map(message =>
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
});
|
|
409
|
-
} else {
|
|
410
|
-
// $FlowFixMe
|
|
411
|
-
payload._retry = retry + 1;
|
|
405
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
406
|
+
} else if (payload && typeof payload === 'object') {
|
|
407
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
412
408
|
}
|
|
413
409
|
|
|
414
410
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -416,6 +412,15 @@ class IssueReporter {
|
|
|
416
412
|
});
|
|
417
413
|
}
|
|
418
414
|
|
|
415
|
+
_writeRetryCount(message , count ) {
|
|
416
|
+
if (message && typeof message === 'object') {
|
|
417
|
+
// $FlowFixMe
|
|
418
|
+
message._retry = count;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return message;
|
|
422
|
+
}
|
|
423
|
+
|
|
419
424
|
_isLevelAbove(level1 , level2 ) {
|
|
420
425
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
421
426
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2251,9 +2256,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2251
2256
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2252
2257
|
refresh_token: refreshToken,
|
|
2253
2258
|
client_id: client.clientId,
|
|
2254
|
-
tenant_id: tenantId,
|
|
2255
2259
|
};
|
|
2256
2260
|
|
|
2261
|
+
if (tenantId) {
|
|
2262
|
+
body.tenant_id = tenantId;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2257
2265
|
const headers = {
|
|
2258
2266
|
'Content-Type': 'application/json',
|
|
2259
2267
|
...(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/simple/Phone.js
CHANGED
|
@@ -1039,13 +1039,9 @@ class IssueReporter {
|
|
|
1039
1039
|
|
|
1040
1040
|
setTimeout(() => {
|
|
1041
1041
|
if (isArray) {
|
|
1042
|
-
payload = payload.map(message =>
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
});
|
|
1046
|
-
} else {
|
|
1047
|
-
// $FlowFixMe
|
|
1048
|
-
payload._retry = retry + 1;
|
|
1042
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1043
|
+
} else if (payload && typeof payload === 'object') {
|
|
1044
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1049
1045
|
}
|
|
1050
1046
|
|
|
1051
1047
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1053,6 +1049,15 @@ class IssueReporter {
|
|
|
1053
1049
|
});
|
|
1054
1050
|
}
|
|
1055
1051
|
|
|
1052
|
+
_writeRetryCount(message , count ) {
|
|
1053
|
+
if (message && typeof message === 'object') {
|
|
1054
|
+
// $FlowFixMe
|
|
1055
|
+
message._retry = count;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return message;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1056
1061
|
_isLevelAbove(level1 , level2 ) {
|
|
1057
1062
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1058
1063
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2878,9 +2883,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2878
2883
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2879
2884
|
refresh_token: refreshToken,
|
|
2880
2885
|
client_id: client.clientId,
|
|
2881
|
-
tenant_id: tenantId,
|
|
2882
2886
|
};
|
|
2883
2887
|
|
|
2888
|
+
if (tenantId) {
|
|
2889
|
+
body.tenant_id = tenantId;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2884
2892
|
const headers = {
|
|
2885
2893
|
'Content-Type': 'application/json',
|
|
2886
2894
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5425,6 +5433,7 @@ class ApiClient {
|
|
|
5425
5433
|
|
|
5426
5434
|
|
|
5427
5435
|
|
|
5436
|
+
|
|
5428
5437
|
|
|
5429
5438
|
|
|
5430
5439
|
|
|
@@ -5477,23 +5486,31 @@ class ApiClient {
|
|
|
5477
5486
|
return null;
|
|
5478
5487
|
}
|
|
5479
5488
|
|
|
5480
|
-
|
|
5481
|
-
this.refreshToken
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5489
|
+
try {
|
|
5490
|
+
const session = await this.auth.refreshToken(
|
|
5491
|
+
this.refreshToken,
|
|
5492
|
+
this.refreshBackend,
|
|
5493
|
+
this.refreshExpiration,
|
|
5494
|
+
this.isMobile,
|
|
5495
|
+
this.refreshTenantId,
|
|
5496
|
+
);
|
|
5487
5497
|
|
|
5488
|
-
|
|
5498
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5489
5499
|
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5500
|
+
if (this.onRefreshToken) {
|
|
5501
|
+
this.onRefreshToken(session.token, session);
|
|
5502
|
+
}
|
|
5493
5503
|
|
|
5494
|
-
|
|
5504
|
+
this.setToken(session.token);
|
|
5495
5505
|
|
|
5496
|
-
|
|
5506
|
+
return session.token;
|
|
5507
|
+
} catch (error) {
|
|
5508
|
+
logger$a.error('token refresh, error', error);
|
|
5509
|
+
|
|
5510
|
+
if (this.onRefreshTokenError) {
|
|
5511
|
+
this.onRefreshTokenError(error);
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5497
5514
|
}
|
|
5498
5515
|
|
|
5499
5516
|
setToken(token ) {
|
|
@@ -5516,6 +5533,10 @@ class ApiClient {
|
|
|
5516
5533
|
this.onRefreshToken = onRefreshToken;
|
|
5517
5534
|
}
|
|
5518
5535
|
|
|
5536
|
+
setOnRefreshTokenError(callback ) {
|
|
5537
|
+
this.onRefreshTokenError = callback;
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5519
5540
|
setRefreshExpiration(refreshExpiration ) {
|
|
5520
5541
|
this.refreshExpiration = refreshExpiration;
|
|
5521
5542
|
}
|
|
@@ -5551,7 +5572,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5551
5572
|
global.wazoClientId = global.wazoClientId || {};
|
|
5552
5573
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5553
5574
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5575
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5554
5576
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5577
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5555
5578
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5556
5579
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5557
5580
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5573,10 +5596,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5573
5596
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5574
5597
|
};
|
|
5575
5598
|
|
|
5599
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5600
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5601
|
+
};
|
|
5602
|
+
|
|
5576
5603
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5577
5604
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5578
5605
|
};
|
|
5579
5606
|
|
|
5607
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5608
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5580
5611
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5581
5612
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5582
5613
|
};
|
|
@@ -5595,12 +5626,20 @@ const fillClient = (apiClient ) => {
|
|
|
5595
5626
|
|
|
5596
5627
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5597
5628
|
|
|
5629
|
+
apiClient.setRefreshTenantId(
|
|
5630
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5631
|
+
);
|
|
5632
|
+
|
|
5598
5633
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5599
5634
|
|
|
5600
5635
|
apiClient.setOnRefreshToken(
|
|
5601
5636
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5602
5637
|
);
|
|
5603
5638
|
|
|
5639
|
+
apiClient.setOnRefreshTokenError(
|
|
5640
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5641
|
+
);
|
|
5642
|
+
|
|
5604
5643
|
apiClient.setRefreshExpiration(
|
|
5605
5644
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5606
5645
|
);
|
|
@@ -5614,7 +5653,7 @@ const fillClient = (apiClient ) => {
|
|
|
5614
5653
|
return apiClient;
|
|
5615
5654
|
};
|
|
5616
5655
|
|
|
5617
|
-
var getApiClient = (forServer
|
|
5656
|
+
var getApiClient = (forServer = null) => {
|
|
5618
5657
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5619
5658
|
if (server in global.wazoClients) {
|
|
5620
5659
|
return fillClient(global.wazoClients[server]);
|
|
@@ -7150,8 +7189,10 @@ class WebRTCClient extends Emitter {
|
|
|
7150
7189
|
conference: isConference,
|
|
7151
7190
|
};
|
|
7152
7191
|
|
|
7153
|
-
// Avoid sdh to
|
|
7154
|
-
session.sessionDescriptionHandler
|
|
7192
|
+
// Avoid sdh to create a new stream
|
|
7193
|
+
if (session.sessionDescriptionHandler) {
|
|
7194
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7195
|
+
}
|
|
7155
7196
|
|
|
7156
7197
|
// Send re-INVITE
|
|
7157
7198
|
return session.invite(options);
|
|
@@ -9122,7 +9163,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9122
9163
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9123
9164
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9124
9165
|
// We have to downgrade to audio.
|
|
9125
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9166
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9126
9167
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9127
9168
|
|
|
9128
9169
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9566,7 +9607,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9566
9607
|
|
|
9567
9608
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9568
9609
|
|
|
9569
|
-
// Stop
|
|
9610
|
+
// Stop screenshare if needed
|
|
9570
9611
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9571
9612
|
this.lastScreenShare = this.currentScreenShare;
|
|
9572
9613
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10142,7 +10183,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10142
10183
|
});
|
|
10143
10184
|
|
|
10144
10185
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10145
|
-
logger$8.
|
|
10186
|
+
logger$8.info('WebRTC client disconnected');
|
|
10146
10187
|
|
|
10147
10188
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10148
10189
|
|
|
@@ -10328,7 +10369,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10328
10369
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10329
10370
|
answered: state === sessionState.SessionState.Established,
|
|
10330
10371
|
paused: this.client.isCallHeld(sipSession),
|
|
10331
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10372
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10332
10373
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10333
10374
|
number,
|
|
10334
10375
|
ringing: false,
|
|
@@ -10412,6 +10453,7 @@ class Auth {
|
|
|
10412
10453
|
|
|
10413
10454
|
|
|
10414
10455
|
|
|
10456
|
+
|
|
10415
10457
|
|
|
10416
10458
|
|
|
10417
10459
|
|
|
@@ -10449,6 +10491,14 @@ class Auth {
|
|
|
10449
10491
|
this.onRefreshTokenCallback(token, session);
|
|
10450
10492
|
}
|
|
10451
10493
|
});
|
|
10494
|
+
|
|
10495
|
+
setOnRefreshTokenError(error => {
|
|
10496
|
+
logger$7.error('on refresh token error', error);
|
|
10497
|
+
|
|
10498
|
+
if (this.onRefreshTokenCallbackError) {
|
|
10499
|
+
this.onRefreshTokenCallbackError(error);
|
|
10500
|
+
}
|
|
10501
|
+
});
|
|
10452
10502
|
}
|
|
10453
10503
|
|
|
10454
10504
|
setFetchOptions(options ) {
|
|
@@ -10537,6 +10587,10 @@ class Auth {
|
|
|
10537
10587
|
this.onRefreshTokenCallback = callback;
|
|
10538
10588
|
}
|
|
10539
10589
|
|
|
10590
|
+
setOnRefreshTokenError(callback ) {
|
|
10591
|
+
this.onRefreshTokenCallbackError = callback;
|
|
10592
|
+
}
|
|
10593
|
+
|
|
10540
10594
|
checkAuthorizations(session , authorizationName ) {
|
|
10541
10595
|
if (!authorizationName) {
|
|
10542
10596
|
return;
|
|
@@ -10569,6 +10623,12 @@ class Auth {
|
|
|
10569
10623
|
setRefreshToken(refreshToken);
|
|
10570
10624
|
}
|
|
10571
10625
|
|
|
10626
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
10627
|
+
setRefreshTenantId(refreshTenantId);
|
|
10628
|
+
|
|
10629
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
10630
|
+
}
|
|
10631
|
+
|
|
10572
10632
|
forceRefreshToken() {
|
|
10573
10633
|
getApiClient().forceRefreshToken();
|
|
10574
10634
|
}
|
|
@@ -11026,7 +11086,7 @@ class WebSocketClient extends Emitter {
|
|
|
11026
11086
|
this.close();
|
|
11027
11087
|
}
|
|
11028
11088
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11029
|
-
logger$6.
|
|
11089
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11030
11090
|
|
|
11031
11091
|
return url;
|
|
11032
11092
|
}
|