@wazo/sdk 0.37.24 → 0.37.25
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 +6 -6
- package/esm/__tests__/api-client.test.js +12 -12
- package/esm/__tests__/web-rtc-client.test.js +120 -103
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- package/esm/api/ctid-ng.js +3 -3
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +12 -12
- package/esm/checker/Checker.js +145 -128
- package/esm/checker/checks/aor.js +12 -12
- package/esm/checker/checks/api.js +12 -12
- package/esm/checker/checks/index.js +135 -118
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +120 -103
- package/esm/checker/checks/webrtc.js +120 -103
- package/esm/domain/AdHocAPIConference.js +12 -12
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +12 -12
- package/esm/domain/Phone/CTIPhone.js +26 -26
- package/esm/domain/Phone/WebRTCPhone.js +87 -86
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/index.js +356 -338
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +12 -12
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +12 -12
- package/esm/simple/Auth.js +346 -328
- package/esm/simple/Configuration.js +346 -328
- package/esm/simple/Directory.js +12 -12
- package/esm/simple/Phone.js +346 -328
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +350 -332
- package/esm/simple/room/LocalParticipant.js +350 -332
- package/esm/simple/room/Participant.js +350 -332
- package/esm/simple/room/RemoteParticipant.js +350 -332
- package/esm/simple/room/Room.js +351 -333
- package/esm/simple/room/SipRoom.js +350 -332
- package/esm/simple/room/Stream.js +350 -332
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/esm/simple/utils.js +350 -332
- package/esm/web-rtc-client.js +120 -103
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +12 -12
- package/lib/__tests__/web-rtc-client.test.js +120 -103
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- package/lib/api/ctid-ng.js +3 -3
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +12 -12
- package/lib/checker/Checker.js +145 -128
- package/lib/checker/checks/aor.js +12 -12
- package/lib/checker/checks/api.js +12 -12
- package/lib/checker/checks/index.js +135 -118
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +120 -103
- package/lib/checker/checks/webrtc.js +120 -103
- package/lib/domain/AdHocAPIConference.js +12 -12
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +12 -12
- package/lib/domain/Phone/CTIPhone.js +26 -26
- package/lib/domain/Phone/WebRTCPhone.js +87 -86
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/index.js +356 -338
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +12 -12
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +12 -12
- package/lib/simple/Auth.js +346 -328
- package/lib/simple/Configuration.js +346 -328
- package/lib/simple/Directory.js +12 -12
- package/lib/simple/Phone.js +346 -328
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +350 -332
- package/lib/simple/room/LocalParticipant.js +350 -332
- package/lib/simple/room/Participant.js +350 -332
- package/lib/simple/room/RemoteParticipant.js +350 -332
- package/lib/simple/room/Room.js +351 -333
- package/lib/simple/room/SipRoom.js +350 -332
- package/lib/simple/room/Stream.js +350 -332
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/lib/simple/utils.js +350 -332
- package/lib/web-rtc-client.js +120 -103
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Phone/WebRTCPhone.js +3 -2
- package/src/web-rtc-client.js +27 -10
package/esm/websocket-client.js
CHANGED
|
@@ -35,7 +35,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
35
35
|
|
|
36
36
|
/* */
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
39
39
|
|
|
40
40
|
// Use a function here to be able to mock it in tests
|
|
41
41
|
const realFetch = () => {
|
|
@@ -611,7 +611,7 @@ const BLACKLIST_EVENTS = [
|
|
|
611
611
|
];
|
|
612
612
|
|
|
613
613
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
614
|
-
const logger
|
|
614
|
+
const logger = IssueReporter$1.loggerFor('wazo-ws');
|
|
615
615
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
616
616
|
|
|
617
617
|
class WebSocketClient extends Emitter {
|
|
@@ -660,19 +660,19 @@ class WebSocketClient extends Emitter {
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
connect() {
|
|
663
|
-
logger
|
|
663
|
+
logger.info('connect method started', { host: this.host, token: this.token });
|
|
664
664
|
this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
|
|
665
665
|
if (this.options.binaryType) {
|
|
666
666
|
this.socket.binaryType = this.options.binaryType;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
669
|
this.socket.onopen = () => {
|
|
670
|
-
logger
|
|
670
|
+
logger.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
671
671
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
672
672
|
};
|
|
673
673
|
|
|
674
674
|
this.socket.onerror = event => {
|
|
675
|
-
logger
|
|
675
|
+
logger.error('on Wazo WS error', event.target);
|
|
676
676
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
677
677
|
};
|
|
678
678
|
|
|
@@ -702,7 +702,7 @@ class WebSocketClient extends Emitter {
|
|
|
702
702
|
|
|
703
703
|
this.socket.onclose = event => {
|
|
704
704
|
// Can't be converted to JSON (circular structure)
|
|
705
|
-
logger
|
|
705
|
+
logger.info('on Wazo WS close', {
|
|
706
706
|
reason: event.reason,
|
|
707
707
|
code: event.code,
|
|
708
708
|
readyState: event.target.readyState,
|
|
@@ -720,12 +720,12 @@ class WebSocketClient extends Emitter {
|
|
|
720
720
|
};
|
|
721
721
|
|
|
722
722
|
this.socket.onerror = event => {
|
|
723
|
-
logger
|
|
723
|
+
logger.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
724
724
|
};
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
close(force = false) {
|
|
728
|
-
logger
|
|
728
|
+
logger.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
729
729
|
|
|
730
730
|
if (!this.socket) {
|
|
731
731
|
return;
|
|
@@ -743,7 +743,7 @@ class WebSocketClient extends Emitter {
|
|
|
743
743
|
|
|
744
744
|
updateToken(token ) {
|
|
745
745
|
this.token = token;
|
|
746
|
-
logger
|
|
746
|
+
logger.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
747
747
|
|
|
748
748
|
if (this.socket) {
|
|
749
749
|
// If still connected, send the token to the WS
|
|
@@ -761,7 +761,7 @@ class WebSocketClient extends Emitter {
|
|
|
761
761
|
}
|
|
762
762
|
|
|
763
763
|
startHeartbeat() {
|
|
764
|
-
logger
|
|
764
|
+
logger.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
765
765
|
|
|
766
766
|
if (!this.socket) {
|
|
767
767
|
this.heartbeat.stop();
|
|
@@ -775,7 +775,7 @@ class WebSocketClient extends Emitter {
|
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
stopHeartbeat() {
|
|
778
|
-
logger
|
|
778
|
+
logger.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
779
779
|
|
|
780
780
|
this.heartbeat.stop();
|
|
781
781
|
}
|
|
@@ -805,7 +805,7 @@ class WebSocketClient extends Emitter {
|
|
|
805
805
|
}
|
|
806
806
|
|
|
807
807
|
reconnect(reason ) {
|
|
808
|
-
logger
|
|
808
|
+
logger.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
809
809
|
if (!this.socket) {
|
|
810
810
|
return;
|
|
811
811
|
}
|
|
@@ -861,7 +861,7 @@ class WebSocketClient extends Emitter {
|
|
|
861
861
|
this.close();
|
|
862
862
|
}
|
|
863
863
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
864
|
-
logger
|
|
864
|
+
logger.log('Wazo WS url computed to reconnect', { url });
|
|
865
865
|
|
|
866
866
|
return url;
|
|
867
867
|
}
|
|
@@ -869,12 +869,12 @@ class WebSocketClient extends Emitter {
|
|
|
869
869
|
_onHeartbeat(message ) {
|
|
870
870
|
if (message.payload === 'pong') {
|
|
871
871
|
this.heartbeat.onHeartbeat();
|
|
872
|
-
logger
|
|
872
|
+
logger.log('on heartbeat received from Wazo WS');
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
async _onHeartbeatTimeout() {
|
|
877
|
-
logger
|
|
877
|
+
logger.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
878
878
|
|
|
879
879
|
this.close();
|
|
880
880
|
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
@@ -446,7 +446,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
446
446
|
|
|
447
447
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
448
448
|
|
|
449
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
449
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
450
450
|
|
|
451
451
|
// Use a function here to be able to mock it in tests
|
|
452
452
|
const realFetch = () => {
|
|
@@ -585,7 +585,7 @@ class ApiRequester {
|
|
|
585
585
|
};
|
|
586
586
|
|
|
587
587
|
if (this.refreshTokenPromise) {
|
|
588
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
588
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
589
589
|
await this.refreshTokenPromise;
|
|
590
590
|
}
|
|
591
591
|
|
|
@@ -605,7 +605,7 @@ class ApiRequester {
|
|
|
605
605
|
return promise.then(async (err ) => {
|
|
606
606
|
// Check if the token is still valid
|
|
607
607
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
608
|
-
logger.warn('token expired', { error: err.reason });
|
|
608
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
609
609
|
// Replay the call after refreshing the token
|
|
610
610
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
611
611
|
}
|
|
@@ -615,7 +615,7 @@ class ApiRequester {
|
|
|
615
615
|
: exceptionClass.fromResponse(err, response.status);
|
|
616
616
|
|
|
617
617
|
if (this.shouldLogErrors) {
|
|
618
|
-
logger.error('API error', error);
|
|
618
|
+
logger$1.error('API error', error);
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
throw error;
|
|
@@ -625,7 +625,7 @@ class ApiRequester {
|
|
|
625
625
|
return newParse(response, isJson);
|
|
626
626
|
}).catch(error => {
|
|
627
627
|
if (this.shouldLogErrors) {
|
|
628
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
628
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
throw error;
|
|
@@ -653,13 +653,13 @@ class ApiRequester {
|
|
|
653
653
|
) {
|
|
654
654
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
655
655
|
let newPath = path;
|
|
656
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
656
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
657
657
|
|
|
658
658
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
659
659
|
|
|
660
660
|
return this.refreshTokenPromise.then(() => {
|
|
661
661
|
this.refreshTokenPromise = null;
|
|
662
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
662
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
663
663
|
if (isTokenNotFound) {
|
|
664
664
|
const pathParts = path.split('/');
|
|
665
665
|
pathParts.pop();
|
|
@@ -3601,7 +3601,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3601
3601
|
|
|
3602
3602
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3603
3603
|
|
|
3604
|
-
|
|
3604
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3605
3605
|
|
|
3606
3606
|
/* */
|
|
3607
3607
|
|
|
@@ -4520,7 +4520,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4520
4520
|
const WEBHOOKD_VERSION = '1.0';
|
|
4521
4521
|
const AMID_VERSION = '1.0';
|
|
4522
4522
|
|
|
4523
|
-
const logger
|
|
4523
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4524
4524
|
|
|
4525
4525
|
class ApiClient {
|
|
4526
4526
|
|
|
@@ -4572,12 +4572,12 @@ class ApiClient {
|
|
|
4572
4572
|
}
|
|
4573
4573
|
|
|
4574
4574
|
async forceRefreshToken() {
|
|
4575
|
-
logger
|
|
4575
|
+
logger.info('forcing refresh token, calling callback');
|
|
4576
4576
|
return this.refreshTokenCallback();
|
|
4577
4577
|
}
|
|
4578
4578
|
|
|
4579
4579
|
async refreshTokenCallback() {
|
|
4580
|
-
logger
|
|
4580
|
+
logger.info('refresh token callback called', {
|
|
4581
4581
|
refreshToken: this.refreshToken,
|
|
4582
4582
|
refreshBackend: this.refreshBackend,
|
|
4583
4583
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4595,7 +4595,7 @@ class ApiClient {
|
|
|
4595
4595
|
this.isMobile,
|
|
4596
4596
|
);
|
|
4597
4597
|
|
|
4598
|
-
logger
|
|
4598
|
+
logger.info('token refreshed', { token: session.token });
|
|
4599
4599
|
|
|
4600
4600
|
if (this.onRefreshToken) {
|
|
4601
4601
|
this.onRefreshToken(session.token, session);
|