@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/lib/api-client.js
CHANGED
|
@@ -402,13 +402,9 @@ class IssueReporter {
|
|
|
402
402
|
|
|
403
403
|
setTimeout(() => {
|
|
404
404
|
if (isArray) {
|
|
405
|
-
payload = payload.map(message =>
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
});
|
|
409
|
-
} else {
|
|
410
|
-
// $FlowFixMe
|
|
411
|
-
payload._retry = retry + 1;
|
|
405
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
406
|
+
} else if (payload && typeof payload === 'object') {
|
|
407
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
412
408
|
}
|
|
413
409
|
|
|
414
410
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -416,6 +412,15 @@ class IssueReporter {
|
|
|
416
412
|
});
|
|
417
413
|
}
|
|
418
414
|
|
|
415
|
+
_writeRetryCount(message , count ) {
|
|
416
|
+
if (message && typeof message === 'object') {
|
|
417
|
+
// $FlowFixMe
|
|
418
|
+
message._retry = count;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return message;
|
|
422
|
+
}
|
|
423
|
+
|
|
419
424
|
_isLevelAbove(level1 , level2 ) {
|
|
420
425
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
421
426
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2251,9 +2256,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2251
2256
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2252
2257
|
refresh_token: refreshToken,
|
|
2253
2258
|
client_id: client.clientId,
|
|
2254
|
-
tenant_id: tenantId,
|
|
2255
2259
|
};
|
|
2256
2260
|
|
|
2261
|
+
if (tenantId) {
|
|
2262
|
+
body.tenant_id = tenantId;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2257
2265
|
const headers = {
|
|
2258
2266
|
'Content-Type': 'application/json',
|
|
2259
2267
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -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
|
}
|
package/lib/checker/Checker.js
CHANGED
|
@@ -424,13 +424,9 @@ class IssueReporter {
|
|
|
424
424
|
|
|
425
425
|
setTimeout(() => {
|
|
426
426
|
if (isArray) {
|
|
427
|
-
payload = payload.map(message =>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
});
|
|
431
|
-
} else {
|
|
432
|
-
// $FlowFixMe
|
|
433
|
-
payload._retry = retry + 1;
|
|
427
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
428
|
+
} else if (payload && typeof payload === 'object') {
|
|
429
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
434
430
|
}
|
|
435
431
|
|
|
436
432
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -438,6 +434,15 @@ class IssueReporter {
|
|
|
438
434
|
});
|
|
439
435
|
}
|
|
440
436
|
|
|
437
|
+
_writeRetryCount(message , count ) {
|
|
438
|
+
if (message && typeof message === 'object') {
|
|
439
|
+
// $FlowFixMe
|
|
440
|
+
message._retry = count;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return message;
|
|
444
|
+
}
|
|
445
|
+
|
|
441
446
|
_isLevelAbove(level1 , level2 ) {
|
|
442
447
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
443
448
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2273,9 +2278,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2278
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2274
2279
|
refresh_token: refreshToken,
|
|
2275
2280
|
client_id: client.clientId,
|
|
2276
|
-
tenant_id: tenantId,
|
|
2277
2281
|
};
|
|
2278
2282
|
|
|
2283
|
+
if (tenantId) {
|
|
2284
|
+
body.tenant_id = tenantId;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2279
2287
|
const headers = {
|
|
2280
2288
|
'Content-Type': 'application/json',
|
|
2281
2289
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3589,7 +3597,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3589
3597
|
global.wazoClientId = global.wazoClientId || {};
|
|
3590
3598
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3591
3599
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3600
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3592
3601
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3602
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3593
3603
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3594
3604
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3595
3605
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4635,6 +4645,7 @@ class ApiClient {
|
|
|
4635
4645
|
|
|
4636
4646
|
|
|
4637
4647
|
|
|
4648
|
+
|
|
4638
4649
|
|
|
4639
4650
|
|
|
4640
4651
|
|
|
@@ -4687,23 +4698,31 @@ class ApiClient {
|
|
|
4687
4698
|
return null;
|
|
4688
4699
|
}
|
|
4689
4700
|
|
|
4690
|
-
|
|
4691
|
-
this.refreshToken
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4701
|
+
try {
|
|
4702
|
+
const session = await this.auth.refreshToken(
|
|
4703
|
+
this.refreshToken,
|
|
4704
|
+
this.refreshBackend,
|
|
4705
|
+
this.refreshExpiration,
|
|
4706
|
+
this.isMobile,
|
|
4707
|
+
this.refreshTenantId,
|
|
4708
|
+
);
|
|
4709
|
+
|
|
4710
|
+
logger$3.info('token refreshed', { token: session.token });
|
|
4711
|
+
|
|
4712
|
+
if (this.onRefreshToken) {
|
|
4713
|
+
this.onRefreshToken(session.token, session);
|
|
4714
|
+
}
|
|
4697
4715
|
|
|
4698
|
-
|
|
4716
|
+
this.setToken(session.token);
|
|
4699
4717
|
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
this.setToken(session.token);
|
|
4718
|
+
return session.token;
|
|
4719
|
+
} catch (error) {
|
|
4720
|
+
logger$3.error('token refresh, error', error);
|
|
4705
4721
|
|
|
4706
|
-
|
|
4722
|
+
if (this.onRefreshTokenError) {
|
|
4723
|
+
this.onRefreshTokenError(error);
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4707
4726
|
}
|
|
4708
4727
|
|
|
4709
4728
|
setToken(token ) {
|
|
@@ -4726,6 +4745,10 @@ class ApiClient {
|
|
|
4726
4745
|
this.onRefreshToken = onRefreshToken;
|
|
4727
4746
|
}
|
|
4728
4747
|
|
|
4748
|
+
setOnRefreshTokenError(callback ) {
|
|
4749
|
+
this.onRefreshTokenError = callback;
|
|
4750
|
+
}
|
|
4751
|
+
|
|
4729
4752
|
setRefreshExpiration(refreshExpiration ) {
|
|
4730
4753
|
this.refreshExpiration = refreshExpiration;
|
|
4731
4754
|
}
|
|
@@ -5299,7 +5322,7 @@ class WebSocketClient extends Emitter {
|
|
|
5299
5322
|
this.close();
|
|
5300
5323
|
}
|
|
5301
5324
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5302
|
-
logger$2.
|
|
5325
|
+
logger$2.info('Wazo WS url computed to reconnect', { url });
|
|
5303
5326
|
|
|
5304
5327
|
return url;
|
|
5305
5328
|
}
|
|
@@ -6679,8 +6702,10 @@ class WebRTCClient extends Emitter {
|
|
|
6679
6702
|
conference: isConference,
|
|
6680
6703
|
};
|
|
6681
6704
|
|
|
6682
|
-
// Avoid sdh to
|
|
6683
|
-
session.sessionDescriptionHandler
|
|
6705
|
+
// Avoid sdh to create a new stream
|
|
6706
|
+
if (session.sessionDescriptionHandler) {
|
|
6707
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6708
|
+
}
|
|
6684
6709
|
|
|
6685
6710
|
// Send re-INVITE
|
|
6686
6711
|
return session.invite(options);
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -424,13 +424,9 @@ class IssueReporter {
|
|
|
424
424
|
|
|
425
425
|
setTimeout(() => {
|
|
426
426
|
if (isArray) {
|
|
427
|
-
payload = payload.map(message =>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
});
|
|
431
|
-
} else {
|
|
432
|
-
// $FlowFixMe
|
|
433
|
-
payload._retry = retry + 1;
|
|
427
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
428
|
+
} else if (payload && typeof payload === 'object') {
|
|
429
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
434
430
|
}
|
|
435
431
|
|
|
436
432
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -438,6 +434,15 @@ class IssueReporter {
|
|
|
438
434
|
});
|
|
439
435
|
}
|
|
440
436
|
|
|
437
|
+
_writeRetryCount(message , count ) {
|
|
438
|
+
if (message && typeof message === 'object') {
|
|
439
|
+
// $FlowFixMe
|
|
440
|
+
message._retry = count;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return message;
|
|
444
|
+
}
|
|
445
|
+
|
|
441
446
|
_isLevelAbove(level1 , level2 ) {
|
|
442
447
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
443
448
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2273,9 +2278,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2273
2278
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2274
2279
|
refresh_token: refreshToken,
|
|
2275
2280
|
client_id: client.clientId,
|
|
2276
|
-
tenant_id: tenantId,
|
|
2277
2281
|
};
|
|
2278
2282
|
|
|
2283
|
+
if (tenantId) {
|
|
2284
|
+
body.tenant_id = tenantId;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2279
2287
|
const headers = {
|
|
2280
2288
|
'Content-Type': 'application/json',
|
|
2281
2289
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -3589,7 +3597,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
3589
3597
|
global.wazoClientId = global.wazoClientId || {};
|
|
3590
3598
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
3591
3599
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
3600
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
3592
3601
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
3602
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
3593
3603
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
3594
3604
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
3595
3605
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4635,6 +4645,7 @@ class ApiClient {
|
|
|
4635
4645
|
|
|
4636
4646
|
|
|
4637
4647
|
|
|
4648
|
+
|
|
4638
4649
|
|
|
4639
4650
|
|
|
4640
4651
|
|
|
@@ -4687,23 +4698,31 @@ class ApiClient {
|
|
|
4687
4698
|
return null;
|
|
4688
4699
|
}
|
|
4689
4700
|
|
|
4690
|
-
|
|
4691
|
-
this.refreshToken
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4701
|
+
try {
|
|
4702
|
+
const session = await this.auth.refreshToken(
|
|
4703
|
+
this.refreshToken,
|
|
4704
|
+
this.refreshBackend,
|
|
4705
|
+
this.refreshExpiration,
|
|
4706
|
+
this.isMobile,
|
|
4707
|
+
this.refreshTenantId,
|
|
4708
|
+
);
|
|
4709
|
+
|
|
4710
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
4711
|
+
|
|
4712
|
+
if (this.onRefreshToken) {
|
|
4713
|
+
this.onRefreshToken(session.token, session);
|
|
4714
|
+
}
|
|
4697
4715
|
|
|
4698
|
-
|
|
4716
|
+
this.setToken(session.token);
|
|
4699
4717
|
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
this.setToken(session.token);
|
|
4718
|
+
return session.token;
|
|
4719
|
+
} catch (error) {
|
|
4720
|
+
logger$2.error('token refresh, error', error);
|
|
4705
4721
|
|
|
4706
|
-
|
|
4722
|
+
if (this.onRefreshTokenError) {
|
|
4723
|
+
this.onRefreshTokenError(error);
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4707
4726
|
}
|
|
4708
4727
|
|
|
4709
4728
|
setToken(token ) {
|
|
@@ -4726,6 +4745,10 @@ class ApiClient {
|
|
|
4726
4745
|
this.onRefreshToken = onRefreshToken;
|
|
4727
4746
|
}
|
|
4728
4747
|
|
|
4748
|
+
setOnRefreshTokenError(callback ) {
|
|
4749
|
+
this.onRefreshTokenError = callback;
|
|
4750
|
+
}
|
|
4751
|
+
|
|
4729
4752
|
setRefreshExpiration(refreshExpiration ) {
|
|
4730
4753
|
this.refreshExpiration = refreshExpiration;
|
|
4731
4754
|
}
|
|
@@ -5299,7 +5322,7 @@ class WebSocketClient extends Emitter {
|
|
|
5299
5322
|
this.close();
|
|
5300
5323
|
}
|
|
5301
5324
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
5302
|
-
logger$1.
|
|
5325
|
+
logger$1.info('Wazo WS url computed to reconnect', { url });
|
|
5303
5326
|
|
|
5304
5327
|
return url;
|
|
5305
5328
|
}
|
|
@@ -6679,8 +6702,10 @@ class WebRTCClient extends Emitter {
|
|
|
6679
6702
|
conference: isConference,
|
|
6680
6703
|
};
|
|
6681
6704
|
|
|
6682
|
-
// Avoid sdh to
|
|
6683
|
-
session.sessionDescriptionHandler
|
|
6705
|
+
// Avoid sdh to create a new stream
|
|
6706
|
+
if (session.sessionDescriptionHandler) {
|
|
6707
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6708
|
+
}
|
|
6684
6709
|
|
|
6685
6710
|
// Send re-INVITE
|
|
6686
6711
|
return session.invite(options);
|
|
@@ -395,13 +395,9 @@ class IssueReporter {
|
|
|
395
395
|
|
|
396
396
|
setTimeout(() => {
|
|
397
397
|
if (isArray) {
|
|
398
|
-
payload = payload.map(message =>
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
402
|
-
} else {
|
|
403
|
-
// $FlowFixMe
|
|
404
|
-
payload._retry = retry + 1;
|
|
398
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
399
|
+
} else if (payload && typeof payload === 'object') {
|
|
400
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
405
401
|
}
|
|
406
402
|
|
|
407
403
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -409,6 +405,15 @@ class IssueReporter {
|
|
|
409
405
|
});
|
|
410
406
|
}
|
|
411
407
|
|
|
408
|
+
_writeRetryCount(message , count ) {
|
|
409
|
+
if (message && typeof message === 'object') {
|
|
410
|
+
// $FlowFixMe
|
|
411
|
+
message._retry = count;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return message;
|
|
415
|
+
}
|
|
416
|
+
|
|
412
417
|
_isLevelAbove(level1 , level2 ) {
|
|
413
418
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
414
419
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -869,7 +874,7 @@ class WebSocketClient extends Emitter {
|
|
|
869
874
|
this.close();
|
|
870
875
|
}
|
|
871
876
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
872
|
-
logger.
|
|
877
|
+
logger.info('Wazo WS url computed to reconnect', { url });
|
|
873
878
|
|
|
874
879
|
return url;
|
|
875
880
|
}
|