@wazo/sdk 0.37.24 → 0.37.28
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/README.md +96 -58
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +14 -14
- package/esm/__tests__/web-rtc-client.test.js +130 -108
- package/esm/api/agentd.js +1 -1
- package/esm/api/amid.js +2 -2
- package/esm/api/application.js +1 -1
- package/esm/api/auth.js +1 -1
- package/esm/api/call-logd.js +3 -3
- package/esm/api/calld.js +1 -1
- package/esm/api/chatd.js +1 -1
- package/esm/api/confd.js +1 -1
- package/esm/api/ctid-ng.js +4 -4
- package/esm/api/dird.js +3 -3
- package/esm/api/webhookd.js +2 -2
- package/esm/api-client.js +14 -14
- package/esm/checker/Checker.js +155 -133
- package/esm/checker/checks/aor.js +14 -14
- package/esm/checker/checks/api.js +14 -14
- package/esm/checker/checks/index.js +145 -123
- package/esm/checker/checks/wazo-websocket.js +16 -16
- package/esm/checker/checks/webrtc-transport.js +130 -108
- package/esm/checker/checks/webrtc.js +130 -108
- package/esm/domain/AdHocAPIConference.js +14 -14
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/CallSession.js +15 -0
- package/esm/domain/Contact.js +2 -2
- package/esm/domain/Features.js +14 -14
- package/esm/domain/Phone/CTIPhone.js +43 -28
- package/esm/domain/Phone/WebRTCPhone.js +126 -90
- package/esm/domain/SFUNotAvailableError.js +9 -0
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/CallSession.test.js +15 -0
- package/esm/domain/__tests__/Contact.test.js +2 -2
- package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/esm/domain/__tests__/Room.test.js +15 -0
- package/esm/index.js +415 -346
- package/esm/lib/WazoSessionDescriptionHandler.js +10 -5
- package/esm/service/CallApi.js +14 -14
- package/esm/service/IssueReporter.js +2 -2
- package/esm/service/__tests__/IssueReporter.test.js +2 -2
- package/esm/service/getApiClient.js +14 -14
- package/esm/simple/Auth.js +404 -336
- package/esm/simple/Configuration.js +404 -336
- package/esm/simple/Directory.js +14 -14
- package/esm/simple/Phone.js +404 -336
- package/esm/simple/Websocket.js +18 -18
- package/esm/simple/index.js +408 -340
- package/esm/simple/room/LocalParticipant.js +408 -340
- package/esm/simple/room/Participant.js +408 -340
- package/esm/simple/room/RemoteParticipant.js +408 -340
- package/esm/simple/room/Room.js +409 -341
- package/esm/simple/room/SipRoom.js +408 -340
- package/esm/simple/room/Stream.js +408 -340
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/esm/simple/utils.js +408 -340
- package/esm/utils/__tests__/api-requester.test.js +1 -1
- package/esm/utils/api-requester.js +1 -1
- package/esm/web-rtc-client.js +130 -108
- package/esm/websocket-client.js +16 -16
- package/lib/__tests__/api-client.test.js +14 -14
- package/lib/__tests__/web-rtc-client.test.js +130 -108
- package/lib/api/agentd.js +1 -1
- package/lib/api/amid.js +2 -2
- package/lib/api/application.js +1 -1
- package/lib/api/auth.js +1 -1
- package/lib/api/call-logd.js +3 -3
- package/lib/api/calld.js +1 -1
- package/lib/api/chatd.js +1 -1
- package/lib/api/confd.js +1 -1
- package/lib/api/ctid-ng.js +4 -4
- package/lib/api/dird.js +3 -3
- package/lib/api/webhookd.js +2 -2
- package/lib/api-client.js +14 -14
- package/lib/checker/Checker.js +155 -133
- package/lib/checker/checks/aor.js +14 -14
- package/lib/checker/checks/api.js +14 -14
- package/lib/checker/checks/index.js +145 -123
- package/lib/checker/checks/wazo-websocket.js +16 -16
- package/lib/checker/checks/webrtc-transport.js +130 -108
- package/lib/checker/checks/webrtc.js +130 -108
- package/lib/domain/AdHocAPIConference.js +14 -14
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/CallSession.js +15 -0
- package/lib/domain/Contact.js +2 -2
- package/lib/domain/Features.js +14 -14
- package/lib/domain/Phone/CTIPhone.js +43 -28
- package/lib/domain/Phone/WebRTCPhone.js +126 -89
- package/lib/domain/SFUNotAvailableError.js +11 -0
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/CallSession.test.js +15 -0
- package/lib/domain/__tests__/Contact.test.js +2 -2
- package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/lib/domain/__tests__/Room.test.js +15 -0
- package/lib/index.js +415 -346
- package/lib/lib/WazoSessionDescriptionHandler.js +10 -5
- package/lib/service/CallApi.js +14 -14
- package/lib/service/IssueReporter.js +2 -2
- package/lib/service/__tests__/IssueReporter.test.js +2 -2
- package/lib/service/getApiClient.js +14 -14
- package/lib/simple/Auth.js +404 -336
- package/lib/simple/Configuration.js +404 -336
- package/lib/simple/Directory.js +14 -14
- package/lib/simple/Phone.js +404 -336
- package/lib/simple/Websocket.js +18 -18
- package/lib/simple/index.js +408 -340
- package/lib/simple/room/LocalParticipant.js +408 -340
- package/lib/simple/room/Participant.js +408 -340
- package/lib/simple/room/RemoteParticipant.js +408 -340
- package/lib/simple/room/Room.js +409 -341
- package/lib/simple/room/SipRoom.js +408 -340
- package/lib/simple/room/Stream.js +408 -340
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/lib/simple/utils.js +408 -340
- package/lib/utils/__tests__/api-requester.test.js +1 -1
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +130 -108
- package/lib/websocket-client.js +16 -16
- package/package.json +1 -1
- package/src/domain/CallSession.js +16 -0
- package/src/domain/Contact.js +1 -1
- package/src/domain/Phone/WebRTCPhone.js +25 -4
- package/src/domain/SFUNotAvailableError.js +7 -0
- package/src/index.js +2 -0
- package/src/lib/WazoSessionDescriptionHandler.js +8 -3
- package/src/simple/Phone.js +2 -1
- package/src/simple/index.js +2 -0
- package/src/utils/api-requester.js +1 -1
- package/src/web-rtc-client.js +27 -10
|
@@ -660,11 +660,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
660
660
|
|
|
661
661
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
662
662
|
|
|
663
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
663
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
664
664
|
|
|
665
665
|
// Use a function here to be able to mock it in tests
|
|
666
666
|
const realFetch = () => {
|
|
667
|
-
if (typeof document !== 'undefined') {
|
|
667
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
668
668
|
// Browser
|
|
669
669
|
return window.fetch;
|
|
670
670
|
}
|
|
@@ -799,7 +799,7 @@ class ApiRequester {
|
|
|
799
799
|
};
|
|
800
800
|
|
|
801
801
|
if (this.refreshTokenPromise) {
|
|
802
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
802
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
803
803
|
await this.refreshTokenPromise;
|
|
804
804
|
}
|
|
805
805
|
|
|
@@ -819,7 +819,7 @@ class ApiRequester {
|
|
|
819
819
|
return promise.then(async (err ) => {
|
|
820
820
|
// Check if the token is still valid
|
|
821
821
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
822
|
-
logger.warn('token expired', { error: err.reason });
|
|
822
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
823
823
|
// Replay the call after refreshing the token
|
|
824
824
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
825
825
|
}
|
|
@@ -829,7 +829,7 @@ class ApiRequester {
|
|
|
829
829
|
: exceptionClass.fromResponse(err, response.status);
|
|
830
830
|
|
|
831
831
|
if (this.shouldLogErrors) {
|
|
832
|
-
logger.error('API error', error);
|
|
832
|
+
logger$1.error('API error', error);
|
|
833
833
|
}
|
|
834
834
|
|
|
835
835
|
throw error;
|
|
@@ -839,7 +839,7 @@ class ApiRequester {
|
|
|
839
839
|
return newParse(response, isJson);
|
|
840
840
|
}).catch(error => {
|
|
841
841
|
if (this.shouldLogErrors) {
|
|
842
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
842
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
throw error;
|
|
@@ -867,13 +867,13 @@ class ApiRequester {
|
|
|
867
867
|
) {
|
|
868
868
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
869
869
|
let newPath = path;
|
|
870
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
870
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
871
871
|
|
|
872
872
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
873
873
|
|
|
874
874
|
return this.refreshTokenPromise.then(() => {
|
|
875
875
|
this.refreshTokenPromise = null;
|
|
876
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
876
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
877
877
|
if (isTokenNotFound) {
|
|
878
878
|
const pathParts = path.split('/');
|
|
879
879
|
pathParts.pop();
|
|
@@ -2113,7 +2113,7 @@ class Contact {
|
|
|
2113
2113
|
this[key] = old[key] || this[key];
|
|
2114
2114
|
});
|
|
2115
2115
|
|
|
2116
|
-
if (old.lineState
|
|
2116
|
+
if (old.lineState) {
|
|
2117
2117
|
this.lineState = old.lineState;
|
|
2118
2118
|
}
|
|
2119
2119
|
|
|
@@ -3580,7 +3580,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3580
3580
|
|
|
3581
3581
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3582
3582
|
|
|
3583
|
-
|
|
3583
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3584
3584
|
|
|
3585
3585
|
/* */
|
|
3586
3586
|
|
|
@@ -4499,7 +4499,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4499
4499
|
const WEBHOOKD_VERSION = '1.0';
|
|
4500
4500
|
const AMID_VERSION = '1.0';
|
|
4501
4501
|
|
|
4502
|
-
const logger
|
|
4502
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4503
4503
|
|
|
4504
4504
|
class ApiClient {
|
|
4505
4505
|
|
|
@@ -4551,12 +4551,12 @@ class ApiClient {
|
|
|
4551
4551
|
}
|
|
4552
4552
|
|
|
4553
4553
|
async forceRefreshToken() {
|
|
4554
|
-
logger
|
|
4554
|
+
logger.info('forcing refresh token, calling callback');
|
|
4555
4555
|
return this.refreshTokenCallback();
|
|
4556
4556
|
}
|
|
4557
4557
|
|
|
4558
4558
|
async refreshTokenCallback() {
|
|
4559
|
-
logger
|
|
4559
|
+
logger.info('refresh token callback called', {
|
|
4560
4560
|
refreshToken: this.refreshToken,
|
|
4561
4561
|
refreshBackend: this.refreshBackend,
|
|
4562
4562
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4574,7 +4574,7 @@ class ApiClient {
|
|
|
4574
4574
|
this.isMobile,
|
|
4575
4575
|
);
|
|
4576
4576
|
|
|
4577
|
-
logger
|
|
4577
|
+
logger.info('token refreshed', { token: session.token });
|
|
4578
4578
|
|
|
4579
4579
|
if (this.onRefreshToken) {
|
|
4580
4580
|
this.onRefreshToken(session.token, session);
|
package/esm/domain/CallLog.js
CHANGED
|
@@ -37,8 +37,10 @@ var updateFrom = (instance , from ) => {
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
|
|
40
41
|
|
|
41
42
|
|
|
43
|
+
|
|
42
44
|
|
|
43
45
|
|
|
44
46
|
|
|
@@ -55,6 +57,7 @@ var updateFrom = (instance , from ) => {
|
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
|
|
60
|
+
|
|
58
61
|
|
|
59
62
|
|
|
60
63
|
class CallSession {
|
|
@@ -74,8 +77,12 @@ class CallSession {
|
|
|
74
77
|
|
|
75
78
|
|
|
76
79
|
|
|
80
|
+
|
|
81
|
+
|
|
77
82
|
|
|
78
83
|
|
|
84
|
+
|
|
85
|
+
|
|
79
86
|
|
|
80
87
|
|
|
81
88
|
|
|
@@ -113,6 +120,8 @@ class CallSession {
|
|
|
113
120
|
|
|
114
121
|
|
|
115
122
|
|
|
123
|
+
|
|
124
|
+
|
|
116
125
|
|
|
117
126
|
constructor({
|
|
118
127
|
answered,
|
|
@@ -126,6 +135,8 @@ class CallSession {
|
|
|
126
135
|
paused,
|
|
127
136
|
ringing,
|
|
128
137
|
startTime,
|
|
138
|
+
creationTime,
|
|
139
|
+
endTime,
|
|
129
140
|
cameraEnabled,
|
|
130
141
|
dialedExtension,
|
|
131
142
|
sipCallId,
|
|
@@ -138,12 +149,15 @@ class CallSession {
|
|
|
138
149
|
recording,
|
|
139
150
|
recordingPaused,
|
|
140
151
|
videoRemotelyDowngraded,
|
|
152
|
+
sipSession,
|
|
141
153
|
} ) {
|
|
142
154
|
this.callId = callId;
|
|
143
155
|
this.sipCallId = sipCallId;
|
|
144
156
|
this.displayName = displayName;
|
|
145
157
|
this.number = number;
|
|
158
|
+
this.creationTime = creationTime;
|
|
146
159
|
this.startTime = startTime;
|
|
160
|
+
this.endTime = endTime;
|
|
147
161
|
this.isCaller = isCaller;
|
|
148
162
|
this.answered = answered;
|
|
149
163
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -162,6 +176,7 @@ class CallSession {
|
|
|
162
176
|
this.recording = recording || false;
|
|
163
177
|
this.recordingPaused = recordingPaused || false;
|
|
164
178
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
179
|
+
this.sipSession = sipSession;
|
|
165
180
|
|
|
166
181
|
// Useful to compare instead of instanceof with minified code
|
|
167
182
|
this.type = 'CallSession';
|
package/esm/domain/Contact.js
CHANGED
|
@@ -44,7 +44,7 @@ const LINE_STATE = {
|
|
|
44
44
|
|
|
45
45
|
//
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
KEYUTIL.getKey(swarmPublicKey);
|
|
48
48
|
|
|
49
49
|
//
|
|
50
50
|
|
|
@@ -698,7 +698,7 @@ class Contact {
|
|
|
698
698
|
this[key] = old[key] || this[key];
|
|
699
699
|
});
|
|
700
700
|
|
|
701
|
-
if (old.lineState
|
|
701
|
+
if (old.lineState) {
|
|
702
702
|
this.lineState = old.lineState;
|
|
703
703
|
}
|
|
704
704
|
|
package/esm/domain/Features.js
CHANGED
|
@@ -440,11 +440,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
440
440
|
|
|
441
441
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
442
442
|
|
|
443
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
443
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
444
444
|
|
|
445
445
|
// Use a function here to be able to mock it in tests
|
|
446
446
|
const realFetch = () => {
|
|
447
|
-
if (typeof document !== 'undefined') {
|
|
447
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
448
448
|
// Browser
|
|
449
449
|
return window.fetch;
|
|
450
450
|
}
|
|
@@ -579,7 +579,7 @@ class ApiRequester {
|
|
|
579
579
|
};
|
|
580
580
|
|
|
581
581
|
if (this.refreshTokenPromise) {
|
|
582
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
582
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
583
583
|
await this.refreshTokenPromise;
|
|
584
584
|
}
|
|
585
585
|
|
|
@@ -599,7 +599,7 @@ class ApiRequester {
|
|
|
599
599
|
return promise.then(async (err ) => {
|
|
600
600
|
// Check if the token is still valid
|
|
601
601
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
602
|
-
logger.warn('token expired', { error: err.reason });
|
|
602
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
603
603
|
// Replay the call after refreshing the token
|
|
604
604
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
605
605
|
}
|
|
@@ -609,7 +609,7 @@ class ApiRequester {
|
|
|
609
609
|
: exceptionClass.fromResponse(err, response.status);
|
|
610
610
|
|
|
611
611
|
if (this.shouldLogErrors) {
|
|
612
|
-
logger.error('API error', error);
|
|
612
|
+
logger$1.error('API error', error);
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
throw error;
|
|
@@ -619,7 +619,7 @@ class ApiRequester {
|
|
|
619
619
|
return newParse(response, isJson);
|
|
620
620
|
}).catch(error => {
|
|
621
621
|
if (this.shouldLogErrors) {
|
|
622
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
622
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
throw error;
|
|
@@ -647,13 +647,13 @@ class ApiRequester {
|
|
|
647
647
|
) {
|
|
648
648
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
649
649
|
let newPath = path;
|
|
650
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
650
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
651
651
|
|
|
652
652
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
653
653
|
|
|
654
654
|
return this.refreshTokenPromise.then(() => {
|
|
655
655
|
this.refreshTokenPromise = null;
|
|
656
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
656
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
657
657
|
if (isTokenNotFound) {
|
|
658
658
|
const pathParts = path.split('/');
|
|
659
659
|
pathParts.pop();
|
|
@@ -1904,7 +1904,7 @@ class Contact {
|
|
|
1904
1904
|
this[key] = old[key] || this[key];
|
|
1905
1905
|
});
|
|
1906
1906
|
|
|
1907
|
-
if (old.lineState
|
|
1907
|
+
if (old.lineState) {
|
|
1908
1908
|
this.lineState = old.lineState;
|
|
1909
1909
|
}
|
|
1910
1910
|
|
|
@@ -3580,7 +3580,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3580
3580
|
|
|
3581
3581
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3582
3582
|
|
|
3583
|
-
|
|
3583
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3584
3584
|
|
|
3585
3585
|
/* */
|
|
3586
3586
|
|
|
@@ -4499,7 +4499,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4499
4499
|
const WEBHOOKD_VERSION = '1.0';
|
|
4500
4500
|
const AMID_VERSION = '1.0';
|
|
4501
4501
|
|
|
4502
|
-
const logger
|
|
4502
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4503
4503
|
|
|
4504
4504
|
class ApiClient {
|
|
4505
4505
|
|
|
@@ -4551,12 +4551,12 @@ class ApiClient {
|
|
|
4551
4551
|
}
|
|
4552
4552
|
|
|
4553
4553
|
async forceRefreshToken() {
|
|
4554
|
-
logger
|
|
4554
|
+
logger.info('forcing refresh token, calling callback');
|
|
4555
4555
|
return this.refreshTokenCallback();
|
|
4556
4556
|
}
|
|
4557
4557
|
|
|
4558
4558
|
async refreshTokenCallback() {
|
|
4559
|
-
logger
|
|
4559
|
+
logger.info('refresh token callback called', {
|
|
4560
4560
|
refreshToken: this.refreshToken,
|
|
4561
4561
|
refreshBackend: this.refreshBackend,
|
|
4562
4562
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4574,7 +4574,7 @@ class ApiClient {
|
|
|
4574
4574
|
this.isMobile,
|
|
4575
4575
|
);
|
|
4576
4576
|
|
|
4577
|
-
logger
|
|
4577
|
+
logger.info('token refreshed', { token: session.token });
|
|
4578
4578
|
|
|
4579
4579
|
if (this.onRefreshToken) {
|
|
4580
4580
|
this.onRefreshToken(session.token, session);
|
|
@@ -1217,7 +1217,7 @@ class Contact {
|
|
|
1217
1217
|
this[key] = old[key] || this[key];
|
|
1218
1218
|
});
|
|
1219
1219
|
|
|
1220
|
-
if (old.lineState
|
|
1220
|
+
if (old.lineState) {
|
|
1221
1221
|
this.lineState = old.lineState;
|
|
1222
1222
|
}
|
|
1223
1223
|
|
|
@@ -1711,8 +1711,10 @@ var updateFrom = (instance , from ) => {
|
|
|
1711
1711
|
|
|
1712
1712
|
|
|
1713
1713
|
|
|
1714
|
+
|
|
1714
1715
|
|
|
1715
1716
|
|
|
1717
|
+
|
|
1716
1718
|
|
|
1717
1719
|
|
|
1718
1720
|
|
|
@@ -1729,6 +1731,7 @@ var updateFrom = (instance , from ) => {
|
|
|
1729
1731
|
|
|
1730
1732
|
|
|
1731
1733
|
|
|
1734
|
+
|
|
1732
1735
|
|
|
1733
1736
|
|
|
1734
1737
|
class CallSession {
|
|
@@ -1748,8 +1751,12 @@ class CallSession {
|
|
|
1748
1751
|
|
|
1749
1752
|
|
|
1750
1753
|
|
|
1754
|
+
|
|
1755
|
+
|
|
1751
1756
|
|
|
1752
1757
|
|
|
1758
|
+
|
|
1759
|
+
|
|
1753
1760
|
|
|
1754
1761
|
|
|
1755
1762
|
|
|
@@ -1787,6 +1794,8 @@ class CallSession {
|
|
|
1787
1794
|
|
|
1788
1795
|
|
|
1789
1796
|
|
|
1797
|
+
|
|
1798
|
+
|
|
1790
1799
|
|
|
1791
1800
|
constructor({
|
|
1792
1801
|
answered,
|
|
@@ -1800,6 +1809,8 @@ class CallSession {
|
|
|
1800
1809
|
paused,
|
|
1801
1810
|
ringing,
|
|
1802
1811
|
startTime,
|
|
1812
|
+
creationTime,
|
|
1813
|
+
endTime,
|
|
1803
1814
|
cameraEnabled,
|
|
1804
1815
|
dialedExtension,
|
|
1805
1816
|
sipCallId,
|
|
@@ -1812,12 +1823,15 @@ class CallSession {
|
|
|
1812
1823
|
recording,
|
|
1813
1824
|
recordingPaused,
|
|
1814
1825
|
videoRemotelyDowngraded,
|
|
1826
|
+
sipSession,
|
|
1815
1827
|
} ) {
|
|
1816
1828
|
this.callId = callId;
|
|
1817
1829
|
this.sipCallId = sipCallId;
|
|
1818
1830
|
this.displayName = displayName;
|
|
1819
1831
|
this.number = number;
|
|
1832
|
+
this.creationTime = creationTime;
|
|
1820
1833
|
this.startTime = startTime;
|
|
1834
|
+
this.endTime = endTime;
|
|
1821
1835
|
this.isCaller = isCaller;
|
|
1822
1836
|
this.answered = answered;
|
|
1823
1837
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -1836,6 +1850,7 @@ class CallSession {
|
|
|
1836
1850
|
this.recording = recording || false;
|
|
1837
1851
|
this.recordingPaused = recordingPaused || false;
|
|
1838
1852
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
1853
|
+
this.sipSession = sipSession;
|
|
1839
1854
|
|
|
1840
1855
|
// Useful to compare instead of instanceof with minified code
|
|
1841
1856
|
this.type = 'CallSession';
|
|
@@ -2833,11 +2848,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
2833
2848
|
|
|
2834
2849
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
2835
2850
|
|
|
2836
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2851
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2837
2852
|
|
|
2838
2853
|
// Use a function here to be able to mock it in tests
|
|
2839
2854
|
const realFetch = () => {
|
|
2840
|
-
if (typeof document !== 'undefined') {
|
|
2855
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
2841
2856
|
// Browser
|
|
2842
2857
|
return window.fetch;
|
|
2843
2858
|
}
|
|
@@ -2972,7 +2987,7 @@ class ApiRequester {
|
|
|
2972
2987
|
};
|
|
2973
2988
|
|
|
2974
2989
|
if (this.refreshTokenPromise) {
|
|
2975
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2990
|
+
logger$2.info('A token is already refreshing, waiting ...', { url });
|
|
2976
2991
|
await this.refreshTokenPromise;
|
|
2977
2992
|
}
|
|
2978
2993
|
|
|
@@ -2992,7 +3007,7 @@ class ApiRequester {
|
|
|
2992
3007
|
return promise.then(async (err ) => {
|
|
2993
3008
|
// Check if the token is still valid
|
|
2994
3009
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2995
|
-
logger.warn('token expired', { error: err.reason });
|
|
3010
|
+
logger$2.warn('token expired', { error: err.reason });
|
|
2996
3011
|
// Replay the call after refreshing the token
|
|
2997
3012
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2998
3013
|
}
|
|
@@ -3002,7 +3017,7 @@ class ApiRequester {
|
|
|
3002
3017
|
: exceptionClass.fromResponse(err, response.status);
|
|
3003
3018
|
|
|
3004
3019
|
if (this.shouldLogErrors) {
|
|
3005
|
-
logger.error('API error', error);
|
|
3020
|
+
logger$2.error('API error', error);
|
|
3006
3021
|
}
|
|
3007
3022
|
|
|
3008
3023
|
throw error;
|
|
@@ -3012,7 +3027,7 @@ class ApiRequester {
|
|
|
3012
3027
|
return newParse(response, isJson);
|
|
3013
3028
|
}).catch(error => {
|
|
3014
3029
|
if (this.shouldLogErrors) {
|
|
3015
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
3030
|
+
logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
3016
3031
|
}
|
|
3017
3032
|
|
|
3018
3033
|
throw error;
|
|
@@ -3040,13 +3055,13 @@ class ApiRequester {
|
|
|
3040
3055
|
) {
|
|
3041
3056
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
3042
3057
|
let newPath = path;
|
|
3043
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
3058
|
+
logger$2.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
3044
3059
|
|
|
3045
3060
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
3046
3061
|
|
|
3047
3062
|
return this.refreshTokenPromise.then(() => {
|
|
3048
3063
|
this.refreshTokenPromise = null;
|
|
3049
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
3064
|
+
logger$2.info('token refreshed', { isTokenNotFound });
|
|
3050
3065
|
if (isTokenNotFound) {
|
|
3051
3066
|
const pathParts = path.split('/');
|
|
3052
3067
|
pathParts.pop();
|
|
@@ -5134,7 +5149,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
5134
5149
|
|
|
5135
5150
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
5136
5151
|
|
|
5137
|
-
const logger
|
|
5152
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
5138
5153
|
|
|
5139
5154
|
class CTIPhone extends Emitter {
|
|
5140
5155
|
|
|
@@ -5147,7 +5162,7 @@ class CTIPhone extends Emitter {
|
|
|
5147
5162
|
|
|
5148
5163
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
5149
5164
|
super();
|
|
5150
|
-
logger
|
|
5165
|
+
logger.info('CTI Phone created');
|
|
5151
5166
|
this.session = session;
|
|
5152
5167
|
this.isMobile = isMobile;
|
|
5153
5168
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -5208,7 +5223,7 @@ class CTIPhone extends Emitter {
|
|
|
5208
5223
|
}
|
|
5209
5224
|
|
|
5210
5225
|
async makeCall(number , line ) {
|
|
5211
|
-
logger
|
|
5226
|
+
logger.info('make CTI call', { number });
|
|
5212
5227
|
|
|
5213
5228
|
if (!number) {
|
|
5214
5229
|
return null;
|
|
@@ -5231,7 +5246,7 @@ class CTIPhone extends Emitter {
|
|
|
5231
5246
|
if (!callSession) {
|
|
5232
5247
|
return Promise.resolve(null);
|
|
5233
5248
|
}
|
|
5234
|
-
logger
|
|
5249
|
+
logger.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5235
5250
|
|
|
5236
5251
|
if (!this.currentCall) {
|
|
5237
5252
|
this.currentCall = callSession.call;
|
|
@@ -5244,7 +5259,7 @@ class CTIPhone extends Emitter {
|
|
|
5244
5259
|
if (!callSession) {
|
|
5245
5260
|
return;
|
|
5246
5261
|
}
|
|
5247
|
-
logger
|
|
5262
|
+
logger.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5248
5263
|
|
|
5249
5264
|
this.currentCall = undefined;
|
|
5250
5265
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -5254,7 +5269,7 @@ class CTIPhone extends Emitter {
|
|
|
5254
5269
|
if (!callSession) {
|
|
5255
5270
|
return Promise.resolve(false);
|
|
5256
5271
|
}
|
|
5257
|
-
logger
|
|
5272
|
+
logger.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5258
5273
|
|
|
5259
5274
|
try {
|
|
5260
5275
|
await CallApi.cancelCall(callSession);
|
|
@@ -5265,7 +5280,7 @@ class CTIPhone extends Emitter {
|
|
|
5265
5280
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
5266
5281
|
return true;
|
|
5267
5282
|
} catch (e) {
|
|
5268
|
-
logger
|
|
5283
|
+
logger.error('hangup CTI call, error', e);
|
|
5269
5284
|
|
|
5270
5285
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
5271
5286
|
return false;
|
|
@@ -5278,7 +5293,7 @@ class CTIPhone extends Emitter {
|
|
|
5278
5293
|
if (!callSession) {
|
|
5279
5294
|
return;
|
|
5280
5295
|
}
|
|
5281
|
-
logger
|
|
5296
|
+
logger.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5282
5297
|
|
|
5283
5298
|
await CallApi.cancelCall(callSession);
|
|
5284
5299
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -5288,7 +5303,7 @@ class CTIPhone extends Emitter {
|
|
|
5288
5303
|
if (!callSession) {
|
|
5289
5304
|
return;
|
|
5290
5305
|
}
|
|
5291
|
-
logger
|
|
5306
|
+
logger.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
5292
5307
|
|
|
5293
5308
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
5294
5309
|
}
|
|
@@ -5301,19 +5316,19 @@ class CTIPhone extends Emitter {
|
|
|
5301
5316
|
if (!callSession) {
|
|
5302
5317
|
return;
|
|
5303
5318
|
}
|
|
5304
|
-
logger
|
|
5319
|
+
logger.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
5305
5320
|
|
|
5306
5321
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
5307
5322
|
}
|
|
5308
5323
|
|
|
5309
5324
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
5310
|
-
logger
|
|
5325
|
+
logger.info('cancel CTI transfer', { transferId });
|
|
5311
5326
|
|
|
5312
5327
|
return CallApi.cancelCallTransfer(transferId);
|
|
5313
5328
|
}
|
|
5314
5329
|
|
|
5315
5330
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
5316
|
-
logger
|
|
5331
|
+
logger.info('confirm CTI transfer', { transferId });
|
|
5317
5332
|
|
|
5318
5333
|
return CallApi.confirmCallTransfer(transferId);
|
|
5319
5334
|
}
|
|
@@ -5322,19 +5337,19 @@ class CTIPhone extends Emitter {
|
|
|
5322
5337
|
if (!callSession) {
|
|
5323
5338
|
return;
|
|
5324
5339
|
}
|
|
5325
|
-
logger
|
|
5340
|
+
logger.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
5326
5341
|
|
|
5327
5342
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
5328
5343
|
}
|
|
5329
5344
|
|
|
5330
5345
|
onConnectionMade() {
|
|
5331
|
-
logger
|
|
5346
|
+
logger.info('on CTI connection made');
|
|
5332
5347
|
|
|
5333
5348
|
this.eventEmitter.emit('onCallAccepted');
|
|
5334
5349
|
}
|
|
5335
5350
|
|
|
5336
5351
|
async close() {
|
|
5337
|
-
logger
|
|
5352
|
+
logger.info('CTI close');
|
|
5338
5353
|
|
|
5339
5354
|
return Promise.resolve();
|
|
5340
5355
|
}
|
|
@@ -5343,7 +5358,7 @@ class CTIPhone extends Emitter {
|
|
|
5343
5358
|
if (!callSession) {
|
|
5344
5359
|
return;
|
|
5345
5360
|
}
|
|
5346
|
-
logger
|
|
5361
|
+
logger.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
5347
5362
|
|
|
5348
5363
|
return CallApi.hold(callSession.callId);
|
|
5349
5364
|
}
|
|
@@ -5352,7 +5367,7 @@ class CTIPhone extends Emitter {
|
|
|
5352
5367
|
if (!callSession) {
|
|
5353
5368
|
return;
|
|
5354
5369
|
}
|
|
5355
|
-
logger
|
|
5370
|
+
logger.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
5356
5371
|
|
|
5357
5372
|
return CallApi.resume(callSession.callId);
|
|
5358
5373
|
}
|
|
@@ -5361,7 +5376,7 @@ class CTIPhone extends Emitter {
|
|
|
5361
5376
|
if (!callSession) {
|
|
5362
5377
|
return;
|
|
5363
5378
|
}
|
|
5364
|
-
logger
|
|
5379
|
+
logger.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
5365
5380
|
|
|
5366
5381
|
return CallApi.mute(callSession.callId);
|
|
5367
5382
|
}
|
|
@@ -5370,7 +5385,7 @@ class CTIPhone extends Emitter {
|
|
|
5370
5385
|
if (!callSession) {
|
|
5371
5386
|
return;
|
|
5372
5387
|
}
|
|
5373
|
-
logger
|
|
5388
|
+
logger.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
5374
5389
|
|
|
5375
5390
|
return CallApi.unmute(callSession.callId);
|
|
5376
5391
|
}
|