@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
|
@@ -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]);
|
|
@@ -7140,8 +7179,10 @@ class WebRTCClient extends Emitter {
|
|
|
7140
7179
|
conference: isConference,
|
|
7141
7180
|
};
|
|
7142
7181
|
|
|
7143
|
-
// Avoid sdh to
|
|
7144
|
-
session.sessionDescriptionHandler
|
|
7182
|
+
// Avoid sdh to create a new stream
|
|
7183
|
+
if (session.sessionDescriptionHandler) {
|
|
7184
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7185
|
+
}
|
|
7145
7186
|
|
|
7146
7187
|
// Send re-INVITE
|
|
7147
7188
|
return session.invite(options);
|
|
@@ -9112,7 +9153,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9112
9153
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9113
9154
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9114
9155
|
// We have to downgrade to audio.
|
|
9115
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9156
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9116
9157
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9117
9158
|
|
|
9118
9159
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9556,7 +9597,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9556
9597
|
|
|
9557
9598
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9558
9599
|
|
|
9559
|
-
// Stop
|
|
9600
|
+
// Stop screenshare if needed
|
|
9560
9601
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9561
9602
|
this.lastScreenShare = this.currentScreenShare;
|
|
9562
9603
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10132,7 +10173,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10132
10173
|
});
|
|
10133
10174
|
|
|
10134
10175
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10135
|
-
logger$8.
|
|
10176
|
+
logger$8.info('WebRTC client disconnected');
|
|
10136
10177
|
|
|
10137
10178
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10138
10179
|
|
|
@@ -10318,7 +10359,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10318
10359
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10319
10360
|
answered: state === SessionState.Established,
|
|
10320
10361
|
paused: this.client.isCallHeld(sipSession),
|
|
10321
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10362
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10322
10363
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10323
10364
|
number,
|
|
10324
10365
|
ringing: false,
|
|
@@ -11152,7 +11193,7 @@ class WebSocketClient extends Emitter {
|
|
|
11152
11193
|
this.close();
|
|
11153
11194
|
}
|
|
11154
11195
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11155
|
-
logger$6.
|
|
11196
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11156
11197
|
|
|
11157
11198
|
return url;
|
|
11158
11199
|
}
|
|
@@ -13701,6 +13742,7 @@ class Auth {
|
|
|
13701
13742
|
|
|
13702
13743
|
|
|
13703
13744
|
|
|
13745
|
+
|
|
13704
13746
|
|
|
13705
13747
|
|
|
13706
13748
|
|
|
@@ -13738,6 +13780,14 @@ class Auth {
|
|
|
13738
13780
|
this.onRefreshTokenCallback(token, session);
|
|
13739
13781
|
}
|
|
13740
13782
|
});
|
|
13783
|
+
|
|
13784
|
+
setOnRefreshTokenError(error => {
|
|
13785
|
+
logger.error('on refresh token error', error);
|
|
13786
|
+
|
|
13787
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13788
|
+
this.onRefreshTokenCallbackError(error);
|
|
13789
|
+
}
|
|
13790
|
+
});
|
|
13741
13791
|
}
|
|
13742
13792
|
|
|
13743
13793
|
setFetchOptions(options ) {
|
|
@@ -13826,6 +13876,10 @@ class Auth {
|
|
|
13826
13876
|
this.onRefreshTokenCallback = callback;
|
|
13827
13877
|
}
|
|
13828
13878
|
|
|
13879
|
+
setOnRefreshTokenError(callback ) {
|
|
13880
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13881
|
+
}
|
|
13882
|
+
|
|
13829
13883
|
checkAuthorizations(session , authorizationName ) {
|
|
13830
13884
|
if (!authorizationName) {
|
|
13831
13885
|
return;
|
|
@@ -13858,6 +13912,12 @@ class Auth {
|
|
|
13858
13912
|
setRefreshToken(refreshToken);
|
|
13859
13913
|
}
|
|
13860
13914
|
|
|
13915
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13916
|
+
setRefreshTenantId(refreshTenantId);
|
|
13917
|
+
|
|
13918
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13919
|
+
}
|
|
13920
|
+
|
|
13861
13921
|
forceRefreshToken() {
|
|
13862
13922
|
getApiClient().forceRefreshToken();
|
|
13863
13923
|
}
|
package/esm/simple/Directory.js
CHANGED
|
@@ -396,13 +396,9 @@ class IssueReporter {
|
|
|
396
396
|
|
|
397
397
|
setTimeout(() => {
|
|
398
398
|
if (isArray) {
|
|
399
|
-
payload = payload.map(message =>
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
});
|
|
403
|
-
} else {
|
|
404
|
-
// $FlowFixMe
|
|
405
|
-
payload._retry = retry + 1;
|
|
399
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
400
|
+
} else if (payload && typeof payload === 'object') {
|
|
401
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
406
402
|
}
|
|
407
403
|
|
|
408
404
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -410,6 +406,15 @@ class IssueReporter {
|
|
|
410
406
|
});
|
|
411
407
|
}
|
|
412
408
|
|
|
409
|
+
_writeRetryCount(message , count ) {
|
|
410
|
+
if (message && typeof message === 'object') {
|
|
411
|
+
// $FlowFixMe
|
|
412
|
+
message._retry = count;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return message;
|
|
416
|
+
}
|
|
417
|
+
|
|
413
418
|
_isLevelAbove(level1 , level2 ) {
|
|
414
419
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
415
420
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2245,9 +2250,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2245
2250
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2246
2251
|
refresh_token: refreshToken,
|
|
2247
2252
|
client_id: client.clientId,
|
|
2248
|
-
tenant_id: tenantId,
|
|
2249
2253
|
};
|
|
2250
2254
|
|
|
2255
|
+
if (tenantId) {
|
|
2256
|
+
body.tenant_id = tenantId;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2251
2259
|
const headers = {
|
|
2252
2260
|
'Content-Type': 'application/json',
|
|
2253
2261
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4566,6 +4574,7 @@ class ApiClient {
|
|
|
4566
4574
|
|
|
4567
4575
|
|
|
4568
4576
|
|
|
4577
|
+
|
|
4569
4578
|
|
|
4570
4579
|
|
|
4571
4580
|
|
|
@@ -4618,23 +4627,31 @@ class ApiClient {
|
|
|
4618
4627
|
return null;
|
|
4619
4628
|
}
|
|
4620
4629
|
|
|
4621
|
-
|
|
4622
|
-
this.refreshToken
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
+
try {
|
|
4631
|
+
const session = await this.auth.refreshToken(
|
|
4632
|
+
this.refreshToken,
|
|
4633
|
+
this.refreshBackend,
|
|
4634
|
+
this.refreshExpiration,
|
|
4635
|
+
this.isMobile,
|
|
4636
|
+
this.refreshTenantId,
|
|
4637
|
+
);
|
|
4638
|
+
|
|
4639
|
+
logger.info('token refreshed', { token: session.token });
|
|
4640
|
+
|
|
4641
|
+
if (this.onRefreshToken) {
|
|
4642
|
+
this.onRefreshToken(session.token, session);
|
|
4643
|
+
}
|
|
4630
4644
|
|
|
4631
|
-
|
|
4632
|
-
this.onRefreshToken(session.token, session);
|
|
4633
|
-
}
|
|
4645
|
+
this.setToken(session.token);
|
|
4634
4646
|
|
|
4635
|
-
|
|
4647
|
+
return session.token;
|
|
4648
|
+
} catch (error) {
|
|
4649
|
+
logger.error('token refresh, error', error);
|
|
4636
4650
|
|
|
4637
|
-
|
|
4651
|
+
if (this.onRefreshTokenError) {
|
|
4652
|
+
this.onRefreshTokenError(error);
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4638
4655
|
}
|
|
4639
4656
|
|
|
4640
4657
|
setToken(token ) {
|
|
@@ -4657,6 +4674,10 @@ class ApiClient {
|
|
|
4657
4674
|
this.onRefreshToken = onRefreshToken;
|
|
4658
4675
|
}
|
|
4659
4676
|
|
|
4677
|
+
setOnRefreshTokenError(callback ) {
|
|
4678
|
+
this.onRefreshTokenError = callback;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4660
4681
|
setRefreshExpiration(refreshExpiration ) {
|
|
4661
4682
|
this.refreshExpiration = refreshExpiration;
|
|
4662
4683
|
}
|
|
@@ -4692,7 +4713,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4692
4713
|
global.wazoClientId = global.wazoClientId || {};
|
|
4693
4714
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4694
4715
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4716
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4695
4717
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4718
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4696
4719
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4697
4720
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4698
4721
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4708,12 +4731,20 @@ const fillClient = (apiClient ) => {
|
|
|
4708
4731
|
|
|
4709
4732
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4710
4733
|
|
|
4734
|
+
apiClient.setRefreshTenantId(
|
|
4735
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4736
|
+
);
|
|
4737
|
+
|
|
4711
4738
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4712
4739
|
|
|
4713
4740
|
apiClient.setOnRefreshToken(
|
|
4714
4741
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4715
4742
|
);
|
|
4716
4743
|
|
|
4744
|
+
apiClient.setOnRefreshTokenError(
|
|
4745
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4746
|
+
);
|
|
4747
|
+
|
|
4717
4748
|
apiClient.setRefreshExpiration(
|
|
4718
4749
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4719
4750
|
);
|
|
@@ -4727,7 +4758,7 @@ const fillClient = (apiClient ) => {
|
|
|
4727
4758
|
return apiClient;
|
|
4728
4759
|
};
|
|
4729
4760
|
|
|
4730
|
-
var getApiClient = (forServer
|
|
4761
|
+
var getApiClient = (forServer = null) => {
|
|
4731
4762
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4732
4763
|
if (server in global.wazoClients) {
|
|
4733
4764
|
return fillClient(global.wazoClients[server]);
|
package/esm/simple/Phone.js
CHANGED
|
@@ -1029,13 +1029,9 @@ class IssueReporter {
|
|
|
1029
1029
|
|
|
1030
1030
|
setTimeout(() => {
|
|
1031
1031
|
if (isArray) {
|
|
1032
|
-
payload = payload.map(message =>
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
});
|
|
1036
|
-
} else {
|
|
1037
|
-
// $FlowFixMe
|
|
1038
|
-
payload._retry = retry + 1;
|
|
1032
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1033
|
+
} else if (payload && typeof payload === 'object') {
|
|
1034
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1039
1035
|
}
|
|
1040
1036
|
|
|
1041
1037
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1043,6 +1039,15 @@ class IssueReporter {
|
|
|
1043
1039
|
});
|
|
1044
1040
|
}
|
|
1045
1041
|
|
|
1042
|
+
_writeRetryCount(message , count ) {
|
|
1043
|
+
if (message && typeof message === 'object') {
|
|
1044
|
+
// $FlowFixMe
|
|
1045
|
+
message._retry = count;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
return message;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1046
1051
|
_isLevelAbove(level1 , level2 ) {
|
|
1047
1052
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1048
1053
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2868,9 +2873,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2868
2873
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2869
2874
|
refresh_token: refreshToken,
|
|
2870
2875
|
client_id: client.clientId,
|
|
2871
|
-
tenant_id: tenantId,
|
|
2872
2876
|
};
|
|
2873
2877
|
|
|
2878
|
+
if (tenantId) {
|
|
2879
|
+
body.tenant_id = tenantId;
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2874
2882
|
const headers = {
|
|
2875
2883
|
'Content-Type': 'application/json',
|
|
2876
2884
|
...(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]);
|
|
@@ -7140,8 +7179,10 @@ class WebRTCClient extends Emitter {
|
|
|
7140
7179
|
conference: isConference,
|
|
7141
7180
|
};
|
|
7142
7181
|
|
|
7143
|
-
// Avoid sdh to
|
|
7144
|
-
session.sessionDescriptionHandler
|
|
7182
|
+
// Avoid sdh to create a new stream
|
|
7183
|
+
if (session.sessionDescriptionHandler) {
|
|
7184
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7185
|
+
}
|
|
7145
7186
|
|
|
7146
7187
|
// Send re-INVITE
|
|
7147
7188
|
return session.invite(options);
|
|
@@ -9112,7 +9153,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9112
9153
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9113
9154
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9114
9155
|
// We have to downgrade to audio.
|
|
9115
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9156
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9116
9157
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9117
9158
|
|
|
9118
9159
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9556,7 +9597,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9556
9597
|
|
|
9557
9598
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9558
9599
|
|
|
9559
|
-
// Stop
|
|
9600
|
+
// Stop screenshare if needed
|
|
9560
9601
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9561
9602
|
this.lastScreenShare = this.currentScreenShare;
|
|
9562
9603
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10132,7 +10173,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10132
10173
|
});
|
|
10133
10174
|
|
|
10134
10175
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10135
|
-
logger$8.
|
|
10176
|
+
logger$8.info('WebRTC client disconnected');
|
|
10136
10177
|
|
|
10137
10178
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10138
10179
|
|
|
@@ -10318,7 +10359,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10318
10359
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10319
10360
|
answered: state === SessionState.Established,
|
|
10320
10361
|
paused: this.client.isCallHeld(sipSession),
|
|
10321
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10362
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10322
10363
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10323
10364
|
number,
|
|
10324
10365
|
ringing: false,
|
|
@@ -10402,6 +10443,7 @@ class Auth {
|
|
|
10402
10443
|
|
|
10403
10444
|
|
|
10404
10445
|
|
|
10446
|
+
|
|
10405
10447
|
|
|
10406
10448
|
|
|
10407
10449
|
|
|
@@ -10439,6 +10481,14 @@ class Auth {
|
|
|
10439
10481
|
this.onRefreshTokenCallback(token, session);
|
|
10440
10482
|
}
|
|
10441
10483
|
});
|
|
10484
|
+
|
|
10485
|
+
setOnRefreshTokenError(error => {
|
|
10486
|
+
logger$7.error('on refresh token error', error);
|
|
10487
|
+
|
|
10488
|
+
if (this.onRefreshTokenCallbackError) {
|
|
10489
|
+
this.onRefreshTokenCallbackError(error);
|
|
10490
|
+
}
|
|
10491
|
+
});
|
|
10442
10492
|
}
|
|
10443
10493
|
|
|
10444
10494
|
setFetchOptions(options ) {
|
|
@@ -10527,6 +10577,10 @@ class Auth {
|
|
|
10527
10577
|
this.onRefreshTokenCallback = callback;
|
|
10528
10578
|
}
|
|
10529
10579
|
|
|
10580
|
+
setOnRefreshTokenError(callback ) {
|
|
10581
|
+
this.onRefreshTokenCallbackError = callback;
|
|
10582
|
+
}
|
|
10583
|
+
|
|
10530
10584
|
checkAuthorizations(session , authorizationName ) {
|
|
10531
10585
|
if (!authorizationName) {
|
|
10532
10586
|
return;
|
|
@@ -10559,6 +10613,12 @@ class Auth {
|
|
|
10559
10613
|
setRefreshToken(refreshToken);
|
|
10560
10614
|
}
|
|
10561
10615
|
|
|
10616
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
10617
|
+
setRefreshTenantId(refreshTenantId);
|
|
10618
|
+
|
|
10619
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
10620
|
+
}
|
|
10621
|
+
|
|
10562
10622
|
forceRefreshToken() {
|
|
10563
10623
|
getApiClient().forceRefreshToken();
|
|
10564
10624
|
}
|
|
@@ -11016,7 +11076,7 @@ class WebSocketClient extends Emitter {
|
|
|
11016
11076
|
this.close();
|
|
11017
11077
|
}
|
|
11018
11078
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11019
|
-
logger$6.
|
|
11079
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11020
11080
|
|
|
11021
11081
|
return url;
|
|
11022
11082
|
}
|