@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
|
@@ -365,13 +365,9 @@ class IssueReporter {
|
|
|
365
365
|
|
|
366
366
|
setTimeout(() => {
|
|
367
367
|
if (isArray) {
|
|
368
|
-
payload = payload.map(message =>
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
// $FlowFixMe
|
|
374
|
-
payload._retry = retry + 1;
|
|
368
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
369
|
+
} else if (payload && typeof payload === 'object') {
|
|
370
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
375
371
|
}
|
|
376
372
|
|
|
377
373
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -379,6 +375,15 @@ class IssueReporter {
|
|
|
379
375
|
});
|
|
380
376
|
}
|
|
381
377
|
|
|
378
|
+
_writeRetryCount(message , count ) {
|
|
379
|
+
if (message && typeof message === 'object') {
|
|
380
|
+
// $FlowFixMe
|
|
381
|
+
message._retry = count;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return message;
|
|
385
|
+
}
|
|
386
|
+
|
|
382
387
|
_isLevelAbove(level1 , level2 ) {
|
|
383
388
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
384
389
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -365,13 +365,9 @@ class IssueReporter {
|
|
|
365
365
|
|
|
366
366
|
setTimeout(() => {
|
|
367
367
|
if (isArray) {
|
|
368
|
-
payload = payload.map(message =>
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
// $FlowFixMe
|
|
374
|
-
payload._retry = retry + 1;
|
|
368
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
369
|
+
} else if (payload && typeof payload === 'object') {
|
|
370
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
375
371
|
}
|
|
376
372
|
|
|
377
373
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -379,6 +375,15 @@ class IssueReporter {
|
|
|
379
375
|
});
|
|
380
376
|
}
|
|
381
377
|
|
|
378
|
+
_writeRetryCount(message , count ) {
|
|
379
|
+
if (message && typeof message === 'object') {
|
|
380
|
+
// $FlowFixMe
|
|
381
|
+
message._retry = count;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return message;
|
|
385
|
+
}
|
|
386
|
+
|
|
382
387
|
_isLevelAbove(level1 , level2 ) {
|
|
383
388
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
384
389
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -494,4 +499,10 @@ describe('IssueReporter', () => {
|
|
|
494
499
|
expect(IssueReporter$1.removeSlashes('\"')).toBe("'");
|
|
495
500
|
expect(IssueReporter$1.removeSlashes('\\\"')).toBe("'");
|
|
496
501
|
});
|
|
502
|
+
|
|
503
|
+
it('Add retry count', () => {
|
|
504
|
+
expect(IssueReporter$1._writeRetryCount('', 1)).toBe('');
|
|
505
|
+
expect(IssueReporter$1._writeRetryCount('{}', 1)).toBe('{}');
|
|
506
|
+
expect(IssueReporter$1._writeRetryCount({}, 1)).toEqual({ _retry: 1 });
|
|
507
|
+
});
|
|
497
508
|
});
|
|
@@ -404,13 +404,9 @@ class IssueReporter {
|
|
|
404
404
|
|
|
405
405
|
setTimeout(() => {
|
|
406
406
|
if (isArray) {
|
|
407
|
-
payload = payload.map(message =>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
411
|
-
} else {
|
|
412
|
-
// $FlowFixMe
|
|
413
|
-
payload._retry = retry + 1;
|
|
407
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
408
|
+
} else if (payload && typeof payload === 'object') {
|
|
409
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
414
410
|
}
|
|
415
411
|
|
|
416
412
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -418,6 +414,15 @@ class IssueReporter {
|
|
|
418
414
|
});
|
|
419
415
|
}
|
|
420
416
|
|
|
417
|
+
_writeRetryCount(message , count ) {
|
|
418
|
+
if (message && typeof message === 'object') {
|
|
419
|
+
// $FlowFixMe
|
|
420
|
+
message._retry = count;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return message;
|
|
424
|
+
}
|
|
425
|
+
|
|
421
426
|
_isLevelAbove(level1 , level2 ) {
|
|
422
427
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
423
428
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2253,9 +2258,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2253
2258
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2254
2259
|
refresh_token: refreshToken,
|
|
2255
2260
|
client_id: client.clientId,
|
|
2256
|
-
tenant_id: tenantId,
|
|
2257
2261
|
};
|
|
2258
2262
|
|
|
2263
|
+
if (tenantId) {
|
|
2264
|
+
body.tenant_id = tenantId;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2259
2267
|
const headers = {
|
|
2260
2268
|
'Content-Type': 'application/json',
|
|
2261
2269
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4574,6 +4582,7 @@ class ApiClient {
|
|
|
4574
4582
|
|
|
4575
4583
|
|
|
4576
4584
|
|
|
4585
|
+
|
|
4577
4586
|
|
|
4578
4587
|
|
|
4579
4588
|
|
|
@@ -4626,23 +4635,31 @@ class ApiClient {
|
|
|
4626
4635
|
return null;
|
|
4627
4636
|
}
|
|
4628
4637
|
|
|
4629
|
-
|
|
4630
|
-
this.refreshToken
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
+
try {
|
|
4639
|
+
const session = await this.auth.refreshToken(
|
|
4640
|
+
this.refreshToken,
|
|
4641
|
+
this.refreshBackend,
|
|
4642
|
+
this.refreshExpiration,
|
|
4643
|
+
this.isMobile,
|
|
4644
|
+
this.refreshTenantId,
|
|
4645
|
+
);
|
|
4646
|
+
|
|
4647
|
+
logger.info('token refreshed', { token: session.token });
|
|
4648
|
+
|
|
4649
|
+
if (this.onRefreshToken) {
|
|
4650
|
+
this.onRefreshToken(session.token, session);
|
|
4651
|
+
}
|
|
4638
4652
|
|
|
4639
|
-
|
|
4640
|
-
this.onRefreshToken(session.token, session);
|
|
4641
|
-
}
|
|
4653
|
+
this.setToken(session.token);
|
|
4642
4654
|
|
|
4643
|
-
|
|
4655
|
+
return session.token;
|
|
4656
|
+
} catch (error) {
|
|
4657
|
+
logger.error('token refresh, error', error);
|
|
4644
4658
|
|
|
4645
|
-
|
|
4659
|
+
if (this.onRefreshTokenError) {
|
|
4660
|
+
this.onRefreshTokenError(error);
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4646
4663
|
}
|
|
4647
4664
|
|
|
4648
4665
|
setToken(token ) {
|
|
@@ -4665,6 +4682,10 @@ class ApiClient {
|
|
|
4665
4682
|
this.onRefreshToken = onRefreshToken;
|
|
4666
4683
|
}
|
|
4667
4684
|
|
|
4685
|
+
setOnRefreshTokenError(callback ) {
|
|
4686
|
+
this.onRefreshTokenError = callback;
|
|
4687
|
+
}
|
|
4688
|
+
|
|
4668
4689
|
setRefreshExpiration(refreshExpiration ) {
|
|
4669
4690
|
this.refreshExpiration = refreshExpiration;
|
|
4670
4691
|
}
|
|
@@ -4700,7 +4721,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4700
4721
|
global.wazoClientId = global.wazoClientId || {};
|
|
4701
4722
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4702
4723
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4724
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4703
4725
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4726
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4704
4727
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4705
4728
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4706
4729
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4722,10 +4745,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
4722
4745
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
4723
4746
|
};
|
|
4724
4747
|
|
|
4748
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
4749
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
4750
|
+
};
|
|
4751
|
+
|
|
4725
4752
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
4726
4753
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
4727
4754
|
};
|
|
4728
4755
|
|
|
4756
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
4757
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
4758
|
+
};
|
|
4759
|
+
|
|
4729
4760
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
4730
4761
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
4731
4762
|
};
|
|
@@ -4752,12 +4783,20 @@ const fillClient = (apiClient ) => {
|
|
|
4752
4783
|
|
|
4753
4784
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4754
4785
|
|
|
4786
|
+
apiClient.setRefreshTenantId(
|
|
4787
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4788
|
+
);
|
|
4789
|
+
|
|
4755
4790
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4756
4791
|
|
|
4757
4792
|
apiClient.setOnRefreshToken(
|
|
4758
4793
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4759
4794
|
);
|
|
4760
4795
|
|
|
4796
|
+
apiClient.setOnRefreshTokenError(
|
|
4797
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4798
|
+
);
|
|
4799
|
+
|
|
4761
4800
|
apiClient.setRefreshExpiration(
|
|
4762
4801
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4763
4802
|
);
|
|
@@ -4771,7 +4810,7 @@ const fillClient = (apiClient ) => {
|
|
|
4771
4810
|
return apiClient;
|
|
4772
4811
|
};
|
|
4773
4812
|
|
|
4774
|
-
var getApiClient = (forServer
|
|
4813
|
+
var getApiClient = (forServer = null) => {
|
|
4775
4814
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4776
4815
|
if (server in global.wazoClients) {
|
|
4777
4816
|
return fillClient(global.wazoClients[server]);
|
|
@@ -4789,6 +4828,8 @@ exports.setCurrentServer = setCurrentServer;
|
|
|
4789
4828
|
exports.setFetchOptions = setFetchOptions;
|
|
4790
4829
|
exports.setIsMobile = setIsMobile;
|
|
4791
4830
|
exports.setOnRefreshToken = setOnRefreshToken;
|
|
4831
|
+
exports.setOnRefreshTokenError = setOnRefreshTokenError;
|
|
4792
4832
|
exports.setRefreshBackend = setRefreshBackend;
|
|
4793
4833
|
exports.setRefreshExpiration = setRefreshExpiration;
|
|
4834
|
+
exports.setRefreshTenantId = setRefreshTenantId;
|
|
4794
4835
|
exports.setRefreshToken = setRefreshToken;
|
package/lib/simple/Auth.js
CHANGED
|
@@ -1921,13 +1921,9 @@ class IssueReporter {
|
|
|
1921
1921
|
|
|
1922
1922
|
setTimeout(() => {
|
|
1923
1923
|
if (isArray) {
|
|
1924
|
-
payload = payload.map(message =>
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
});
|
|
1928
|
-
} else {
|
|
1929
|
-
// $FlowFixMe
|
|
1930
|
-
payload._retry = retry + 1;
|
|
1924
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1925
|
+
} else if (payload && typeof payload === 'object') {
|
|
1926
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1931
1927
|
}
|
|
1932
1928
|
|
|
1933
1929
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1935,6 +1931,15 @@ class IssueReporter {
|
|
|
1935
1931
|
});
|
|
1936
1932
|
}
|
|
1937
1933
|
|
|
1934
|
+
_writeRetryCount(message , count ) {
|
|
1935
|
+
if (message && typeof message === 'object') {
|
|
1936
|
+
// $FlowFixMe
|
|
1937
|
+
message._retry = count;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
return message;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1938
1943
|
_isLevelAbove(level1 , level2 ) {
|
|
1939
1944
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1940
1945
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2277,9 +2282,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2277
2282
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2278
2283
|
refresh_token: refreshToken,
|
|
2279
2284
|
client_id: client.clientId,
|
|
2280
|
-
tenant_id: tenantId,
|
|
2281
2285
|
};
|
|
2282
2286
|
|
|
2287
|
+
if (tenantId) {
|
|
2288
|
+
body.tenant_id = tenantId;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2283
2291
|
const headers = {
|
|
2284
2292
|
'Content-Type': 'application/json',
|
|
2285
2293
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5427,6 +5435,7 @@ class ApiClient {
|
|
|
5427
5435
|
|
|
5428
5436
|
|
|
5429
5437
|
|
|
5438
|
+
|
|
5430
5439
|
|
|
5431
5440
|
|
|
5432
5441
|
|
|
@@ -5479,23 +5488,31 @@ class ApiClient {
|
|
|
5479
5488
|
return null;
|
|
5480
5489
|
}
|
|
5481
5490
|
|
|
5482
|
-
|
|
5483
|
-
this.refreshToken
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5491
|
+
try {
|
|
5492
|
+
const session = await this.auth.refreshToken(
|
|
5493
|
+
this.refreshToken,
|
|
5494
|
+
this.refreshBackend,
|
|
5495
|
+
this.refreshExpiration,
|
|
5496
|
+
this.isMobile,
|
|
5497
|
+
this.refreshTenantId,
|
|
5498
|
+
);
|
|
5489
5499
|
|
|
5490
|
-
|
|
5500
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5491
5501
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5502
|
+
if (this.onRefreshToken) {
|
|
5503
|
+
this.onRefreshToken(session.token, session);
|
|
5504
|
+
}
|
|
5495
5505
|
|
|
5496
|
-
|
|
5506
|
+
this.setToken(session.token);
|
|
5497
5507
|
|
|
5498
|
-
|
|
5508
|
+
return session.token;
|
|
5509
|
+
} catch (error) {
|
|
5510
|
+
logger$a.error('token refresh, error', error);
|
|
5511
|
+
|
|
5512
|
+
if (this.onRefreshTokenError) {
|
|
5513
|
+
this.onRefreshTokenError(error);
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5499
5516
|
}
|
|
5500
5517
|
|
|
5501
5518
|
setToken(token ) {
|
|
@@ -5518,6 +5535,10 @@ class ApiClient {
|
|
|
5518
5535
|
this.onRefreshToken = onRefreshToken;
|
|
5519
5536
|
}
|
|
5520
5537
|
|
|
5538
|
+
setOnRefreshTokenError(callback ) {
|
|
5539
|
+
this.onRefreshTokenError = callback;
|
|
5540
|
+
}
|
|
5541
|
+
|
|
5521
5542
|
setRefreshExpiration(refreshExpiration ) {
|
|
5522
5543
|
this.refreshExpiration = refreshExpiration;
|
|
5523
5544
|
}
|
|
@@ -5553,7 +5574,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5553
5574
|
global.wazoClientId = global.wazoClientId || {};
|
|
5554
5575
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5555
5576
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5577
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5556
5578
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5579
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5557
5580
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5558
5581
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5559
5582
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5575,10 +5598,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5575
5598
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5576
5599
|
};
|
|
5577
5600
|
|
|
5601
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5602
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5603
|
+
};
|
|
5604
|
+
|
|
5578
5605
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5579
5606
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5580
5607
|
};
|
|
5581
5608
|
|
|
5609
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5610
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5611
|
+
};
|
|
5612
|
+
|
|
5582
5613
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5583
5614
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5584
5615
|
};
|
|
@@ -5597,12 +5628,20 @@ const fillClient = (apiClient ) => {
|
|
|
5597
5628
|
|
|
5598
5629
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5599
5630
|
|
|
5631
|
+
apiClient.setRefreshTenantId(
|
|
5632
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5633
|
+
);
|
|
5634
|
+
|
|
5600
5635
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5601
5636
|
|
|
5602
5637
|
apiClient.setOnRefreshToken(
|
|
5603
5638
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5604
5639
|
);
|
|
5605
5640
|
|
|
5641
|
+
apiClient.setOnRefreshTokenError(
|
|
5642
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5643
|
+
);
|
|
5644
|
+
|
|
5606
5645
|
apiClient.setRefreshExpiration(
|
|
5607
5646
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5608
5647
|
);
|
|
@@ -5616,7 +5655,7 @@ const fillClient = (apiClient ) => {
|
|
|
5616
5655
|
return apiClient;
|
|
5617
5656
|
};
|
|
5618
5657
|
|
|
5619
|
-
var getApiClient = (forServer
|
|
5658
|
+
var getApiClient = (forServer = null) => {
|
|
5620
5659
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5621
5660
|
if (server in global.wazoClients) {
|
|
5622
5661
|
return fillClient(global.wazoClients[server]);
|
|
@@ -7152,8 +7191,10 @@ class WebRTCClient extends Emitter {
|
|
|
7152
7191
|
conference: isConference,
|
|
7153
7192
|
};
|
|
7154
7193
|
|
|
7155
|
-
// Avoid sdh to
|
|
7156
|
-
session.sessionDescriptionHandler
|
|
7194
|
+
// Avoid sdh to create a new stream
|
|
7195
|
+
if (session.sessionDescriptionHandler) {
|
|
7196
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7197
|
+
}
|
|
7157
7198
|
|
|
7158
7199
|
// Send re-INVITE
|
|
7159
7200
|
return session.invite(options);
|
|
@@ -9124,7 +9165,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9124
9165
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
9125
9166
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
9126
9167
|
// We have to downgrade to audio.
|
|
9127
|
-
const screenshareStopped = this.currentScreenShare.
|
|
9168
|
+
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
9128
9169
|
const constraints = { audio: false, video: screenshareStopped };
|
|
9129
9170
|
|
|
9130
9171
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
@@ -9568,7 +9609,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9568
9609
|
|
|
9569
9610
|
logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9570
9611
|
|
|
9571
|
-
// Stop
|
|
9612
|
+
// Stop screenshare if needed
|
|
9572
9613
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
9573
9614
|
this.lastScreenShare = this.currentScreenShare;
|
|
9574
9615
|
await this.stopScreenSharing(false, callSession);
|
|
@@ -10144,7 +10185,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10144
10185
|
});
|
|
10145
10186
|
|
|
10146
10187
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10147
|
-
logger$8.
|
|
10188
|
+
logger$8.info('WebRTC client disconnected');
|
|
10148
10189
|
|
|
10149
10190
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10150
10191
|
|
|
@@ -10330,7 +10371,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10330
10371
|
endTime: fromSession ? fromSession.endTime : null,
|
|
10331
10372
|
answered: state === sessionState.SessionState.Established,
|
|
10332
10373
|
paused: this.client.isCallHeld(sipSession),
|
|
10333
|
-
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
10374
|
+
isCaller: fromSession ? fromSession.isCaller : ('incoming' in extra ? !extra.incoming : false),
|
|
10334
10375
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
10335
10376
|
number,
|
|
10336
10377
|
ringing: false,
|
|
@@ -11164,7 +11205,7 @@ class WebSocketClient extends Emitter {
|
|
|
11164
11205
|
this.close();
|
|
11165
11206
|
}
|
|
11166
11207
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11167
|
-
logger$6.
|
|
11208
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11168
11209
|
|
|
11169
11210
|
return url;
|
|
11170
11211
|
}
|
|
@@ -13730,6 +13771,7 @@ class Auth {
|
|
|
13730
13771
|
|
|
13731
13772
|
|
|
13732
13773
|
|
|
13774
|
+
|
|
13733
13775
|
|
|
13734
13776
|
|
|
13735
13777
|
|
|
@@ -13767,6 +13809,14 @@ class Auth {
|
|
|
13767
13809
|
this.onRefreshTokenCallback(token, session);
|
|
13768
13810
|
}
|
|
13769
13811
|
});
|
|
13812
|
+
|
|
13813
|
+
setOnRefreshTokenError(error => {
|
|
13814
|
+
logger.error('on refresh token error', error);
|
|
13815
|
+
|
|
13816
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13817
|
+
this.onRefreshTokenCallbackError(error);
|
|
13818
|
+
}
|
|
13819
|
+
});
|
|
13770
13820
|
}
|
|
13771
13821
|
|
|
13772
13822
|
setFetchOptions(options ) {
|
|
@@ -13855,6 +13905,10 @@ class Auth {
|
|
|
13855
13905
|
this.onRefreshTokenCallback = callback;
|
|
13856
13906
|
}
|
|
13857
13907
|
|
|
13908
|
+
setOnRefreshTokenError(callback ) {
|
|
13909
|
+
this.onRefreshTokenCallbackError = callback;
|
|
13910
|
+
}
|
|
13911
|
+
|
|
13858
13912
|
checkAuthorizations(session , authorizationName ) {
|
|
13859
13913
|
if (!authorizationName) {
|
|
13860
13914
|
return;
|
|
@@ -13887,6 +13941,12 @@ class Auth {
|
|
|
13887
13941
|
setRefreshToken(refreshToken);
|
|
13888
13942
|
}
|
|
13889
13943
|
|
|
13944
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
13945
|
+
setRefreshTenantId(refreshTenantId);
|
|
13946
|
+
|
|
13947
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
13948
|
+
}
|
|
13949
|
+
|
|
13890
13950
|
forceRefreshToken() {
|
|
13891
13951
|
getApiClient().forceRefreshToken();
|
|
13892
13952
|
}
|