@wazo/sdk 0.37.41 → 0.38.0
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 +14 -7
- package/esm/index.js +233 -25
- 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 +233 -25
- package/esm/simple/Configuration.js +233 -25
- package/esm/simple/Directory.js +54 -23
- package/esm/simple/Phone.js +233 -25
- package/esm/simple/Softphone.js +148 -0
- package/esm/simple/Websocket.js +13 -8
- package/esm/simple/index.js +233 -25
- package/esm/simple/room/LocalParticipant.js +233 -25
- package/esm/simple/room/Participant.js +233 -25
- package/esm/simple/room/RemoteParticipant.js +233 -25
- package/esm/simple/room/Room.js +233 -25
- package/esm/simple/room/SipRoom.js +233 -25
- package/esm/simple/room/Stream.js +233 -25
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/esm/simple/utils.js +233 -25
- 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 +14 -7
- package/lib/index.js +233 -25
- 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 +233 -25
- package/lib/simple/Configuration.js +233 -25
- package/lib/simple/Directory.js +54 -23
- package/lib/simple/Phone.js +233 -25
- package/lib/simple/Softphone.js +150 -0
- package/lib/simple/Websocket.js +13 -8
- package/lib/simple/index.js +233 -25
- package/lib/simple/room/LocalParticipant.js +233 -25
- package/lib/simple/room/Participant.js +233 -25
- package/lib/simple/room/RemoteParticipant.js +233 -25
- package/lib/simple/room/Room.js +233 -25
- package/lib/simple/room/SipRoom.js +233 -25
- package/lib/simple/room/Stream.js +233 -25
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +233 -25
- package/lib/simple/utils.js +233 -25
- 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/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/simple/Softphone.js +148 -0
- package/src/simple/index.js +2 -0
- package/src/web-rtc-client.js +4 -2
- package/src/websocket-client.js +1 -1
package/esm/api-client.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' } : {}),
|
|
@@ -3535,7 +3543,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3535
3543
|
global.wazoClientId = global.wazoClientId || {};
|
|
3536
3544
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3537
3545
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3546
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3538
3547
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3548
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3539
3549
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3540
3550
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3541
3551
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4581,6 +4591,7 @@ class ApiClient {
|
|
|
4581
4591
|
|
|
4582
4592
|
|
|
4583
4593
|
|
|
4594
|
+
|
|
4584
4595
|
|
|
4585
4596
|
|
|
4586
4597
|
|
|
@@ -4633,23 +4644,31 @@ class ApiClient {
|
|
|
4633
4644
|
return null;
|
|
4634
4645
|
}
|
|
4635
4646
|
|
|
4636
|
-
|
|
4637
|
-
this.refreshToken
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4647
|
+
try {
|
|
4648
|
+
const session = await this.auth.refreshToken(
|
|
4649
|
+
this.refreshToken,
|
|
4650
|
+
this.refreshBackend,
|
|
4651
|
+
this.refreshExpiration,
|
|
4652
|
+
this.isMobile,
|
|
4653
|
+
this.refreshTenantId,
|
|
4654
|
+
);
|
|
4655
|
+
|
|
4656
|
+
logger.info('token refreshed', { token: session.token });
|
|
4657
|
+
|
|
4658
|
+
if (this.onRefreshToken) {
|
|
4659
|
+
this.onRefreshToken(session.token, session);
|
|
4660
|
+
}
|
|
4645
4661
|
|
|
4646
|
-
|
|
4647
|
-
this.onRefreshToken(session.token, session);
|
|
4648
|
-
}
|
|
4662
|
+
this.setToken(session.token);
|
|
4649
4663
|
|
|
4650
|
-
|
|
4664
|
+
return session.token;
|
|
4665
|
+
} catch (error) {
|
|
4666
|
+
logger.error('token refresh, error', error);
|
|
4651
4667
|
|
|
4652
|
-
|
|
4668
|
+
if (this.onRefreshTokenError) {
|
|
4669
|
+
this.onRefreshTokenError(error);
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4653
4672
|
}
|
|
4654
4673
|
|
|
4655
4674
|
setToken(token ) {
|
|
@@ -4672,6 +4691,10 @@ class ApiClient {
|
|
|
4672
4691
|
this.onRefreshToken = onRefreshToken;
|
|
4673
4692
|
}
|
|
4674
4693
|
|
|
4694
|
+
setOnRefreshTokenError(callback ) {
|
|
4695
|
+
this.onRefreshTokenError = callback;
|
|
4696
|
+
}
|
|
4697
|
+
|
|
4675
4698
|
setRefreshExpiration(refreshExpiration ) {
|
|
4676
4699
|
this.refreshExpiration = refreshExpiration;
|
|
4677
4700
|
}
|
package/esm/checker/Checker.js
CHANGED
|
@@ -414,13 +414,9 @@ class IssueReporter {
|
|
|
414
414
|
|
|
415
415
|
setTimeout(() => {
|
|
416
416
|
if (isArray) {
|
|
417
|
-
payload = payload.map(message =>
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
421
|
-
} else {
|
|
422
|
-
// $FlowFixMe
|
|
423
|
-
payload._retry = retry + 1;
|
|
417
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
418
|
+
} else if (payload && typeof payload === 'object') {
|
|
419
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
424
420
|
}
|
|
425
421
|
|
|
426
422
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -428,6 +424,15 @@ class IssueReporter {
|
|
|
428
424
|
});
|
|
429
425
|
}
|
|
430
426
|
|
|
427
|
+
_writeRetryCount(message , count ) {
|
|
428
|
+
if (message && typeof message === 'object') {
|
|
429
|
+
// $FlowFixMe
|
|
430
|
+
message._retry = count;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return message;
|
|
434
|
+
}
|
|
435
|
+
|
|
431
436
|
_isLevelAbove(level1 , level2 ) {
|
|
432
437
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
433
438
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2263,9 +2268,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2263
2268
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2264
2269
|
refresh_token: refreshToken,
|
|
2265
2270
|
client_id: client.clientId,
|
|
2266
|
-
tenant_id: tenantId,
|
|
2267
2271
|
};
|
|
2268
2272
|
|
|
2273
|
+
if (tenantId) {
|
|
2274
|
+
body.tenant_id = tenantId;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2269
2277
|
const headers = {
|
|
2270
2278
|
'Content-Type': 'application/json',
|
|
2271
2279
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3579,7 +3587,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3579
3587
|
global.wazoClientId = global.wazoClientId || {};
|
|
3580
3588
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3581
3589
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3590
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3582
3591
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3592
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3583
3593
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3584
3594
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3585
3595
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4625,6 +4635,7 @@ class ApiClient {
|
|
|
4625
4635
|
|
|
4626
4636
|
|
|
4627
4637
|
|
|
4638
|
+
|
|
4628
4639
|
|
|
4629
4640
|
|
|
4630
4641
|
|
|
@@ -4677,23 +4688,31 @@ class ApiClient {
|
|
|
4677
4688
|
return null;
|
|
4678
4689
|
}
|
|
4679
4690
|
|
|
4680
|
-
|
|
4681
|
-
this.refreshToken
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4691
|
+
try {
|
|
4692
|
+
const session = await this.auth.refreshToken(
|
|
4693
|
+
this.refreshToken,
|
|
4694
|
+
this.refreshBackend,
|
|
4695
|
+
this.refreshExpiration,
|
|
4696
|
+
this.isMobile,
|
|
4697
|
+
this.refreshTenantId,
|
|
4698
|
+
);
|
|
4699
|
+
|
|
4700
|
+
logger$3.info('token refreshed', { token: session.token });
|
|
4701
|
+
|
|
4702
|
+
if (this.onRefreshToken) {
|
|
4703
|
+
this.onRefreshToken(session.token, session);
|
|
4704
|
+
}
|
|
4687
4705
|
|
|
4688
|
-
|
|
4706
|
+
this.setToken(session.token);
|
|
4689
4707
|
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
this.setToken(session.token);
|
|
4708
|
+
return session.token;
|
|
4709
|
+
} catch (error) {
|
|
4710
|
+
logger$3.error('token refresh, error', error);
|
|
4695
4711
|
|
|
4696
|
-
|
|
4712
|
+
if (this.onRefreshTokenError) {
|
|
4713
|
+
this.onRefreshTokenError(error);
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4697
4716
|
}
|
|
4698
4717
|
|
|
4699
4718
|
setToken(token ) {
|
|
@@ -4716,6 +4735,10 @@ class ApiClient {
|
|
|
4716
4735
|
this.onRefreshToken = onRefreshToken;
|
|
4717
4736
|
}
|
|
4718
4737
|
|
|
4738
|
+
setOnRefreshTokenError(callback ) {
|
|
4739
|
+
this.onRefreshTokenError = callback;
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4719
4742
|
setRefreshExpiration(refreshExpiration ) {
|
|
4720
4743
|
this.refreshExpiration = refreshExpiration;
|
|
4721
4744
|
}
|
|
@@ -5289,7 +5312,7 @@ class WebSocketClient extends Emitter {
|
|
|
5289
5312
|
this.close();
|
|
5290
5313
|
}
|
|
5291
5314
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5292
|
-
logger$2.
|
|
5315
|
+
logger$2.info('Wazo WS url computed to reconnect', { url });
|
|
5293
5316
|
|
|
5294
5317
|
return url;
|
|
5295
5318
|
}
|
|
@@ -6669,8 +6692,10 @@ class WebRTCClient extends Emitter {
|
|
|
6669
6692
|
conference: isConference,
|
|
6670
6693
|
};
|
|
6671
6694
|
|
|
6672
|
-
// Avoid sdh to
|
|
6673
|
-
session.sessionDescriptionHandler
|
|
6695
|
+
// Avoid sdh to create a new stream
|
|
6696
|
+
if (session.sessionDescriptionHandler) {
|
|
6697
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6698
|
+
}
|
|
6674
6699
|
|
|
6675
6700
|
// Send re-INVITE
|
|
6676
6701
|
return session.invite(options);
|
|
@@ -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' } : {}),
|
|
@@ -3535,7 +3543,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3535
3543
|
global.wazoClientId = global.wazoClientId || {};
|
|
3536
3544
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3537
3545
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3546
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3538
3547
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3548
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3539
3549
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3540
3550
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3541
3551
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4581,6 +4591,7 @@ class ApiClient {
|
|
|
4581
4591
|
|
|
4582
4592
|
|
|
4583
4593
|
|
|
4594
|
+
|
|
4584
4595
|
|
|
4585
4596
|
|
|
4586
4597
|
|
|
@@ -4633,23 +4644,31 @@ class ApiClient {
|
|
|
4633
4644
|
return null;
|
|
4634
4645
|
}
|
|
4635
4646
|
|
|
4636
|
-
|
|
4637
|
-
this.refreshToken
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4647
|
+
try {
|
|
4648
|
+
const session = await this.auth.refreshToken(
|
|
4649
|
+
this.refreshToken,
|
|
4650
|
+
this.refreshBackend,
|
|
4651
|
+
this.refreshExpiration,
|
|
4652
|
+
this.isMobile,
|
|
4653
|
+
this.refreshTenantId,
|
|
4654
|
+
);
|
|
4655
|
+
|
|
4656
|
+
logger.info('token refreshed', { token: session.token });
|
|
4657
|
+
|
|
4658
|
+
if (this.onRefreshToken) {
|
|
4659
|
+
this.onRefreshToken(session.token, session);
|
|
4660
|
+
}
|
|
4645
4661
|
|
|
4646
|
-
|
|
4647
|
-
this.onRefreshToken(session.token, session);
|
|
4648
|
-
}
|
|
4662
|
+
this.setToken(session.token);
|
|
4649
4663
|
|
|
4650
|
-
|
|
4664
|
+
return session.token;
|
|
4665
|
+
} catch (error) {
|
|
4666
|
+
logger.error('token refresh, error', error);
|
|
4651
4667
|
|
|
4652
|
-
|
|
4668
|
+
if (this.onRefreshTokenError) {
|
|
4669
|
+
this.onRefreshTokenError(error);
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4653
4672
|
}
|
|
4654
4673
|
|
|
4655
4674
|
setToken(token ) {
|
|
@@ -4672,6 +4691,10 @@ class ApiClient {
|
|
|
4672
4691
|
this.onRefreshToken = onRefreshToken;
|
|
4673
4692
|
}
|
|
4674
4693
|
|
|
4694
|
+
setOnRefreshTokenError(callback ) {
|
|
4695
|
+
this.onRefreshTokenError = callback;
|
|
4696
|
+
}
|
|
4697
|
+
|
|
4675
4698
|
setRefreshExpiration(refreshExpiration ) {
|
|
4676
4699
|
this.refreshExpiration = refreshExpiration;
|
|
4677
4700
|
}
|
|
@@ -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' } : {}),
|
|
@@ -3535,7 +3543,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3535
3543
|
global.wazoClientId = global.wazoClientId || {};
|
|
3536
3544
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3537
3545
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3546
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3538
3547
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3548
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3539
3549
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3540
3550
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3541
3551
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4581,6 +4591,7 @@ class ApiClient {
|
|
|
4581
4591
|
|
|
4582
4592
|
|
|
4583
4593
|
|
|
4594
|
+
|
|
4584
4595
|
|
|
4585
4596
|
|
|
4586
4597
|
|
|
@@ -4633,23 +4644,31 @@ class ApiClient {
|
|
|
4633
4644
|
return null;
|
|
4634
4645
|
}
|
|
4635
4646
|
|
|
4636
|
-
|
|
4637
|
-
this.refreshToken
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4647
|
+
try {
|
|
4648
|
+
const session = await this.auth.refreshToken(
|
|
4649
|
+
this.refreshToken,
|
|
4650
|
+
this.refreshBackend,
|
|
4651
|
+
this.refreshExpiration,
|
|
4652
|
+
this.isMobile,
|
|
4653
|
+
this.refreshTenantId,
|
|
4654
|
+
);
|
|
4655
|
+
|
|
4656
|
+
logger.info('token refreshed', { token: session.token });
|
|
4657
|
+
|
|
4658
|
+
if (this.onRefreshToken) {
|
|
4659
|
+
this.onRefreshToken(session.token, session);
|
|
4660
|
+
}
|
|
4645
4661
|
|
|
4646
|
-
|
|
4647
|
-
this.onRefreshToken(session.token, session);
|
|
4648
|
-
}
|
|
4662
|
+
this.setToken(session.token);
|
|
4649
4663
|
|
|
4650
|
-
|
|
4664
|
+
return session.token;
|
|
4665
|
+
} catch (error) {
|
|
4666
|
+
logger.error('token refresh, error', error);
|
|
4651
4667
|
|
|
4652
|
-
|
|
4668
|
+
if (this.onRefreshTokenError) {
|
|
4669
|
+
this.onRefreshTokenError(error);
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4653
4672
|
}
|
|
4654
4673
|
|
|
4655
4674
|
setToken(token ) {
|
|
@@ -4672,6 +4691,10 @@ class ApiClient {
|
|
|
4672
4691
|
this.onRefreshToken = onRefreshToken;
|
|
4673
4692
|
}
|
|
4674
4693
|
|
|
4694
|
+
setOnRefreshTokenError(callback ) {
|
|
4695
|
+
this.onRefreshTokenError = callback;
|
|
4696
|
+
}
|
|
4697
|
+
|
|
4675
4698
|
setRefreshExpiration(refreshExpiration ) {
|
|
4676
4699
|
this.refreshExpiration = refreshExpiration;
|
|
4677
4700
|
}
|
|
@@ -414,13 +414,9 @@ class IssueReporter {
|
|
|
414
414
|
|
|
415
415
|
setTimeout(() => {
|
|
416
416
|
if (isArray) {
|
|
417
|
-
payload = payload.map(message =>
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
421
|
-
} else {
|
|
422
|
-
// $FlowFixMe
|
|
423
|
-
payload._retry = retry + 1;
|
|
417
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
418
|
+
} else if (payload && typeof payload === 'object') {
|
|
419
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
424
420
|
}
|
|
425
421
|
|
|
426
422
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -428,6 +424,15 @@ class IssueReporter {
|
|
|
428
424
|
});
|
|
429
425
|
}
|
|
430
426
|
|
|
427
|
+
_writeRetryCount(message , count ) {
|
|
428
|
+
if (message && typeof message === 'object') {
|
|
429
|
+
// $FlowFixMe
|
|
430
|
+
message._retry = count;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return message;
|
|
434
|
+
}
|
|
435
|
+
|
|
431
436
|
_isLevelAbove(level1 , level2 ) {
|
|
432
437
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
433
438
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2263,9 +2268,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2263
2268
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2264
2269
|
refresh_token: refreshToken,
|
|
2265
2270
|
client_id: client.clientId,
|
|
2266
|
-
tenant_id: tenantId,
|
|
2267
2271
|
};
|
|
2268
2272
|
|
|
2273
|
+
if (tenantId) {
|
|
2274
|
+
body.tenant_id = tenantId;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2269
2277
|
const headers = {
|
|
2270
2278
|
'Content-Type': 'application/json',
|
|
2271
2279
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3579,7 +3587,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3579
3587
|
global.wazoClientId = global.wazoClientId || {};
|
|
3580
3588
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3581
3589
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3590
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3582
3591
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3592
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3583
3593
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3584
3594
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3585
3595
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4625,6 +4635,7 @@ class ApiClient {
|
|
|
4625
4635
|
|
|
4626
4636
|
|
|
4627
4637
|
|
|
4638
|
+
|
|
4628
4639
|
|
|
4629
4640
|
|
|
4630
4641
|
|
|
@@ -4677,23 +4688,31 @@ class ApiClient {
|
|
|
4677
4688
|
return null;
|
|
4678
4689
|
}
|
|
4679
4690
|
|
|
4680
|
-
|
|
4681
|
-
this.refreshToken
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4691
|
+
try {
|
|
4692
|
+
const session = await this.auth.refreshToken(
|
|
4693
|
+
this.refreshToken,
|
|
4694
|
+
this.refreshBackend,
|
|
4695
|
+
this.refreshExpiration,
|
|
4696
|
+
this.isMobile,
|
|
4697
|
+
this.refreshTenantId,
|
|
4698
|
+
);
|
|
4699
|
+
|
|
4700
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
4701
|
+
|
|
4702
|
+
if (this.onRefreshToken) {
|
|
4703
|
+
this.onRefreshToken(session.token, session);
|
|
4704
|
+
}
|
|
4687
4705
|
|
|
4688
|
-
|
|
4706
|
+
this.setToken(session.token);
|
|
4689
4707
|
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
this.setToken(session.token);
|
|
4708
|
+
return session.token;
|
|
4709
|
+
} catch (error) {
|
|
4710
|
+
logger$2.error('token refresh, error', error);
|
|
4695
4711
|
|
|
4696
|
-
|
|
4712
|
+
if (this.onRefreshTokenError) {
|
|
4713
|
+
this.onRefreshTokenError(error);
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4697
4716
|
}
|
|
4698
4717
|
|
|
4699
4718
|
setToken(token ) {
|
|
@@ -4716,6 +4735,10 @@ class ApiClient {
|
|
|
4716
4735
|
this.onRefreshToken = onRefreshToken;
|
|
4717
4736
|
}
|
|
4718
4737
|
|
|
4738
|
+
setOnRefreshTokenError(callback ) {
|
|
4739
|
+
this.onRefreshTokenError = callback;
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4719
4742
|
setRefreshExpiration(refreshExpiration ) {
|
|
4720
4743
|
this.refreshExpiration = refreshExpiration;
|
|
4721
4744
|
}
|
|
@@ -5289,7 +5312,7 @@ class WebSocketClient extends Emitter {
|
|
|
5289
5312
|
this.close();
|
|
5290
5313
|
}
|
|
5291
5314
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5292
|
-
logger$1.
|
|
5315
|
+
logger$1.info('Wazo WS url computed to reconnect', { url });
|
|
5293
5316
|
|
|
5294
5317
|
return url;
|
|
5295
5318
|
}
|
|
@@ -6669,8 +6692,10 @@ class WebRTCClient extends Emitter {
|
|
|
6669
6692
|
conference: isConference,
|
|
6670
6693
|
};
|
|
6671
6694
|
|
|
6672
|
-
// Avoid sdh to
|
|
6673
|
-
session.sessionDescriptionHandler
|
|
6695
|
+
// Avoid sdh to create a new stream
|
|
6696
|
+
if (session.sessionDescriptionHandler) {
|
|
6697
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6698
|
+
}
|
|
6674
6699
|
|
|
6675
6700
|
// Send re-INVITE
|
|
6676
6701
|
return session.invite(options);
|
|
@@ -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
|
}
|