@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/simple/utils.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);
|
|
5507
|
+
|
|
5508
|
+
return session.token;
|
|
5509
|
+
} catch (error) {
|
|
5510
|
+
logger$a.error('token refresh, error', error);
|
|
5497
5511
|
|
|
5498
|
-
|
|
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]);
|
|
@@ -5643,6 +5682,7 @@ class Auth {
|
|
|
5643
5682
|
|
|
5644
5683
|
|
|
5645
5684
|
|
|
5685
|
+
|
|
5646
5686
|
|
|
5647
5687
|
|
|
5648
5688
|
|
|
@@ -5680,6 +5720,14 @@ class Auth {
|
|
|
5680
5720
|
this.onRefreshTokenCallback(token, session);
|
|
5681
5721
|
}
|
|
5682
5722
|
});
|
|
5723
|
+
|
|
5724
|
+
setOnRefreshTokenError(error => {
|
|
5725
|
+
logger$9.error('on refresh token error', error);
|
|
5726
|
+
|
|
5727
|
+
if (this.onRefreshTokenCallbackError) {
|
|
5728
|
+
this.onRefreshTokenCallbackError(error);
|
|
5729
|
+
}
|
|
5730
|
+
});
|
|
5683
5731
|
}
|
|
5684
5732
|
|
|
5685
5733
|
setFetchOptions(options ) {
|
|
@@ -5768,6 +5816,10 @@ class Auth {
|
|
|
5768
5816
|
this.onRefreshTokenCallback = callback;
|
|
5769
5817
|
}
|
|
5770
5818
|
|
|
5819
|
+
setOnRefreshTokenError(callback ) {
|
|
5820
|
+
this.onRefreshTokenCallbackError = callback;
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5771
5823
|
checkAuthorizations(session , authorizationName ) {
|
|
5772
5824
|
if (!authorizationName) {
|
|
5773
5825
|
return;
|
|
@@ -5800,6 +5852,12 @@ class Auth {
|
|
|
5800
5852
|
setRefreshToken(refreshToken);
|
|
5801
5853
|
}
|
|
5802
5854
|
|
|
5855
|
+
setRefreshTenantId(refreshTenantId ) {
|
|
5856
|
+
setRefreshTenantId(refreshTenantId);
|
|
5857
|
+
|
|
5858
|
+
getApiClient().setRefreshTenantId(refreshTenantId);
|
|
5859
|
+
}
|
|
5860
|
+
|
|
5803
5861
|
forceRefreshToken() {
|
|
5804
5862
|
getApiClient().forceRefreshToken();
|
|
5805
5863
|
}
|
|
@@ -7434,8 +7492,10 @@ class WebRTCClient extends Emitter {
|
|
|
7434
7492
|
conference: isConference,
|
|
7435
7493
|
};
|
|
7436
7494
|
|
|
7437
|
-
// Avoid sdh to
|
|
7438
|
-
session.sessionDescriptionHandler
|
|
7495
|
+
// Avoid sdh to create a new stream
|
|
7496
|
+
if (session.sessionDescriptionHandler) {
|
|
7497
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
7498
|
+
}
|
|
7439
7499
|
|
|
7440
7500
|
// Send re-INVITE
|
|
7441
7501
|
return session.invite(options);
|
|
@@ -11446,7 +11506,7 @@ class WebSocketClient extends Emitter {
|
|
|
11446
11506
|
this.close();
|
|
11447
11507
|
}
|
|
11448
11508
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11449
|
-
logger$5.
|
|
11509
|
+
logger$5.info('Wazo WS url computed to reconnect', { url });
|
|
11450
11510
|
|
|
11451
11511
|
return url;
|
|
11452
11512
|
}
|
|
@@ -13905,6 +13965,153 @@ class Checker {
|
|
|
13905
13965
|
}
|
|
13906
13966
|
}
|
|
13907
13967
|
|
|
13968
|
+
//
|
|
13969
|
+
/* eslint-disable no-unused-vars */
|
|
13970
|
+
/* global window, document */
|
|
13971
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13972
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13973
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13974
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13975
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13976
|
+
|
|
13977
|
+
class Softphone {
|
|
13978
|
+
url = 'https://softphone.wazo.io';
|
|
13979
|
+
width = 500;
|
|
13980
|
+
height = 600;
|
|
13981
|
+
displayed = false;
|
|
13982
|
+
iframe = null;
|
|
13983
|
+
|
|
13984
|
+
onLinkEnabled(link ) {}
|
|
13985
|
+
|
|
13986
|
+
onCallMade(call ) {}
|
|
13987
|
+
onCallIncoming(call ) {}
|
|
13988
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13989
|
+
onAuthenticated(session ) {}
|
|
13990
|
+
|
|
13991
|
+
init(url , width , height ) {
|
|
13992
|
+
if (url) {
|
|
13993
|
+
this.url = url;
|
|
13994
|
+
}
|
|
13995
|
+
if (width) {
|
|
13996
|
+
this.width = width;
|
|
13997
|
+
}
|
|
13998
|
+
if (height) {
|
|
13999
|
+
this.height = height;
|
|
14000
|
+
}
|
|
14001
|
+
|
|
14002
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14003
|
+
|
|
14004
|
+
this._createIframe();
|
|
14005
|
+
}
|
|
14006
|
+
|
|
14007
|
+
parseLinks() {
|
|
14008
|
+
const links = this._getLinks();
|
|
14009
|
+
|
|
14010
|
+
links.forEach(link => {
|
|
14011
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
14012
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
14013
|
+
this.onLinkEnabled(link);
|
|
14014
|
+
});
|
|
14015
|
+
}
|
|
14016
|
+
|
|
14017
|
+
makeCall(number ) {
|
|
14018
|
+
this.displaySoftphone();
|
|
14019
|
+
|
|
14020
|
+
if (this.iframe) {
|
|
14021
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
14022
|
+
}
|
|
14023
|
+
}
|
|
14024
|
+
|
|
14025
|
+
toggleSoftphoneDisplay() {
|
|
14026
|
+
if (this.displayed) {
|
|
14027
|
+
this.hideSoftphone();
|
|
14028
|
+
} else {
|
|
14029
|
+
this.displaySoftphone();
|
|
14030
|
+
}
|
|
14031
|
+
|
|
14032
|
+
this.displayed = !this.displayed;
|
|
14033
|
+
}
|
|
14034
|
+
|
|
14035
|
+
displaySoftphone() {
|
|
14036
|
+
if (!this.iframe) {
|
|
14037
|
+
this._createIframe();
|
|
14038
|
+
}
|
|
14039
|
+
|
|
14040
|
+
if (this.iframe) {
|
|
14041
|
+
this.iframe.style.display = 'block';
|
|
14042
|
+
}
|
|
14043
|
+
}
|
|
14044
|
+
|
|
14045
|
+
hideSoftphone() {
|
|
14046
|
+
if (this.iframe) {
|
|
14047
|
+
this.iframe.style.display = 'none';
|
|
14048
|
+
}
|
|
14049
|
+
}
|
|
14050
|
+
|
|
14051
|
+
_createIframe() {
|
|
14052
|
+
this.iframe = document.createElement('iframe');
|
|
14053
|
+
// $FlowFixMe
|
|
14054
|
+
this.iframe.width = this.width;
|
|
14055
|
+
// $FlowFixMe
|
|
14056
|
+
this.iframe.height = this.height;
|
|
14057
|
+
// $FlowFixMe
|
|
14058
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
14059
|
+
this.iframe.style.position = 'absolute';
|
|
14060
|
+
this.iframe.style.left = '0';
|
|
14061
|
+
this.iframe.style.bottom = '0';
|
|
14062
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
14063
|
+
this.iframe.src = this.url;
|
|
14064
|
+
this.iframe.style.display = 'none';
|
|
14065
|
+
this.iframe.id = 'wazo-softphone';
|
|
14066
|
+
|
|
14067
|
+
// $FlowFixMe
|
|
14068
|
+
document.body.appendChild(this.iframe);
|
|
14069
|
+
}
|
|
14070
|
+
|
|
14071
|
+
_getLinks() {
|
|
14072
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
14073
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
14074
|
+
}
|
|
14075
|
+
|
|
14076
|
+
_onLinkClick(e ) {
|
|
14077
|
+
e.preventDefault();
|
|
14078
|
+
const number = e.target.href.split(':')[1];
|
|
14079
|
+
|
|
14080
|
+
this.makeCall(number);
|
|
14081
|
+
}
|
|
14082
|
+
|
|
14083
|
+
_onAuthenticated() {
|
|
14084
|
+
this.parseLinks();
|
|
14085
|
+
}
|
|
14086
|
+
|
|
14087
|
+
_onMessage(event ) {
|
|
14088
|
+
if (!event.data) {
|
|
14089
|
+
return;
|
|
14090
|
+
}
|
|
14091
|
+
|
|
14092
|
+
switch (event.data.type) {
|
|
14093
|
+
case SDK_ON_CALL_MADE:
|
|
14094
|
+
this.onCallMade(event.data.callSession);
|
|
14095
|
+
break;
|
|
14096
|
+
case SDK_CALL_ENDED: {
|
|
14097
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
14098
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
14099
|
+
break;
|
|
14100
|
+
}
|
|
14101
|
+
case SDK_CALL_INCOMING:
|
|
14102
|
+
this.onCallIncoming(event.data.callSession);
|
|
14103
|
+
break;
|
|
14104
|
+
case SDK_AUTHENTICATED:
|
|
14105
|
+
// $FlowFixMe
|
|
14106
|
+
this._onAuthenticated(event.data.session);
|
|
14107
|
+
this.onAuthenticated(event.data.session);
|
|
14108
|
+
break;
|
|
14109
|
+
}
|
|
14110
|
+
}
|
|
14111
|
+
}
|
|
14112
|
+
|
|
14113
|
+
var Softphone$1 = new Softphone();
|
|
14114
|
+
|
|
13908
14115
|
/* global window */
|
|
13909
14116
|
|
|
13910
14117
|
const Wazo = {
|
|
@@ -13925,6 +14132,7 @@ const Wazo = {
|
|
|
13925
14132
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13926
14133
|
Features: Features$1,
|
|
13927
14134
|
Checker,
|
|
14135
|
+
Softphone: Softphone$1,
|
|
13928
14136
|
|
|
13929
14137
|
// Domain
|
|
13930
14138
|
domain: {
|
|
@@ -398,13 +398,9 @@ class IssueReporter {
|
|
|
398
398
|
|
|
399
399
|
setTimeout(() => {
|
|
400
400
|
if (isArray) {
|
|
401
|
-
payload = payload.map(message =>
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
} else {
|
|
406
|
-
// $FlowFixMe
|
|
407
|
-
payload._retry = retry + 1;
|
|
401
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
402
|
+
} else if (payload && typeof payload === 'object') {
|
|
403
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
408
404
|
}
|
|
409
405
|
|
|
410
406
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -412,6 +408,15 @@ class IssueReporter {
|
|
|
412
408
|
});
|
|
413
409
|
}
|
|
414
410
|
|
|
411
|
+
_writeRetryCount(message , count ) {
|
|
412
|
+
if (message && typeof message === 'object') {
|
|
413
|
+
// $FlowFixMe
|
|
414
|
+
message._retry = count;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return message;
|
|
418
|
+
}
|
|
419
|
+
|
|
415
420
|
_isLevelAbove(level1 , level2 ) {
|
|
416
421
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
417
422
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -400,13 +400,9 @@ class IssueReporter {
|
|
|
400
400
|
|
|
401
401
|
setTimeout(() => {
|
|
402
402
|
if (isArray) {
|
|
403
|
-
payload = payload.map(message =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
});
|
|
407
|
-
} else {
|
|
408
|
-
// $FlowFixMe
|
|
409
|
-
payload._retry = retry + 1;
|
|
403
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
404
|
+
} else if (payload && typeof payload === 'object') {
|
|
405
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
410
406
|
}
|
|
411
407
|
|
|
412
408
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -414,6 +410,15 @@ class IssueReporter {
|
|
|
414
410
|
});
|
|
415
411
|
}
|
|
416
412
|
|
|
413
|
+
_writeRetryCount(message , count ) {
|
|
414
|
+
if (message && typeof message === 'object') {
|
|
415
|
+
// $FlowFixMe
|
|
416
|
+
message._retry = count;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return message;
|
|
420
|
+
}
|
|
421
|
+
|
|
417
422
|
_isLevelAbove(level1 , level2 ) {
|
|
418
423
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
419
424
|
const index2 = LOG_LEVELS.indexOf(level2);
|
package/lib/web-rtc-client.js
CHANGED
|
@@ -689,13 +689,9 @@ class IssueReporter {
|
|
|
689
689
|
|
|
690
690
|
setTimeout(() => {
|
|
691
691
|
if (isArray) {
|
|
692
|
-
payload = payload.map(message =>
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
});
|
|
696
|
-
} else {
|
|
697
|
-
// $FlowFixMe
|
|
698
|
-
payload._retry = retry + 1;
|
|
692
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
693
|
+
} else if (payload && typeof payload === 'object') {
|
|
694
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
699
695
|
}
|
|
700
696
|
|
|
701
697
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -703,6 +699,15 @@ class IssueReporter {
|
|
|
703
699
|
});
|
|
704
700
|
}
|
|
705
701
|
|
|
702
|
+
_writeRetryCount(message , count ) {
|
|
703
|
+
if (message && typeof message === 'object') {
|
|
704
|
+
// $FlowFixMe
|
|
705
|
+
message._retry = count;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return message;
|
|
709
|
+
}
|
|
710
|
+
|
|
706
711
|
_isLevelAbove(level1 , level2 ) {
|
|
707
712
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
708
713
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -2804,9 +2809,12 @@ var authMethods = (client , baseUrl ) => ({
|
|
|
2804
2809
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
2805
2810
|
refresh_token: refreshToken,
|
|
2806
2811
|
client_id: client.clientId,
|
|
2807
|
-
tenant_id: tenantId,
|
|
2808
2812
|
};
|
|
2809
2813
|
|
|
2814
|
+
if (tenantId) {
|
|
2815
|
+
body.tenant_id = tenantId;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2810
2818
|
const headers = {
|
|
2811
2819
|
'Content-Type': 'application/json',
|
|
2812
2820
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|
|
@@ -4094,7 +4102,9 @@ global.wazoClients = global.wazoClients || {};
|
|
|
4094
4102
|
global.wazoClientId = global.wazoClientId || {};
|
|
4095
4103
|
global.wazoClientToken = global.wazoClientToken || {};
|
|
4096
4104
|
global.wazoRefreshToken = global.wazoRefreshToken || {};
|
|
4105
|
+
global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
|
|
4097
4106
|
global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
|
|
4107
|
+
global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
|
|
4098
4108
|
global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
|
|
4099
4109
|
global.wazoRefreshBackend = global.wazoRefreshBackend || {};
|
|
4100
4110
|
global.wazoIsMobile = global.wazoIsMobile || {};
|
|
@@ -5140,6 +5150,7 @@ class ApiClient {
|
|
|
5140
5150
|
|
|
5141
5151
|
|
|
5142
5152
|
|
|
5153
|
+
|
|
5143
5154
|
|
|
5144
5155
|
|
|
5145
5156
|
|
|
@@ -5192,23 +5203,31 @@ class ApiClient {
|
|
|
5192
5203
|
return null;
|
|
5193
5204
|
}
|
|
5194
5205
|
|
|
5195
|
-
|
|
5196
|
-
this.refreshToken
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5206
|
+
try {
|
|
5207
|
+
const session = await this.auth.refreshToken(
|
|
5208
|
+
this.refreshToken,
|
|
5209
|
+
this.refreshBackend,
|
|
5210
|
+
this.refreshExpiration,
|
|
5211
|
+
this.isMobile,
|
|
5212
|
+
this.refreshTenantId,
|
|
5213
|
+
);
|
|
5214
|
+
|
|
5215
|
+
logger$1.info('token refreshed', { token: session.token });
|
|
5216
|
+
|
|
5217
|
+
if (this.onRefreshToken) {
|
|
5218
|
+
this.onRefreshToken(session.token, session);
|
|
5219
|
+
}
|
|
5204
5220
|
|
|
5205
|
-
|
|
5206
|
-
this.onRefreshToken(session.token, session);
|
|
5207
|
-
}
|
|
5221
|
+
this.setToken(session.token);
|
|
5208
5222
|
|
|
5209
|
-
|
|
5223
|
+
return session.token;
|
|
5224
|
+
} catch (error) {
|
|
5225
|
+
logger$1.error('token refresh, error', error);
|
|
5210
5226
|
|
|
5211
|
-
|
|
5227
|
+
if (this.onRefreshTokenError) {
|
|
5228
|
+
this.onRefreshTokenError(error);
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5212
5231
|
}
|
|
5213
5232
|
|
|
5214
5233
|
setToken(token ) {
|
|
@@ -5231,6 +5250,10 @@ class ApiClient {
|
|
|
5231
5250
|
this.onRefreshToken = onRefreshToken;
|
|
5232
5251
|
}
|
|
5233
5252
|
|
|
5253
|
+
setOnRefreshTokenError(callback ) {
|
|
5254
|
+
this.onRefreshTokenError = callback;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5234
5257
|
setRefreshExpiration(refreshExpiration ) {
|
|
5235
5258
|
this.refreshExpiration = refreshExpiration;
|
|
5236
5259
|
}
|
|
@@ -6098,8 +6121,10 @@ class WebRTCClient extends Emitter {
|
|
|
6098
6121
|
conference: isConference,
|
|
6099
6122
|
};
|
|
6100
6123
|
|
|
6101
|
-
// Avoid sdh to
|
|
6102
|
-
session.sessionDescriptionHandler
|
|
6124
|
+
// Avoid sdh to create a new stream
|
|
6125
|
+
if (session.sessionDescriptionHandler) {
|
|
6126
|
+
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
6127
|
+
}
|
|
6103
6128
|
|
|
6104
6129
|
// Send re-INVITE
|
|
6105
6130
|
return session.invite(options);
|
package/lib/websocket-client.js
CHANGED
|
@@ -397,13 +397,9 @@ class IssueReporter {
|
|
|
397
397
|
|
|
398
398
|
setTimeout(() => {
|
|
399
399
|
if (isArray) {
|
|
400
|
-
payload = payload.map(message =>
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
});
|
|
404
|
-
} else {
|
|
405
|
-
// $FlowFixMe
|
|
406
|
-
payload._retry = retry + 1;
|
|
400
|
+
payload = payload.map(message => this._writeRetryCount(message, retry + 1));
|
|
401
|
+
} else if (payload && typeof payload === 'object') {
|
|
402
|
+
payload = this._writeRetryCount(payload, retry + 1);
|
|
407
403
|
}
|
|
408
404
|
|
|
409
405
|
this._sendDebugToGrafana(payload, retry + 1);
|
|
@@ -411,6 +407,15 @@ class IssueReporter {
|
|
|
411
407
|
});
|
|
412
408
|
}
|
|
413
409
|
|
|
410
|
+
_writeRetryCount(message , count ) {
|
|
411
|
+
if (message && typeof message === 'object') {
|
|
412
|
+
// $FlowFixMe
|
|
413
|
+
message._retry = count;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return message;
|
|
417
|
+
}
|
|
418
|
+
|
|
414
419
|
_isLevelAbove(level1 , level2 ) {
|
|
415
420
|
const index1 = LOG_LEVELS.indexOf(level1);
|
|
416
421
|
const index2 = LOG_LEVELS.indexOf(level2);
|
|
@@ -871,7 +876,7 @@ class WebSocketClient extends Emitter {
|
|
|
871
876
|
this.close();
|
|
872
877
|
}
|
|
873
878
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
874
|
-
logger.
|
|
879
|
+
logger.info('Wazo WS url computed to reconnect', { url });
|
|
875
880
|
|
|
876
881
|
return url;
|
|
877
882
|
}
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
|
@@ -74,9 +74,12 @@ export default (client: ApiRequester, baseUrl: string) => ({
|
|
|
74
74
|
expiration: expiration || DETAULT_EXPIRATION,
|
|
75
75
|
refresh_token: refreshToken,
|
|
76
76
|
client_id: client.clientId,
|
|
77
|
-
tenant_id: tenantId,
|
|
78
77
|
};
|
|
79
78
|
|
|
79
|
+
if (tenantId) {
|
|
80
|
+
body.tenant_id = tenantId;
|
|
81
|
+
}
|
|
82
|
+
|
|
80
83
|
const headers: Object = {
|
|
81
84
|
'Content-Type': 'application/json',
|
|
82
85
|
...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
|