@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
|
@@ -1919,13 +1919,9 @@ class IssueReporter {
|
|
|
1919
1919
|
|
|
1920
1920
|
setTimeout(() => {
|
|
1921
1921
|
if (isArray) {
|
|
1922
|
-
payload = payload.map(message =>
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
});
|
|
1926
|
-
} else {
|
|
1927
|
-
// $FlowFixMe
|
|
1928
|
-
payload._retry = retry + 1;
|
|
1922
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
1923
|
+
} else if (payload && typeof payload === 'object') {
|
|
1924
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
1929
1925
|
}
|
|
1930
1926
|
|
|
1931
1927
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -1933,6 +1929,15 @@ class IssueReporter {
|
|
|
1933
1929
|
});
|
|
1934
1930
|
}
|
|
1935
1931
|
|
|
1932
|
+
_writeRetryCount(message , count ) {
|
|
1933
|
+
if (message && typeof message === 'object') {
|
|
1934
|
+
// $FlowFixMe
|
|
1935
|
+
message._retry = count;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
return message;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1936
1941
|
_isLevelAbove(level1 , level2 ) {
|
|
1937
1942
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
1938
1943
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2275,9 +2280,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2275
2280
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2276
2281
|
refresh_token: refreshToken,
|
|
2277
2282
|
client_id: client.clientId,
|
|
2278
|
-
tenant_id: tenantId,
|
|
2279
2283
|
};
|
|
2280
2284
|
|
|
2285
|
+
if (tenantId) {
|
|
2286
|
+
body.tenant_id = tenantId;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2281
2289
|
const headers = {
|
|
2282
2290
|
'Content-Type': 'application/json',
|
|
2283
2291
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -5425,6 +5433,7 @@ class ApiClient {
|
|
|
5425
5433
|
|
|
5426
5434
|
|
|
5427
5435
|
|
|
5436
|
+
|
|
5428
5437
|
|
|
5429
5438
|
|
|
5430
5439
|
|
|
@@ -5477,23 +5486,31 @@ class ApiClient {
|
|
|
5477
5486
|
return null;
|
|
5478
5487
|
}
|
|
5479
5488
|
|
|
5480
|
-
|
|
5481
|
-
this.refreshToken
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5489
|
+
try {
|
|
5490
|
+
const session = await this.auth.refreshToken(
|
|
5491
|
+
this.refreshToken,
|
|
5492
|
+
this.refreshBackend,
|
|
5493
|
+
this.refreshExpiration,
|
|
5494
|
+
this.isMobile,
|
|
5495
|
+
this.refreshTenantId,
|
|
5496
|
+
);
|
|
5487
5497
|
|
|
5488
|
-
|
|
5498
|
+
logger$a.info('token refreshed', { token: session.token });
|
|
5489
5499
|
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5500
|
+
if (this.onRefreshToken) {
|
|
5501
|
+
this.onRefreshToken(session.token, session);
|
|
5502
|
+
}
|
|
5493
5503
|
|
|
5494
|
-
|
|
5504
|
+
this.setToken(session.token);
|
|
5505
|
+
|
|
5506
|
+
return session.token;
|
|
5507
|
+
} catch (error) {
|
|
5508
|
+
logger$a.error('token refresh, error', error);
|
|
5495
5509
|
|
|
5496
|
-
|
|
5510
|
+
if (this.onRefreshTokenError) {
|
|
5511
|
+
this.onRefreshTokenError(error);
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5497
5514
|
}
|
|
5498
5515
|
|
|
5499
5516
|
setToken(token ) {
|
|
@@ -5516,6 +5533,10 @@ class ApiClient {
|
|
|
5516
5533
|
this.onRefreshToken = onRefreshToken;
|
|
5517
5534
|
}
|
|
5518
5535
|
|
|
5536
|
+
setOnRefreshTokenError(callback ) {
|
|
5537
|
+
this.onRefreshTokenError = callback;
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5519
5540
|
setRefreshExpiration(refreshExpiration ) {
|
|
5520
5541
|
this.refreshExpiration = refreshExpiration;
|
|
5521
5542
|
}
|
|
@@ -5551,7 +5572,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
5551
5572
|
global.wazoClientId = global.wazoClientId || {};
|
|
5552
5573
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
5553
5574
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
5575
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
5554
5576
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
5577
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
5555
5578
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
5556
5579
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
5557
5580
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5573,10 +5596,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
|
|
|
5573
5596
|
global.wazoRefreshToken[forServer] = newRefreshToken;
|
|
5574
5597
|
};
|
|
5575
5598
|
|
|
5599
|
+
const setRefreshTenantId = (refreshTenantId , forServer = null) => {
|
|
5600
|
+
global.wazoRefreshTenantId[forServer] = refreshTenantId;
|
|
5601
|
+
};
|
|
5602
|
+
|
|
5576
5603
|
const setOnRefreshToken = (onRefreshToken , forServer = null) => {
|
|
5577
5604
|
global.wazoOnRefreshToken[forServer] = onRefreshToken;
|
|
5578
5605
|
};
|
|
5579
5606
|
|
|
5607
|
+
const setOnRefreshTokenError = (callback , forServer = null) => {
|
|
5608
|
+
global.wazoOnRefreshTokenError[forServer] = callback;
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5580
5611
|
const setRefreshExpiration = (refreshExpiration , forServer = null) => {
|
|
5581
5612
|
global.wazoRefreshExpiration[forServer] = refreshExpiration;
|
|
5582
5613
|
};
|
|
@@ -5595,12 +5626,20 @@ const fillClient = (apiClient ) => {
|
|
|
5595
5626
|
|
|
5596
5627
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
5597
5628
|
|
|
5629
|
+
apiClient.setRefreshTenantId(
|
|
5630
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
5631
|
+
);
|
|
5632
|
+
|
|
5598
5633
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
5599
5634
|
|
|
5600
5635
|
apiClient.setOnRefreshToken(
|
|
5601
5636
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
5602
5637
|
);
|
|
5603
5638
|
|
|
5639
|
+
apiClient.setOnRefreshTokenError(
|
|
5640
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
5641
|
+
);
|
|
5642
|
+
|
|
5604
5643
|
apiClient.setRefreshExpiration(
|
|
5605
5644
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
5606
5645
|
);
|
|
@@ -5614,7 +5653,7 @@ const fillClient = (apiClient ) => {
|
|
|
5614
5653
|
return apiClient;
|
|
5615
5654
|
};
|
|
5616
5655
|
|
|
5617
|
-
var getApiClient = (forServer
|
|
5656
|
+
var getApiClient = (forServer = null) => {
|
|
5618
5657
|
const server = forServer || global.wazoCurrentServer || '';
|
|
5619
5658
|
if (server in global.wazoClients) {
|
|
5620
5659
|
return fillClient(global.wazoClients[server]);
|
|
@@ -7150,8 +7189,10 @@ class WebRTCClient extends Emitter {
|
|
|
7150
7189
|
conference: isConference,
|
|
7151
7190
|
};
|
|
7152
7191
|
|
|
7153
|
-
// Avoid sdh to
|
|
7154
|
-
session.sessionDescriptionHandler
|
|
7192
|
+
// Avoid sdh to create a new stream
|
|
7193
|
+
if (session.sessionDescriptionHandler) {
|
|
7194
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7195
|
+
}
|
|
7155
7196
|
|
|
7156
7197
|
// Send re-INVITE
|
|
7157
7198
|
return session.invite(options);
|
|
@@ -11162,7 +11203,7 @@ class WebSocketClient extends Emitter {
|
|
|
11162
11203
|
this.close();
|
|
11163
11204
|
}
|
|
11164
11205
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11165
|
-
logger$6.
|
|
11206
|
+
logger$6.info('Wazo WS url computed to reconnect', { url });
|
|
11166
11207
|
|
|
11167
11208
|
return url;
|
|
11168
11209
|
}
|
|
@@ -13620,6 +13661,153 @@ class Checker {
|
|
|
13620
13661
|
}
|
|
13621
13662
|
}
|
|
13622
13663
|
|
|
13664
|
+
//
|
|
13665
|
+
/* eslint-disable no-unused-vars */
|
|
13666
|
+
/* global window, document */
|
|
13667
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13668
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13669
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13670
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13671
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13672
|
+
|
|
13673
|
+
class Softphone {
|
|
13674
|
+
url = 'https://softphone.wazo.io';
|
|
13675
|
+
width = 500;
|
|
13676
|
+
height = 600;
|
|
13677
|
+
displayed = false;
|
|
13678
|
+
iframe = null;
|
|
13679
|
+
|
|
13680
|
+
onLinkEnabled(link ) {}
|
|
13681
|
+
|
|
13682
|
+
onCallMade(call ) {}
|
|
13683
|
+
onCallIncoming(call ) {}
|
|
13684
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13685
|
+
onAuthenticated(session ) {}
|
|
13686
|
+
|
|
13687
|
+
init(url , width , height ) {
|
|
13688
|
+
if (url) {
|
|
13689
|
+
this.url = url;
|
|
13690
|
+
}
|
|
13691
|
+
if (width) {
|
|
13692
|
+
this.width = width;
|
|
13693
|
+
}
|
|
13694
|
+
if (height) {
|
|
13695
|
+
this.height = height;
|
|
13696
|
+
}
|
|
13697
|
+
|
|
13698
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13699
|
+
|
|
13700
|
+
this._createIframe();
|
|
13701
|
+
}
|
|
13702
|
+
|
|
13703
|
+
parseLinks() {
|
|
13704
|
+
const links = this._getLinks();
|
|
13705
|
+
|
|
13706
|
+
links.forEach(link => {
|
|
13707
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13708
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13709
|
+
this.onLinkEnabled(link);
|
|
13710
|
+
});
|
|
13711
|
+
}
|
|
13712
|
+
|
|
13713
|
+
makeCall(number ) {
|
|
13714
|
+
this.displaySoftphone();
|
|
13715
|
+
|
|
13716
|
+
if (this.iframe) {
|
|
13717
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13718
|
+
}
|
|
13719
|
+
}
|
|
13720
|
+
|
|
13721
|
+
toggleSoftphoneDisplay() {
|
|
13722
|
+
if (this.displayed) {
|
|
13723
|
+
this.hideSoftphone();
|
|
13724
|
+
} else {
|
|
13725
|
+
this.displaySoftphone();
|
|
13726
|
+
}
|
|
13727
|
+
|
|
13728
|
+
this.displayed = !this.displayed;
|
|
13729
|
+
}
|
|
13730
|
+
|
|
13731
|
+
displaySoftphone() {
|
|
13732
|
+
if (!this.iframe) {
|
|
13733
|
+
this._createIframe();
|
|
13734
|
+
}
|
|
13735
|
+
|
|
13736
|
+
if (this.iframe) {
|
|
13737
|
+
this.iframe.style.display = 'block';
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13740
|
+
|
|
13741
|
+
hideSoftphone() {
|
|
13742
|
+
if (this.iframe) {
|
|
13743
|
+
this.iframe.style.display = 'none';
|
|
13744
|
+
}
|
|
13745
|
+
}
|
|
13746
|
+
|
|
13747
|
+
_createIframe() {
|
|
13748
|
+
this.iframe = document.createElement('iframe');
|
|
13749
|
+
// $FlowFixMe
|
|
13750
|
+
this.iframe.width = this.width;
|
|
13751
|
+
// $FlowFixMe
|
|
13752
|
+
this.iframe.height = this.height;
|
|
13753
|
+
// $FlowFixMe
|
|
13754
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13755
|
+
this.iframe.style.position = 'absolute';
|
|
13756
|
+
this.iframe.style.left = '0';
|
|
13757
|
+
this.iframe.style.bottom = '0';
|
|
13758
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13759
|
+
this.iframe.src = this.url;
|
|
13760
|
+
this.iframe.style.display = 'none';
|
|
13761
|
+
this.iframe.id = 'wazo-softphone';
|
|
13762
|
+
|
|
13763
|
+
// $FlowFixMe
|
|
13764
|
+
document.body.appendChild(this.iframe);
|
|
13765
|
+
}
|
|
13766
|
+
|
|
13767
|
+
_getLinks() {
|
|
13768
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13769
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13770
|
+
}
|
|
13771
|
+
|
|
13772
|
+
_onLinkClick(e ) {
|
|
13773
|
+
e.preventDefault();
|
|
13774
|
+
const number = e.target.href.split(':')[1];
|
|
13775
|
+
|
|
13776
|
+
this.makeCall(number);
|
|
13777
|
+
}
|
|
13778
|
+
|
|
13779
|
+
_onAuthenticated() {
|
|
13780
|
+
this.parseLinks();
|
|
13781
|
+
}
|
|
13782
|
+
|
|
13783
|
+
_onMessage(event ) {
|
|
13784
|
+
if (!event.data) {
|
|
13785
|
+
return;
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13788
|
+
switch (event.data.type) {
|
|
13789
|
+
case SDK_ON_CALL_MADE:
|
|
13790
|
+
this.onCallMade(event.data.callSession);
|
|
13791
|
+
break;
|
|
13792
|
+
case SDK_CALL_ENDED: {
|
|
13793
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13794
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13795
|
+
break;
|
|
13796
|
+
}
|
|
13797
|
+
case SDK_CALL_INCOMING:
|
|
13798
|
+
this.onCallIncoming(event.data.callSession);
|
|
13799
|
+
break;
|
|
13800
|
+
case SDK_AUTHENTICATED:
|
|
13801
|
+
// $FlowFixMe
|
|
13802
|
+
this._onAuthenticated(event.data.session);
|
|
13803
|
+
this.onAuthenticated(event.data.session);
|
|
13804
|
+
break;
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
}
|
|
13808
|
+
|
|
13809
|
+
var Softphone$1 = new Softphone();
|
|
13810
|
+
|
|
13623
13811
|
/* global window */
|
|
13624
13812
|
|
|
13625
13813
|
const Wazo = {
|
|
@@ -13640,6 +13828,7 @@ const Wazo = {
|
|
|
13640
13828
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13641
13829
|
Features: Features$1,
|
|
13642
13830
|
Checker,
|
|
13831
|
+
Softphone: Softphone$1,
|
|
13643
13832
|
|
|
13644
13833
|
// Domain
|
|
13645
13834
|
domain: {
|
|
@@ -13711,6 +13900,7 @@ class Auth {
|
|
|
13711
13900
|
|
|
13712
13901
|
|
|
13713
13902
|
|
|
13903
|
+
|
|
13714
13904
|
|
|
13715
13905
|
|
|
13716
13906
|
|
|
@@ -13748,6 +13938,14 @@ class Auth {
|
|
|
13748
13938
|
this.onRefreshTokenCallback(token, session);
|
|
13749
13939
|
}
|
|
13750
13940
|
});
|
|
13941
|
+
|
|
13942
|
+
setOnRefreshTokenError(error => {
|
|
13943
|
+
logger.error('on refresh token error', error);
|
|
13944
|
+
|
|
13945
|
+
if (this.onRefreshTokenCallbackError) {
|
|
13946
|
+
this.onRefreshTokenCallbackError(error);
|
|
13947
|
+
}
|
|
13948
|
+
});
|
|
13751
13949
|
}
|
|
13752
13950
|
|
|
13753
13951
|
setFetchOptions(options ) {
|
|
@@ -13836,6 +14034,10 @@ class Auth {
|
|
|
13836
14034
|
this.onRefreshTokenCallback = callback;
|
|
13837
14035
|
}
|
|
13838
14036
|
|
|
14037
|
+
setOnRefreshTokenError(callback ) {
|
|
14038
|
+
this.onRefreshTokenCallbackError = callback;
|
|
14039
|
+
}
|
|
14040
|
+
|
|
13839
14041
|
checkAuthorizations(session , authorizationName ) {
|
|
13840
14042
|
if (!authorizationName) {
|
|
13841
14043
|
return;
|
|
@@ -13868,6 +14070,12 @@ class Auth {
|
|
|
13868
14070
|
setRefreshToken(refreshToken);
|
|
13869
14071
|
}
|
|
13870
14072
|
|
|
14073
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
14074
|
+
setRefreshTenantId(refreshTenantId);
|
|
14075
|
+
|
|
14076
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
14077
|
+
}
|
|
14078
|
+
|
|
13871
14079
|
forceRefreshToken() {
|
|
13872
14080
|
getApiClient().forceRefreshToken();
|
|
13873
14081
|
}
|
package/lib/simple/Directory.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' } : {}),
|
|
@@ -4572,6 +4580,7 @@ class ApiClient {
|
|
|
4572
4580
|
|
|
4573
4581
|
|
|
4574
4582
|
|
|
4583
|
+
|
|
4575
4584
|
|
|
4576
4585
|
|
|
4577
4586
|
|
|
@@ -4624,23 +4633,31 @@ class ApiClient {
|
|
|
4624
4633
|
return null;
|
|
4625
4634
|
}
|
|
4626
4635
|
|
|
4627
|
-
|
|
4628
|
-
this.refreshToken
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
+
try {
|
|
4637
|
+
const session = await this.auth.refreshToken(
|
|
4638
|
+
this.refreshToken,
|
|
4639
|
+
this.refreshBackend,
|
|
4640
|
+
this.refreshExpiration,
|
|
4641
|
+
this.isMobile,
|
|
4642
|
+
this.refreshTenantId,
|
|
4643
|
+
);
|
|
4644
|
+
|
|
4645
|
+
logger.info('token refreshed', { token: session.token });
|
|
4646
|
+
|
|
4647
|
+
if (this.onRefreshToken) {
|
|
4648
|
+
this.onRefreshToken(session.token, session);
|
|
4649
|
+
}
|
|
4636
4650
|
|
|
4637
|
-
|
|
4638
|
-
this.onRefreshToken(session.token, session);
|
|
4639
|
-
}
|
|
4651
|
+
this.setToken(session.token);
|
|
4640
4652
|
|
|
4641
|
-
|
|
4653
|
+
return session.token;
|
|
4654
|
+
} catch (error) {
|
|
4655
|
+
logger.error('token refresh, error', error);
|
|
4642
4656
|
|
|
4643
|
-
|
|
4657
|
+
if (this.onRefreshTokenError) {
|
|
4658
|
+
this.onRefreshTokenError(error);
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4644
4661
|
}
|
|
4645
4662
|
|
|
4646
4663
|
setToken(token ) {
|
|
@@ -4663,6 +4680,10 @@ class ApiClient {
|
|
|
4663
4680
|
this.onRefreshToken = onRefreshToken;
|
|
4664
4681
|
}
|
|
4665
4682
|
|
|
4683
|
+
setOnRefreshTokenError(callback ) {
|
|
4684
|
+
this.onRefreshTokenError = callback;
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4666
4687
|
setRefreshExpiration(refreshExpiration ) {
|
|
4667
4688
|
this.refreshExpiration = refreshExpiration;
|
|
4668
4689
|
}
|
|
@@ -4698,7 +4719,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4698
4719
|
global.wazoClientId = global.wazoClientId || {};
|
|
4699
4720
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4700
4721
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4722
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4701
4723
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4724
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4702
4725
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4703
4726
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4704
4727
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -4714,12 +4737,20 @@ const fillClient = (apiClient ) => {
|
|
|
4714
4737
|
|
|
4715
4738
|
apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
|
|
4716
4739
|
|
|
4740
|
+
apiClient.setRefreshTenantId(
|
|
4741
|
+
global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
|
|
4742
|
+
);
|
|
4743
|
+
|
|
4717
4744
|
apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
|
|
4718
4745
|
|
|
4719
4746
|
apiClient.setOnRefreshToken(
|
|
4720
4747
|
global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
|
|
4721
4748
|
);
|
|
4722
4749
|
|
|
4750
|
+
apiClient.setOnRefreshTokenError(
|
|
4751
|
+
global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
|
|
4752
|
+
);
|
|
4753
|
+
|
|
4723
4754
|
apiClient.setRefreshExpiration(
|
|
4724
4755
|
global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
|
|
4725
4756
|
);
|
|
@@ -4733,7 +4764,7 @@ const fillClient = (apiClient ) => {
|
|
|
4733
4764
|
return apiClient;
|
|
4734
4765
|
};
|
|
4735
4766
|
|
|
4736
|
-
var getApiClient = (forServer
|
|
4767
|
+
var getApiClient = (forServer = null) => {
|
|
4737
4768
|
const server = forServer || global.wazoCurrentServer || '';
|
|
4738
4769
|
if (server in global.wazoClients) {
|
|
4739
4770
|
return fillClient(global.wazoClients[server]);
|