@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/esm/simple/utils.js
CHANGED
|
@@ -1909,13 +1909,9 @@ class IssueReporter {
|
|
|
1909
1909
|
|
|
1910
1910
|
setTimeout(() => {
|
|
1911
1911
|
if (isArray) {
|
|
1912
|
-
payload = payload.map(message =>
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
});
|
|
1916
|
-
} else {
|
|
1917
|
-
// $FlowFixMe
|
|
1918
|
-
payload._retry = retry + 1;
|
|
1912
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1913
|
+
} else if (payload && typeof payload === 'object') {
|
|
1914
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1919
1915
|
}
|
|
1920
1916
|
|
|
1921
1917
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1923,6 +1919,15 @@ class IssueReporter {
|
|
|
1923
1919
|
});
|
|
1924
1920
|
}
|
|
1925
1921
|
|
|
1922
|
+
_writeRetryCount(message , count ) {
|
|
1923
|
+
if (message && typeof message === 'object') {
|
|
1924
|
+
// $FlowFixMe
|
|
1925
|
+
message._retry = count;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
return message;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1926
1931
|
_isLevelAbove(level1 , level2 ) {
|
|
1927
1932
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1928
1933
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2265,9 +2270,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2265
2270
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2266
2271
|
refresh_token: refreshToken,
|
|
2267
2272
|
client_id: client.clientId,
|
|
2268
|
-
tenant_id: tenantId,
|
|
2269
2273
|
};
|
|
2270
2274
|
|
|
2275
|
+
if (tenantId) {
|
|
2276
|
+
body.tenant_id = tenantId;
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2271
2279
|
const headers = {
|
|
2272
2280
|
'Content-Type': 'application/json',
|
|
2273
2281
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5415,6 +5423,7 @@ class ApiClient {
|
|
|
5415
5423
|
|
|
5416
5424
|
|
|
5417
5425
|
|
|
5426
|
+
|
|
5418
5427
|
|
|
5419
5428
|
|
|
5420
5429
|
|
|
@@ -5467,23 +5476,31 @@ class ApiClient {
|
|
|
5467
5476
|
return null;
|
|
5468
5477
|
}
|
|
5469
5478
|
|
|
5470
|
-
|
|
5471
|
-
this.refreshToken
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5479
|
+
try {
|
|
5480
|
+
const session = await this.auth.refreshToken(
|
|
5481
|
+
this.refreshToken,
|
|
5482
|
+
this.refreshBackend,
|
|
5483
|
+
this.refreshExpiration,
|
|
5484
|
+
this.isMobile,
|
|
5485
|
+
this.refreshTenantId,
|
|
5486
|
+
);
|
|
5477
5487
|
|
|
5478
|
-
|
|
5488
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5479
5489
|
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5490
|
+
if (this.onRefreshToken) {
|
|
5491
|
+
this.onRefreshToken(session.token, session);
|
|
5492
|
+
}
|
|
5483
5493
|
|
|
5484
|
-
|
|
5494
|
+
this.setToken(session.token);
|
|
5485
5495
|
|
|
5486
|
-
|
|
5496
|
+
return session.token;
|
|
5497
|
+
} catch (error) {
|
|
5498
|
+
logger$a.error('token refresh, error', error);
|
|
5499
|
+
|
|
5500
|
+
if (this.onRefreshTokenError) {
|
|
5501
|
+
this.onRefreshTokenError(error);
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5487
5504
|
}
|
|
5488
5505
|
|
|
5489
5506
|
setToken(token ) {
|
|
@@ -5506,6 +5523,10 @@ class ApiClient {
|
|
|
5506
5523
|
this.onRefreshToken = onRefreshToken;
|
|
5507
5524
|
}
|
|
5508
5525
|
|
|
5526
|
+
setOnRefreshTokenError(callback ) {
|
|
5527
|
+
this.onRefreshTokenError = callback;
|
|
5528
|
+
}
|
|
5529
|
+
|
|
5509
5530
|
setRefreshExpiration(refreshExpiration ) {
|
|
5510
5531
|
this.refreshExpiration = refreshExpiration;
|
|
5511
5532
|
}
|
|
@@ -5541,7 +5562,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5541
5562
|
global.wazoClientId = global.wazoClientId || {};
|
|
5542
5563
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5543
5564
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5565
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5544
5566
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5567
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5545
5568
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5546
5569
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5547
5570
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5563,10 +5586,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5563
5586
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5564
5587
|
};
|
|
5565
5588
|
|
|
5589
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5590
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5591
|
+
};
|
|
5592
|
+
|
|
5566
5593
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5567
5594
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5568
5595
|
};
|
|
5569
5596
|
|
|
5597
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5598
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5599
|
+
};
|
|
5600
|
+
|
|
5570
5601
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5571
5602
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5572
5603
|
};
|
|
@@ -5585,12 +5616,20 @@ const fillClient = (apiClient ) => {
|
|
|
5585
5616
|
|
|
5586
5617
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5587
5618
|
|
|
5619
|
+
apiClient.setRefreshTenantId(
|
|
5620
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5621
|
+
);
|
|
5622
|
+
|
|
5588
5623
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5589
5624
|
|
|
5590
5625
|
apiClient.setOnRefreshToken(
|
|
5591
5626
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5592
5627
|
);
|
|
5593
5628
|
|
|
5629
|
+
apiClient.setOnRefreshTokenError(
|
|
5630
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5631
|
+
);
|
|
5632
|
+
|
|
5594
5633
|
apiClient.setRefreshExpiration(
|
|
5595
5634
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5596
5635
|
);
|
|
@@ -5604,7 +5643,7 @@ const fillClient = (apiClient ) => {
|
|
|
5604
5643
|
return apiClient;
|
|
5605
5644
|
};
|
|
5606
5645
|
|
|
5607
|
-
var getApiClient = (forServer
|
|
5646
|
+
var getApiClient = (forServer = null) => {
|
|
5608
5647
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5609
5648
|
if (server in global.wazoClients) {
|
|
5610
5649
|
return fillClient(global.wazoClients[server]);
|
|
@@ -5631,6 +5670,7 @@ class Auth {
|
|
|
5631
5670
|
|
|
5632
5671
|
|
|
5633
5672
|
|
|
5673
|
+
|
|
5634
5674
|
|
|
5635
5675
|
|
|
5636
5676
|
|
|
@@ -5668,6 +5708,14 @@ class Auth {
|
|
|
5668
5708
|
this.onRefreshTokenCallback(token, session);
|
|
5669
5709
|
}
|
|
5670
5710
|
});
|
|
5711
|
+
|
|
5712
|
+
setOnRefreshTokenError(error => {
|
|
5713
|
+
logger$9.error('on refresh token error', error);
|
|
5714
|
+
|
|
5715
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5716
|
+
this.onRefreshTokenCallbackError(error);
|
|
5717
|
+
}
|
|
5718
|
+
});
|
|
5671
5719
|
}
|
|
5672
5720
|
|
|
5673
5721
|
setFetchOptions(options ) {
|
|
@@ -5756,6 +5804,10 @@ class Auth {
|
|
|
5756
5804
|
this.onRefreshTokenCallback = callback;
|
|
5757
5805
|
}
|
|
5758
5806
|
|
|
5807
|
+
setOnRefreshTokenError(callback ) {
|
|
5808
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5809
|
+
}
|
|
5810
|
+
|
|
5759
5811
|
checkAuthorizations(session , authorizationName ) {
|
|
5760
5812
|
if (!authorizationName) {
|
|
5761
5813
|
return;
|
|
@@ -5788,6 +5840,12 @@ class Auth {
|
|
|
5788
5840
|
setRefreshToken(refreshToken);
|
|
5789
5841
|
}
|
|
5790
5842
|
|
|
5843
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5844
|
+
setRefreshTenantId(refreshTenantId);
|
|
5845
|
+
|
|
5846
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5847
|
+
}
|
|
5848
|
+
|
|
5791
5849
|
forceRefreshToken() {
|
|
5792
5850
|
getApiClient().forceRefreshToken();
|
|
5793
5851
|
}
|
|
@@ -7422,8 +7480,10 @@ class WebRTCClient extends Emitter {
|
|
|
7422
7480
|
conference: isConference,
|
|
7423
7481
|
};
|
|
7424
7482
|
|
|
7425
|
-
// Avoid sdh to
|
|
7426
|
-
session.sessionDescriptionHandler
|
|
7483
|
+
// Avoid sdh to create a new stream
|
|
7484
|
+
if (session.sessionDescriptionHandler) {
|
|
7485
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7486
|
+
}
|
|
7427
7487
|
|
|
7428
7488
|
// Send re-INVITE
|
|
7429
7489
|
return session.invite(options);
|
|
@@ -9394,7 +9454,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9394
9454
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9395
9455
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9396
9456
|
// We have to downgrade to audio.
|
|
9397
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9457
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9398
9458
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9399
9459
|
|
|
9400
9460
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9838,7 +9898,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9838
9898
|
|
|
9839
9899
|
logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9840
9900
|
|
|
9841
|
-
// Stop
|
|
9901
|
+
// Stop screenshare if needed
|
|
9842
9902
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9843
9903
|
this.lastScreenShare = this.currentScreenShare;
|
|
9844
9904
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10414,7 +10474,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10414
10474
|
});
|
|
10415
10475
|
|
|
10416
10476
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10417
|
-
logger$7.
|
|
10477
|
+
logger$7.info('WebRTC client disconnected');
|
|
10418
10478
|
|
|
10419
10479
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10420
10480
|
|
|
@@ -10600,7 +10660,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10600
10660
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10601
10661
|
answered: state === SessionState.Established,
|
|
10602
10662
|
paused: this.client.isCallHeld(sipSession),
|
|
10603
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10663
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10604
10664
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10605
10665
|
number,
|
|
10606
10666
|
ringing: false,
|
|
@@ -11434,7 +11494,7 @@ class WebSocketClient extends Emitter {
|
|
|
11434
11494
|
this.close();
|
|
11435
11495
|
}
|
|
11436
11496
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11437
|
-
logger$5.
|
|
11497
|
+
logger$5.info('Wazo WS url computed to reconnect', { url });
|
|
11438
11498
|
|
|
11439
11499
|
return url;
|
|
11440
11500
|
}
|
|
@@ -392,13 +392,9 @@ class IssueReporter {
|
|
|
392
392
|
|
|
393
393
|
setTimeout(() => {
|
|
394
394
|
if (isArray) {
|
|
395
|
-
payload = payload.map(message =>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
});
|
|
399
|
-
} else {
|
|
400
|
-
// $FlowFixMe
|
|
401
|
-
payload._retry = retry + 1;
|
|
395
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
396
|
+
} else if (payload && typeof payload === 'object') {
|
|
397
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
402
398
|
}
|
|
403
399
|
|
|
404
400
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -406,6 +402,15 @@ class IssueReporter {
|
|
|
406
402
|
});
|
|
407
403
|
}
|
|
408
404
|
|
|
405
|
+
_writeRetryCount(message , count ) {
|
|
406
|
+
if (message && typeof message === 'object') {
|
|
407
|
+
// $FlowFixMe
|
|
408
|
+
message._retry = count;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return message;
|
|
412
|
+
}
|
|
413
|
+
|
|
409
414
|
_isLevelAbove(level1 , level2 ) {
|
|
410
415
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
411
416
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -392,13 +392,9 @@ class IssueReporter {
|
|
|
392
392
|
|
|
393
393
|
setTimeout(() => {
|
|
394
394
|
if (isArray) {
|
|
395
|
-
payload = payload.map(message =>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
});
|
|
399
|
-
} else {
|
|
400
|
-
// $FlowFixMe
|
|
401
|
-
payload._retry = retry + 1;
|
|
395
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
396
|
+
} else if (payload && typeof payload === 'object') {
|
|
397
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
402
398
|
}
|
|
403
399
|
|
|
404
400
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -406,6 +402,15 @@ class IssueReporter {
|
|
|
406
402
|
});
|
|
407
403
|
}
|
|
408
404
|
|
|
405
|
+
_writeRetryCount(message , count ) {
|
|
406
|
+
if (message && typeof message === 'object') {
|
|
407
|
+
// $FlowFixMe
|
|
408
|
+
message._retry = count;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return message;
|
|
412
|
+
}
|
|
413
|
+
|
|
409
414
|
_isLevelAbove(level1 , level2 ) {
|
|
410
415
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
411
416
|
const index2 = LOG_LEVELS.indexOf(level2);
|
package/esm/web-rtc-client.js
CHANGED
|
@@ -678,13 +678,9 @@ class IssueReporter {
|
|
|
678
678
|
|
|
679
679
|
setTimeout(() => {
|
|
680
680
|
if (isArray) {
|
|
681
|
-
payload = payload.map(message =>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
});
|
|
685
|
-
} else {
|
|
686
|
-
// $FlowFixMe
|
|
687
|
-
payload._retry = retry + 1;
|
|
681
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
682
|
+
} else if (payload && typeof payload === 'object') {
|
|
683
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
688
684
|
}
|
|
689
685
|
|
|
690
686
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -692,6 +688,15 @@ class IssueReporter {
|
|
|
692
688
|
});
|
|
693
689
|
}
|
|
694
690
|
|
|
691
|
+
_writeRetryCount(message , count ) {
|
|
692
|
+
if (message && typeof message === 'object') {
|
|
693
|
+
// $FlowFixMe
|
|
694
|
+
message._retry = count;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return message;
|
|
698
|
+
}
|
|
699
|
+
|
|
695
700
|
_isLevelAbove(level1 , level2 ) {
|
|
696
701
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
697
702
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2793,9 +2798,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2793
2798
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2794
2799
|
refresh_token: refreshToken,
|
|
2795
2800
|
client_id: client.clientId,
|
|
2796
|
-
tenant_id: tenantId,
|
|
2797
2801
|
};
|
|
2798
2802
|
|
|
2803
|
+
if (tenantId) {
|
|
2804
|
+
body.tenant_id = tenantId;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2799
2807
|
const headers = {
|
|
2800
2808
|
'Content-Type': 'application/json',
|
|
2801
2809
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4083,7 +4091,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4083
4091
|
global.wazoClientId = global.wazoClientId || {};
|
|
4084
4092
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4085
4093
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4094
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4086
4095
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4096
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4087
4097
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4088
4098
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4089
4099
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5129,6 +5139,7 @@ class ApiClient {
|
|
|
5129
5139
|
|
|
5130
5140
|
|
|
5131
5141
|
|
|
5142
|
+
|
|
5132
5143
|
|
|
5133
5144
|
|
|
5134
5145
|
|
|
@@ -5181,23 +5192,31 @@ class ApiClient {
|
|
|
5181
5192
|
return null;
|
|
5182
5193
|
}
|
|
5183
5194
|
|
|
5184
|
-
|
|
5185
|
-
this.refreshToken
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5195
|
+
try {
|
|
5196
|
+
const session = await this.auth.refreshToken(
|
|
5197
|
+
this.refreshToken,
|
|
5198
|
+
this.refreshBackend,
|
|
5199
|
+
this.refreshExpiration,
|
|
5200
|
+
this.isMobile,
|
|
5201
|
+
this.refreshTenantId,
|
|
5202
|
+
);
|
|
5203
|
+
|
|
5204
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5205
|
+
|
|
5206
|
+
if (this.onRefreshToken) {
|
|
5207
|
+
this.onRefreshToken(session.token, session);
|
|
5208
|
+
}
|
|
5193
5209
|
|
|
5194
|
-
|
|
5195
|
-
this.onRefreshToken(session.token, session);
|
|
5196
|
-
}
|
|
5210
|
+
this.setToken(session.token);
|
|
5197
5211
|
|
|
5198
|
-
|
|
5212
|
+
return session.token;
|
|
5213
|
+
} catch (error) {
|
|
5214
|
+
logger$1.error('token refresh, error', error);
|
|
5199
5215
|
|
|
5200
|
-
|
|
5216
|
+
if (this.onRefreshTokenError) {
|
|
5217
|
+
this.onRefreshTokenError(error);
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5201
5220
|
}
|
|
5202
5221
|
|
|
5203
5222
|
setToken(token ) {
|
|
@@ -5220,6 +5239,10 @@ class ApiClient {
|
|
|
5220
5239
|
this.onRefreshToken = onRefreshToken;
|
|
5221
5240
|
}
|
|
5222
5241
|
|
|
5242
|
+
setOnRefreshTokenError(callback ) {
|
|
5243
|
+
this.onRefreshTokenError = callback;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5223
5246
|
setRefreshExpiration(refreshExpiration ) {
|
|
5224
5247
|
this.refreshExpiration = refreshExpiration;
|
|
5225
5248
|
}
|
|
@@ -6087,8 +6110,10 @@ class WebRTCClient extends Emitter {
|
|
|
6087
6110
|
conference: isConference,
|
|
6088
6111
|
};
|
|
6089
6112
|
|
|
6090
|
-
// Avoid sdh to
|
|
6091
|
-
session.sessionDescriptionHandler
|
|
6113
|
+
// Avoid sdh to create a new stream
|
|
6114
|
+
if (session.sessionDescriptionHandler) {
|
|
6115
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6116
|
+
}
|
|
6092
6117
|
|
|
6093
6118
|
// Send re-INVITE
|
|
6094
6119
|
return session.invite(options);
|
package/esm/websocket-client.js
CHANGED
|
@@ -387,13 +387,9 @@ class IssueReporter {
|
|
|
387
387
|
|
|
388
388
|
setTimeout(() => {
|
|
389
389
|
if (isArray) {
|
|
390
|
-
payload = payload.map(message =>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
394
|
-
} else {
|
|
395
|
-
// $FlowFixMe
|
|
396
|
-
payload._retry = retry + 1;
|
|
390
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
391
|
+
} else if (payload && typeof payload === 'object') {
|
|
392
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
397
393
|
}
|
|
398
394
|
|
|
399
395
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -401,6 +397,15 @@ class IssueReporter {
|
|
|
401
397
|
});
|
|
402
398
|
}
|
|
403
399
|
|
|
400
|
+
_writeRetryCount(message , count ) {
|
|
401
|
+
if (message && typeof message === 'object') {
|
|
402
|
+
// $FlowFixMe
|
|
403
|
+
message._retry = count;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return message;
|
|
407
|
+
}
|
|
408
|
+
|
|
404
409
|
_isLevelAbove(level1 , level2 ) {
|
|
405
410
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
406
411
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -861,7 +866,7 @@ class WebSocketClient extends Emitter {
|
|
|
861
866
|
this.close();
|
|
862
867
|
}
|
|
863
868
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
864
|
-
logger.
|
|
869
|
+
logger.info('Wazo WS url computed to reconnect', { url });
|
|
865
870
|
|
|
866
871
|
return url;
|
|
867
872
|
}
|
|
@@ -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' } : {}),
|
|
@@ -3541,7 +3549,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3541
3549
|
global.wazoClientId = global.wazoClientId || {};
|
|
3542
3550
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3543
3551
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3552
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3544
3553
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3554
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3545
3555
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3546
3556
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3547
3557
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4587,6 +4597,7 @@ class ApiClient {
|
|
|
4587
4597
|
|
|
4588
4598
|
|
|
4589
4599
|
|
|
4600
|
+
|
|
4590
4601
|
|
|
4591
4602
|
|
|
4592
4603
|
|
|
@@ -4639,23 +4650,31 @@ class ApiClient {
|
|
|
4639
4650
|
return null;
|
|
4640
4651
|
}
|
|
4641
4652
|
|
|
4642
|
-
|
|
4643
|
-
this.refreshToken
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4653
|
+
try {
|
|
4654
|
+
const session = await this.auth.refreshToken(
|
|
4655
|
+
this.refreshToken,
|
|
4656
|
+
this.refreshBackend,
|
|
4657
|
+
this.refreshExpiration,
|
|
4658
|
+
this.isMobile,
|
|
4659
|
+
this.refreshTenantId,
|
|
4660
|
+
);
|
|
4661
|
+
|
|
4662
|
+
logger.info('token refreshed', { token: session.token });
|
|
4663
|
+
|
|
4664
|
+
if (this.onRefreshToken) {
|
|
4665
|
+
this.onRefreshToken(session.token, session);
|
|
4666
|
+
}
|
|
4651
4667
|
|
|
4652
|
-
|
|
4653
|
-
this.onRefreshToken(session.token, session);
|
|
4654
|
-
}
|
|
4668
|
+
this.setToken(session.token);
|
|
4655
4669
|
|
|
4656
|
-
|
|
4670
|
+
return session.token;
|
|
4671
|
+
} catch (error) {
|
|
4672
|
+
logger.error('token refresh, error', error);
|
|
4657
4673
|
|
|
4658
|
-
|
|
4674
|
+
if (this.onRefreshTokenError) {
|
|
4675
|
+
this.onRefreshTokenError(error);
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4659
4678
|
}
|
|
4660
4679
|
|
|
4661
4680
|
setToken(token ) {
|
|
@@ -4678,6 +4697,10 @@ class ApiClient {
|
|
|
4678
4697
|
this.onRefreshToken = onRefreshToken;
|
|
4679
4698
|
}
|
|
4680
4699
|
|
|
4700
|
+
setOnRefreshTokenError(callback ) {
|
|
4701
|
+
this.onRefreshTokenError = callback;
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4681
4704
|
setRefreshExpiration(refreshExpiration ) {
|
|
4682
4705
|
this.refreshExpiration = refreshExpiration;
|
|
4683
4706
|
}
|