@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
|
@@ -666,11 +666,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
666
666
|
|
|
667
667
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
668
668
|
|
|
669
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
669
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
670
670
|
|
|
671
671
|
// Use a function here to be able to mock it in tests
|
|
672
672
|
const realFetch = () => {
|
|
673
|
-
if (typeof document !== 'undefined') {
|
|
673
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
674
674
|
// Browser
|
|
675
675
|
return window.fetch;
|
|
676
676
|
}
|
|
@@ -805,7 +805,7 @@ class ApiRequester {
|
|
|
805
805
|
};
|
|
806
806
|
|
|
807
807
|
if (this.refreshTokenPromise) {
|
|
808
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
808
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
809
809
|
await this.refreshTokenPromise;
|
|
810
810
|
}
|
|
811
811
|
|
|
@@ -825,7 +825,7 @@ class ApiRequester {
|
|
|
825
825
|
return promise.then(async (err ) => {
|
|
826
826
|
// Check if the token is still valid
|
|
827
827
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
828
|
-
logger.warn('token expired', { error: err.reason });
|
|
828
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
829
829
|
// Replay the call after refreshing the token
|
|
830
830
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
831
831
|
}
|
|
@@ -835,7 +835,7 @@ class ApiRequester {
|
|
|
835
835
|
: exceptionClass.fromResponse(err, response.status);
|
|
836
836
|
|
|
837
837
|
if (this.shouldLogErrors) {
|
|
838
|
-
logger.error('API error', error);
|
|
838
|
+
logger$1.error('API error', error);
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
throw error;
|
|
@@ -845,7 +845,7 @@ class ApiRequester {
|
|
|
845
845
|
return newParse(response, isJson);
|
|
846
846
|
}).catch(error => {
|
|
847
847
|
if (this.shouldLogErrors) {
|
|
848
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
848
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
849
849
|
}
|
|
850
850
|
|
|
851
851
|
throw error;
|
|
@@ -873,13 +873,13 @@ class ApiRequester {
|
|
|
873
873
|
) {
|
|
874
874
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
875
875
|
let newPath = path;
|
|
876
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
876
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
877
877
|
|
|
878
878
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
879
879
|
|
|
880
880
|
return this.refreshTokenPromise.then(() => {
|
|
881
881
|
this.refreshTokenPromise = null;
|
|
882
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
882
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
883
883
|
if (isTokenNotFound) {
|
|
884
884
|
const pathParts = path.split('/');
|
|
885
885
|
pathParts.pop();
|
|
@@ -2119,7 +2119,7 @@ class Contact {
|
|
|
2119
2119
|
this[key] = old[key] || this[key];
|
|
2120
2120
|
});
|
|
2121
2121
|
|
|
2122
|
-
if (old.lineState
|
|
2122
|
+
if (old.lineState) {
|
|
2123
2123
|
this.lineState = old.lineState;
|
|
2124
2124
|
}
|
|
2125
2125
|
|
|
@@ -3586,7 +3586,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3586
3586
|
|
|
3587
3587
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3588
3588
|
|
|
3589
|
-
|
|
3589
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3590
3590
|
|
|
3591
3591
|
/* */
|
|
3592
3592
|
|
|
@@ -4505,7 +4505,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4505
4505
|
const WEBHOOKD_VERSION = '1.0';
|
|
4506
4506
|
const AMID_VERSION = '1.0';
|
|
4507
4507
|
|
|
4508
|
-
const logger
|
|
4508
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4509
4509
|
|
|
4510
4510
|
class ApiClient {
|
|
4511
4511
|
|
|
@@ -4557,12 +4557,12 @@ class ApiClient {
|
|
|
4557
4557
|
}
|
|
4558
4558
|
|
|
4559
4559
|
async forceRefreshToken() {
|
|
4560
|
-
logger
|
|
4560
|
+
logger.info('forcing refresh token, calling callback');
|
|
4561
4561
|
return this.refreshTokenCallback();
|
|
4562
4562
|
}
|
|
4563
4563
|
|
|
4564
4564
|
async refreshTokenCallback() {
|
|
4565
|
-
logger
|
|
4565
|
+
logger.info('refresh token callback called', {
|
|
4566
4566
|
refreshToken: this.refreshToken,
|
|
4567
4567
|
refreshBackend: this.refreshBackend,
|
|
4568
4568
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4580,7 +4580,7 @@ class ApiClient {
|
|
|
4580
4580
|
this.isMobile,
|
|
4581
4581
|
);
|
|
4582
4582
|
|
|
4583
|
-
logger
|
|
4583
|
+
logger.info('token refreshed', { token: session.token });
|
|
4584
4584
|
|
|
4585
4585
|
if (this.onRefreshToken) {
|
|
4586
4586
|
this.onRefreshToken(session.token, session);
|
package/lib/domain/CallLog.js
CHANGED
|
@@ -39,8 +39,10 @@ var updateFrom = (instance , from ) => {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
|
|
42
43
|
|
|
43
44
|
|
|
45
|
+
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
|
|
@@ -57,6 +59,7 @@ var updateFrom = (instance , from ) => {
|
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
|
|
62
|
+
|
|
60
63
|
|
|
61
64
|
|
|
62
65
|
class CallSession {
|
|
@@ -76,8 +79,12 @@ class CallSession {
|
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
|
|
82
|
+
|
|
83
|
+
|
|
79
84
|
|
|
80
85
|
|
|
86
|
+
|
|
87
|
+
|
|
81
88
|
|
|
82
89
|
|
|
83
90
|
|
|
@@ -115,6 +122,8 @@ class CallSession {
|
|
|
115
122
|
|
|
116
123
|
|
|
117
124
|
|
|
125
|
+
|
|
126
|
+
|
|
118
127
|
|
|
119
128
|
constructor({
|
|
120
129
|
answered,
|
|
@@ -128,6 +137,8 @@ class CallSession {
|
|
|
128
137
|
paused,
|
|
129
138
|
ringing,
|
|
130
139
|
startTime,
|
|
140
|
+
creationTime,
|
|
141
|
+
endTime,
|
|
131
142
|
cameraEnabled,
|
|
132
143
|
dialedExtension,
|
|
133
144
|
sipCallId,
|
|
@@ -140,12 +151,15 @@ class CallSession {
|
|
|
140
151
|
recording,
|
|
141
152
|
recordingPaused,
|
|
142
153
|
videoRemotelyDowngraded,
|
|
154
|
+
sipSession,
|
|
143
155
|
} ) {
|
|
144
156
|
this.callId = callId;
|
|
145
157
|
this.sipCallId = sipCallId;
|
|
146
158
|
this.displayName = displayName;
|
|
147
159
|
this.number = number;
|
|
160
|
+
this.creationTime = creationTime;
|
|
148
161
|
this.startTime = startTime;
|
|
162
|
+
this.endTime = endTime;
|
|
149
163
|
this.isCaller = isCaller;
|
|
150
164
|
this.answered = answered;
|
|
151
165
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -164,6 +178,7 @@ class CallSession {
|
|
|
164
178
|
this.recording = recording || false;
|
|
165
179
|
this.recordingPaused = recordingPaused || false;
|
|
166
180
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
181
|
+
this.sipSession = sipSession;
|
|
167
182
|
|
|
168
183
|
// Useful to compare instead of instanceof with minified code
|
|
169
184
|
this.type = 'CallSession';
|
package/lib/domain/Contact.js
CHANGED
|
@@ -48,7 +48,7 @@ const LINE_STATE = {
|
|
|
48
48
|
|
|
49
49
|
//
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
52
52
|
|
|
53
53
|
//
|
|
54
54
|
|
|
@@ -702,7 +702,7 @@ class Contact {
|
|
|
702
702
|
this[key] = old[key] || this[key];
|
|
703
703
|
});
|
|
704
704
|
|
|
705
|
-
if (old.lineState
|
|
705
|
+
if (old.lineState) {
|
|
706
706
|
this.lineState = old.lineState;
|
|
707
707
|
}
|
|
708
708
|
|
package/lib/domain/Features.js
CHANGED
|
@@ -448,11 +448,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
448
448
|
|
|
449
449
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
450
450
|
|
|
451
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
451
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
452
452
|
|
|
453
453
|
// Use a function here to be able to mock it in tests
|
|
454
454
|
const realFetch = () => {
|
|
455
|
-
if (typeof document !== 'undefined') {
|
|
455
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
456
456
|
// Browser
|
|
457
457
|
return window.fetch;
|
|
458
458
|
}
|
|
@@ -587,7 +587,7 @@ class ApiRequester {
|
|
|
587
587
|
};
|
|
588
588
|
|
|
589
589
|
if (this.refreshTokenPromise) {
|
|
590
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
590
|
+
logger$1.info('A token is already refreshing, waiting ...', { url });
|
|
591
591
|
await this.refreshTokenPromise;
|
|
592
592
|
}
|
|
593
593
|
|
|
@@ -607,7 +607,7 @@ class ApiRequester {
|
|
|
607
607
|
return promise.then(async (err ) => {
|
|
608
608
|
// Check if the token is still valid
|
|
609
609
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
610
|
-
logger.warn('token expired', { error: err.reason });
|
|
610
|
+
logger$1.warn('token expired', { error: err.reason });
|
|
611
611
|
// Replay the call after refreshing the token
|
|
612
612
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
613
613
|
}
|
|
@@ -617,7 +617,7 @@ class ApiRequester {
|
|
|
617
617
|
: exceptionClass.fromResponse(err, response.status);
|
|
618
618
|
|
|
619
619
|
if (this.shouldLogErrors) {
|
|
620
|
-
logger.error('API error', error);
|
|
620
|
+
logger$1.error('API error', error);
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
throw error;
|
|
@@ -627,7 +627,7 @@ class ApiRequester {
|
|
|
627
627
|
return newParse(response, isJson);
|
|
628
628
|
}).catch(error => {
|
|
629
629
|
if (this.shouldLogErrors) {
|
|
630
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
630
|
+
logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
631
631
|
}
|
|
632
632
|
|
|
633
633
|
throw error;
|
|
@@ -655,13 +655,13 @@ class ApiRequester {
|
|
|
655
655
|
) {
|
|
656
656
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
657
657
|
let newPath = path;
|
|
658
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
658
|
+
logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
659
659
|
|
|
660
660
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
661
661
|
|
|
662
662
|
return this.refreshTokenPromise.then(() => {
|
|
663
663
|
this.refreshTokenPromise = null;
|
|
664
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
664
|
+
logger$1.info('token refreshed', { isTokenNotFound });
|
|
665
665
|
if (isTokenNotFound) {
|
|
666
666
|
const pathParts = path.split('/');
|
|
667
667
|
pathParts.pop();
|
|
@@ -1912,7 +1912,7 @@ class Contact {
|
|
|
1912
1912
|
this[key] = old[key] || this[key];
|
|
1913
1913
|
});
|
|
1914
1914
|
|
|
1915
|
-
if (old.lineState
|
|
1915
|
+
if (old.lineState) {
|
|
1916
1916
|
this.lineState = old.lineState;
|
|
1917
1917
|
}
|
|
1918
1918
|
|
|
@@ -3588,7 +3588,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3588
3588
|
|
|
3589
3589
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3590
3590
|
|
|
3591
|
-
|
|
3591
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3592
3592
|
|
|
3593
3593
|
/* */
|
|
3594
3594
|
|
|
@@ -4507,7 +4507,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
4507
4507
|
const WEBHOOKD_VERSION = '1.0';
|
|
4508
4508
|
const AMID_VERSION = '1.0';
|
|
4509
4509
|
|
|
4510
|
-
const logger
|
|
4510
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
4511
4511
|
|
|
4512
4512
|
class ApiClient {
|
|
4513
4513
|
|
|
@@ -4559,12 +4559,12 @@ class ApiClient {
|
|
|
4559
4559
|
}
|
|
4560
4560
|
|
|
4561
4561
|
async forceRefreshToken() {
|
|
4562
|
-
logger
|
|
4562
|
+
logger.info('forcing refresh token, calling callback');
|
|
4563
4563
|
return this.refreshTokenCallback();
|
|
4564
4564
|
}
|
|
4565
4565
|
|
|
4566
4566
|
async refreshTokenCallback() {
|
|
4567
|
-
logger
|
|
4567
|
+
logger.info('refresh token callback called', {
|
|
4568
4568
|
refreshToken: this.refreshToken,
|
|
4569
4569
|
refreshBackend: this.refreshBackend,
|
|
4570
4570
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -4582,7 +4582,7 @@ class ApiClient {
|
|
|
4582
4582
|
this.isMobile,
|
|
4583
4583
|
);
|
|
4584
4584
|
|
|
4585
|
-
logger
|
|
4585
|
+
logger.info('token refreshed', { token: session.token });
|
|
4586
4586
|
|
|
4587
4587
|
if (this.onRefreshToken) {
|
|
4588
4588
|
this.onRefreshToken(session.token, session);
|
|
@@ -1226,7 +1226,7 @@ class Contact {
|
|
|
1226
1226
|
this[key] = old[key] || this[key];
|
|
1227
1227
|
});
|
|
1228
1228
|
|
|
1229
|
-
if (old.lineState
|
|
1229
|
+
if (old.lineState) {
|
|
1230
1230
|
this.lineState = old.lineState;
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
@@ -1720,8 +1720,10 @@ var updateFrom = (instance , from ) => {
|
|
|
1720
1720
|
|
|
1721
1721
|
|
|
1722
1722
|
|
|
1723
|
+
|
|
1723
1724
|
|
|
1724
1725
|
|
|
1726
|
+
|
|
1725
1727
|
|
|
1726
1728
|
|
|
1727
1729
|
|
|
@@ -1738,6 +1740,7 @@ var updateFrom = (instance , from ) => {
|
|
|
1738
1740
|
|
|
1739
1741
|
|
|
1740
1742
|
|
|
1743
|
+
|
|
1741
1744
|
|
|
1742
1745
|
|
|
1743
1746
|
class CallSession {
|
|
@@ -1757,8 +1760,12 @@ class CallSession {
|
|
|
1757
1760
|
|
|
1758
1761
|
|
|
1759
1762
|
|
|
1763
|
+
|
|
1764
|
+
|
|
1760
1765
|
|
|
1761
1766
|
|
|
1767
|
+
|
|
1768
|
+
|
|
1762
1769
|
|
|
1763
1770
|
|
|
1764
1771
|
|
|
@@ -1796,6 +1803,8 @@ class CallSession {
|
|
|
1796
1803
|
|
|
1797
1804
|
|
|
1798
1805
|
|
|
1806
|
+
|
|
1807
|
+
|
|
1799
1808
|
|
|
1800
1809
|
constructor({
|
|
1801
1810
|
answered,
|
|
@@ -1809,6 +1818,8 @@ class CallSession {
|
|
|
1809
1818
|
paused,
|
|
1810
1819
|
ringing,
|
|
1811
1820
|
startTime,
|
|
1821
|
+
creationTime,
|
|
1822
|
+
endTime,
|
|
1812
1823
|
cameraEnabled,
|
|
1813
1824
|
dialedExtension,
|
|
1814
1825
|
sipCallId,
|
|
@@ -1821,12 +1832,15 @@ class CallSession {
|
|
|
1821
1832
|
recording,
|
|
1822
1833
|
recordingPaused,
|
|
1823
1834
|
videoRemotelyDowngraded,
|
|
1835
|
+
sipSession,
|
|
1824
1836
|
} ) {
|
|
1825
1837
|
this.callId = callId;
|
|
1826
1838
|
this.sipCallId = sipCallId;
|
|
1827
1839
|
this.displayName = displayName;
|
|
1828
1840
|
this.number = number;
|
|
1841
|
+
this.creationTime = creationTime;
|
|
1829
1842
|
this.startTime = startTime;
|
|
1843
|
+
this.endTime = endTime;
|
|
1830
1844
|
this.isCaller = isCaller;
|
|
1831
1845
|
this.answered = answered;
|
|
1832
1846
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -1845,6 +1859,7 @@ class CallSession {
|
|
|
1845
1859
|
this.recording = recording || false;
|
|
1846
1860
|
this.recordingPaused = recordingPaused || false;
|
|
1847
1861
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
1862
|
+
this.sipSession = sipSession;
|
|
1848
1863
|
|
|
1849
1864
|
// Useful to compare instead of instanceof with minified code
|
|
1850
1865
|
this.type = 'CallSession';
|
|
@@ -2842,11 +2857,11 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
2842
2857
|
|
|
2843
2858
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
2844
2859
|
|
|
2845
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2860
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
2846
2861
|
|
|
2847
2862
|
// Use a function here to be able to mock it in tests
|
|
2848
2863
|
const realFetch = () => {
|
|
2849
|
-
if (typeof document !== 'undefined') {
|
|
2864
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
2850
2865
|
// Browser
|
|
2851
2866
|
return window.fetch;
|
|
2852
2867
|
}
|
|
@@ -2981,7 +2996,7 @@ class ApiRequester {
|
|
|
2981
2996
|
};
|
|
2982
2997
|
|
|
2983
2998
|
if (this.refreshTokenPromise) {
|
|
2984
|
-
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2999
|
+
logger$2.info('A token is already refreshing, waiting ...', { url });
|
|
2985
3000
|
await this.refreshTokenPromise;
|
|
2986
3001
|
}
|
|
2987
3002
|
|
|
@@ -3001,7 +3016,7 @@ class ApiRequester {
|
|
|
3001
3016
|
return promise.then(async (err ) => {
|
|
3002
3017
|
// Check if the token is still valid
|
|
3003
3018
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
3004
|
-
logger.warn('token expired', { error: err.reason });
|
|
3019
|
+
logger$2.warn('token expired', { error: err.reason });
|
|
3005
3020
|
// Replay the call after refreshing the token
|
|
3006
3021
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
3007
3022
|
}
|
|
@@ -3011,7 +3026,7 @@ class ApiRequester {
|
|
|
3011
3026
|
: exceptionClass.fromResponse(err, response.status);
|
|
3012
3027
|
|
|
3013
3028
|
if (this.shouldLogErrors) {
|
|
3014
|
-
logger.error('API error', error);
|
|
3029
|
+
logger$2.error('API error', error);
|
|
3015
3030
|
}
|
|
3016
3031
|
|
|
3017
3032
|
throw error;
|
|
@@ -3021,7 +3036,7 @@ class ApiRequester {
|
|
|
3021
3036
|
return newParse(response, isJson);
|
|
3022
3037
|
}).catch(error => {
|
|
3023
3038
|
if (this.shouldLogErrors) {
|
|
3024
|
-
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
3039
|
+
logger$2.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
3025
3040
|
}
|
|
3026
3041
|
|
|
3027
3042
|
throw error;
|
|
@@ -3049,13 +3064,13 @@ class ApiRequester {
|
|
|
3049
3064
|
) {
|
|
3050
3065
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
3051
3066
|
let newPath = path;
|
|
3052
|
-
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
3067
|
+
logger$2.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
3053
3068
|
|
|
3054
3069
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
3055
3070
|
|
|
3056
3071
|
return this.refreshTokenPromise.then(() => {
|
|
3057
3072
|
this.refreshTokenPromise = null;
|
|
3058
|
-
logger.info('token refreshed', { isTokenNotFound });
|
|
3073
|
+
logger$2.info('token refreshed', { isTokenNotFound });
|
|
3059
3074
|
if (isTokenNotFound) {
|
|
3060
3075
|
const pathParts = path.split('/');
|
|
3061
3076
|
pathParts.pop();
|
|
@@ -5143,7 +5158,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
5143
5158
|
|
|
5144
5159
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
5145
5160
|
|
|
5146
|
-
const logger
|
|
5161
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
5147
5162
|
|
|
5148
5163
|
class CTIPhone extends Emitter {
|
|
5149
5164
|
|
|
@@ -5156,7 +5171,7 @@ class CTIPhone extends Emitter {
|
|
|
5156
5171
|
|
|
5157
5172
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
5158
5173
|
super();
|
|
5159
|
-
logger
|
|
5174
|
+
logger.info('CTI Phone created');
|
|
5160
5175
|
this.session = session;
|
|
5161
5176
|
this.isMobile = isMobile;
|
|
5162
5177
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -5217,7 +5232,7 @@ class CTIPhone extends Emitter {
|
|
|
5217
5232
|
}
|
|
5218
5233
|
|
|
5219
5234
|
async makeCall(number , line ) {
|
|
5220
|
-
logger
|
|
5235
|
+
logger.info('make CTI call', { number });
|
|
5221
5236
|
|
|
5222
5237
|
if (!number) {
|
|
5223
5238
|
return null;
|
|
@@ -5240,7 +5255,7 @@ class CTIPhone extends Emitter {
|
|
|
5240
5255
|
if (!callSession) {
|
|
5241
5256
|
return Promise.resolve(null);
|
|
5242
5257
|
}
|
|
5243
|
-
logger
|
|
5258
|
+
logger.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5244
5259
|
|
|
5245
5260
|
if (!this.currentCall) {
|
|
5246
5261
|
this.currentCall = callSession.call;
|
|
@@ -5253,7 +5268,7 @@ class CTIPhone extends Emitter {
|
|
|
5253
5268
|
if (!callSession) {
|
|
5254
5269
|
return;
|
|
5255
5270
|
}
|
|
5256
|
-
logger
|
|
5271
|
+
logger.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5257
5272
|
|
|
5258
5273
|
this.currentCall = undefined;
|
|
5259
5274
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -5263,7 +5278,7 @@ class CTIPhone extends Emitter {
|
|
|
5263
5278
|
if (!callSession) {
|
|
5264
5279
|
return Promise.resolve(false);
|
|
5265
5280
|
}
|
|
5266
|
-
logger
|
|
5281
|
+
logger.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5267
5282
|
|
|
5268
5283
|
try {
|
|
5269
5284
|
await CallApi.cancelCall(callSession);
|
|
@@ -5274,7 +5289,7 @@ class CTIPhone extends Emitter {
|
|
|
5274
5289
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
5275
5290
|
return true;
|
|
5276
5291
|
} catch (e) {
|
|
5277
|
-
logger
|
|
5292
|
+
logger.error('hangup CTI call, error', e);
|
|
5278
5293
|
|
|
5279
5294
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
5280
5295
|
return false;
|
|
@@ -5287,7 +5302,7 @@ class CTIPhone extends Emitter {
|
|
|
5287
5302
|
if (!callSession) {
|
|
5288
5303
|
return;
|
|
5289
5304
|
}
|
|
5290
|
-
logger
|
|
5305
|
+
logger.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
5291
5306
|
|
|
5292
5307
|
await CallApi.cancelCall(callSession);
|
|
5293
5308
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -5297,7 +5312,7 @@ class CTIPhone extends Emitter {
|
|
|
5297
5312
|
if (!callSession) {
|
|
5298
5313
|
return;
|
|
5299
5314
|
}
|
|
5300
|
-
logger
|
|
5315
|
+
logger.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
5301
5316
|
|
|
5302
5317
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
5303
5318
|
}
|
|
@@ -5310,19 +5325,19 @@ class CTIPhone extends Emitter {
|
|
|
5310
5325
|
if (!callSession) {
|
|
5311
5326
|
return;
|
|
5312
5327
|
}
|
|
5313
|
-
logger
|
|
5328
|
+
logger.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
5314
5329
|
|
|
5315
5330
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
5316
5331
|
}
|
|
5317
5332
|
|
|
5318
5333
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
5319
|
-
logger
|
|
5334
|
+
logger.info('cancel CTI transfer', { transferId });
|
|
5320
5335
|
|
|
5321
5336
|
return CallApi.cancelCallTransfer(transferId);
|
|
5322
5337
|
}
|
|
5323
5338
|
|
|
5324
5339
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
5325
|
-
logger
|
|
5340
|
+
logger.info('confirm CTI transfer', { transferId });
|
|
5326
5341
|
|
|
5327
5342
|
return CallApi.confirmCallTransfer(transferId);
|
|
5328
5343
|
}
|
|
@@ -5331,19 +5346,19 @@ class CTIPhone extends Emitter {
|
|
|
5331
5346
|
if (!callSession) {
|
|
5332
5347
|
return;
|
|
5333
5348
|
}
|
|
5334
|
-
logger
|
|
5349
|
+
logger.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
5335
5350
|
|
|
5336
5351
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
5337
5352
|
}
|
|
5338
5353
|
|
|
5339
5354
|
onConnectionMade() {
|
|
5340
|
-
logger
|
|
5355
|
+
logger.info('on CTI connection made');
|
|
5341
5356
|
|
|
5342
5357
|
this.eventEmitter.emit('onCallAccepted');
|
|
5343
5358
|
}
|
|
5344
5359
|
|
|
5345
5360
|
async close() {
|
|
5346
|
-
logger
|
|
5361
|
+
logger.info('CTI close');
|
|
5347
5362
|
|
|
5348
5363
|
return Promise.resolve();
|
|
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 hold', { callId: callSession.getId(), number: callSession.number });
|
|
5356
5371
|
|
|
5357
5372
|
return CallApi.hold(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 resume', { callId: callSession.getId(), number: callSession.number });
|
|
5365
5380
|
|
|
5366
5381
|
return CallApi.resume(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 mute', { callId: callSession.getId(), number: callSession.number });
|
|
5374
5389
|
|
|
5375
5390
|
return CallApi.mute(callSession.callId);
|
|
5376
5391
|
}
|
|
@@ -5379,7 +5394,7 @@ class CTIPhone extends Emitter {
|
|
|
5379
5394
|
if (!callSession) {
|
|
5380
5395
|
return;
|
|
5381
5396
|
}
|
|
5382
|
-
logger
|
|
5397
|
+
logger.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
5383
5398
|
|
|
5384
5399
|
return CallApi.unmute(callSession.callId);
|
|
5385
5400
|
}
|