@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
package/lib/simple/utils.js
CHANGED
|
@@ -1921,13 +1921,9 @@ class IssueReporter {
|
|
|
1921
1921
|
|
|
1922
1922
|
setTimeout(() => {
|
|
1923
1923
|
if (isArray) {
|
|
1924
|
-
payload = payload.map(message =>
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
});
|
|
1928
|
-
} else {
|
|
1929
|
-
// $FlowFixMe
|
|
1930
|
-
payload._retry = retry + 1;
|
|
1924
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1925
|
+
} else if (payload && typeof payload === 'object') {
|
|
1926
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1931
1927
|
}
|
|
1932
1928
|
|
|
1933
1929
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1935,6 +1931,15 @@ class IssueReporter {
|
|
|
1935
1931
|
});
|
|
1936
1932
|
}
|
|
1937
1933
|
|
|
1934
|
+
_writeRetryCount(message , count ) {
|
|
1935
|
+
if (message && typeof message === 'object') {
|
|
1936
|
+
// $FlowFixMe
|
|
1937
|
+
message._retry = count;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
return message;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1938
1943
|
_isLevelAbove(level1 , level2 ) {
|
|
1939
1944
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1940
1945
|
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' } : {}),
|
|
@@ -5427,6 +5435,7 @@ class ApiClient {
|
|
|
5427
5435
|
|
|
5428
5436
|
|
|
5429
5437
|
|
|
5438
|
+
|
|
5430
5439
|
|
|
5431
5440
|
|
|
5432
5441
|
|
|
@@ -5479,23 +5488,31 @@ class ApiClient {
|
|
|
5479
5488
|
return null;
|
|
5480
5489
|
}
|
|
5481
5490
|
|
|
5482
|
-
|
|
5483
|
-
this.refreshToken
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5491
|
+
try {
|
|
5492
|
+
const session = await this.auth.refreshToken(
|
|
5493
|
+
this.refreshToken,
|
|
5494
|
+
this.refreshBackend,
|
|
5495
|
+
this.refreshExpiration,
|
|
5496
|
+
this.isMobile,
|
|
5497
|
+
this.refreshTenantId,
|
|
5498
|
+
);
|
|
5489
5499
|
|
|
5490
|
-
|
|
5500
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5491
5501
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5502
|
+
if (this.onRefreshToken) {
|
|
5503
|
+
this.onRefreshToken(session.token, session);
|
|
5504
|
+
}
|
|
5495
5505
|
|
|
5496
|
-
|
|
5506
|
+
this.setToken(session.token);
|
|
5497
5507
|
|
|
5498
|
-
|
|
5508
|
+
return session.token;
|
|
5509
|
+
} catch (error) {
|
|
5510
|
+
logger$a.error('token refresh, error', error);
|
|
5511
|
+
|
|
5512
|
+
if (this.onRefreshTokenError) {
|
|
5513
|
+
this.onRefreshTokenError(error);
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5499
5516
|
}
|
|
5500
5517
|
|
|
5501
5518
|
setToken(token ) {
|
|
@@ -5518,6 +5535,10 @@ class ApiClient {
|
|
|
5518
5535
|
this.onRefreshToken = onRefreshToken;
|
|
5519
5536
|
}
|
|
5520
5537
|
|
|
5538
|
+
setOnRefreshTokenError(callback ) {
|
|
5539
|
+
this.onRefreshTokenError = callback;
|
|
5540
|
+
}
|
|
5541
|
+
|
|
5521
5542
|
setRefreshExpiration(refreshExpiration ) {
|
|
5522
5543
|
this.refreshExpiration = refreshExpiration;
|
|
5523
5544
|
}
|
|
@@ -5553,7 +5574,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5553
5574
|
global.wazoClientId = global.wazoClientId || {};
|
|
5554
5575
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5555
5576
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5577
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5556
5578
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5579
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5557
5580
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5558
5581
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5559
5582
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5575,10 +5598,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5575
5598
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5576
5599
|
};
|
|
5577
5600
|
|
|
5601
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5602
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5603
|
+
};
|
|
5604
|
+
|
|
5578
5605
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5579
5606
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5580
5607
|
};
|
|
5581
5608
|
|
|
5609
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5610
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5611
|
+
};
|
|
5612
|
+
|
|
5582
5613
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5583
5614
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5584
5615
|
};
|
|
@@ -5597,12 +5628,20 @@ const fillClient = (apiClient ) => {
|
|
|
5597
5628
|
|
|
5598
5629
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5599
5630
|
|
|
5631
|
+
apiClient.setRefreshTenantId(
|
|
5632
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5633
|
+
);
|
|
5634
|
+
|
|
5600
5635
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5601
5636
|
|
|
5602
5637
|
apiClient.setOnRefreshToken(
|
|
5603
5638
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5604
5639
|
);
|
|
5605
5640
|
|
|
5641
|
+
apiClient.setOnRefreshTokenError(
|
|
5642
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5643
|
+
);
|
|
5644
|
+
|
|
5606
5645
|
apiClient.setRefreshExpiration(
|
|
5607
5646
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5608
5647
|
);
|
|
@@ -5616,7 +5655,7 @@ const fillClient = (apiClient ) => {
|
|
|
5616
5655
|
return apiClient;
|
|
5617
5656
|
};
|
|
5618
5657
|
|
|
5619
|
-
var getApiClient = (forServer
|
|
5658
|
+
var getApiClient = (forServer = null) => {
|
|
5620
5659
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5621
5660
|
if (server in global.wazoClients) {
|
|
5622
5661
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5643,6 +5682,7 @@ class Auth {
|
|
|
5643
5682
|
|
|
5644
5683
|
|
|
5645
5684
|
|
|
5685
|
+
|
|
5646
5686
|
|
|
5647
5687
|
|
|
5648
5688
|
|
|
@@ -5680,6 +5720,14 @@ class Auth {
|
|
|
5680
5720
|
this.onRefreshTokenCallback(token, session);
|
|
5681
5721
|
}
|
|
5682
5722
|
});
|
|
5723
|
+
|
|
5724
|
+
setOnRefreshTokenError(error => {
|
|
5725
|
+
logger$9.error('on refresh token error', error);
|
|
5726
|
+
|
|
5727
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5728
|
+
this.onRefreshTokenCallbackError(error);
|
|
5729
|
+
}
|
|
5730
|
+
});
|
|
5683
5731
|
}
|
|
5684
5732
|
|
|
5685
5733
|
setFetchOptions(options ) {
|
|
@@ -5768,6 +5816,10 @@ class Auth {
|
|
|
5768
5816
|
this.onRefreshTokenCallback = callback;
|
|
5769
5817
|
}
|
|
5770
5818
|
|
|
5819
|
+
setOnRefreshTokenError(callback ) {
|
|
5820
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5771
5823
|
checkAuthorizations(session , authorizationName ) {
|
|
5772
5824
|
if (!authorizationName) {
|
|
5773
5825
|
return;
|
|
@@ -5800,6 +5852,12 @@ class Auth {
|
|
|
5800
5852
|
setRefreshToken(refreshToken);
|
|
5801
5853
|
}
|
|
5802
5854
|
|
|
5855
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5856
|
+
setRefreshTenantId(refreshTenantId);
|
|
5857
|
+
|
|
5858
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5859
|
+
}
|
|
5860
|
+
|
|
5803
5861
|
forceRefreshToken() {
|
|
5804
5862
|
getApiClient().forceRefreshToken();
|
|
5805
5863
|
}
|
|
@@ -7434,8 +7492,10 @@ class WebRTCClient extends Emitter {
|
|
|
7434
7492
|
conference: isConference,
|
|
7435
7493
|
};
|
|
7436
7494
|
|
|
7437
|
-
// Avoid sdh to
|
|
7438
|
-
session.sessionDescriptionHandler
|
|
7495
|
+
// Avoid sdh to create a new stream
|
|
7496
|
+
if (session.sessionDescriptionHandler) {
|
|
7497
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7498
|
+
}
|
|
7439
7499
|
|
|
7440
7500
|
// Send re-INVITE
|
|
7441
7501
|
return session.invite(options);
|
|
@@ -9406,7 +9466,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9406
9466
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9407
9467
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9408
9468
|
// We have to downgrade to audio.
|
|
9409
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9469
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9410
9470
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9411
9471
|
|
|
9412
9472
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9850,7 +9910,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9850
9910
|
|
|
9851
9911
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9852
9912
|
|
|
9853
|
-
// Stop
|
|
9913
|
+
// Stop screenshare if needed
|
|
9854
9914
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9855
9915
|
this.lastScreenShare = this.currentScreenShare;
|
|
9856
9916
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10426,7 +10486,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10426
10486
|
});
|
|
10427
10487
|
|
|
10428
10488
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10429
|
-
logger$7.
|
|
10489
|
+
logger$7.info('WebRTC client disconnected');
|
|
10430
10490
|
|
|
10431
10491
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10432
10492
|
|
|
@@ -10612,7 +10672,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10612
10672
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10613
10673
|
answered: state === sessionState.SessionState.Established,
|
|
10614
10674
|
paused: this.client.isCallHeld(sipSession),
|
|
10615
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10675
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10616
10676
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10617
10677
|
number,
|
|
10618
10678
|
ringing: false,
|
|
@@ -11446,7 +11506,7 @@ class WebSocketClient extends Emitter {
|
|
|
11446
11506
|
this.close();
|
|
11447
11507
|
}
|
|
11448
11508
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11449
|
-
logger$5.
|
|
11509
|
+
logger$5.info('Wazo WS url computed to reconnect', { url });
|
|
11450
11510
|
|
|
11451
11511
|
return url;
|
|
11452
11512
|
}
|
|
@@ -398,13 +398,9 @@ class IssueReporter {
|
|
|
398
398
|
|
|
399
399
|
setTimeout(() => {
|
|
400
400
|
if (isArray) {
|
|
401
|
-
payload = payload.map(message =>
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
} else {
|
|
406
|
-
// $FlowFixMe
|
|
407
|
-
payload._retry = retry + 1;
|
|
401
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
402
|
+
} else if (payload && typeof payload === 'object') {
|
|
403
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
408
404
|
}
|
|
409
405
|
|
|
410
406
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -412,6 +408,15 @@ class IssueReporter {
|
|
|
412
408
|
});
|
|
413
409
|
}
|
|
414
410
|
|
|
411
|
+
_writeRetryCount(message , count ) {
|
|
412
|
+
if (message && typeof message === 'object') {
|
|
413
|
+
// $FlowFixMe
|
|
414
|
+
message._retry = count;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return message;
|
|
418
|
+
}
|
|
419
|
+
|
|
415
420
|
_isLevelAbove(level1 , level2 ) {
|
|
416
421
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
417
422
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -400,13 +400,9 @@ class IssueReporter {
|
|
|
400
400
|
|
|
401
401
|
setTimeout(() => {
|
|
402
402
|
if (isArray) {
|
|
403
|
-
payload = payload.map(message =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
});
|
|
407
|
-
} else {
|
|
408
|
-
// $FlowFixMe
|
|
409
|
-
payload._retry = retry + 1;
|
|
403
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
404
|
+
} else if (payload && typeof payload === 'object') {
|
|
405
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
410
406
|
}
|
|
411
407
|
|
|
412
408
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -414,6 +410,15 @@ class IssueReporter {
|
|
|
414
410
|
});
|
|
415
411
|
}
|
|
416
412
|
|
|
413
|
+
_writeRetryCount(message , count ) {
|
|
414
|
+
if (message && typeof message === 'object') {
|
|
415
|
+
// $FlowFixMe
|
|
416
|
+
message._retry = count;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return message;
|
|
420
|
+
}
|
|
421
|
+
|
|
417
422
|
_isLevelAbove(level1 , level2 ) {
|
|
418
423
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
419
424
|
const index2 = LOG_LEVELS.indexOf(level2);
|
package/lib/web-rtc-client.js
CHANGED
|
@@ -689,13 +689,9 @@ class IssueReporter {
|
|
|
689
689
|
|
|
690
690
|
setTimeout(() => {
|
|
691
691
|
if (isArray) {
|
|
692
|
-
payload = payload.map(message =>
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
});
|
|
696
|
-
} else {
|
|
697
|
-
// $FlowFixMe
|
|
698
|
-
payload._retry = retry + 1;
|
|
692
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
693
|
+
} else if (payload && typeof payload === 'object') {
|
|
694
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
699
695
|
}
|
|
700
696
|
|
|
701
697
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -703,6 +699,15 @@ class IssueReporter {
|
|
|
703
699
|
});
|
|
704
700
|
}
|
|
705
701
|
|
|
702
|
+
_writeRetryCount(message , count ) {
|
|
703
|
+
if (message && typeof message === 'object') {
|
|
704
|
+
// $FlowFixMe
|
|
705
|
+
message._retry = count;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return message;
|
|
709
|
+
}
|
|
710
|
+
|
|
706
711
|
_isLevelAbove(level1 , level2 ) {
|
|
707
712
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
708
713
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2804,9 +2809,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2804
2809
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2805
2810
|
refresh_token: refreshToken,
|
|
2806
2811
|
client_id: client.clientId,
|
|
2807
|
-
tenant_id: tenantId,
|
|
2808
2812
|
};
|
|
2809
2813
|
|
|
2814
|
+
if (tenantId) {
|
|
2815
|
+
body.tenant_id = tenantId;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2810
2818
|
const headers = {
|
|
2811
2819
|
'Content-Type': 'application/json',
|
|
2812
2820
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4094,7 +4102,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4094
4102
|
global.wazoClientId = global.wazoClientId || {};
|
|
4095
4103
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4096
4104
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4105
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4097
4106
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4107
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4098
4108
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4099
4109
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4100
4110
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5140,6 +5150,7 @@ class ApiClient {
|
|
|
5140
5150
|
|
|
5141
5151
|
|
|
5142
5152
|
|
|
5153
|
+
|
|
5143
5154
|
|
|
5144
5155
|
|
|
5145
5156
|
|
|
@@ -5192,23 +5203,31 @@ class ApiClient {
|
|
|
5192
5203
|
return null;
|
|
5193
5204
|
}
|
|
5194
5205
|
|
|
5195
|
-
|
|
5196
|
-
this.refreshToken
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5206
|
+
try {
|
|
5207
|
+
const session = await this.auth.refreshToken(
|
|
5208
|
+
this.refreshToken,
|
|
5209
|
+
this.refreshBackend,
|
|
5210
|
+
this.refreshExpiration,
|
|
5211
|
+
this.isMobile,
|
|
5212
|
+
this.refreshTenantId,
|
|
5213
|
+
);
|
|
5214
|
+
|
|
5215
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5216
|
+
|
|
5217
|
+
if (this.onRefreshToken) {
|
|
5218
|
+
this.onRefreshToken(session.token, session);
|
|
5219
|
+
}
|
|
5204
5220
|
|
|
5205
|
-
|
|
5206
|
-
this.onRefreshToken(session.token, session);
|
|
5207
|
-
}
|
|
5221
|
+
this.setToken(session.token);
|
|
5208
5222
|
|
|
5209
|
-
|
|
5223
|
+
return session.token;
|
|
5224
|
+
} catch (error) {
|
|
5225
|
+
logger$1.error('token refresh, error', error);
|
|
5210
5226
|
|
|
5211
|
-
|
|
5227
|
+
if (this.onRefreshTokenError) {
|
|
5228
|
+
this.onRefreshTokenError(error);
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5212
5231
|
}
|
|
5213
5232
|
|
|
5214
5233
|
setToken(token ) {
|
|
@@ -5231,6 +5250,10 @@ class ApiClient {
|
|
|
5231
5250
|
this.onRefreshToken = onRefreshToken;
|
|
5232
5251
|
}
|
|
5233
5252
|
|
|
5253
|
+
setOnRefreshTokenError(callback ) {
|
|
5254
|
+
this.onRefreshTokenError = callback;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5234
5257
|
setRefreshExpiration(refreshExpiration ) {
|
|
5235
5258
|
this.refreshExpiration = refreshExpiration;
|
|
5236
5259
|
}
|
|
@@ -6098,8 +6121,10 @@ class WebRTCClient extends Emitter {
|
|
|
6098
6121
|
conference: isConference,
|
|
6099
6122
|
};
|
|
6100
6123
|
|
|
6101
|
-
// Avoid sdh to
|
|
6102
|
-
session.sessionDescriptionHandler
|
|
6124
|
+
// Avoid sdh to create a new stream
|
|
6125
|
+
if (session.sessionDescriptionHandler) {
|
|
6126
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6127
|
+
}
|
|
6103
6128
|
|
|
6104
6129
|
// Send re-INVITE
|
|
6105
6130
|
return session.invite(options);
|
package/lib/websocket-client.js
CHANGED
|
@@ -397,13 +397,9 @@ class IssueReporter {
|
|
|
397
397
|
|
|
398
398
|
setTimeout(() => {
|
|
399
399
|
if (isArray) {
|
|
400
|
-
payload = payload.map(message =>
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
});
|
|
404
|
-
} else {
|
|
405
|
-
// $FlowFixMe
|
|
406
|
-
payload._retry = retry + 1;
|
|
400
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
401
|
+
} else if (payload && typeof payload === 'object') {
|
|
402
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
407
403
|
}
|
|
408
404
|
|
|
409
405
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -411,6 +407,15 @@ class IssueReporter {
|
|
|
411
407
|
});
|
|
412
408
|
}
|
|
413
409
|
|
|
410
|
+
_writeRetryCount(message , count ) {
|
|
411
|
+
if (message && typeof message === 'object') {
|
|
412
|
+
// $FlowFixMe
|
|
413
|
+
message._retry = count;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return message;
|
|
417
|
+
}
|
|
418
|
+
|
|
414
419
|
_isLevelAbove(level1 , level2 ) {
|
|
415
420
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
416
421
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -871,7 +876,7 @@ class WebSocketClient extends Emitter {
|
|
|
871
876
|
this.close();
|
|
872
877
|
}
|
|
873
878
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
874
|
-
logger.
|
|
879
|
+
logger.info('Wazo WS url computed to reconnect', { url });
|
|
875
880
|
|
|
876
881
|
return url;
|
|
877
882
|
}
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
|
@@ -74,9 +74,12 @@ export default (client: ApiRequester, baseUrl: string) => ({
|
|
|
74
74
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
75
75
|
refresh_token: refreshToken,
|
|
76
76
|
client_id: client.clientId,
|
|
77
|
-
tenant_id: tenantId,
|
|
78
77
|
};
|
|
79
78
|
|
|
79
|
+
if (tenantId) {
|
|
80
|
+
body.tenant_id = tenantId;
|
|
81
|
+
}
|
|
82
|
+
|
|
80
83
|
const headers: Object = {
|
|
81
84
|
'Content-Type': 'application/json',
|
|
82
85
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
package/src/api-client.js
CHANGED
|
@@ -53,6 +53,7 @@ export default class ApiClient {
|
|
|
53
53
|
|
|
54
54
|
refreshToken: ?string;
|
|
55
55
|
onRefreshToken: ?Function;
|
|
56
|
+
onRefreshTokenError: ?Function;
|
|
56
57
|
refreshExpiration: ?number;
|
|
57
58
|
refreshBackend: ?string;
|
|
58
59
|
refreshTenantId: ?string;
|
|
@@ -105,23 +106,31 @@ export default class ApiClient {
|
|
|
105
106
|
return null;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
this.refreshToken
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
try {
|
|
110
|
+
const session = await this.auth.refreshToken(
|
|
111
|
+
this.refreshToken,
|
|
112
|
+
this.refreshBackend,
|
|
113
|
+
this.refreshExpiration,
|
|
114
|
+
this.isMobile,
|
|
115
|
+
this.refreshTenantId,
|
|
116
|
+
);
|
|
115
117
|
|
|
116
|
-
|
|
118
|
+
logger.info('token refreshed', { token: session.token });
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
if (this.onRefreshToken) {
|
|
121
|
+
this.onRefreshToken(session.token, session);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.setToken(session.token);
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
return session.token;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
logger.error('token refresh, error', error);
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
if (this.onRefreshTokenError) {
|
|
131
|
+
this.onRefreshTokenError(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
setToken(token: string) {
|
|
@@ -144,6 +153,10 @@ export default class ApiClient {
|
|
|
144
153
|
this.onRefreshToken = onRefreshToken;
|
|
145
154
|
}
|
|
146
155
|
|
|
156
|
+
setOnRefreshTokenError(callback: Function) {
|
|
157
|
+
this.onRefreshTokenError = callback;
|
|
158
|
+
}
|
|
159
|
+
|
|
147
160
|
setRefreshExpiration(refreshExpiration: number) {
|
|
148
161
|
this.refreshExpiration = refreshExpiration;
|
|
149
162
|
}
|
|
@@ -543,7 +543,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
543
543
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
544
544
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
545
545
|
// We have to downgrade to audio.
|
|
546
|
-
const screenshareStopped = this.currentScreenShare.
|
|
546
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
547
547
|
const constraints = { audio: false, video: screenshareStopped };
|
|
548
548
|
|
|
549
549
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -987,7 +987,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
987
987
|
|
|
988
988
|
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
989
989
|
|
|
990
|
-
// Stop
|
|
990
|
+
// Stop screenshare if needed
|
|
991
991
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
992
992
|
this.lastScreenShare = this.currentScreenShare;
|
|
993
993
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -1563,7 +1563,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1563
1563
|
});
|
|
1564
1564
|
|
|
1565
1565
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
1566
|
-
logger.
|
|
1566
|
+
logger.info('WebRTC client disconnected');
|
|
1567
1567
|
|
|
1568
1568
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
1569
1569
|
|
|
@@ -1751,7 +1751,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1751
1751
|
endTime: fromSession ? fromSession.endTime : null,
|
|
1752
1752
|
answered: state === SessionState.Established,
|
|
1753
1753
|
paused: this.client.isCallHeld(sipSession),
|
|
1754
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
1754
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
1755
1755
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
1756
1756
|
number,
|
|
1757
1757
|
ringing: false,
|
|
@@ -330,13 +330,9 @@ class IssueReporter {
|
|
|
330
330
|
|
|
331
331
|
setTimeout(() => {
|
|
332
332
|
if (isArray) {
|
|
333
|
-
payload = payload.map(message =>
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
337
|
-
} else {
|
|
338
|
-
// $FlowFixMe
|
|
339
|
-
payload._retry = retry + 1;
|
|
333
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
334
|
+
} else if (payload && typeof payload === 'object') {
|
|
335
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
340
336
|
}
|
|
341
337
|
|
|
342
338
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -344,6 +340,15 @@ class IssueReporter {
|
|
|
344
340
|
});
|
|
345
341
|
}
|
|
346
342
|
|
|
343
|
+
_writeRetryCount(message: string | Object, count: number): string | Object {
|
|
344
|
+
if (message && typeof message === 'object') {
|
|
345
|
+
// $FlowFixMe
|
|
346
|
+
message._retry = count;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return message;
|
|
350
|
+
}
|
|
351
|
+
|
|
347
352
|
_isLevelAbove(level1: string, level2: string) {
|
|
348
353
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
349
354
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -100,4 +100,10 @@ describe('IssueReporter', () => {
|
|
|
100
100
|
expect(IssueReporter.removeSlashes('\"')).toBe("'");
|
|
101
101
|
expect(IssueReporter.removeSlashes('\\\"')).toBe("'");
|
|
102
102
|
});
|
|
103
|
+
|
|
104
|
+
it('Add retry count', () => {
|
|
105
|
+
expect(IssueReporter._writeRetryCount('', 1)).toBe('');
|
|
106
|
+
expect(IssueReporter._writeRetryCount('{}', 1)).toBe('{}');
|
|
107
|
+
expect(IssueReporter._writeRetryCount({}, 1)).toEqual({ _retry: 1 });
|
|
108
|
+
});
|
|
103
109
|
});
|